1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2021 Álvaro Fernández Rojas <noltari@gmail.com>
4  * Copyright (C) 2016 Jonas Gorski <jonas.gorski@gmail.com>
5  */
6 
7 #ifndef __PINCTRL_BCM63XX_H__
8 #define __PINCTRL_BCM63XX_H__
9 
10 #include <linux/pinctrl/pinctrl.h>
11 
12 #define BCM63XX_BANK_GPIOS 32
13 
14 struct bcm63xx_pinctrl_soc {
15 	const struct pinctrl_ops *pctl_ops;
16 	const struct pinmux_ops *pmx_ops;
17 
18 	const struct pinctrl_pin_desc *pins;
19 	unsigned npins;
20 
21 	unsigned int ngpios;
22 };
23 
24 #define BCM_PIN_GROUP(n)	PINCTRL_PINGROUP(#n, n##_pins, ARRAY_SIZE(n##_pins))
25 
26 struct bcm63xx_pinctrl {
27 	struct device *dev;
28 	struct regmap *regs;
29 
30 	struct pinctrl_desc pctl_desc;
31 	struct pinctrl_dev *pctl_dev;
32 
33 	void *driver_data;
34 };
35 
36 static inline unsigned int bcm63xx_bank_pin(unsigned int pin)
37 {
38 	return pin % BCM63XX_BANK_GPIOS;
39 }
40 
41 int bcm63xx_pinctrl_probe(struct platform_device *pdev,
42 			  const struct bcm63xx_pinctrl_soc *soc,
43 			  void *driver_data);
44 
45 #endif /* __PINCTRL_BCM63XX_H__ */
46