Commit graph

70 commits

Author SHA1 Message Date
Sumitra Sharma
f48198232d staging: greybus: Inline gpio_chip_to_gb_gpio_controller()
Convert 'gpio_chip_to_gb_gpio_controller' from a macro to a static
inline function, to make the relevant types apparent in the
definition and to benefit from the type checking performed by
the compiler at call sites.

Signed-off-by: Sumitra Sharma <sumitraartsy@gmail.com>
Link: https://lore.kernel.org/r/3fc5d84a99574ac4a76d26427ac544de375adeb4.1679732179.git.sumitraartsy@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-03-25 09:54:52 +01:00
Brent Pappas
72b74b646b staging: greybus: gpio: Replace macro irq_data_to_gpio_chip with function
Replace the macro irq_data_to_gpio_chip with a static inline function to comply
with Linux coding style standards.

Signed-off-by: Brent Pappas <bpappas@pappasbrent.com>
Link: https://lore.kernel.org/r/20230117152857.22141-1-bpappas@pappasbrent.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-01-17 19:18:54 +01:00
Sebastian Andrzej Siewior
ff8dcfebe0 staging: greybus: gpio: Use generic_handle_irq_safe().
Instead of manually disabling interrupts before invoking use
generic_handle_irq_safe() which can be invoked with enabled and disabled
interrupts.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Johan Hovold <johan@kernel.org>
Cc: Alex Elder <elder@kernel.org>
Cc: Rui Miguel Silva <rmfrfs@gmail.com>
Link: https://lore.kernel.org/r/20220211181500.1856198-8-bigeasy@linutronix.de
2022-03-02 22:28:51 +01:00
Linus Walleij
8750d02d1a staging: greybus: gpio: Use irqchip template
This makes the driver use the irqchip template to assign
properties to the gpio_irq_chip instead of using the
explicit calls to gpiochip_irqchip_add(). The irqchip is
instead added while adding the gpiochip.

Cc: Nishad Kamdar <nishadkamdar@gmail.com>
Cc: Johan Hovold <johan@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20200722074414.48457-1-linus.walleij@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-07-28 10:05:33 +02:00
Thomas Gleixner
66d93d7ff9 staging: greybus: Fix the irq API abuse
Nothing outside of low level architecture code is supposed to look up
interrupt descriptors and fiddle with them.

Replace the open coded abuse by calling generic_handle_irq().

This still does not explain why and in which context this connection
magic is injecting interrupts in the first place and why this is correct
and safe, but at least the API abuse is gone.

Fixes: 036aad9d02 ("greybus: gpio: add interrupt handling support")
Fixes: 2611ebef83 ("greybus: gpio: don't call irq-flow handler directly")
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Johan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/87o8t9boqq.fsf@nanos.tec.linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-10 10:15:22 +01:00
Greg Kroah-Hartman
ec0ad86817 staging: greybus: move core include files to include/linux/greybus/
With the goal of moving the core of the greybus code out of staging, the
include files need to be moved to include/linux/greybus.h and
include/linux/greybus/

Cc: Vaibhav Hiremath <hvaibhav.linux@gmail.com>
Cc: Johan Hovold <johan@kernel.org>
Cc: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Cc: Rui Miguel Silva <rmfrfs@gmail.com>
Cc: David Lin <dtwlin@gmail.com>
Cc: "Bryan O'Donoghue" <pure.logic@nexus-software.ie>
Cc: greybus-dev@lists.linaro.org
Cc: devel@driverdev.osuosl.org
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Alex Elder <elder@kernel.org>
Link: https://lore.kernel.org/r/20190825055429.18547-8-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-08-27 19:02:59 +02:00
Nishad Kamdar
e28dd69ee8 staging: greybus: gpio: switch GPIO portions to use GPIOLIB_IRQCHIP
Convert the GPIO driver to use the GPIO irqchip library
GPIOLIB_IRQCHIP instead of reimplementing the same.

Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Nishad Kamdar <nishadkamdar@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-01-15 16:18:14 +01:00
Cristian Sicilia
8478c35a85 staging: greybus: Parenthesis alignment
Some parameters are aligned with parentheses.
Some parentheses was opened at end of line.

Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-26 20:59:05 +01:00
Greg Kroah-Hartman
863dbc52e7 staging: greybus: Remove redundant license text
Now that the SPDX tag is in all greybus files, that identifies the
license in a specific and legally-defined manner.  So the extra GPL text
wording can be removed as it is no longer needed at all.

