18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) ST-Ericsson SA 2012 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Author: Patrice Chotard <patrice.chotard@stericsson.com> for ST-Ericsson. 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#include <linux/kernel.h> 98c2ecf20Sopenharmony_ci#include <linux/gpio/driver.h> 108c2ecf20Sopenharmony_ci#include <linux/pinctrl/pinctrl.h> 118c2ecf20Sopenharmony_ci#include <linux/mfd/abx500/ab8500.h> 128c2ecf20Sopenharmony_ci#include "pinctrl-abx500.h" 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci/* All the pins that can be used for GPIO and some other functions */ 158c2ecf20Sopenharmony_ci#define ABX500_GPIO(offset) (offset) 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#define AB8505_PIN_N4 ABX500_GPIO(1) 188c2ecf20Sopenharmony_ci#define AB8505_PIN_R5 ABX500_GPIO(2) 198c2ecf20Sopenharmony_ci#define AB8505_PIN_P5 ABX500_GPIO(3) 208c2ecf20Sopenharmony_ci/* hole */ 218c2ecf20Sopenharmony_ci#define AB8505_PIN_B16 ABX500_GPIO(10) 228c2ecf20Sopenharmony_ci#define AB8505_PIN_B17 ABX500_GPIO(11) 238c2ecf20Sopenharmony_ci/* hole */ 248c2ecf20Sopenharmony_ci#define AB8505_PIN_D17 ABX500_GPIO(13) 258c2ecf20Sopenharmony_ci#define AB8505_PIN_C16 ABX500_GPIO(14) 268c2ecf20Sopenharmony_ci/* hole */ 278c2ecf20Sopenharmony_ci#define AB8505_PIN_P2 ABX500_GPIO(17) 288c2ecf20Sopenharmony_ci#define AB8505_PIN_N3 ABX500_GPIO(18) 298c2ecf20Sopenharmony_ci#define AB8505_PIN_T1 ABX500_GPIO(19) 308c2ecf20Sopenharmony_ci#define AB8505_PIN_P3 ABX500_GPIO(20) 318c2ecf20Sopenharmony_ci/* hole */ 328c2ecf20Sopenharmony_ci#define AB8505_PIN_H14 ABX500_GPIO(34) 338c2ecf20Sopenharmony_ci/* hole */ 348c2ecf20Sopenharmony_ci#define AB8505_PIN_J15 ABX500_GPIO(40) 358c2ecf20Sopenharmony_ci#define AB8505_PIN_J14 ABX500_GPIO(41) 368c2ecf20Sopenharmony_ci/* hole */ 378c2ecf20Sopenharmony_ci#define AB8505_PIN_L4 ABX500_GPIO(50) 388c2ecf20Sopenharmony_ci/* hole */ 398c2ecf20Sopenharmony_ci#define AB8505_PIN_D16 ABX500_GPIO(52) 408c2ecf20Sopenharmony_ci#define AB8505_PIN_D15 ABX500_GPIO(53) 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci/* indicates the higher GPIO number */ 438c2ecf20Sopenharmony_ci#define AB8505_GPIO_MAX_NUMBER 53 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci/* 468c2ecf20Sopenharmony_ci * The names of the pins are denoted by GPIO number and ball name, even 478c2ecf20Sopenharmony_ci * though they can be used for other things than GPIO, this is the first 488c2ecf20Sopenharmony_ci * column in the table of the data sheet and often used on schematics and 498c2ecf20Sopenharmony_ci * such. 508c2ecf20Sopenharmony_ci */ 518c2ecf20Sopenharmony_cistatic const struct pinctrl_pin_desc ab8505_pins[] = { 528c2ecf20Sopenharmony_ci PINCTRL_PIN(AB8505_PIN_N4, "GPIO1_N4"), 538c2ecf20Sopenharmony_ci PINCTRL_PIN(AB8505_PIN_R5, "GPIO2_R5"), 548c2ecf20Sopenharmony_ci PINCTRL_PIN(AB8505_PIN_P5, "GPIO3_P5"), 558c2ecf20Sopenharmony_ci/* hole */ 568c2ecf20Sopenharmony_ci PINCTRL_PIN(AB8505_PIN_B16, "GPIO10_B16"), 578c2ecf20Sopenharmony_ci PINCTRL_PIN(AB8505_PIN_B17, "GPIO11_B17"), 588c2ecf20Sopenharmony_ci/* hole */ 598c2ecf20Sopenharmony_ci PINCTRL_PIN(AB8505_PIN_D17, "GPIO13_D17"), 608c2ecf20Sopenharmony_ci PINCTRL_PIN(AB8505_PIN_C16, "GPIO14_C16"), 618c2ecf20Sopenharmony_ci/* hole */ 628c2ecf20Sopenharmony_ci PINCTRL_PIN(AB8505_PIN_P2, "GPIO17_P2"), 638c2ecf20Sopenharmony_ci PINCTRL_PIN(AB8505_PIN_N3, "GPIO18_N3"), 648c2ecf20Sopenharmony_ci PINCTRL_PIN(AB8505_PIN_T1, "GPIO19_T1"), 658c2ecf20Sopenharmony_ci PINCTRL_PIN(AB8505_PIN_P3, "GPIO20_P3"), 668c2ecf20Sopenharmony_ci/* hole */ 678c2ecf20Sopenharmony_ci PINCTRL_PIN(AB8505_PIN_H14, "GPIO34_H14"), 688c2ecf20Sopenharmony_ci/* hole */ 698c2ecf20Sopenharmony_ci PINCTRL_PIN(AB8505_PIN_J15, "GPIO40_J15"), 708c2ecf20Sopenharmony_ci PINCTRL_PIN(AB8505_PIN_J14, "GPIO41_J14"), 718c2ecf20Sopenharmony_ci/* hole */ 728c2ecf20Sopenharmony_ci PINCTRL_PIN(AB8505_PIN_L4, "GPIO50_L4"), 738c2ecf20Sopenharmony_ci/* hole */ 748c2ecf20Sopenharmony_ci PINCTRL_PIN(AB8505_PIN_D16, "GPIO52_D16"), 758c2ecf20Sopenharmony_ci PINCTRL_PIN(AB8505_PIN_D15, "GPIO53_D15"), 768c2ecf20Sopenharmony_ci}; 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci/* 798c2ecf20Sopenharmony_ci * Maps local GPIO offsets to local pin numbers 808c2ecf20Sopenharmony_ci */ 818c2ecf20Sopenharmony_cistatic const struct abx500_pinrange ab8505_pinranges[] = { 828c2ecf20Sopenharmony_ci ABX500_PINRANGE(1, 3, ABX500_ALT_A), 838c2ecf20Sopenharmony_ci ABX500_PINRANGE(10, 2, ABX500_DEFAULT), 848c2ecf20Sopenharmony_ci ABX500_PINRANGE(13, 1, ABX500_DEFAULT), 858c2ecf20Sopenharmony_ci ABX500_PINRANGE(14, 1, ABX500_ALT_A), 868c2ecf20Sopenharmony_ci ABX500_PINRANGE(17, 4, ABX500_ALT_A), 878c2ecf20Sopenharmony_ci ABX500_PINRANGE(34, 1, ABX500_ALT_A), 888c2ecf20Sopenharmony_ci ABX500_PINRANGE(40, 2, ABX500_ALT_A), 898c2ecf20Sopenharmony_ci ABX500_PINRANGE(50, 1, ABX500_DEFAULT), 908c2ecf20Sopenharmony_ci ABX500_PINRANGE(52, 2, ABX500_ALT_A), 918c2ecf20Sopenharmony_ci}; 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci/* 948c2ecf20Sopenharmony_ci * Read the pin group names like this: 958c2ecf20Sopenharmony_ci * sysclkreq2_d_1 = first groups of pins for sysclkreq2 on default function 968c2ecf20Sopenharmony_ci * 978c2ecf20Sopenharmony_ci * The groups are arranged as sets per altfunction column, so we can 988c2ecf20Sopenharmony_ci * mux in one group at a time by selecting the same altfunction for them 998c2ecf20Sopenharmony_ci * all. When functions require pins on different altfunctions, you need 1008c2ecf20Sopenharmony_ci * to combine several groups. 1018c2ecf20Sopenharmony_ci */ 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci/* default column */ 1048c2ecf20Sopenharmony_cistatic const unsigned sysclkreq2_d_1_pins[] = { AB8505_PIN_N4 }; 1058c2ecf20Sopenharmony_cistatic const unsigned sysclkreq3_d_1_pins[] = { AB8505_PIN_R5 }; 1068c2ecf20Sopenharmony_cistatic const unsigned sysclkreq4_d_1_pins[] = { AB8505_PIN_P5 }; 1078c2ecf20Sopenharmony_cistatic const unsigned gpio10_d_1_pins[] = { AB8505_PIN_B16 }; 1088c2ecf20Sopenharmony_cistatic const unsigned gpio11_d_1_pins[] = { AB8505_PIN_B17 }; 1098c2ecf20Sopenharmony_cistatic const unsigned gpio13_d_1_pins[] = { AB8505_PIN_D17 }; 1108c2ecf20Sopenharmony_cistatic const unsigned pwmout1_d_1_pins[] = { AB8505_PIN_C16 }; 1118c2ecf20Sopenharmony_ci/* audio data interface 2*/ 1128c2ecf20Sopenharmony_cistatic const unsigned adi2_d_1_pins[] = { AB8505_PIN_P2, AB8505_PIN_N3, 1138c2ecf20Sopenharmony_ci AB8505_PIN_T1, AB8505_PIN_P3 }; 1148c2ecf20Sopenharmony_cistatic const unsigned extcpena_d_1_pins[] = { AB8505_PIN_H14 }; 1158c2ecf20Sopenharmony_ci/* modem SDA/SCL */ 1168c2ecf20Sopenharmony_cistatic const unsigned modsclsda_d_1_pins[] = { AB8505_PIN_J15, AB8505_PIN_J14 }; 1178c2ecf20Sopenharmony_cistatic const unsigned gpio50_d_1_pins[] = { AB8505_PIN_L4 }; 1188c2ecf20Sopenharmony_cistatic const unsigned resethw_d_1_pins[] = { AB8505_PIN_D16 }; 1198c2ecf20Sopenharmony_cistatic const unsigned service_d_1_pins[] = { AB8505_PIN_D15 }; 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ci/* Altfunction A column */ 1228c2ecf20Sopenharmony_cistatic const unsigned gpio1_a_1_pins[] = { AB8505_PIN_N4 }; 1238c2ecf20Sopenharmony_cistatic const unsigned gpio2_a_1_pins[] = { AB8505_PIN_R5 }; 1248c2ecf20Sopenharmony_cistatic const unsigned gpio3_a_1_pins[] = { AB8505_PIN_P5 }; 1258c2ecf20Sopenharmony_cistatic const unsigned hiqclkena_a_1_pins[] = { AB8505_PIN_B16 }; 1268c2ecf20Sopenharmony_cistatic const unsigned pdmclk_a_1_pins[] = { AB8505_PIN_B17 }; 1278c2ecf20Sopenharmony_cistatic const unsigned uarttxdata_a_1_pins[] = { AB8505_PIN_D17 }; 1288c2ecf20Sopenharmony_cistatic const unsigned gpio14_a_1_pins[] = { AB8505_PIN_C16 }; 1298c2ecf20Sopenharmony_cistatic const unsigned gpio17_a_1_pins[] = { AB8505_PIN_P2 }; 1308c2ecf20Sopenharmony_cistatic const unsigned gpio18_a_1_pins[] = { AB8505_PIN_N3 }; 1318c2ecf20Sopenharmony_cistatic const unsigned gpio19_a_1_pins[] = { AB8505_PIN_T1 }; 1328c2ecf20Sopenharmony_cistatic const unsigned gpio20_a_1_pins[] = { AB8505_PIN_P3 }; 1338c2ecf20Sopenharmony_cistatic const unsigned gpio34_a_1_pins[] = { AB8505_PIN_H14 }; 1348c2ecf20Sopenharmony_cistatic const unsigned gpio40_a_1_pins[] = { AB8505_PIN_J15 }; 1358c2ecf20Sopenharmony_cistatic const unsigned gpio41_a_1_pins[] = { AB8505_PIN_J14 }; 1368c2ecf20Sopenharmony_cistatic const unsigned uartrxdata_a_1_pins[] = { AB8505_PIN_J14 }; 1378c2ecf20Sopenharmony_cistatic const unsigned gpio50_a_1_pins[] = { AB8505_PIN_L4 }; 1388c2ecf20Sopenharmony_cistatic const unsigned gpio52_a_1_pins[] = { AB8505_PIN_D16 }; 1398c2ecf20Sopenharmony_cistatic const unsigned gpio53_a_1_pins[] = { AB8505_PIN_D15 }; 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci/* Altfunction B colum */ 1428c2ecf20Sopenharmony_cistatic const unsigned pdmdata_b_1_pins[] = { AB8505_PIN_B16 }; 1438c2ecf20Sopenharmony_cistatic const unsigned extvibrapwm1_b_1_pins[] = { AB8505_PIN_D17 }; 1448c2ecf20Sopenharmony_cistatic const unsigned extvibrapwm2_b_1_pins[] = { AB8505_PIN_L4 }; 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci/* Altfunction C column */ 1478c2ecf20Sopenharmony_cistatic const unsigned usbvdat_c_1_pins[] = { AB8505_PIN_D17 }; 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci#define AB8505_PIN_GROUP(a, b) { .name = #a, .pins = a##_pins, \ 1508c2ecf20Sopenharmony_ci .npins = ARRAY_SIZE(a##_pins), .altsetting = b } 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_cistatic const struct abx500_pingroup ab8505_groups[] = { 1538c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(sysclkreq2_d_1, ABX500_DEFAULT), 1548c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(sysclkreq3_d_1, ABX500_DEFAULT), 1558c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(sysclkreq4_d_1, ABX500_DEFAULT), 1568c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(gpio10_d_1, ABX500_DEFAULT), 1578c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(gpio11_d_1, ABX500_DEFAULT), 1588c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(gpio13_d_1, ABX500_DEFAULT), 1598c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(pwmout1_d_1, ABX500_DEFAULT), 1608c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(adi2_d_1, ABX500_DEFAULT), 1618c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(extcpena_d_1, ABX500_DEFAULT), 1628c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(modsclsda_d_1, ABX500_DEFAULT), 1638c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(gpio50_d_1, ABX500_DEFAULT), 1648c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(resethw_d_1, ABX500_DEFAULT), 1658c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(service_d_1, ABX500_DEFAULT), 1668c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(gpio1_a_1, ABX500_ALT_A), 1678c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(gpio2_a_1, ABX500_ALT_A), 1688c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(gpio3_a_1, ABX500_ALT_A), 1698c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(hiqclkena_a_1, ABX500_ALT_A), 1708c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(pdmclk_a_1, ABX500_ALT_A), 1718c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(uarttxdata_a_1, ABX500_ALT_A), 1728c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(gpio14_a_1, ABX500_ALT_A), 1738c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(gpio17_a_1, ABX500_ALT_A), 1748c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(gpio18_a_1, ABX500_ALT_A), 1758c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(gpio19_a_1, ABX500_ALT_A), 1768c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(gpio20_a_1, ABX500_ALT_A), 1778c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(gpio34_a_1, ABX500_ALT_A), 1788c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(gpio40_a_1, ABX500_ALT_A), 1798c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(gpio41_a_1, ABX500_ALT_A), 1808c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(uartrxdata_a_1, ABX500_ALT_A), 1818c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(gpio50_a_1, ABX500_ALT_A), 1828c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(gpio52_a_1, ABX500_ALT_A), 1838c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(gpio53_a_1, ABX500_ALT_A), 1848c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(pdmdata_b_1, ABX500_ALT_B), 1858c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(extvibrapwm1_b_1, ABX500_ALT_B), 1868c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(extvibrapwm2_b_1, ABX500_ALT_B), 1878c2ecf20Sopenharmony_ci AB8505_PIN_GROUP(usbvdat_c_1, ABX500_ALT_C), 1888c2ecf20Sopenharmony_ci}; 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_ci/* We use this macro to define the groups applicable to a function */ 1918c2ecf20Sopenharmony_ci#define AB8505_FUNC_GROUPS(a, b...) \ 1928c2ecf20Sopenharmony_cistatic const char * const a##_groups[] = { b }; 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_ciAB8505_FUNC_GROUPS(sysclkreq, "sysclkreq2_d_1", "sysclkreq3_d_1", 1958c2ecf20Sopenharmony_ci "sysclkreq4_d_1"); 1968c2ecf20Sopenharmony_ciAB8505_FUNC_GROUPS(gpio, "gpio1_a_1", "gpio2_a_1", "gpio3_a_1", 1978c2ecf20Sopenharmony_ci "gpio10_d_1", "gpio11_d_1", "gpio13_d_1", "gpio14_a_1", 1988c2ecf20Sopenharmony_ci "gpio17_a_1", "gpio18_a_1", "gpio19_a_1", "gpio20_a_1", 1998c2ecf20Sopenharmony_ci "gpio34_a_1", "gpio40_a_1", "gpio41_a_1", "gpio50_d_1", 2008c2ecf20Sopenharmony_ci "gpio52_a_1", "gpio53_a_1"); 2018c2ecf20Sopenharmony_ciAB8505_FUNC_GROUPS(pwmout, "pwmout1_d_1"); 2028c2ecf20Sopenharmony_ciAB8505_FUNC_GROUPS(adi2, "adi2_d_1"); 2038c2ecf20Sopenharmony_ciAB8505_FUNC_GROUPS(extcpena, "extcpena_d_1"); 2048c2ecf20Sopenharmony_ciAB8505_FUNC_GROUPS(modsclsda, "modsclsda_d_1"); 2058c2ecf20Sopenharmony_ciAB8505_FUNC_GROUPS(resethw, "resethw_d_1"); 2068c2ecf20Sopenharmony_ciAB8505_FUNC_GROUPS(service, "service_d_1"); 2078c2ecf20Sopenharmony_ciAB8505_FUNC_GROUPS(hiqclkena, "hiqclkena_a_1"); 2088c2ecf20Sopenharmony_ciAB8505_FUNC_GROUPS(pdm, "pdmclk_a_1", "pdmdata_b_1"); 2098c2ecf20Sopenharmony_ciAB8505_FUNC_GROUPS(uartdata, "uarttxdata_a_1", "uartrxdata_a_1"); 2108c2ecf20Sopenharmony_ciAB8505_FUNC_GROUPS(extvibra, "extvibrapwm1_b_1", "extvibrapwm2_b_1"); 2118c2ecf20Sopenharmony_ciAB8505_FUNC_GROUPS(usbvdat, "usbvdat_c_1"); 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci#define FUNCTION(fname) \ 2148c2ecf20Sopenharmony_ci { \ 2158c2ecf20Sopenharmony_ci .name = #fname, \ 2168c2ecf20Sopenharmony_ci .groups = fname##_groups, \ 2178c2ecf20Sopenharmony_ci .ngroups = ARRAY_SIZE(fname##_groups), \ 2188c2ecf20Sopenharmony_ci } 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_cistatic const struct abx500_function ab8505_functions[] = { 2218c2ecf20Sopenharmony_ci FUNCTION(sysclkreq), 2228c2ecf20Sopenharmony_ci FUNCTION(gpio), 2238c2ecf20Sopenharmony_ci FUNCTION(pwmout), 2248c2ecf20Sopenharmony_ci FUNCTION(adi2), 2258c2ecf20Sopenharmony_ci FUNCTION(extcpena), 2268c2ecf20Sopenharmony_ci FUNCTION(modsclsda), 2278c2ecf20Sopenharmony_ci FUNCTION(resethw), 2288c2ecf20Sopenharmony_ci FUNCTION(service), 2298c2ecf20Sopenharmony_ci FUNCTION(hiqclkena), 2308c2ecf20Sopenharmony_ci FUNCTION(pdm), 2318c2ecf20Sopenharmony_ci FUNCTION(uartdata), 2328c2ecf20Sopenharmony_ci FUNCTION(extvibra), 2338c2ecf20Sopenharmony_ci FUNCTION(extvibra), 2348c2ecf20Sopenharmony_ci FUNCTION(usbvdat), 2358c2ecf20Sopenharmony_ci}; 2368c2ecf20Sopenharmony_ci 2378c2ecf20Sopenharmony_ci/* 2388c2ecf20Sopenharmony_ci * this table translates what's is in the AB8505 specification regarding the 2398c2ecf20Sopenharmony_ci * balls alternate functions (as for DB, default, ALT_A, ALT_B and ALT_C). 2408c2ecf20Sopenharmony_ci * ALTERNATE_FUNCTIONS(GPIO_NUMBER, GPIOSEL bit, ALTERNATFUNC bit1, 2418c2ecf20Sopenharmony_ci * ALTERNATEFUNC bit2, ALTA val, ALTB val, ALTC val), 2428c2ecf20Sopenharmony_ci * 2438c2ecf20Sopenharmony_ci * example : 2448c2ecf20Sopenharmony_ci * 2458c2ecf20Sopenharmony_ci * ALTERNATE_FUNCTIONS(13, 4, 3, 4, 1, 0, 2), 2468c2ecf20Sopenharmony_ci * means that pin AB8505_PIN_D18 (pin 13) supports 4 mux (default/ALT_A, 2478c2ecf20Sopenharmony_ci * ALT_B and ALT_C), so GPIOSEL and ALTERNATFUNC registers are used to 2488c2ecf20Sopenharmony_ci * select the mux. ALTA, ALTB and ALTC val indicates values to write in 2498c2ecf20Sopenharmony_ci * ALTERNATFUNC register. We need to specifies these values as SOC 2508c2ecf20Sopenharmony_ci * designers didn't apply the same logic on how to select mux in the 2518c2ecf20Sopenharmony_ci * ABx500 family. 2528c2ecf20Sopenharmony_ci * 2538c2ecf20Sopenharmony_ci * As this pins supports at least ALT_B mux, default mux is 2548c2ecf20Sopenharmony_ci * selected by writing 1 in GPIOSEL bit : 2558c2ecf20Sopenharmony_ci * 2568c2ecf20Sopenharmony_ci * | GPIOSEL bit=4 | alternatfunc bit2=4 | alternatfunc bit1=3 2578c2ecf20Sopenharmony_ci * default | 1 | 0 | 0 2588c2ecf20Sopenharmony_ci * alt_A | 0 | 0 | 1 2598c2ecf20Sopenharmony_ci * alt_B | 0 | 0 | 0 2608c2ecf20Sopenharmony_ci * alt_C | 0 | 1 | 0 2618c2ecf20Sopenharmony_ci * 2628c2ecf20Sopenharmony_ci * ALTERNATE_FUNCTIONS(1, 0, UNUSED, UNUSED), 2638c2ecf20Sopenharmony_ci * means that pin AB9540_PIN_R4 (pin 1) supports 2 mux, so only GPIOSEL 2648c2ecf20Sopenharmony_ci * register is used to select the mux. As this pins doesn't support at 2658c2ecf20Sopenharmony_ci * least ALT_B mux, default mux is by writing 0 in GPIOSEL bit : 2668c2ecf20Sopenharmony_ci * 2678c2ecf20Sopenharmony_ci * | GPIOSEL bit=0 | alternatfunc bit2= | alternatfunc bit1= 2688c2ecf20Sopenharmony_ci * default | 0 | 0 | 0 2698c2ecf20Sopenharmony_ci * alt_A | 1 | 0 | 0 2708c2ecf20Sopenharmony_ci */ 2718c2ecf20Sopenharmony_ci 2728c2ecf20Sopenharmony_cistatic struct 2738c2ecf20Sopenharmony_cialternate_functions ab8505_alternate_functions[AB8505_GPIO_MAX_NUMBER + 1] = { 2748c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(0, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO0 */ 2758c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(1, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO1, altA controlled by bit 0 */ 2768c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(2, 1, UNUSED, UNUSED, 0, 0, 0), /* GPIO2, altA controlled by bit 1 */ 2778c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(3, 2, UNUSED, UNUSED, 0, 0, 0), /* GPIO3, altA controlled by bit 2*/ 2788c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(4, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO4, bit 3 reserved */ 2798c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(5, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO5, bit 4 reserved */ 2808c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(6, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO6, bit 5 reserved */ 2818c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(7, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO7, bit 6 reserved */ 2828c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(8, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO8, bit 7 reserved */ 2838c2ecf20Sopenharmony_ci 2848c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(9, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO9, bit 0 reserved */ 2858c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(10, 1, 0, UNUSED, 1, 0, 0), /* GPIO10, altA and altB controlled by bit 0 */ 2868c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(11, 2, 1, UNUSED, 0, 0, 0), /* GPIO11, altA controlled by bit 2 */ 2878c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(12, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO12, bit3 reserved */ 2888c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(13, 4, 3, 4, 1, 0, 2), /* GPIO13, altA altB and altC controlled by bit 3 and 4 */ 2898c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(14, 5, UNUSED, UNUSED, 0, 0, 0), /* GPIO14, altA controlled by bit 5 */ 2908c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(15, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO15, bit 6 reserved */ 2918c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(16, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO15, bit 7 reserved */ 2928c2ecf20Sopenharmony_ci /* 2938c2ecf20Sopenharmony_ci * pins 17 to 20 are special case, only bit 0 is used to select 2948c2ecf20Sopenharmony_ci * alternate function for these 4 pins. 2958c2ecf20Sopenharmony_ci * bits 1 to 3 are reserved 2968c2ecf20Sopenharmony_ci */ 2978c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(17, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO17, altA controlled by bit 0 */ 2988c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(18, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO18, altA controlled by bit 0 */ 2998c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(19, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO19, altA controlled by bit 0 */ 3008c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(20, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO20, altA controlled by bit 0 */ 3018c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(21, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO21, bit 4 reserved */ 3028c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(22, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO22, bit 5 reserved */ 3038c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(23, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO23, bit 6 reserved */ 3048c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(24, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO24, bit 7 reserved */ 3058c2ecf20Sopenharmony_ci 3068c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(25, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO25, bit 0 reserved */ 3078c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(26, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO26, bit 1 reserved */ 3088c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(27, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO27, bit 2 reserved */ 3098c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(28, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO28, bit 3 reserved */ 3108c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(29, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO29, bit 4 reserved */ 3118c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(30, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO30, bit 5 reserved */ 3128c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(31, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO31, bit 6 reserved */ 3138c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(32, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO32, bit 7 reserved */ 3148c2ecf20Sopenharmony_ci 3158c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(33, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO33, bit 0 reserved */ 3168c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(34, 1, UNUSED, UNUSED, 0, 0, 0), /* GPIO34, altA controlled by bit 1 */ 3178c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(35, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO35, bit 2 reserved */ 3188c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(36, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO36, bit 2 reserved */ 3198c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(37, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO37, bit 2 reserved */ 3208c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(38, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO38, bit 2 reserved */ 3218c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(39, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO39, bit 2 reserved */ 3228c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(40, 7, UNUSED, UNUSED, 0, 0, 0), /* GPIO40, altA controlled by bit 7*/ 3238c2ecf20Sopenharmony_ci 3248c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(41, 0, UNUSED, UNUSED, 0, 0, 0), /* GPIO41, altA controlled by bit 0 */ 3258c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(42, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO42, bit 1 reserved */ 3268c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(43, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO43, bit 2 reserved */ 3278c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(44, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO44, bit 3 reserved */ 3288c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(45, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO45, bit 4 reserved */ 3298c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(46, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO46, bit 5 reserved */ 3308c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(47, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO47, bit 6 reserved */ 3318c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(48, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO48, bit 7 reserved */ 3328c2ecf20Sopenharmony_ci 3338c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(49, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO49, bit 0 reserved */ 3348c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(50, 1, 2, UNUSED, 1, 0, 0), /* GPIO50, altA controlled by bit 1 */ 3358c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(51, UNUSED, UNUSED, UNUSED, 0, 0, 0), /* no GPIO49, bit 0 reserved */ 3368c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(52, 3, UNUSED, UNUSED, 0, 0, 0), /* GPIO52, altA controlled by bit 3 */ 3378c2ecf20Sopenharmony_ci ALTERNATE_FUNCTIONS(53, 4, UNUSED, UNUSED, 0, 0, 0), /* GPIO53, altA controlled by bit 4 */ 3388c2ecf20Sopenharmony_ci}; 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_ci/* 3418c2ecf20Sopenharmony_ci * For AB8505 Only some GPIOs are interrupt capable, and they are 3428c2ecf20Sopenharmony_ci * organized in discontiguous clusters: 3438c2ecf20Sopenharmony_ci * 3448c2ecf20Sopenharmony_ci * GPIO10 to GPIO11 3458c2ecf20Sopenharmony_ci * GPIO13 3468c2ecf20Sopenharmony_ci * GPIO40 and GPIO41 3478c2ecf20Sopenharmony_ci * GPIO50 3488c2ecf20Sopenharmony_ci * GPIO52 to GPIO53 3498c2ecf20Sopenharmony_ci */ 3508c2ecf20Sopenharmony_cistatic struct abx500_gpio_irq_cluster ab8505_gpio_irq_cluster[] = { 3518c2ecf20Sopenharmony_ci GPIO_IRQ_CLUSTER(10, 11, AB8500_INT_GPIO10R), 3528c2ecf20Sopenharmony_ci GPIO_IRQ_CLUSTER(13, 13, AB8500_INT_GPIO13R), 3538c2ecf20Sopenharmony_ci GPIO_IRQ_CLUSTER(40, 41, AB8500_INT_GPIO40R), 3548c2ecf20Sopenharmony_ci GPIO_IRQ_CLUSTER(50, 50, AB9540_INT_GPIO50R), 3558c2ecf20Sopenharmony_ci GPIO_IRQ_CLUSTER(52, 53, AB9540_INT_GPIO52R), 3568c2ecf20Sopenharmony_ci}; 3578c2ecf20Sopenharmony_ci 3588c2ecf20Sopenharmony_cistatic struct abx500_pinctrl_soc_data ab8505_soc = { 3598c2ecf20Sopenharmony_ci .gpio_ranges = ab8505_pinranges, 3608c2ecf20Sopenharmony_ci .gpio_num_ranges = ARRAY_SIZE(ab8505_pinranges), 3618c2ecf20Sopenharmony_ci .pins = ab8505_pins, 3628c2ecf20Sopenharmony_ci .npins = ARRAY_SIZE(ab8505_pins), 3638c2ecf20Sopenharmony_ci .functions = ab8505_functions, 3648c2ecf20Sopenharmony_ci .nfunctions = ARRAY_SIZE(ab8505_functions), 3658c2ecf20Sopenharmony_ci .groups = ab8505_groups, 3668c2ecf20Sopenharmony_ci .ngroups = ARRAY_SIZE(ab8505_groups), 3678c2ecf20Sopenharmony_ci .alternate_functions = ab8505_alternate_functions, 3688c2ecf20Sopenharmony_ci .gpio_irq_cluster = ab8505_gpio_irq_cluster, 3698c2ecf20Sopenharmony_ci .ngpio_irq_cluster = ARRAY_SIZE(ab8505_gpio_irq_cluster), 3708c2ecf20Sopenharmony_ci .irq_gpio_rising_offset = AB8500_INT_GPIO6R, 3718c2ecf20Sopenharmony_ci .irq_gpio_falling_offset = AB8500_INT_GPIO6F, 3728c2ecf20Sopenharmony_ci .irq_gpio_factor = 1, 3738c2ecf20Sopenharmony_ci}; 3748c2ecf20Sopenharmony_ci 3758c2ecf20Sopenharmony_civoid 3768c2ecf20Sopenharmony_ciabx500_pinctrl_ab8505_init(struct abx500_pinctrl_soc_data **soc) 3778c2ecf20Sopenharmony_ci{ 3788c2ecf20Sopenharmony_ci *soc = &ab8505_soc; 3798c2ecf20Sopenharmony_ci} 380