History log of /linux-master/drivers/gpio/gpio-mxc.c
Revision Date Author Comments
# 9e0fa5d8 18-Aug-2023 Li Zetao <lizetao1@huawei.com>

gpio: mxc: Use helper function devm_clk_get_optional_enabled()

Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for
prepared and enabled clocks"), devm_clk_get_optional() and
clk_prepare_enable() can now be replaced by
devm_clk_get_optional_enabled() when the driver enables (and possibly
prepares) the clocks for the whole lifetime of the device. Moreover,
it is no longer necessary to unprepare and disable the clocks explicitly.

Signed-off-by: Li Zetao <lizetao1@huawei.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


# 5f6d1998 09-Aug-2023 Shenwei Wang <shenwei.wang@nxp.com>

gpio: mxc: release the parent IRQ in runtime suspend

Release the parent interrupt request during runtime suspend, allowing
the parent interrupt controller to enter runtime suspend if there are
no active users.

This change may not have a visible impact if the parent controller is
the GIC, but it can enable significant power savings for parent IRQ
controllers like IRQSteer inside a subsystem on i.MX8 SoCs. Releasing
the parent IRQ provides an opportunity for the subsystem to enter suspend
states if there are no active users.

Signed-off-by: Shenwei Wang <shenwei.wang@nxp.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


# 6a270bbd 11-Jul-2023 Geert Uytterhoeven <geert+renesas@glider.be>

gpio: mxc: Improve PM configuration

If CONFIG_PM=n (e.g. m68k/allmodconfig):

drivers/gpio/gpio-mxc.c:612:12: error: ‘mxc_gpio_runtime_resume’ defined but not used [-Werror=unused-function]
612 | static int mxc_gpio_runtime_resume(struct device *dev)
| ^~~~~~~~~~~~~~~~~~~~~~~
drivers/gpio/gpio-mxc.c:602:12: error: ‘mxc_gpio_runtime_suspend’ defined but not used [-Werror=unused-function]
602 | static int mxc_gpio_runtime_suspend(struct device *dev)
| ^~~~~~~~~~~~~~~~~~~~~~~~

Fix this by using the non-SET *_PM_OPS to configure the dev_pm_ops
callbacks, and by wrapping the driver.pm initializer insider pm_ptr().

As NOIRQ_SYSTEM_SLEEP_PM_OPS() uses pm_sleep_ptr() internally, the
__maybe_unused annotations for the noirq callbacks are no longer needed,
and can be removed.

Fixes: 3283d820dce649ad ("gpio: mxc: add runtime pm support")
Reported-by: noreply@ellerman.id.au
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


# e91d0f05 14-Jul-2023 Rob Herring <robh@kernel.org>

gpio: Explicitly include correct DT includes

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 <robh@kernel.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Romain Perier <romain.perier@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


# 3283d820 06-Jul-2023 Shenwei Wang <shenwei.wang@nxp.com>

gpio: mxc: add runtime pm support

Add runtime PM support and allow the GPIO controller to enter
into runtime suspend automatically when not in use to save power.
However, it will automatically resume and enable clocks when a
GPIO or IRQ is requested.

While putting the GPIO module itself into power saving mode may not
have an obvious impact on current dissipation, the function is necessary
because the GPIO module disables its clock when idle. This enables the
system an opportunity to power off the parent subsystem, and this conserves
more power. The typical i.MX8 SoC features up to 8 GPIO controllers, but
most of the controllers often remain unused.

Signed-off-by: Shenwei Wang <shenwei.wang@nxp.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


# 37870358 24-Jan-2023 Dan Carpenter <error27@gmail.com>

gpio: mxc: Unlock on error path in mxc_flip_edge()

We recently added locking to this function but one error path was
over looked. Drop the lock before returning.

Fixes: e5464277625c ("gpio: mxc: Protect GPIO irqchip RMW with bgpio spinlock")
Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: Marek Vasut <marex@denx.de>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


# 8e88a0fe 16-Jan-2023 Marek Vasut <marex@denx.de>

gpio: mxc: Always set GPIOs used as interrupt source to INPUT mode

Always configure GPIO pins which are used as interrupt source as INPUTs.
In case the default pin configuration is OUTPUT, or the prior stage does
configure the pins as OUTPUT, then Linux will not reconfigure the pin as
INPUT and no interrupts are received.