This is done on a quest to remove the 700+ different ways that files in
the kernel describe the GPL license text.  And there's unneeded stuff
like the address (sometimes incorrect) for the FSF which is never
needed.

No copyright headers or other non-license-description text was removed.

Cc: Vaibhav Hiremath <hvaibhav.linux@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Acked-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Acked-by: David Lin <dtwlin@gmail.com>
Acked-by: Johan Hovold <johan@kernel.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Acked-by: "Bryan O'Donoghue" <pure.logic@nexus-software.ie>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-11 14:46:21 +01:00
Greg Kroah-Hartman
eb50fd3a22 staging: greybus: add SPDX identifiers to all greybus driver files
It's good to have SPDX identifiers in all files to make it easier to
audit the kernel tree for correct licenses.

Update the drivers/staging/greybus files files with the correct SPDX
license identifier based on the license text in the file itself.  The
SPDX identifier is a legally binding shorthand, which can be used
instead of the full boiler plate text.

This work is based on a script and data from Thomas Gleixner, Philippe
Ombredanne, and Kate Stewart.

Cc: Vaibhav Hiremath <hvaibhav.linux@gmail.com>
Cc: "Bryan O'Donoghue" <pure.logic@nexus-software.ie>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Acked-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Acked-by: David Lin <dtwlin@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Acked-by: Johan Hovold <johan@kernel.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Mark Greer <mgreer@animalcreek.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-11 14:46:20 +01:00
Linus Torvalds
caa5942897 staging/iio driver patches for 4.11-rc1
Here is the big staging and iio driver patchsets for 4.11-rc1.
 
 We almost broke even this time around, with only a few thousand lines
 added overall, as we removed the old and obsolete i4l code, but added
 some new drivers for the RPi platform, as well as adding some new IIO
 drivers.
 
 All of these have been in linux-next for a while with no reported
 issues.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCWK2j/w8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ymZ1ACdFR4o6xYrWEizmao4a/u+lUZE1aIAnRmcGcIc
 J+leO1n9bE5iadQvKYUW
 =sKVA
 -----END PGP SIGNATURE-----

Merge tag 'staging-4.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging

Pull staging/iio driver updates from Greg KH:
 "Here is the big staging and iio driver patchsets for 4.11-rc1.

  We almost broke even this time around, with only a few thousand lines
  added overall, as we removed the old and obsolete i4l code, but added
  some new drivers for the RPi platform, as well as adding some new IIO
  drivers.

  All of these have been in linux-next for a while with no reported
  issues"

* tag 'staging-4.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (669 commits)
  Staging: vc04_services: Fix the "space prohibited" code style errors
  Staging: vc04_services: Fix the "wrong indent" code style errors
  staging: octeon: Use net_device_stats from struct net_device
  Staging: rtl8192u: ieee80211: ieee80211.h - style fix
  Staging: rtl8192u: ieee80211: ieee80211_tx.c - style fix
  Staging: rtl8192u: ieee80211: rtl819x_BAProc.c - style fix
  Staging: rtl8192u: ieee80211: ieee80211_module.c - style fix
  Staging: rtl8192u: ieee80211: rtl819x_TSProc.c - style fix
  Staging: rtl8192u: r8192U.h - style fix
  Staging: rtl8192u: r8192U_core.c - style fix
  Staging: rtl8192u: r819xU_cmdpkt.c - style fix
  staging: rtl8192u: blank lines aren't necessary before a close brace '}'
  staging: rtl8192u: Adding space after enum and struct definition
  staging: rtl8192u: Adding space after struct definition
  Staging: ks7010: Add required and preferred spaces around operators
  Staging: ks7010: ks*: Remove redundant blank lines
  Staging: ks7010: ks*: Add missing blank lines after declarations
  staging: visorbus, replace init_timer with setup_timer
  staging: vt6656: rxtx.c Removed multiple dereferencing
  staging: vt6656: Alignment match open parenthesis
  ...
2017-02-22 12:14:01 -08:00
Gioh Kim
461ab8077d staging: greybus: fix "line over 80 characters" coding style issues
This patch fixes only obvious lines.
There are still more issues.

Signed-off-by: Gioh Kim <gi-oh.kim@profitbricks.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-02-12 13:26:14 +01:00
Mika Westerberg
2956b5d94a pinctrl / gpio: Introduce .set_config() callback for GPIO chips
Currently we already have two pin configuration related callbacks
available for GPIO chips .set_single_ended() and .set_debounce(). In
future we expect to have even more, which does not scale well if we need
to add yet another callback to the GPIO chip structure for each possible
configuration parameter.

