]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/log
mirror_ubuntu-jammy-kernel.git
8 years agogreybus: Loopback_test: use poll instead of inotify
Axel Haslam [Fri, 26 Feb 2016 10:39:49 +0000 (11:39 +0100)]
greybus: Loopback_test: use poll instead of inotify

Inotify does not handle sysfs events, so use poll instead.

The loopback kernel driver will send a notification when the test is
complete. So, open a poll file descriptor for every enabled device,
and after starting the test, wait for an event from each device.
After all events are received, read the total number of iterations
and make sure the test is complete.

Also, add missing stdint header which was included in inotify.

Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: Notify user space only when the test finished.
Axel Haslam [Fri, 26 Feb 2016 10:39:48 +0000 (11:39 +0100)]
greybus: Notify user space only when the test finished.

Currently, user space is notified for every message sent,
but this is not really needed and does not work in the async case
where all messages are sent from the start.

Instead, notify userspace only when all the transfers are complete.
This allows userspace to wait in a poll loop and wakeup only when
the test is finished.

Also, don't use the bundle kobj to send the notification it is
the loopback device that contains the loopback attributes.

Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: hid: Replace WARN_ON() with dev_err()
Viresh Kumar [Fri, 26 Feb 2016 11:14:19 +0000 (16:44 +0530)]
greybus: hid: Replace WARN_ON() with dev_err()

WARN_ON() is a bit harsh here, as we just failed to power-off the HID
device while it is getting removed.

Replace it with dev_err().

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>
8 years agogreybus: hid: Don't disable connection-tx before destroying hid-device
Viresh Kumar [Mon, 29 Feb 2016 06:49:50 +0000 (12:19 +0530)]
greybus: hid: Don't disable connection-tx before destroying hid-device

hid_destroy_device() can potentially call callbacks defined in struct
hid_ll_driver, which may initiate few greybus operations.

And so connection (tx) should be kept enabled until the hid-device isn't
destroyed.

Reported-by: Jiss Kuruvila <jkuruvila@google.com>
Reported-by: Laurent Pinchart <laurent.pinchart@linaro.org>
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>
8 years agogreybus: audio: Register CPorts for specific directions
Mark Greer [Sat, 27 Feb 2016 00:04:36 +0000 (17:04 -0700)]
greybus: audio: Register CPorts for specific directions

Currently, it is assumed that all audio data CPorts registered on
APB1 are used for transmitting audio data.  That may not always be
true like when a microphone is connected but no speakers.  Also,
the current special protocol lacks a way to tell APB1 whether the CPort
being registered is for transmitting, receiving, or both.

Fix by adding a 'direction' field to the register and unregister CPort
requests and define bits indicating which direction (or both) audio
data will go on that CPort.

Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: expose full 32 bits of vid/pid to userspace
Greg Kroah-Hartman [Sat, 27 Feb 2016 05:54:38 +0000 (21:54 -0800)]
greybus: expose full 32 bits of vid/pid to userspace

Now that userspace is ready for all 32 bits of the vid/pid, take off our
mask and send the full values.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: loopback: Fix averaging
Alexandre Bailon [Thu, 25 Feb 2016 17:19:16 +0000 (18:19 +0100)]
greybus: loopback: Fix averaging

Currently, we are adding 0.5 to the average to round the average.
But we are using the remainder to calculate the decimal, so we do not
need to round the average.
In addition, use a u64 type for the remainder to avoid overflow
that might happen when stats->sum value is too big,
usually for requests per seconds and the throughput.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: loopback: Fix throughput calculations
Alexandre Bailon [Thu, 25 Feb 2016 17:19:15 +0000 (18:19 +0100)]
greybus: loopback: Fix throughput calculations

Throughput and requests per second calculations are broken for
asynchronous request.
Instead of calculate the throughput for each iteration,
calculate it once at the end of the test.
In addition, update every seconds the min and the max
for throughput and requests per second.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: loopback: Fix incoherency in calculations in the case of error
Alexandre Bailon [Thu, 25 Feb 2016 17:19:14 +0000 (18:19 +0100)]
greybus: loopback: Fix incoherency in calculations in the case of error

Currently, in case the case of error, statistics are updated for
asynchronous but not for an asynchronous operation.
Do not update the statistics in the case of error.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: loopback: Fix calculations error for ping transfers
Alexandre Bailon [Thu, 25 Feb 2016 17:19:13 +0000 (18:19 +0100)]
greybus: loopback: Fix calculations error for ping transfers

For the async ping transfer, statistics are counted twice,
once after the after the gb_loopback_async_operation() and
once in the callback.
Only keep the one in the callback.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: lights: remove unnecessary check
Rui Miguel Silva [Thu, 25 Feb 2016 18:05:09 +0000 (18:05 +0000)]
greybus: lights: remove unnecessary check

lights can never be NULL at that point since lights_count must be different than
zero, and we need only to validate the light_id.

Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Disable HUB3613 only in APB poweroff fn
Vaibhav Hiremath [Thu, 25 Feb 2016 11:15:45 +0000 (16:45 +0530)]
greybus: arche-platform: Disable HUB3613 only in APB poweroff fn

HUB3613 configuration, either disable (Standby mode) or enable (HUB mode)
is related to APB. So it makes perfect sense to put both of them
together in one function.

HUB3613 enable happens only at one place, in hub_conf_delayed_work() fn,
but disable is initiated from multiple places.
Move all calls to usb3613_hub_mode_ctrl(false) to apb_poweroff().

Testing Done: Tested on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Make sure APB power cycles on coldboot
Vaibhav Hiremath [Thu, 25 Feb 2016 11:15:44 +0000 (16:45 +0530)]
greybus: arche-platform: Make sure APB power cycles on coldboot

On first wake/detect pulse, everything works fine, as APB would be
in poweroff state initially.
But on subsequent wake/detect pulses, where APB is already in active
state, internal function just returns doing nothing, as it finds that
device is already in active state.

So the solution would be to make sure that, whenever execution reaches
to coldboot, make sure we power cycle it. Power off first, before
powering on.

Interrupt handler takes care of ignoring < 30msec pulses, so we should
be safe here to power cycle APB.

Testing Done: Testd on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: operation: add support for short responses
Johan Hovold [Thu, 25 Feb 2016 13:40:24 +0000 (14:40 +0100)]
greybus: operation: add support for short responses

Add support for operations with short responses.

So far we have assumed that the initiator of an operation always knows
the exact size of the expected response. This is however not always the
case and we've worked around this limitation in a couple of places by,
for example, first requesting the size of a resource before fetching the
actual data.

To avoid such workarounds and simplify our protocols, add a
short-response flag that can be set when allocating an operation. When
this flag is set on an operation, core will accept a response that is
shorter than the size of the (pre-allocated) response payload buffer.

For now, we update the response-message payload_size field to reflect
the actual length of the response received.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: operation: add temporary pointer to response handler
Johan Hovold [Thu, 25 Feb 2016 13:40:23 +0000 (14:40 +0100)]
greybus: operation: add temporary pointer to response handler

As a preparatory clean up, add a temporary variable to point to the
response message header.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Disable wake/detect interrupt in poweroff
Vaibhav Hiremath [Wed, 24 Feb 2016 23:07:39 +0000 (04:37 +0530)]
greybus: arche-platform: Disable wake/detect interrupt in poweroff

In poweroff() fn, we are shutting down SVC, so disable interrupt
as well.

Testing Done: Tested on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Michael Scott <michael.scott@linaro.org>
Tested-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Set direction of wake/detect gpio in poweroff fn
Vaibhav Hiremath [Wed, 24 Feb 2016 23:07:38 +0000 (04:37 +0530)]
greybus: arche-platform: Set direction of wake/detect gpio in poweroff fn

With support of interrupt based mechanism, gpio is not longer set to
output mode, so gpio_set_value won't work. So use
gpio_direction_output() fn in poweroff(), while setting value on
wake/detect line.

Testing Done: Tested on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Michael Scott <michael.scott@linaro.org>
Tested-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Assert wake/detect after SVC reset without delay
Vaibhav Hiremath [Wed, 24 Feb 2016 23:07:37 +0000 (04:37 +0530)]
greybus: arche-platform: Assert wake/detect after SVC reset without delay

Since now driver supports interrupt based mechanism to read events
from SVC over wake/detect line, no need to delay wake/detect assertion.
We can assert wake/detect after SVC reset deassertion, so during boot
itself SVC will start sending wake_out pulses.

Testing Done: Tested on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Michael Scott <michael.scott@linaro.org>
Tested-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Enable interrupt support on wake/detect line
Vaibhav Hiremath [Wed, 24 Feb 2016 23:07:36 +0000 (04:37 +0530)]
greybus: arche-platform: Enable interrupt support on wake/detect line

This patch enabled interrupt support on events received over wake/detect
line. The driver follows below state machine,

Default: wake/detect line is high (WD_STATE_IDLE)
On Falling edge:
  SVC initiates boot (either cold/standby).
  On ES3, > 30msec = coldboot, else standby boot.
  Driver moves to WD_STATE_BOOT_INIT
On rising edge (> 30msec):
  SVC expects APB to coldboot
  Driver wakes irq thread which kicks off APB  coldboot
  (WD_STATE_COLDBOOT_TRIG)
On rising edge (< 30msec):
  Driver ignores it, do nothing.

After coldboot of APB, HUB configuration work is scheduled after 2 sec,
allowing enough time for APB<->SVC/Switch to linkup (in multiple
iterations)

Testing Done: Tested on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Michael Scott <michael.scott@linaro.org>
Tested-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Add wake detect state based on functionality
Vaibhav Hiremath [Wed, 24 Feb 2016 23:07:35 +0000 (04:37 +0530)]
greybus: arche-platform: Add wake detect state based on functionality

If driver needs to process wake/detect events from SVC, by enabling
interrupt support on wake/detect event, it becomes easier to maintain
state of wake/detect line based on functionality.

Testing Done: Tested on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Michael Scott <michael.scott@linaro.org>
Tested-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Convert delayed work to do only hub3613 configuration
Vaibhav Hiremath [Wed, 24 Feb 2016 23:07:34 +0000 (04:37 +0530)]
greybus: arche-platform: Convert delayed work to do only hub3613 configuration

This is preparation of interrupt handling support, where APB coldboot
and wake/detect handling will be handled as response to wake/detect
interrupt.
Due to slower I2C write operations in HUB configuration, it is important
to separate HUB configuration, and probably delay it after APB is
cold booted.

Note that delayed work will be scheduled from interrupt handler,
in following patches.

To satisfy build (and bisect), remove apb_cold_boot() fn, which will be
added back in the patch where it gets used again.

Testing Done: Tested on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Michael Scott <michael.scott@linaro.org>
Tested-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-apb-ctrl: Remove extra delay in APB reset
Vaibhav Hiremath [Wed, 24 Feb 2016 23:07:33 +0000 (04:37 +0530)]
greybus: arche-apb-ctrl: Remove extra delay in APB reset

With synchronization between SVC <=> AP over wake/detect line to
bring APB's out of reset, we do not need any extra delays now.
So remove it.

Testing Done: Tested for DB3.5 and EVT1.2 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Michael Scott <michael.scott@linaro.org>
Tested-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: Documentation/sysfs: make 1-5 a 2x2 module
Johan Hovold [Mon, 22 Feb 2016 17:50:56 +0000 (18:50 +0100)]
greybus: Documentation/sysfs: make 1-5 a 2x2 module

Make example module 1-5 a 2x2 module by adding a second, dummy
interface.

This is both an example of how a 2x2 module would be represented and
also suggests what a dummy interface may look like.

A 2x2 module has two child interface devices and a num_interfaces value
of two.

In this example, the secondary interface 1-5.6, is a dummy interface and
therefore lacks the normal identifying attributes (e.g. UniPro DDBL1 and
Ara ids). We may eventually add an interface_type attribute to
facilitate distinguishing various interface types (there may be more
than two).

In the following tree, the bundle attributes and child devices have been
left out:

greybus1/
├── 1-2
│   ├── 1-2.2
│   │   ├── 1-2.2.1
│   │   ├── 1-2.2.2
│   │   ├── ddbl1_manufacturer_id
│   │   ├── ddbl1_product_id
│   │   ├── interface_id
│   │   ├── product_id
│   │   ├── serial_number
│   │   ├── unique_id
│   │   └── vendor_id
│   ├── eject
│   ├── module_id
│   └── num_interfaces
├── 1-5
│   ├── 1-5.5
│   │   ├── 1-5.5.2
│   │   ├── ddbl1_manufacturer_id
│   │   ├── ddbl1_product_id
│   │   ├── interface_id
│   │   ├── product_id
│   │   ├── serial_number
│   │   ├── unique_id
│   │   └── vendor_id
│   ├── 1-5.6
│   │   └── interface_id
│   ├── eject
│   ├── module_id
│   └── num_interfaces
└── 1-svc

