1155cca1bSÁlvaro Fernández Rojas // SPDX-License-Identifier: GPL-2.0+ 2155cca1bSÁlvaro Fernández Rojas /* 3155cca1bSÁlvaro Fernández Rojas * Driver for BCM63268 GPIO unit (pinctrl + GPIO) 4155cca1bSÁlvaro Fernández Rojas * 5155cca1bSÁlvaro Fernández Rojas * Copyright (C) 2021 Álvaro Fernández Rojas <noltari@gmail.com> 6155cca1bSÁlvaro Fernández Rojas * Copyright (C) 2016 Jonas Gorski <jonas.gorski@gmail.com> 7155cca1bSÁlvaro Fernández Rojas */ 8155cca1bSÁlvaro Fernández Rojas 9155cca1bSÁlvaro Fernández Rojas #include <linux/bits.h> 10155cca1bSÁlvaro Fernández Rojas #include <linux/gpio/driver.h> 11155cca1bSÁlvaro Fernández Rojas #include <linux/kernel.h> 12155cca1bSÁlvaro Fernández Rojas #include <linux/of.h> 13155cca1bSÁlvaro Fernández Rojas #include <linux/pinctrl/pinmux.h> 14155cca1bSÁlvaro Fernández Rojas #include <linux/platform_device.h> 15155cca1bSÁlvaro Fernández Rojas #include <linux/regmap.h> 16155cca1bSÁlvaro Fernández Rojas 17155cca1bSÁlvaro Fernández Rojas #include "../pinctrl-utils.h" 18155cca1bSÁlvaro Fernández Rojas 19155cca1bSÁlvaro Fernández Rojas #include "pinctrl-bcm63xx.h" 20155cca1bSÁlvaro Fernández Rojas 21155cca1bSÁlvaro Fernández Rojas #define BCM63268_NUM_GPIOS 52 22155cca1bSÁlvaro Fernández Rojas #define BCM63268_NUM_LEDS 24 23155cca1bSÁlvaro Fernández Rojas 24155cca1bSÁlvaro Fernández Rojas #define BCM63268_LED_REG 0x10 25155cca1bSÁlvaro Fernández Rojas #define BCM63268_MODE_REG 0x18 26155cca1bSÁlvaro Fernández Rojas #define BCM63268_CTRL_REG 0x1c 27155cca1bSÁlvaro Fernández Rojas #define BCM63268_BASEMODE_REG 0x38 28155cca1bSÁlvaro Fernández Rojas #define BCM63268_BASEMODE_NAND BIT(2) /* GPIOs 2-7, 24-31 */ 29155cca1bSÁlvaro Fernández Rojas #define BCM63268_BASEMODE_GPIO35 BIT(4) /* GPIO 35 */ 30155cca1bSÁlvaro Fernández Rojas #define BCM63268_BASEMODE_DECTPD BIT(5) /* GPIOs 8/9 */ 31155cca1bSÁlvaro Fernández Rojas #define BCM63268_BASEMODE_VDSL_PHY_0 BIT(6) /* GPIOs 10/11 */ 32155cca1bSÁlvaro Fernández Rojas #define BCM63268_BASEMODE_VDSL_PHY_1 BIT(7) /* GPIOs 12/13 */ 33155cca1bSÁlvaro Fernández Rojas #define BCM63268_BASEMODE_VDSL_PHY_2 BIT(8) /* GPIOs 24/25 */ 34155cca1bSÁlvaro Fernández Rojas #define BCM63268_BASEMODE_VDSL_PHY_3 BIT(9) /* GPIOs 26/27 */ 35155cca1bSÁlvaro Fernández Rojas 36155cca1bSÁlvaro Fernández Rojas enum bcm63268_pinctrl_reg { 37155cca1bSÁlvaro Fernández Rojas BCM63268_LEDCTRL, 38155cca1bSÁlvaro Fernández Rojas BCM63268_MODE, 39155cca1bSÁlvaro Fernández Rojas BCM63268_CTRL, 40155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE, 41155cca1bSÁlvaro Fernández Rojas }; 42155cca1bSÁlvaro Fernández Rojas 43155cca1bSÁlvaro Fernández Rojas struct bcm63268_pingroup { 44155cca1bSÁlvaro Fernández Rojas const char *name; 45155cca1bSÁlvaro Fernández Rojas const unsigned * const pins; 46155cca1bSÁlvaro Fernández Rojas const unsigned num_pins; 47155cca1bSÁlvaro Fernández Rojas }; 48155cca1bSÁlvaro Fernández Rojas 49155cca1bSÁlvaro Fernández Rojas struct bcm63268_function { 50155cca1bSÁlvaro Fernández Rojas const char *name; 51155cca1bSÁlvaro Fernández Rojas const char * const *groups; 52155cca1bSÁlvaro Fernández Rojas const unsigned num_groups; 53155cca1bSÁlvaro Fernández Rojas 54155cca1bSÁlvaro Fernández Rojas enum bcm63268_pinctrl_reg reg; 55155cca1bSÁlvaro Fernández Rojas uint32_t mask; 56155cca1bSÁlvaro Fernández Rojas }; 57155cca1bSÁlvaro Fernández Rojas 58155cca1bSÁlvaro Fernández Rojas #define BCM63268_PIN(a, b, basemode) \ 59155cca1bSÁlvaro Fernández Rojas { \ 60155cca1bSÁlvaro Fernández Rojas .number = a, \ 61155cca1bSÁlvaro Fernández Rojas .name = b, \ 62155cca1bSÁlvaro Fernández Rojas .drv_data = (void *)(basemode) \ 63155cca1bSÁlvaro Fernández Rojas } 64155cca1bSÁlvaro Fernández Rojas 65155cca1bSÁlvaro Fernández Rojas static const struct pinctrl_pin_desc bcm63268_pins[] = { 66155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(0, "gpio0"), 67155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(1, "gpio1"), 68155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(2, "gpio2", BCM63268_BASEMODE_NAND), 69155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(3, "gpio3", BCM63268_BASEMODE_NAND), 70155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(4, "gpio4", BCM63268_BASEMODE_NAND), 71155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(5, "gpio5", BCM63268_BASEMODE_NAND), 72155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(6, "gpio6", BCM63268_BASEMODE_NAND), 73155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(7, "gpio7", BCM63268_BASEMODE_NAND), 74155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(8, "gpio8", BCM63268_BASEMODE_DECTPD), 75155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(9, "gpio9", BCM63268_BASEMODE_DECTPD), 76155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(10, "gpio10", BCM63268_BASEMODE_VDSL_PHY_0), 77155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(11, "gpio11", BCM63268_BASEMODE_VDSL_PHY_0), 78155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(12, "gpio12", BCM63268_BASEMODE_VDSL_PHY_1), 79155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(13, "gpio13", BCM63268_BASEMODE_VDSL_PHY_1), 80155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(14, "gpio14"), 81155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(15, "gpio15"), 82155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(16, "gpio16"), 83155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(17, "gpio17"), 84155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(18, "gpio18"), 85155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(19, "gpio19"), 86155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(20, "gpio20"), 87155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(21, "gpio21"), 88155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(22, "gpio22"), 89155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(23, "gpio23"), 90155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(24, "gpio24", 91155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE_NAND | BCM63268_BASEMODE_VDSL_PHY_2), 92155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(25, "gpio25", 93155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE_NAND | BCM63268_BASEMODE_VDSL_PHY_2), 94155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(26, "gpio26", 95155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE_NAND | BCM63268_BASEMODE_VDSL_PHY_3), 96155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(27, "gpio27", 97155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE_NAND | BCM63268_BASEMODE_VDSL_PHY_3), 98155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(28, "gpio28", BCM63268_BASEMODE_NAND), 99155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(29, "gpio29", BCM63268_BASEMODE_NAND), 100155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(30, "gpio30", BCM63268_BASEMODE_NAND), 101155cca1bSÁlvaro Fernández Rojas BCM63268_PIN(31, "gpio31", BCM63268_BASEMODE_NAND), 102155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(32, "gpio32"), 103155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(33, "gpio33"), 104155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(34, "gpio34"), 105155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(35, "gpio35"), 106155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(36, "gpio36"), 107155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(37, "gpio37"), 108155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(38, "gpio38"), 109155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(39, "gpio39"), 110155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(40, "gpio40"), 111155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(41, "gpio41"), 112155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(42, "gpio42"), 113155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(43, "gpio43"), 114155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(44, "gpio44"), 115155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(45, "gpio45"), 116155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(46, "gpio46"), 117155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(47, "gpio47"), 118155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(48, "gpio48"), 119155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(49, "gpio49"), 120155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(50, "gpio50"), 121155cca1bSÁlvaro Fernández Rojas PINCTRL_PIN(51, "gpio51"), 122155cca1bSÁlvaro Fernández Rojas }; 123155cca1bSÁlvaro Fernández Rojas 124155cca1bSÁlvaro Fernández Rojas static unsigned gpio0_pins[] = { 0 }; 125155cca1bSÁlvaro Fernández Rojas static unsigned gpio1_pins[] = { 1 }; 126155cca1bSÁlvaro Fernández Rojas static unsigned gpio2_pins[] = { 2 }; 127155cca1bSÁlvaro Fernández Rojas static unsigned gpio3_pins[] = { 3 }; 128155cca1bSÁlvaro Fernández Rojas static unsigned gpio4_pins[] = { 4 }; 129155cca1bSÁlvaro Fernández Rojas static unsigned gpio5_pins[] = { 5 }; 130155cca1bSÁlvaro Fernández Rojas static unsigned gpio6_pins[] = { 6 }; 131155cca1bSÁlvaro Fernández Rojas static unsigned gpio7_pins[] = { 7 }; 132155cca1bSÁlvaro Fernández Rojas static unsigned gpio8_pins[] = { 8 }; 133155cca1bSÁlvaro Fernández Rojas static unsigned gpio9_pins[] = { 9 }; 134155cca1bSÁlvaro Fernández Rojas static unsigned gpio10_pins[] = { 10 }; 135155cca1bSÁlvaro Fernández Rojas static unsigned gpio11_pins[] = { 11 }; 136155cca1bSÁlvaro Fernández Rojas static unsigned gpio12_pins[] = { 12 }; 137155cca1bSÁlvaro Fernández Rojas static unsigned gpio13_pins[] = { 13 }; 138155cca1bSÁlvaro Fernández Rojas static unsigned gpio14_pins[] = { 14 }; 139155cca1bSÁlvaro Fernández Rojas static unsigned gpio15_pins[] = { 15 }; 140155cca1bSÁlvaro Fernández Rojas static unsigned gpio16_pins[] = { 16 }; 141155cca1bSÁlvaro Fernández Rojas static unsigned gpio17_pins[] = { 17 }; 142155cca1bSÁlvaro Fernández Rojas static unsigned gpio18_pins[] = { 18 }; 143155cca1bSÁlvaro Fernández Rojas static unsigned gpio19_pins[] = { 19 }; 144155cca1bSÁlvaro Fernández Rojas static unsigned gpio20_pins[] = { 20 }; 145155cca1bSÁlvaro Fernández Rojas static unsigned gpio21_pins[] = { 21 }; 146155cca1bSÁlvaro Fernández Rojas static unsigned gpio22_pins[] = { 22 }; 147155cca1bSÁlvaro Fernández Rojas static unsigned gpio23_pins[] = { 23 }; 148155cca1bSÁlvaro Fernández Rojas static unsigned gpio24_pins[] = { 24 }; 149155cca1bSÁlvaro Fernández Rojas static unsigned gpio25_pins[] = { 25 }; 150155cca1bSÁlvaro Fernández Rojas static unsigned gpio26_pins[] = { 26 }; 151155cca1bSÁlvaro Fernández Rojas static unsigned gpio27_pins[] = { 27 }; 152155cca1bSÁlvaro Fernández Rojas static unsigned gpio28_pins[] = { 28 }; 153155cca1bSÁlvaro Fernández Rojas static unsigned gpio29_pins[] = { 29 }; 154155cca1bSÁlvaro Fernández Rojas static unsigned gpio30_pins[] = { 30 }; 155155cca1bSÁlvaro Fernández Rojas static unsigned gpio31_pins[] = { 31 }; 156155cca1bSÁlvaro Fernández Rojas static unsigned gpio32_pins[] = { 32 }; 157155cca1bSÁlvaro Fernández Rojas static unsigned gpio33_pins[] = { 33 }; 158155cca1bSÁlvaro Fernández Rojas static unsigned gpio34_pins[] = { 34 }; 159155cca1bSÁlvaro Fernández Rojas static unsigned gpio35_pins[] = { 35 }; 160155cca1bSÁlvaro Fernández Rojas static unsigned gpio36_pins[] = { 36 }; 161155cca1bSÁlvaro Fernández Rojas static unsigned gpio37_pins[] = { 37 }; 162155cca1bSÁlvaro Fernández Rojas static unsigned gpio38_pins[] = { 38 }; 163155cca1bSÁlvaro Fernández Rojas static unsigned gpio39_pins[] = { 39 }; 164155cca1bSÁlvaro Fernández Rojas static unsigned gpio40_pins[] = { 40 }; 165155cca1bSÁlvaro Fernández Rojas static unsigned gpio41_pins[] = { 41 }; 166155cca1bSÁlvaro Fernández Rojas static unsigned gpio42_pins[] = { 42 }; 167155cca1bSÁlvaro Fernández Rojas static unsigned gpio43_pins[] = { 43 }; 168155cca1bSÁlvaro Fernández Rojas static unsigned gpio44_pins[] = { 44 }; 169155cca1bSÁlvaro Fernández Rojas static unsigned gpio45_pins[] = { 45 }; 170155cca1bSÁlvaro Fernández Rojas static unsigned gpio46_pins[] = { 46 }; 171155cca1bSÁlvaro Fernández Rojas static unsigned gpio47_pins[] = { 47 }; 172155cca1bSÁlvaro Fernández Rojas static unsigned gpio48_pins[] = { 48 }; 173155cca1bSÁlvaro Fernández Rojas static unsigned gpio49_pins[] = { 49 }; 174155cca1bSÁlvaro Fernández Rojas static unsigned gpio50_pins[] = { 50 }; 175155cca1bSÁlvaro Fernández Rojas static unsigned gpio51_pins[] = { 51 }; 176155cca1bSÁlvaro Fernández Rojas 177155cca1bSÁlvaro Fernández Rojas static unsigned nand_grp_pins[] = { 178155cca1bSÁlvaro Fernández Rojas 2, 3, 4, 5, 6, 7, 24, 179155cca1bSÁlvaro Fernández Rojas 25, 26, 27, 28, 29, 30, 31, 180155cca1bSÁlvaro Fernández Rojas }; 181155cca1bSÁlvaro Fernández Rojas 182155cca1bSÁlvaro Fernández Rojas static unsigned dectpd_grp_pins[] = { 8, 9 }; 183155cca1bSÁlvaro Fernández Rojas static unsigned vdsl_phy0_grp_pins[] = { 10, 11 }; 184155cca1bSÁlvaro Fernández Rojas static unsigned vdsl_phy1_grp_pins[] = { 12, 13 }; 185155cca1bSÁlvaro Fernández Rojas static unsigned vdsl_phy2_grp_pins[] = { 24, 25 }; 186155cca1bSÁlvaro Fernández Rojas static unsigned vdsl_phy3_grp_pins[] = { 26, 27 }; 187155cca1bSÁlvaro Fernández Rojas 188155cca1bSÁlvaro Fernández Rojas #define BCM63268_GROUP(n) \ 189155cca1bSÁlvaro Fernández Rojas { \ 190155cca1bSÁlvaro Fernández Rojas .name = #n, \ 191155cca1bSÁlvaro Fernández Rojas .pins = n##_pins, \ 192155cca1bSÁlvaro Fernández Rojas .num_pins = ARRAY_SIZE(n##_pins), \ 193155cca1bSÁlvaro Fernández Rojas } 194155cca1bSÁlvaro Fernández Rojas 195155cca1bSÁlvaro Fernández Rojas static struct bcm63268_pingroup bcm63268_groups[] = { 196155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio0), 197155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio1), 198155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio2), 199155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio3), 200155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio4), 201155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio5), 202155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio6), 203155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio7), 204155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio8), 205155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio9), 206155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio10), 207155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio11), 208155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio12), 209155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio13), 210155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio14), 211155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio15), 212155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio16), 213155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio17), 214155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio18), 215155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio19), 216155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio20), 217155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio21), 218155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio22), 219155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio23), 220155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio24), 221155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio25), 222155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio26), 223155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio27), 224155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio28), 225155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio29), 226155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio30), 227155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio31), 228155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio32), 229155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio33), 230155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio34), 231155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio35), 232155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio36), 233155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio37), 234155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio38), 235155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio39), 236155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio40), 237155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio41), 238155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio42), 239155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio43), 240155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio44), 241155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio45), 242155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio46), 243155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio47), 244155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio48), 245155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio49), 246155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio50), 247155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(gpio51), 248155cca1bSÁlvaro Fernández Rojas 249155cca1bSÁlvaro Fernández Rojas /* multi pin groups */ 250155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(nand_grp), 251155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(dectpd_grp), 252155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(vdsl_phy0_grp), 253155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(vdsl_phy1_grp), 254155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(vdsl_phy2_grp), 255155cca1bSÁlvaro Fernández Rojas BCM63268_GROUP(vdsl_phy3_grp), 256155cca1bSÁlvaro Fernández Rojas }; 257155cca1bSÁlvaro Fernández Rojas 258155cca1bSÁlvaro Fernández Rojas static const char * const led_groups[] = { 259155cca1bSÁlvaro Fernández Rojas "gpio0", 260155cca1bSÁlvaro Fernández Rojas "gpio1", 261155cca1bSÁlvaro Fernández Rojas "gpio2", 262155cca1bSÁlvaro Fernández Rojas "gpio3", 263155cca1bSÁlvaro Fernández Rojas "gpio4", 264155cca1bSÁlvaro Fernández Rojas "gpio5", 265155cca1bSÁlvaro Fernández Rojas "gpio6", 266155cca1bSÁlvaro Fernández Rojas "gpio7", 267155cca1bSÁlvaro Fernández Rojas "gpio8", 268155cca1bSÁlvaro Fernández Rojas "gpio9", 269155cca1bSÁlvaro Fernández Rojas "gpio10", 270155cca1bSÁlvaro Fernández Rojas "gpio11", 271155cca1bSÁlvaro Fernández Rojas "gpio12", 272155cca1bSÁlvaro Fernández Rojas "gpio13", 273155cca1bSÁlvaro Fernández Rojas "gpio14", 274155cca1bSÁlvaro Fernández Rojas "gpio15", 275155cca1bSÁlvaro Fernández Rojas "gpio16", 276155cca1bSÁlvaro Fernández Rojas "gpio17", 277155cca1bSÁlvaro Fernández Rojas "gpio18", 278155cca1bSÁlvaro Fernández Rojas "gpio19", 279155cca1bSÁlvaro Fernández Rojas "gpio20", 280155cca1bSÁlvaro Fernández Rojas "gpio21", 281155cca1bSÁlvaro Fernández Rojas "gpio22", 282155cca1bSÁlvaro Fernández Rojas "gpio23", 283155cca1bSÁlvaro Fernández Rojas }; 284155cca1bSÁlvaro Fernández Rojas 285155cca1bSÁlvaro Fernández Rojas static const char * const serial_led_clk_groups[] = { 286155cca1bSÁlvaro Fernández Rojas "gpio0", 287155cca1bSÁlvaro Fernández Rojas }; 288155cca1bSÁlvaro Fernández Rojas 289155cca1bSÁlvaro Fernández Rojas static const char * const serial_led_data_groups[] = { 290155cca1bSÁlvaro Fernández Rojas "gpio1", 291155cca1bSÁlvaro Fernández Rojas }; 292155cca1bSÁlvaro Fernández Rojas 293155cca1bSÁlvaro Fernández Rojas static const char * const hsspi_cs4_groups[] = { 294155cca1bSÁlvaro Fernández Rojas "gpio16", 295155cca1bSÁlvaro Fernández Rojas }; 296155cca1bSÁlvaro Fernández Rojas 297155cca1bSÁlvaro Fernández Rojas static const char * const hsspi_cs5_groups[] = { 298155cca1bSÁlvaro Fernández Rojas "gpio17", 299155cca1bSÁlvaro Fernández Rojas }; 300155cca1bSÁlvaro Fernández Rojas 301155cca1bSÁlvaro Fernández Rojas static const char * const hsspi_cs6_groups[] = { 302155cca1bSÁlvaro Fernández Rojas "gpio8", 303155cca1bSÁlvaro Fernández Rojas }; 304155cca1bSÁlvaro Fernández Rojas 305155cca1bSÁlvaro Fernández Rojas static const char * const hsspi_cs7_groups[] = { 306155cca1bSÁlvaro Fernández Rojas "gpio9", 307155cca1bSÁlvaro Fernández Rojas }; 308155cca1bSÁlvaro Fernández Rojas 309155cca1bSÁlvaro Fernández Rojas static const char * const uart1_scts_groups[] = { 310155cca1bSÁlvaro Fernández Rojas "gpio10", 311155cca1bSÁlvaro Fernández Rojas "gpio24", 312155cca1bSÁlvaro Fernández Rojas }; 313155cca1bSÁlvaro Fernández Rojas 314155cca1bSÁlvaro Fernández Rojas static const char * const uart1_srts_groups[] = { 315155cca1bSÁlvaro Fernández Rojas "gpio11", 316155cca1bSÁlvaro Fernández Rojas "gpio25", 317155cca1bSÁlvaro Fernández Rojas }; 318155cca1bSÁlvaro Fernández Rojas 319155cca1bSÁlvaro Fernández Rojas static const char * const uart1_sdin_groups[] = { 320155cca1bSÁlvaro Fernández Rojas "gpio12", 321155cca1bSÁlvaro Fernández Rojas "gpio26", 322155cca1bSÁlvaro Fernández Rojas }; 323155cca1bSÁlvaro Fernández Rojas 324155cca1bSÁlvaro Fernández Rojas static const char * const uart1_sdout_groups[] = { 325155cca1bSÁlvaro Fernández Rojas "gpio13", 326155cca1bSÁlvaro Fernández Rojas "gpio27", 327155cca1bSÁlvaro Fernández Rojas }; 328155cca1bSÁlvaro Fernández Rojas 329155cca1bSÁlvaro Fernández Rojas static const char * const ntr_pulse_in_groups[] = { 330155cca1bSÁlvaro Fernández Rojas "gpio14", 331155cca1bSÁlvaro Fernández Rojas "gpio28", 332155cca1bSÁlvaro Fernández Rojas }; 333155cca1bSÁlvaro Fernández Rojas 334155cca1bSÁlvaro Fernández Rojas static const char * const dsl_ntr_pulse_out_groups[] = { 335155cca1bSÁlvaro Fernández Rojas "gpio15", 336155cca1bSÁlvaro Fernández Rojas "gpio29", 337155cca1bSÁlvaro Fernández Rojas }; 338155cca1bSÁlvaro Fernández Rojas 339155cca1bSÁlvaro Fernández Rojas static const char * const adsl_spi_miso_groups[] = { 340155cca1bSÁlvaro Fernández Rojas "gpio18", 341155cca1bSÁlvaro Fernández Rojas }; 342155cca1bSÁlvaro Fernández Rojas 343155cca1bSÁlvaro Fernández Rojas static const char * const adsl_spi_mosi_groups[] = { 344155cca1bSÁlvaro Fernández Rojas "gpio19", 345155cca1bSÁlvaro Fernández Rojas }; 346155cca1bSÁlvaro Fernández Rojas 347155cca1bSÁlvaro Fernández Rojas static const char * const vreg_clk_groups[] = { 348155cca1bSÁlvaro Fernández Rojas "gpio22", 349155cca1bSÁlvaro Fernández Rojas }; 350155cca1bSÁlvaro Fernández Rojas 351155cca1bSÁlvaro Fernández Rojas static const char * const pcie_clkreq_b_groups[] = { 352155cca1bSÁlvaro Fernández Rojas "gpio23", 353155cca1bSÁlvaro Fernández Rojas }; 354155cca1bSÁlvaro Fernández Rojas 355155cca1bSÁlvaro Fernández Rojas static const char * const switch_led_clk_groups[] = { 356155cca1bSÁlvaro Fernández Rojas "gpio30", 357155cca1bSÁlvaro Fernández Rojas }; 358155cca1bSÁlvaro Fernández Rojas 359155cca1bSÁlvaro Fernández Rojas static const char * const switch_led_data_groups[] = { 360155cca1bSÁlvaro Fernández Rojas "gpio31", 361155cca1bSÁlvaro Fernández Rojas }; 362155cca1bSÁlvaro Fernández Rojas 363155cca1bSÁlvaro Fernández Rojas static const char * const wifi_groups[] = { 364155cca1bSÁlvaro Fernández Rojas "gpio32", 365155cca1bSÁlvaro Fernández Rojas "gpio33", 366155cca1bSÁlvaro Fernández Rojas "gpio34", 367155cca1bSÁlvaro Fernández Rojas "gpio35", 368155cca1bSÁlvaro Fernández Rojas "gpio36", 369155cca1bSÁlvaro Fernández Rojas "gpio37", 370155cca1bSÁlvaro Fernández Rojas "gpio38", 371155cca1bSÁlvaro Fernández Rojas "gpio39", 372155cca1bSÁlvaro Fernández Rojas "gpio40", 373155cca1bSÁlvaro Fernández Rojas "gpio41", 374155cca1bSÁlvaro Fernández Rojas "gpio42", 375155cca1bSÁlvaro Fernández Rojas "gpio43", 376155cca1bSÁlvaro Fernández Rojas "gpio44", 377155cca1bSÁlvaro Fernández Rojas "gpio45", 378155cca1bSÁlvaro Fernández Rojas "gpio46", 379155cca1bSÁlvaro Fernández Rojas "gpio47", 380155cca1bSÁlvaro Fernández Rojas "gpio48", 381155cca1bSÁlvaro Fernández Rojas "gpio49", 382155cca1bSÁlvaro Fernández Rojas "gpio50", 383155cca1bSÁlvaro Fernández Rojas "gpio51", 384155cca1bSÁlvaro Fernández Rojas }; 385155cca1bSÁlvaro Fernández Rojas 386155cca1bSÁlvaro Fernández Rojas static const char * const nand_groups[] = { 387155cca1bSÁlvaro Fernández Rojas "nand_grp", 388155cca1bSÁlvaro Fernández Rojas }; 389155cca1bSÁlvaro Fernández Rojas 390155cca1bSÁlvaro Fernández Rojas static const char * const dectpd_groups[] = { 391155cca1bSÁlvaro Fernández Rojas "dectpd_grp", 392155cca1bSÁlvaro Fernández Rojas }; 393155cca1bSÁlvaro Fernández Rojas 394155cca1bSÁlvaro Fernández Rojas static const char * const vdsl_phy_override_0_groups[] = { 395155cca1bSÁlvaro Fernández Rojas "vdsl_phy_override_0_grp", 396155cca1bSÁlvaro Fernández Rojas }; 397155cca1bSÁlvaro Fernández Rojas 398155cca1bSÁlvaro Fernández Rojas static const char * const vdsl_phy_override_1_groups[] = { 399155cca1bSÁlvaro Fernández Rojas "vdsl_phy_override_1_grp", 400155cca1bSÁlvaro Fernández Rojas }; 401155cca1bSÁlvaro Fernández Rojas 402155cca1bSÁlvaro Fernández Rojas static const char * const vdsl_phy_override_2_groups[] = { 403155cca1bSÁlvaro Fernández Rojas "vdsl_phy_override_2_grp", 404155cca1bSÁlvaro Fernández Rojas }; 405155cca1bSÁlvaro Fernández Rojas 406155cca1bSÁlvaro Fernández Rojas static const char * const vdsl_phy_override_3_groups[] = { 407155cca1bSÁlvaro Fernández Rojas "vdsl_phy_override_3_grp", 408155cca1bSÁlvaro Fernández Rojas }; 409155cca1bSÁlvaro Fernández Rojas 410155cca1bSÁlvaro Fernández Rojas #define BCM63268_LED_FUN(n) \ 411155cca1bSÁlvaro Fernández Rojas { \ 412155cca1bSÁlvaro Fernández Rojas .name = #n, \ 413155cca1bSÁlvaro Fernández Rojas .groups = n##_groups, \ 414155cca1bSÁlvaro Fernández Rojas .num_groups = ARRAY_SIZE(n##_groups), \ 415155cca1bSÁlvaro Fernández Rojas .reg = BCM63268_LEDCTRL, \ 416155cca1bSÁlvaro Fernández Rojas } 417155cca1bSÁlvaro Fernández Rojas 418155cca1bSÁlvaro Fernández Rojas #define BCM63268_MODE_FUN(n) \ 419155cca1bSÁlvaro Fernández Rojas { \ 420155cca1bSÁlvaro Fernández Rojas .name = #n, \ 421155cca1bSÁlvaro Fernández Rojas .groups = n##_groups, \ 422155cca1bSÁlvaro Fernández Rojas .num_groups = ARRAY_SIZE(n##_groups), \ 423155cca1bSÁlvaro Fernández Rojas .reg = BCM63268_MODE, \ 424155cca1bSÁlvaro Fernández Rojas } 425155cca1bSÁlvaro Fernández Rojas 426155cca1bSÁlvaro Fernández Rojas #define BCM63268_CTRL_FUN(n) \ 427155cca1bSÁlvaro Fernández Rojas { \ 428155cca1bSÁlvaro Fernández Rojas .name = #n, \ 429155cca1bSÁlvaro Fernández Rojas .groups = n##_groups, \ 430155cca1bSÁlvaro Fernández Rojas .num_groups = ARRAY_SIZE(n##_groups), \ 431155cca1bSÁlvaro Fernández Rojas .reg = BCM63268_CTRL, \ 432155cca1bSÁlvaro Fernández Rojas } 433155cca1bSÁlvaro Fernández Rojas 434155cca1bSÁlvaro Fernández Rojas #define BCM63268_BASEMODE_FUN(n, val) \ 435155cca1bSÁlvaro Fernández Rojas { \ 436155cca1bSÁlvaro Fernández Rojas .name = #n, \ 437155cca1bSÁlvaro Fernández Rojas .groups = n##_groups, \ 438155cca1bSÁlvaro Fernández Rojas .num_groups = ARRAY_SIZE(n##_groups), \ 439155cca1bSÁlvaro Fernández Rojas .reg = BCM63268_BASEMODE, \ 440155cca1bSÁlvaro Fernández Rojas .mask = val, \ 441155cca1bSÁlvaro Fernández Rojas } 442155cca1bSÁlvaro Fernández Rojas 443155cca1bSÁlvaro Fernández Rojas static const struct bcm63268_function bcm63268_funcs[] = { 444155cca1bSÁlvaro Fernández Rojas BCM63268_LED_FUN(led), 445155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(serial_led_clk), 446155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(serial_led_data), 447155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(hsspi_cs6), 448155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(hsspi_cs7), 449155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(uart1_scts), 450155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(uart1_srts), 451155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(uart1_sdin), 452155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(uart1_sdout), 453155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(ntr_pulse_in), 454155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(dsl_ntr_pulse_out), 455155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(hsspi_cs4), 456155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(hsspi_cs5), 457155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(adsl_spi_miso), 458155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(adsl_spi_mosi), 459155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(vreg_clk), 460155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(pcie_clkreq_b), 461155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(switch_led_clk), 462155cca1bSÁlvaro Fernández Rojas BCM63268_MODE_FUN(switch_led_data), 463155cca1bSÁlvaro Fernández Rojas BCM63268_CTRL_FUN(wifi), 464155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE_FUN(nand, BCM63268_BASEMODE_NAND), 465155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE_FUN(dectpd, BCM63268_BASEMODE_DECTPD), 466155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE_FUN(vdsl_phy_override_0, 467155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE_VDSL_PHY_0), 468155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE_FUN(vdsl_phy_override_1, 469155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE_VDSL_PHY_1), 470155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE_FUN(vdsl_phy_override_2, 471155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE_VDSL_PHY_2), 472155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE_FUN(vdsl_phy_override_3, 473155cca1bSÁlvaro Fernández Rojas BCM63268_BASEMODE_VDSL_PHY_3), 474155cca1bSÁlvaro Fernández Rojas }; 475155cca1bSÁlvaro Fernández Rojas 476155cca1bSÁlvaro Fernández Rojas static int bcm63268_pinctrl_get_group_count(struct pinctrl_dev *pctldev) 477155cca1bSÁlvaro Fernández Rojas { 478155cca1bSÁlvaro Fernández Rojas return ARRAY_SIZE(bcm63268_groups); 479155cca1bSÁlvaro Fernández Rojas } 480155cca1bSÁlvaro Fernández Rojas 481155cca1bSÁlvaro Fernández Rojas static const char *bcm63268_pinctrl_get_group_name(struct pinctrl_dev *pctldev, 482155cca1bSÁlvaro Fernández Rojas unsigned group) 483155cca1bSÁlvaro Fernández Rojas { 484155cca1bSÁlvaro Fernández Rojas return bcm63268_groups[group].name; 485155cca1bSÁlvaro Fernández Rojas } 486155cca1bSÁlvaro Fernández Rojas 487155cca1bSÁlvaro Fernández Rojas static int bcm63268_pinctrl_get_group_pins(struct pinctrl_dev *pctldev, 488155cca1bSÁlvaro Fernández Rojas unsigned group, 489155cca1bSÁlvaro Fernández Rojas const unsigned **pins, 490155cca1bSÁlvaro Fernández Rojas unsigned *num_pins) 491155cca1bSÁlvaro Fernández Rojas { 492155cca1bSÁlvaro Fernández Rojas *pins = bcm63268_groups[group].pins; 493155cca1bSÁlvaro Fernández Rojas *num_pins = bcm63268_groups[group].num_pins; 494155cca1bSÁlvaro Fernández Rojas 495155cca1bSÁlvaro Fernández Rojas return 0; 496155cca1bSÁlvaro Fernández Rojas } 497155cca1bSÁlvaro Fernández Rojas 498155cca1bSÁlvaro Fernández Rojas static int bcm63268_pinctrl_get_func_count(struct pinctrl_dev *pctldev) 499155cca1bSÁlvaro Fernández Rojas { 500155cca1bSÁlvaro Fernández Rojas return ARRAY_SIZE(bcm63268_funcs); 501155cca1bSÁlvaro Fernández Rojas } 502155cca1bSÁlvaro Fernández Rojas 503155cca1bSÁlvaro Fernández Rojas static const char *bcm63268_pinctrl_get_func_name(struct pinctrl_dev *pctldev, 504155cca1bSÁlvaro Fernández Rojas unsigned selector) 505155cca1bSÁlvaro Fernández Rojas { 506155cca1bSÁlvaro Fernández Rojas return bcm63268_funcs[selector].name; 507155cca1bSÁlvaro Fernández Rojas } 508155cca1bSÁlvaro Fernández Rojas 509155cca1bSÁlvaro Fernández Rojas static int bcm63268_pinctrl_get_groups(struct pinctrl_dev *pctldev, 510155cca1bSÁlvaro Fernández Rojas unsigned selector, 511155cca1bSÁlvaro Fernández Rojas const char * const **groups, 512155cca1bSÁlvaro Fernández Rojas unsigned * const num_groups) 513155cca1bSÁlvaro Fernández Rojas { 514155cca1bSÁlvaro Fernández Rojas *groups = bcm63268_funcs[selector].groups; 515155cca1bSÁlvaro Fernández Rojas *num_groups = bcm63268_funcs[selector].num_groups; 516155cca1bSÁlvaro Fernández Rojas 517155cca1bSÁlvaro Fernández Rojas return 0; 518155cca1bSÁlvaro Fernández Rojas } 519155cca1bSÁlvaro Fernández Rojas 520155cca1bSÁlvaro Fernández Rojas static void bcm63268_set_gpio(struct bcm63xx_pinctrl *pc, unsigned pin) 521155cca1bSÁlvaro Fernández Rojas { 522155cca1bSÁlvaro Fernández Rojas const struct pinctrl_pin_desc *desc = &bcm63268_pins[pin]; 523155cca1bSÁlvaro Fernández Rojas unsigned int basemode = (unsigned long) desc->drv_data; 524155cca1bSÁlvaro Fernández Rojas unsigned int mask = BIT(bcm63xx_bank_pin(pin)); 525155cca1bSÁlvaro Fernández Rojas 526155cca1bSÁlvaro Fernández Rojas if (basemode) 527155cca1bSÁlvaro Fernández Rojas regmap_update_bits(pc->regs, BCM63268_BASEMODE_REG, basemode, 528155cca1bSÁlvaro Fernández Rojas 0); 529155cca1bSÁlvaro Fernández Rojas 530155cca1bSÁlvaro Fernández Rojas if (pin < BCM63XX_BANK_GPIOS) { 531155cca1bSÁlvaro Fernández Rojas /* base mode: 0 => gpio, 1 => mux function */ 532155cca1bSÁlvaro Fernández Rojas regmap_update_bits(pc->regs, BCM63268_MODE_REG, mask, 0); 533155cca1bSÁlvaro Fernández Rojas 534155cca1bSÁlvaro Fernández Rojas /* pins 0-23 might be muxed to led */ 535155cca1bSÁlvaro Fernández Rojas if (pin < BCM63268_NUM_LEDS) 536155cca1bSÁlvaro Fernández Rojas regmap_update_bits(pc->regs, BCM63268_LED_REG, mask, 537155cca1bSÁlvaro Fernández Rojas 0); 538155cca1bSÁlvaro Fernández Rojas } else if (pin < BCM63268_NUM_GPIOS) { 539155cca1bSÁlvaro Fernández Rojas /* ctrl reg: 0 => wifi function, 1 => gpio */ 540155cca1bSÁlvaro Fernández Rojas regmap_update_bits(pc->regs, BCM63268_CTRL_REG, mask, mask); 541155cca1bSÁlvaro Fernández Rojas } 542155cca1bSÁlvaro Fernández Rojas } 543155cca1bSÁlvaro Fernández Rojas 544155cca1bSÁlvaro Fernández Rojas static int bcm63268_pinctrl_set_mux(struct pinctrl_dev *pctldev, 545155cca1bSÁlvaro Fernández Rojas unsigned selector, unsigned group) 546155cca1bSÁlvaro Fernández Rojas { 547155cca1bSÁlvaro Fernández Rojas struct bcm63xx_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev); 548155cca1bSÁlvaro Fernández Rojas const struct bcm63268_pingroup *pg = &bcm63268_groups[group]; 549155cca1bSÁlvaro Fernández Rojas const struct bcm63268_function *f = &bcm63268_funcs[selector]; 550155cca1bSÁlvaro Fernández Rojas unsigned i; 551155cca1bSÁlvaro Fernández Rojas unsigned int reg; 552155cca1bSÁlvaro Fernández Rojas unsigned int val, mask; 553155cca1bSÁlvaro Fernández Rojas 554155cca1bSÁlvaro Fernández Rojas for (i = 0; i < pg->num_pins; i++) 555155cca1bSÁlvaro Fernández Rojas bcm63268_set_gpio(pc, pg->pins[i]); 556155cca1bSÁlvaro Fernández Rojas 557155cca1bSÁlvaro Fernández Rojas switch (f->reg) { 558155cca1bSÁlvaro Fernández Rojas case BCM63268_LEDCTRL: 559155cca1bSÁlvaro Fernández Rojas reg = BCM63268_LED_REG; 560155cca1bSÁlvaro Fernández Rojas mask = BIT(pg->pins[0]); 561155cca1bSÁlvaro Fernández Rojas val = BIT(pg->pins[0]); 562155cca1bSÁlvaro Fernández Rojas break; 563155cca1bSÁlvaro Fernández Rojas case BCM63268_MODE: 564155cca1bSÁlvaro Fernández Rojas reg = BCM63268_MODE_REG; 565155cca1bSÁlvaro Fernández Rojas mask = BIT(pg->pins[0]); 566155cca1bSÁlvaro Fernández Rojas val = BIT(pg->pins[0]); 567155cca1bSÁlvaro Fernández Rojas break; 568155cca1bSÁlvaro Fernández Rojas case BCM63268_CTRL: 569155cca1bSÁlvaro Fernández Rojas reg = BCM63268_CTRL_REG; 570155cca1bSÁlvaro Fernández Rojas mask = BIT(pg->pins[0]); 571155cca1bSÁlvaro Fernández Rojas val = 0; 572155cca1bSÁlvaro Fernández Rojas break; 573155cca1bSÁlvaro Fernández Rojas case BCM63268_BASEMODE: 574155cca1bSÁlvaro Fernández Rojas reg = BCM63268_BASEMODE_REG; 575155cca1bSÁlvaro Fernández Rojas mask = f->mask; 576155cca1bSÁlvaro Fernández Rojas val = f->mask; 577155cca1bSÁlvaro Fernández Rojas break; 578155cca1bSÁlvaro Fernández Rojas default: 579155cca1bSÁlvaro Fernández Rojas WARN_ON(1); 580155cca1bSÁlvaro Fernández Rojas return -EINVAL; 581155cca1bSÁlvaro Fernández Rojas } 582155cca1bSÁlvaro Fernández Rojas 583155cca1bSÁlvaro Fernández Rojas regmap_update_bits(pc->regs, reg, mask, val); 584155cca1bSÁlvaro Fernández Rojas 585155cca1bSÁlvaro Fernández Rojas return 0; 586155cca1bSÁlvaro Fernández Rojas } 587155cca1bSÁlvaro Fernández Rojas 588155cca1bSÁlvaro Fernández Rojas static int bcm63268_gpio_request_enable(struct pinctrl_dev *pctldev, 589155cca1bSÁlvaro Fernández Rojas struct pinctrl_gpio_range *range, 590155cca1bSÁlvaro Fernández Rojas unsigned offset) 591155cca1bSÁlvaro Fernández Rojas { 592155cca1bSÁlvaro Fernández Rojas struct bcm63xx_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev); 593155cca1bSÁlvaro Fernández Rojas 594155cca1bSÁlvaro Fernández Rojas /* disable all functions using this pin */ 595155cca1bSÁlvaro Fernández Rojas bcm63268_set_gpio(pc, offset); 596155cca1bSÁlvaro Fernández Rojas 597155cca1bSÁlvaro Fernández Rojas return 0; 598155cca1bSÁlvaro Fernández Rojas } 599155cca1bSÁlvaro Fernández Rojas 600d9779093SRikard Falkeborn static const struct pinctrl_ops bcm63268_pctl_ops = { 601155cca1bSÁlvaro Fernández Rojas .dt_free_map = pinctrl_utils_free_map, 602155cca1bSÁlvaro Fernández Rojas .dt_node_to_map = pinconf_generic_dt_node_to_map_pin, 603155cca1bSÁlvaro Fernández Rojas .get_group_name = bcm63268_pinctrl_get_group_name, 604155cca1bSÁlvaro Fernández Rojas .get_group_pins = bcm63268_pinctrl_get_group_pins, 605155cca1bSÁlvaro Fernández Rojas .get_groups_count = bcm63268_pinctrl_get_group_count, 606155cca1bSÁlvaro Fernández Rojas }; 607155cca1bSÁlvaro Fernández Rojas 608*0c683876SRikard Falkeborn static const struct pinmux_ops bcm63268_pmx_ops = { 609155cca1bSÁlvaro Fernández Rojas .get_function_groups = bcm63268_pinctrl_get_groups, 610155cca1bSÁlvaro Fernández Rojas .get_function_name = bcm63268_pinctrl_get_func_name, 611155cca1bSÁlvaro Fernández Rojas .get_functions_count = bcm63268_pinctrl_get_func_count, 612155cca1bSÁlvaro Fernández Rojas .gpio_request_enable = bcm63268_gpio_request_enable, 613155cca1bSÁlvaro Fernández Rojas .set_mux = bcm63268_pinctrl_set_mux, 614155cca1bSÁlvaro Fernández Rojas .strict = true, 615155cca1bSÁlvaro Fernández Rojas }; 616155cca1bSÁlvaro Fernández Rojas 617155cca1bSÁlvaro Fernández Rojas static const struct bcm63xx_pinctrl_soc bcm63268_soc = { 618155cca1bSÁlvaro Fernández Rojas .ngpios = BCM63268_NUM_GPIOS, 619155cca1bSÁlvaro Fernández Rojas .npins = ARRAY_SIZE(bcm63268_pins), 620155cca1bSÁlvaro Fernández Rojas .pctl_ops = &bcm63268_pctl_ops, 621155cca1bSÁlvaro Fernández Rojas .pins = bcm63268_pins, 622155cca1bSÁlvaro Fernández Rojas .pmx_ops = &bcm63268_pmx_ops, 623155cca1bSÁlvaro Fernández Rojas }; 624155cca1bSÁlvaro Fernández Rojas 625155cca1bSÁlvaro Fernández Rojas static int bcm63268_pinctrl_probe(struct platform_device *pdev) 626155cca1bSÁlvaro Fernández Rojas { 627155cca1bSÁlvaro Fernández Rojas return bcm63xx_pinctrl_probe(pdev, &bcm63268_soc, NULL); 628155cca1bSÁlvaro Fernández Rojas } 629155cca1bSÁlvaro Fernández Rojas 630155cca1bSÁlvaro Fernández Rojas static const struct of_device_id bcm63268_pinctrl_match[] = { 631155cca1bSÁlvaro Fernández Rojas { .compatible = "brcm,bcm63268-pinctrl", }, 632155cca1bSÁlvaro Fernández Rojas { /* sentinel */ } 633155cca1bSÁlvaro Fernández Rojas }; 634155cca1bSÁlvaro Fernández Rojas 635155cca1bSÁlvaro Fernández Rojas static struct platform_driver bcm63268_pinctrl_driver = { 636155cca1bSÁlvaro Fernández Rojas .probe = bcm63268_pinctrl_probe, 637155cca1bSÁlvaro Fernández Rojas .driver = { 638155cca1bSÁlvaro Fernández Rojas .name = "bcm63268-pinctrl", 639155cca1bSÁlvaro Fernández Rojas .of_match_table = bcm63268_pinctrl_match, 640155cca1bSÁlvaro Fernández Rojas }, 641155cca1bSÁlvaro Fernández Rojas }; 642155cca1bSÁlvaro Fernández Rojas 643155cca1bSÁlvaro Fernández Rojas builtin_platform_driver(bcm63268_pinctrl_driver); 644