Commit graph

35 commits

Author SHA1 Message Date
Viresh Kumar e18822e3d0 greybus: Rename gb_gpbridge_protocol_driver() as gb_builtin_protocol_driver()
This macro is also required by core protocols like control and svc, and
hence the 'gpbridge' name doesn't fit anymore.

Lets call this macro gb_builtin_protocol_driver().

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-01 16:34:55 -07:00
Johan Hovold 7ba864a19f greybus: gpio: add irq-type defines
Add Greybus GPIO IRQ-type defines rather than rely on the current
Linux implementation.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-28 14:48:30 -07:00
Johan Hovold 1409c4d6a8 greybus: gpio: fix interrupt protocol
The current interrupt implementation uses the simple irq-flow handler,
which means that the interrupt subsystem makes no irq-chip callbacks
when handling an interrupt. Specifically, no end-of-interrupt message is
sent when the threaded handler has run. This means that we may currently
re-enable an interrupt before it has been serviced (i.e. the irq-event
operation may complete before the threaded handler has run).

The simple flow handler also silently drops a second interrupt arriving
while a handler is running. This means that we may lose a second edge
interrupt with the current firmware.

Switch to a new one-shot interrupt protocol, where the primary handler
(firmware) always masks and acks an interrupt before sending an event to
the AP. The AP is responsible for unmasking the interrupt when it has
been handled. By having the firmware ack an edge interrupt before
sending the event, a second edge interrupt will no longer get lost.

This one-shot protocol can be implemented in the kernel by using the
level irq-flow handler, one-shot interrupts with threaded handlers and
bus-lock synchronisation for slow buses. Note that the same flow handler
is used for both edge and level interrupts.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-26 15:27:39 -07:00
Johan Hovold 25f11ed965 greybus: gpio: fix atomic sleep when using interrupts
The irq-chip callbacks are made in atomic context where we must not do
any synchronous greybus operations.

Fix the current gpio-interrupt implementation by using the bus-lock
functionality provided by the irq subsystem.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-26 15:26:08 -07:00
Johan Hovold 0cb918d72d greybus: gpio: rename irq mask and unmask callbacks
Rename irq mask and unmask functions to match the callback names.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-26 15:26:08 -07:00
Johan Hovold ec762115a5 greybus: gpio: use irq-domain lookups
Use irq_find_mapping directly rather than go through the legacy gpio
interface.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-26 15:25:17 -07:00
Johan Hovold 2611ebef83 greybus: gpio: don't call irq-flow handler directly
Use generic_handle_irq_desc rather than call a hardcoded irq-flow
handler directly.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-26 15:25:17 -07:00
Johan Hovold b8e3ffebac greybus: gpio: remove unused irq-ack operation
Remove unused irq-ack operation, which has never been called and does
not make sense for message-signalled interrupts over slow buses.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-26 15:25:17 -07:00
Johan Hovold c8d1ad8013 greybus: gpio: fix debugfs output
Fix debugfs output by removing the unimplemented, custom dbg_show
callback. The default implementation is perfectly sufficient.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-26 15:25:17 -07:00
Alex Elder e9385e5d5a greybus: include "gpbridge.h" from "greybus.h"
Avoid the need for all the source files to include "gpbridge.h"
by just having "greybus.h" include it.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-23 16:34:39 -07:00
Viresh Kumar bdac599c70 greybus: Use gb_gpbridge_protocol_init()
Start using gb_gpbridge_protocol_init() in gpbridge drivers.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-20 22:44:37 -07:00
Viresh Kumar 8de925b973 greybus: gpio: fix tab/space mistake
Spaces were present in place of tab. Fix that.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-05-20 22:36:03 -07:00
John Stultz 453bbea807 greybus: Move briged phy structure definitions into gpbridge.h
In order to facilitate re-use of the gpio, i2c, pwm and i2s
structures, split them out of independent files and add
them into a shared gpbridge.h

This will be a prereq to sharing these headers w/ gbsim.

Cc: Alex Elder <alex.elder@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@google.com>
CC: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-04-10 11:17:20 +02:00
Johan Hovold 973ccfd626 greybus: operation: refactor response handling
Send response to incoming requests from the operation request handler
rather than in every protocol request_recv callback.

This simplifies request_recv error handling and allows for further code
reuse.

