1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Pinctrl / GPIO driver for StarFive JH7110 SoC
5 * Copyright (C) 2022 StarFive Technology Co., Ltd.
8 #ifndef __PINCTRL_STARFIVE_JH7110_H__
9 #define __PINCTRL_STARFIVE_JH7110_H__
11 #include <linux/pinctrl/pinconf-generic.h>
12 #include <linux/pinctrl/pinmux.h>
14 struct jh7110_pinctrl {
17 struct pinctrl_gpio_range gpios;
20 struct pinctrl_dev *pctl;
21 /* register read/write mutex */
23 const struct jh7110_pinctrl_soc_info *info;
27 struct jh7110_gpio_irq_reg {
28 unsigned int is_reg_base;
29 unsigned int ic_reg_base;
30 unsigned int ibe_reg_base;
31 unsigned int iev_reg_base;
32 unsigned int ie_reg_base;
33 unsigned int ris_reg_base;
34 unsigned int mis_reg_base;
37 struct jh7110_pinctrl_soc_info {
38 const struct pinctrl_pin_desc *pins;
43 /* gpio dout/doen/din/gpioinput register */
44 unsigned int dout_reg_base;
45 unsigned int dout_mask;
46 unsigned int doen_reg_base;
47 unsigned int doen_mask;
48 unsigned int gpi_reg_base;
49 unsigned int gpi_mask;
50 unsigned int gpioin_reg_base;
52 const struct jh7110_gpio_irq_reg *irq_reg;
54 unsigned int nsaved_regs;
57 int (*jh7110_set_one_pin_mux)(struct jh7110_pinctrl *sfp,
59 unsigned int din, u32 dout,
62 int (*jh7110_get_padcfg_base)(struct jh7110_pinctrl *sfp,
64 void (*jh7110_gpio_irq_handler)(struct irq_desc *desc);
65 int (*jh7110_gpio_init_hw)(struct gpio_chip *gc);
68 void jh7110_set_gpiomux(struct jh7110_pinctrl *sfp, unsigned int pin,
69 unsigned int din, u32 dout, u32 doen);
70 int jh7110_pinctrl_probe(struct platform_device *pdev);
71 struct jh7110_pinctrl *jh7110_from_irq_desc(struct irq_desc *desc);
72 extern const struct dev_pm_ops jh7110_pinctrl_pm_ops;
74 #endif /* __PINCTRL_STARFIVE_JH7110_H__ */