Commit Graph

1976 Commits

Author SHA1 Message Date
Bryan O'Donoghue 8c81d4608d greybus: interface: Extract and store Interface feature byte
The Interface description in the Greybus specification contains a
'features' field which is currently not implemented on the AP side. The
Interface features field provides information on optional attributes of an
Interface as a bitmask. Currently only GREYBUS_INTERFACE_FEATURE_TIMESYNC
is implemented in the specification but, the expectation is that other
feature flags will be added over time.

This patch adds support to extract the feature byte communicated in the
features field of the Interface Descriptor header and extends struct
interface to contain a features field through which any user with a pointer
to struct interface may interrogate the features of an Interface.

This is a necessary pre-cursor for TimeSync to ensure only Interfaces which
declare GREYBUS_INTERFACE_FEATURE_TIMESYNC will be included when we go
through the process of FrameTime synchronization.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-15 11:39:57 -07:00
Bryan O'Donoghue c8a657ba3f greybus: hd: Add TimeSync APBridge commands
This patch adds a number of USB Vendor commands to es2.c to enable TimeSync
in the bridge.

Adds:
- es2.c::timesync_enable(u8 count, u64 frame_time, u32 strobe_delay,
			 u32 refclk);
  Commands APBx to enable timers and clocks to track a pulse-train of
  incoming TIME_SYNC strobes with strobe_delay microseconds between each.
  Provides the reference clock the AP is using to track FrameTime. It is
  the responsibility of APBx to adequately track the FrameTime based on
  the indicated AP refclk. Once this command has succeeded APBx may not
  transition to a low-power state were FrameTime counters stop.

  This function is initiated from the timesync worker thread logic when
  re-synchronizing frame-time throughout the system.

  TimeSync is at this time enabled for all APBx active in the system i.e.
  currently APB2 will not receive TimeSync commands until it becomes a
  registered host-device in Greybus.

- es2.c::timesync_disable(void)
  Commands APBx to discontinue tracking of FrameTime. After this operation
  completes APBx may transition to a low-power state where timer-clocks
  stop operating.

- es2.c::timesync_authoritative(u64 *frame_time)
  Provides an authoritative time for each TIME_SYNC strobe to APBx.
  APBx must align its local FrameTime to the authoritative clock.

- es2.c::timesync_get_last_event(u64 *frame_time)
  Returns the FrameTime at the last SVC_TIMESYNC_PING to the AP Module.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-15 11:39:57 -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
Viresh Kumar e2386c9327 greybus: firmware: Add SPI protocol support
This patch adds SPI Protocol support to firmware core, which allows the
AP to access an SPI flash memory present with an Interface.

Tested by using the API from fw-management driver and compiling it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-15 00:23:52 +02:00
Viresh Kumar 96ba674009 greybus: fw-management: Free fw-mgmt only after all users are gone
The fw-management driver rightly destroys the char device on
connection-exit, but that doesn't guarantee that all of the users of the
device are gone.

Userspace may still be holding file-descriptor of the char device and
can initiate new ioctl operations. And that *will* lead to kernel crash.

To avoid this issue, manage struct users with kref, manage a list of
'struct fw-mgmt' and start using the structure only after getting its
kref incremented.

The important part is the routine get_fw_mgmt(), which increments the
reference to the struct before returning it to the caller. The list of
fw-mgmt structs in protected with a mutex to avoid any races around
that.

The kref is incremented once the char device is opened and dropped only
when it is closed.

Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-15 00:23:52 +02:00
Viresh Kumar 04f0e6ebd1 greybus: fw-management: Add ioctl to initiate mode-switch
Once the interface firmware is loaded successfully to a module,
userspace can ask it to mode switch to the newly loaded firmware.

This patch provides a new ioctl to initiate mode switch.

Userspace can initiate a mode switch if it has previously loaded the
interface firmware successfully, otherwise the firmware core rejects it.