Note that if we ever get protocols that need to hold off sending
responses we could implement this by letting them return a special
value (after acquiring the necessary operation references) to suppress
the response from being sent by greybus core.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-30 15:20:34 +02:00
Johan Hovold fef96a226e greybus: gpio: fix missing response on request errors
Send response also to incoming requests that cannot be fulfilled.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-30 15:17:37 +02:00
Johan Hovold 244b5a2344 greybus: gpio: fix null-deref on unexpected irq requests
Fix null-pointer dereference on failure to look up irq due to missing
error handling.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-30 15:17:37 +02:00
Johan Hovold 1842dd8b7b greybus: gpio: fix null-deref on short irq requests
Make sure to verify the length of incoming requests before trying to
parse the request buffer, which can even be NULL on empty requests.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-30 15:17:37 +02:00
Johan Hovold 792c17e643 greybus: gpio: add error messages to callbacks not propagating errors
Add error messages on failures to deactivate, set and get operation
handlers as any errors would not be detected by the upper layers (either
because the callbacks are declared void or expected to return a boolean
value).

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-19 17:30:38 +01:00
Johan Hovold 7bfa078140 greybus: gpio: refuse to set value of input pins
Add warning and refuse to set output value for pin configured as input,
as the result of such an operation is undefined.

Remove incorrect todo-comment suggesting that the driver could
implicitly switch direction as part of the call.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-19 17:30:38 +01:00
Johan Hovold 64d2f4e5f9 greybus: gpio: clean up line-state allocation
Clean up allocation of line-state array.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-19 17:30:38 +01:00
Johan Hovold e5032d8511 greybus: gpio: use dev_err and dev_warn
Use the more informative dev_err and dev_warn for messages, and make the
messages more uniform.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-19 17:30:38 +01:00
Johan Hovold 86c6816158 greybus: gpio: fix error handling
Make sure to propagate any errors detected up the call chain.

This specifically means that we will detect failed connection init,
something which is now handled more gracefully by greybus core.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-19 17:30:38 +01:00
Johan Hovold 8aff1aceb2 greybus: gpio: make gb_gpio_controller pointer naming consistent
Rename all struct gb_gpio_controller-pointer variables "ggc" for
consistency and readability reason.

This also fixes a bunch of lines that exceeded the 80 columns limit.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-19 17:29:40 +01:00
Johan Hovold bda7e2d112 greybus: gpio: remove unnecessary explicit cast
Remove unnecessary explicit cast of line value.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-19 17:29:40 +01:00
Johan Hovold 83d9cddb85 greybus: gpio: remove overly defensive argument verification
Remove overly defensive argument verification in gpio-chip callbacks. We
should trust gpiolib to get this right (or we would not even get any
callback) just like the other gpio drivers do.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-19 17:29:40 +01:00
Johan Hovold 65f5a5f161 greybus: gpio: remove redundant argument verification
Remove redundant verification of gpio numbers (which have already been
verified in the gpio-chip callbacks) from greybus-operation helpers.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-19 17:29:40 +01:00
Johan Hovold 56c2da1873 greybus: gpio: remove incorrect todo comments
The module reference count is incremented by gpiolib when a gpio is
requested, and the driver callbacks certainly do sleep.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-19 17:29:40 +01:00
Johan Hovold c2a6610686 greybus: gpio: fix truncated debounce times
Fix set_debounce, which silently truncated the time argument to 255us
even though we support 16-bit values.

Also remove the unnecessary explicit cast when verifying the argument.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-19 17:29:40 +01:00
Johan Hovold fcc4356de4 greybus: gpio: fix set-debounce request alignment
Fix alignment of the usec-field in the set-debounce request, which
should follow the which-field without any inserted padding.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-17 22:34:43 +01:00
Alexandre Bailon d1b20d72ae greybus: gpio.c: fix a bad irq number
When it receive an interrupt, the function gb_gpio_request_recv doesn't
use the good gpio number to get the irq number. Then, the expected irq is never fired.

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-02 08:54:20 -08:00
Johan Hovold 35a64f2c49 greybus: gpio: fix memory leaks at init and exit
Fix three related memory leaks in the init an exit callbacks, where the
gpio-lines array was never freed at all and the controller data wasn't
freed in the init error path.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-02-17 16:31:27 -08:00
Matt Porter 036aad9d02 greybus: gpio: add interrupt handling support
Adds gpio interrupt handling support using an irqchip/irqdomain
instantiation inside the GB GPIO driver. This implementation works
on older kernels such as 3.10 that do not have the gpiolib irqchip
helpers. Any line on a Greybus gpiochip may be configured as an
interrupt. Once configured, IRQ event messages received from a
module fire off the registered interrupt handler.

Signed-off-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-02-17 16:28:28 -08:00
Viresh Kumar 89210f64ba greybus: remove unused version-response structs
These aren't used anymore and so can be removed.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-01-22 11:29:39 +08:00
Viresh Kumar 36e79dec96 greybus: create get_version() routines with the help of a macro
This gets rid of lots of duplication of code.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-01-22 11:29:39 +08:00
Viresh Kumar 5357cf3231 greybus: Remove "-gb" suffix from .c files
Some files are prefixed with "gb-" and some are suffixed with "-gb". The
rationale behind the first one is that the modules would be named so, i.e.
gb-*.ko. But there is no reason to keep the "-gb" suffix in the second case.

Remove the unnecessary suffix.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-01-22 11:27:20 +08:00
Renamed from drivers/staging/greybus/gpio-gb.c (Browse further)