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 struct platform_device;
22 extern const struct pinmux_ops starfive_pmx_ops;
24 struct starfive_pin_config {
25 unsigned long io_config;
38 struct starfive_pin_config pin_config;
41 struct starfive_pin_reg {
54 struct starfive_iopad_sel_func_inf {
55 unsigned int padctl_gpio_base;
56 unsigned int padctl_gpio0;
59 struct starfive_pinctrl {
61 struct pinctrl_dev *pctl_dev;
62 void __iomem *padctl_base;
63 void __iomem *gpio_base;
64 unsigned int padctl_gpio_base;
65 unsigned int padctl_gpio0;
66 const struct starfive_pinctrl_soc_info *info;
67 struct starfive_pin_reg *pin_regs;
68 unsigned int group_index;
74 struct pinctrl_gpio_range gpios;
75 unsigned long enabled;
76 unsigned int trigger[MAX_GPIO];
79 struct starfive_pinctrl_soc_info {
80 const struct pinctrl_pin_desc *pins;
84 /*gpio dout/doen/din register*/
85 unsigned int dout_reg_base;
86 unsigned int dout_reg_offset;
87 unsigned int doen_reg_base;
88 unsigned int doen_reg_offset;
89 unsigned int din_reg_base;
90 unsigned int din_reg_offset;
93 int (*starfive_iopad_sel_func)(struct platform_device *pdev,
94 struct starfive_pinctrl *ipctl,
95 unsigned int func_id);
97 int (*starfive_pinconf_get)(struct pinctrl_dev *pctldev, unsigned int pin_id,
98 unsigned long *config);
99 int (*starfive_pinconf_set)(struct pinctrl_dev *pctldev,
100 unsigned int pin_id, unsigned long *configs,
101 unsigned int num_configs);
104 int (*starfive_pmx_set_one_pin_mux)(struct starfive_pinctrl *ipctl,
105 struct starfive_pin *pin);
107 int (*starfive_gpio_register)(struct platform_device *pdev,
108 struct starfive_pinctrl *ipctl);
109 void (*starfive_pinctrl_parse_pin)(struct starfive_pinctrl *ipctl,
110 unsigned int *pins_id, struct starfive_pin *pin_data,
111 const __be32 *list_p,
112 struct device_node *np);
115 #define STARFIVE_PINCTRL_PIN(pin) PINCTRL_PIN(pin, #pin)
117 int starfive_pinctrl_probe(struct platform_device *pdev,
118 const struct starfive_pinctrl_soc_info *info);
120 #endif /* __DRIVERS_PINCTRL_STARFIVE_H */