cascardo/linux.git
9 years agogreybus: descriptor type updates
Alex Elder [Thu, 2 Oct 2014 02:54:10 +0000 (21:54 -0500)]
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>
9 years agogreybus: fix error message on parse of cport descriptor size
Matt Porter [Wed, 1 Oct 2014 19:09:01 +0000 (15:09 -0400)]
greybus: fix error message on parse of cport descriptor size

Fix a simple cut and paste error that was reporting a serial
number header size error rather than a cport descriptor size
error.

Signed-off-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
9 years agogreybus: remove additional unused fields from the cport descriptor
Matt Porter [Wed, 1 Oct 2014 19:09:00 +0000 (15:09 -0400)]
greybus: remove additional unused fields from the cport descriptor

The Greybus spec was updated to remove some unused fields from the
CPort descriptor definition. Remove them from the structure so
we don't fail manifest parsing.

Signed-off-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
9 years agogreybus: clarify device vs module
Alex Elder [Wed, 1 Oct 2014 00:25:22 +0000 (19:25 -0500)]
greybus: clarify device vs module

The Project ARA MDK states that a single module can have more than
one interface block (up to 2 at the moment).  An interface block
consists of two bidirectional UniPro lanes (along with power and
detect lines), and effectively represents a UniPro Device (with
an id in the range 0-127).

The service messages currently use "module_id" everywhere, even
though in a lot of cases we really need to be talking about device
ids.  The easiest case of this to see is the "set route" request
directed at a switch; a switch has no notion of modules, just
UniPro devices.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
9 years agogreybus: es1: no BUG_ON() code, report an error and recover.
Greg Kroah-Hartman [Wed, 1 Oct 2014 01:21:36 +0000 (18:21 -0700)]
greybus: es1: no BUG_ON() code, report an error and recover.

9 years agogreybus: kill struct gmod_cport
Alex Elder [Wed, 1 Oct 2014 00:25:21 +0000 (19:25 -0500)]
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>
9 years agogreybus: es1-ap-usb: adjust SVC buffer size to handle worst case
Matt Porter [Tue, 30 Sep 2014 20:01:40 +0000 (16:01 -0400)]
greybus: es1-ap-usb: adjust SVC buffer size to handle worst case

The worst case message from the SVC->AP is a hotplug "plugged"
event. It includes the module manifest which may be up to 64KB
in size. Adjust our buffer allocation to allow for this.

Signed-off-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
9 years agogreybus: reorder greybus_svc_in() arguments
Alex Elder [Sat, 27 Sep 2014 01:55:35 +0000 (20:55 -0500)]
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>
9 years agogreybus: fix version check
Alex Elder [Sat, 27 Sep 2014 01:55:34 +0000 (20:55 -0500)]
greybus: fix version check

When we read a module manifest we are required to verify that its
version is compatible with the version the present code is able
to parse.  All that's required is a check of the major version
number.  If the manifest's major version is greater than the
software, the software can't assume it can parse it.  All new
code must be able to parse all old versions of the format.  And
any difference in minor version is supposed to have no effect
on parsability.

Update the version check to enforce this policy, and reword the
error message to do a better job of explaining the situation.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
9 years agogreybus: descriptor type is 1 byte
Alex Elder [Sat, 27 Sep 2014 01:55:33 +0000 (20:55 -0500)]
greybus: descriptor type is 1 byte

The spec was changed to require only one byte to represent the
type of a module descriptor.  Update our data type and the values
used to reflect that.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
9 years agogreybus: fix the guard in "greybus_manifest.h"
Alex Elder [Sat, 27 Sep 2014 01:55:32 +0000 (20:55 -0500)]
greybus: fix the guard in "greybus_manifest.h"

The tag in the #ifndef guard surrounding the content of
"greybus_manifest.h" needs to be updated to reflect the
actual name of the file.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
9 years agogreybus: fix document version number
Alex Elder [Wed, 24 Sep 2014 10:16:17 +0000 (05:16 -0500)]
greybus: fix document version number

Two spots use the old "0.draft" version number for the Greybus
protocol specification.  We've updated that to be 0.1.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
9 years agogreybus: update a few header file comments
Alex Elder [Wed, 24 Sep 2014 10:16:16 +0000 (05:16 -0500)]
greybus: update a few header file comments

Add a GPLv2 tag and reword some comments at the top of "greybus_desc.h"
and "svc_msg.h".

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
9 years agogreybus: some more renames
Alex Elder [Wed, 24 Sep 2014 10:16:14 +0000 (05:16 -0500)]
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>
9 years agogreybus: encapsulate URB status checking
Alex Elder [Wed, 24 Sep 2014 10:16:13 +0000 (05:16 -0500)]
greybus: encapsulate URB status checking

Define a new common function check_urb_status() that looks at the
status in a completed URB (containing incoming data) and issues
warnings in a consistent way.  It returns -EAGAIN to signal an
unrecognized status was seen, so the caller can ignore it and
re-post the URB to receive the next incoming data.  This
consolidates three blocks of code into one.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
9 years agogreybus: update descriptor type enums to match renumbering in spec
Matt Porter [Sat, 27 Sep 2014 01:49:52 +0000 (20:49 -0500)]
greybus: update descriptor type enums to match renumbering in spec

Greybus spec updated the descriptor type values and added an
additional class descriptor type. Change the enum 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>
9 years agogreybus: update string descriptor length field to __u8 type to match spec
Matt Porter [Sat, 27 Sep 2014 01:49:51 +0000 (20:49 -0500)]
greybus: update string descriptor length field to __u8 type to match spec

Greybus spec was updated to make the length field a single byte. Update
the type and remove endian handling of that field in the core.

Signed-off-by: Matt Porter <mporter@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
9 years agogreybus: remove unused function descriptor fields and change class->function_type
Matt Porter [Sat, 27 Sep 2014 01:49:50 +0000 (20:49 -0500)]
greybus: remove unused function descriptor fields and change class->function_type

Greybus spec was updated to remove a number of unused function descriptor
fields. In addition, the class field was change to function_type to avoid
confusion with the concept of high-level class drivers.

Signed-off-by: Matt Porter <mporter@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
9 years agogreybus: remove serial number descriptor to match spec
Matt Porter [Sat, 27 Sep 2014 01:49:49 +0000 (20:49 -0500)]
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>
9 years agogreybus: update descriptor module_id->module to match spec
Matt Porter [Sat, 27 Sep 2014 01:49:48 +0000 (20:49 -0500)]
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>
9 years agogreybus: fix up coding style issue I caused with the last patch...
Greg Kroah-Hartman [Wed, 24 Sep 2014 03:58:58 +0000 (20:58 -0700)]
greybus: fix up coding style issue I caused with the last patch...

9 years agogreybus: embed workqueue structure in struct gbuf
Alex Elder [Tue, 23 Sep 2014 17:46:36 +0000 (12:46 -0500)]
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>
9 years agogreybus: get rid of a weird idiom
Alex Elder [Tue, 23 Sep 2014 17:46:33 +0000 (12:46 -0500)]
greybus: get rid of a weird idiom

It strikes me as strange to add one to a value while checking to see
if it exceeds a maximum.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
9 years agogreybus: quick fix for sysfs serial number
Alex Elder [Tue, 23 Sep 2014 17:46:32 +0000 (12:46 -0500)]
greybus: quick fix for sysfs serial number

Let the serial number attribute have its own is_visible function.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
9 years agogreybus: rename struct greybus_device
Alex Elder [Tue, 23 Sep 2014 00:19:03 +0000 (19:19 -0500)]
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>
9 years agogreybus: simple fixes
Alex Elder [Mon, 22 Sep 2014 23:53:02 +0000 (18:53 -0500)]
greybus: simple fixes

A few silly little fixes.
    - Clear out some unnecessary #includes in "debugfs.c"
    - Drop some unneeded parentheses in hd_to_es1()
    - Use &hd->hd_priv in hd_to_es1() to emphasize we are working
      with an embedded array, not a pointer
    - Fix a comment in the header for ap_probe()
    - Drop a duplicate #include in "gpio-gb.c"
    - Fix a use-before-set problem in set_serial_info()

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
9 years agogreybus: initialize all fields in an SVC handshake message
Matt Porter [Mon, 22 Sep 2014 19:51:49 +0000 (15:51 -0400)]
greybus: initialize all fields in an SVC handshake message

