Commit graph

28 commits

Author SHA1 Message Date
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 7326e07b58 greybus: interface: register control device at hotplug
Make sure to register also the control device along with any bundles
when registering an interface.

Note that we currently ignore failures to register the control device
just as we do for bundle devices.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 10:06:00 +09:00
Johan Hovold a6e5b014b8 greybus: core: make the control object be a device
Make the control object be a greybus device.

The control device will be used to expose attributes specific to
greybus-type interfaces.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-21 10:06:00 +09:00
Johan Hovold 1ed8cdef40 greybus: control: move timesync-operation functions
Move the timesync-operation functions above the control-object
management functions, which is where all other operation implementations
reside.

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:06:00 +09:00
Bryan O'Donoghue 777471a445 greybus: Fixup __u64, __u32 to __le64, __le32 in timesync declarations
A number of data in TimeSync command structures are declared __u64/__u32
instead of __le64/__le32, I forgot to put this through an x86_64 compile
before presentation for merge and as a result didn't catch this error. This
patch fixes.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-04-12 22:33:39 -07:00
Johan Hovold ec199ccdd2 greybus: interface: clean up ES3-bootroom-quirk handling
Clean up handling of the ES3-bootrom quirks by adding an interface
quirk-flags field that is set appropriately when we detect that the ES3
bootrom is running.

Note that we need to reserve the DME_DIS_UNIPRO_BOOT_STARTED and
DME_DIS_FALLBACK_UNIPRO_BOOT_STARTED status values for the ES3 bootrom,
which does not support any CPort features (unlike later boot stages).
Add a BOOTROM infix to the defines to make this more clear.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-03-30 14:17:40 -07:00
Greg Kroah-Hartman 0ec3063244 greybus: convert drivers to use connection->private set/get
This converts all drivers to use the gb_connection_get_data() and
gb_connection_set_data() functions to make it a bit more explicit as to
what is going on.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-03-22 16:47:28 -04:00
Bryan O'Donoghue 8fd9466b8c greybus: control: Add TimeSync control commands
Simple addition of the TimeSync commands defined in the specification.
Note for the case of timesync_authoritative we're passing the request
structure directly so as not to have to pass eight parameters into the
function.

Adds:
- control.c::timesync_enable(u8 count, u64 frame_time,
                             u32 strobe_delay, u32 refclk)
  Informs an Interface to expect count TimeSync strobe pulses with
  strobe_delay milliseconds delay between each strobe. Once enabled
  an Interface may not enter a low-power mode which will result in the
  reference timer used to track time switching off.

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

- control.c::timesync_authoritative(u64 *frame_time, u8 count)
  Used by the AP Module to inform an Interface of the authoritative
  TimeSync clock-master time at each strobe pulse. Down-stream clock slaves
  shall adjust their local frame-time appropriately based on the
  diseminated authoritative frame-time.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-03-03 15:22:52 -08:00
Viresh Kumar ee9627bce7 greybus: control: Fix sparse warnings
gb_control_get_version() is not used outside of the file and must be
marked as static. Following sparse warnings are reported today:

greybus/control.c:20:5: warning: symbol 'gb_control_get_version' was not declared. Should it be static?

Fix it by marking gb_control_get_version() 'static'.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-02-02 21:26:32 -08:00
Johan Hovold 24e094d687 greybus: connection: return error-valued pointer on creation errors
Return an ERR_PTR on errors when creating connections.

This allows driver probe to fail with a more informative error message
as not all connection creation errors are due to memory exhaustion.

Reviewed-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-01-21 22:45:09 -08:00
Johan Hovold 59507e2612 greybus: connection: add helper to create control connections
Add dedicated helper to create control connections.

This will allow us to simplify the generic (dynamic) interface.

Reviewed-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-01-21 22:45:09 -08:00
Johan Hovold b807aa7aa5 greybus: control: add bundle-version operation
Add bundle-version operation to fetch the version of the bundle class.

Retrieve the bundle version of all bundles when initialising the
interface in case the control-protocol version is greater than 0.1.

Reviewed-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-01-19 12:17:13 -08:00
Johan Hovold e217ae762b greybus: control: drop legacy-protocol dependency
Drop dependency on the legacy protocol abstraction.