Always configure the interrupt source GPIO pin as input to fix the above case.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Fixes: 07bd1a6cc7cbb ("MXC arch: Add gpio support for the whole platform")
Signed-off-by: Marek Vasut <marex@denx.de>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


# e5464277 16-Jan-2023 Marek Vasut <marex@denx.de>

gpio: mxc: Protect GPIO irqchip RMW with bgpio spinlock

The driver currently performs register read-modify-write without locking
in its irqchip part, this could lead to a race condition when configuring
interrupt mode setting. Add the missing bgpio spinlock lock/unlock around
the register read-modify-write.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Marc Zyngier <maz@kernel.org>
Fixes: 07bd1a6cc7cbb ("MXC arch: Add gpio support for the whole platform")
Signed-off-by: Marek Vasut <marex@denx.de>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


# f60c9eac 27-Oct-2022 Shenwei Wang <shenwei.wang@nxp.com>

gpio: mxc: enable pad wakeup on i.MX8x platforms

On i.MX8QM/QXP/DXL SoCs, even a GPIO is selected as the wakeup source,
the GPIO block will be powered off when system enters into suspend
state. This can greatly reduce the power consumption of suspend state
because the whole partition can be shutdown. This is called PAD wakeup
feature on i.MX8x platform.

This patch adds the noirq suspend/resume hooks and uses the pad wakeup
feature as the default wakeup method for GPIO modules on
i.MX8QM/QXP/DXL platforms.

Signed-off-by: Shenwei Wang <shenwei.wang@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Acked-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Link: https://lore.kernel.org/r/20221027130859.1444412-6-shenwei.wang@nxp.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# dbd1c54f 04-May-2021 Marc Zyngier <maz@kernel.org>

gpio: Bulk conversion to generic_handle_domain_irq()

Wherever possible, replace constructs that match either
generic_handle_irq(irq_find_mapping()) or
generic_handle_irq(irq_linear_revmap()) to a single call to
generic_handle_domain_irq().

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>


# 3093e6cc 17-Jun-2021 Loic Poulain <loic.poulain@linaro.org>

gpio: mxc: Fix disabled interrupt wake-up support

A disabled/masked interrupt marked as wakeup source must be re-enable
and unmasked in order to be able to wake-up the host. That can be done
by flaging the irqchip with IRQCHIP_ENABLE_WAKEUP_ON_SUSPEND.

Note: It 'sometimes' works without that change, but only thanks to the
lazy generic interrupt disabling (keeping interrupt unmasked).

Reported-by: Michal Koziel <michal.koziel@emlogic.no>
Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>


# 0f2c7af4 17-Nov-2020 Fabio Estevam <festevam@gmail.com>

gpio: mxc: Convert the driver to DT-only

Since 5.10-rc1 i.MX is a devicetree-only platform, so simplify the code
by removing the unused non-DT support.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20201117105917.27591-1-festevam@gmail.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 12d16b39 16-Sep-2020 Anson Huang <Anson.Huang@nxp.com>

gpio: mxc: Support module build

Change config to tristate, add module device table, module author,
description and license to support module build for i.MX GPIO driver.

As this is a SoC GPIO module, it provides common functions for most
of the peripheral devices, such as GPIO pins control, secondary
interrupt controller for GPIO pins IRQ etc., without GPIO driver, most
of the peripheral devices will NOT work properly, so GPIO module is
similar with clock, pinctrl driver that should be loaded ONCE and
never unloaded.

Since MXC GPIO driver needs to have init function to register syscore
ops once, here still use subsys_initcall(), NOT module_platform_driver().

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Link: https://lore.kernel.org/r/1600320829-1453-1-git-send-email-Anson.Huang@nxp.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# f0254b51 01-Apr-2020 Thierry Reding <treding@nvidia.com>

gpio: Unconditionally assign .request()/.free()

The gpiochip_generic_request() and gpiochip_generic_free() functions can
now deal properly with chips that don't have any pin-ranges defined, so
they can be assigned unconditionally.

Suggested-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Link: https://lore.kernel.org/r/20200401200527.2982450-1-thierry.reding@gmail.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# c8f3d144 19-Sep-2019 Anson Huang <Anson.Huang@nxp.com>

gpio: mxc: Only get the second IRQ when there is more than one IRQ