Currently only the handshake_type is being initialized when
responding to an SVC handshake request. Update this to
explicitly set all header/payload fields appropriately.

Signed-off-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
9 years agogreybus: es1-ap-usb: fix svc control pipe flags
Matt Porter [Mon, 22 Sep 2014 19:51:48 +0000 (15:51 -0400)]
greybus: es1-ap-usb: fix svc control pipe flags

The control message flags currently indicate USB_DIR_IN, which
doesn't allow the data phase carrying the SVC message to be
send to the device. Change this to USB_DIR_OUT so our SVC
message buffer reaches the device.

Also, the recipient is USB_RECIP_OTHER but almost all real devices
that handle vendor setup requests seem to set this as
USB_RECIP_INTERFACE. As a result, functionfs-based gadgets don't handle
vendor setup requests with a recipient of OTHER. Change this to
USB_RECIP_INTERFACE to work with the functionfs-based emulator and
this should be no issue for the firmware to implement to match.

Signed-off-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
9 years agogreybus: core: hook up the hotplug message
Greg Kroah-Hartman [Mon, 22 Sep 2014 02:17:55 +0000 (19:17 -0700)]
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...

9 years agogreybus: ap: validate the rest of the svc message buffer sizes
Greg Kroah-Hartman [Mon, 22 Sep 2014 02:10:39 +0000 (19:10 -0700)]
greybus: ap: validate the rest of the svc message buffer sizes

9 years agogreybus: ap: start validating the message better
Greg Kroah-Hartman [Mon, 22 Sep 2014 01:19:54 +0000 (18:19 -0700)]
greybus: ap: start validating the message better

We check the type of the message now.

Start to check the size of the payload to match the size of the message
type.  Still more work to do needed here.

Also "hooked up" the hotplug message, but doesn't call anything as the
core doesn't implement that yet...

9 years agogreybus: core.c: create empty functions to keep linking working for hotplug/remove
Greg Kroah-Hartman [Mon, 22 Sep 2014 01:17:36 +0000 (18:17 -0700)]
greybus: core.c: create empty functions to keep linking working for hotplug/remove

9 years agogreybus: greybus.h: add function prototype for add/remove a module
Greg Kroah-Hartman [Mon, 22 Sep 2014 01:17:12 +0000 (18:17 -0700)]
greybus: greybus.h: add function prototype for add/remove a module

9 years agogreybus: svc_msg.h: add data for hotplug message
Greg Kroah-Hartman [Mon, 22 Sep 2014 01:16:41 +0000 (18:16 -0700)]
greybus: svc_msg.h: add data for hotplug message

9 years agogreybus: gbuf: clean up logic of who owns what "part" of the gbuf
Greg Kroah-Hartman [Mon, 22 Sep 2014 00:34:28 +0000 (17:34 -0700)]
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...

9 years agogreybus: gbuf: implement submission logic
Greg Kroah-Hartman [Sat, 20 Sep 2014 02:13:33 +0000 (19:13 -0700)]
greybus: gbuf: implement submission logic

9 years agogreybus: es1: set buffer sizes for messages based on email discussions
Greg Kroah-Hartman [Sat, 20 Sep 2014 01:37:44 +0000 (18:37 -0700)]
greybus: es1: set buffer sizes for messages based on email discussions

The gbuf sizes are 4k (i.e. PAGE_SIZE) and svc interrupt urb is 2k

9 years agogreybus: update GREYBUS_VERSION_[MAJOR|MINOR] to match spec
Matt Porter [Thu, 18 Sep 2014 19:25:43 +0000 (15:25 -0400)]
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>
9 years agogreybus: move versioning from svc message header to handshake function
Matt Porter [Thu, 18 Sep 2014 19:25:42 +0000 (15:25 -0400)]
greybus: move versioning from svc message header to handshake function

