Linux Audio

Check our new training course

Loading...
Note: File does not exist in v6.8.
  1#ifndef PINCTRL_PINCTRL_NOMADIK_H
  2#define PINCTRL_PINCTRL_NOMADIK_H
  3
  4/* Package definitions */
  5#define PINCTRL_NMK_STN8815	0
  6#define PINCTRL_NMK_DB8500	1
  7#define PINCTRL_NMK_DB8540	2
  8
  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)
 14
 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)
 20
 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)\
 26{\
 27	.pin = pin_num,\
 28	.altcx[PRCM_IDX_GPIOCR_ALTC1] = {\
 29		.used = altc1_used,\
 30		.reg_index = altc1_ri,\
 31		.control_bit = altc1_cb\
 32	},\
 33	.altcx[PRCM_IDX_GPIOCR_ALTC2] = {\
 34		.used = altc2_used,\
 35		.reg_index = altc2_ri,\
 36		.control_bit = altc2_cb\
 37	},\
 38	.altcx[PRCM_IDX_GPIOCR_ALTC3] = {\
 39		.used = altc3_used,\
 40		.reg_index = altc3_ri,\
 41		.control_bit = altc3_cb\
 42	},\
 43	.altcx[PRCM_IDX_GPIOCR_ALTC4] = {\
 44		.used = altc4_used,\
 45		.reg_index = altc4_ri,\
 46		.control_bit = altc4_cb\
 47	},\
 48}
 49
 50/**
 51 * enum prcm_gpiocr_reg_index
 52 * Used to reference an PRCM GPIOCR register address.
 53 */
 54enum prcm_gpiocr_reg_index {
 55	PRCM_IDX_GPIOCR1,
 56	PRCM_IDX_GPIOCR2,
 57	PRCM_IDX_GPIOCR3
 58};
 59/**
 60 * enum prcm_gpiocr_altcx_index
 61 * Used to reference an Other alternate-C function.
 62 */
 63enum 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,
 69};
 70
 71/**
 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
 76 */
 77struct prcm_gpiocr_altcx {
 78	bool used:1;
 79	u8 reg_index:2;
 80	u8 control_bit:5;
 81} __packed;
 82
 83/**
 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
 87 */
 88struct prcm_gpiocr_altcx_pin_desc {
 89	unsigned short pin;
 90	struct prcm_gpiocr_altcx altcx[PRCM_IDX_GPIOCR_ALTC_MAX];
 91};
 92
 93/**
 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.
 98 */
 99struct nmk_function {
100	const char *name;
101	const char * const *groups;
102	unsigned ngroups;
103};
104
105/**
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
114 */
115struct nmk_pingroup {
116	const char *name;
117	const unsigned int *pins;
118	const unsigned npins;
119	int altsetting;
120};
121
122/**
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
129 *		numbering.
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
138 */
139struct nmk_pinctrl_soc_data {
140	struct pinctrl_gpio_range *gpio_ranges;
141	unsigned gpio_num_ranges;
142	const struct pinctrl_pin_desc *pins;
143	unsigned npins;
144	const struct nmk_function *functions;
145	unsigned nfunctions;
146	const struct nmk_pingroup *groups;
147	unsigned ngroups;
148	const struct prcm_gpiocr_altcx_pin_desc *altcx_pins;
149	unsigned npins_altcx;
150	const u16 *prcm_gpiocr_registers;
151};
152
153#ifdef CONFIG_PINCTRL_STN8815
154
155void nmk_pinctrl_stn8815_init(const struct nmk_pinctrl_soc_data **soc);
156
157#else
158
159static inline void
160nmk_pinctrl_stn8815_init(const struct nmk_pinctrl_soc_data **soc)
161{
162}
163
164#endif
165
166#ifdef CONFIG_PINCTRL_DB8500
167
168void nmk_pinctrl_db8500_init(const struct nmk_pinctrl_soc_data **soc);
169
170#else
171
172static inline void
173nmk_pinctrl_db8500_init(const struct nmk_pinctrl_soc_data **soc)
174{
175}
176
177#endif
178
179#ifdef CONFIG_PINCTRL_DB8540
180
181void nmk_pinctrl_db8540_init(const struct nmk_pinctrl_soc_data **soc);
182
183#else
184
185static inline void
186nmk_pinctrl_db8540_init(const struct nmk_pinctrl_soc_data **soc)
187{
188}
189
190#endif
191
192#endif /* PINCTRL_PINCTRL_NOMADIK_H */