Commit Graph

46 Commits

Author SHA1 Message Date
Alex Elder b09c94a1b7 greybus: start improving manifest parsing
Currently the module manifest parsing code is sort of representative
only and is not really very useful.

This patch begins doing "real" parsing of the module manifest.
It scans the module manifest to identify the descriptors it holds.
It then verifies there's only one module descriptor found, and
initializes new some fields in the gb_module structure based on what
it contains (converting what's found to native byte order).
Note that if anything unexpected is found or other errors occur when
parsing the manifest, the parse fails.

Because we now save this converted information when it's parsed we
no longer have a greybus_descriptor_module struct within a struct
gb_module.  And because we've already converted these values, we can
do a little less work displaying values in sysfs.  (We also now show
vendor, product, and version values in the right byte order.)  This
eliminates the need for greybus_string(), so get rid of it.

It also slightly simplifies the greybus module matching code.

Move some existing parsing code into a new file, "manifest.c".

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-10-02 21:18:41 -07:00
Alex Elder e88afa5811 greybus: introduce an operation abstraction
This patch defines a new "operation" abstraction.  An operation is a
request from by one end of a connection to the function (or AP) on
the other, coupled with a matching response returned to the requestor.
The request indicates some action to be performed by the target of
the request (such as "read some data").  Once the action has
completed the target sends back an operation response message.
Additional data can be supplied by the sender with its request,
and/or by the target with its resposne message.

Each request message has a unique id, generated by the sender.
The sender recognizes the matching response by the presence
of this id value.  Each end of a connection is responsible
for creating unique ids for the requests it sends.

An operation also has a type, whose interpretation is dependent on
the function type on the end of the connection opposite the sender.
It is up to the creator of an operation to fill in the data (if any)
to be sent with the request.

Note that not all requests are initiated by the AP.  Incoming data
on a module function can result in a request message being sent from
that function to the AP to notify of the data's arrival.  Once the
AP has processed this, it sends a response to the sender.

Every operation response contains a status byte.  If it's value
is 0, the operation was successful.  Any other value indicates
an error.

Add a defintion of U16_MAX to "kernel_ver.h".

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-10-02 21:18:41 -07:00
Alex Elder c68adb2f2c greybus: introduce a connection abstraction
Within a UniPro network a pair of CPorts can be linked to form a
UniPro Connection.  This patch creates a new abstraction to
represent an AP CPort that is connected with a CPort used by a
function within a Greybus module.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-10-02 21:18:41 -07:00
Alex Elder ef0d2ba201 greybus: define greybus function abstraction
Define new source files "function.h" and "function.c" to contain the
definitions of the Greybus function abstraction.  A Greybus function
represents an active entity connected to a CPort implemented by a
Greybus interface.  A Greybus function has a type, which defines the
protocol to be used to interact with the function.  A Greybus
interface normally has at least two functions, but potentially many
more.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-10-02 21:18:40 -07:00
Alex Elder 8c12cde3c2 greybus: define greybus interface abstraction
Define new source files "interface.h" and "interface.c" to contain
the definitions of the Greybus interface abstraction.  A Greybus
interface represents a UniPro device present in a UniPro module.
For Project Ara, each interface block on a module implements a
UniPro interface.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-10-02 21:17:20 -07:00
Alex Elder e1e9dbddfe greybus: isolate greybus module code
Define new source files "module.h" and "module.c" to separate the
definitions of the Greybus module abstraction from other code.

Rename "greybus_module" to be "gb_module", for brevity.  Do the same
for a few other symbols with "greybus_module" in their names.  A few
(like greybus_module_id) are more visible outside this kernel module
so we'll keep their names more descriptive.

Add a definition for U8_MAX in "kernel_ver.h" (it appeared in 3.14).

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-10-02 21:17:20 -07:00
Alex Elder ecf7d57971 greybus: descriptor type updates
Some more updates to the definition of a manifest descriptor.
    - We get rid of function descriptors.  The type of function is
      easily specified with the CPort it uses.
    - Add a new interface descriptor type.
    - Clean up the CPort descriptor structure, eliminating fields
      that serve no purpose and adding the function id field

The sysfs stuff will be updated a little later to add entries
for the Greybus interfaces associated with modules.

Rearrange the order of a few things in "greybus_manifest.h".

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-10-02 21:17:20 -07:00
Alex Elder 1cfc667d75 greybus: kill struct gmod_cport
A UniPro (short header) segment has a 5-bit field to represent a
CPort Id.  In addition, the 7-bit L3 short header holds a UniPro
device id.  There can be no more than 128 devices in a UniPro
network, but these two fields can be combined in ways to allow for
over 2000 CPorts within a single device.  As a result, a device id
is represented with one byte, and a CPort Id within a device is
always representable with a two byte value.

This patch changes integral values that reresent CPort Ids so they
use type u16 consistently.

Separately, the contents of the gmod_cport structure were mostly
fabricated, with the cport_id field being the only one that's
meaningful.  This patch gets rid of that structure, putting a
simple u16 to represent the CPort Id everywhere it had been used
before.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-09-30 18:19:12 -07:00
Alex Elder 51c75fd060 greybus: reorder greybus_svc_in() arguments
The two functions greybus_svc_in() and greybus_cport_in() do
very similar things, but their arguments are in a different order.
Move the greybus_host_device structure argument for greybus_svc_in()
to be first so the functions' prototypes are better aligned.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-09-29 18:08:14 -07:00
Alex Elder 0db32a6d5e greybus: some more renames
This patch renames of symbols, for better clarity and consistency.

    cport -> cport_id (when it represents a cport *number*)
    send_svc_msg -> submit_svc (like submit_gbuf)
    greybus_cport_in_data -> greybus_cport_in
    gb_new_ap_msg -> greybus_svc_in (like greybus_cport_in)
    cport->number -> cport->id (like cport_id)

Making the svc and cport message stuff more similar is done with an
eye toward having SVC messages and messages exchanged with other
modules use some more common communication mechanisms.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-09-29 18:00:55 -07:00
Matt Porter 4fc645494f greybus: remove serial number descriptor to match spec
Greybus spec was updated to remove the serial number descriptor and
move the serial number field to the, now mandatory, module descriptor.
Change everything accordingly.

Signed-off-by: Matt Porter <mporter@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-09-29 17:57:06 -07:00
Matt Porter 6d63ff7a2d greybus: update descriptor module_id->module to match spec
Greybus spec was updated to change the name of the Module ID descriptor
to simply Module descriptor. Change everything accordingly.

Signed-off-by: Matt Porter <mporter@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-09-29 17:54:08 -07:00
Alex Elder 2e353685bf greybus: embed workqueue structure in struct gbuf
A Greybus buffer containing outbound data is submitted to to the
underlying driver to be sent over a CPort.  Sending that data could
be deferred, so the submit operation completes asynchronously.  When
the send is done, a callback occurs, and the buffer is "completed",
and the buffer's completion routine is called.  The buffer is then
freed.

If data arrives on the CPort, greybus_cport_in_data() is called
to allocate a Greybus buffer and copy the received data into it.
Once that's done the buffer is completed, again allowing the
buffer's completion routine to finish any final tasks before
freeing the buffer.

We use a workqueue to schedule calling the buffer's completion
function.  This patch does two things related to the work queue:
    - Renames the work queue "gbuf_workqueue" so its name more
      directly describes its purpose
    - Moves the work_struct needed for scheduling completions
      into the struct greybuf.  Previously a separate type
      was used, and dynamically allocated *at interrupt time*
      to hold this work_struct.  We can now do away with that.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-09-23 20:58:00 -07:00
Alex Elder 778c69c9e2 greybus: rename struct greybus_device
The greybus_device structure represents an Ara phone module.
It does *not* (necessarily) represent a UniPro device, nor any
device (like an i2c adapter) that might reside on an Ara module.

As such, rename struct greybus_device to be struct greybus_module.
Rename all symbols having that type to be "gmod" rather than "gdev".

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-09-22 17:33:07 -07:00
Greg Kroah-Hartman 4a833fdb7f greybus: core: hook up the hotplug message
We should now try to parse the manifest and create a device based on the
manifest.  Not hooked up to the driver core yet, so removing it isn't
going to do anything except cause problems...
2014-09-21 19:17:55 -07:00
Greg Kroah-Hartman d0cfd109c7 greybus: ap: validate the rest of the svc message buffer sizes 2014-09-21 19:10:39 -07:00
Greg Kroah-Hartman 85e0066c59 greybus: greybus.h: add function prototype for add/remove a module 2014-09-21 18:17:12 -07:00
Greg Kroah-Hartman 3e7736e5c1 greybus: gbuf: clean up logic of who owns what "part" of the gbuf
Started documenting the gbuf and how a greybus driver and a host
controller driver needs to interact with it, and the rest of the greybus
system.  It's crude documentation, but better than nothing for now...
2014-09-21 17:34:28 -07:00
Greg Kroah-Hartman f036e05600 greybus: gbuf: implement submission logic 2014-09-19 19:13:33 -07:00
Matt Porter 52adb56340 greybus: update GREYBUS_VERSION_[MAJOR|MINOR] to match spec
The Greybus spec was updated to have major=0 and minor=1 so update
this in the code.

Signed-off-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-09-18 20:06:08 -07:00
Greg Kroah-Hartman 772149b6df greybus: fix hd init sequence of setting up parent and driver pointers properly 2014-09-14 12:27:28 -07:00
Greg Kroah-Hartman 45f3678bcf greybus: gbuf: cport in buffer stream logic 2014-09-14 11:40:35 -07:00
Greg Kroah-Hartman 80e04f0994 greybus: gbuf recieve path work, not done, dinner time... 2014-09-13 18:20:54 -07:00
Greg Kroah-Hartman 9c8d3afdb5 greybus: es1: handle cport data in and out 2014-09-13 11:09:35 -07:00
Greg Kroah-Hartman 112997324d greybus: es1: add the start of cport urb handling. 2014-09-12 21:17:37 -07:00
Greg Kroah-Hartman 8c53e073f7 greybus: AP: move a bunch of svc message handling logic into ap.c
Add a send_svc_msg() callback to the host driver.
hook up ES1 driver to send control USB messages as it's SVC transport.
2014-09-12 20:47:11 -07:00
Alex Elder 05ad189c23 greybus: switch to the term "manifest"
We agreed to rename a few things to improve clarity.  This patch
implements one of those changes.  The blob of data that describes
what's relevant to Greybus within an Ara module will now be called
the "module manifest."  In addition, in the context of Greybus we'll
also be calling what's in an Ara module a "module" or "Greybus module."

So this patch renames some structures and updates some comments.  It
also renames "greybus_desc.h" to be "greybus_manifest.h", and renames
greybus_new_device() to be greybus_new_module().

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-09-09 15:05:25 -07:00
Greg Kroah-Hartman 33ea3a3f56 greybus: add battery module 2014-09-07 15:39:34 -07:00
Greg Kroah-Hartman 68f1fc4d2c greybus: more hd work 2014-09-07 13:12:11 -07:00
Greg Kroah-Hartman a39879fc08 greybus: host controller additions
Also some gbuf functions starting to get fleshed out.
2014-09-06 16:57:36 -07:00
Greg Kroah-Hartman 06340efb7c greybus: split sysfs functions out to separate file. 2014-09-01 19:05:54 -07:00
Greg Kroah-Hartman e24e7257b1 greybus: greybus_string() 2014-09-01 19:01:14 -07:00
Greg Kroah-Hartman 21ee4116fd greybus: module id attributes 2014-09-01 18:57:42 -07:00
Greg Kroah-Hartman b94295e050 greybus: sysfs attributes for functions and more driver core integration. 2014-09-01 18:34:28 -07:00
Greg Kroah-Hartman 526c5c8d23 greybus: start parsing descriptor fields 2014-09-01 16:03:31 -07:00
Greg Kroah-Hartman a239f67c5d greybus: start parsing descriptor structures 2014-09-01 14:39:49 -07:00
Greg Kroah-Hartman 6dca7b97c7 greybus: get field names right for descriptors 2014-09-01 13:42:43 -07:00
Greg Kroah-Hartman 6584c8af70 greybus: s/greybus_device_id/greybus_module_id/g 2014-09-01 13:31:31 -07:00
Greg Kroah-Hartman 712d65915a greybus: greybus.h: tiny movement around 2014-09-01 09:51:51 -07:00
Greg Kroah-Hartman de536e3094 greybus: ap message loop added. 2014-08-31 16:17:04 -07:00
Greg Kroah-Hartman 27fb83109a greybus: register the bus with the driver core and add framework for debugfs files. 2014-08-31 13:54:59 -07:00
Greg Kroah-Hartman db6e1fd264 greybus: hook up sdio, gpio, and tty into the greybus core. 2014-08-30 16:47:26 -07:00
Greg Kroah-Hartman 199d68d4a8 greybus: start moving the function types into the greybus core 2014-08-30 16:20:22 -07:00
Greg Kroah-Hartman d5d1903dcd greybus: add framework for 'struct gbuf'
This is the equlivant of sk_buf or urbs for Greybus.
2014-08-11 19:03:20 +08:00
Greg Kroah-Hartman 776f136c75 greybus: greybus.h: tiny coding style cleanups 2014-08-11 17:27:07 +08:00
Greg Kroah-Hartman c8a797a98c greybus: Import most recent greybus code to new repo. 2014-08-11 15:30:45 +08:00