On some of i.MX SoCs like i.MX8QXP, there is ONLY one IRQ for each
GPIO bank, so it is better to check the IRQ count before getting
second IRQ to avoid below error message during probe:

[ 1.070908] gpio-mxc 5d080000.gpio: IRQ index 1 not found
[ 1.077420] gpio-mxc 5d090000.gpio: IRQ index 1 not found
[ 1.083766] gpio-mxc 5d0a0000.gpio: IRQ index 1 not found
[ 1.090122] gpio-mxc 5d0b0000.gpio: IRQ index 1 not found
[ 1.096470] gpio-mxc 5d0c0000.gpio: IRQ index 1 not found
[ 1.102804] gpio-mxc 5d0d0000.gpio: IRQ index 1 not found
[ 1.109144] gpio-mxc 5d0e0000.gpio: IRQ index 1 not found
[ 1.115475] gpio-mxc 5d0f0000.gpio: IRQ index 1 not found

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>


# 7beb620f 01-Aug-2019 Anson Huang <Anson.Huang@nxp.com>

gpio: mxc: Use devm_clk_get_optional instead of devm_clk_get

i.MX SoC's GPIO clock is optional, so it is better to use
devm_clk_get_optional instead of devm_clk_get.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>


# 123ac0e5 11-Mar-2019 Enrico Weigelt, metux IT consult <info@metux.net>

drivers: gpio: mxc: use devm_platform_ioremap_resource()

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 <info@metux.net>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 43c691e6 31-Mar-2019 Anson Huang <anson.huang@nxp.com>

gpio: mxc: use devm_platform_ioremap_resource() to simplify code

Use the new helper devm_platform_ioremap_resource() which wraps the
platform_get_resource() and devm_ioremap_resource() together, to
simplify the code.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>


# a329bbe7 22-Feb-2019 Anson Huang <anson.huang@nxp.com>

gpio: mxc: add check to return defer probe if clock tree NOT ready

On i.MX8MQ platform, clock driver uses platform driver
model and it is probed after GPIO driver, so when GPIO
driver fails to get clock, it should check the error type
to decide whether to return defer probe or just ignore
the clock operation.

Fixes: 2808801aab8a ("gpio: mxc: add clock operation")
Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 1a5287a3 08-Nov-2018 Anson Huang <anson.huang@nxp.com>

gpio: mxc: move gpio noirq suspend/resume to syscore phase

During noirq suspend/resume phase, GPIO irq could arrive
and its registers like IMR will be changed by irq handle
process, to make the GPIO registers exactly when it is
powered ON after resume, move the GPIO noirq suspend/resume
callback to syscore suspend/resume phase, local irq is
disabled at this phase so GPIO registers are atomic.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 11868645 21-Oct-2018 Wolfram Sang <wsa+renesas@sang-engineering.com>

gpio: gpio-mxc: simplify getting .driver_data

We should get 'driver_data' from 'struct device' directly. Going via
platform_device is an unneeded step back and forth.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# c19fdaee 17-Jul-2018 Anson Huang <Anson.Huang@nxp.com>

gpio: mxc: add power management support

GPIO registers could lose context on i.MX7D, when
enter LPSR mode, the whole SoC will be powered off
except LPSR domain, GPIO banks will lose context
in this case, need to restore the context after
resume from LPSR mode.

This patch adds new compatible string for i.MX7D
which supports GPIO power off feature in suspend,
and adds the GPIO save/restore operations in noirq
suspend/resume phase, since GPIO is fundamental
module which could be used by other peripherals'
resume phase.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 014e420d 21-May-2018 Fabio Estevam <fabio.estevam@nxp.com>

gpio: mxc: Switch to SPDX identifier

Adopt the SPDX license identifier headers to ease license compliance
management.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 2808801a 21-May-2018 Anson Huang <Anson.Huang@nxp.com>

gpio: mxc: add clock operation

Some i.MX SoCs have GPIO clock gates in CCM CCGR, such as
i.MX6SLL, need to enable clocks before accessing GPIO
registers, add optional clock operation for GPIO driver.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 8d0bd9a5 15-Apr-2018 Linus Walleij <linus.walleij@linaro.org>

gpio: mxc: Remove reliance on <linux/gpio.h>