Also, once the mode-switch is initiated, disallow any more interactions
from the userspace.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
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
Viresh Kumar 013e665372 greybus: fw-management: Add firmware-management protocol driver
This patch adds Firmware Management Protocol support to firmware core,
which allows the AP to manage firmware on an Interface.

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
Greg Kroah-Hartman 8502eb3b78 greybus: make greybus_gpbdev_type static
'make check' correctly complains that this should be static, so make it
so.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-14 23:20:52 +02:00
Viresh Kumar 8888b96374 greybus: spi: Separate out spilib from spi bridged PHY bundle driver
spilib can be used by multiple bridge drivers implementing different
bundle classes. Separate out bridged PHY bundle drivers parts.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-14 23:18:32 +02:00
Viresh Kumar 4c412921c7 greybus: spi: Restructure spi.c to share it with other bundle drivers
This patch restructures spi.c as spilib core, so that the same logic can
be reused for SPI connections implemented as part of different bundle
types. This is required for Firmware Management Bundle.

Note that the 'struct gb_protocol' and its callback aren't moved to
a separate file in this commit to make its reviews easier. That will be
done by a following patch.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-14 23:18:32 +02:00
Viresh Kumar dc0754088e greybus: Remove bridge PHY protocol specific classes
These protocols are managed under the bridged PHY class and doesn't need
protocol specific classes anymore.

Remove their entries from gb_gpbridge_id_table array and remove the now
unused macro's and mark their values as unused.

Tested on EVT 1.5 with generic-test module.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Sandeep Patil <sspatil@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-14 19:18:24 +02:00
Viresh Kumar b9662266aa greybus: gpbridge: Remove (now) unused macro gb_gpbridge_builtin_driver()
gb_gpbridge_builtin_driver() isn't used anymore, remove it.

Tested on EVT 1.5 by inserting GP test module, all the devices were
enumerated correctly.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-14 19:13:57 +02:00
Viresh Kumar a4b9a098f2 greybus: gpbridge: Rename gb-phy.ko module
Rename gb-phy.ko module as gb-gpbridge.ko.

Tested on EVT 1.5 by inserting GP test module, all the devices were
enumerated correctly.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-14 19:13:57 +02:00
Viresh Kumar ea7c47771b greybus: usb: Create separate module
Create separate module for usb gpbridge driver.

Tested on EVT 1.5 by inserting GP test module, all the devices were
enumerated correctly.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-14 19:13:57 +02:00
Viresh Kumar 66b9e09e28 greybus: uart: Create separate module
Create separate module for uart gpbridge driver.

Tested on EVT 1.5 by inserting GP test module, all the devices were
enumerated correctly.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-14 19:13:57 +02:00
Viresh Kumar bebc013baf greybus: spi: Create separate module
Create separate module for spi gpbridge driver.

Tested on EVT 1.5 by inserting GP test module, all the devices were
enumerated correctly.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-14 19:13:57 +02:00
Viresh Kumar 3d64730e11 greybus: sdio: Create separate module
Create separate module for sdio gpbridge driver.

Tested on EVT 1.5 by inserting GP test module, all the devices were
enumerated correctly.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-14 19:13:57 +02:00
Viresh Kumar dca8060db8 greybus: pwm: Create separate module
Create separate module for pwm gpbridge driver.

Tested on EVT 1.5 by inserting GP test module, all the devices were
enumerated correctly.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-14 19:13:57 +02:00
Viresh Kumar d6046b44a5 greybus: i2c : Create separate module
Create separate module for i2c gpbridge driver.

Tested on EVT 1.5 by inserting GP test module, all the devices were
enumerated correctly.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-14 19:13:57 +02:00
Viresh Kumar 7c0925eb57 greybus: gpio: Create separate module
Create separate module for gpio gpbridge driver.

Tested on EVT 1.5 by inserting GP test module, all the devices were
enumerated correctly.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-14 19:13:57 +02:00
Viresh Kumar 9b919bdfcc greybus: gpbridge: Create module_gpbridge_driver()
Create module_gpbridge_driver() for registering gpbridge module drivers.

Tested on EVT 1.5 by inserting GP test module, all the devices were
enumerated correctly.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-14 19:13:57 +02:00
Viresh Kumar 90fa0e6c3e greybus: gpbridge: Export few routines
In order to separate protocol specific drivers into their own modules,
some of the gpbridge routines need to be exported.

Tested on EVT 1.5 by inserting GP test module, all the devices were
enumerated correctly.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-14 19:13:57 +02:00
Bryan O'Donoghue 123e749723 greybus: control: Drop unused parameter from timesync_authoritative
The count field is redundant and unused. Drop it from the control
timesync_authoritative command.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-14 18:26:24 +02:00
Bryan O'Donoghue fa433b6196 greybus: control: Add TimeSync get-last-event logic
gb_control_timesync_get_last_event() sends a request asking for the
FrameTime at the last SVC strobe event. The responding entity returns the
FrameTime in the response phase of the request. Performing this operation
to an Interface after previously:

