summaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpio-max77620.c
AgeCommit message (Collapse)AuthorFilesLines
2022-05-05gpio: max77620: Make the irqchip immutableJon Hunter1-3/+6
Commit 6c846d026d49 ("gpio: Don't fiddle with irqchips marked as immutable") added a warning to indicate if the gpiolib is altering the internals of irqchips. Following this change the following warning is now observed for the max77620 gpio driver ... WARNING KERN gpio gpiochip0: (max77620-gpio): not an immutable chip, please consider fixing it! Fix the above warning by making the max77620 gpio driver immutable. Signed-off-by: Jon Hunter <jonathanh@nvidia.com> Reviewed-by: Marc Zyngier <maz@kernel.org> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
2021-09-22gpio: max77620: drop unneeded MODULE_ALIASKrzysztof Kozlowski1-1/+0
The MODULE_DEVICE_TABLE already creates proper alias for platform driver. Having another MODULE_ALIAS causes the alias to be duplicated. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
2021-02-15gpio: max77620: convert comma to semicolonZheng Yongjun1-1/+1
Replace a comma between expression statements by a semicolon. Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2020-07-17gpio: max77620: Use helper variable and clarifyLinus Walleij1-5/+11
Most other drivers fill out the gpio_irq_chip using a struct gpio_irq_chip *girq helper variable for ease of reading. We also make a habit of explicitly assigning NULL and zero to the parent IRQs when using ordinary IRQ handlers in the driver, mostly for code readability and maintenance. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Dmitry Osipenko <digetx@gmail.com> Cc: Dmitry Osipenko <digetx@gmail.com> Link: https://lore.kernel.org/r/20200716092835.69176-1-linus.walleij@linaro.org
2020-07-16gpio: max77620: Initialize hardware state of interruptsDmitry Osipenko1-0/+25
I noticed on Nexus 7 that after rebooting from downstream kernel to upstream, the GPIO interrupt is triggering non-stop despite interrupts being disabled for all of GPIOs. This happens because Nexus 7 uses a soft-reboot, meaning that bootloader should take care of resetting hardware, but the bootloader doesn't do it well. As a result, GPIO interrupt may be left ON at a boot time. Let's mask all GPIO interrupts at the driver's initialization time in order to resolve the issue. Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Acked-by: Laxman Dewangan <ldewangan@nvidia.com> Link: https://lore.kernel.org/r/20200709171203.12950-7-digetx@gmail.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-07-16gpio: max77620: Use irqchip templateDmitry Osipenko1-8/+6
This change addresses one of the GPIO-core TODOs for the MAX77620 driver which requires modern drivers to use the irqchip template. Instead of using the GPIO's irqchip-helpers for creating the IRQ domain, the gpio_irq_chip structure is now filled by the driver itself and then gpiochip_add_data() takes care of instantiating the IRQ domain for us. Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Acked-by: Laxman Dewangan <ldewangan@nvidia.com> Link: https://lore.kernel.org/r/20200709171203.12950-6-digetx@gmail.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-07-16gpio: max77620: Don't shadow error code of platform_get_irq()Dmitry Osipenko1-4/+6
The platform_get_irq() returns a positive interrupt number on success and negative error code on failure (zero shouldn't ever happen in practice, it would produce a noisy warning). Hence let's return the error code directly instead of overriding it with -ENODEV. Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Acked-by: Laxman Dewangan <ldewangan@nvidia.com> Link: https://lore.kernel.org/r/20200709171203.12950-5-digetx@gmail.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-07-16gpio: max77620: Don't set of_nodeDmitry Osipenko1-4/+1
The gpiochip_add_data() takes care of setting the of_node to the parent's device of_node, hence there is no need to do it manually in the driver's code. This patch corrects the parent's device pointer and removes the unnecessary setting of the of_node. Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Acked-by: Laxman Dewangan <ldewangan@nvidia.com> Link: https://lore.kernel.org/r/20200709171203.12950-4-digetx@gmail.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-07-16gpio: max77620: Fix missing release of interruptDmitry Osipenko1-2/+3
The requested interrupt is never released by the driver. Fix this by using the resource-managed variant of request_threaded_irq(). Fixes: ab3dd9cc24d4 ("gpio: max77620: Fix interrupt handling") Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Acked-by: Laxman Dewangan <ldewangan@nvidia.com> Cc: <stable@vger.kernel.org> # 5.5+ Link: https://lore.kernel.org/r/20200709171203.12950-3-digetx@gmail.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-07-16gpio: max77620: Replace 8 with MAX77620_GPIO_NRDmitry Osipenko1-3/+3
The MAX77620_GPIO_NR enum value represents the total number of GPIOs, let's use it instead of a raw value in order to improve the code's readability a tad. Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Acked-by: Laxman Dewangan <ldewangan@nvidia.com> Link: https://lore.kernel.org/r/20200709171203.12950-2-digetx@gmail.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2019-12-01Merge tag 'gpio-v5.5-1' of ↵Linus Torvalds1-114/+117
git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio Pull GPIO updates from Linus Walleij: "This is the bulk of GPIO changes for the v5.5 kernel cycle Core changes: - Expose pull up/down flags for the GPIO character device to userspace. After clear input from the RaspberryPi and Beagle communities, it has been established that prototyping, industrial automation and make communities strongly need this feature, and as we want people to use the character device, we have implemented the simple pull up/down interface for GPIO lines. This means we can specify that a (chip-specific) pull up/down resistor can be enabled, but does not offer fine-grained control such as cases where the resistance of the same pull resistor can be controlled (yet). - Introduce devm_fwnode_gpiod_get_index() and start to phase out the old symbol devm_fwnode_get_index_gpiod_from_child(). - A bit of documentation clean-up work. - Introduce a define for GPIO line directions and deploy it in all GPIO drivers in the drivers/gpio directory. - Add a special callback to populate pin ranges when cooperating with the pin control subsystem and registering ranges as part of adding a gpiolib driver and a gpio_irq_chip driver at the same time. This is also deployed in the Intel Merrifield driver. New drivers: - RDA Micro GPIO controller. - XGS-iproc GPIO driver. Driver improvements: - Wake event and debounce support on the Tegra 186 driver. - Finalize the Aspeed SGPIO driver. - MPC8xxx uses a normal IRQ handler rather than a chained handler" * tag 'gpio-v5.5-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: (64 commits) gpio: Add TODO item for regmap helper Documentation: gpio: driver.rst: Fix warnings gpio: of: Fix bogus reference to gpiod_get_count() gpiolib: Grammar s/manager/managed/ gpio: lynxpoint: Setup correct IRQ handlers MAINTAINERS: Replace my email by one @kernel.org gpiolib: acpi: Make acpi_gpiochip_alloc_event always return AE_OK gpio/mpc8xxx: fix qoriq GPIO reading gpio: mpc8xxx: Don't overwrite default irq_set_type callback gpiolib: acpi: Print pin number on acpi_gpiochip_alloc_event errors gpiolib: fix coding style in gpiod_hog() drm/bridge: ti-tfp410: switch to using fwnode_gpiod_get_index() gpio: merrifield: Pass irqchip when adding gpiochip gpio: merrifield: Add GPIO <-> pin mapping ranges via callback gpiolib: Introduce ->add_pin_ranges() callback gpio: mmio: remove untrue leftover comment gpio: em: Use platform_get_irq() to obtain interrupts gpio: tegra186: Add debounce support gpio: tegra186: Program interrupt route mapping gpio: tegra186: Derive register offsets from bank/port ...
2019-11-12gpio: max77620: Fixup debounce delaysThierry Reding1-3/+3
When converting milliseconds to microseconds in commit fffa6af94894 ("gpio: max77620: Use correct unit for debounce times") some ~1 ms gaps were introduced between the various ranges supported by the controller. Fix this by changing the start of each range to the value immediately following the end of the previous range. This way a debounce time of, say 8250 us will translate into 16 ms instead of returning an -EINVAL error. Typically the debounce delay is only ever set through device tree and specified in milliseconds, so we can never really hit this issue because debounce times are always a multiple of 1000 us. The only notable exception for this is drivers/mmc/host/mmc-spi.c where the CD GPIO is requested, which passes a 1 us debounce time. According to a comment preceeding that code this should actually be 1 ms (i.e. 1000 us). Reported-by: Pavel Machek <pavel@denx.de> Signed-off-by: Thierry Reding <treding@nvidia.com> Acked-by: Pavel Machek <pavel@denx.de> Cc: <stable@vger.kernel.org> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2019-11-05Merge tag 'v5.4-rc6' into develLinus Walleij1-3/+3
Linux 5.4-rc6
2019-10-05gpio: max77620: Fix interrupt handlingTimo Alho1-114/+117
The interrupt-related register fields on the MAX77620 GPIO controller share registers with GPIO related fields. If the IRQ chip is implemented with regmap-irq, this causes the IRQ controller code to overwrite fields previously configured by the GPIO controller code. Two examples where this causes problems are the NVIDIA Jetson TX1 and Jetson TX2 boards, where some of the GPIOs are used to enable vital power regulators. The MAX77620 GPIO controller also provides the USB OTG ID pin. If configured as an interrupt, this causes some of the regulators to be powered off. Signed-off-by: Timo Alho <talho@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com> Link: https://lore.kernel.org/r/20191002122825.3948322-3-thierry.reding@gmail.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2019-10-04gpio: max77620: Do not allocate IRQs upfrontThierry Reding1-1/+1
regmap_add_irq_chip() will try to allocate all of the IRQ descriptors upfront if passed a non-zero irq_base parameter. However, the intention is to allocate IRQ descriptors on an as-needed basis if possible. Pass 0 instead of -1 to fix that use-case. Signed-off-by: Thierry Reding <treding@nvidia.com> Link: https://lore.kernel.org/r/20191002122825.3948322-2-thierry.reding@gmail.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2019-10-04gpio: max77620: Use correct unit for debounce timesThierry Reding1-3/+3
The gpiod_set_debounce() function takes the debounce time in microseconds. Adjust the switch/case values in the MAX77620 GPIO to use the correct unit. Signed-off-by: Thierry Reding <treding@nvidia.com> Link: https://lore.kernel.org/r/20191002122825.3948322-1-thierry.reding@gmail.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2019-08-05gpio: Remove dev_err() usage after platform_get_irq()Stephen Boyd1-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: linux-gpio@vger.kernel.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Stephen Boyd <swboyd@chromium.org> Link: https://lore.kernel.org/r/20190730181557.90391-16-swboyd@chromium.org Acked-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2019-06-05treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 422Thomas Gleixner1-4/+1
Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms and conditions of the gnu general public license version 2 as published by the free software foundation extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 101 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190531190113.822954939@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-19regmap: regmap-irq/gpio-max77620: add level-irq supportMatti Vaittinen1-32/+64
Add level active IRQ support to regmap-irq irqchip. Change breaks existing regmap-irq type setting. Convert the existing drivers which use regmap-irq with trigger type setting (gpio-max77620) to work with this new approach. So we do not magically support level-active IRQs on gpio-max77620 - but add support to the regmap-irq for chips which support them =) We do not support distinguishing situation where HW supports rising and falling edge detection but not both. Separating this would require inventing yet another flags for IRQ types. Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-14gpio: max77620: Make regmap_irq_chip constBhumika Goyal1-1/+1
Make the structure const as it is only passed to the function devm_regmap_add_irq_chip having the corresponding argument as const. Done using Coccinelle. Signed-off-by: Bhumika Goyal <bhumirks@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2017-01-26pinctrl / gpio: Introduce .set_config() callback for GPIO chipsMika Westerberg1-10/+10
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>
2016-11-16gpio: max77620: add compatible string to device id listVenkat Reddy Talla1-0/+1
Adding max20024 compatible string to the device id list to support both max77620 and max20024 devices. Signed-off-by: Venkat Reddy Talla <vreddytalla@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2016-10-24gpio: max77620: Remove unused fields from struct max77620_gpioAxel Lin1-8/+2
Current code does not use gpio_irq/irq_base/gpio_base fields from struct max77620_gpio, so remove them. Signed-off-by: Axel Lin <axel.lin@ingics.com> Acked-by: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2016-07-04gpio: max77620: get gpio value based on directionVenkat Reddy Talla1-1/+4
Gpio direction is determined by DIRx bit of GPIO configuration register, return max77620 gpio value based on direction in or out. Signed-off-by: Venkat Reddy Talla <vreddytalla@nvidia.com> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2016-06-07gpio: max77620: use the new open drain callbackLaxman Dewangan1-0/+23
The MAX77620 have a GPIO pins which can act as open drain or push pull mode. Implement support for controlling this from GPIO descriptor tables or other hardware descriptions such as device tree by implementing the .set_single_ended() callback. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2016-06-07gpio: max77620: Configure interrupt trigger levelLaxman Dewangan1-8/+59
The GPIO sub modules of MAX77620 offers to configure the GPIO interrupt trigger level as RISING and FALLING edge. Pass this information to regmap-irg when registering for GPIO interrupts. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2016-06-07gpio: max77620: add gpio driver for MAX77620/MAX20024Laxman Dewangan1-0/+238
MAXIM Semiconductor's PMIC, MAX77620/MAX20024 has 8 GPIO pins. It also supports interrupts from these pins. Add GPIO driver for these pins to control via GPIO APIs. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>