+++ /dev/null
-#!/system/bin/sh
-#
-# 'ls greybus'
-#
-# Copyright 2016 Google Inc.
-# All rights reserved.
-#
-###############################################################################
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-# 1. Redistributions of source code must retain the above copyright notice,
-# this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright notice,
-# this list of conditions and the following disclaimer in the documentation
-# and/or other materials provided with the distribution.
-# 3. Neither the name of the copyright holder nor the names of its
-# contributors may be used to endorse or promote products derived from this
-# software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-###############################################################################
-
-# Horrid hack to just make it easier than poking around directly in sysfs
-# Don't rely on any of these fields to be stable, the layout is going to
-# change a lot over time.
-#
-
-print_interface() {
- local devname=$1
- local iid=`cat interface_id`
- local vid=`cat vendor_id`
- local pid=`cat product_id`
- local version=`cat version`
- local serial=`cat serial_number`
- local vs=`cat vendor_string`
- local ps=`cat product_string`
- printf " Intf %02d %s:%s %s %s v%s\n" \
- ${iid} ${vid} ${pid} "${vs}" "${ps}" ${version}
-}
-
-print_bundle() {
- local devname=$1
- local id=`cat bundle_id`
- local class=`cat bundle_class`
- local class_type="unknown"
- case ${class} in
- "0x01" ) class_type="SVC"
- ;;
- "0x02" ) class_type="GPIO"
- ;;
- "0x03" ) class_type="I2C"
- ;;
- "0x04" ) class_type="UART"
- ;;
- "0x05" ) class_type="HID"
- ;;
- "0x06" ) class_type="USB"
- ;;
- "0x07" ) class_type="SDIO"
- ;;
- "0x08" ) class_type="Power Supply"
- ;;
- "0x09" ) class_type="PWM"
- ;;
- "0x0a" ) class_type="unknown"
- ;;
- "0x0b" ) class_type="SPI"
- ;;
- "0x0c" ) class_type="Display"
- ;;
- "0x0d" ) class_type="Camera"
- ;;
- "0x0e" ) class_type="Sensoe"
- ;;
- "0x0f" ) class_type="Lights"
- ;;
- "0x10" ) class_type="Vibrator"
- ;;
- "0x11" ) class_type="Loopback"
- ;;
- "0x12" ) class_type="Audio Management"
- ;;
- "0x13" ) class_type="Audio Data"
- ;;
- "0x14" ) class_type="SVC"
- ;;
- "0x15" ) class_type="Firmware"
- ;;
- "0xfe" ) class_type="Raw"
- ;;
- "0xff" ) class_type="Vendor"
- ;;
- esac
- printf " Bundle %02d Class %s (%s)\n" ${id} ${class} ${class_type}
-}
-
-print_svc() {
- local devname=$1
- local bus=`cat uevent | grep BUS | cut -f 2 -d '='`
- printf " SVC %02d\n" ${bus}
-}
-
-print_host_device() {
- local devname=$1
- local bus=`cat uevent | grep BUS | cut -f 2 -d '='`
- printf "Bus %02d\n" ${bus}
-}
-
-print_unknown() {
- local devname=$1
-
- printf "Unknown device type: ${devname}\n"
-}
-
-
-print_device() {
- local dev=$1
-
- [ -d $dev ] || return
- cd $dev
-
- local devname=`basename ${dev}`
- local devtype=`cat uevent | grep DEVTYPE | cut -f 2 -d '='`
- case ${devtype} in
- greybus_interface ) print_interface ${devname}
- ;;
- greybus_bundle ) print_bundle ${devname}
- ;;
- greybus_svc ) print_svc ${devname}
- ;;
- greybus_host_device ) print_host_device ${devname}
- ;;
- * ) print_unknown ${devname}
- ;;
- esac
-}
-
-for device in /sys/bus/greybus/devices/*
-do
- print_device $device
-done