arm: socfpga: Enable all FPGA config support for Arria 10
[platform/kernel/u-boot.git] / drivers / pinctrl / meson / pinctrl-meson.h
1 /*
2  * (C) Copyright 2016 - Beniamino Galvani <b.galvani@gmail.com>
3  *
4  * SPDX-License-Identifier:     GPL-2.0+
5  */
6
7 #ifndef __PINCTRL_MESON_H__
8 #define __PINCTRL_MESON_H__
9
10 #include <linux/types.h>
11
12 struct meson_pmx_group {
13         const char *name;
14         const unsigned int *pins;
15         unsigned int num_pins;
16         bool is_gpio;
17         unsigned int reg;
18         unsigned int bit;
19 };
20
21 struct meson_pmx_func {
22         const char *name;
23         const char * const *groups;
24         unsigned int num_groups;
25 };
26
27 struct meson_pinctrl_data {
28         const char *name;
29         struct meson_pmx_group *groups;
30         struct meson_pmx_func *funcs;
31         unsigned int pin_base;
32         unsigned int num_pins;
33         unsigned int num_groups;
34         unsigned int num_funcs;
35 };
36
37 struct meson_pinctrl {
38         struct meson_pinctrl_data *data;
39         void __iomem *reg_mux;
40 };
41
42 #define PIN(x, b)       (b + x)
43
44 #define GROUP(grp, r, b)                                                \
45         {                                                               \
46                 .name = #grp,                                           \
47                 .pins = grp ## _pins,                                   \
48                 .num_pins = ARRAY_SIZE(grp ## _pins),                   \
49                 .reg = r,                                               \
50                 .bit = b,                                               \
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                 .is_gpio = true,                                        \
59          }
60
61 #define FUNCTION(fn)                                                    \
62         {                                                               \
63                 .name = #fn,                                            \
64                 .groups = fn ## _groups,                                \
65                 .num_groups = ARRAY_SIZE(fn ## _groups),                \
66         }
67
68 #define MESON_PIN(x, b) PINCTRL_PIN(PIN(x, b), #x)
69
70 extern const struct pinctrl_ops meson_pinctrl_ops;
71
72 int meson_pinctrl_probe(struct udevice *dev);
73
74 #endif /* __PINCTRL_MESON_H__ */