Commit graph

22 commits

Author SHA1 Message Date
Guenter Roeck b2f68b6306 gpio: generic: Revert to old error handling in bgpio_map
Returning an error instead of NULL in bgpio_map if
platform_get_resource_byname does not find a resource was introduced with
commit cf3f2a2c8b ("gpio: generic: improve error handling in bgpio_map").
This results in several qemu runtime failures with default and non-default
configurations, if attempts are made to boot from mmcblk0. Examples for
failures with multi_v7_defconfig are

Machine: vexpress-a9	dtb: vexpress-v2p-ca9
Machine: vexpress-a15	dtb: vexpress-v2p-ca15-tc1

Crash:

VFS: Cannot open root device "mmcblk0" or unknown-block(0,0): error -6
Please append a correct "root=" boot option; here are the available partitions:
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

Looking into the code, always returning an error if bgpio_map fails
does not appear to make much sense, since the code in bgpio_setup_io
specifically supports some of the resources to be NULL.

Fixes: cf3f2a2c8b ("gpio: generic: improve error handling in bgpio_map")
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2015-10-27 11:26:31 +01:00
Heiner Kallweit 8d2402605b gpio: generic: use error pointers
Use the ERRPTR standard way to return an error code in a pointer
thus simplifiying the code.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2015-10-05 09:16:28 +02:00
Heiner Kallweit 43960b4731 gpio: generic: modernize remapping
Replace devm_request_mem_region / devm_ioremap with devm_ioremap_resource.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2015-10-05 09:14:44 +02:00
Heiner Kallweit cf3f2a2c8b gpio: generic: improve error handling in bgpio_map
If bgpio_map returns NULL then err should always be set.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2015-10-05 09:13:39 +02:00
Rabin Vincent 91492a44b9 gpio: generic: support input-only chips
Allow chips to indicates that they are input-only and thus cannot set
the output value.  This will be used by the gpio-etraxfs driver.

Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2015-07-27 15:01:05 +02:00
Philipp Zabel db3b0fcc5a gpio: generic: add get_direction support
Allow to determine the current direction configuration by
reading back from the direction register.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Acked-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2015-07-16 00:11:02 +02:00
Vladimir Zapolskiy b19e7f51a5 gpio: gpio-generic: add flag to read out output value from reg_set
The change introduces BGPIOF_READ_OUTPUT_REG_SET flag for gpio-generic
GPIO chip implementation, which allows to get correct configured value
from reg_set register, input value is still get from reg_dat.

Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2015-05-11 11:49:02 +02:00
Rojhalat Ibrahim 73c4ceda09 gpio-generic: add bgpio_set_multiple functions
Add set_multiple functions to the generic driver for memory-mapped GPIO
controllers to improve performance when setting multiple outputs
simultaneously.

Signed-off-by: Rojhalat Ibrahim <imr@rtschenk.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2015-01-19 11:07:00 +01:00
abdoulaye berthe 9f5132ae82 gpio: remove all usage of gpio_remove retval in driver/gpio
Signed-off-by: abdoulaye berthe <berthe.ab@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-07-22 16:39:26 +02:00
Anthony Fee 7b42e3dbda gpio: generic: add request function pointer
gpiolib will require all gpio drivers to expicitly set the request
function pointer in the future. To encourage gpio driver developers
to adhere to this standard gpio-generic.c now sets this function
pointer.

Signed-off-by: Anthony Fee <anthony.fee@emutex.com>
Acked-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-05-23 14:31:51 +02:00
Alexander Shiyan 193385305b gpio: generic: Use platform_device_id->driver_data field for driver flags
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-03-18 09:28:31 +01:00
Linus Walleij 25b35da7f4 gpio: generic: clamp retured value to [0,1]
The generic GPIO would return 0 for low generic GPIO, and
something != 0 for high GPIO. Let's make this sane by clamping
the returned value to [0,1].