This is a driver so we should only include <linux/gpio/driver.h>.
However this driver was using gpio_get_value() to fetch the
current value of a GPIO used as IRQ line to determine trigger
direction, so we need a better way than looping over the
global GPIO numberspace.

Fix this by just calling the .get() function in the GPIO chip,
as we don't want to end up creating a consumer dependency
on ourselves.

Cc: Vladimir Zapolskiy <vz@mleia.com>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Acked-by: Shawn Guo <shawnguo@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# db5270ac 09-Aug-2017 Bartosz Golaszewski <brgl@bgdev.pl>

gpio: mxc: use devres for irq generic chip

Use resource managed variants of irq_alloc_generic_chip() and
irq_setup_generic_chip().

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 90e1fc4c 09-Aug-2017 Bartosz Golaszewski <brgl@bgdev.pl>

gpio: mxc: disallow unbinding the driver

This driver is non-modular so explicitly disallow a driver unbind.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 77a4d757 12-Jul-2017 Philipp Rosenberger <p.rosenberger@linutronix.de>

gpio: gpio-mxc: gpio_set_wake_irq() use proper return values

Errors from enable_irq_wake() in gpio_set_wake_irq() were silently ignored.
Thus led to the problem that gpio_set_wake_irq() always returned
successfully, even if enable_irq_wake() returned an error.

Signed-off-by: Philipp Rosenberger <p.rosenberger@linutronix.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# cc9269f8 12-Jul-2017 Philipp Rosenberger <p.rosenberger@linutronix.de>

gpio: gpio-mxc: Fix: higher 16 GPIOs usable as wake source

In the function gpio_set_wake_irq(), port->irq_high is only checked for
zero. As platform_get_irq() returns a value less then zero if no interrupt
was found, any gpio >= 16 was handled like an irq_high interrupt was
available. On iMX27 for example no high interrupt is available. This lead
to the problem that only some gpios (the lower 16) were useable as wake
sources.

Signed-off-by: Philipp Rosenberger <p.rosenberger@linutronix.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# c553c3c4 04-Mar-2017 Bartosz Golaszewski <bgolaszewski@baylibre.com>

gpio: mxc: use devm_irq_alloc_descs()

This driver never frees the interrupt descriptors it allocates. Fix
it by using the resource managed version of irq_alloc_descs().

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 4c806c98 07-Sep-2016 Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>

gpio: mxc: add generic gpio request/free callbacks to pinctrl

If a GPIO controller description in board DTB contains information
about mappings between GPIOs and pads under IOMUX control use it to
request and free GPIOs with respect to pinctrl/pinmux subsystems.

One of immediate positive functional changes is inability to
request non-existing GPIOs, i.e. if there is no pad such. Also
pinctrl/pinmux may now properly account pads occupied by requested
GPIOs.

The change has no effect, if "gpio-ranges" property is not found
including the case if a board has no DTB firmware.

Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Acked-by: Shawn Guo <shawnguo@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# e188cbf7 07-Sep-2016 Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>

gpio: mxc: shift gpio_mxc_init() to subsys_initcall level

In general situation on-SoC GPIO controller drivers should be probed
after pinctrl/pinmux controller driver, because on-SoC GPIOs utilize a
pin/pad as a resource provided and controlled by pinctrl subsystem.

This is stated in multiple places, e.g. from drivers/Makefile:

GPIO must come after pinctrl as gpios may need to mux pins etc

Looking at Freescale iMX SoC series specifics, imx*_pinctrl_init()
functions are called at arch_initcall and postcore_initcall init
levels, so the change of initcall level for gpio-mxc driver from
postcore_initcall to subsys_initcall level is sufficient. Also note
that the most of GPIO controller drivers settled at subsys_initcall
level.

If pinctrl subsystem manages pads with GPIO functions, the change is
needed to avoid unwanted driver probe deferrals during kernel boot.

Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Acked-by: Shawn Guo <shawnguo@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 2c8d6c86 21-Aug-2016 Paul Gortmaker <paul.gortmaker@windriver.com>

gpio: mxc: drop unused MODULE_ tags from non-modular code

The Kconfig currently controlling compilation of this code is:

drivers/gpio/Kconfig:config GPIO_MXC
drivers/gpio/Kconfig: def_bool y

...meaning that it currently is not being built as a module by anyone.

Lets remove the couple traces of modular infrastructure use, so that
when reading the driver there is no doubt it is builtin-only.

