Commit 966942ae authored by Théo Lebrun's avatar Théo Lebrun Committed by Linus Walleij

gpio: nomadik: extract GPIO platform driver from drivers/pinctrl/nomadik/

Previously, drivers/pinctrl/nomadik/pinctrl-nomadik.c registered two
platform drivers: pinctrl & GPIO. Move the GPIO aspect to the
drivers/gpio/ folder, as would be expected.

Both drivers are intertwined for a reason; pinctrl requires access to
GPIO registers for pinmuxing, pull-disable, disabling interrupts while
setting the muxing and wakeup control. Information sharing is done
through a shared array containing GPIO chips and a few helper
functions. That shared array is not touched from gpio-nomadik when
CONFIG_PINCTRL_NOMADIK is not defined.

Make no change to the code that moved into gpio-nomadik; there should be
no behavior change following. A few functions are shared and header
comments are added. Checkpatch warnings are addressed. NUM_BANKS is
renamed to NMK_MAX_BANKS.

It is supported to compile gpio-nomadik without pinctrl-nomadik. The
opposite is not true.
Signed-off-by: default avatarThéo Lebrun <theo.lebrun@bootlin.com>
Link: https://lore.kernel.org/r/20240228-mbly-gpio-v2-6-3ba757474006@bootlin.comSigned-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 53cf6b72
...@@ -2474,6 +2474,7 @@ F: drivers/clk/clk-nomadik.c ...@@ -2474,6 +2474,7 @@ F: drivers/clk/clk-nomadik.c
F: drivers/clocksource/clksrc-dbx500-prcmu.c F: drivers/clocksource/clksrc-dbx500-prcmu.c
F: drivers/dma/ste_dma40* F: drivers/dma/ste_dma40*
F: drivers/pmdomain/st/ste-ux500-pm-domain.c F: drivers/pmdomain/st/ste-ux500-pm-domain.c
F: drivers/gpio/gpio-nomadik.c
F: drivers/hwspinlock/u8500_hsem.c F: drivers/hwspinlock/u8500_hsem.c
F: drivers/i2c/busses/i2c-nomadik.c F: drivers/i2c/busses/i2c-nomadik.c
F: drivers/iio/adc/ab8500-gpadc.c F: drivers/iio/adc/ab8500-gpadc.c
......
...@@ -478,6 +478,18 @@ config GPIO_MXS ...@@ -478,6 +478,18 @@ config GPIO_MXS
select GPIO_GENERIC select GPIO_GENERIC
select GENERIC_IRQ_CHIP select GENERIC_IRQ_CHIP
config GPIO_NOMADIK
bool "Nomadik GPIO driver"
depends on ARCH_U8500 || ARCH_NOMADIK || COMPILE_TEST
select OF_GPIO
select GPIOLIB_IRQCHIP
help
Say yes here to support the Nomadik SoC GPIO block.
It handles up to 32 GPIOs per bank, that can all be interrupt sources.
It is deeply interconnected with the associated pinctrl driver as GPIO
registers handle muxing ("alternate functions") as well.
config GPIO_NPCM_SGPIO config GPIO_NPCM_SGPIO
bool "Nuvoton SGPIO support" bool "Nuvoton SGPIO support"
depends on ARCH_NPCM || COMPILE_TEST depends on ARCH_NPCM || COMPILE_TEST
......
...@@ -116,6 +116,7 @@ obj-$(CONFIG_GPIO_MT7621) += gpio-mt7621.o ...@@ -116,6 +116,7 @@ obj-$(CONFIG_GPIO_MT7621) += gpio-mt7621.o
obj-$(CONFIG_GPIO_MVEBU) += gpio-mvebu.o obj-$(CONFIG_GPIO_MVEBU) += gpio-mvebu.o
obj-$(CONFIG_GPIO_MXC) += gpio-mxc.o obj-$(CONFIG_GPIO_MXC) += gpio-mxc.o
obj-$(CONFIG_GPIO_MXS) += gpio-mxs.o obj-$(CONFIG_GPIO_MXS) += gpio-mxs.o
obj-$(CONFIG_GPIO_NOMADIK) += gpio-nomadik.o
obj-$(CONFIG_GPIO_NPCM_SGPIO) += gpio-npcm-sgpio.o obj-$(CONFIG_GPIO_NPCM_SGPIO) += gpio-npcm-sgpio.o
obj-$(CONFIG_GPIO_OCTEON) += gpio-octeon.o obj-$(CONFIG_GPIO_OCTEON) += gpio-octeon.o
obj-$(CONFIG_GPIO_OMAP) += gpio-omap.o obj-$(CONFIG_GPIO_OMAP) += gpio-omap.o
......
This diff is collapsed.
...@@ -22,11 +22,10 @@ if (ARCH_U8500 || ARCH_NOMADIK) ...@@ -22,11 +22,10 @@ if (ARCH_U8500 || ARCH_NOMADIK)
config PINCTRL_NOMADIK config PINCTRL_NOMADIK
bool "Nomadik pin controller driver" bool "Nomadik pin controller driver"
depends on OF && GPIOLIB depends on OF
select PINMUX select PINMUX
select PINCONF select PINCONF
select OF_GPIO select GPIO_NOMADIK
select GPIOLIB_IRQCHIP
config PINCTRL_STN8815 config PINCTRL_STN8815
bool "STN8815 pin controller driver" bool "STN8815 pin controller driver"
......
...@@ -3,8 +3,9 @@ ...@@ -3,8 +3,9 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/pinctrl/pinctrl.h> #include <linux/pinctrl/pinctrl.h>
#include <linux/gpio/driver.h>
#include "pinctrl-nomadik.h" #include <linux/gpio/gpio-nomadik.h>
/* All the pins that can be used for GPIO and some other functions */ /* All the pins that can be used for GPIO and some other functions */
#define _GPIO(offset) (offset) #define _GPIO(offset) (offset)
......
...@@ -3,8 +3,9 @@ ...@@ -3,8 +3,9 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/pinctrl/pinctrl.h> #include <linux/pinctrl/pinctrl.h>
#include <linux/gpio/driver.h>
#include "pinctrl-nomadik.h" #include <linux/gpio/gpio-nomadik.h>
/* All the pins that can be used for GPIO and some other functions */ /* All the pins that can be used for GPIO and some other functions */
#define _GPIO(offset) (offset) #define _GPIO(offset) (offset)
......
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0 */ /* SPDX-License-Identifier: GPL-2.0 */
#ifndef PINCTRL_PINCTRL_NOMADIK_H #ifndef __LINUX_GPIO_NOMADIK_H
#define PINCTRL_PINCTRL_NOMADIK_H #define __LINUX_GPIO_NOMADIK_H
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/pinctrl/pinctrl.h>
/* Package definitions */ /* Package definitions */
#define PINCTRL_NMK_STN8815 0 #define PINCTRL_NMK_STN8815 0
#define PINCTRL_NMK_DB8500 1 #define PINCTRL_NMK_DB8500 1
#define GPIO_BLOCK_SHIFT 5
#define NMK_GPIO_PER_CHIP BIT(GPIO_BLOCK_SHIFT)
#define NMK_MAX_BANKS DIV_ROUND_UP(512, NMK_GPIO_PER_CHIP)
/* Register in the logic block */
#define NMK_GPIO_DAT 0x00
#define NMK_GPIO_DATS 0x04
#define NMK_GPIO_DATC 0x08
#define NMK_GPIO_PDIS 0x0c
#define NMK_GPIO_DIR 0x10
#define NMK_GPIO_DIRS 0x14
#define NMK_GPIO_DIRC 0x18
#define NMK_GPIO_SLPC 0x1c
#define NMK_GPIO_AFSLA 0x20
#define NMK_GPIO_AFSLB 0x24
#define NMK_GPIO_LOWEMI 0x28
#define NMK_GPIO_RIMSC 0x40
#define NMK_GPIO_FIMSC 0x44
#define NMK_GPIO_IS 0x48
#define NMK_GPIO_IC 0x4c
#define NMK_GPIO_RWIMSC 0x50
#define NMK_GPIO_FWIMSC 0x54
#define NMK_GPIO_WKS 0x58
/* These appear in DB8540 and later ASICs */
#define NMK_GPIO_EDGELEVEL 0x5C
#define NMK_GPIO_LEVEL 0x60
/* Pull up/down values */
enum nmk_gpio_pull {
NMK_GPIO_PULL_NONE,
NMK_GPIO_PULL_UP,
NMK_GPIO_PULL_DOWN,
};
/* Sleep mode */
enum nmk_gpio_slpm {
NMK_GPIO_SLPM_INPUT,
NMK_GPIO_SLPM_WAKEUP_ENABLE = NMK_GPIO_SLPM_INPUT,
NMK_GPIO_SLPM_NOCHANGE,
NMK_GPIO_SLPM_WAKEUP_DISABLE = NMK_GPIO_SLPM_NOCHANGE,
};
struct nmk_gpio_chip {
struct gpio_chip chip;
void __iomem *addr;
struct clk *clk;
unsigned int bank;
void (*set_ioforce)(bool enable);
spinlock_t lock;
bool sleepmode;
/* Keep track of configured edges */
u32 edge_rising;
u32 edge_falling;
u32 real_wake;
u32 rwimsc;
u32 fwimsc;
u32 rimsc;
u32 fimsc;
u32 pull_up;
u32 lowemi;
};
/* Alternate functions: function C is set in hw by setting both A and B */ /* Alternate functions: function C is set in hw by setting both A and B */
#define NMK_GPIO_ALT_GPIO 0 #define NMK_GPIO_ALT_GPIO 0
#define NMK_GPIO_ALT_A 1 #define NMK_GPIO_ALT_A 1
...@@ -104,7 +162,7 @@ struct prcm_gpiocr_altcx_pin_desc { ...@@ -104,7 +162,7 @@ struct prcm_gpiocr_altcx_pin_desc {
struct nmk_function { struct nmk_function {
const char *name; const char *name;
const char * const *groups; const char * const *groups;
unsigned ngroups; unsigned int ngroups;
}; };
/** /**
...@@ -141,13 +199,13 @@ struct nmk_pingroup { ...@@ -141,13 +199,13 @@ struct nmk_pingroup {
*/ */
struct nmk_pinctrl_soc_data { struct nmk_pinctrl_soc_data {
const struct pinctrl_pin_desc *pins; const struct pinctrl_pin_desc *pins;
unsigned npins; unsigned int npins;
const struct nmk_function *functions; const struct nmk_function *functions;
unsigned nfunctions; unsigned int nfunctions;
const struct nmk_pingroup *groups; const struct nmk_pingroup *groups;
unsigned ngroups; unsigned int ngroups;
const struct prcm_gpiocr_altcx_pin_desc *altcx_pins; const struct prcm_gpiocr_altcx_pin_desc *altcx_pins;
unsigned npins_altcx; unsigned int npins_altcx;
const u16 *prcm_gpiocr_registers; const u16 *prcm_gpiocr_registers;
}; };
...@@ -177,4 +235,42 @@ nmk_pinctrl_db8500_init(const struct nmk_pinctrl_soc_data **soc) ...@@ -177,4 +235,42 @@ nmk_pinctrl_db8500_init(const struct nmk_pinctrl_soc_data **soc)
#endif #endif
#endif /* PINCTRL_PINCTRL_NOMADIK_H */ #ifdef CONFIG_PINCTRL_DB8540
void nmk_pinctrl_db8540_init(const struct nmk_pinctrl_soc_data **soc);
#else
static inline void
nmk_pinctrl_db8540_init(const struct nmk_pinctrl_soc_data **soc)
{
}
#endif
struct platform_device;
/*
* Symbols declared in gpio-nomadik used by pinctrl-nomadik. If pinctrl-nomadik
* is enabled, then gpio-nomadik is enabled as well; the reverse if not always
* true.
*/
void nmk_gpio_dbg_show_one(struct seq_file *s, struct pinctrl_dev *pctldev,
struct gpio_chip *chip, unsigned int offset,
unsigned int gpio);
void __nmk_gpio_make_output(struct nmk_gpio_chip *nmk_chip,
unsigned int offset, int val);
void __nmk_gpio_set_slpm(struct nmk_gpio_chip *nmk_chip, unsigned int offset,
enum nmk_gpio_slpm mode);
struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np,
struct platform_device *pdev);
/* Symbols declared in pinctrl-nomadik used by gpio-nomadik. */
#ifdef CONFIG_PINCTRL_NOMADIK
extern struct nmk_gpio_chip *nmk_gpio_chips[NMK_MAX_BANKS];
extern spinlock_t nmk_gpio_slpm_lock;
int __maybe_unused nmk_prcm_gpiocr_get_mode(struct pinctrl_dev *pctldev,
int gpio);
#endif
#endif /* __LINUX_GPIO_NOMADIK_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment