Commit graph

71 commits

Author SHA1 Message Date
Greg Kroah-Hartman eb50fd3a22 staging: greybus: add SPDX identifiers to all greybus driver files
It's good to have SPDX identifiers in all files to make it easier to
audit the kernel tree for correct licenses.

Update the drivers/staging/greybus files files with the correct SPDX
license identifier based on the license text in the file itself.  The
SPDX identifier is a legally binding shorthand, which can be used
instead of the full boiler plate text.

This work is based on a script and data from Thomas Gleixner, Philippe
Ombredanne, and Kate Stewart.

Cc: Vaibhav Hiremath <hvaibhav.linux@gmail.com>
Cc: "Bryan O'Donoghue" <pure.logic@nexus-software.ie>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Acked-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Acked-by: David Lin <dtwlin@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Acked-by: Johan Hovold <johan@kernel.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-11 14:46:20 +01:00
Michael Sartain 4da14d5922 staging: greybus: firmware: Convert sscanf calls to strtoul
Also convert the fw_update_type and fw_timeout variables to
unsigned and update the printf specifier to %u.

The FW_MGMT_IOC_SET_TIMEOUT_MS ioctl takes an unsigned int
and checkpatch was complaining about not checking the sscanf
return values.

Signed-off-by: Michael Sartain <mikesart@fastmail.com>
Acked-by: Viresh Kumar <viresh.kumar at linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-09 19:29:50 +01:00
Michael Sartain afb5fdfc12 staging: greybus: firmware: Change long long unsigned to unsigned long long
Fixes checkpatch warning:
  type 'long long unsigned int' should be specified
  in [[un]signed] [short|int|long|long long] order

Signed-off-by: Michael Sartain <mikesart@fastmail.com>
Acked-by: Viresh Kumar <viresh.kumar at linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-09 19:29:50 +01:00
Michael Sartain 5099c4c4a6 staging: greybus: firmware: Remove extra braces from single line if
Fixes checkpatch warning:
  braces {} are not necessary for any arm of this statement

Signed-off-by: Michael Sartain <mikesart@fastmail.com>
Acked-by: Viresh Kumar <viresh.kumar at linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-09 19:29:50 +01:00
Michael Sartain 0c3801875c staging: greybus: firmware: Remove trailing semicolon from FW_TIMEOUT_DEFAULT
Fixes checkpatch warning:
  macros should not use a trailing semicolon

Signed-off-by: Michael Sartain <mikesart@fastmail.com>
Acked-by: Viresh Kumar <viresh.kumar at linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-09 19:29:50 +01:00
Greg Kroah-Hartman 526dec0642 staging: greybus: remove old es1 endpoint description
The Toshiba ES1 chip is no longer around, so remove the USB descriptor
documentation for it as no one cares anymore.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 12:40:33 +02:00
Greg Kroah-Hartman bc5aa3a079 staging: greybus: Documentation: remove sysfs tree
We do not need an example of the sysfs tree in the kernel code itself,
so remove these files, as they are now pointless.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 12:35:16 +02:00
Viresh Kumar b2abeaa10d greybus: firmware: s/_LEN/_SIZE
Alex Elder pointed out that the macros also count the trailing NULL
('\0') character and so it should be using SIZE instead of LEN.

This patch makes that change.

Reported-by: Alex Elder <alex.elder@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-12 17:38:19 +02:00
Viresh Kumar d581bc88cb greybus: firmware: Fix typo in documentation
s/shall be used the user/shall be used by the user/

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-08-11 14:14:54 +02:00
Johan Hovold 6c298035a1 greybus: Documentation/sysfs: replace Ara references
Refer to the MDK as GMP MDK.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-28 07:30:13 -07:00
David Lin 7c4a0edb38 greybus: svc_watchdog: Add sysfs file to change the behavior of bite
Currently, AP performs unipro_reset if SVC fails to response to its
ping. While this error recovery is best suited for the end-user
experience, errors in the UniPro network could potentially go unnoticed
by the QA and fishfooders in the development phase of the project. This
patch adds an option to trigger a kernel panic so logs can be collected
for analysis.