We delete the MODULE_LICENSE tag etc. since all that information
was (or is now) contained at the top of the file in the comments.
Note the original e-mail had a missing/typo'd @ symbol anyway.

We don't replace module.h with init.h since the file already has that.

Cc: Alexandre Courbot <gnurou@gmail.com>
Cc: Daniel Mack <daniel@caiaq.de>
Cc: Juergen Beisert <kernel@pengutronix.de>
Cc: linux-gpio@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# ffc56630 22-Feb-2016 Laxman Dewangan <ldewangan@nvidia.com>

gpio: mxc: Use devm_gpiochip_add_data() for gpio registration

Use devm_gpiochip_add_data() for GPIO registration and clean the
error path.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>


# 0f4630f3 04-Dec-2015 Linus Walleij <linus.walleij@linaro.org>

gpio: generic: factor into gpio_chip struct

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: arm@kernel.org
Cc: Alexander Shiyan <shc_work@mail.ru>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <kernel@pengutronix.de>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: Alexandre Courbot <gnurou@gmail.com>
Cc: Brian Norris <computersforpeace@gmail.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Sudeep Holla <sudeep.holla@arm.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Nicolas Pitre <nicolas.pitre@linaro.org>
Cc: Olof Johansson <olof@lixom.net>
Cc: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Cc: Rabin Vincent <rabin@rab.in>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-omap@vger.kernel.org
Cc: linux-samsung-soc@vger.kernel.org
Cc: bcm-kernel-feedback-list@broadcom.com
Acked-by: Gregory Fong <gregory.0xf0@gmail.com>
Acked-by: Liviu Dudau <Liviu.Dudau@arm.com>
Acked-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Acked-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 16c3bd35 28-Aug-2015 Christoph Hellwig <hch@lst.de>

gpio-mxc: stop including <asm-generic/bug>

<asm-generic/bug> contains the default implementation of BUG() and friends,
which architectures may decide to use. The proper way to get them is
<linux/bug.h>, so use that.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>


# bd0b9ac4 14-Sep-2015 Thomas Gleixner <tglx@linutronix.de>

genirq: Remove irq argument from irq flow handlers

Most interrupt flow handlers do not use the irq argument. Those few
which use it can retrieve the irq number from the irq descriptor.

Remove the argument.

Search and replace was done with coccinelle and some extra helper
scripts around it. Thanks to Julia for her help!

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: Jiang Liu <jiang.liu@linux.intel.com>


# 9e26b0b1 23-Aug-2015 Peng Fan <van.freenix@gmail.com>

gpio: mxc: need to check return value of irq_alloc_generic_chip

Need to check return value of irq_alloc_generic_chip, because
it may return NULL.
1. Change mxc_gpio_init_gc return type from void to int.
2. Add a new lable out_irqdomain_remove to remove the irq domain
when mxc_gpio_init_gc fail.

Signed-off-by: Peng Fan <van.freenix@gmail.com>
Cc: Alexandre Courbot <gnurou@gmail.com>
[Manually rebased]
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 929550b9 11-Aug-2015 Dirk Behme <dirk.behme@de.bosch.com>

gpio: mxc: fix section mismatch warning

Fix the section mismatch warning

WARNING: vmlinux.o(.text+0x2b2788): Section mismatch in reference from the function mxc_gpio_probe() to the function .init.text:mxc_gpio_init_gc()
The function mxc_gpio_probe() references
the function __init mxc_gpio_init_gc().
This is often because mxc_gpio_probe lacks a __init
annotation or the annotation of mxc_gpio_init_gc is wrong.

Signed-off-by: Dirk Behme <dirk.behme@de.bosch.com>
Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 952cfbd3 05-Aug-2015 Ulises Brindis <ubrindis56@gmail.com>

gpio/mxc: mask gpio interrupts in suspend

Currently in the FSL platform all GPIO interrupts in a bank are muxed
into two GPIO lines to the GPC interrupt controller. In each GPIO bank
GPIOs 0-15 are OR'ed into one GPC interrupt controller interrupt and 16-31
are OR'ed into another. With the current code, if any of the 0-15 or
16-31 interrupts are marked as wakeup capable, all interrupts belonging
to that sub-bank (either 0-15 or 16-31) will wake up the device. This is
because interrupts are only being masked at the interrupt controller
and not at the GPIO controller.