The Greybus spec has been updated to improve the efficiency of the
version major/minor information that had been previously carried in
every SVC message header. The version major/minor is now provided
as part of the handshake function.

Update the SVC msg header and handshake function payload definitions
and move the version major/minor validation into the SVC handshake
handling routine.

Signed-off-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
9 years agogreybus: update svc_msg_header fields and users to match spec
Matt Porter [Thu, 18 Sep 2014 19:25:41 +0000 (15:25 -0400)]
greybus: update svc_msg_header fields and users to match spec

The Greybus spec has been updated to clarify some of the original
intent of the SVC message definition. The svc_msg_header was:

struct svc_msg_header {
__u8 function;
__u8 message_type;
...
}

and is now

struct svc_msg_header {
__u8 function_id;
__u8 message_type;
...
}

to match the spec. The function_id carries enum svc_function_id values
and message_type is now clarified to be a session layer level field
that is simply "data" or "error".

Change all references of function type to function id. For now, don't
parse the message_type field but add the two allowable svc_msg_type enums.

Signed-off-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
9 years agogreybus: fix hd init sequence of setting up parent and driver pointers properly
Greg Kroah-Hartman [Sun, 14 Sep 2014 19:27:28 +0000 (12:27 -0700)]
greybus: fix hd init sequence of setting up parent and driver pointers properly

9 years agogreybus: add test_sink driver
Greg Kroah-Hartman [Sun, 14 Sep 2014 19:27:19 +0000 (12:27 -0700)]
greybus: add test_sink driver

9 years agogreybus: gbuf: cport in buffer stream logic
Greg Kroah-Hartman [Sun, 14 Sep 2014 18:40:35 +0000 (11:40 -0700)]
greybus: gbuf: cport in buffer stream logic

9 years agogreybus: gbuf recieve path work, not done, dinner time...
Greg Kroah-Hartman [Sun, 14 Sep 2014 01:20:54 +0000 (18:20 -0700)]
greybus: gbuf recieve path work, not done, dinner time...

9 years agogreybus: devices: endpoint description of device
Greg Kroah-Hartman [Sun, 14 Sep 2014 00:31:27 +0000 (17:31 -0700)]
greybus: devices: endpoint description of device

9 years agogreybus: es1: functionally complete
Greg Kroah-Hartman [Sun, 14 Sep 2014 00:28:33 +0000 (17:28 -0700)]
greybus: es1: functionally complete

Have only tested USB device add/remove, the urbs seem to all be queued
up, no data has been tested to flow through yet.

Odds are the hc interface will have to change, but this is a good first
start to build on.

9 years agogreybus: core: verify major/minor number of greybus protocol
Greg Kroah-Hartman [Sun, 14 Sep 2014 00:28:19 +0000 (17:28 -0700)]
greybus: core: verify major/minor number of greybus protocol

9 years agogreybus: uart-gb: let the core dynamically allocate the major number
Greg Kroah-Hartman [Sun, 14 Sep 2014 00:02:47 +0000 (17:02 -0700)]
greybus: uart-gb: let the core dynamically allocate the major number

Don't register the tty_gb_driver, the gb core is not ready for the for
ES1 devices.

9 years agogreybus: tty driver fixes to get init working properly
Greg Kroah-Hartman [Sat, 13 Sep 2014 23:15:52 +0000 (16:15 -0700)]
greybus: tty driver fixes to get init working properly

9 years agogreybus: es1 endpoint descriptor: minor fixes to get the config right
Greg Kroah-Hartman [Sat, 13 Sep 2014 23:15:07 +0000 (16:15 -0700)]
greybus: es1 endpoint descriptor: minor fixes to get the config right

9 years agogreybus: Makefile: add 'check' option to run sparse with endian checks enabled
Greg Kroah-Hartman [Sat, 13 Sep 2014 19:39:23 +0000 (12:39 -0700)]
greybus: Makefile: add 'check' option to run sparse with endian checks enabled

9 years agogreybus: ap: cleanup of process ap message loop
Greg Kroah-Hartman [Sat, 13 Sep 2014 19:18:09 +0000 (12:18 -0700)]
greybus: ap: cleanup of process ap message loop