In this example there are two modules: 1-2 is a 1x2 module with one
interface, and 1-5 is a 2x2 module with two interfaces of which the
second (1-5.6) is a dummy interface.

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>
8 years agogreybus: Documentation/sysfs: move module 1-4 to position 5
Johan Hovold [Mon, 22 Feb 2016 17:50:55 +0000 (18:50 +0100)]
greybus: Documentation/sysfs: move module 1-4 to position 5

Move example module 1-4 to position 5, effectively renaming it 1-5.

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>
8 years agogreybus: Documentation/sysfs: add module devices
Johan Hovold [Mon, 22 Feb 2016 17:50:54 +0000 (18:50 +0100)]
greybus: Documentation/sysfs: add module devices

Introduce module devices and rename interface and bundle devices.

Greybus module devices correspond to physical modules and have one or
more interfaces. Modules have an id that is identical to the id of their
primary interface, which in turn is the interface with lowest numbered
id. The module name is constructed from the bus and module id:

<bus_id>-<module_id>

Interfaces and bundles are consequently renamed as

<bus_id>-<module_id>.<interface_id>

and

<bus_id>-<module_id>.<interface_id>.<bundle_id>

respectively.

As before, interface ids (and therefore in a sense now also module ids)
correspond to physical interface positions on the frame.

Modules have the following attributes:

eject
module_id
num_interfaces

where module_id is the id of the module and num_interface the number of
interfaces the module has.

Note that the interface ids of a module's interfaces are expected to be
<module_id>, <module_id + 1>, ..., <module_id + num_interfaces - 1>.

Writing a non-zero argument to eject cleanly shuts down and unregisters
all of the module interfaces before ejecting the module.

The example sysfs tree now looks as follows with the second bus
(APBridgeA) left out:

greybus1/
├── 1-2
│   ├── 1-2.2
│   │   ├── 1-2.2.1
│   │   │   ├── bundle_class
│   │   │   ├── bundle_id
│   │   │   └── state
│   │   ├── 1-2.2.2
│   │   │   ├── bundle_class
│   │   │   ├── bundle_id
│   │   │   └── state
│   │   ├── ddbl1_manufacturer_id
│   │   ├── ddbl1_product_id
│   │   ├── interface_id
│   │   ├── product_id
│   │   ├── serial_number
│   │   ├── unique_id
│   │   └── vendor_id
│   ├── eject
│   ├── module_id
│   └── num_interfaces
├── 1-4
│   ├── 1-4.4
│   │   ├── 1-4.4.2
│   │   │   ├── bundle_class
│   │   │   ├── bundle_id
│   │   │   ├── gpbridge0
│   │   │   │   ├── gpio
│   │   │   │   │   └── gpiochip490
│   │   │   │   └── i2c-4
│   │   │   └── state
│   │   ├── ddbl1_manufacturer_id
│   │   ├── ddbl1_product_id
│   │   ├── interface_id
│   │   ├── product_id
│   │   ├── serial_number
│   │   ├── unique_id
│   │   └── vendor_id
│   ├── eject
│   ├── module_id
│   └── num_interfaces
└── 1-svc
    ├── ap_intf_id
    ├── eject
    └── endo_id

where greybus1 is a bus; 1-svc the svc; 1-2, and 1-4 are modules; 1-2.2
and 1-4.4 are (primary) interfaces; and 1-2.2.1, 1-2.2.2, and 1-4.4.2
are bundles.

Note that the svc eject attribute may eventually be renamed force_eject.

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>
8 years agogreybus: gpio: handle api changes for 4.5 kernel release
Greg Kroah-Hartman [Wed, 24 Feb 2016 06:51:45 +0000 (22:51 -0800)]
greybus: gpio: handle api changes for 4.5 kernel release

In kernel version 4.5, struct gpio_chip renamed the field 'dev' to
'parent' so handle this properly.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: gpio: use bundle device for error messages
Greg Kroah-Hartman [Wed, 24 Feb 2016 06:51:23 +0000 (22:51 -0800)]
greybus: gpio: use bundle device for error messages

Use the bundle device directly in gpio error messages instead of the
gpio device, as they are the same pointer.  This will make future gpio
api changes much easier to handle.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Fix exit path in probe fn
Vaibhav Hiremath [Wed, 24 Feb 2016 20:57:36 +0000 (02:27 +0530)]
greybus: arche-platform: Fix exit path in probe fn

If SVC coldboot fails or if of_platform_populate() fn fails,
then state of device needs to be reverted.

Importantly, if of_platform_populate() fails, then poweroff the SVC.

Testing Done: Tested on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: uart: fix incomplete receive-data sanity checks
Johan Hovold [Wed, 24 Feb 2016 15:11:51 +0000 (16:11 +0100)]
greybus: uart: fix incomplete receive-data sanity checks

Fix incomplete receive-data sanity checks.

The payload size was never verified before parsing the uart header and
neither was the uart-header data size verified against the actual
payload size, something which could lead to information leaks when
passing data beyond the payload buffer to the tty layer.

Also remove the incorrect check against the maximum (tx-buffer) payload
size.

Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: uart: add missing serial-state sanity check
Johan Hovold [Wed, 24 Feb 2016 15:11:50 +0000 (16:11 +0100)]
greybus: uart: add missing serial-state sanity check

Add dedicated serial-state request handler and add the missing sanity
check on the incoming request.

Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: uart: add max-payload sanity check
Johan Hovold [Wed, 24 Feb 2016 15:11:49 +0000 (16:11 +0100)]
greybus: uart: add max-payload sanity check

Let's be well behaved and add a sanity check on the maximum greybus
payload size to avoid underflow on the calculated buffer size.

Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: connection: {en,dis}able fct flow in connection management
Fabien Parent [Tue, 23 Feb 2016 17:46:11 +0000 (18:46 +0100)]
greybus: connection: {en,dis}able fct flow in connection management

The AP must enable the FCT flow of APBA once it has received the response
from the AP that the connection between APBA and a module has been setted up.
Disable the flow of FCT tokens when destroying connections.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: es2: implement the fct flow control requests
Fabien Parent [Tue, 23 Feb 2016 17:46:10 +0000 (18:46 +0100)]
greybus: es2: implement the fct flow control requests

Implement the control requests enabling/disabling the flow of FCT on APBA.

Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Fabien Parent <fparent@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: apba: add fct flow usb control requests
Fabien Parent [Tue, 23 Feb 2016 17:46:09 +0000 (18:46 +0100)]
greybus: apba: add fct flow usb control requests

Add control requests to enable/disable the flow of unipro FCT tokens

Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Fabien Parent <fparent@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: connection: add api to {en,dis}able unipro fct flow
Fabien Parent [Tue, 23 Feb 2016 17:46:08 +0000 (18:46 +0100)]
greybus: connection: add api to {en,dis}able unipro fct flow

In order to support mailbox-free control cport init on the bridges the AP must
be able to enable/disable the flow of unipro fct tokens. Add a new API that
will enable or disable on APBA the flow of fct tokens.

Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Fabien Parent <fparent@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-apb-ctrl: Return immediately if in same state from state change fns
Vaibhav Hiremath [Mon, 22 Feb 2016 11:57:26 +0000 (17:27 +0530)]
greybus: arche-apb-ctrl: Return immediately if in same state from state change fns

Have a check inside all individual operational state change functions
to check whether device is in same state, and if yes, then return
immediately.

Testing Done: Tested on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Avoid doing same thing again in poweroff fn
Vaibhav Hiremath [Mon, 22 Feb 2016 11:57:25 +0000 (17:27 +0530)]
greybus: arche-platform: Avoid doing same thing again in poweroff fn

If user switches from fw_flashing => off mode, then we do not need
to do same things again, for example, clk_disable and wake/detect event,
as while switching to fw_flashing, driver makes sure that device goes
to off state and then brings back in fw_flashing state.

Testing Done: Tested on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Return immediately if in same state from state change fns
Vaibhav Hiremath [Mon, 22 Feb 2016 11:57:24 +0000 (17:27 +0530)]
greybus: arche-platform: Return immediately if in same state from state change fns

Have a check inside all individual operational state change functions
to check whether device is in same state, and if yes, then return
immediately.

Testing Done: Tested on DB3.5 platform

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: camera: Rename clock_mode to flags
Jacopo Mondi [Tue, 23 Feb 2016 10:22:49 +0000 (11:22 +0100)]
greybus: camera: Rename clock_mode to flags

Rename the 'clock_mode' parameter to a more generic 'flags' in the csi
bus configuration structure.
Define flags value for continuous clock mode.

Signed-off-by: Jacopo Mondi <jacopo.mondi@linaro.org>
Acked-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: camera: Add CSI configuration parameters
Jacopo Mondi [Tue, 23 Feb 2016 10:22:48 +0000 (11:22 +0100)]
greybus: camera: Add CSI configuration parameters

Add CSI configuration parameters to the configure_stream operation
response.
Currently, only the total number of lines in a second is used to configure the
the AP-Bridge CSI transmitter, all other parameters (number of CSI data
lanes, and CSI bus clock frequency) are kept hard-coded for two reasons:
1) We need to configure the CSI receiver on AP side accordingly to these
settings, before sending them to APB1 CSI transmitter.
2) We cannot use the camera module provided parameters as-is, but use
those information to compute the required bandwidth on the CSI bus, and
configure the # of CSI data lanes, and the CSI bus clock speed in a way that
satisfies that bandwidth requirement.

Signed-off-by: Jacopo Mondi <jacopo.mondi@linaro.org>
Acked-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: uart: properly calculate max buffer size
Greg Kroah-Hartman [Tue, 23 Feb 2016 02:14:46 +0000 (18:14 -0800)]
greybus: uart: properly calculate max buffer size

We forgot to count the size of the uart send data message header when
calculating the maximum size of the buffer that the uart driver could
send in one chunk.

This fixes the math and makes the variable a size_t to match the return
value of the call to gb_operation_get_payload_size_max();

Reported-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Tested-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: Documentation: remove svc unique_id attribute
Johan Hovold [Mon, 22 Feb 2016 17:50:53 +0000 (18:50 +0100)]
greybus: Documentation: remove svc unique_id attribute

Remove unimplemented svc unique_id attribute from the documentation.

This attribute made more sense when we thought we'd have an AP-module,
unlike now when the AP and SVC are both part of the same frame.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: interface: Add print messages on interface initialization/removal
Viresh Kumar [Fri, 19 Feb 2016 10:27:46 +0000 (15:57 +0530)]
greybus: interface: Add print messages on interface initialization/removal

It might be of interest (to developers at least) to know when an
interface is getting created or removed from the system.

Interface creation message can further contain basic information about
the interface, like its vid/pid and mfg/prod ids.

Now, the interface is created by gb_interface_create(), which doesn't
register the intf->dev to the kernel and so the print message is rather
added to gb_interface_init() where we register the device with the
kernel.

A similar message is added to gb_interface_remove() only when the
interface was earlier initialized.

And this is how the output looks on real insertion/removal of the
module:

greybus 1-1: Interface added: VID=0x00000001, PID=0x00000001
greybus 1-1: DDBL1 Manufacturer=0x00000001, Product=0x00000001
...
greybus 1-1: Interface removed

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>
8 years agogreybus: Revert "gb_loopback: Fix throughput calculations"
Greg Kroah-Hartman [Thu, 18 Feb 2016 00:30:38 +0000 (16:30 -0800)]
greybus: Revert "gb_loopback: Fix throughput calculations"

This reverts commit 9b9b046af237f5674c2f7ca991dc62332b2d4041

Bryan wants more feedback first.

Reported-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: audio: return success for stop trigger if device removed
Vaibhav Agarwal [Tue, 16 Feb 2016 16:46:33 +0000 (22:16 +0530)]
greybus: audio: return success for stop trigger if device removed

In case GB codec module is already removed, no action is required
at the HW level. Thus, report SUCCESS to above layer.

Reporting error to above layer will cause repeated trials and won't
allow to update DPCM connections.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: audio: schedule workqueue to perform codec cleanup on module removal
Vaibhav Agarwal [Mon, 15 Feb 2016 18:57:28 +0000 (00:27 +0530)]
greybus: audio: schedule workqueue to perform codec cleanup on module removal

In response to codec module removal, user space is reported about
the event. In response to this, ALSA layer will update DAPM route
and cleanup DAPM states.
As a fallback mechanism, kernel can cleanup the DAPM state for codec
module. But, this would cause immediate playback (first trial) to fail,
since DSP is still in inconsistent state.
To avoid such situation, a workqueue is scheduled for codec cleanup
with timeout=50ms.
Thus, normally it is expected from above layers to update routes and
perform cleanup. However, fallback mechanism still holds good after
50ms.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: audio: Enable support for multiple codec modules
Vaibhav Agarwal [Mon, 15 Feb 2016 18:57:27 +0000 (00:27 +0530)]
greybus: audio: Enable support for multiple codec modules

Update params, sequence in response to changes in msm8994
helper APIs

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: lights: fix check for configured lights
Rui Miguel Silva [Wed, 17 Feb 2016 14:32:53 +0000 (14:32 +0000)]
greybus: lights: fix check for configured lights

The validation for a complete configured light is wrong and it is
reworked to make sure that only when the light is ready, will handle
request events.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: lights: remove has_flash on failure
Rui Miguel Silva [Wed, 17 Feb 2016 14:32:52 +0000 (14:32 +0000)]
greybus: lights: remove has_flash on failure

If register to v4l2 fails just mark the light as not having flash so in
release we do not try to unregister.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: lights: remove unnecessary checks
Rui Miguel Silva [Wed, 17 Feb 2016 14:32:51 +0000 (14:32 +0000)]
greybus: lights: remove unnecessary checks

We do not need to check for channels and lights as they can never be
NULL as a big memory array elements.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: gb_loopback: Fix throughput calculations
Alexandre Bailon [Wed, 17 Feb 2016 17:21:06 +0000 (18:21 +0100)]
greybus: gb_loopback: Fix throughput calculations

Throughput and requests per second calculations are broken for
asynchronous request.
Instead of calculate the throughput for each iteration,
calculate it once at the end of the test.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: es2: fix cport-count error handling
Johan Hovold [Wed, 17 Feb 2016 18:30:40 +0000 (19:30 +0100)]
greybus: es2: fix cport-count error handling

Make sure to check for short transfers when retrieving the bridge cport
count.

Also clear the request buffer when allocating it.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: loopback: Add reserved fields to transfer request
Axel Haslam [Wed, 10 Feb 2016 13:19:29 +0000 (14:19 +0100)]
greybus: loopback: Add reserved fields to transfer request

All loopback transfer operations should have an identical header
format in order to facilitate bandwidth and data movement analysis.

Suggested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-apb-ctrl: Do not coldboot APBs in probe
Vaibhav Hiremath [Tue, 16 Feb 2016 19:57:52 +0000 (01:27 +0530)]
greybus: arche-apb-ctrl: Do not coldboot APBs in probe

Since parent driver (SVC) is controlling APBs directly, we do not
need to bringup APBs in its own probe.

Testing Done: Tested on EVT1.2.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: manifest: Parse cports (within a bundle) in the order from manifest blob
Viresh Kumar [Fri, 12 Feb 2016 16:18:03 +0000 (21:48 +0530)]
greybus: manifest: Parse cports (within a bundle) in the order from manifest blob

The order in which cports (of a bundle) are present in the manifest blob
is important for gbsim, as it allocates hd_cport_id's for them
sequentially.

For example, if there are two cports (1 and 2, in order 1->2) present in
a bundle in the manifest blob, then gbsim allocates hd_cport_id X and
X+1 for them. This is done on the assumption that kernel will do the
same. Though it shouldn't have had any such assumptions since the
beginning.

But with a recent patch that sequence is changed, and it broke the
assumption gbsim had.

While parsing the manifest blob, the cports within a bundle are now
moved to another list using list_move() and then they are picked one by
one from the HEAD of the list.

list_move() first deletes the node and then adds it to HEAD as it uses
list_add() and not list_add_tail(). And that reverses the order in which
the cports were present in the original list.

And because of this, the messages destined for cport 1 are delivered to
cport 2 and the ones for cport 2 are delivered to cport 1.

In order to get gbsim working with greybus, keep the cport list in the
order in which they were present in manifest, by replacing list_move()
with list_move_tail().

Its a trivial patch and shouldn't have any side effects on the working
of greybus with nuttx.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: camera: Don't configure CSI TX in test only mode
Laurent Pinchart [Sun, 14 Feb 2016 00:33:07 +0000 (02:33 +0200)]
greybus: camera: Don't configure CSI TX in test only mode

When the GB_CAMERA_CONFIGURE_STREAMS_TEST_ONLY flag is set by the caller
the configure streams operation should only test the requested settings
without modifying the hardware state. This applies for both the module,
the UniPro links power modes and the AP bridge settings. Return early
when the flag is set to avoid modifying the AP bridge CSI TX settings.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Tested-by: Jacopo Mondi <jacopo.mondi@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: camera: Set power mode after configuring streams
Laurent Pinchart [Sun, 14 Feb 2016 00:33:06 +0000 (02:33 +0200)]
greybus: camera: Set power mode after configuring streams

There's no need to set the power mode before configuring streams, doing
it after simplifies code.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Tested-by: Jacopo Mondi <jacopo.mondi@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: camera: Clean up when AP link power mode configuration failed
Laurent Pinchart [Sun, 14 Feb 2016 00:33:05 +0000 (02:33 +0200)]
greybus: camera: Clean up when AP link power mode configuration failed

Restore the module link power mode to the previous state in that case.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Tested-by: Jacopo Mondi <jacopo.mondi@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: camera: Factorize link power mode configuration code into a function
Laurent Pinchart [Sun, 14 Feb 2016 00:33:04 +0000 (02:33 +0200)]
greybus: camera: Factorize link power mode configuration code into a function

Avoid duplicating the same code block multiple times.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo.mondi@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: power_supply: convert to bundle driver
Viresh Kumar [Fri, 12 Feb 2016 10:38:33 +0000 (16:08 +0530)]
greybus: power_supply: convert to bundle driver

Convert the legacy power_supply protocol driver to a bundle driver.

This also fixes a potential crash should a (malicious) module have sent
an early request before the private data had been initialised.

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>
8 years agogreybus: power_supply: Break supply setup into two parts
Viresh Kumar [Fri, 12 Feb 2016 10:38:32 +0000 (16:08 +0530)]
greybus: power_supply: Break supply setup into two parts

This breaks the power supply setup routine into two parts, the first one
allocates all the necessary resources and the second on registers
supplies to the required frameworks.

This is required to enable only TX on the connection, until we have
allocated all the resources, otherwise the request handler might get
called for partially initialized structures.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: lights: convert to bundle driver
Viresh Kumar [Fri, 12 Feb 2016 10:38:31 +0000 (16:08 +0530)]
greybus: lights: convert to bundle driver

Convert the legacy lights protocol driver to a bundle driver.

This also fixes a potential crash should a (malicious) module have sent
an early request before the private data had been initialised.

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>
8 years agogreybus: lights: Break light setup into two parts
Viresh Kumar [Fri, 12 Feb 2016 10:38:30 +0000 (16:08 +0530)]
greybus: lights: Break light setup into two parts

This breaks the light setup routine into two parts, the first one
allocates all the necessary resources and the second on registers lights
to the required frameworks.

This is required to enable only TX on the connection, until we have
allocated all the resources, otherwise the request handler might get
called for partially initialized structures.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: loopback: convert to bundle driver
Viresh Kumar [Fri, 12 Feb 2016 10:38:29 +0000 (16:08 +0530)]
greybus: loopback: convert to bundle driver

Convert the legacy loopback protocol driver to a bundle driver.

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>
8 years agogreybus: raw: convert to bundle driver
Viresh Kumar [Mon, 15 Feb 2016 05:17:27 +0000 (10:47 +0530)]
greybus: raw: convert to bundle driver

Convert the legacy raw protocol driver to a bundle driver.

This also fixes a potential crash should a (malicious) module have sent
an early request before the private data had been initialised.

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>
8 years agogreybus: raw: Don't use (possibly) uninitialized raw->device in gb_raw_receive()
Viresh Kumar [Fri, 12 Feb 2016 10:38:27 +0000 (16:08 +0530)]
greybus: raw: Don't use (possibly) uninitialized raw->device in gb_raw_receive()

If an incoming request comes on the connection, before the driver has
allocated its raw->device in gb_raw_connection_init(), then it might
result in a crash while printing error messages.

Fix that by using bundle->dev for printing error messages.

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>
8 years agogreybus: raw: Use consistent label names in connection_init()
Viresh Kumar [Fri, 12 Feb 2016 10:38:26 +0000 (16:08 +0530)]
greybus: raw: Use consistent label names in connection_init()

Some of the labels are named based on what they are going to undo, while
others are based on where we failed in connection_init().

Follow only the first type of naming.

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>
8 years agogreybus: only build arche platform driver if usb3613 is enabled
Greg Kroah-Hartman [Mon, 15 Feb 2016 21:58:21 +0000 (13:58 -0800)]
greybus: only build arche platform driver if usb3613 is enabled

The build is broken if you try to build the arche platform driver
without the usb3163 driver enabled at the same time, so specify that
dependency in the greybus Makefile.

Testing done:  built inside and outside of the build system against
many different kernel versions.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Control usb3613 from arche-platform
Vaibhav Hiremath [Fri, 12 Feb 2016 20:34:20 +0000 (02:04 +0530)]
greybus: arche-platform: Control usb3613 from arche-platform

USB3613 hub driver exports control function, which allows caller
to switch the mode of operation of hub device.
As we know that, we have dependency between HUB3613 and APB's where,
HUB supposed to enter into HUB only after APB's brought out of reset.

Until now, we had all userspace driver sequences to control this,
but now since we are moving all resource management strictly to the
driver, it makes sense (even though it looks hacky) to enable control
of hub3613 from arche-platform driver.

Note that, there is another discussion where, the hub.connect IO pin may
get interfaced with MSM gpio, at that time, we can get rid of this hack
and replace it with gpio control.

Testing Done: Tested on EVT1.2 and DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-apb-ctrl: Do not export any gpios
Vaibhav Hiremath [Fri, 12 Feb 2016 20:34:19 +0000 (02:04 +0530)]
greybus: arche-apb-ctrl: Do not export any gpios

With addition of operational state in driver, user/developer
can switch to FW flashing state through sysfs. So no need to
export any gpios to userspace now.

Testing Done: Tested on EVT1.2 and DB3.5 platform

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Do not export any gpios
Vaibhav Hiremath [Fri, 12 Feb 2016 20:34:18 +0000 (02:04 +0530)]
greybus: arche-platform: Do not export any gpios

With addition of operational state in driver, user/developer
can switch to FW flashing state through sysfs. So no need to
export any gpios to userspace now.

Testing Done: Tested on EVT1.2 and DB3.5 platform

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Fix boot, poweroff and fw_flashing seq with APBs
Vaibhav Hiremath [Fri, 12 Feb 2016 20:34:17 +0000 (02:04 +0530)]
greybus: arche-platform: Fix boot, poweroff and fw_flashing seq with APBs

Now SVC driver has an access to APBs operational functions
(coldboot, standby_boot, fw_flashing and poweroff), SVC driver
can control APB's as per below rules,

 - If SVC goes down (poweroff state), it will also power off APBs
   and vice a versa for all operational states.
 - On boot, SVC will probe/populate APB device, but will not coldboot
   it. APBs will coldboot only after handshaking with SVC over
   wake/detect line.
   Note that, both APBs share same wake/detect line.

So from user/developer perspective, it is highly recommended that
they should use arche-platform interfaces, instead of individual
apb interface,

 # echo [off/active/standby/fw_flashing] > /sys/devices/arche_platform.*/state

Note: 'standby' mode is not supported as of now.

Testing Done: Testd on EVT1.2 and DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-apb-ctrl: Export operational fns from driver
Vaibhav Hiremath [Fri, 12 Feb 2016 20:34:16 +0000 (02:04 +0530)]
greybus: arche-apb-ctrl: Export operational fns from driver

In order to use single wake/detect line for both APB's we need to have
access to APB operational functions to parent/SVC driver.
So export coldboot, standby_boot, fw_flashing and poweroff operation
functions from the driver.

Testing Done: Tested on EVT1.2 and DB3.5 platform

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-apb-ctrl: Rename internal operational state fns
Vaibhav Hiremath [Fri, 12 Feb 2016 20:34:15 +0000 (02:04 +0530)]
greybus: arche-apb-ctrl: Rename internal operational state fns

This is preparation for enabling export set of operational fns
to parent driver.
So it is important to differentiate internal ops function against
externally accessed (from parent).

Testing Done: Tested on EVT1.2 and DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-apb-ctrl: Introduce ara,init-disable property for APB
Vaibhav Hiremath [Fri, 12 Feb 2016 20:34:14 +0000 (02:04 +0530)]
greybus: arche-apb-ctrl: Introduce ara,init-disable property for APB

