Replace reference to "endo0" and generate the raw-latency filename based
on the host-device bus id instead.
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>
Use dev_err and friends with the svc device for messages.
Clean up error messages.
Demote a few warnings to warning level.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Create the svc connection when registering the host-device and
remove the current svc connection hacks that "upgraded" the svc
connection once the endo id and ap interface id was known.
Note that the old implementation was partly based on a misunderstanding
as it was the remote interface id, rather than the local AP interface id,
that used to define a connection (but we also needed the endo_id).
The remote interface is no longer needed as static connections, such as
the svc connection, are now simply defined by the host-device and host
cport id.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Use host-device device and connection name for log messages, as not all
connections have a bundle.
Note that the "initial" svc connection has never had a bundle.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Use the host-device device and connection name for error messages, as
the operation code can not assume that a connection has a bundle.
Note that the "initial" svc connection has never had a bundle.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Use host-device device and connection name for log messages rather than
assume that all connections have a bundle (e.g. not true for static
connections).
Note that the "initial" svc connection has never had a bundle.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Add a name field to connections that can be used in log messages.
A connection always belongs to a host-device (bus) and can be uniquely
identified by its host-device cport id, but include remote interface and
cport id nonetheless on the following format:
<hd_cport_id>/<intf_id>:<cport_id>
The remote interface and cport id will be zero for static connections.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Add helper to determine whether a connection is static, and remove the
protocol flag GB_PROTOCOL_SKIP_SVC_CONNECTION.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Make sure that the interface lookup helper can handle static,
bundle-less connections without oopsing when creating further
connections.
Note that the initial svc-connection has always been bundle-less, but
did not trigger an oops as a bundle was created for it before further
connections were created.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Clean up the connection-creation interface by clearly separating our two
types of connections: static and dynamic.
Add two convenience functions for creating static and dynamic connections.
A static connection is a pre-setup connection that is defined by a host
device and a host-device cport id. Specifically, the remote interface or
cport id need not be known. The SVC connection is a static connection.
A dynamic connection is defined by a host device and a remote interface
and cport id. This is our normal connections where the host-device cport
is (generally) allocated dynamically.
Note that the new generic interface is marked static, but can be
exported later to allow dynamic connections to be created also from
fixed host-device cports (e.g. for CSI).
Also note that a connection of either type is uniquely identified by its
host-device and host-device cport id once created.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Kill gb_create_bundle_connection, which was only used to create the
control bundle and connection, and replace it with a specialised static
helper.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Move endo_id and AP interface id to the svc device.
The endo abstraction is about to be removed, and these attributes are
arguable attributes of the svc anyway.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Register the svc device upon reception of the HELLO request.
The SVC HELLO request contains the endo id and AP interface id, which
will be exposed from the svc device rather than the endo.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Make sure to initialise the svc device fully before adding it to the
host device.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Make the svc object a child device of the host-device device and use
driver core to manage its lifetime.
The svc device name is "<bus_id>-svc", where bus_id is the dynamically
assigned id of the host device.
Note that there is exactly one svc-device per host device (bus).
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Rename bundle devices so that the new device names become
"<bus_id>-<intf_id>.<bundle_id>", where bus_id is the dynamically
allocated host-device bus id and intf_id the svc-allocated interface
id.
Using a period (.) rather than a colon (:) makes dev-messages easier to
read as as those already add a colon after the device name, for example:
greybus 1-4.15: failed to connect cport: -22
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Make interfaces child devices of host devices.
The new interface device name is "<bus_id>-<intf_id>", where bus_id is
the dynamically allocated bus id for the host device and intf_id is the
svc-allocated interface id.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
The parent parameter was only used for debug messages and to name the
connection workqueue. Use the host-device device for this instead.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Make the host device a proper device in the kernel device model.
Host devices will be our new greybus-bus root devices.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
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>
Use hexadecimal notation for class-attribute value.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>