9 years agogreybus: ap: convert to workqueue from thread
Greg Kroah-Hartman [Sat, 13 Sep 2014 18:35:02 +0000 (11:35 -0700)]
greybus: ap: convert to workqueue from thread

9 years agogreybus: es1: handle cport data in and out
Greg Kroah-Hartman [Sat, 13 Sep 2014 18:09:35 +0000 (11:09 -0700)]
greybus: es1: handle cport data in and out

9 years agogreybus: es1: allocate cport out urbs properly
Greg Kroah-Hartman [Sat, 13 Sep 2014 16:54:35 +0000 (09:54 -0700)]
greybus: es1: allocate cport out urbs properly

9 years agogreybus: es1: add the start of cport urb handling.
Greg Kroah-Hartman [Sat, 13 Sep 2014 04:17:37 +0000 (21:17 -0700)]
greybus: es1: add the start of cport urb handling.

9 years agogreybus: AP: move a bunch of svc message handling logic into ap.c
Greg Kroah-Hartman [Sat, 13 Sep 2014 03:47:11 +0000 (20:47 -0700)]
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.

9 years agogreybus: Merge branch 'master' of github.com:gregkh/greybus
Greg Kroah-Hartman [Thu, 11 Sep 2014 15:22:57 +0000 (08:22 -0700)]
greybus: Merge branch 'master' of github.com:gregkh/greybus

9 years agogreybus: Fix build errors on older kernels.
Greg Kroah-Hartman [Thu, 11 Sep 2014 15:22:06 +0000 (08:22 -0700)]
greybus: Fix build errors on older kernels.

Thanks to Marti for pointing out the code didn't build properly on 3.10.
Added kernel_ver.h to handle any api mis-matches between the code and
older kernel versions.

9 years agogreybus: fix endian issue in sysfs.c
Greg Kroah-Hartman [Thu, 11 Sep 2014 00:12:20 +0000 (17:12 -0700)]
greybus: fix endian issue in sysfs.c

9 years agogreybus: pass appropriate type to create function
Greg Kroah-Hartman [Wed, 10 Sep 2014 00:16:54 +0000 (17:16 -0700)]
greybus: pass appropriate type to create function

Based on a patch from Alex Elder <elder@linaro.org>.

Alex's original description:

Every descriptor in a manifest is interpreted by greybus_new_module().
We call a function to do initialization based on descriptor's type.

Since we know the type of the descriptor at that point, we can pass
to the called function the actual sub-type it needs (i.e., the union
member associated with the type).  This allows those functions to
be slightly simplified, and more focused.

Also change some size variables to have size_t type, and simplify a
few spots further by using sizeof(object) in place of sizeof(type).

9 years agogreybus: fix manifest parsing size bug
Alex Elder [Tue, 9 Sep 2014 18:55:09 +0000 (13:55 -0500)]
greybus: fix manifest parsing size bug

The type-specific "create" routines that get called while parsing
the descriptor entries in the module manifest assume the size they
are provided is the size of their data portion only--not including
the descriptor header.

Compute this value in greybus_new_module(), and pass it to those
functions rather than the full descriptor size.  Move a few
declarations to the innermost block that uses them.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
9 years agogreybus: validate descriptor sizes
Alex Elder [Tue, 9 Sep 2014 18:55:08 +0000 (13:55 -0500)]
greybus: validate descriptor sizes

When interpreting a manifest descriptor header, don't assume there
is enough space in the buffer to hold a descriptor header.  Also,
verify the remaining buffer is at least as big as the reported
descriptor size.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
9 years agogreybus: interpret descriptor type properly
Alex Elder [Tue, 9 Sep 2014 18:55:07 +0000 (13:55 -0500)]
greybus: interpret descriptor type properly

The type field in a manifest descriptor header is in little endian
format.  Make sure we interpret it that way.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
9 years agogreybus: call put_device() on error
Alex Elder [Tue, 9 Sep 2014 18:55:06 +0000 (13:55 -0500)]
greybus: call put_device() on error