Better solution is to reuse what we already have available in the
generic pinconf.

To support this, we introduce a new .set_config() callback for GPIO
chips. The callback takes a single packed pin configuration value as
parameter. This can then be extended easily beyond what is currently
supported by just adding new types to the generic pinconf enum.

If the GPIO driver is backed up by a pinctrl driver the GPIO driver can
just assign gpiochip_generic_config() (introduced in this patch) to
.set_config and that will take care configuration requests are directed
to the pinctrl driver.

We then convert the existing drivers over .set_config() and finally
remove the .set_single_ended() and .set_debounce() callbacks.

Suggested-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-01-26 15:27:37 +01:00
Roman Sommer
1d3dfbd1dd staging: greybus: fix checkpatch unsigned warnings
Fix checkpatch warnings for parameter type unsigned in greybus.
Note that this patch does not fix all checkpatch warnings for the
affected files.

Signed-off-by: Christian Bewermeyer <christian.bewermeyer@fau.de>
Signed-off-by: Roman Sommer <roman.sommer@fau.de>
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-16 18:08:56 +01:00
Viresh Kumar
039bea8440 Staging: greybus: gpio: Use gbphy_dev->dev instead of bundle->dev
Some of the print messages are using the incorrect device pointer, fix
them.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-17 09:14:55 +02:00
Chase Metzger
3d7f358855 drivers/staging/greybus: gpio.c - Fixed a checkpatch generated warning
Removed braces for single line if statement.

Signed-off-by: Chase Metzger <chasemetzger15@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-09-27 12:59:51 +02:00
Greg Kroah-Hartman
b14bb97626 staging: greybus: gpio: remove KERNEL_VERSION checks
No need to support older kernel versions in the Greybus GPIO driver, so
remove the checks as needed, we can now rely on all of the correct
GPIO core apis being present.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-19 16:41:45 +02:00
Viresh Kumar
88f6ba61f2 greybus: gpio: create irqdomain before registering gpio controller
If a gpio line is getting used for an irq, gpio core will create
/proc/irq/X/gpiolib/ directory for it. This directory gets removed while
the gpio controller is unregistered.

In case of greybus, gb_gpio_irqchip_add() creates an irqdomain and
creates irq mappings for the gpio lines. Currently they are added after
registering the gpio controller and removed before the gpio controller
is removed. On the removal path, while the core tries to remove the irq
directory (/proc/irq/X), it finds that the irq is still getting used and
a "gpiolib" directory is present within it and so it gives this warning:

Steps to reproduce:

    $ cd /sys/class/gpio
    $ echo X > export
    $ echo both > gpioX/edge
    $ echo <interface-number> > /sys/bus/greybus/devices/1-svc/intf_eject

[  139.171436] ------------[ cut here ]------------
[  139.171468] WARNING: at /home/vireshk/all/work/repos/ara/arche/kernel/arche/fs/proc/generic.c:552 remove_proc_entry+0x154/0x188()
[  139.171476] remove_proc_entry: removing non-empty directory 'irq/683', leaking at least 'gpiolib'
[  139.171589] Modules linked in: gb_vibrator(O) gb_usb(O) gb_uart(O) gb_spi(O) gb_sdio(O) gb_raw(O) gb_pwm(O) gb_power_supply(O) gb_loopback(O) gb_log(O) gb_light(O) gb_i2c(O) gb_hid(O) gb_gpio(O) gb_gbphy(O) gb_firmware(O) gb_spilib(O) gb_es2(O) gb_camera(O) gb_bootrom(O) gb_audio_module(O) gb_audio_manager(O) gb_audio_codec(O) gb_audio_gb(O) gb_audio_apbridgea(O) gb_arche(O) greybus(O)
[  139.171605] CPU: 1 PID: 280 Comm: kworker/u16:4 Tainted: G        W  O 3.10.83-g9771b10cbeed #107
[  139.171652] Workqueue: greybus1:svc gb_svc_intf_set_power_mode [greybus]
[  139.171657] Call trace:
[  139.171677] [<ffffffc000207b40>] dump_backtrace+0x0/0x268
[  139.171689] [<ffffffc000207db8>] show_stack+0x10/0x1c
[  139.171707] [<ffffffc000ccad78>] dump_stack+0x1c/0x28
[  139.171723] [<ffffffc00021f9dc>] warn_slowpath_common+0x74/0x9c
[  139.171735] [<ffffffc00021fa60>] warn_slowpath_fmt+0x5c/0x80
[  139.171747] [<ffffffc00035fa38>] remove_proc_entry+0x150/0x188
[  139.171763] [<ffffffc00027464c>] unregister_irq_proc+0xb4/0xdc
[  139.171779] [<ffffffc00026e3f4>] free_desc+0x2c/0x70
[  139.171791] [<ffffffc00026e48c>] irq_free_descs+0x54/0x9c
[  139.171802] [<ffffffc000273448>] irq_dispose_mapping+0x54/0x64
[  139.171814] [<ffffffbffc0621e8>] 0xffffffbffc0621e8
[  139.171825] [<ffffffbffc05e01c>] 0xffffffbffc05e01c
[  139.171843] [<ffffffc0005d4e30>] __device_release_driver+0x90/0xe4
[  139.171854] [<ffffffc0005d4ea4>] device_release_driver+0x20/0x38
[  139.171867] [<ffffffc0005d4634>] bus_remove_device+0x12c/0x148
[  139.171878] [<ffffffc0005d1cb0>] device_del+0x108/0x16c
[  139.171888] [<ffffffc0005d1d64>] device_unregister+0x50/0x68
[  139.171901] [<ffffffbffc05e2bc>] gb_gbphy_deregister_driver+0xf0/0x4ec [gb_gbphy]
[  139.171924] [<ffffffbffc0014c4>] greybus_disabled+0x14c4/0x1760 [greybus]
[  139.171936] [<ffffffc0005d4e30>] __device_release_driver+0x90/0xe4
[  139.171948] [<ffffffc0005d4ea4>] device_release_driver+0x20/0x38
[  139.171959] [<ffffffc0005d4634>] bus_remove_device+0x12c/0x148
[  139.171969] [<ffffffc0005d1cb0>] device_del+0x108/0x16c
[  139.171992] [<ffffffbffc004cec>] gb_bundle_destroy+0x7c/0x1b0 [greybus]
[  139.172017] [<ffffffbffc004074>] gb_interface_disable+0xb4/0x178 [greybus]
[  139.172040] [<ffffffbffc002ae4>] gb_module_del+0x5c/0xf8 [greybus]
[  139.172063] [<ffffffbffc008418>] gb_svc_intf_set_power_mode+0xea0/0xfe8 [greybus]
[  139.172078] [<ffffffc00023888c>] process_one_work+0x268/0x3c8
[  139.172089] [<ffffffc000239a64>] worker_thread+0x204/0x358
[  139.172108] [<ffffffc00023f43c>] kthread+0xb8/0xc4
[  139.172114] ---[ end trace 6fa3314e8c6157ca ]---

Also note that registering the gpio controller before creating irqdomain
is incorrect as well and may lead to kernel panic, as a gpio may get
requested as an interrupt source right after the controller is
registered, and the greybus gpio driver wouldn't be fully ready by then.

This patch changes the sequence in both probe() and remove() to fix it.

Fixes: 426e88a47d39 ("greybus: gpio: add interrupt handling support")
Reported-by: David Hsu <davidhsu@google.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-09-05 09:16:47 +02:00
Axel Haslam
993dc992f2 greybus: gpio: Add runtime_pm suppourt
Add runtime pm support for the gpio driver.
Since there is no remote wakeup support, the
module will not suspend as long as a gpio is
requested.

Maybe an optimization could be made, to allow suspend
if all the requested gpios are in output mode, since
the bridge should maintain the state of the gpio
during suspend.

Testing Done: using the test board, let the
gpbrige enter standby and request a gpio.

Signed-off-by: Axel Haslam <haslam_axel@projectara.com>
Signed-off-by: David Lin <dtwlin@google.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Alex Elder <elder@linaro.org>
2016-07-14 16:53:55 -05:00
Viresh Kumar
60fb3405c7 greybus: Remove extra blank lines
This patch removes few blank lines across the repository at places where
two blank lines were present together or when a blank line is present at
the start or end of a routine.

Note that this doesn't remove most of them from greybus_protocols.h as
they were added on purpose.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-06-10 16:32:33 -07:00
Viresh Kumar
64060fe954 greybus: gbphy: Remove protocol specific version handling
We should be using the generic version handling at bundle level, instead
of at protocol level for bridged PHY devices as well.

