summaryrefslogtreecommitdiff
path: root/drivers/gpio
AgeCommit message (Collapse)AuthorFilesLines
2020-06-03gpio: add a reusable generic gpio_chip using regmapMichael Walle3-0/+354
There are quite a lot simple GPIO controller which are using regmap to access the hardware. This driver tries to be a base to unify existing code into one place. This won't cover everything but it should be a good starting point. It does not implement its own irq_chip because there is already a generic one for regmap based devices. Instead, the irq_chip will be instantiated in the parent driver and its irq domain will be associate to this driver. For now it consists of the usual registers, like set (and an optional clear) data register, an input register and direction registers. Out-of-the-box, it supports consecutive register mappings and mappings where the registers have gaps between them with a linear mapping between GPIO offset and bit position. For weirder mappings the user can register its own .xlate(). Signed-off-by: Michael Walle <michael@walle.cc> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20200528145845.31436-3-michael@walle.cc Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-06-03gpiolib: Introduce gpiochip_irqchip_add_domain()Michael Walle1-0/+20
The function connects an IRQ domain to a gpiochip and reuses gpiochip_to_irq() which is provided by gpiolib. gpiochip_irqchip_* and regmap_irq partially provide the same functionality. This function will help to connect just the minimal functionality of the gpiochip_irqchip which is needed to work together with regmap-irq. Signed-off-by: Michael Walle <michael@walle.cc> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20200528145845.31436-2-michael@walle.cc Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-05-29gpio: gpiolib: Allow GPIO IRQs to lazy disableMaulik Shah1-19/+36
With 'commit 461c1a7d4733 ("gpiolib: override irq_enable/disable")' gpiolib overrides irqchip's irq_enable and irq_disable callbacks. If irq_disable callback is implemented then genirq takes unlazy path to disable irq. Underlying irqchip may not want to implement irq_disable callback to lazy disable irq when client drivers invokes disable_irq(). By overriding irq_disable callback, gpiolib ends up always unlazy disabling IRQ. Allow gpiolib to lazy disable IRQs by overriding irq_disable callback only if irqchip implemented irq_disable. In cases where irq_disable is not implemented irq_mask is overridden. Similarly override irq_enable callback only if irqchip implemented irq_enable otherwise irq_unmask is overridden. Fixes: 461c1a7d4733 ("gpiolib: override irq_enable/disable") Signed-off-by: Maulik Shah <mkshah@codeaurora.org> Tested-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Link: https://lore.kernel.org/r/1590253873-11556-2-git-send-email-mkshah@codeaurora.org Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-05-27gpiolib: Separate GPIO_GET_LINEINFO_WATCH_IOCTL conditionalAndy Shevchenko1-10/+23
We already have two conditionals inside the outer one to check if the command is GPIO_GET_LINEINFO_WATCH_IOCTL. I think it's time to actually do what I have proposed in the first place, i.e. to separate GPIO_GET_LINEINFO_WATCH_IOCTL from GPIO_GET_LINEINFO_IOCTL. It's +13 LOCs, and surprisingly only +13 bytes of binary on x86_32, but for the price of much better readability. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Link: https://lore.kernel.org/r/20200525194028.74236-1-andriy.shevchenko@linux.intel.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-05-27Merge tag 'v5.7-rc7' into develLinus Walleij3-6/+31
Linux 5.7-rc7
2020-05-27Merge tag 'gpio-updates-for-v5.8-part2' of ↵Linus Walleij2-9/+7
git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux into devel gpio: updates for v5.8 - part 2 - fix the initialization ordering in gpio-max730x - make gpio-pxa buildable for compile testing - make gpio-pca953x buildable as a module
2020-05-25gpio: rcar: Fix runtime PM imbalance on errorDinghao Liu1-1/+3
pm_runtime_get_sync() increments the runtime PM usage counter even when it returns an error code. Thus a pairing decrement is needed on the error handling path to keep the counter balanced. Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn> Link: https://lore.kernel.org/r/20200522080839.32612-1-dinghao.liu@zju.edu.cn Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-05-25gpio: pca935x: Allow IRQ support for driver built as a moduleAndy Shevchenko1-1/+1
Perhaps by some historical reasons the IRQ support has been allowed only for built-in driver. However, there is nothing prevents us to build it as module an use as IRQ chip. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2020-05-25gpio: pxa: Add COMPILE_TEST supportTiezhu Yang1-1/+1
Add COMPILE_TEST support to the PXA GPIO driver for better compile testing coverage. Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2020-05-25gpio: dwapb: Remove unneeded has_irq member in struct dwapb_port_propertyAndy Shevchenko1-7/+7
has_irq member of struct dwapb_port_property is used only in one place, so, make it local test instead and remove from the structure. This local test is using memchr_inv() which is quite efficient in comparison to the original loop and possible little overhead can be neglected. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Tested-by: Serge Semin <fancer.lancer@gmail.com> Acked-by: Lee Jones <lee.jones@linaro.org> Acked-by: Serge Semin <fancer.lancer@gmail.com> Link: https://lore.kernel.org/r/20200519131233.59032-4-andriy.shevchenko@linux.intel.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-05-25gpio: dwapb: Don't use IRQ 0 as valid Linux interruptAndy Shevchenko1-7/+7
IRQ 0 is not valid in Linux interrupt number space. Refactor the code with this kept in mind. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Tested-by: Serge Semin <fancer.lancer@gmail.com> Acked-by: Serge Semin <fancer.lancer@gmail.com> Link: https://lore.kernel.org/r/20200519131233.59032-3-andriy.shevchenko@linux.intel.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-05-25gpio: dwapb: avoid error message for optional IRQAndy Shevchenko1-1/+1
platform_get_irq() will generate an error message if the requested IRQ is not present. Use platform_get_irq_optional() to avoid the error message being generated. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Tested-by: Serge Semin <fancer.lancer@gmail.com> Reviewed-by: Serge Semin <fancer.lancer@gmail.com> Acked-by: Serge Semin <fancer.lancer@gmail.com> Link: https://lore.kernel.org/r/20200519131233.59032-2-andriy.shevchenko@linux.intel.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-05-25gpio: dwapb: Call acpi_gpiochip_free_interrupts() on GPIO chip de-registrationAndy Shevchenko1-9/+16
Add missed acpi_gpiochip_free_interrupts() call when unregistering ports. While at it, drop extra check to call acpi_gpiochip_request_interrupts(). There is no need to have an additional check to call acpi_gpiochip_request_interrupts(). Even without any interrupts available the registered ACPI Event handlers can be useful for debugging purposes. Fixes: e6cb3486f5a1 ("gpio: dwapb: add gpio-signaled acpi event support") Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Tested-by: Serge Semin <fancer.lancer@gmail.com> Acked-by: Serge Semin <fancer.lancer@gmail.com> Link: https://lore.kernel.org/r/20200519131233.59032-1-andriy.shevchenko@linux.intel.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-05-22gpio: max730x: bring gpiochip_add_data after port configRodrigo Alencar1-7/+5
gpiochip_add_data being called before might cause premature calls of the gpiochip operations before the port_config values are initialized, which would possibily write zeros to port configuration registers, an operation not allowed. For example, if there are gpio-hog nodes in a device-tree, the sequence of function calls are performed gpiochip_add_data of_gpiochip_add of_gpiochip_scan_gpios of_gpiochip_add_hog gpiod_hog gpiochip_request_own_desc gpiod_configure_flags gpiod_direction_output/gpiod_direction_input which would call later the gpiochip operation direction_output or direction_input prior the port_config[] initialization. Moreover, gpiochip_get_data is replaced by the container_of macro inside the gpiochip operations, which would allow the calling of max7301_direction_input prior to gpiochip_add_data Signed-off-by: Rodrigo Alencar <455.rodrigo.alencar@gmail.com> [Bartosz: tweaked the commit message] Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2020-05-18Merge branch 'ib-gpio-aggregator' into develLinus Walleij4-5/+598
2020-05-18gpio: Add GPIO AggregatorGeert Uytterhoeven3-0/+581
GPIO controllers are exported to userspace using /dev/gpiochip* character devices. Access control to these devices is provided by standard UNIX file system permissions, on an all-or-nothing basis: either a GPIO controller is accessible for a user, or it is not. Currently no mechanism exists to control access to individual GPIOs. Hence add a GPIO driver to aggregate existing GPIOs, and expose them as a new gpiochip. This supports the following use cases: - Aggregating GPIOs using Sysfs This is useful for implementing access control, and assigning a set of GPIOs to a specific user or virtual machine. - Generic GPIO Driver This is useful for industrial control, where it can provide userspace access to a simple GPIO-operated device described in DT, cfr. e.g. spidev for SPI-operated devices. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Tested-by: Eugeniu Rosca <erosca@de.adit-jv.com> Reviewed-by: Eugeniu Rosca <erosca@de.adit-jv.com> Link: https://lore.kernel.org/r/20200511145257.22970-5-geert+renesas@glider.be Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-05-18gpiolib: Add support for GPIO lookup by line nameGeert Uytterhoeven1-5/+17
Currently a GPIO lookup table can only refer to a specific GPIO by a tuple, consisting of a GPIO controller label and a GPIO offset inside the controller. However, a GPIO may also carry a line name, defined by DT or ACPI. If present, the line name is the most use-centric way to refer to a GPIO. Hence add support for looking up GPIOs by line name. Note that there is no guarantee that GPIO line names are globally unique, so this will use the first match found. Implement this by reusing the existing gpiod_lookup infrastructure. Rename gpiod_lookup.chip_label to gpiod_lookup.key, to make it clear that this field can have two meanings, and update the kerneldoc and GPIO_LOOKUP*() macros. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Tested-by: Eugeniu Rosca <erosca@de.adit-jv.com> Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu> Reviewed-by: Eugeniu Rosca <erosca@de.adit-jv.com> Link: https://lore.kernel.org/r/20200511145257.22970-4-geert+renesas@glider.be Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-05-18gpio: xgene-sb: Drop extra check to call acpi_gpiochip_request_interrupts()Andy Shevchenko1-7/+3
There is no need to have an additional check to call acpi_gpiochip_request_interrupts(). Even without any interrupts available the registered ACPI Event handlers can be useful for debugging purposes. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20200512182721.55127-3-andriy.shevchenko@linux.intel.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-05-18gpio: xgene-sb: Allow driver to be built with COMPILE_TESTAndy Shevchenko1-1/+1
Allow driver to be built with COMPILE_TEST for better test coverage. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20200512182721.55127-2-andriy.shevchenko@linux.intel.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-05-18gpio: xgene-sb: Drop redundant OF_GPIO dependencyAndy Shevchenko2-2/+2
There is nothing in the driver requires OF_GPIO. Moreover, driver supports ACPI and OF_GPIO may be a quite overhead on such configurations. Drop dependency for good and replace of_gpio.h to of.h since we have one function to be defined from there. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20200512182721.55127-1-andriy.shevchenko@linux.intel.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-05-18gpio: mb86s7x: Remove superfluous test for ACPI companionAndy Shevchenko1-8/+6
acpi_gpiochip_request_interrupts() will check for ACPI handle of the GPIO chip parent device and bail out if there is none defined. Thus, has_acpi_companion() is effectively repeating above and is not needed in the individual driver. Assigning ->to_irq() unconditionally doesn't change anything, except an error code, but this we fix as well by propagating it from platform_get_irq(). Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20200512182623.54990-2-andriy.shevchenko@linux.intel.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-05-18gpio: mb86s7x: Use devm_clk_get_optional() to get the input clockAndy Shevchenko1-9/+7
Simplify the code which fetches the input clock by using devm_clk_get_optional(). If no input clock is present devm_clk_get_optional() will return NULL instead of an error which matches the behavior of the old code. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20200512182623.54990-1-andriy.shevchenko@linux.intel.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-05-16gpiolib: Document that GPIO line names are not globally uniqueGeert Uytterhoeven1-3/+8
gpiochip_set_desc_names() no longer rejects GPIO line name collisions. Hence GPIO line names are not guaranteed to be globally unique. In case of multiple GPIO lines with the same name, gpio_name_to_desc() will return the first match found. Update the comments for gpio_name_to_desc() and gpiochip_set_desc_names() to match reality. Fixes: f881bab038c9667d ("gpio: keep the GPIO line names internal") Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/r/20200511101828.30046-1-geert+renesas@glider.be Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-05-12Merge tag 'intel-gpio-v5.8-1' of ↵Linus Walleij3-40/+45
git://git.kernel.org/pub/scm/linux/kernel/git/andy/linux-gpio-intel into devel intel-gpio for v5.8-1 * MSI support for Intel Merrifield * Refactor gpio-pch to be up-to-date with recent kernel APIs * Miscellaneous cleanups here and there The following is an automated git shortlog grouped by driver: ich: - fix a typo merrifield: - Better show how GPIO and IRQ bases are derived from hardware - Switch over to MSI interrupts pch: - Use in pch_irq_type() macros provided by IRQ core - Refactor pch_irq_type() to avoid unnecessary locking - Get rid of unneeded variable in IRQ handler - Use BIT() and GENMASK() where it's appropriate
2020-05-09Merge tag 'gpio-updates-for-v5.8-part1' of ↵Linus Walleij9-47/+113
git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux into devel gpio updates for v5.8-rc1 - part1 - correct the IRQ type used in to_irq() in gpio-xgene-sb - add new item to the TODO list - support building gpio-pl061 as module - improve pull-up/down support on GPIO expanders in device-tree - several improvements in gpio-pca953x - emit a warning for too long GPIO line names - add MODULE_DEVICE_TABLE to gpio-tegra186 - add support for new variant to gpio-f7188x - lsgpio can now display bias flags
2020-05-05gpio-f7188x: Add GPIO support for F81865Petteri Jokinen1-3/+30
Add GPIO support for Fintek F81865 chip. Datasheet: http://www.hardwaresecrets.com/datasheets/F81865_V028P.pdf Signed-off-by: Petteri Jokinen <petteri@kiho.fi> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2020-05-05gpio: tegra186: export MODULE_DEVICE_TABLEMian Yousaf Kaukab1-0/+1
Export MODULE_DEVICE_TABLE since the driver can be built as a module. Signed-off-by: Mian Yousaf Kaukab <ykaukab@suse.de> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2020-04-29gpio: pca953x: drop unused parameters of pca953x_recalc_addr()Uwe Kleine-König1-20/+11
After the previous patch the two last parameters of pca953x_recalc_addr() are unused and so can be dropped. Tested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2020-04-29gpio: pca953x: fix handling of automatic address incrementingUwe Kleine-König1-16/+28
Some of the chips supported by the pca953x driver need the most significant bit in the address word set to automatically increment the address pointer on subsequent reads and writes (example: PCA9505). With this bit unset the same register is read multiple times on a multi-byte read sequence. Other chips must not have this bit set and autoincrement always (example: PCA9555). Up to now this AI bit was interpreted to be part of the address, which resulted in inconsistent regmap caching when a register was written with AI set and then read without it. This happened for the PCA9505 in pca953x_gpio_set_multiple() where pca953x_read_regs() bulk read from the cache for registers 0x8-0xc and then wrote to registers 0x88-0x8c. (Side note: reading 5 values from offset 0x8 yiels OP0 5 times because AI must be set to get OP0-OP4, which is another bug that is resolved here as a by-product.) The same problem happens when calls to gpio_set_value() and gpio_set_array_value() were mixed. With this patch the AI bit is always set for chips that support it. This works as there are no code locations that make use of the behaviour with AI unset (for the chips that support it). Note that the call to pca953x_setup_gpio() had to be done a bit earlier to make the NBANK macro work. The history of this bug is a bit complicated. Commit b32cecb46bdc ("gpio: pca953x: Extract the register address mangling to single function") changed which chips and functions are affected. Commit 3b00691cc46a ("gpio: pca953x: hack to fix 24 bit gpio expanders") used some duct tape to make the driver at least appear to work. Commit 49427232764d ("gpio: pca953x: Perform basic regmap conversion") introduced the caching. Commit b4818afeacbd ("gpio: pca953x: Add set_multiple to allow multiple bits to be set in one write.") introduced the .set_multiple() callback which didn't work for chips that need the AI bit which was fixed later for some chips in 8958262af3fb ("gpio: pca953x: Repair multi-byte IO address increment on PCA9575"). So I'm sorry, I don't know which commit I should pick for a Fixes: line. Tested-by: Marcel Gudert <m.gudert@eckelmann.de> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Tested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2020-04-29gpio: pca953x: Rewrite ->get_multiple() functionAndy Shevchenko1-30/+11
The commit 96d7c7b3e654 ("gpio: gpio-pca953x, Add get_multiple function") basically did everything wrong from style and code reuse perspective, i.e. - it didn't utilize existing PCA953x internal helpers - it didn't utilize bitmap API - it misses the point that ilog2(), besides that BANK_SFT is useless, can be used in macros - it has indentation issues. Rewrite the function completely. Cc: Paul Thomas <pthomas8589@gmail.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2020-04-28gpio: mm-lantiq: Fix small typoDejin Zheng1-1/+1
Fix a spelling typo in gpio-mm-lantiq.c by codespell s/dont/don't/ Cc: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com> Link: https://lore.kernel.org/r/20200424154103.10311-3-zhengdejin5@gmail.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-04-28gpio: tegra: mask GPIO IRQs during IRQ shutdownStephen Warren1-0/+1
The driver currently leaves GPIO IRQs unmasked even when the GPIO IRQ client has released the GPIO IRQ. This allows the HW to raise IRQs, and SW to process them, after shutdown. Fix this by masking the IRQ when it's shut down. This is usually taken care of by the irqchip core, but since this driver has a custom irq_shutdown implementation, it must do this explicitly itself. Signed-off-by: Stephen Warren <swarren@nvidia.com> Link: https://lore.kernel.org/r/20200427232605.11608-1-swarren@wwwdotorg.org Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-04-28gpio: mlxbf2: fix return value check in mlxbf2_gpio_get_lock_res()Wei Yongjun1-2/+2
In case of error, the function devm_ioremap() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test. Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com> Link: https://lore.kernel.org/r/20200427110829.154785-1-weiyongjun1@huawei.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-04-28gpio: of: Build fails if CONFIG_OF_DYNAMIC enabled without CONFIG_OF_GPIODavid Gow1-2/+3
The symbol 'gpio_of_notifier' doesn't exist without both CONFIG_OF_GPIO and CONFIG_OF_DYNAMIC enabled, but is referenced when only CONFIG_OF_DYNAMIC is enabled. This broke building with 'make ARCH=um allyesconfig': --------------- /usr/bin/ld: drivers/gpio/gpiolib.o: in function `gpiolib_dev_init': ./drivers/gpio/gpiolib.c:5293: undefined reference to `gpio_of_notifier' collect2: error: ld returned 1 exit status --------------- Fixes: 63636d956c45 ("gpio: of: Add DT overlay support for GPIO hogs") Signed-off-by: David Gow <davidgow@google.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/r/20200425044655.166257-1-davidgow@google.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-04-28gpio: ftgpio010: Fix small typoDejin Zheng1-1/+1
Fix a spelling typo in gpio-ftgpio010.c by codespell s/desireable/desirable/ Cc: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com> Link: https://lore.kernel.org/r/20200424154103.10311-2-zhengdejin5@gmail.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-04-28gpiolib: Rename "chip" variables to "gc" in core header fileGeert Uytterhoeven1-14/+13
Consistently use "gc" for "struct gpio *" variables. This follows the spirit of commit a0b66a73785ccc8f ("gpio: Rename variable in core APIs"). Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/r/20200424141517.11582-1-geert+renesas@glider.be Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-04-28gpiolib: Improve kernel messagesGeert Uytterhoeven1-13/+11
Simplify the printing of kernel messages and make the messages more accurate by using the most appropriate {dev,chip,gpiod}_*() helpers. Sample impact: -gpiochip_setup_dev: registered GPIOs 496 to 511 on device: gpiochip0 (e6050000.gpio) +gpio gpiochip0: registered GPIOs 496 to 511 on e6050000.gpio -no flags found for gpios +gpio-953 (?): no flags found for gpios -GPIO line 355 (PCIE/SATA switch) hogged as output/low +gpio-355 (PCIE/SATA switch): hogged as output/low Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/r/20200424141432.11400-1-geert+renesas@glider.be Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-04-28gpio: dwapb: Amend indentation in some casesAndy Shevchenko1-8/+6
In some cases indentation makes code harder to read. Amend indentation in those cases despite of lines go a bit over 80 character limit. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Serge Semin <fancer.lancer@gmail.com> Cc: Serge Semin <fancer.lancer@gmail.com> Link: https://lore.kernel.org/r/20200422110654.23442-2-andriy.shevchenko@linux.intel.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-04-28gpio: dwapb: Get rid of unnecessary conjunction over 32-bit valueAndy Shevchenko1-2/+1
When we mask interrupts before sleep, there is no need to have a conjunction with 0xffffffff since the accepted by dwapb_write() value is 32-bit. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Serge Semin <fancer.lancer@gmail.com> Cc: Serge Semin <fancer.lancer@gmail.com> Link: https://lore.kernel.org/r/20200422110654.23442-1-andriy.shevchenko@linux.intel.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-04-24gpiolib: devprop: Warn if gpio-line-names is too longStephen Boyd1-1/+4
Some DT authors (including myself) have messed up the length of gpio-line-names and made it longer than it should be. Add a warning here so that developers can figure out that they've messed up their DT and should fix it. Cc: Alexandru M Stan <amstan@chromium.org> Signed-off-by: Stephen Boyd <swboyd@chromium.org> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2020-04-23gpiolib: don't call sleeping functions with a spinlock takenBartosz Golaszewski1-1/+12
We must not call pinctrl_gpio_can_use_line() with the gpio_lock taken as it takes a mutex internally. Let's move the call before taking the spinlock and store the return value. This isn't perfect - there's a moment between calling pinctrl_gpio_can_use_line() and taking the spinlock where the situation can change but it isn't a regression either: previously this part wasn't protected at all and it only affects the information user-space is seeing. Reported-by: Geert Uytterhoeven <geert@linux-m68k.org> Fixes: d2ac25798208 ("gpiolib: provide a dedicated function for setting lineinfo") Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Acked-by: Linus Walleij <linus.walleij@linaro.org>
2020-04-23gpiolib: improve the robustness of watch/unwatch ioctl()Bartosz Golaszewski1-2/+14
This makes the new ioctl() a bit more robust - we now check if a line is already being watched and return -EBUSY if the user-space tries to start watching it again. Same for unwatch - return -EBUSY if user-space tries to unwatch a line that's not being watched. Fixes: 51c1064e82e7 ("gpiolib: add new ioctl() for monitoring changes in line info") Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
2020-04-23gpio: pca953x: Fix pca953x_gpio_set_configAdam Ford1-1/+1
pca953x_gpio_set_config is setup to support pull-up/down bias. Currently the driver uses a variable called 'config' to determine which options to use. Unfortunately, this is incorrect. This patch uses function pinconf_to_config_param(config), which converts this 'config' parameter back to pinconfig to determine which option to use. Fixes: 15add06841a3 ("gpio: pca953x: add ->set_config implementation") Signed-off-by: Adam Ford <aford173@gmail.com> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2020-04-17gpio: mlxbf2: remove unused including <linux/version.h>YueHaibing1-1/+0
Remove including <linux/version.h> that don't need it. Signed-off-by: YueHaibing <yuehaibing@huawei.com> Link: https://lore.kernel.org/r/20200408070832.137037-1-yuehaibing@huawei.com Acked-by: Asmaa Mnebhi <Asmaa@mellanox.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-04-17gpio: dwapb: Split out dwapb_get_irq() helperAndy Shevchenko1-27/+29
Split out dwapb_get_irq() helper for better readability and maintenance. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Tested-by: Serge Semin <fancer.lancer@gmail.com> Reviewed-by: Serge Semin <fancer.lancer@gmail.com> Link: https://lore.kernel.org/r/20200415141534.31240-13-andriy.shevchenko@linux.intel.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-04-17gpio: dwapb: Drop of_match_ptr() & ACPI_PTR() callsAndy Shevchenko1-2/+2
Since we always have a table of IDs compiled in, there is no use for of_match_ptr() nor ACPI_PTR() call. Besides that it brings a warning (depending on configuration): .../gpio-dwapb.c:638:34: warning: ‘dwapb_of_match’ defined but not used [-Wunused-const-variable=] 638 | static const struct of_device_id dwapb_of_match[] = { | ^~~~~~~~~~~~~~ Get rid of them for good. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Tested-by: Serge Semin <fancer.lancer@gmail.com> Reviewed-by: Serge Semin <fancer.lancer@gmail.com> Link: https://lore.kernel.org/r/20200415141534.31240-12-andriy.shevchenko@linux.intel.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-04-17gpio: dwapb: Drop bogus BUG_ON()sAndy Shevchenko1-4/+0
There is no case when no context is provided in the ->suspend() and ->resume() hooks. Moreover, BUG_ON() is harmful to user and makes kernel inoperable after the crash. Drop the BUG_ON()s for good. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Tested-by: Serge Semin <fancer.lancer@gmail.com> Reviewed-by: Serge Semin <fancer.lancer@gmail.com> Link: https://lore.kernel.org/r/20200415141534.31240-11-andriy.shevchenko@linux.intel.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-04-17gpio: dwapb: Switch to more usual pattern of RMW in dwapb_gpio_set_debounce()Andy Shevchenko1-2/+3
More usual pattern is to prepare value and then write it in a single place. Switch code in dwapb_gpio_set_debounce() to it. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Tested-by: Serge Semin <fancer.lancer@gmail.com> Reviewed-by: Serge Semin <fancer.lancer@gmail.com> Link: https://lore.kernel.org/r/20200415141534.31240-10-andriy.shevchenko@linux.intel.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-04-17gpio: dwapb: Convert to use IRQ core provided macrosAndy Shevchenko1-8/+2
IRQ core provides macros such as IRQ_RETVAL(). Convert code to use them. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Tested-by: Serge Semin <fancer.lancer@gmail.com> Reviewed-by: Serge Semin <fancer.lancer@gmail.com> Link: https://lore.kernel.org/r/20200415141534.31240-9-andriy.shevchenko@linux.intel.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-04-17gpio: dwapb: Use device_get_match_data() to simplify codeAndy Shevchenko1-12/+1
Use device_get_match_data() here to simplify the code a bit. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Tested-by: Serge Semin <fancer.lancer@gmail.com> Reviewed-by: Serge Semin <fancer.lancer@gmail.com> Link: https://lore.kernel.org/r/20200415141534.31240-8-andriy.shevchenko@linux.intel.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>