As soon as we've called device_initialize() we're required to call
put_device() in order to drop our reference to the device structure.
This was missed in the error path in greybus_new_module().  Fix that.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
9 years agogreybus: define struct greybus_manifest
Alex Elder [Tue, 9 Sep 2014 18:55:04 +0000 (13:55 -0500)]
greybus: define struct greybus_manifest

Define a structure that describes the entire greybus manifest.
Adjust greybus_new_module() to use that, making it explicit that
it's not just a header that's being provided to that function.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
9 years agogreybus: switch to the term "manifest"
Alex Elder [Tue, 9 Sep 2014 18:55:03 +0000 (13:55 -0500)]
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>
9 years agogreybus: es1: forgot to free our urb on disconnect
Greg Kroah-Hartman [Tue, 9 Sep 2014 03:11:18 +0000 (20:11 -0700)]
greybus: es1: forgot to free our urb on disconnect

9 years agogreybus: es1: finialized USB device structure
Greg Kroah-Hartman [Tue, 9 Sep 2014 03:09:08 +0000 (20:09 -0700)]
greybus: es1: finialized USB device structure

Set up device properly and start up the SVC interrupt in endpoint for
processing data

9 years agogreybus: es1_ap_desc.c: updated ES1 USB device descriptor
Greg Kroah-Hartman [Tue, 9 Sep 2014 02:34:30 +0000 (19:34 -0700)]
greybus: es1_ap_desc.c: updated ES1 USB device descriptor

Interrupt IN endpoint added.

9 years agogreybus: minor whitespace cleanups to make checkpatch.pl happy
Greg Kroah-Hartman [Sun, 7 Sep 2014 22:57:07 +0000 (15:57 -0700)]
greybus: minor whitespace cleanups to make checkpatch.pl happy

9 years agogreybus: battery FIXME added
Greg Kroah-Hartman [Sun, 7 Sep 2014 22:54:24 +0000 (15:54 -0700)]
greybus: battery FIXME added

9 years agogreybus: add battery module
Greg Kroah-Hartman [Sun, 7 Sep 2014 22:39:34 +0000 (15:39 -0700)]
greybus: add battery module

9 years agogreybus: first cut at parsing svc messages sent to the AP
Greg Kroah-Hartman [Sun, 7 Sep 2014 20:51:12 +0000 (13:51 -0700)]
greybus: first cut at parsing svc messages sent to the AP

9 years agogreybus: more hd work
Greg Kroah-Hartman [Sun, 7 Sep 2014 20:12:11 +0000 (13:12 -0700)]
greybus: more hd work

9 years agogreybus: host controller additions
Greg Kroah-Hartman [Sat, 6 Sep 2014 23:57:36 +0000 (16:57 -0700)]
greybus: host controller additions

Also some gbuf functions starting to get fleshed out.

9 years agogreybus: add es1_ap_desc.c to describe the ES1 USB device descriptors
Greg Kroah-Hartman [Sat, 6 Sep 2014 20:13:13 +0000 (13:13 -0700)]
greybus: add es1_ap_desc.c to describe the ES1 USB device descriptors

9 years agogreybus: uart-gb: remove unneeded THIS_MODULE setting
Greg Kroah-Hartman [Sat, 6 Sep 2014 18:42:25 +0000 (11:42 -0700)]
greybus: uart-gb: remove unneeded THIS_MODULE setting

9 years agogreybus: uart-gb.c: dynamically allocate device numbers
Marti Bolivar [Sat, 6 Sep 2014 03:56:10 +0000 (23:56 -0400)]
greybus: uart-gb.c: dynamically allocate device numbers

9 years agogreybus: uart-gb.c: replace alloc_tty_driver with tty_alloc_driver
Marti Bolivar [Sat, 6 Sep 2014 03:56:09 +0000 (23:56 -0400)]
greybus: uart-gb.c: replace alloc_tty_driver with tty_alloc_driver

alloc_tty_driver() is deprecated.

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
9 years agogreybus: add proper packing to all greybus message types
Greg Kroah-Hartman [Tue, 2 Sep 2014 17:51:56 +0000 (10:51 -0700)]
greybus: add proper packing to all greybus message types