Testing Done:
 - Reproduce issue and observe kernel panic when
   watchdob_control is changed to 'panic'

Signed-off-by: David Lin <dtwlin@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-26 20:58:37 -07:00
Viresh Kumar 6136cce89c greybus: firmware: Update Documentation and sample application
Update documentation and sample application to capture the 'status' byte
in backend version operation and new error types in backend firmware
update operation.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-26 16:16:15 -07:00
Viresh Kumar adac4b9594 greybus: firmware: Improve test application
It can take arguments not and we can perform all the operations with a
single binary, sorry for missing that initially.

Usage: ./firmware <gb-fw-mgmt-X> <type: interface/backend> <firmware-tag> <timeout>

And all of them have default values, etc.

Tested with a semco 13 MP module.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-21 19:00:26 -07:00
Johan Hovold e21e6bad3f greybus: interface: fix power_state documentation
Reword the power_state attribute documentation to make it clear that an
attempt to boot and possibly enumerate an interface is made when writing
"on" to the file, and that on errors the interface will again be powered
down.

Drop the incorrect claim that writing the currently read value has no
effect, since no such guarantees can be made (e.g. several writers may
be sleeping on the interface mutex).

Also fix some minor language issues.

Reviewed-by: Sandeep Patil <sspatil@google.com>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Patrick Titiano <ptitiano@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-20 10:16:54 -07:00
Viresh Kumar 93e29c8530 greybus: interface: add power_state attribute
User space needs the capability of powering ON or OFF an Interface for
multiple use cases. For example, userspace may want an Interface
currently in its S3 boot stage, to boot into its S2 Loader stage to
update the bridge SPI flash. Or the Interface is running its S2 Loader
stage and updated the SPI flash with the new S2 Loader firmware and
wants to boot into the new S2 Loader firmware.

Another use case can be, Android wants to disable (not eject) a
misbehaving module.

Add a 'power_state' sysfs file within the interface directory. It can be
read to know the current power state of the Interface and can be written
to power ON or power OFF an Interface. Possible values that can be
written or read from it are: "on" and "off".

Testing Done: Tested by enabling/disabling camera module on EVT 2.0.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
CC: David Lin <dtwlin@google.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
[johan: drop es3-quirk duplication, add to power attribute group, fix
return value, drop tags ]
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Sandeep Patil <sspatil@google.com>
Reviewed-by: Patrick Titiano <ptitiano@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-20 10:16:54 -07:00
Johan Hovold 1bb61840c4 greybus: interface: add interface-type attribute
Add an interface-type string attribute that represents the detected
interface type as either "dummy", "unipro", "greybus", or "unknown".

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Sandeep Patil <sspatil@google.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-07-19 19:03:32 -07:00
Viresh Kumar 6f4219dd7d greybus: Documentation: Document Authentication interfaces
This patch defined userspace interface of the CAP protocol.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Jun Li <li_jun@projectara.com>
Tested-by: Jun Li <li_jun@projectara.com>
Signed-off-by: Alex Elder <elder@linaro.org>
2016-07-06 17:51:32 -05:00
Viresh Kumar 4ee48a5ecb greybus: firmware: prefix char-device with 'gb-'
This will make it consistent with any other character devices we have
for greybus and let us identify greybus character devices easily.

Compiled tested only.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-06-16 10:13:20 -07:00
Viresh Kumar df124299d1 greybus: firmware: Add license and copyright header to application
Add license and copyright header to the firmware.c test application.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-06-16 00:03:43 -07:00
Viresh Kumar 6554efa28e greybus: firmware: Fix spelling mistake
s/directly/directory :)

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-06-10 16:32:33 -07:00
Viresh Kumar 7a9a5bf01e greybus: Documentation/sysfs: gbphy0 is an invalid name
The numbering of gbphy devices is going to start from 1 and not 0.
Reflect the same in sysfs hierarchy.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-26 22:33:27 -07:00
Viresh Kumar 71b7a36072 greybus: Documentation/sysfs: Rename gpbridge to gbphy
These were left in the earlier renaming series, fix them as well.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-26 22:33:27 -07:00
Viresh Kumar 7bf7fa12fc greybus: Documentation: Document firmware-management interfaces
This patch adds a new 'firmware' folder in Documentation, which contains
two files:

- firmware-management: This describes the userspace interface for
  interacting with firmware-management bundle.

- firmware.c: Sample application to test firmware load for Interface
  Firmware and firmware updates to Backend Interface Firmware.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Jun Li <li_jun@projectara.com>
Tested-by: Karthik Ravi Shankar <karthikrs@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-15 00:23:52 +02:00
Vaibhav Hiremath ceadf9def1 greybus: Documentation: Add sysfs information about bridged-phy device
Update the documentation (sysfs-bus-greybus) for recent conversion of
bridged-phy drivers to real drivers.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-05 13:38:57 -07:00
Viresh Kumar 0decdd55b3 greybus: Revert "interface: Fetch and expose version of interface's firmware"
This reverts commit b957ade7b3e4ab8c149c53346dbf02e977b7f3a7.

The interface version is now managed as part of the firmware-management
protocol. This operation is already removed from the greybus
specifications.

Drop interface version support from greybus.

Tested with gbsim (sysfs file not available after this patch).

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Acked-by: Sandeep Patil <sspatil@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-05 13:33:20 -07:00
Sandeep Patil 16ba59cedf greybus: Documentation/sysfs: fix sysfs paths
correct sysfs paths typo. (s/device/devices).

Signed-off-by: Sandeep Patil <sspatil@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-29 14:09:44 -07:00
Sandeep Patil dc9e9cf450 greybus: Documentation/sysfs: add entry for host device bus_id
Add description for greybus host device bus_id attribute

Signed-off-by: Sandeep Patil <sspatil@google.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-29 14:09:44 -07:00
Johan Hovold 36602a2981 greybus: module: implement controlled module removal
Implement controlled module removal through a new module attribute
"eject".

When a non-zero argument is written to the attribute, all interfaces of
the module are disabled (e.g. bundles are deregistered) and deactivated
(e.g. powered off) before instructing the SVC to physically eject the
module.

Note that the module device is not deregistered until the SVC has
reported the physical removal of all of its interfaces.

A new interface mutex is added to enforce interface state-change
serialisation.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-25 11:08:30 -07:00
Johan Hovold b15d97d770 greybus: core: add module abstraction
Add Greybus module abstraction that will be used to implement controlled
module removal (eject) and represent module geometry.

Greybus module devices correspond to physical modules and have one or
more interfaces. Modules have an id that is identical to the id of their
primary interface, which in turn is the interface with lowest numbered
id. The module name is constructed from the bus and module id:

        <bus_id>-<module_id>

Interfaces, bundles, and control devices are consequently renamed as

        <bus_id>-<module_id>.<interface_id>
        <bus_id>-<module_id>.<interface_id>.<bundle_id>
        <bus_id>-<module_id>.<interface_id>.ctrl

As before, interface ids (and therefore in a sense now also module ids)
correspond to physical interface positions on the frame.

Modules have the following attributes:

        module_id
        num_interfaces

where module_id is the id of the module and num_interface the number of
interfaces the module has.

Note that until SVC module-size detection has been implemented, all
interfaces are considered to be part of 1x2 modules. Specifically, the
two interfaces of a 2x2 module will be presented as two 1x2 modules for
now.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-25 11:08:30 -07:00
Johan Hovold deba0c03e9 greybus: Documentation/sysfs: sort entries alphabetically
The attribute entries have been kept mostly sorted within each device
type. Let's move the three more-recently added interface attributes
that were not.

Suggested-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-25 11:08:30 -07:00
Johan Hovold 4ff80a59ac greybus: Documentation/sysfs: add entry for control device
Add an entry for the recently added interface control device.

Also move the bundle-device entry below the control-device entries.

Reported-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-25 11:08:30 -07:00
Johan Hovold 7c8eb12dbb greybus: interface: move vendor and product strings to control device
The control device is an abstraction of the control connection over
which a greybus manifest is retrieved. As interfaces switch modes (e.g.
after boot-over-unipro) they expose new manifests, which can contain
different vendor and product strings.