Reported-by: Evgeny Boger <boger@contactless.ru>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-02-06 10:33:48 +01:00
Pawel Moll 781f6d710d gpio: generic: Add label to platform data
When registering more than one platform device, it is
useful to set the gpio chip label in the platform data.

Signed-off-by: Pawel Moll <pawel.moll@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-02-06 10:33:47 +01:00
Alexander Shiyan 2ce7c62d1b GPIO: gpio-generic: remove kfree() from bgpio_remove call
Memory for basic-mmio-gpio driver is allocated by the driver
using it, whether it's the generic GPIO driver itself or another
driver. In either case, the owner shall allocate and free the
struct bgpio_chip it is using, preferably using a managed
resource.

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2013-04-11 19:33:54 +02:00
Andreas Larsson 2b78f1e138 gpio: gpio-generic: Add 16 and 32 bit big endian byte order support
There is no general support for 64-bit big endian accesses, so that is
left unsupported.

Signed-off-by: Andreas Larsson <andreas@gaisler.com>
Acked-by: Anton Vorontsov <anton@enomsg.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2013-04-10 23:41:16 +02:00
Bill Pemberton 206210ce68 gpio: remove use of __devexit
CONFIG_HOTPLUG is going away as an option so __devexit is no
longer needed.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Cc: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Cc: Peter Tyser <ptyser@xes-inc.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-28 11:39:59 -08:00
Bill Pemberton 3836309d93 gpio: remove use of __devinit
CONFIG_HOTPLUG is going away as an option so __devinit is no longer
needed.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Peter Tyser <ptyser@xes-inc.com>
Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: Kevin Hilman <khilman@ti.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-28 11:39:33 -08:00
Bill Pemberton 8283c4ff57 gpio: remove use of __devexit_p
CONFIG_HOTPLUG is going away as an option so __devexit_p is no longer
needed.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Peter Tyser <ptyser@xes-inc.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-28 11:36:36 -08:00
Shawn Guo 3e11f7b840 gpio/generic: initialize basic_mmio_gpio shadow variables properly
It fixes the issue in gpio-generic that commit fb14921 (gpio/mxc: add
missing initialization of basic_mmio_gpio shadow variables) manged to
fix in gpio-mxc driver, so that other platform specific drivers do not
suffer from the same problem over and over again.

Changes since v1:
* Turn the last parameter of bgpio_init() "bool big_endian" into
  "unsigned long flags" and give those really quirky hardwares a
  chance to tell that reg_set and reg_dir are unreadable.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
[grant.likely: Fix big-endian usage to explicitly set BBGPIOF_BIG_ENDIAN]
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
2012-05-19 12:17:35 -06:00
Mark Brown 6f61415e9c gpio: Convert GPIO drivers to module_platform_driver
Where appropriate factor out some boilerplate code for platform device
registration into module_platform_driver. Drivers that don't use the
standard module_init initcall haven't been converted.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
2012-01-02 00:26:06 -07:00
Russell King 4f5b04800a drivers/gpio/gpio-generic.c: fix build errors
Building a kernel with hotplug disabled results in a link failure:

  `bgpio_remove' referenced in section `___ksymtab_gpl+bgpio_remove' of drivers/built-in.o: defined in discarded section `.devexit.text' of drivers/built-in.o

This is because of bgpio_remove() is exported.  It is illegal to export
symbols which are discarded either at link time or as part of an
init/exit section.

Fix this by dropping the __devexit attributation from bgpio_remove().
Also drop the __devinit attributation from bgpio_init().

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-14 18:09:38 -07:00
Grant Likely c103de2404 gpio: reorganize drivers
Sort the gpio makefile and enforce the naming convention gpio-*.c for
gpio drivers.

v2: cleaned up filenames in Kconfig and comment blocks
v3: fixup use of BASIC_MMIO to GENERIC_GPIO for mxc

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
2011-06-06 10:10:11 -06:00
Renamed from drivers/gpio/basic_mmio_gpio.c (Browse further)