1. Synchronizing time using timesync-enable/timesync-authoritative
2. Sending an SVC_TIMESYNC_PING

will return the FrameTime of the responding entity at the SVC-ping. If
this command is sent before synchronization has been initiated or
successfully completed the responding entity should return an error
code.

- control.c::gb_control_timesync_get_last_event(u64 *frame_time)
  Returns the FrameTime at the last SVC_TIMESYNC_PING to the AP Module.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-14 18:26:24 +02:00
Bryan O'Donoghue 5705020fbe greybus: svc: Add TimeSync SVC commands
Simple addition of the TimeSync commands defined in the specification.

Adds:
- svc.c::timesync_enable(u8 count, u64 frame_time, u32 strobe_delay,
                         u32 refclk)
  Commands the SVC to initiate count TimeSync strobe pulses with
  strobe_delay microseconds delay between each strobe to the specified
  bit-mask of Interface IDs indicated in a previous
  timesync_wake_pins_acquire command. The frame_time parameter indicates
  the initial time the SVC should base the first strobe from. The refclk
  parameter indicates the APs clock rate, the SVC should ensure its own
  clock ticks at this rate. Once enabled the SVC may not enter a low-power
  mode which will result in the reference timer used to track time
  switching off. The SVC will capture the authoritative FrameTime at each
  strobe and store these values for later propagation to the AP with the
  timesync_authoritative request.

- svc.c::timesync_disable(void)
  Commands the SVC to immediately halt TimeSync logic. This will allow
  the SVC to transition into low-power modes where the reference timer
  being used for TimeSync may switch off.

- svc.c::timesync_authoritative(u64 *frame_time)
  Used by the AP Module to ask the SVC for the authoritative FrameTime
  as captured at each TimeSync strobe.

- svc.c::timesync_ping(u64 *frame_time)
  Used by the AP Module to command the SVC to initiate a single strobe on
  a specified bit-mask of Interface IDs communicated in a previous
  timesync_wake_pins_acquire command. SVC will latch the FrameTime on the
  rising edge of the outbound pulse and will return the FrameTime to the
  AP Module in the response phase of the greybus transaction.

- svc::timesync_wake_pins_acquire(u32 strobe_mask)
  Used by the AP to tell the SVC to set a bit-mask of wake lines associated
  with a bit-mask of Interface IDs to a known initial state prior to the
  SVC generating a TimeSync related pulse such as timesync-enable or
  timesync-ping.

- svc::timesync_wake_pins_release(void)
  Used by the AP to tell the SVC to release all wake-detect lines in the
  timesync active state as previously specified in the
  timesync_wake_pins_acquire operation.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-14 18:26:24 +02:00
Sandeep Patil a974f469ff greybus: arche-platform: Fix the MODULE_LICENSE to match with header
The header calls out the license to be GPL v2, while the module declares
itself as "GPL"

Testing Done: Trivial

Signed-off-by: Sandeep Patil <sspatil@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-14 11:20:53 +02:00
Sandeep Patil 6458492e9c greybus: gpbridge: add uevent vars for gpbridge devices
The uevent vars now include module, interface, greybus_id,
bundle id, class and gpbridge device specific properties.

This make it consistent with how we are reporting uevents for
all other greybus devices.

Testing Done:
Tested by reading uevent from gpbridge devices that enumerate
using gpb module

Signed-off-by: Sandeep Patil <sspatil@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-14 11:19:41 +02:00
Sandeep Patil c7092b22fc greybus: gpbridge: make gpbridge device ids start with 1
Making gpb device ids consistent with all other devices on
greybus

Testing Done:
Tested using gpb module to make sure the first gpbX/ device
starts with 1.

Signed-off-by: Sandeep Patil <sspatil@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-14 11:19:41 +02:00
Sandeep Patil 14a5f47b29 greybus: gpbridge: add gpbridge device type
Right now, there is no way to know the device type of gpbridge
(bridged-phy) devices in userspace. So, add that.

Testing Done:
Tested by reading the 'uevent' for gpb device of gpbridge
module

Signed-off-by: Sandeep Patil <sspatil@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-14 11:19:41 +02:00
Johan Hovold 3ba9fa5c92 greybus: camera: fix data-connection handling
Now that core supports offloaded connections, we can remove the hack
that was used to setup the data connection.

Note that offloaded-resource management may need to be refined later,
but the current minimal implementation is enough to allow core to manage
the connections (e.g. needed for proper connection tear down and power
management).

This will also allow the camera driver to be converted to a bundle
driver.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-13 15:32:48 +02:00
Johan Hovold 3b05d8508f greybus: connection: add camera-data connected workaround
Firmware currently lacks a representation of the offloaded CDSI
connections and connected requests sent for these ports therefore fails.

Add a temporary work-around until this has been resolved in firmware.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-13 15:32:48 +02:00
Johan Hovold 045d356114 greybus: es2: add support for CDSI1 allocation
Use the new CPort-allocation callbacks to allow for rudimentary resource
management of the CDSI CPorts.

How to manage offloaded resources in a generic fashion is yet to be
determined, but this minimal implementation will allow core to manage
the camera data connection so that the current camera-driver hacks can
be removed. This is specifically required to be able to implement proper
connection closing and for power management.

Note that the CDSI CPorts can not (currently) be reset through the
USB vendor request.

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-05-13 15:32:48 +02:00
Johan Hovold e7b848c288 greybus: es2: clean up cport-reset handling
Move handling of CPort-reset exceptions to the reset handler.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-13 15:30:05 +02:00
Johan Hovold f2aae1c6e6 greybus: hd: generalise cport allocation
Generalise CPort allocation by allowing host-device drivers to override
the default implementation.

Also pass the connection flags down the stack as such information is
needed for proper CPort allocation. Specifically, this will initially be
used to allow the camera driver to allocate the dedicated CDSI CPorts.

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-05-13 15:30:05 +02:00
Johan Hovold 0506150766 greybus: es2: clean up CDSI CPort reservation
Clean up the CDSI CPort reservation by adding a host-device helper and
CPort defines.

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-05-13 15:30:05 +02:00
Johan Hovold be5d01f10b greybus: es2: fix probe error handling
Make sure to return -ENODEV when the expected endpoints are missing and
stop relying on a default error.

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-05-13 15:30:05 +02:00
Johan Hovold 74a5d93cee greybus: hd: move CPort allocation to host-device code
Move host-device CPort allocation to the host-device code.

Proper CPort allocation requires knowledge of the hardware and must be
handled by the host-device driver. This is an intermediate step that
moves the generic CPort-allocation code to the host-device code.

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-05-13 15:30:05 +02:00
Johan Hovold a8af16313d greybus: audio: mark the data connection as offloaded
Mark the data-connection as offloaded, that is, under control of the
host device (AP-bridge).

This prevents messages from being sent from or forwarded to the AP.

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-05-13 15:30:05 +02:00
Johan Hovold 781ac8662f greybus: connection: add helper for creating offloaded connection
Add helper for creating offloaded connection.

This can later be extended to support more elaborate resource
management.

Also fix a minor white space issue.

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-05-13 15:30:05 +02:00
Johan Hovold ca1f8f8090 greybus: connection: add offloaded connection flag
Add an offloaded connection flag, which is used to mark a connection as
offloaded and prevent drivers from initiating operation over it.

This will be used for the audio and camera data connections.

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-05-13 15:30:05 +02:00
Johan Hovold 0e9b41ab98 greybus: connection: add no-flow-control connection flag
Add a no-flow-control connection flag, which is set for connection that
should not have any flow-control feature enabled.

This flag is specifically set for all connections to the legacy ES3
bootrom, and will also be used by the camera driver eventually.

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-05-13 15:30:05 +02:00
Viresh Kumar 501cc8bd09 greybus: Fix probing of gpbridge devices
The gpbridge core tries to match the driver's id-table against all
CPorts available within the bundle for which the gpbridge bus was
created. The gpbdev here is unique for a cport_desc and only a single
cport_desc->protocol_id should be matched with the driver's id-table.

Fix it.

Tested on EVT 1.5 with a special manifest for GP module, where multiple
CPorts are part of the same Bridged PHY bundle.