This patch allows masking of GPIO interrupts at the GPIO controller during
suspend if they have not been labeled wakeup capable. This patch uses
preexisting IRQCHIP_MASK_ON_SUSPEND flag while initializing the GPIO
interrupts to get the desired behavior.

Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Alexandre Courbot <gnurou@gmail.com>
Cc: linux-gpio@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
Signed-off-by: Ulises Brindis <ubrindis56@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 476f8b4c 03-Jun-2015 Jiang Liu <jiang.liu@linux.intel.com>

gpio: Use irq_desc_get_xxx() to avoid redundant lookup of irq_desc

Use irq_desc_get_xxx() to avoid redundant lookup of irq_desc while we
already have a pointer to corresponding irq_desc.

Preparatory patch for the removal of the 'irq' argument from irq flow
handlers.

Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Cc: Alexandre Courbot <gnurou@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>


# e65eea54 16-Jun-2015 Russell King <rmk+kernel@arm.linux.org.uk>

gpio: gpio-mxc: Fix race in installing chained IRQ handler

Fix a race where a pending interrupt could be received and the handler
called before the handler's data has been setup, by converting to
irq_set_chained_handler_and_data().

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: Alexandre Courbot <gnurou@gmail.com>
Cc: Hans Ulli Kroll <ulli.kroll@googlemail.com>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lkml.kernel.org/r/E1Z4z0C-0002SX-Lj@rmk-PC.arm.linux.org.uk
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>


# f4f79d40 01-May-2015 Krzysztof Kozlowski <krzk@kernel.org>

gpio: Constify platform_device_id

The platform_device_id is not modified by the driver and core uses it as
const.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski.k@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 442b2494 29-Apr-2015 Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>

gpio: mxc: read output value from GPIO_DR register

All supported iMX GPIO controllers store configured GPIO output value
in GPIO_DR data register, which is represented by GPIO generic reg_set.
Provide a BGPIOF_READ_OUTPUT_REG_SET flag to bgpio_init() to allow
correct getting of previously set output value.

Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 4a3a950e 20-Oct-2014 Wolfram Sang <wsa@kernel.org>

gpio: drop owner assignment from platform_drivers

A platform_driver does not need to set an owner, it will be populated by the
driver core.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# 9f5132ae 12-Jul-2014 abdoulaye berthe <berthe.ab@gmail.com>

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>


# 5ea80e49 21-Dec-2013 Sachin Kamat <sachin.kamat@linaro.org>

gpio: mxc: Do not hard code return value

Silences the following warning:
why not propagate 'port->irq' from platform_get_irq() instead of (-22)?

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# c0e811d9 18-Jul-2013 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

gpio/mxc: add chained_irq_enter/exit() to mx2_gpio_irq_handler

Similar to commit

0e44b6e (gpio/mxc: add chained_irq_enter/exit() to mx3_gpio_irq_handler())

. It doesn't seem to be critical to make the irqs work, but still it is
more correct.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 18f92b19 22-Jul-2013 Fabio Estevam <fabio.estevam@freescale.com>

gpio: gpio-mxc: Include "<linux/err.h>"

Commit 8cd73e4e (gpio: gpio-mxc: Use devm functions) causes the following build
error on imx_v4_v7_defconfig:

drivers/gpio/gpio-mxc.c:414:2: error: implicit declaration of function 'IS_ERR' [-Werror=implicit-function-declaration]
drivers/gpio/gpio-mxc.c:415:3: error: implicit declaration of function 'PTR_ERR' [-Werror=implicit-function-declaration]

Note: imx_v6_v7_defconfig does not give this build error, probably due to some
indirect header file inclusion.

Reported-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 8cd73e4e 08-Jul-2013 Fabio Estevam <fabio.estevam@freescale.com>

gpio: gpio-mxc: Use devm functions

By using devm functions we can get a simpler code.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# de88cbb7 18-Jan-2013 Catalin Marinas <catalin.marinas@arm.com>

arm: Move chained_irq_(enter|exit) to a generic file

These functions have been introduced by commit 10a8c383 (irq: introduce
entry and exit functions for chained handlers) in asm/mach/irq.h. This
patch moves them to linux/irqchip/chained_irq.h so that generic irqchip
drivers do not rely on architecture specific header files.

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Tested-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Rob Herring <rob.herring@calxeda.com>


