Commit Graph

1345 Commits

Author SHA1 Message Date
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
Johan Hovold 2b14daba1d greybus: bundle: use hexadecimal notation for class attribute
Use hexadecimal notation for class-attribute value.

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
Johan Hovold 4396c00b73 greybus: bundle: rename class attribute
Rename the bundle class-attribute "bundle_class" for consistency reasons
and to make it self documenting.

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
Johan Hovold 320421a80b greybus: interface: add interface_id attribute
Add interface_id attribute that user space needs to identify an
interface.

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
Johan Hovold 1eca63ae79 greybus: interface: remove device_id attribute
The interface device_id attribute is an implementation detail that does
not need to be exported to user space.

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
Johan Hovold 9f59263a89 greybus: interface: rename vendor and product attributes
Rename vendor and product attributes vendor_id and product_id.

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
Johan Hovold fda3412566 greybus: Documentation/sysfs-bus-greybus: update the bus ABI documentation
Update the ABI documentation to match the new device model.

Note that the SVC unique_id and version attributes are not yet
implemented.

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
Johan Hovold f6f8aeaa35 greybus: Documentation/sysfs: update the example sysfs tree
Update the example sysfs-tree layout under Documentation.

The new layout reflects changes to the kernel device-model that are
needed to eventually be able to handle multiple AP-bridges.

The example tree has two AP-bridges, each with its own view of the
UniPro network, the bus.

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

Every bus has exactly one svc device (1-svc and 2-svc). For our system,
the svc device of each bus will be a representation of the same
network-unique SVC device (e.g. endo_id and unique_id will be
identical).

The first bus has two registered interfaces (1-2 and 1-4), while the
second bus has a single interface (2-3). Note that the interface ids (2,
4, and 3) are necessarily unique as these are interfaces on the same
network.

Interface 1-2 has two bundles (1-2.1 and 1-2.2) and interface 1-4 has
a single bundle (1-4.2). The bundle ids are interface-unique and reflect
the ids found in each manifest.

In the example, bundle 1-4.2 has a gbbridge-device, which is the parent
device for a gpiochip device and an i2c bus.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-23 19:24:27 -08:00
Sachin Pandhare fc25d9068e greybus: manifest: simplify descriptor address calculation
This patch doesn't change any functionality. It just improves the
readability of the code.
Current code to get 'descriptors' pointer looks as if we are forcing the
pointer type change. To simplify the address calculations, use
'descriptors' member directly from greybus_manifest structure.

Signed-off-by: Sachin Pandhare <sachin.pandhare@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-23 19:23:47 -08:00
Johan Hovold bfe2c99c1c greybus: hd: fix cport-count check
Fix off-by-one error when checking the number of cports a host-device
supports.

The CPORT_ID_MAX is the largest valid cport id so the maximum number of
cports a host-device can use is CPORT_ID_MAX + 1.

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>
2015-11-23 19:23:27 -08:00
Johan Hovold 39f36c8f9f greybus: connection: fix cport-id range
Fix cport-id allocation that failed to include the highest port id in the
available cport-id range.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-23 19:23:27 -08:00
Vaibhav Agarwal d3d2af51f9 greybus: Audio: Add skeleton code for GB virtual codec driver
This patch adds gb-codec driver with static information for
DAPM widgets, controls & dapm_routes.

Including some changes in kernel code(machine driver):
- Able to register codec and glue it with existing sound card successfully.
- Able to view & modify mixer controls:
        (volume/mute[left/right][input/output])
- Able to view DAPM widgets registered via /debug interface.
- Able to establish DAPM path for playback.

Since, FE<->BE path not yet verified with default jetson build,
registering GB DAI as normal DAI link to verify GB virtual codec
specific DAPM path.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-23 16:38:22 -08:00
Johan Hovold 3823c61479 greybus: add class matching macro
Add matching macro for bundle class.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-21 17:15:35 -08:00
Johan Hovold 700001af96 greybus: move id-matching back to core
Move id-matching back to core and the bus code where it belongs.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-21 17:15:35 -08:00
Johan Hovold f65fa47f28 greybus: fix vendor and product matching
Fix vendor and product matching by matching on the 32-bit Ara vendor and
product ids.

Remove the "fake" 16-bit vendor and product ids and export the Ara ids
using the "vendor" and "product" interface attributes instead.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-21 17:15:35 -08:00
Johan Hovold 8034bd561d greybus: interface: remove unique id
Remove the unimplemented interface unique-id.

There will eventually be an interface-serial-number attribute provided,
but let's not export it or commit to a name for this attribute until we
need it.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-21 17:15:35 -08:00
Johan Hovold 9784a591f0 greybus: remove unique-id matching
Remove unique-id matching as it does not make much sense to have a
driver match a specific device serial number.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-21 17:15:35 -08:00
Johan Hovold 358e9400f4 greybus: fix bundle-id match macros
The matching flags were renamed over a year ago but the so far unused
id-macros were never updated.

Also rename the GREYBUS_ID_MATCH_DEVICE mask to use the common
GREYBUS_ID_MATCH-prefix.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-21 17:15:35 -08:00
Johan Hovold 55510843c1 greybus: svc: fix missing version-request sanity checks
Add missing sanity checks on version-request payload size.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-19 16:07:48 -08:00
Johan Hovold 87f6c976f4 greybus: firmware: break long lines
Break lines longer than 80 cols, and clean up an error message while at
it.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-19 16:07:48 -08:00
Johan Hovold 98645a9c69 greybus: firmware: fix information leak
Add missing sanity checks on get_firmware-request offset and size
parameters to fix potential information leaks.

This prevents remotely controlled information leaks as the requestor
currently controls both the 32-bit firmware-image offset and the amount
of data that is returned (up to host-device MTU).

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-19 16:07:48 -08:00
Bartosz Golaszewski 81ad699461 greybus: loopback: allocate a response even for a 0-byte request
If payload length of a transfer packet is 0, no response is allocated.
Send a well-formed response even in that case.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-19 16:02:41 -08:00
Alexandre Bailon 9864756be7 greybus: loopback: fix invalid response size
The size of timestamps is not taken into account, which makes the
loopback driver in the firmware drop invalid packages.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-19 16:02:41 -08:00
Rui Miguel Silva 5c864e775d greybus: manifest: fix bundle descriptor parse
The descriptor list is walked in two points, in the bundle parsing and
cport parsing, this can make the next descriptor pointer in bundle to be
already removed by the cport remove descriptor and become invalid.

So, just get the next bundle until there no more left.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-16 22:26:43 -08:00
Mark Greer 80ee842825 greybus: audio: Allocate protocol and class values
Allocate protocol and class values for the Audio Device Class
Protocol.  Two values of each type are allocated: one for Audio
Management Connections and one for Audio Data Connections.

Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-16 22:18:52 -08:00
Viresh Kumar e3c25930d9 greybus: es1: Remove the (now) unused es1 driver
This was used by gbsim earlier, but not anymore. Lets remove it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-16 22:18:52 -08:00
Viresh Kumar bf6a61bd2f greybus: es2: remove fake vendor/product ids
These aren't used anymore, remove them.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-16 22:18:52 -08:00
Rui Miguel Silva ffe2e2487a greybus: power_supply: rework and operation changes
This is a major rework and changes to the current implementation of the
battery protocol. The previous implementation lack the support of a more
dynamic handle of power supply properties and updating of status. Also,
reflect the actual state of the greybus specification

So, with this new approach a set of operations to fetch the battery
module configuration and properties is add, new methods to cache and
update the values of properties, new operation to set properties if
declared writable and an event operation that can be triggered by the
module to force an update read on the properties values.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-12 16:12:55 -08:00
Rui Miguel Silva 783e373a9f greybus: makefile: add power_supply config check
Add check for POWER_SUPPLY config option to guarantee that it is enabled.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-12 16:09:32 -08:00
Rui Miguel Silva 2724be0305 greybus: battery: move implementation to power_supply
Rename protocol to POWER_SUPPLY and implementation details from battery
to power_supply.

Also fix some tabs between define and macro name.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-12 16:08:40 -08:00
Rui Miguel Silva 464888410d greybus: battery: move battery file to power_supply
Rename the battery.c to power_supply.c and update the makefile as the
Greybus protocol is being renamed from battery to power_supply.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-12 16:06:49 -08:00
Viresh Kumar 69166d2525 greybus: es2: Send cport-id in wValue field to usb_control_msg()
wIndex field has a special meaning, as that can be used by the core to
index into the possible USB interfaces. And that specifically broke with
gbsim, as it has a single USB interface.

Other similar requests (REQUEST_LATENCY_TAG_{EN|DIS}) are already using
wValue field for passing cport-id.