The bundle version handling is already in place, though it is *not* used
today as we haven't bumped the version of control protocol yet.

Remove protocol specific handling for bridged PHY devices.

Tested on EVT 1.5 with gpbridge-test module. No nuttx changes are
required with this.

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>
2016-05-31 22:02:58 -07:00
Sandeep Patil
e54b106dd1 greybus: gpbridge: rename 'gpbridge' to 'gbphy' everywhere
The 'gpbridge' name didn't relaly reflect what the bus is; which
is a bus for bridged-phy devices. So, rename all instances
of 'gpbridge' to more appropriate 'gbphy'

Testing Done:
Build and boot tested. 'lsgb' will stop displaying 'GPBridge' devices
until I change the library to reflect this change.

Signed-off-by: Sandeep Patil <patil_sandeep@projectara.com>
Suggested-by: Greg Kroah-Hartman <gregkh@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-19 10:09:13 -07:00
Viresh Kumar
7c0925eb57 greybus: gpio: Create separate module
Create separate module for gpio gpbridge driver.

Tested on EVT 1.5 by inserting GP test module, all the devices were
enumerated correctly.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-14 19:13:57 +02:00
Greg Kroah-Hartman
315bea0e96 greybus: GPIO: convert to a gpbridge driver
This converts the GPIO driver to be a gpbridge driver, moving it away
from the "legacy" interface.

Testing Done: Tested on gbsim.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
[vaibhav.hiremath@linaro.org: 1.Changed code to retain init/exit fns of
drivers. 2.Exit path fix. 3. Fixed review comments]
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-05-05 13:38:57 -07:00
Greg Kroah-Hartman
0ec3063244 greybus: convert drivers to use connection->private set/get
This converts all drivers to use the gb_connection_get_data() and
gb_connection_set_data() functions to make it a bit more explicit as to
what is going on.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-03-22 16:47:28 -04:00
Greg Kroah-Hartman
c7b0726504 greybus: gpbridge.h: move protocol init/exit prototypes
Create gpbridge.h for the gpbridge-specific function prototypes, the
rest of the greybus drivers don't care about them.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
2016-03-03 13:52:02 -08:00
Greg Kroah-Hartman
bb80c76448 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>
2016-02-24 17:44:11 -08:00
Greg Kroah-Hartman
7a6396d9ce 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>
2016-02-24 17:44:11 -08:00
Greg Kroah-Hartman
c7eb46e459 greybus: gpio: use the bundle struct device instead of the connector
We are removing struct device from the gb_connection structure in the
near future.  The gb_bundle structure's struct device should be used as
a replacement.

This patch moves the gpio driver to use the bundle pointer instead of
the connection pointer.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>
2015-10-15 09:19:15 -07:00
Johan Hovold
0010245e2c greybus: gpio: handle set_irq_flags api change
The ARM-specific set_irq_flags helper has been removed in 4.3. Instead
of doing conditional compilation on the kernel version to avoid build
breakages, simply use the genirq interface directly.

Suggested-by: Rob Herring <rob.herring@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-10-14 12:15:45 -07:00
Rui Miguel Silva
3c9426ad27 greybus: gpio: fix generic_handle_irq_desc api change
The generic_handle_irq_desc api only have changed in 4.3.0, so check
against the correct version, if not will break builds for 4.2.x.

Fixes: e7895cfc476 ("gpio: handle api change in generic_handle_irq_desc()")
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-10-01 06:32:56 +02:00
Greg Kroah-Hartman
4ee144170a greybus: gpio: handle api change in generic_handle_irq_desc()
generic_handle_irq_desc changed the api in the 4.2 kernel, so fix up the
gpio driver to handle this properly to keep it working.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-09-30 08:17:49 +02:00
Viresh Kumar
03490fdbe7 greybus: gpio: Drop get_version support
This is done from a common place now, no need to replicate it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-08-11 19:33:05 -07:00
Viresh Kumar
8590ed30be greybus: gpio: Use (already defined) major/minor macros
We already have macros for these, use them instead of writing fixed
values.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-08-10 17:40:46 -07:00
Viresh Kumar
782c3b7328 greybus: gpio: Print expected/actual payload size on mismatch
Print (expected-payload-size actual-payload-size), when the size doesn't
match for requests received by the module. This gives more details
required for debugging the issue.

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-08-10 17:28:30 -07:00
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