# 3836309d 19-Nov-2012 Bill Pemberton <wfp5p@virginia.edu>

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>


# 7e6086d9 05-Aug-2012 Shawn Guo <shawn.guo@linaro.org>

gpio/mxc: specify gpio base for device tree probe

Currently, unlike the non-DT probe where the gpio base is specified
with pdev->id, the DT probe uses the base dynamically allocated by
gpio core, which uses a completely different numbering scheme. This
causes two issues to user space applications which access sysfs entry
/sys/class/gpio/gpioN.

* It breaks the compatibility with user space applications between
non-DT and DT kernels.

* It's not intuitive and sometimes hard for users to map the Linux
gpio number to the actual hardware pin.

Use alias to identify the gpio port/bank, and then the gpio base
can be specified with port id to solve above issues. If alias is not
defined in device tree, the base number dynamically allocated by gpio
core will be used.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Tested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# f6b0ca25 05-Aug-2012 Shawn Guo <shawn.guo@linaro.org>

gpio/mxc: remove redundant shadow variables initialization

With commit 3e11f7b (gpio/generic: initialize basic_mmio_gpio shadow
variables properly) in place, the shadow variables initialization is
being done in generic driver bgpio_init call.

Remove the redundant shadow variables initialization from gpio-mxc
driver.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Tested-by: Dirk Behme <dirk.behme@de.bosch.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# aeb27748 22-Jun-2012 Benoît Thébaudeau <benoit.thebaudeau@advansee.com>

gpio/mxc: use the edge_sel feature if available

Some mxc processors have an edge_sel feature, which allows the IRQ to be
triggered by any edge.

This patch makes use of this feature if available, which skips mxc_flip_edge().

Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Linus Walleij <linus.walleij@stericsson.com>
Acked-by: Sascha Hauer <kernel@pengutronix.de>
Cc: <linux-arm-kernel@lists.infradead.org>
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 33a4e985 06-Jun-2012 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

gpio/mxc: make irqs work for fsl,imx21-gpio devices

The chained handler was set for the platform device with id == 0.
When the gpio devices are instantiated by a device tree, all have id ==
-1 and so the handler was unset resulting in unusable gpio irqs on
i.MX21 and i.MX27 (when using oftree).

Acked-by: Shawn Guo <shawn.guo@linaro.org>
Cc: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 1ab7ef15 12-Jun-2012 Shawn Guo <shawn.guo@linaro.org>

gpio/mxc: move irq_domain_add_legacy call into gpio driver

Move irq_domain_add_legacy call from imx*-dt.c into gpio driver and
have the gpio driver adopt irqdomain support for both DT and non-DT
boot.

With all imx platform code converted from static gpio irq number
computation to use run-time gpio_to_irq call, we can now use
irq_alloc_descs and irqdomain support to dynamically get irq_base
and have the mapping between gpio and irq number available without
using virtual_irq_start and MXC_GPIO_IRQ_START.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Cc: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Dong Aisheng <dong.aisheng@linaro.org>


# 3e11f7b8 19-May-2012 Shawn Guo <shawn.guo@linaro.org>

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>


# bb207ef1 03-Jul-2011 Paul Gortmaker <paul.gortmaker@windriver.com>

drivers/gpio: Fix drivers who are implicit users of module.h

A pending cleanup will mean that module.h won't be implicitly
everywhere anymore. Make sure the modular drivers in gpio
are actually calling out for <module.h> explicitly in advance.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>


# 0e44b6ec 21-Sep-2011 Shawn Guo <shawn.guo@linaro.org>

gpio/mxc: add chained_irq_enter/exit() to mx3_gpio_irq_handler()

The mx3_gpio_irq_handler() is also called on imx6q which has GIC as
the primary interrupt controller. As GIC implements the fasteoi flow
control, we need to add chained_irq_enter/exit() to
mx3_gpio_irq_handler() for signaling EOI, otherwise system will hang
whenever there is a gpio irq triggered.

v2: use chained_irq_{enter,exit}()

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>


# a4395612 13-Aug-2011 Shawn Guo <shawn.guo@linaro.org>

gpio/mxc: move irq_to_gpio() into gpio-mxc driver

As irq_to_gpio() is only being used by gpio-mxc driver, it should be
moved from mach/gpio.h into gpio-mxc.c.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>