9 years agogreybus: minor checkpatch cleanups
Greg Kroah-Hartman [Tue, 2 Sep 2014 02:10:06 +0000 (19:10 -0700)]
greybus: minor checkpatch cleanups

9 years agogreybus: split sysfs functions out to separate file.
Greg Kroah-Hartman [Tue, 2 Sep 2014 02:05:54 +0000 (19:05 -0700)]
greybus: split sysfs functions out to separate file.

9 years agogreybus: greybus_string()
Greg Kroah-Hartman [Tue, 2 Sep 2014 02:01:14 +0000 (19:01 -0700)]
greybus: greybus_string()

9 years agogreybus: module id attributes
Greg Kroah-Hartman [Tue, 2 Sep 2014 01:57:42 +0000 (18:57 -0700)]
greybus: module id attributes

9 years agogreybus: serial number attribute added
Greg Kroah-Hartman [Tue, 2 Sep 2014 01:41:39 +0000 (18:41 -0700)]
greybus: serial number attribute added

9 years agogreybus: sysfs attributes for functions and more driver core integration.
Greg Kroah-Hartman [Tue, 2 Sep 2014 01:34:28 +0000 (18:34 -0700)]
greybus: sysfs attributes for functions and more driver core integration.

9 years agogreybus: start parsing descriptor fields
Greg Kroah-Hartman [Mon, 1 Sep 2014 23:03:31 +0000 (16:03 -0700)]
greybus: start parsing descriptor fields

9 years agogreybus: start parsing descriptor structures
Greg Kroah-Hartman [Mon, 1 Sep 2014 21:39:49 +0000 (14:39 -0700)]
greybus: start parsing descriptor structures

9 years agogreybus: export gb_new_ap_msg so that the es1 module can use it
Greg Kroah-Hartman [Mon, 1 Sep 2014 21:39:34 +0000 (14:39 -0700)]
greybus: export gb_new_ap_msg so that the es1 module can use it

9 years agogreybus: turn off warnings for es1-ap-usb.c to make it easier to build for now...
Greg Kroah-Hartman [Mon, 1 Sep 2014 21:39:14 +0000 (14:39 -0700)]
greybus: turn off warnings for es1-ap-usb.c to make it easier to build for now...

9 years agogreybus: get field names right for descriptors
Greg Kroah-Hartman [Mon, 1 Sep 2014 20:42:43 +0000 (13:42 -0700)]
greybus: get field names right for descriptors

9 years agogreybus: s/greybus_device_id/greybus_module_id/g
Greg Kroah-Hartman [Mon, 1 Sep 2014 20:31:31 +0000 (13:31 -0700)]
greybus: s/greybus_device_id/greybus_module_id/g

9 years agogreybus: more changes due to name changes in the greybus document
Greg Kroah-Hartman [Mon, 1 Sep 2014 17:59:08 +0000 (10:59 -0700)]
greybus: more changes due to name changes in the greybus document

9 years agogreybus: greybus.h: tiny movement around
Greg Kroah-Hartman [Mon, 1 Sep 2014 16:51:51 +0000 (09:51 -0700)]
greybus: greybus.h: tiny movement around

9 years agogreybus: header file s/u8/__u8/g
Greg Kroah-Hartman [Mon, 1 Sep 2014 16:51:33 +0000 (09:51 -0700)]
greybus: header file s/u8/__u8/g

9 years agogreybus: greybus_desc.h created
Greg Kroah-Hartman [Mon, 1 Sep 2014 01:08:52 +0000 (18:08 -0700)]
greybus: greybus_desc.h created

9 years agogreybus: split svc msg out into separate header file
Greg Kroah-Hartman [Mon, 1 Sep 2014 00:43:38 +0000 (17:43 -0700)]
greybus: split svc msg out into separate header file

9 years agogreybus: more structure definitions added
Greg Kroah-Hartman [Mon, 1 Sep 2014 00:25:22 +0000 (17:25 -0700)]
greybus: more structure definitions added

9 years agogreybus: structures added
Greg Kroah-Hartman [Sun, 31 Aug 2014 23:21:33 +0000 (16:21 -0700)]
greybus: structures added