Eventually control devices will be deregistered and recreated after an
interface mode switch, while the interface itself remains registered.

Note that only interfaces of type greybus will have control devices.
Specifically, dummy interfaces will not.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 10:09:03 +09:00
Johan Hovold 078ef067bc greybus: Documentation/sysfs: add example control devices
Add control devices to the example sysfs tree.

Control devices are named

	<bus_id>-<module_id>.<intf_id>.ctrl

and expose attributes that are specific to the greybus interface type.
Specifically, dummy interfaces do not have a control device.

Currently, only the vendor and product strings extracted from the
manifest are exported.

A subtree of the example tree now looks as follows:

greybus1/
├── 1-5
│   ├── 1-5.5
│   │   ├── 1-5.5.2
│   │   │   ├── bundle_class
│   │   │   ├── bundle_id
│   │   │   └── state
│   │   ├── 1-5.5.ctrl
│   │   │   ├── product_string
│   │   │   └── vendor_string
│   │   ├── ddbl1_manufacturer_id
│   │   ├── ddbl1_product_id
│   │   ├── interface_id
│   │   ├── product_id
│   │   ├── serial_number
│   │   └── vendor_id
│   ├── 1-5.6
│   │   └── interface_id
│   ├── eject
│   ├── module_id
│   └── num_interfaces
└── 1-svc

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 10:03:13 +09:00
Johan Hovold 9e5e6fa6bf greybus: Documentation/sysfs: rename the svc eject attribute
The svc eject attribute was added as an interim solution and is still
used to implement a form of forced ejection.

This will soon be superseded by the module eject attribute, which will
provide an interface for clean eject. We may keep the forced-eject
mechanism around indefinitely, albeit possibly with a different name
(e.g. forced_intf_eject). Either way, update the example tree to reflect
the actual name, intf_eject, which currently used for this svc attribute.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 10:03:13 +09:00
Johan Hovold 78b609b14c greybus: Documentation/sysfs: remove interface unique_id attribute
Remove the interface unique_id attribute, which there is currently no
plan to ever implement.

Note that the Ara serial numbers are already exposed through the
serial_number attribute.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 10:03:13 +09:00
Johan Hovold aba2fc626e greybus: Documentation: move the interface power attributes
Move the interface power attributes after the other interface attributes
to keep the attributes grouped by device type.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 10:03:13 +09:00
David Lin ddb10c8acc greybus: svc: add Interface power measurements support
This change implements the AP Power Monitor functions for obtaining
current/voltage/power on a specific rail of an Interface.

Testing Done:

$ cat /sys/bus/greybus/devices/1-3/current_now
103
$ cat /sys/bus/greybus/devices/1-3/power_now
303
$ cat /sys/bus/greybus/devices/1-3/voltage_now
203

Signed-off-by: David Lin <dtwlin@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-07 21:37:59 -07:00
Johan Hovold c8733c513d greybus: Documentation/sysfs: make 1-5 a 2x2 module
Make example module 1-5 a 2x2 module by adding a second, dummy
interface.

This is both an example of how a 2x2 module would be represented and
also suggests what a dummy interface may look like.

A 2x2 module has two child interface devices and a num_interfaces value
of two.

In this example, the secondary interface 1-5.6, is a dummy interface and
therefore lacks the normal identifying attributes (e.g. UniPro DDBL1 and
Ara ids). We may eventually add an interface_type attribute to
facilitate distinguishing various interface types (there may be more
than two).

In the following tree, the bundle attributes and child devices have been
left out:

greybus1/
├── 1-2
│   ├── 1-2.2
│   │   ├── 1-2.2.1
│   │   ├── 1-2.2.2
│   │   ├── ddbl1_manufacturer_id
│   │   ├── ddbl1_product_id
│   │   ├── interface_id
│   │   ├── product_id
│   │   ├── serial_number
│   │   ├── unique_id
│   │   └── vendor_id
│   ├── eject
│   ├── module_id
│   └── num_interfaces
├── 1-5
│   ├── 1-5.5
│   │   ├── 1-5.5.2
│   │   ├── ddbl1_manufacturer_id
│   │   ├── ddbl1_product_id
│   │   ├── interface_id
│   │   ├── product_id
│   │   ├── serial_number
│   │   ├── unique_id
│   │   └── vendor_id
│   ├── 1-5.6
│   │   └── interface_id
│   ├── eject
│   ├── module_id
│   └── num_interfaces
└── 1-svc