Fix cport_reset() by sending the cport-id in wValue field instead of
wIndex.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Fabien Parent <fparent@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-12 15:49:12 -08:00
Johan Hovold f6c6c1388a greybus: svc: use bit-macro for cport flags
Use BIT-macro for cport flags.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-11 09:18:28 -08:00
Johan Hovold 35a84ba7f9 greybus: use decimal notation for interface and cport ids
Fix up the few places where hexadecimal rather than decimal notation was
used for interface and cport ids.

Note that this includes the endo sysfs-attribute for the AP interface
id.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-11 09:18:28 -08:00
Johan Hovold febe252179 greybus: interface: fix obsolete comment
Fix obsolete comment that was referring to "module" rather than
"interface".

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-11 09:18:28 -08:00
Johan Hovold eeb6a6ff59 greybus: interface: fix potential use-after-free at remove
Fix resources (accessible through sysfs) being released before interface
is deregistered.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-11 09:18:28 -08:00
Johan Hovold f865734d3c greybus: light: fix class-device parent
Greybus bundle drivers should register their class devices as children
to the bundle device that they bind to.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-11 09:18:28 -08:00
Johan Hovold cd414d4726 greybus: battery: fix class-device parent
Greybus bundle drivers should register their class devices as children
to the bundle device that they bind to.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-11 09:18:28 -08:00
Johan Hovold 0d1d6ee209 greybus: loopback: fix layer violation
A bundle (protocol) driver has no business creating sysfs entries for an
ancestor device.

Move the sysfs entries to the bundle device for now.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-11 09:18:28 -08:00
Greg Kroah-Hartman c9e9de26f9 greybus: hid: hid should not be part of the bridged-phy driver.
HID is a stand-alone greybus protocol, not part of the bridged-phy
protocols, so make it a stand-alone kernel module.

Note, some hard-coded android init script might need to be changed to
load the gb-hid.ko kernel module now.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
2015-11-05 18:00:29 -08:00
Johan Hovold a52028626a greybus: es2: clean up es2 destructor
Now that the host-device is deregistered separately from deallocation,
we can simplify the cport_to_ep-array deallocation.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-04 20:35:18 -08:00
Johan Hovold c170047984 greybus: hd: fix host-device life time issues
Fix host-device life time issues by separating host-device allocation
from registration.

This is needed both to make sure that all host-device resources are
available before registering the device and to prevent such resources
from being deallocated while the device is still in use during device
removal.

This specifically fixes the following warnings during es1 and es2
disconnect:

usb 1-1.1: No free CPort OUT urbs, having to dynamically allocate one!

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-04 20:35:18 -08:00
Johan Hovold b4bd3617ed greybus: es1: add more structure to probe error handling
Add more structure to probe error handling rather than use the big
hammer and call disconnect directly.

This is needed to fix some host-device life-time issues.

Note that there was never any need to clear the USB interface data as
this will be done by driver core.

Compile-only tested.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-04 20:35:18 -08:00
Johan Hovold 57bc17ffc5 greybus: es2: add more structure to probe error handling
Add more structure to probe error handling rather than use the big
hammer and call disconnect directly.

This is needed to fix some host-device life-time issues.

Note that there was never any need to clear the USB interface data as
this will be done by driver core.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-04 20:35:18 -08:00
Johan Hovold fb7a4ea22b greybus: es1: fix debugfs dentry leak
Fix dentry leak due to failure to remove debugfs file.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-04 20:35:18 -08:00
Johan Hovold 74cd6503e5 greybus: es2: fix debugfs dentry leak
Fix dentry leak due to failure to remove debugfs file.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-04 20:35:18 -08:00
Johan Hovold 715d7a7280 greybus: es1: separate stopping and deallocating urbs
Separate stopping and deallocating our in-urbs.

This will facilitate implementing proper host-device life-time management.

Compile-only tested.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-04 20:35:18 -08:00
Johan Hovold f6624ca77c greybus: es2: separate stopping and deallocating urbs
Separate stopping and deallocating our in-urbs.

This will facilitate implementing proper host-device life-time management.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-04 20:35:18 -08:00
Johan Hovold 8dfd3fe564 greybus: es1: separate urb allocation and submission
Separate in-urb allocation and submission.

This is needed for the driver-model rework.

Compile-tested only.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-04 20:35:18 -08:00
Johan Hovold 0ce68ce417 greybus: es2: separate urb allocation and submission
Refactor in-urb submission, and make sure to separate allocation and
submission.

Eventually we'll be submitting the urbs at cport enable rather than at
probe, and this is also needed for the driver-model rework.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-04 20:35:18 -08:00