18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef PINCTRL_PINCTRL_NOMADIK_H 38c2ecf20Sopenharmony_ci#define PINCTRL_PINCTRL_NOMADIK_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci/* Package definitions */ 68c2ecf20Sopenharmony_ci#define PINCTRL_NMK_STN8815 0 78c2ecf20Sopenharmony_ci#define PINCTRL_NMK_DB8500 1 88c2ecf20Sopenharmony_ci#define PINCTRL_NMK_DB8540 2 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci/* Alternate functions: function C is set in hw by setting both A and B */ 118c2ecf20Sopenharmony_ci#define NMK_GPIO_ALT_GPIO 0 128c2ecf20Sopenharmony_ci#define NMK_GPIO_ALT_A 1 138c2ecf20Sopenharmony_ci#define NMK_GPIO_ALT_B 2 148c2ecf20Sopenharmony_ci#define NMK_GPIO_ALT_C (NMK_GPIO_ALT_A | NMK_GPIO_ALT_B) 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#define NMK_GPIO_ALT_CX_SHIFT 2 178c2ecf20Sopenharmony_ci#define NMK_GPIO_ALT_C1 ((1<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C) 188c2ecf20Sopenharmony_ci#define NMK_GPIO_ALT_C2 ((2<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C) 198c2ecf20Sopenharmony_ci#define NMK_GPIO_ALT_C3 ((3<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C) 208c2ecf20Sopenharmony_ci#define NMK_GPIO_ALT_C4 ((4<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C) 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#define PRCM_GPIOCR_ALTCX(pin_num,\ 238c2ecf20Sopenharmony_ci altc1_used, altc1_ri, altc1_cb,\ 248c2ecf20Sopenharmony_ci altc2_used, altc2_ri, altc2_cb,\ 258c2ecf20Sopenharmony_ci altc3_used, altc3_ri, altc3_cb,\ 268c2ecf20Sopenharmony_ci altc4_used, altc4_ri, altc4_cb)\ 278c2ecf20Sopenharmony_ci{\ 288c2ecf20Sopenharmony_ci .pin = pin_num,\ 298c2ecf20Sopenharmony_ci .altcx[PRCM_IDX_GPIOCR_ALTC1] = {\ 308c2ecf20Sopenharmony_ci .used = altc1_used,\ 318c2ecf20Sopenharmony_ci .reg_index = altc1_ri,\ 328c2ecf20Sopenharmony_ci .control_bit = altc1_cb\ 338c2ecf20Sopenharmony_ci },\ 348c2ecf20Sopenharmony_ci .altcx[PRCM_IDX_GPIOCR_ALTC2] = {\ 358c2ecf20Sopenharmony_ci .used = altc2_used,\ 368c2ecf20Sopenharmony_ci .reg_index = altc2_ri,\ 378c2ecf20Sopenharmony_ci .control_bit = altc2_cb\ 388c2ecf20Sopenharmony_ci },\ 398c2ecf20Sopenharmony_ci .altcx[PRCM_IDX_GPIOCR_ALTC3] = {\ 408c2ecf20Sopenharmony_ci .used = altc3_used,\ 418c2ecf20Sopenharmony_ci .reg_index = altc3_ri,\ 428c2ecf20Sopenharmony_ci .control_bit = altc3_cb\ 438c2ecf20Sopenharmony_ci },\ 448c2ecf20Sopenharmony_ci .altcx[PRCM_IDX_GPIOCR_ALTC4] = {\ 458c2ecf20Sopenharmony_ci .used = altc4_used,\ 468c2ecf20Sopenharmony_ci .reg_index = altc4_ri,\ 478c2ecf20Sopenharmony_ci .control_bit = altc4_cb\ 488c2ecf20Sopenharmony_ci },\ 498c2ecf20Sopenharmony_ci} 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci/** 528c2ecf20Sopenharmony_ci * enum prcm_gpiocr_reg_index 538c2ecf20Sopenharmony_ci * Used to reference an PRCM GPIOCR register address. 548c2ecf20Sopenharmony_ci */ 558c2ecf20Sopenharmony_cienum prcm_gpiocr_reg_index { 568c2ecf20Sopenharmony_ci PRCM_IDX_GPIOCR1, 578c2ecf20Sopenharmony_ci PRCM_IDX_GPIOCR2, 588c2ecf20Sopenharmony_ci PRCM_IDX_GPIOCR3 598c2ecf20Sopenharmony_ci}; 608c2ecf20Sopenharmony_ci/** 618c2ecf20Sopenharmony_ci * enum prcm_gpiocr_altcx_index 628c2ecf20Sopenharmony_ci * Used to reference an Other alternate-C function. 638c2ecf20Sopenharmony_ci */ 648c2ecf20Sopenharmony_cienum prcm_gpiocr_altcx_index { 658c2ecf20Sopenharmony_ci PRCM_IDX_GPIOCR_ALTC1, 668c2ecf20Sopenharmony_ci PRCM_IDX_GPIOCR_ALTC2, 678c2ecf20Sopenharmony_ci PRCM_IDX_GPIOCR_ALTC3, 688c2ecf20Sopenharmony_ci PRCM_IDX_GPIOCR_ALTC4, 698c2ecf20Sopenharmony_ci PRCM_IDX_GPIOCR_ALTC_MAX, 708c2ecf20Sopenharmony_ci}; 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci/** 738c2ecf20Sopenharmony_ci * struct prcm_gpio_altcx - Other alternate-C function 748c2ecf20Sopenharmony_ci * @used: other alternate-C function availability 758c2ecf20Sopenharmony_ci * @reg_index: PRCM GPIOCR register index used to control the function 768c2ecf20Sopenharmony_ci * @control_bit: PRCM GPIOCR bit used to control the function 778c2ecf20Sopenharmony_ci */ 788c2ecf20Sopenharmony_cistruct prcm_gpiocr_altcx { 798c2ecf20Sopenharmony_ci bool used:1; 808c2ecf20Sopenharmony_ci u8 reg_index:2; 818c2ecf20Sopenharmony_ci u8 control_bit:5; 828c2ecf20Sopenharmony_ci} __packed; 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci/** 858c2ecf20Sopenharmony_ci * struct prcm_gpio_altcx_pin_desc - Other alternate-C pin 868c2ecf20Sopenharmony_ci * @pin: The pin number 878c2ecf20Sopenharmony_ci * @altcx: array of other alternate-C[1-4] functions 888c2ecf20Sopenharmony_ci */ 898c2ecf20Sopenharmony_cistruct prcm_gpiocr_altcx_pin_desc { 908c2ecf20Sopenharmony_ci unsigned short pin; 918c2ecf20Sopenharmony_ci struct prcm_gpiocr_altcx altcx[PRCM_IDX_GPIOCR_ALTC_MAX]; 928c2ecf20Sopenharmony_ci}; 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci/** 958c2ecf20Sopenharmony_ci * struct nmk_function - Nomadik pinctrl mux function 968c2ecf20Sopenharmony_ci * @name: The name of the function, exported to pinctrl core. 978c2ecf20Sopenharmony_ci * @groups: An array of pin groups that may select this function. 988c2ecf20Sopenharmony_ci * @ngroups: The number of entries in @groups. 998c2ecf20Sopenharmony_ci */ 1008c2ecf20Sopenharmony_cistruct nmk_function { 1018c2ecf20Sopenharmony_ci const char *name; 1028c2ecf20Sopenharmony_ci const char * const *groups; 1038c2ecf20Sopenharmony_ci unsigned ngroups; 1048c2ecf20Sopenharmony_ci}; 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci/** 1078c2ecf20Sopenharmony_ci * struct nmk_pingroup - describes a Nomadik pin group 1088c2ecf20Sopenharmony_ci * @name: the name of this specific pin group 1098c2ecf20Sopenharmony_ci * @pins: an array of discrete physical pins used in this group, taken 1108c2ecf20Sopenharmony_ci * from the driver-local pin enumeration space 1118c2ecf20Sopenharmony_ci * @num_pins: the number of pins in this group array, i.e. the number of 1128c2ecf20Sopenharmony_ci * elements in .pins so we can iterate over that array 1138c2ecf20Sopenharmony_ci * @altsetting: the altsetting to apply to all pins in this group to 1148c2ecf20Sopenharmony_ci * configure them to be used by a function 1158c2ecf20Sopenharmony_ci */ 1168c2ecf20Sopenharmony_cistruct nmk_pingroup { 1178c2ecf20Sopenharmony_ci const char *name; 1188c2ecf20Sopenharmony_ci const unsigned int *pins; 1198c2ecf20Sopenharmony_ci const unsigned npins; 1208c2ecf20Sopenharmony_ci int altsetting; 1218c2ecf20Sopenharmony_ci}; 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci/** 1248c2ecf20Sopenharmony_ci * struct nmk_pinctrl_soc_data - Nomadik pin controller per-SoC configuration 1258c2ecf20Sopenharmony_ci * @pins: An array describing all pins the pin controller affects. 1268c2ecf20Sopenharmony_ci * All pins which are also GPIOs must be listed first within the 1278c2ecf20Sopenharmony_ci * array, and be numbered identically to the GPIO controller's 1288c2ecf20Sopenharmony_ci * numbering. 1298c2ecf20Sopenharmony_ci * @npins: The number of entries in @pins. 1308c2ecf20Sopenharmony_ci * @functions: The functions supported on this SoC. 1318c2ecf20Sopenharmony_ci * @nfunction: The number of entries in @functions. 1328c2ecf20Sopenharmony_ci * @groups: An array describing all pin groups the pin SoC supports. 1338c2ecf20Sopenharmony_ci * @ngroups: The number of entries in @groups. 1348c2ecf20Sopenharmony_ci * @altcx_pins: The pins that support Other alternate-C function on this SoC 1358c2ecf20Sopenharmony_ci * @npins_altcx: The number of Other alternate-C pins 1368c2ecf20Sopenharmony_ci * @prcm_gpiocr_registers: The array of PRCM GPIOCR registers on this SoC 1378c2ecf20Sopenharmony_ci */ 1388c2ecf20Sopenharmony_cistruct nmk_pinctrl_soc_data { 1398c2ecf20Sopenharmony_ci const struct pinctrl_pin_desc *pins; 1408c2ecf20Sopenharmony_ci unsigned npins; 1418c2ecf20Sopenharmony_ci const struct nmk_function *functions; 1428c2ecf20Sopenharmony_ci unsigned nfunctions; 1438c2ecf20Sopenharmony_ci const struct nmk_pingroup *groups; 1448c2ecf20Sopenharmony_ci unsigned ngroups; 1458c2ecf20Sopenharmony_ci const struct prcm_gpiocr_altcx_pin_desc *altcx_pins; 1468c2ecf20Sopenharmony_ci unsigned npins_altcx; 1478c2ecf20Sopenharmony_ci const u16 *prcm_gpiocr_registers; 1488c2ecf20Sopenharmony_ci}; 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_ci#ifdef CONFIG_PINCTRL_STN8815 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_civoid nmk_pinctrl_stn8815_init(const struct nmk_pinctrl_soc_data **soc); 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci#else 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_cistatic inline void 1578c2ecf20Sopenharmony_cinmk_pinctrl_stn8815_init(const struct nmk_pinctrl_soc_data **soc) 1588c2ecf20Sopenharmony_ci{ 1598c2ecf20Sopenharmony_ci} 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_ci#endif 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_ci#ifdef CONFIG_PINCTRL_DB8500 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_civoid nmk_pinctrl_db8500_init(const struct nmk_pinctrl_soc_data **soc); 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci#else 1688c2ecf20Sopenharmony_ci 1698c2ecf20Sopenharmony_cistatic inline void 1708c2ecf20Sopenharmony_cinmk_pinctrl_db8500_init(const struct nmk_pinctrl_soc_data **soc) 1718c2ecf20Sopenharmony_ci{ 1728c2ecf20Sopenharmony_ci} 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci#endif 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ci#ifdef CONFIG_PINCTRL_DB8540 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_civoid nmk_pinctrl_db8540_init(const struct nmk_pinctrl_soc_data **soc); 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_ci#else 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_cistatic inline void 1838c2ecf20Sopenharmony_cinmk_pinctrl_db8540_init(const struct nmk_pinctrl_soc_data **soc) 1848c2ecf20Sopenharmony_ci{ 1858c2ecf20Sopenharmony_ci} 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ci#endif 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_ci#endif /* PINCTRL_PINCTRL_NOMADIK_H */ 190