1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Pinctrl / GPIO driver for StarFive JH7110 SoC
5 * Copyright (C) 2022 Shanghai StarFive Technology Co., Ltd.
8 #ifndef __DRIVERS_PINCTRL_STARFIVE_H
9 #define __DRIVERS_PINCTRL_STARFIVE_H
11 #include <linux/pinctrl/pinconf-generic.h>
12 #include <linux/pinctrl/pinmux.h>
16 #define STARFIVE_PINS_SIZE 4
18 #define STARFIVE_USE_SCU BIT(0)
20 #define SYS_IRQ_REG_SUSPENDED_NUM 11
21 #define AON_IRQ_REG_SUSPENDED_NUM 6
23 struct platform_device;
25 extern const struct pinmux_ops starfive_pmx_ops;
27 struct starfive_pin_config {
28 unsigned long io_config;
41 struct starfive_pin_config pin_config;
44 struct starfive_pin_reg {
57 struct starfive_iopad_sel_func_inf {
58 unsigned int padctl_gpio_base;
59 unsigned int padctl_gpio0;
62 struct starfive_pinctrl {
64 struct pinctrl_dev *pctl_dev;
65 void __iomem *padctl_base;
66 void __iomem *gpio_base;
67 unsigned int padctl_gpio_base;
68 unsigned int padctl_gpio0;
69 const struct starfive_pinctrl_soc_info *info;
70 struct starfive_pin_reg *pin_regs;
71 unsigned int group_index;
77 struct pinctrl_gpio_range gpios;
78 unsigned long enabled;
79 unsigned int trigger[MAX_GPIO];
81 u32 sys_irq_reg_suspended[SYS_IRQ_REG_SUSPENDED_NUM];
82 u32 aon_irq_reg_suspended[AON_IRQ_REG_SUSPENDED_NUM];
85 struct starfive_pinctrl_soc_info {
86 const struct pinctrl_pin_desc *pins;
90 /*gpio dout/doen/din register*/
91 unsigned int dout_reg_base;
92 unsigned int dout_reg_offset;
93 unsigned int doen_reg_base;
94 unsigned int doen_reg_offset;
95 unsigned int din_reg_base;
96 unsigned int din_reg_offset;
99 int (*starfive_iopad_sel_func)(struct platform_device *pdev,
100 struct starfive_pinctrl *ipctl,
101 unsigned int func_id);
102 /* generic pinconf */
103 int (*starfive_pinconf_get)(struct pinctrl_dev *pctldev, unsigned int pin_id,
104 unsigned long *config);
105 int (*starfive_pinconf_set)(struct pinctrl_dev *pctldev,
106 unsigned int pin_id, unsigned long *configs,
107 unsigned int num_configs);
110 int (*starfive_pmx_set_one_pin_mux)(struct starfive_pinctrl *ipctl,
111 struct starfive_pin *pin);
113 int (*starfive_gpio_register)(struct platform_device *pdev,
114 struct starfive_pinctrl *ipctl);
115 void (*starfive_pinctrl_parse_pin)(struct starfive_pinctrl *ipctl,
116 unsigned int *pins_id, struct starfive_pin *pin_data,
117 const __be32 *list_p,
118 struct device_node *np);
121 #define STARFIVE_PINCTRL_PIN(pin) PINCTRL_PIN(pin, #pin)
123 int starfive_pinctrl_probe(struct platform_device *pdev,
124 const struct starfive_pinctrl_soc_info *info);
126 #endif /* __DRIVERS_PINCTRL_STARFIVE_H */