1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (C) 2017 Jerome Brunet  <jbrunet@baylibre.com>
4  * Copyright (C) 2017 Xingyu Chen <xingyu.chen@amlogic.com>
5  */
6 
7 #ifndef __PINCTRL_MESON_AXG_H__
8 #define __PINCTRL_MESON_AXG_H__
9 
10 #include "pinctrl-meson.h"
11 
12 struct meson_pmx_bank {
13 	const char *name;
14 	unsigned int first;
15 	unsigned int last;
16 	unsigned int reg;
17 	unsigned int offset;
18 };
19 
20 struct meson_axg_pmx_data {
21 	struct meson_pmx_bank *pmx_banks;
22 	unsigned int num_pmx_banks;
23 };
24 
25 #define BANK_PMX(n, f, l, r, o)				\
26 	{							\
27 		.name   = n,					\
28 		.first	= f,					\
29 		.last	= l,					\
30 		.reg	= r,					\
31 		.offset = o,					\
32 	}
33 
34 struct meson_pmx_axg_data {
35 	unsigned int func;
36 };
37 
38 #define PMX_DATA(f)							\
39 	{								\
40 		.func = f,						\
41 	}
42 
43 #define GROUP(grp, f)							\
44 	{								\
45 		.name = #grp,						\
46 		.pins = grp ## _pins,                                   \
47 		.num_pins = ARRAY_SIZE(grp ## _pins),			\
48 		.data = (const struct meson_pmx_axg_data[]){		\
49 			PMX_DATA(f),					\
50 		},							\
51 	}
52 
53 #define GPIO_GROUP(gpio, b)						\
54 	{								\
55 		.name = #gpio,						\
56 		.pins = (const unsigned int[]){ PIN(gpio, b) },		\
57 		.num_pins = 1,						\
58 		.data = (const struct meson_pmx_axg_data[]){		\
59 			PMX_DATA(0),					\
60 		},							\
61 	}
62 
63 extern const struct pinctrl_ops meson_axg_pinctrl_ops;
64 extern const struct driver meson_axg_gpio_driver;
65 
66 #endif /* __PINCTRL_MESON_AXG_H__ */
67