aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpio-eic-sprd.c
Commit message (Collapse)AuthorAgeFilesLines
* treewide: rename GPIO set callbacks back to their original namesBartosz Golaszewski2025-08-071-1/+1
| | | | | | | | | | | The conversion of all GPIO drivers to using the .set_rv() and .set_multiple_rv() callbacks from struct gpio_chip (which - unlike their predecessors - return an integer and allow the controller drivers to indicate failures to users) is now complete and the legacy ones have been removed. Rename the new callbacks back to their original names in one sweeping change. Signed-off-by: Bartosz Golaszewski <[email protected]>
* gpio: eic-sprd: use new line value setter callbacksBartosz Golaszewski2025-04-161-2/+3
| | | | | | | | | | struct gpio_chip now has callbacks for setting line values that return an integer, allowing to indicate failures. Convert the driver to using them. Signed-off-by: Bartosz Golaszewski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
* gpio: eic-sprd: use generic device_get_match_data()Bartosz Golaszewski2024-10-141-2/+2
| | | | | | | | | There's no need to use the OF-specific variant to get the match data. Switch to using device_get_match_data() instead. Reviewed-by: Linus Walleij <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
* Merge tag 'v6.8-rc4' into gpio/for-nextBartosz Golaszewski2024-02-121-4/+28
|\ | | | | | | | | | | | | Linux 6.8-rc4 Pulling this for a bugfix upstream with which the gpio/for-next branch conflicts.
| * gpio: eic-sprd: Clear interrupt after set the interrupt typeWenhua Lin2024-01-221-4/+28
| | | | | | | | | | | | | | | | | | | | | | | | The raw interrupt status of eic maybe set before the interrupt is enabled, since the eic interrupt has a latch function, which would trigger the interrupt event once enabled it from user side. To solve this problem, interrupts generated before setting the interrupt trigger type are ignored. Fixes: 25518e024e3a ("gpio: Add Spreadtrum EIC driver support") Acked-by: Chunyan Zhang <[email protected]> Signed-off-by: Wenhua Lin <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
* | gpio: eic-sprd: Optimize the calculation method of eic numberWenhua Lin2024-01-221-6/+4
|/ | | | | | | | | | The num_eics is a default value, but some SoCs support more than 8. In order to adapt to all projects, the total number of eics is automatically calculated through dts. Signed-off-by: Wenhua Lin <[email protected]> Acked-by: Chunyan Zhang <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
* gpio: eic-sprd: use a helper variable for &pdev->devBartosz Golaszewski2023-09-131-10/+10
| | | | | | | | Instead of dereferencing pdev everywhere, just store the address of the underlying struct device in a local variable. Signed-off-by: Bartosz Golaszewski <[email protected]> Reviewed-by: Baolin Wang <[email protected]>
* gpio: eic-sprd: unregister from the irq notifier on remove()Bartosz Golaszewski2023-09-131-2/+17
| | | | | | | | | This is a tristate module, it can be unloaded. We need to cleanup properly and unregister from the interrupt notifier on driver detach. Fixes: b32415652a4d ("gpio: eic-sprd: use atomic notifiers to notify all chips about irqs") Signed-off-by: Bartosz Golaszewski <[email protected]> Reviewed-by: Baolin Wang <[email protected]>
* gpio: eic-sprd: use atomic notifiers to notify all chips about irqsBartosz Golaszewski2023-09-111-19/+25
| | | | | | | | | | | | | | | | | | | | | | | Calling gpiochip_find() from interrupt handler in this driver is an abuse of the GPIO API. It only happens to work because nobody added a might_sleep() to it and the lock used by GPIOLIB is a spinlock. Both will soon be changed as we're limiting both the number of interfaces allowed to be called from atomic context as well as making struct gpio_chip private to the GPIO code that owns it. We'll also switch to protecting the global GPIO device list with a mutex as there is no reason to allow changes to it from interrupt handlers. Instead of iterating over all SPRD chips and looking up each corresponding GPIO chip, let's make each SPRD GPIO controller register with a notifier chain. The chain will be called at interrupt so that every chip that already probed will be notified. The rest of the interrupt handling remains the same. This should result in faster code as we're avoiding iterating over the list of all GPIO devices. Signed-off-by: Bartosz Golaszewski <[email protected]> Reviewed-by: Chunyan Zhang <[email protected]> Tested-by: Wenhua Lin <[email protected]>
* gpio: eic-sprd: remove unneeded platform_set_drvdata() callAndrei Coardos2023-07-291-1/+0
| | | | | | | | | | | | | The platform_set_drvdata() call was never used, ever since the driver was originally added. It looks like this copy+paste left-over. Possibly the author copied from a driver that had this line, but also had a remove hook. Reviewed-by: Alexandru Ardelean <[email protected]> Signed-off-by: Andrei Coardos <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Baolin Wang <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
* gpio: Explicitly include correct DT includesRob Herring2023-07-191-1/+1
| | | | | | | | | | | | | | | | The DT of_device.h and of_platform.h date back to the separate of_platform_bus_type before it as merged into the regular platform bus. As part of that merge prepping Arm DT support 13 years ago, they "temporarily" include each other. They also include platform_device.h and of.h. As a result, there's a pretty much random mix of those include files used throughout the tree. In order to detangle these headers and replace the implicit includes with struct declarations, users need to explicitly include the correct includes. Signed-off-by: Rob Herring <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Acked-by: Romain Perier <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
* gpio: eic-sprd: Make the irqchip immutableCixi Geng2022-12-301-9/+14
| | | | | | | | | | Remove the irq_chip from pmic_eic structure, use the various calls by defining the statically irq_chip structure. Signed-off-by: Cixi Geng <[email protected]> Reviewed-by: Baolin Wang <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
* gpio: Get rid of duplicate of_node assignment in the driversAndy Shevchenko2021-12-171-1/+0
| | | | | | | | | | | | | | GPIO library does copy the of_node from the parent device of the GPIO chip, there is no need to repeat this in the individual drivers. Remove these assignment all at once. For the details one may look into the of_gpio_dev_init() implementation. While at it, remove duplicate parent device assignment where it is the case. Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-By: Matti Vaittinen <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
* gpio: eic-sprd: break loop when getting NULL device resourceChunyan Zhang2020-12-091-1/+1
| | | | | | | | | | | | | EIC controller have unfixed numbers of banks on different Spreadtrum SoCs, and each bank has its own base address, the loop of getting there base address in driver should break if the resource gotten via platform_get_resource() is NULL already. The later ones would be all NULL even if the loop continues. Fixes: 25518e024e3a ("gpio: Add Spreadtrum EIC driver support") Signed-off-by: Chunyan Zhang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
* treewide: Use fallthrough pseudo-keywordGustavo A. R. Silva2020-08-231-3/+1
| | | | | | | | | | Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary fall-through markings when it is the case. [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through Signed-off-by: Gustavo A. R. Silva <[email protected]>
* Revert "gpio: eic-sprd: Use devm_platform_ioremap_resource()"Baolin Wang2020-04-021-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 0f5cb8cc27a266c81e6523b436479802e9aafc9e. This commit will cause below warnings, since our EIC controller can support differnt banks on different Spreadtrum SoCs, and each bank has its own base address, we will get invalid resource warning if the bank number is less than SPRD_EIC_MAX_BANK on some Spreadtrum SoCs. So we should not use devm_platform_ioremap_resource() here to remove the warnings. [ 1.118508] sprd-eic 40210000.gpio: invalid resource [ 1.118535] sprd-eic 40210000.gpio: invalid resource [ 1.119034] sprd-eic 40210080.gpio: invalid resource [ 1.119055] sprd-eic 40210080.gpio: invalid resource [ 1.119462] sprd-eic 402100a0.gpio: invalid resource [ 1.119482] sprd-eic 402100a0.gpio: invalid resource [ 1.119893] sprd-eic 402100c0.gpio: invalid resource [ 1.119913] sprd-eic 402100c0.gpio: invalid resource Signed-off-by: Baolin Wang <[email protected]> Link: https://lore.kernel.org/r/8d3579f4b49bb675dc805035960f24852898be28.1585734060.git.baolin.wang7@gmail.com Signed-off-by: Linus Walleij <[email protected]>
* gpio: eic: sprd: Fix the incorrect EIC offset when togglingBruce Chen2019-10-011-3/+4
| | | | | | | | | | | | When toggling the level trigger to emulate the edge trigger, the EIC offset is incorrect without adding the corresponding bank index, thus fix it. Fixes: 7bf0d7f62282 ("gpio: eic: Add edge trigger emulation for EIC") Cc: [email protected] Signed-off-by: Bruce Chen <[email protected]> Signed-off-by: Baolin Wang <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
* gpio: Remove dev_err() usage after platform_get_irq()Stephen Boyd2019-08-051-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We don't need dev_err() messages when platform_get_irq() fails now that platform_get_irq() prints an error message itself when something goes wrong. Let's remove these prints with a simple semantic patch. // <smpl> @@ expression ret; struct platform_device *E; @@ ret = ( platform_get_irq(E, ...) | platform_get_irq_byname(E, ...) ); if ( \( ret < 0 \| ret <= 0 \) ) { ( -if (ret != -EPROBE_DEFER) -{ ... -dev_err(...); -... } | ... -dev_err(...); ) ... } // </smpl> While we're here, remove braces on if statements that only have one statement (manually). Cc: [email protected] Cc: Greg Kroah-Hartman <[email protected]> Signed-off-by: Stephen Boyd <[email protected]> Link: https://lore.kernel.org/r/[email protected] Acked-by: Bartosz Golaszewski <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* gpio: eic-sprd: Use devm_platform_ioremap_resource()Enrico Weigelt, metux IT consult2019-06-271-7/+2
| | | | | | | | | Use the new helper that wraps the calls to platform_get_resource() and devm_ioremap_resource() together. Signed-off-by: Enrico Weigelt, metux IT consult <[email protected]> Reviewed-by: Baolin Wang <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* gpio: eic: sprd: Fix incorrect irq type setting for the sync EICBaolin Wang2019-04-111-0/+1
| | | | | | | | | | | | When setting sync EIC as IRQ_TYPE_EDGE_BOTH type, we missed to set the SPRD_EIC_SYNC_INTMODE register to 0, which means detecting edge signals. Thus this patch fixes the issue. Fixes: 25518e024e3a ("gpio: Add Spreadtrum EIC driver support") Cc: <[email protected]> Signed-off-by: Baolin Wang <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* Merge tag 'gpio-v5.1-updates-for-linus' of ↵Linus Walleij2019-02-171-1/+13
|\ | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux into devel gpio updates for v5.1 - support for a new variant of pca953x - documentation fix from Wolfram - some tegra186 name changes - two minor fixes for madera and altera-a10sr
| * gpio: sprd: Fix incorrect irq type setting for the async EICNeo Hou2019-01-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | When setting async EIC as IRQ_TYPE_EDGE_BOTH type, we missed to set the SPRD_EIC_ASYNC_INTMODE register to 0, which means detecting edge signals. Thus this patch fixes the issue. Fixes: 25518e024e3a ("gpio: Add Spreadtrum EIC driver support") Cc: <[email protected]> Signed-off-by: Neo Hou <[email protected]> Signed-off-by: Baolin Wang <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
| * gpio: sprd: Fix the incorrect data registerNeo Hou2019-01-231-1/+12
| | | | | | | | | | | | | | | | | | | | | | Since differnt type EICs have its own data register to read, thus fix the incorrect data register. Fixes: 25518e024e3a ("gpio: Add Spreadtrum EIC driver support") Cc: <[email protected]> Signed-off-by: Neo Hou <[email protected]> Signed-off-by: Baolin Wang <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
* | gpio: sprd: Add missing break in switch statementGustavo A. R. Silva2019-02-131-0/+1
|/ | | | | | | | | | | | | | | | | | | Fix the following warning by adding a missing break: drivers/gpio/gpio-eic-sprd.c: In function ‘sprd_eic_irq_set_type’: drivers/gpio/gpio-eic-sprd.c:403:3: warning: this statement may fall through [-Wimplicit-fallthrough=] switch (flow_type) { ^~~~~~ drivers/gpio/gpio-eic-sprd.c:435:2: note: here default: ^~~~~~~ This patch is part of the ongoing efforts to enable -Wimplicit-fallthrough. Signed-off-by: Gustavo A. R. Silva <[email protected]> Reviewed-by: Baolin Wang <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* gpio: eic: Add edge trigger emulation for EICBaolin Wang2018-05-161-0/+73
| | | | | | | | | | The Spreadtrum debounce EIC and latch EIC can not support edge trigger, but most GPIO users (like gpio-key driver) only use the edge trigger, thus the EIC driver need add some support to emulate the edge trigger to satisfy this requirement. Signed-off-by: Baolin Wang <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
* gpio: Add Spreadtrum EIC driver supportBaolin Wang2018-03-271-0/+606
The Spreadtrum digital-chip EIC controller has 4 sub-modules: debounce EIC, latch EIC, async EIC and sync EIC, and each sub-module can has multiple banks and each bank contains 8 EICs. Each EIC can only be used as input mode, and has the capability to trigger interrupts when detecting input signals. Signed-off-by: Baolin Wang <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Linus Walleij <[email protected]>