In this example there are two modules: 1-2 is a 1x2 module with one
interface, and 1-5 is a 2x2 module with two interfaces of which the
second (1-5.6) is a dummy interface.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-25 16:23:01 -08:00
Johan Hovold bd93d2a819 greybus: Documentation/sysfs: move module 1-4 to position 5
Move example module 1-4 to position 5, effectively renaming it 1-5.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-25 16:23:01 -08:00
Johan Hovold 8886c44f87 greybus: Documentation/sysfs: add module devices
Introduce module devices and rename interface and bundle devices.

Greybus module devices correspond to physical modules and have one or
more interfaces. Modules have an id that is identical to the id of their
primary interface, which in turn is the interface with lowest numbered
id. The module name is constructed from the bus and module id:

	<bus_id>-<module_id>

Interfaces and bundles are consequently renamed as

	<bus_id>-<module_id>.<interface_id>

and

	<bus_id>-<module_id>.<interface_id>.<bundle_id>

respectively.

As before, interface ids (and therefore in a sense now also module ids)
correspond to physical interface positions on the frame.

Modules have the following attributes:

	eject
	module_id
	num_interfaces

where module_id is the id of the module and num_interface the number of
interfaces the module has.

Note that the interface ids of a module's interfaces are expected to be
<module_id>, <module_id + 1>, ..., <module_id + num_interfaces - 1>.

Writing a non-zero argument to eject cleanly shuts down and unregisters
all of the module interfaces before ejecting the module.

The example sysfs tree now looks as follows with the second bus
(APBridgeA) left out:

greybus1/
├── 1-2
│   ├── 1-2.2
│   │   ├── 1-2.2.1
│   │   │   ├── bundle_class
│   │   │   ├── bundle_id
│   │   │   └── state
│   │   ├── 1-2.2.2
│   │   │   ├── bundle_class
│   │   │   ├── bundle_id
│   │   │   └── state
│   │   ├── ddbl1_manufacturer_id
│   │   ├── ddbl1_product_id
│   │   ├── interface_id
│   │   ├── product_id
│   │   ├── serial_number
│   │   ├── unique_id
│   │   └── vendor_id
│   ├── eject
│   ├── module_id
│   └── num_interfaces
├── 1-4
│   ├── 1-4.4
│   │   ├── 1-4.4.2
│   │   │   ├── bundle_class
│   │   │   ├── bundle_id
│   │   │   ├── gpbridge0
│   │   │   │   ├── gpio
│   │   │   │   │   └── gpiochip490
│   │   │   │   └── i2c-4
│   │   │   └── state
│   │   ├── ddbl1_manufacturer_id
│   │   ├── ddbl1_product_id
│   │   ├── interface_id
│   │   ├── product_id
│   │   ├── serial_number
│   │   ├── unique_id
│   │   └── vendor_id
│   ├── eject
│   ├── module_id
│   └── num_interfaces
└── 1-svc
    ├── ap_intf_id
    ├── eject
    └── endo_id

where greybus1 is a bus; 1-svc the svc; 1-2, and 1-4 are modules; 1-2.2
and 1-4.4 are (primary) interfaces; and 1-2.2.1, 1-2.2.2, and 1-4.4.2
are bundles.

Note that the svc eject attribute may eventually be renamed force_eject.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-25 16:23:01 -08:00
Johan Hovold 737df280a7 greybus: Documentation: remove svc unique_id attribute
Remove unimplemented svc unique_id attribute from the documentation.

