summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/hd.c
AgeCommit message (Collapse)Author
2016-04-29greybus: hd: add bus_id attributeSandeep Patil
The greybus host device id can only be read by parsing the uevent if one wants to identify a specific host device 'or' bus. This is 'lsgb' uses today. This change adds a bus_id attribute so libraries can identify multiple host devices 'or' bus if they exist. Testing Done: Tested on Arche, 'cat /sys/bus/greybus/devices/greysbus1/bus_id' 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-25greybus: core: add module abstractionJohan Hovold
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-03-10greybus: interface: move interface-removal helperJohan Hovold
Move helper to remove all interfaces of a host-device to the svc code and call it when removing the svc device as this needs to be coordinated with flushing the SVC work queue. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-11greybus: core: add device prefix to error messagesJohan Hovold
Use dev_err and dev_warn where appropriate and remove now unused pr_fmt defines. Testing Done: Tested on DB3.5 with the generic bridge firmware on APB2. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-28greybus: hd: fix host-device-removal raceJohan Hovold
Make sure to tear down the svc and flush any on-going hotplug processing before removing the remaining interfaces. This fixes crashes due to host-device removal racing with svc hotplug/unplug processing (e.g. at "UniPro restart"). Testing Done: Verified that this fixes crashes reproducible on SDB when unloading the host-device driver module while generating hotplug/unplug events. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-12greybus: host: provide "generic" apbridge output callsGreg Kroah-Hartman
Provide a new function, gb_hd_output() to send data to the apbridge. This is useful for the camera and audio drivers that need to do this type of messaging. The camera driver is converted to use this new function, the audio driver can use it when it gets merged later. Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Tested-by: Mark Greer <mgreer@animalcreek.com> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
2015-12-08greybus: svc: create svc along with host deviceJohan Hovold
Create svc device along with host-device and move the svc-connection to the svc structure. The svc connection is enabled when registering the host device, but as the SVC protocol is currently driven by the SVC, we need to defer registration of the svc device to the connection request handler. 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-12-08greybus: hd: make svc-connection life time coincide with host-deviceJohan Hovold
Create the svc-connection as part of the host device, and destroy it in the host-device destructor. The svc-connection is enabled when registering the host device, and disabled when the host device is deregistered. 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-12-08greybus: hd: initialise device lastJohan Hovold
Initialise the struct device last when creating the host device. After device_initialize(), or rather dev_set_name(), we must use put_device to release the host device. Initialising last will allow for a simpler release callback. 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-12-08greybus: connection: separate connection creation and enablingJohan Hovold
Separate connection creation from enabling. This will ultimately allow connection structures to be created while parsing manifests, but the connections to not be enabled until a driver is bound. 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-25greybus: kill the endoJohan Hovold
Remove the now unused endo and module code. Note that the never-implemented serial and version attributes of the endo can be implemented as svc attributes if needed. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-25greybus: hd: fix svc-connection handlingJohan Hovold
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>
2015-11-25greybus: hd: make host device a deviceJohan Hovold
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>
2015-11-23greybus: hd: fix cport-count checkJohan Hovold
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-04greybus: hd: fix host-device life time issuesJohan Hovold
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-04greybus: hd: use common prefix for exported functionsJohan Hovold
Rename the exported functions using the common gb_-prefix. 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-04greybus: hd: rename host-driver structureJohan Hovold
Rename host-driver structure to gb_hd_driver to more clearly separate it from the host-device structure. Also remove an outdated description of the struct. 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-04greybus: hd: rename host-device structureJohan Hovold
Rename host-device structure gb_host_device to match our other structures. 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-04greybus: create host-device compilation unitJohan Hovold
Move everything host-device related to hd.c and hd.h. 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>