1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef PINCTRL_PINCTRL_NOMADIK_H
3 #define PINCTRL_PINCTRL_NOMADIK_H
5 #include <linux/kernel.h>
6 #include <linux/types.h>
8 #include <linux/pinctrl/pinctrl.h>
10 /* Package definitions */
11 #define PINCTRL_NMK_STN8815 0
12 #define PINCTRL_NMK_DB8500 1
14 /* Alternate functions: function C is set in hw by setting both A and B */
15 #define NMK_GPIO_ALT_GPIO 0
16 #define NMK_GPIO_ALT_A 1
17 #define NMK_GPIO_ALT_B 2
18 #define NMK_GPIO_ALT_C (NMK_GPIO_ALT_A | NMK_GPIO_ALT_B)
20 #define NMK_GPIO_ALT_CX_SHIFT 2
21 #define NMK_GPIO_ALT_C1 ((1<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C)
22 #define NMK_GPIO_ALT_C2 ((2<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C)
23 #define NMK_GPIO_ALT_C3 ((3<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C)
24 #define NMK_GPIO_ALT_C4 ((4<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C)
26 #define PRCM_GPIOCR_ALTCX(pin_num,\
27 altc1_used, altc1_ri, altc1_cb,\
28 altc2_used, altc2_ri, altc2_cb,\
29 altc3_used, altc3_ri, altc3_cb,\
30 altc4_used, altc4_ri, altc4_cb)\
33 .altcx[PRCM_IDX_GPIOCR_ALTC1] = {\
35 .reg_index = altc1_ri,\
36 .control_bit = altc1_cb\
38 .altcx[PRCM_IDX_GPIOCR_ALTC2] = {\
40 .reg_index = altc2_ri,\
41 .control_bit = altc2_cb\
43 .altcx[PRCM_IDX_GPIOCR_ALTC3] = {\
45 .reg_index = altc3_ri,\
46 .control_bit = altc3_cb\
48 .altcx[PRCM_IDX_GPIOCR_ALTC4] = {\
50 .reg_index = altc4_ri,\
51 .control_bit = altc4_cb\
56 * enum prcm_gpiocr_reg_index
57 * Used to reference an PRCM GPIOCR register address.
59 enum prcm_gpiocr_reg_index {
65 * enum prcm_gpiocr_altcx_index
66 * Used to reference an Other alternate-C function.
68 enum prcm_gpiocr_altcx_index {
69 PRCM_IDX_GPIOCR_ALTC1,
70 PRCM_IDX_GPIOCR_ALTC2,
71 PRCM_IDX_GPIOCR_ALTC3,
72 PRCM_IDX_GPIOCR_ALTC4,
73 PRCM_IDX_GPIOCR_ALTC_MAX,
77 * struct prcm_gpio_altcx - Other alternate-C function
78 * @used: other alternate-C function availability
79 * @reg_index: PRCM GPIOCR register index used to control the function
80 * @control_bit: PRCM GPIOCR bit used to control the function
82 struct prcm_gpiocr_altcx {
89 * struct prcm_gpio_altcx_pin_desc - Other alternate-C pin
90 * @pin: The pin number
91 * @altcx: array of other alternate-C[1-4] functions
93 struct prcm_gpiocr_altcx_pin_desc {
95 struct prcm_gpiocr_altcx altcx[PRCM_IDX_GPIOCR_ALTC_MAX];
99 * struct nmk_function - Nomadik pinctrl mux function
100 * @name: The name of the function, exported to pinctrl core.
101 * @groups: An array of pin groups that may select this function.
102 * @ngroups: The number of entries in @groups.
104 struct nmk_function {
106 const char * const *groups;
111 * struct nmk_pingroup - describes a Nomadik pin group
112 * @grp: Generic data of the pin group (name and pins)
113 * @altsetting: the altsetting to apply to all pins in this group to
114 * configure them to be used by a function
116 struct nmk_pingroup {
121 #define NMK_PIN_GROUP(a, b) \
123 .grp = PINCTRL_PINGROUP(#a, a##_pins, ARRAY_SIZE(a##_pins)), \
128 * struct nmk_pinctrl_soc_data - Nomadik pin controller per-SoC configuration
129 * @pins: An array describing all pins the pin controller affects.
130 * All pins which are also GPIOs must be listed first within the
131 * array, and be numbered identically to the GPIO controller's
133 * @npins: The number of entries in @pins.
134 * @functions: The functions supported on this SoC.
135 * @nfunction: The number of entries in @functions.
136 * @groups: An array describing all pin groups the pin SoC supports.
137 * @ngroups: The number of entries in @groups.
138 * @altcx_pins: The pins that support Other alternate-C function on this SoC
139 * @npins_altcx: The number of Other alternate-C pins
140 * @prcm_gpiocr_registers: The array of PRCM GPIOCR registers on this SoC
142 struct nmk_pinctrl_soc_data {
143 const struct pinctrl_pin_desc *pins;
145 const struct nmk_function *functions;
147 const struct nmk_pingroup *groups;
149 const struct prcm_gpiocr_altcx_pin_desc *altcx_pins;
150 unsigned npins_altcx;
151 const u16 *prcm_gpiocr_registers;
154 #ifdef CONFIG_PINCTRL_STN8815
156 void nmk_pinctrl_stn8815_init(const struct nmk_pinctrl_soc_data **soc);
161 nmk_pinctrl_stn8815_init(const struct nmk_pinctrl_soc_data **soc)
167 #ifdef CONFIG_PINCTRL_DB8500
169 void nmk_pinctrl_db8500_init(const struct nmk_pinctrl_soc_data **soc);
174 nmk_pinctrl_db8500_init(const struct nmk_pinctrl_soc_data **soc)
180 #endif /* PINCTRL_PINCTRL_NOMADIK_H */