# 09ad8039 13-Aug-2011 Shawn Guo <shawn.guo@linaro.org>

gpio/mxc: add .to_irq for gpio chip

It adds .to_irq support for gpio chip, so that __gpio_to_irq in
gpiolib becomes usable.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>


# 591567a5 19-Jul-2011 Shawn Guo <shawn.guo@linaro.org>

gpio/mxc/mxs: fix build error introduced by the irq_gc_ack() renaming

The following commit renames irq_gc_ack() to irq_gc_ack_set_bit(),
and makes gpio-mxc and gpio-mxs fail to build.

659fb32d1b67476f4ade25e9ea0e2642a5b9c4b5
genirq: replace irq_gc_ack() with {set,clr}_bit variants (fwd)

The patch fixed a couple of typo of comma to semicolon.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>


# 8937cb60 06-Jul-2011 Shawn Guo <shawn.guo@linaro.org>

gpio/mxc: add device tree probe support

The patch adds device tree probe support for gpio-mxc driver.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>


# e7fc6ae7 06-Jul-2011 Shawn Guo <shawn.guo@linaro.org>

gpio/mxc: get rid of the uses of cpu_is_mx()

The patch removes all the uses of cpu_is_mx(). Instead, it utilizes
platform_device_id to distinguish the different gpio types, IMX1_GPIO
on i.mx1, IMX21_GPIO on i.mx21 and i.mx27, IMX31_GPIO on all other
i.mx SoCs.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>


# fb149218 07-Jul-2011 Lothar Waßmann <LW@KARO-electronics.de>

gpio/mxc: add missing initialization of basic_mmio_gpio shadow variables

The bgpio_init() function does not initialise the shadow register for
the GPIO direction register. Thus, when configuring the first GPIO with
gpio_set_direction() all other GPIOs of the same bank will be
configured as inputs. Since the bgpio layer cannot know whether the
register is readable, the initialisation should be done by the caller
of bgpio_init().

Also, the 'data' shadow variable that is used inside basic_mmio_gpio
to cache the current value of the GPIO_DR register is initialised from
the GPIO_PSR register within bgpio_init(). Thus when setting the
output value of a certain GPIO, the other GPIO outputs of the same
bank will be set or cleared depending on the pin state of the GPIO
inputs during bgpio_init().

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>


# 5523f86b 11-Jun-2011 Shawn Guo <shawn.guo@linaro.org>

gpio/mxc: fix a bug with gpio_get_value calling

When calling gpio_get_value, the gpio number other than bit offset
should be passed as the argument.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>


# e4ea9333 07-Jun-2011 Shawn Guo <shawn.guo@linaro.org>

gpio/mxc: convert gpio-mxc to use generic irq chip

The patch converts gpio-mxc driver to use generic irq chip.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>


# 2ce420da 05-Jun-2011 Shawn Guo <shawn.guo@linaro.org>

gpio/mxc: convert gpio-mxc to use basic_mmio_gpio library

The gpio-mxc controller complies with basic_mmio_gpio library. The
patch convert the driver to use the library.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>


# b78d8e59 05-Jun-2011 Shawn Guo <shawn.guo@linaro.org>

gpio/mxc: Change gpio-mxc into an upstanding gpio driver

The patch makes necessary changes on gpio-mxc as below to turn it
into an upstanding gpio driver.

* Add a list to save all mx2 ports references, so that
mx2_gpio_irq_handler can walk through all interrupt status
registers

* Use readl/writel to replace mach-specific accessors
__raw_readl/__raw_writel

* Change mxc_gpio_init into mxc_gpio_probe function

* Move "struct mxc_gpio_port" into gpio-mxc.c, as it needs not to
be public at all, and also make some other cleanup on
plat-mxc/include/mach/gpio.h at the same time

And the patch then migrates mach-imx and mach-mx5 to the updated
driver by adding corresponding platform devices.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Acked-by: Olof Johansson <olof@lixom.net>
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>


# d37a65bb 05-Jun-2011 Shawn Guo <shawn.guo@linaro.org>

gpio/mxc: Move Freescale MXC gpio driver to drivers/gpio

GPIO drivers are getting moved to drivers/gpio for cleanup and
consolidation. This patch moves the plat-mxc driver. Follow up
patches will clean it up and make it a fine upstanding gpio driver.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>