Fixes: 75223f666687 ("gpbridge: implement gpbridge "bus" logic")
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-13 12:39:10 +02:00
Viresh Kumar e4e55360dd greybus: core: Rename greybus_module_match()
greybus_module_match() doesn't match modules anymore but bundle devices
and should be named correctly.

Though we can use greybus_bundle_match() as well, rest of the kernel
uses terminology like 'greybus_match_device' and so choosing that
instead.

Compile tested.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-13 12:39:10 +02:00
Viresh Kumar 6f8a028fd1 greybus: gpbridge: Expose protocol_id in sysfs
Right now, userspace doesn't have any way to find what protocol does a
gpbridge device implement. And this is essential for the scripts to
know, to expect what kind of device will be present inside the gpbN
directory.

Expose 'protocol_id' in sysfs to fix that.

Tested by checking that the field appears with GP module on EVT 1.5.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Sandeep Patil <sspatil@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-13 12:02:57 +02:00
Johan Hovold 792db396d3 greybus: interface: remove unused interface-version quirk
The interface-version request was just removed so remove the now unused
interface-version quirk.

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-05-13 12:02:57 +02:00
Johan Hovold ae0f6454bb greybus: interface: fix type in enable error message
Fix type of PTR_ERR in an interface-enable error message.

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-05-13 12:02:57 +02:00
Jeffrey Carlyle 03fba180ae greybus: svc: support status in svc_intf_activate response
Update per Greybus spec. Status attribute added to activate
response to return more detailed information about errors during
activate. If the Greybus response is GB_OP_SUCCESS, the caller
must also check the status attribute in the response to determine
if any other errors occurred.

Testing done: along with matchine firmware change, verified that modules
              were detected and enumerated as expected.

Signed-off-by: Jeffrey Carlyle <jcarlyle@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
2016-05-12 18:20:34 -07:00
David Lin c77bac08ec greybus: operation: fix an inconsistent indent
This patch fixes an inconsistent indent.

Testing Done:
- Build & boot

Signed-off-by: David Lin <dtwlin@google.com>
Acked-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-09 08:55:12 +02:00
Viresh Kumar c6cc8e73eb greybus: fw-download: Replace timer with delayed-work
The timeout-handlers need to call routines that can sleep and those
can't be called from interrupt context. The timer-handler is called in
interrupt context and so will hit a BUG() in vmalloc.c.

This patch moves away from timers to delayed-work, whose timeout handler
gets called in process context and can call the sleep-able routines
safely.

Note that this issue wasn't hit earlier when the initial patch for
timeouts was implemented due to some issues in the build arche_420. But
with the new build arche_440, the BUG started crashing the phone on
timeouts and so this fix is required.

Tested on EVT 1.5 by triggering fake timeouts, by not sending
release-firmware request for example. This is tested with build
arche_440.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-09 08:48:10 +02:00
Viresh Kumar a956d939af greybus: bootrom: Implement timeouts to detect Module failures
Its possible that the Module may fail to download the next stage
firmware, or to jump into it and boot into the new personality.

We have already seen examples of both of these cases on EVT 1.5.

This patch implements timeouts in the bootrom bundle driver, which now
expects the next request from the Module to be received at the AP within
1 second of the previous request/response. The time interval can be
increased later if required.

The timeouts are added between:
- AP_READY and FIRMWARE_SIZE operations
- FIRMWARE_SIZE and GET_FIRMWARE operations
- Two GET_FIRMWARE operations
- GET_FIRMWARE and READY_TO_BOOT operations
- READY_TO_BOOT operation and the call to the ->disconnect() event of
  the bootrom bundle (once the new hotplug request is received).

The timeout for the last case is kept at 5 seconds right now (random
value), as it may take a bit longer.

Because 'bootrom->fw' can be accessed simultaneously (from timeout
handler and incoming requests) and one of them can potentially free the
'->fw' structure, a mutex is also added to take care of such races while
accessing 'bootrom->fw' structure.

Also note that the '!bootrom->fw' check is moved to free_firmware()
routine.

Note that this version uses delayed-work (instead of timers used in
earlier attempt), as we need to call routines that can sleep from the
timeout handler.

Tested on EVT 1.5, by faking errors on certain requests, so that the
bootrom doesn't send any more requests. Normal case is working just fine
for audio and GP modules. This is tested with build arche_440.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-09 08:48:10 +02:00