1e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij#ifndef PINCTRL_PINCTRL_NOMADIK_H 2e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij#define PINCTRL_PINCTRL_NOMADIK_H 3e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij 4e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij/* Package definitions */ 5e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij#define PINCTRL_NMK_STN8815 0 6e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij#define PINCTRL_NMK_DB8500 1 745a1b53195069f53d5cbdbfff5e5fed97004320bPatrice Chotard#define PINCTRL_NMK_DB8540 2 8e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij 98d99339710ac9bd1eca8f04a356752c89dc7cf0bLinus Walleij/* Alternate functions: function C is set in hw by setting both A and B */ 108d99339710ac9bd1eca8f04a356752c89dc7cf0bLinus Walleij#define NMK_GPIO_ALT_GPIO 0 118d99339710ac9bd1eca8f04a356752c89dc7cf0bLinus Walleij#define NMK_GPIO_ALT_A 1 128d99339710ac9bd1eca8f04a356752c89dc7cf0bLinus Walleij#define NMK_GPIO_ALT_B 2 138d99339710ac9bd1eca8f04a356752c89dc7cf0bLinus Walleij#define NMK_GPIO_ALT_C (NMK_GPIO_ALT_A | NMK_GPIO_ALT_B) 148d99339710ac9bd1eca8f04a356752c89dc7cf0bLinus Walleij 158d99339710ac9bd1eca8f04a356752c89dc7cf0bLinus Walleij#define NMK_GPIO_ALT_CX_SHIFT 2 168d99339710ac9bd1eca8f04a356752c89dc7cf0bLinus Walleij#define NMK_GPIO_ALT_C1 ((1<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C) 178d99339710ac9bd1eca8f04a356752c89dc7cf0bLinus Walleij#define NMK_GPIO_ALT_C2 ((2<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C) 188d99339710ac9bd1eca8f04a356752c89dc7cf0bLinus Walleij#define NMK_GPIO_ALT_C3 ((3<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C) 198d99339710ac9bd1eca8f04a356752c89dc7cf0bLinus Walleij#define NMK_GPIO_ALT_C4 ((4<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C) 208d99339710ac9bd1eca8f04a356752c89dc7cf0bLinus Walleij 21c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux#define PRCM_GPIOCR_ALTCX(pin_num,\ 22c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux altc1_used, altc1_ri, altc1_cb,\ 23c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux altc2_used, altc2_ri, altc2_cb,\ 24c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux altc3_used, altc3_ri, altc3_cb,\ 25c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux altc4_used, altc4_ri, altc4_cb)\ 26c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux{\ 27c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux .pin = pin_num,\ 28c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux .altcx[PRCM_IDX_GPIOCR_ALTC1] = {\ 29c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux .used = altc1_used,\ 30c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux .reg_index = altc1_ri,\ 31c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux .control_bit = altc1_cb\ 32c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux },\ 33c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux .altcx[PRCM_IDX_GPIOCR_ALTC2] = {\ 34c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux .used = altc2_used,\ 35c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux .reg_index = altc2_ri,\ 36c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux .control_bit = altc2_cb\ 37c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux },\ 38c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux .altcx[PRCM_IDX_GPIOCR_ALTC3] = {\ 39c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux .used = altc3_used,\ 40c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux .reg_index = altc3_ri,\ 41c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux .control_bit = altc3_cb\ 42c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux },\ 43c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux .altcx[PRCM_IDX_GPIOCR_ALTC4] = {\ 44c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux .used = altc4_used,\ 45c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux .reg_index = altc4_ri,\ 46c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux .control_bit = altc4_cb\ 47c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux },\ 48c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux} 49c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux 50c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux/** 51c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux * enum prcm_gpiocr_reg_index 52c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux * Used to reference an PRCM GPIOCR register address. 53c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux */ 54c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Grauxenum prcm_gpiocr_reg_index { 55c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux PRCM_IDX_GPIOCR1, 56c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux PRCM_IDX_GPIOCR2, 57c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux PRCM_IDX_GPIOCR3 58c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux}; 59c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux/** 60c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux * enum prcm_gpiocr_altcx_index 61c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux * Used to reference an Other alternate-C function. 62c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux */ 63c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Grauxenum prcm_gpiocr_altcx_index { 64c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux PRCM_IDX_GPIOCR_ALTC1, 65c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux PRCM_IDX_GPIOCR_ALTC2, 66c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux PRCM_IDX_GPIOCR_ALTC3, 67c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux PRCM_IDX_GPIOCR_ALTC4, 68c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux PRCM_IDX_GPIOCR_ALTC_MAX, 69c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux}; 70c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux 71c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux/** 72c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux * struct prcm_gpio_altcx - Other alternate-C function 73c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux * @used: other alternate-C function availability 74c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux * @reg_index: PRCM GPIOCR register index used to control the function 75c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux * @control_bit: PRCM GPIOCR bit used to control the function 76c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux */ 77c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Grauxstruct prcm_gpiocr_altcx { 78c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux bool used:1; 79c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux u8 reg_index:2; 80c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux u8 control_bit:5; 81c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux} __packed; 82c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux 83c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux/** 84c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux * struct prcm_gpio_altcx_pin_desc - Other alternate-C pin 85c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux * @pin: The pin number 86c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux * @altcx: array of other alternate-C[1-4] functions 87c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux */ 88c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Grauxstruct prcm_gpiocr_altcx_pin_desc { 89c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux unsigned short pin; 90c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux struct prcm_gpiocr_altcx altcx[PRCM_IDX_GPIOCR_ALTC_MAX]; 91c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux}; 92c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux 93e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij/** 94dbfe8ca259e1f899ca02ea33d903fa21bbea67c5Linus Walleij * struct nmk_function - Nomadik pinctrl mux function 95dbfe8ca259e1f899ca02ea33d903fa21bbea67c5Linus Walleij * @name: The name of the function, exported to pinctrl core. 96dbfe8ca259e1f899ca02ea33d903fa21bbea67c5Linus Walleij * @groups: An array of pin groups that may select this function. 97dbfe8ca259e1f899ca02ea33d903fa21bbea67c5Linus Walleij * @ngroups: The number of entries in @groups. 98dbfe8ca259e1f899ca02ea33d903fa21bbea67c5Linus Walleij */ 99dbfe8ca259e1f899ca02ea33d903fa21bbea67c5Linus Walleijstruct nmk_function { 100dbfe8ca259e1f899ca02ea33d903fa21bbea67c5Linus Walleij const char *name; 101dbfe8ca259e1f899ca02ea33d903fa21bbea67c5Linus Walleij const char * const *groups; 102dbfe8ca259e1f899ca02ea33d903fa21bbea67c5Linus Walleij unsigned ngroups; 103dbfe8ca259e1f899ca02ea33d903fa21bbea67c5Linus Walleij}; 104dbfe8ca259e1f899ca02ea33d903fa21bbea67c5Linus Walleij 105dbfe8ca259e1f899ca02ea33d903fa21bbea67c5Linus Walleij/** 106e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij * struct nmk_pingroup - describes a Nomadik pin group 107e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij * @name: the name of this specific pin group 108e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij * @pins: an array of discrete physical pins used in this group, taken 109e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij * from the driver-local pin enumeration space 110e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij * @num_pins: the number of pins in this group array, i.e. the number of 111e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij * elements in .pins so we can iterate over that array 112e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij * @altsetting: the altsetting to apply to all pins in this group to 113e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij * configure them to be used by a function 114e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij */ 115e98ea774c8d210364379329f042e7596f83ecc58Linus Walleijstruct nmk_pingroup { 116e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij const char *name; 117e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij const unsigned int *pins; 118e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij const unsigned npins; 119dbfe8ca259e1f899ca02ea33d903fa21bbea67c5Linus Walleij int altsetting; 120e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij}; 121e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij 122e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij/** 123e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij * struct nmk_pinctrl_soc_data - Nomadik pin controller per-SoC configuration 124e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij * @gpio_ranges: An array of GPIO ranges for this SoC 125e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij * @gpio_num_ranges: The number of GPIO ranges for this SoC 126e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij * @pins: An array describing all pins the pin controller affects. 127e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij * All pins which are also GPIOs must be listed first within the 128e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij * array, and be numbered identically to the GPIO controller's 129e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij * numbering. 130dbfe8ca259e1f899ca02ea33d903fa21bbea67c5Linus Walleij * @npins: The number of entries in @pins. 131dbfe8ca259e1f899ca02ea33d903fa21bbea67c5Linus Walleij * @functions: The functions supported on this SoC. 132dbfe8ca259e1f899ca02ea33d903fa21bbea67c5Linus Walleij * @nfunction: The number of entries in @functions. 133e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij * @groups: An array describing all pin groups the pin SoC supports. 134e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij * @ngroups: The number of entries in @groups. 135c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux * @altcx_pins: The pins that support Other alternate-C function on this SoC 136c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux * @npins_altcx: The number of Other alternate-C pins 137c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux * @prcm_gpiocr_registers: The array of PRCM GPIOCR registers on this SoC 138e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij */ 139e98ea774c8d210364379329f042e7596f83ecc58Linus Walleijstruct nmk_pinctrl_soc_data { 140e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij struct pinctrl_gpio_range *gpio_ranges; 141e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij unsigned gpio_num_ranges; 142e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij const struct pinctrl_pin_desc *pins; 143e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij unsigned npins; 144dbfe8ca259e1f899ca02ea33d903fa21bbea67c5Linus Walleij const struct nmk_function *functions; 145dbfe8ca259e1f899ca02ea33d903fa21bbea67c5Linus Walleij unsigned nfunctions; 146e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij const struct nmk_pingroup *groups; 147e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij unsigned ngroups; 148c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux const struct prcm_gpiocr_altcx_pin_desc *altcx_pins; 149c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux unsigned npins_altcx; 150c22df08c7ffbfb281b0e5dff3fff4e192d1a7863Jean-Nicolas Graux const u16 *prcm_gpiocr_registers; 151e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij}; 152e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij 153f79c5ed9dab3ae80f6cbe9edaafbc8a4dadb8408Linus Walleij#ifdef CONFIG_PINCTRL_STN8815 154f79c5ed9dab3ae80f6cbe9edaafbc8a4dadb8408Linus Walleij 155f79c5ed9dab3ae80f6cbe9edaafbc8a4dadb8408Linus Walleijvoid nmk_pinctrl_stn8815_init(const struct nmk_pinctrl_soc_data **soc); 156f79c5ed9dab3ae80f6cbe9edaafbc8a4dadb8408Linus Walleij 157f79c5ed9dab3ae80f6cbe9edaafbc8a4dadb8408Linus Walleij#else 158f79c5ed9dab3ae80f6cbe9edaafbc8a4dadb8408Linus Walleij 159f79c5ed9dab3ae80f6cbe9edaafbc8a4dadb8408Linus Walleijstatic inline void 160f79c5ed9dab3ae80f6cbe9edaafbc8a4dadb8408Linus Walleijnmk_pinctrl_stn8815_init(const struct nmk_pinctrl_soc_data **soc) 161f79c5ed9dab3ae80f6cbe9edaafbc8a4dadb8408Linus Walleij{ 162f79c5ed9dab3ae80f6cbe9edaafbc8a4dadb8408Linus Walleij} 163f79c5ed9dab3ae80f6cbe9edaafbc8a4dadb8408Linus Walleij 164f79c5ed9dab3ae80f6cbe9edaafbc8a4dadb8408Linus Walleij#endif 165f79c5ed9dab3ae80f6cbe9edaafbc8a4dadb8408Linus Walleij 166e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij#ifdef CONFIG_PINCTRL_DB8500 167e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij 168e98ea774c8d210364379329f042e7596f83ecc58Linus Walleijvoid nmk_pinctrl_db8500_init(const struct nmk_pinctrl_soc_data **soc); 169e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij 170e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij#else 171e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij 172e98ea774c8d210364379329f042e7596f83ecc58Linus Walleijstatic inline void 173e98ea774c8d210364379329f042e7596f83ecc58Linus Walleijnmk_pinctrl_db8500_init(const struct nmk_pinctrl_soc_data **soc) 174e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij{ 175e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij} 176e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij 177e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij#endif 178e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij 17945a1b53195069f53d5cbdbfff5e5fed97004320bPatrice Chotard#ifdef CONFIG_PINCTRL_DB8540 18045a1b53195069f53d5cbdbfff5e5fed97004320bPatrice Chotard 18145a1b53195069f53d5cbdbfff5e5fed97004320bPatrice Chotardvoid nmk_pinctrl_db8540_init(const struct nmk_pinctrl_soc_data **soc); 18245a1b53195069f53d5cbdbfff5e5fed97004320bPatrice Chotard 18345a1b53195069f53d5cbdbfff5e5fed97004320bPatrice Chotard#else 18445a1b53195069f53d5cbdbfff5e5fed97004320bPatrice Chotard 18545a1b53195069f53d5cbdbfff5e5fed97004320bPatrice Chotardstatic inline void 18645a1b53195069f53d5cbdbfff5e5fed97004320bPatrice Chotardnmk_pinctrl_db8540_init(const struct nmk_pinctrl_soc_data **soc) 18745a1b53195069f53d5cbdbfff5e5fed97004320bPatrice Chotard{ 18845a1b53195069f53d5cbdbfff5e5fed97004320bPatrice Chotard} 18945a1b53195069f53d5cbdbfff5e5fed97004320bPatrice Chotard 19045a1b53195069f53d5cbdbfff5e5fed97004320bPatrice Chotard#endif 19145a1b53195069f53d5cbdbfff5e5fed97004320bPatrice Chotard 192e98ea774c8d210364379329f042e7596f83ecc58Linus Walleij#endif /* PINCTRL_PINCTRL_NOMADIK_H */ 193