This attribute made more sense when we thought we'd have an AP-module,
unlike now when the AP and SVC are both part of the same frame.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-22 17:12:55 -08:00
Greg Kroah-Hartman d562853d3e greybus: svc watchdog: allow it to be enabled/disabled from userspace
Sometimes you want to disable the SVC watchdog without having to patch
your kernel, so provide a sysfs file to do this.  This can let us do
power measurements, and let the firmware developers not go crazy
worrying that the kernel is going to reset their chips with no notice.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-26 17:06:29 -08:00
Rui Miguel Silva 2c92bd5235 greybus: svc: add intf_eject attribute
Add a new write-only svc attribute to send an eject request to the svc
giving the interface number.

So, doing:
echo 3 > /sys/bus/greybus/devices/1-svc/intf_eject

will force eject the module on interface 3 (module slot 1 on EVT1).
This can take some seconds as the pulse width for module release is
large.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com>
2016-01-12 17:00:19 -08:00
Viresh Kumar d39bf704ac greybus: interface: Fetch and expose version of interface's firmware
The version of the currently running firmware on the module is useful
for userspace as it can be used to find if an update is available or
not. This patch fetches interface's version with a new control operation
and exposes the same in userspace.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-30 13:13:04 -08:00
Viresh Kumar 57c6bcc635 greybus: interface: Receive serial-number on hotplug event
Two exactly same modules can be uniquely identified using module's
serial-number. This patch updates the interface hotplug event to also
receive the serial-number of the module.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-30 13:13:04 -08:00
Viresh Kumar 0e9403a0fb greybus: interface: Expose DDBL1 manufacturing and production id in sysfs
These ids are already fetched from the SVC, but were never exposed to
sysfs. Userspace may be interested in using these values and hence these
must be exposed to it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-22 13:00:52 -08:00
Viresh Kumar c5b6df9c8d greybus: Documentation: Arrange entries in alphabetical order
The order of entries in sysfs-bus-greybus file doesn't match the order
files/directories in sysfs on a real board. More specifically, N-svc
comes at last and ap_interface_id comes before endo_id within the svc.

Fix that.

Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-04 16:22:40 -08:00
Viresh Kumar e6420dac3d greybus: Documentation: Fix N-svc directory name
endo_id was present in place of the directory N-svc, fix it.

Fixes: 4f7b1833e78f ("Documentation/sysfs-bus-greybus: update the bus ABI documentation")
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-03 14:20:49 -08:00
Johan Hovold 32945d6ecc greybus: Documentation/sysfs: rename interface and bundle attributes
Update the example sysfs-tree layout under Documentation due renamed
interface and bundle attributes.

The interface and bundle "id" attributes have been renamed
"interface_id" and "bundle_id" respectively to make them self
describing. For consistency reasons the bundle class attribute is
renamed as "bundle_class".

.
├── greybus1
│   ├── 1-2
│   │   ├── 1-2.1
│   │   │   ├── bundle_class
│   │   │   ├── bundle_id
│   │   │   └── state
│   │   ├── 1-2.2
│   │   │   ├── bundle_class
│   │   │   ├── bundle_id
│   │   │   └── state
│   │   ├── interface_id
│   │   ├── product_id
│   │   ├── unique_id
│   │   └── vendor_id
│   ├── 1-4
│   │   ├── 1-4.2
│   │   │   ├── bundle_class
│   │   │   ├── bundle_id
│   │   │   ├── gpbridge0
│   │   │   │   ├── gpio
│   │   │   │   │   └── gpiochip490
│   │   │   │   └── i2c-4
│   │   │   └── state
│   │   ├── interface_id
│   │   ├── product_id
│   │   ├── unique_id
│   │   └── vendor_id
│   └── 1-svc
│       ├── ap_intf_id
│       ├── eject
│       ├── endo_id
│       └── unique_id
└── greybus2
    ├── 2-3
    │   ├── 2-3.1
    │   │   ├── bundle_class
    │   │   ├── bundle_id
    │   │   └── state
    │   ├── interface_id
    │   ├── product_id
    │   ├── unique_id
    │   └── vendor_id
    └── 2-svc
        ├── ap_intf_id
        ├── eject
        ├── endo_id
        └── unique_id

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-25 15:46:00 -08:00
Johan Hovold a97015c9e9 greybus: bundle: add bundle_id attribute
Add a bundle_id attribute for the interface-unique id of a bundle that
user space can use for matching.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-25 15:27:06 -08:00