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