aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpio-generic.c
Commit message (Collapse)AuthorAgeFilesLines
* gpio: rename gpio-generic.c into gpio-mmio.cChristian Lamparter2016-04-291-660/+0
| | | | | | | | | | This patch renames the gpio-generic.c into gpio-mmio.c. This is because currently the file only contains code for a memory-mapped GPIO driver. There isn't any support for ioports or other resource type. Signed-off-by: Christian Lamparter <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* gpio: generic: fix GPIO_GENERIC_PLATFORM is set to module caseChristian Lamparter2016-04-291-1/+1
| | | | | | | | | GPIO_GENERIC_PLATFORM is a tristate. If the module option is selected the resulting gpio-generic.ko will lack most of the module initialzation and probe code. Signed-off-by: Christian Lamparter <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* gpio: generic: Use devm_gpiochip_add_data() for gpio registrationLaxman Dewangan2016-02-231-10/+1
| | | | | | | Use devm_gpiochip_add_data() for GPIO registration and remove the need of driver callback .remove. Signed-off-by: Laxman Dewangan <[email protected]>
* gpio: generic: factor into gpio_chip structLinus Walleij2016-01-051-159/+133
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The separate struct bgpio_chip has been a pain to handle, both by being confusingly similar in name to struct gpio_chip and for being contained inside a struct so that struct gpio_chip is contained in a struct contained in a struct, making several steps of dereferencing necessary. Make things simpler: include the fields directly into <linux/gpio/driver.h>, #ifdef:ed for CONFIG_GENERIC_GPIO, and get rid of the <linux/basic_mmio_gpio.h> altogether. Prefix some of the member variables with bgpio_* and add proper kerneldoc while we're at it. Modify all users to handle the change and use a struct gpio_chip directly. And while we're at it: replace all container_of() dereferencing by gpiochip_get_data() and registering the gpio_chip with gpiochip_add_data(). Cc: [email protected] Cc: Alexander Shiyan <[email protected]> Cc: Shawn Guo <[email protected]> Cc: Sascha Hauer <[email protected]> Cc: Kukjin Kim <[email protected]> Cc: Alexandre Courbot <[email protected]> Cc: Brian Norris <[email protected]> Cc: Florian Fainelli <[email protected]> Cc: Sudeep Holla <[email protected]> Cc: Lorenzo Pieralisi <[email protected]> Cc: Nicolas Pitre <[email protected]> Cc: Olof Johansson <[email protected]> Cc: Vladimir Zapolskiy <[email protected]> Cc: Rabin Vincent <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Acked-by: Gregory Fong <[email protected]> Acked-by: Liviu Dudau <[email protected]> Acked-by: H Hartley Sweeten <[email protected]> Acked-by: Tony Lindgren <[email protected]> Acked-by: Krzysztof Kozlowski <[email protected]> Acked-by: Lee Jones <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* gpio: generic: fix signedness bug found by cppcheckLinus Walleij2016-01-051-2/+3
| | | | | | | | | | | | | | | cppcheck reports this: (style) int result is returned as long value. If the return value is long to avoid loss of information, then you have loss of information. This can be fixed with (1UL << pin) but that is the same as using <linux/bitops.h> that already use 1UL so take this approach. Reported-by: David Binderman <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* Merge tag 'v4.4-rc6' into develLinus Walleij2015-12-211-2/+2
|\ | | | | | | Linux 4.4-rc6
| * gpio: generic: clamp values from bgpio_get_set()Linus Walleij2015-12-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bgpio_get_set() call should return a value clamped to [0,1], the current code will return a negative value if reading bit 31, which turns the value negative as this is a signed value and thus gets interpreted as an error by the gpiolib core. Found on the gpio-mxc but applies to any MMIO driver. Cc: [email protected] # 4.3+ Cc: [email protected] Cc: Vladimir Zapolskiy <[email protected]> Fixes: e20538b82f1f ("gpio: Propagate errors from chip->get()") Reported-by: Clemens Gruber <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* | gpio: change member .dev to .parentLinus Walleij2015-11-191-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The name .dev in a struct is normally reserved for a struct device that is let us say a superclass to the thing described by the struct. struct gpio_chip stands out by confusingly using a struct device *dev to point to the parent device (such as a platform_device) that represents the hardware. As we want to give gpio_chip:s real devices, this is not working. We need to rename this member to parent. This was done by two coccinelle scripts, I guess it is possible to combine them into one, but I don't know such stuff. They look like this: @@ struct gpio_chip *var; @@ -var->dev +var->parent and: @@ struct gpio_chip var; @@ -var.dev +var.parent and: @@ struct bgpio_chip *var; @@ -var->gc.dev +var->gc.parent Plus a few instances of bgpio that I couldn't figure out how to teach Coccinelle to rewrite. This patch hits all over the place, but I *strongly* prefer this solution to any piecemal approaches that just exercise patch mechanics all over the place. It mainly hits drivers/gpio and drivers/pinctrl which is my own backyard anyway. Cc: Haavard Skinnemoen <[email protected]> Cc: Rafał Miłecki <[email protected]> Cc: Richard Purdie <[email protected]> Cc: Mauro Carvalho Chehab <[email protected]> Cc: Alek Du <[email protected]> Cc: Jaroslav Kysela <[email protected]> Cc: Takashi Iwai <[email protected]> Acked-by: Dmitry Torokhov <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]> Acked-by: Lee Jones <[email protected]> Acked-by: Jiri Kosina <[email protected]> Acked-by: Hans-Christian Egtvedt <[email protected]> Acked-by: Jacek Anaszewski <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* gpio: generic: Revert to old error handling in bgpio_mapGuenter Roeck2015-10-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Returning an error instead of NULL in bgpio_map if platform_get_resource_byname does not find a resource was introduced with commit cf3f2a2c8bae ("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: cf3f2a2c8bae ("gpio: generic: improve error handling in bgpio_map") Cc: Heiner Kallweit <[email protected]> Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* gpio: generic: use error pointersHeiner Kallweit2015-10-051-35/+21
| | | | | | | | Use the ERRPTR standard way to return an error code in a pointer thus simplifiying the code. Signed-off-by: Heiner Kallweit <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* gpio: generic: modernize remappingHeiner Kallweit2015-10-051-11/+3
| | | | | | | Replace devm_request_mem_region / devm_ioremap with devm_ioremap_resource. Signed-off-by: Heiner Kallweit <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* gpio: generic: improve error handling in bgpio_mapHeiner Kallweit2015-10-051-3/+5
| | | | | | | If bgpio_map returns NULL then err should always be set. Signed-off-by: Heiner Kallweit <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* gpio: generic: support input-only chipsRabin Vincent2015-07-271-3/+20
| | | | | | | | 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 <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* gpio: generic: add get_direction supportPhilipp Zabel2015-07-151-0/+18
| | | | | | | | | Allow to determine the current direction configuration by reading back from the direction register. Signed-off-by: Philipp Zabel <[email protected]> Acked-by: Alexandre Courbot <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* gpio: gpio-generic: add flag to read out output value from reg_setVladimir Zapolskiy2015-05-111-3/+19
| | | | | | | | | 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 <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* gpio-generic: add bgpio_set_multiple functionsRojhalat Ibrahim2015-01-191-0/+76
| | | | | | | | | 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 <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* gpio: remove all usage of gpio_remove retval in driver/gpioabdoulaye berthe2014-07-221-1/+2
| | | | | Signed-off-by: abdoulaye berthe <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* gpio: generic: add request function pointerAnthony Fee2014-05-231-0/+9
| | | | | | | | | | | 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 <[email protected]> Acked-by: Alexandre Courbot <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* gpio: generic: Use platform_device_id->driver_data field for driver flagsAlexander Shiyan2014-03-181-7/+9
| | | | | | Signed-off-by: Alexander Shiyan <[email protected]> Reviewed-by: Alexandre Courbot <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* gpio: generic: clamp retured value to [0,1]Linus Walleij2014-02-061-1/+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 <[email protected]> Reviewed-by: Alexandre Courbot <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* gpio: generic: Add label to platform dataPawel Moll2014-02-061-0/+2
| | | | | | | | 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 <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* GPIO: gpio-generic: remove kfree() from bgpio_remove callAlexander Shiyan2013-04-111-5/+1
| | | | | | | | | | | 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 <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* gpio: gpio-generic: Add 16 and 32 bit big endian byte order supportAndreas Larsson2013-04-101-9/+47
| | | | | | | | | There is no general support for 64-bit big endian accesses, so that is left unsupported. Signed-off-by: Andreas Larsson <[email protected]> Acked-by: Anton Vorontsov <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* gpio: remove use of __devexitBill Pemberton2012-11-281-1/+1
| | | | | | | | | | | | CONFIG_HOTPLUG is going away as an option so __devexit is no longer needed. Signed-off-by: Bill Pemberton <[email protected]> Cc: Grant Likely <[email protected]> Acked-by: Linus Walleij <[email protected]> Cc: Peter Tyser <[email protected]> Acked-by: Mark Brown <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
* gpio: remove use of __devinitBill Pemberton2012-11-281-1/+1
| | | | | | | | | | | | | | CONFIG_HOTPLUG is going away as an option so __devinit is no longer needed. Signed-off-by: Bill Pemberton <[email protected]> Cc: Grant Likely <[email protected]> Cc: Peter Tyser <[email protected]> Cc: Santosh Shilimkar <[email protected]> Cc: Kevin Hilman <[email protected]> Acked-by: Linus Walleij <[email protected]> Acked-by: Mark Brown <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
* gpio: remove use of __devexit_pBill Pemberton2012-11-281-1/+1
| | | | | | | | | | | | CONFIG_HOTPLUG is going away as an option so __devexit_p is no longer needed. Signed-off-by: Bill Pemberton <[email protected]> Cc: Grant Likely <[email protected]> Cc: Peter Tyser <[email protected]> Acked-by: Linus Walleij <[email protected]> Acked-by: Mark Brown <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
* gpio/generic: initialize basic_mmio_gpio shadow variables properlyShawn Guo2012-05-191-5/+11
| | | | | | | | | | | | | | | | 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 <[email protected]> [grant.likely: Fix big-endian usage to explicitly set BBGPIOF_BIG_ENDIAN] Signed-off-by: Grant Likely <[email protected]>
* gpio: Convert GPIO drivers to module_platform_driverMark Brown2012-01-021-11/+1
| | | | | | | | | 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 <[email protected]> Signed-off-by: Grant Likely <[email protected]>
* drivers/gpio/gpio-generic.c: fix build errorsRussell King2011-09-151-10/+5
| | | | | | | | | | | | | | | | | | 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 <[email protected]> Cc: Grant Likely <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
* gpio: reorganize driversGrant Likely2011-06-061-0/+548
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 <[email protected]>