1 #ifndef PINCTRL_PINCTRL_NOMADIK_H
2 #define PINCTRL_PINCTRL_NOMADIK_H
4 /* Package definitions */
5 #define PINCTRL_NMK_STN8815 0
6 #define PINCTRL_NMK_DB8500 1
7 #define PINCTRL_NMK_DB8540 2
9 /* Alternate functions: function C is set in hw by setting both A and B */
10 #define NMK_GPIO_ALT_GPIO 0
11 #define NMK_GPIO_ALT_A 1
12 #define NMK_GPIO_ALT_B 2
13 #define NMK_GPIO_ALT_C (NMK_GPIO_ALT_A | NMK_GPIO_ALT_B)
15 #define NMK_GPIO_ALT_CX_SHIFT 2
16 #define NMK_GPIO_ALT_C1 ((1<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C)
17 #define NMK_GPIO_ALT_C2 ((2<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C)
18 #define NMK_GPIO_ALT_C3 ((3<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C)
19 #define NMK_GPIO_ALT_C4 ((4<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C)
21 #define PRCM_GPIOCR_ALTCX(pin_num,\
22 altc1_used, altc1_ri, altc1_cb,\
23 altc2_used, altc2_ri, altc2_cb,\
24 altc3_used, altc3_ri, altc3_cb,\
25 altc4_used, altc4_ri, altc4_cb)\
28 .altcx[PRCM_IDX_GPIOCR_ALTC1] = {\
30 .reg_index = altc1_ri,\
31 .control_bit = altc1_cb\
33 .altcx[PRCM_IDX_GPIOCR_ALTC2] = {\
35 .reg_index = altc2_ri,\
36 .control_bit = altc2_cb\
38 .altcx[PRCM_IDX_GPIOCR_ALTC3] = {\
40 .reg_index = altc3_ri,\
41 .control_bit = altc3_cb\
43 .altcx[PRCM_IDX_GPIOCR_ALTC4] = {\
45 .reg_index = altc4_ri,\
46 .control_bit = altc4_cb\
51 * enum prcm_gpiocr_reg_index
52 * Used to reference an PRCM GPIOCR register address.
54 enum prcm_gpiocr_reg_index
{
60 * enum prcm_gpiocr_altcx_index
61 * Used to reference an Other alternate-C function.
63 enum prcm_gpiocr_altcx_index
{
64 PRCM_IDX_GPIOCR_ALTC1
,
65 PRCM_IDX_GPIOCR_ALTC2
,
66 PRCM_IDX_GPIOCR_ALTC3
,
67 PRCM_IDX_GPIOCR_ALTC4
,
68 PRCM_IDX_GPIOCR_ALTC_MAX
,
72 * struct prcm_gpio_altcx - Other alternate-C function
73 * @used: other alternate-C function availability
74 * @reg_index: PRCM GPIOCR register index used to control the function
75 * @control_bit: PRCM GPIOCR bit used to control the function
77 struct prcm_gpiocr_altcx
{
84 * struct prcm_gpio_altcx_pin_desc - Other alternate-C pin
85 * @pin: The pin number
86 * @altcx: array of other alternate-C[1-4] functions
88 struct prcm_gpiocr_altcx_pin_desc
{
90 struct prcm_gpiocr_altcx altcx
[PRCM_IDX_GPIOCR_ALTC_MAX
];
94 * struct nmk_function - Nomadik pinctrl mux function
95 * @name: The name of the function, exported to pinctrl core.
96 * @groups: An array of pin groups that may select this function.
97 * @ngroups: The number of entries in @groups.
101 const char * const *groups
;
106 * struct nmk_pingroup - describes a Nomadik pin group
107 * @name: the name of this specific pin group
108 * @pins: an array of discrete physical pins used in this group, taken
109 * from the driver-local pin enumeration space
110 * @num_pins: the number of pins in this group array, i.e. the number of
111 * elements in .pins so we can iterate over that array
112 * @altsetting: the altsetting to apply to all pins in this group to
113 * configure them to be used by a function
115 struct nmk_pingroup
{
117 const unsigned int *pins
;
118 const unsigned npins
;
123 * struct nmk_pinctrl_soc_data - Nomadik pin controller per-SoC configuration
124 * @gpio_ranges: An array of GPIO ranges for this SoC
125 * @gpio_num_ranges: The number of GPIO ranges for this SoC
126 * @pins: An array describing all pins the pin controller affects.
127 * All pins which are also GPIOs must be listed first within the
128 * array, and be numbered identically to the GPIO controller's
130 * @npins: The number of entries in @pins.
131 * @functions: The functions supported on this SoC.
132 * @nfunction: The number of entries in @functions.
133 * @groups: An array describing all pin groups the pin SoC supports.
134 * @ngroups: The number of entries in @groups.
135 * @altcx_pins: The pins that support Other alternate-C function on this SoC
136 * @npins_altcx: The number of Other alternate-C pins
137 * @prcm_gpiocr_registers: The array of PRCM GPIOCR registers on this SoC
139 struct nmk_pinctrl_soc_data
{
140 struct pinctrl_gpio_range
*gpio_ranges
;
141 unsigned gpio_num_ranges
;
142 const struct pinctrl_pin_desc
*pins
;
144 const struct nmk_function
*functions
;
146 const struct nmk_pingroup
*groups
;
148 const struct prcm_gpiocr_altcx_pin_desc
*altcx_pins
;
149 unsigned npins_altcx
;
150 const u16
*prcm_gpiocr_registers
;
153 #ifdef CONFIG_PINCTRL_STN8815
155 void nmk_pinctrl_stn8815_init(const struct nmk_pinctrl_soc_data
**soc
);
160 nmk_pinctrl_stn8815_init(const struct nmk_pinctrl_soc_data
**soc
)
166 #ifdef CONFIG_PINCTRL_DB8500
168 void nmk_pinctrl_db8500_init(const struct nmk_pinctrl_soc_data
**soc
);
173 nmk_pinctrl_db8500_init(const struct nmk_pinctrl_soc_data
**soc
)
179 #ifdef CONFIG_PINCTRL_DB8540
181 void nmk_pinctrl_db8540_init(const struct nmk_pinctrl_soc_data
**soc
);
186 nmk_pinctrl_db8540_init(const struct nmk_pinctrl_soc_data
**soc
)
192 #endif /* PINCTRL_PINCTRL_NOMADIK_H */