New DT property "ara,init-disable" will allow user to disable
APB1 or APB2 during boot and enable it only when needed through
command prompt via sysfs interface.

 - To disable APB2 during boot, specify "ara,init-disable" property in
   respective APB node.

 - How to check the state
   # cat /sys/devices/arche_platform.*/apb*/state

   It should be 'off', if 'ara,init-disable' enabled in DT.

 - During runtime if user/developer desired to enable APB2 (strictly and
   only for development purpose) then respective APB can be enabled
   through,

   # echo active > /sys/devices/arche_platform.*/apb*/state

Note:
  - If APB device is in 'off,disabled' state, then no state transitions
    are permitted.
  - User/developer must first activate APB device

    # echo active > /sys/devices/arche_platform.*/apb*/state

    This will clear the 'init-disable' flag and allow state transition
    from here onwards.
    Note that, 'off,disabled' is only indicative state and is only
    applicable during init/boot.

Testing Done: Tested on EVT1.2 and DB3.5 platform

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-apb-ctrl: Add sysfs to allow user to change state
Vaibhav Hiremath [Fri, 12 Feb 2016 20:34:13 +0000 (02:04 +0530)]
greybus: arche-apb-ctrl: Add sysfs to allow user to change state

This patch introduces sysfs interface for the user space to enable
state change of the driver. Driver supports below operational
states,

 - off
 - active
 - standby
 - fw_flashing

To see the current state

i # cat /sys/devices/arche_platform.*/apb*/state

And to change the state
 # echo [off/active/standby/fw_flashing] > /sys/devices/arche_platform.*/apb*/state

Testing Done: Tested on EVT1.2 and DB3.5 platform

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-apb-ctrl: Pass only platform_device to _seq fns
Vaibhav Hiremath [Fri, 12 Feb 2016 20:34:12 +0000 (02:04 +0530)]
greybus: arche-apb-ctrl: Pass only platform_device to _seq fns

Pass only pointer to platform_device to _seq fns and fetch handle to
arche_apb_ctrl_drvdata from platform_device.

This is preparation for support for dynamic switching between operational
states for the device, where these functions will be called from parent
driver.

Testing Done: Tested on EVT1.2 and DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-apb-ctrl: Set default state value to OFF
Vaibhav Hiremath [Fri, 12 Feb 2016 20:34:11 +0000 (02:04 +0530)]
greybus: arche-apb-ctrl: Set default state value to OFF

Explicitly set default apb->state value to ARCHE_PLATFORM_STATE_OFF
in probe() fn.

Testing Done: Tested on EVT1.2 and DB3.5 platform

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-apb-ctrl: Rename init_seq and cleanup fn
Vaibhav Hiremath [Fri, 12 Feb 2016 20:34:10 +0000 (02:04 +0530)]
greybus: arche-apb-ctrl: Rename init_seq and cleanup fn

apb_ctrl_coldboot_seq() and apb_ctrl_poweroff_seq()
is appropriate name as per spec and implementation, so rename it.
Also move apb_ctrl_poweroff_seq() fn above, to group it with
other _seq functions.

Testing Done: Tested on EVT1.2 and DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-apb-ctrl: Re-arrange init sequence
Vaibhav Hiremath [Fri, 12 Feb 2016 20:34:09 +0000 (02:04 +0530)]
greybus: arche-apb-ctrl: Re-arrange init sequence

In order to allow APB2 disable by default on boot/init, and also
provide interface to user to enable it later on, re-arrange the init_seq
fn.
The idea here is, the apb_ctrl_init_seq() fn will be renamed to
apb_ctrl_coldboot_seq(), and should not try to claim any resources.
All the resource claim should happen in apb_ctrl_get_devtree_data() fn.

And also uses devm_gpio_request_one() fn wherever possible.

Testing Done: Tested on EVT1.2 and DB3.5  platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Introduce FW_FLASHING state
Vaibhav Hiremath [Fri, 12 Feb 2016 20:34:08 +0000 (02:04 +0530)]
greybus: arche-platform: Introduce FW_FLASHING state

Introduce FW_FLASHING state to arche-platform driver, to enable
user space to flash/upgrade SVC firmware.

Command to enter into flashing state:

  # echo fw_flashing > /sys/devices/arche_platform.*/state

Testing Done: Tested on EVT1.2 and DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche_platform: Add sysfs to allow user to change state
Vaibhav Hiremath [Fri, 12 Feb 2016 20:34:07 +0000 (02:04 +0530)]
greybus: arche_platform: Add sysfs to allow user to change state

This patch introduces sysfs interface for the user space to enable
operational state change of the driver.
Currently, driver supports, 'off', 'active' and 'standby'

Note that, driver doesn't do anything for standby state as of today.

To see the current state

      # cat /sys/devices/arche_platform.*/state

And to change the state
      # echo [off/active/standby] > /sys/devices/arche_platform.*/state

Testing Done: Tested on EVT1.2 and DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Pull wake/detect low in poweroff
Vaibhav Hiremath [Fri, 12 Feb 2016 20:34:06 +0000 (02:04 +0530)]
greybus: arche-platform: Pull wake/detect low in poweroff

When SVC goes down, make sure that wake/detect is also pulled low.
Note that this is not the criteria for SVC poweroff, but it is required
to have right state on wake/detect line before powering off.
And on next boot, the boot-sequence code would take care of
handshaking with SVC.

Tested-on: Tested on EVT1.2 and DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Add state variable to driver data
Vaibhav Hiremath [Fri, 12 Feb 2016 20:34:05 +0000 (02:04 +0530)]
greybus: arche-platform: Add state variable to driver data

This is preparation for operational state support.
So in order to provide operational state transitions, driver needs to
maintain state. So add 'enum arche_platform_state' variable to
'struct arche_platform_drvdata'

Testing Done: Tested on EVT1.2 and DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Rename cleanup fn to poweroff_seq
Vaibhav Hiremath [Fri, 12 Feb 2016 20:34:04 +0000 (02:04 +0530)]
greybus: arche-platform: Rename cleanup fn to poweroff_seq

In sync with operational states, rename arche_platform_cleanup() fn
to arche_platform_poweroff_seq() fn.

Testing Done: Tested on EVT1.2 and DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Cancel delayed_work in driver remove fn
Vaibhav Hiremath [Fri, 12 Feb 2016 19:45:11 +0000 (01:15 +0530)]
greybus: arche-platform: Cancel delayed_work in driver remove fn

This is a bug fix, where as part of cleanup, delayed work was not
canceled in driver remove function. So fix it.

Testing Done: Tested on EVT1.2 and DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Introduce coldboot_seq fn
Vaibhav Hiremath [Fri, 12 Feb 2016 20:34:03 +0000 (02:04 +0530)]
greybus: arche-platform: Introduce coldboot_seq fn

This is preparation for support for different operational states
(defined by arche_platform_state) in the driver, to enable
user/developer to dynamically configure the state.

arche_platform_coldboot_seq() fn will be responsible for
rebooting SVC device.

Testing Done: Tested on EVT1.2 and DB3.5 platform

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: make apb_state common to both platform drivers
Vaibhav Hiremath [Fri, 12 Feb 2016 20:34:02 +0000 (02:04 +0530)]
greybus: arche-platform: make apb_state common to both platform drivers

Make 'enum apb_state' common to both platform drivers, so that
both drivers can make use of same state and user will have
unified control configuration across devices (SVC, APB1 and APB2)

Testing Done: Tested on EVT1.2 and DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: raw: fix memory leak on disconnect
Johan Hovold [Wed, 10 Feb 2016 10:08:29 +0000 (11:08 +0100)]
greybus: raw: fix memory leak on disconnect

Make sure the class device is freed as well as deregistered on
disconnect.

Also deregister the class device before character device as the former
depends on the latter.

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>
8 years agogreybus: bundle: remove private data field
Johan Hovold [Wed, 10 Feb 2016 11:31:03 +0000 (12:31 +0100)]
greybus: bundle: remove private data field

Remove the private data field from the bundle structure as it is no
longer needed. Bundle drivers can use the driver data field in the
bundle device.

Update the only current user to use the connection private data until it
has been converted to a bundle driver.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: spi: add bundle-device prefix to error messages
Johan Hovold [Thu, 11 Feb 2016 12:52:50 +0000 (13:52 +0100)]
greybus: spi: add bundle-device prefix to error messages

Replace all pr_err with dev_err so we can tell what device (and driver)
a message was for.

Testing Done: Compiled

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: loopback: add missing pr_fmt
Johan Hovold [Thu, 11 Feb 2016 12:52:49 +0000 (13:52 +0100)]
greybus: loopback: add missing pr_fmt

Add missing pr_fmt so we can at least tell what module the sole
remaining pr_err was from.

Testing Done:
Tested on DB3.5 with the generic bridge firmware on APB2.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: i2c: add bundle-device prefix to error messages
Johan Hovold [Thu, 11 Feb 2016 12:52:48 +0000 (13:52 +0100)]
greybus: i2c: add bundle-device prefix to error messages

Replace all pr_err with dev_err so we can tell what device (and driver)
a message was for.

Testing Done: Compiled

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: core: add device prefix to error messages
Johan Hovold [Thu, 11 Feb 2016 12:52:47 +0000 (13:52 +0100)]
greybus: core: add device prefix to error messages

Use dev_err and dev_warn where appropriate and remove now unused pr_fmt
defines.

Testing Done:
Tested on DB3.5 with the generic bridge firmware on APB2.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: manifest: add interface-device prefix to messages
Johan Hovold [Thu, 11 Feb 2016 12:52:46 +0000 (13:52 +0100)]
greybus: manifest: add interface-device prefix to messages

Use dev_err and friends so that we can tell which interface (and module)
a manifest-parsing error messages was for.

Testing Done:
Tested on DB3.5 with the generic bridge firmware on APB2.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: interface: clear upper 16-bits of version_id and product_id
Michael Scott [Tue, 9 Feb 2016 01:08:46 +0000 (17:08 -0800)]
greybus: interface: clear upper 16-bits of version_id and product_id

Current userspace looks through the sysfs interface entries for
matching vendor_id and product_id any time an interface is opened
by module developers.  The upper 16-bits of ES3 vendor_id and
product_id contain a reverse mask of the lower 16-bits.  This
additional information is never used and should be removed so
that every consumer of these sysfs entries doesn't have to perform
the same bit clearing logic.

Signed-off-by: Michael Scott <michael.scott@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: Revert "arche-apb-ctrl: Remove extra delay in APB reset"
Vaibhav Hiremath [Tue, 9 Feb 2016 16:39:16 +0000 (22:09 +0530)]
greybus: Revert "arche-apb-ctrl: Remove extra delay in APB reset"

We are seeing failures on DB3.1 board, and Axel root-caused it to this
commit, so revert it as of now.

This reverts commit 942627227684c187b727ba5fb581bc2d886b6708.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: spi: add device_type field to device config
Rui Miguel Silva [Tue, 2 Feb 2016 14:23:16 +0000 (14:23 +0000)]
greybus: spi: add device_type field to device config

Add device_type field in device config operation to get the type of
device and try to expose less the kernel internal over greybus.
This include the spidev, spi-nor will fetch the correct nor id over
jede and a modalias that will have the previous behavior (name will set
the driver to be loaded).

As at it, fix a trivial error path and return immediately.

Tested: using gbsim and confirming that a spidev and mtd device were
created.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: uart: fix double free of tty port
Rui Miguel Silva [Fri, 5 Feb 2016 13:50:37 +0000 (13:50 +0000)]
greybus: uart: fix double free of tty port

When inserting and removing a module with a UART protocol defined a
double free of the tty_port would happen and that would generate a lot
of kernel oops in different places related to memory corruption.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: power_supply: rework get descriptors
Rui Miguel Silva [Thu, 4 Feb 2016 14:00:36 +0000 (14:00 +0000)]
greybus: power_supply: rework get descriptors

Rework the get property descriptors function to fix a memory handling
error for the response structure. This could corrupt the stack and
throw nonalignment PC or SP error:

Internal error: SP or PC abort: 8a000000 1 PREEMPT SMP
Modules linked in: gb_power_supply(O) gb_arche(O) gb_camera(O) gb_es2(O) gb_vibrator(O) gb_raw(O) g]
CPU: 3 PID: 51 Comm: kworker/u16:2 Tainted: G W O 3.10.73-g8a6af60-00118-g599a5c1 #1
Workqueue: greybus1:svc gb_svc_connection_destroy [greybus]
task: ffffffc0ba249580 ti: ffffffc0ba294000 task.ti: ffffffc0ba294000
PC is at gb_power_supply_connection_init+0x81/0x1dc [gb_power_supply]
LR is at gb_power_supply_connection_init+0x81/0x1dc [gb_power_supply]
pc : [<ffffffbffc03b901>] lr : [<ffffffbffc03b901>] pstate: 80000145
sp : ffffffc0ba297a00
x29: 32002e002a001100 x28: ffffffc042cb2c80

To fix this, allocate firstly the operation and handle request and
response using operation payload.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>