0001
0002
0003
0004
0005
0006
0007
0008 #ifndef __VISCONTI_PINCTRL_COMMON_H__
0009 #define __VISCONTI_PINCTRL_COMMON_H__
0010
0011 struct pinctrl_pin_desc;
0012
0013
0014 #define VISCONTI_PINS(pins_name, ...) \
0015 static const unsigned int pins_name ## _pins[] = { __VA_ARGS__ }
0016
0017 struct visconti_desc_pin {
0018 struct pinctrl_pin_desc pin;
0019 unsigned int dsel_offset;
0020 unsigned int dsel_shift;
0021 unsigned int pude_offset;
0022 unsigned int pudsel_offset;
0023 unsigned int pud_shift;
0024 };
0025
0026 #define VISCONTI_PIN(_pin, dsel, d_sh, pude, pudsel, p_sh) \
0027 { \
0028 .pin = _pin, \
0029 .dsel_offset = dsel, \
0030 .dsel_shift = d_sh, \
0031 .pude_offset = pude, \
0032 .pudsel_offset = pudsel, \
0033 .pud_shift = p_sh, \
0034 }
0035
0036
0037 #define VISCONTI_GROUPS(groups_name, ...) \
0038 static const char * const groups_name ## _grps[] = { __VA_ARGS__ }
0039
0040 struct visconti_mux {
0041 unsigned int offset;
0042 unsigned int mask;
0043 unsigned int val;
0044 };
0045
0046 struct visconti_pin_group {
0047 const char *name;
0048 const unsigned int *pins;
0049 unsigned int nr_pins;
0050 struct visconti_mux mux;
0051 };
0052
0053 #define VISCONTI_PIN_GROUP(group_name, off, msk, v) \
0054 { \
0055 .name = __stringify(group_name) "_grp", \
0056 .pins = group_name ## _pins, \
0057 .nr_pins = ARRAY_SIZE(group_name ## _pins), \
0058 .mux = { \
0059 .offset = off, \
0060 .mask = msk, \
0061 .val = v, \
0062 } \
0063 }
0064
0065
0066 struct visconti_pin_function {
0067 const char *name;
0068 const char * const *groups;
0069 unsigned int nr_groups;
0070 };
0071
0072 #define VISCONTI_PIN_FUNCTION(func) \
0073 { \
0074 .name = #func, \
0075 .groups = func ## _grps, \
0076 .nr_groups = ARRAY_SIZE(func ## _grps), \
0077 }
0078
0079
0080 struct visconti_pinctrl_devdata {
0081 const struct visconti_desc_pin *pins;
0082 unsigned int nr_pins;
0083 const struct visconti_pin_group *groups;
0084 unsigned int nr_groups;
0085 const struct visconti_pin_function *functions;
0086 unsigned int nr_functions;
0087
0088 const struct visconti_mux *gpio_mux;
0089
0090 void (*unlock)(void __iomem *base);
0091 };
0092
0093 int visconti_pinctrl_probe(struct platform_device *pdev,
0094 const struct visconti_pinctrl_devdata *devdata);
0095
0096 #endif