Instead implement the protocol-specific version request directly, and
use the new interface for managing the control connection.

Note that the version request is being removed from most protocols, but
we need to keep the current request for the control protocol as-is
indefinitely to maintain backwards compatibility (e.g. with the ES2/ES3
bootrom).

Reviewed-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-01-19 12:17:13 -08:00
Johan Hovold 6bd6e14893 greybus: greybus_protocols: remove control-protocol version
Remove control-protocol version from the exported protocol definitions
as it is an implementation detail that makes no sense to export.

Currently gbsim uses the kernel's control-protocol version definitions
directly instead of reporting the version of the protocol it actually
implements.

Reviewed-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-01-19 12:17:13 -08:00
Johan Hovold bc3be1705c greybus: connection: remove skip-connected legacy protocol flags
Remove the legacy protocol flags that were used to suppress the
connected and disconnected events.

Instead send the connected and disconnected event for all bundle
connections and explicitly exclude static connections and control
connections.

Reviewed-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-01-19 12:17:13 -08:00
Johan Hovold 6d3d95042e greybus: connection: rename legacy init and exit functions
Rename legacy connection init and exit functions.

This is a step towards removing the legacy-protocol handling from core.

Reviewed-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-01-19 12:12:40 -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 5b22521c89 greybus: control: Use Macro's instead of direct values for major/minor
We already have macro's defined for this, use them.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-22 18:20:39 -08:00
Johan Hovold c634650ecc greybus: interface: clean up control-connection handling
Clean up control-connection handling by managing it through the control
structure and a higher-level control interface. Also make both the
control structure and connection lifetimes coincide with that of the
interface.

The control connection is now only enabled and disabled when the
interface is initialised and removed.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-12-15 14:23:37 -08:00
Johan Hovold 7fa530ad1b greybus: control: do not assume a control bundle
The control bundle is going away so update the code.

Also remove defensive WARN_ON which would not just warn if our
implementation is broken, but also leak further memory unnecessarily.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-25 15:39:16 -08:00
Johan Hovold 41a7fe27d6 greybus: control: remove unused request handler
Remove request handler for control protocol that makes no sense as we do
not have any incoming control requests defined.

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-02 11:26:44 -08:00
Greg Kroah-Hartman defa37ea9b greybus: control: use the bundle struct device instead of the connector
We are removing struct device from the gb_connection structure in the
near future.  The gb_bundle structure's struct device should be used as
a replacement.

This patch moves the control code to use the bundle pointer instead
of the connection pointer for printing out error messages.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>
2015-10-15 09:19:15 -07:00
Viresh Kumar 5a5296bb8d greybus: Add flags to struct gb_protocol
This helps in removing special per-protocol code, with the help of
generic flags passed by protocol drivers.

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-09-14 21:19:46 -07:00
Viresh Kumar 0e2462d1b7 greybus: Drop protocol specific _PROTOCOL_VERSION and _INVALID macros
Greybus core supports protocol independent macros for this now, use
them.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-08-14 14:34:14 -07:00
Viresh Kumar 507d75c4f4 greybus: control: Drop get_version support
This is done from a common place now, no need to replicate it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-08-11 19:33:05 -07:00
Johan Hovold 1c7658cf51 greybus: operation: fix atomic response allocation
Response allocation also needs a GFP-flags argument as a response is
allocated as part of an outgoing operation.

Fixes: 9aa174d202e5 ("operation: allow atomic operation allocations")
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-20 16:14:29 -07:00
Viresh Kumar 463e8736a3 greybus: control: Use gb_builtin_protocol_driver()
No need to write simple init/exit routines, use
gb_builtin_protocol_driver().

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-01 16:34:55 -07:00
Viresh Kumar cdee4f7505 greybus: Add control protocol support
Add control protocol driver that is responsible for handling operations
on control CPort. The AP also needs to support incoming requests on its
control port. Features not implemented yet are marked as TODO for now.

NOTE: This also fixes cport-bundle-id to 0 and cport-id to 2 for control
protocol.

Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-06-23 23:16:15 -07:00