1 /* 2 * Marvell berlin4ct pinctrl driver 3 * 4 * Copyright (C) 2015 Marvell Technology Group Ltd. 5 * 6 * Author: Jisheng Zhang <jszhang@marvell.com> 7 * 8 * This program is free software; you can redistribute it and/or modify it 9 * under the terms and conditions of the GNU General Public License, 10 * version 2, as published by the Free Software Foundation. 11 * 12 * This program is distributed in the hope it will be useful, but WITHOUT 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 15 * more details. 16 * 17 * You should have received a copy of the GNU General Public License along with 18 * this program. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 #include <linux/init.h> 22 #include <linux/of_device.h> 23 #include <linux/platform_device.h> 24 #include <linux/regmap.h> 25 26 #include "berlin.h" 27 28 static const struct berlin_desc_group berlin4ct_soc_pinctrl_groups[] = { 29 BERLIN_PINCTRL_GROUP("EMMC_RSTn", 0x0, 0x3, 0x00, 30 BERLIN_PINCTRL_FUNCTION(0x0, "emmc"), /* RSTn */ 31 BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), /* GPIO47 */ 32 BERLIN_PINCTRL_GROUP("NAND_IO0", 0x0, 0x3, 0x03, 33 BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO0 */ 34 BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* RXD0 */ 35 BERLIN_PINCTRL_FUNCTION(0x2, "sd1"), /* CLK */ 36 BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO0 */ 37 BERLIN_PINCTRL_GROUP("NAND_IO1", 0x0, 0x3, 0x06, 38 BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO1 */ 39 BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* RXD1 */ 40 BERLIN_PINCTRL_FUNCTION(0x2, "sd1"), /* CDn */ 41 BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO1 */ 42 BERLIN_PINCTRL_GROUP("NAND_IO2", 0x0, 0x3, 0x09, 43 BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO2 */ 44 BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* RXD2 */ 45 BERLIN_PINCTRL_FUNCTION(0x2, "sd1"), /* DAT0 */ 46 BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO2 */ 47 BERLIN_PINCTRL_GROUP("NAND_IO3", 0x0, 0x3, 0x0c, 48 BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO3 */ 49 BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* RXD3 */ 50 BERLIN_PINCTRL_FUNCTION(0x2, "sd1"), /* DAT1 */ 51 BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO3 */ 52 BERLIN_PINCTRL_GROUP("NAND_IO4", 0x0, 0x3, 0x0f, 53 BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO4 */ 54 BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* RXC */ 55 BERLIN_PINCTRL_FUNCTION(0x2, "sd1"), /* DAT2 */ 56 BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO4 */ 57 BERLIN_PINCTRL_GROUP("NAND_IO5", 0x0, 0x3, 0x12, 58 BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO5 */ 59 BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* RXCTL */ 60 BERLIN_PINCTRL_FUNCTION(0x2, "sd1"), /* DAT3 */ 61 BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO5 */ 62 BERLIN_PINCTRL_GROUP("NAND_IO6", 0x0, 0x3, 0x15, 63 BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO6 */ 64 BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* MDC */ 65 BERLIN_PINCTRL_FUNCTION(0x2, "sd1"), /* CMD */ 66 BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO6 */ 67 BERLIN_PINCTRL_GROUP("NAND_IO7", 0x0, 0x3, 0x18, 68 BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* IO7 */ 69 BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* MDIO */ 70 BERLIN_PINCTRL_FUNCTION(0x2, "sd1"), /* WP */ 71 BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO7 */ 72 BERLIN_PINCTRL_GROUP("NAND_ALE", 0x0, 0x3, 0x1b, 73 BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* ALE */ 74 BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* TXD0 */ 75 BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO8 */ 76 BERLIN_PINCTRL_GROUP("NAND_CLE", 0x4, 0x3, 0x00, 77 BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* CLE */ 78 BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* TXD1 */ 79 BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO9 */ 80 BERLIN_PINCTRL_GROUP("NAND_WEn", 0x4, 0x3, 0x03, 81 BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* WEn */ 82 BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* TXD2 */ 83 BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO10 */ 84 BERLIN_PINCTRL_GROUP("NAND_REn", 0x4, 0x3, 0x06, 85 BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* REn */ 86 BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* TXD3 */ 87 BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO11 */ 88 BERLIN_PINCTRL_GROUP("NAND_WPn", 0x4, 0x3, 0x09, 89 BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* WPn */ 90 BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO12 */ 91 BERLIN_PINCTRL_GROUP("NAND_CEn", 0x4, 0x3, 0x0c, 92 BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* CEn */ 93 BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* TXC */ 94 BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO13 */ 95 BERLIN_PINCTRL_GROUP("NAND_RDY", 0x4, 0x3, 0x0f, 96 BERLIN_PINCTRL_FUNCTION(0x0, "nand"), /* RDY */ 97 BERLIN_PINCTRL_FUNCTION(0x1, "rgmii"), /* TXCTL */ 98 BERLIN_PINCTRL_FUNCTION(0x3, "gpio")), /* GPIO14 */ 99 BERLIN_PINCTRL_GROUP("SD0_CLK", 0x4, 0x3, 0x12, 100 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO29 */ 101 BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* CLK*/ 102 BERLIN_PINCTRL_FUNCTION(0x2, "sts4"), /* CLK */ 103 BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG8 */ 104 BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG8 */ 105 BERLIN_PINCTRL_GROUP("SD0_DAT0", 0x4, 0x3, 0x15, 106 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO30 */ 107 BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* DAT0 */ 108 BERLIN_PINCTRL_FUNCTION(0x2, "sts4"), /* SOP */ 109 BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG9 */ 110 BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG9 */ 111 BERLIN_PINCTRL_GROUP("SD0_DAT1", 0x4, 0x3, 0x18, 112 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO31 */ 113 BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* DAT1 */ 114 BERLIN_PINCTRL_FUNCTION(0x2, "sts4"), /* SD */ 115 BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG10 */ 116 BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG10 */ 117 BERLIN_PINCTRL_GROUP("SD0_DAT2", 0x4, 0x3, 0x1b, 118 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO32 */ 119 BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* DAT2 */ 120 BERLIN_PINCTRL_FUNCTION(0x2, "sts4"), /* VALD */ 121 BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG11 */ 122 BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG11 */ 123 BERLIN_PINCTRL_GROUP("SD0_DAT3", 0x8, 0x3, 0x00, 124 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO33 */ 125 BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* DAT3 */ 126 BERLIN_PINCTRL_FUNCTION(0x2, "sts5"), /* CLK */ 127 BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG12 */ 128 BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG12 */ 129 BERLIN_PINCTRL_GROUP("SD0_CDn", 0x8, 0x3, 0x03, 130 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO34 */ 131 BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* CDn */ 132 BERLIN_PINCTRL_FUNCTION(0x2, "sts5"), /* SOP */ 133 BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG13 */ 134 BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG13 */ 135 BERLIN_PINCTRL_GROUP("SD0_CMD", 0x8, 0x3, 0x06, 136 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO35 */ 137 BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* CMD */ 138 BERLIN_PINCTRL_FUNCTION(0x2, "sts5"), /* SD */ 139 BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG14 */ 140 BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG14 */ 141 BERLIN_PINCTRL_GROUP("SD0_WP", 0x8, 0x3, 0x09, 142 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO36 */ 143 BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), /* WP */ 144 BERLIN_PINCTRL_FUNCTION(0x2, "sts5"), /* VALD */ 145 BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG15 */ 146 BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG15 */ 147 BERLIN_PINCTRL_GROUP("STS0_CLK", 0x8, 0x3, 0x0c, 148 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO21 */ 149 BERLIN_PINCTRL_FUNCTION(0x1, "sts0"), /* CLK */ 150 BERLIN_PINCTRL_FUNCTION(0x2, "cpupll"), /* CLKO */ 151 BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG0 */ 152 BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG0 */ 153 BERLIN_PINCTRL_GROUP("STS0_SOP", 0x8, 0x3, 0x0f, 154 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO22 */ 155 BERLIN_PINCTRL_FUNCTION(0x1, "sts0"), /* SOP */ 156 BERLIN_PINCTRL_FUNCTION(0x2, "syspll"), /* CLKO */ 157 BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG1 */ 158 BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG1 */ 159 BERLIN_PINCTRL_GROUP("STS0_SD", 0x8, 0x3, 0x12, 160 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO23 */ 161 BERLIN_PINCTRL_FUNCTION(0x1, "sts0"), /* SD */ 162 BERLIN_PINCTRL_FUNCTION(0x2, "mempll"), /* CLKO */ 163 BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG2 */ 164 BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG2 */ 165 BERLIN_PINCTRL_GROUP("STS0_VALD", 0x8, 0x3, 0x15, 166 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO24 */ 167 BERLIN_PINCTRL_FUNCTION(0x1, "sts0"), /* VALD */ 168 BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG3 */ 169 BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG3 */ 170 BERLIN_PINCTRL_GROUP("STS1_CLK", 0x8, 0x3, 0x18, 171 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO25 */ 172 BERLIN_PINCTRL_FUNCTION(0x1, "sts1"), /* CLK */ 173 BERLIN_PINCTRL_FUNCTION(0x2, "pwm0"), 174 BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG4 */ 175 BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG4 */ 176 BERLIN_PINCTRL_GROUP("STS1_SOP", 0x8, 0x3, 0x1b, 177 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO26 */ 178 BERLIN_PINCTRL_FUNCTION(0x1, "sts1"), /* SOP */ 179 BERLIN_PINCTRL_FUNCTION(0x2, "pwm1"), 180 BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG5 */ 181 BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG5 */ 182 BERLIN_PINCTRL_GROUP("STS1_SD", 0xc, 0x3, 0x00, 183 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO27 */ 184 BERLIN_PINCTRL_FUNCTION(0x1, "sts1"), /* SD */ 185 BERLIN_PINCTRL_FUNCTION(0x2, "pwm2"), 186 BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG6 */ 187 BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG6 */ 188 BERLIN_PINCTRL_GROUP("STS1_VALD", 0xc, 0x3, 0x03, 189 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO28 */ 190 BERLIN_PINCTRL_FUNCTION(0x1, "sts1"), /* VALD */ 191 BERLIN_PINCTRL_FUNCTION(0x2, "pwm3"), 192 BERLIN_PINCTRL_FUNCTION(0x5, "v4g"), /* DBG7 */ 193 BERLIN_PINCTRL_FUNCTION(0x7, "phy")), /* DBG7 */ 194 BERLIN_PINCTRL_GROUP("SCRD0_RST", 0xc, 0x3, 0x06, 195 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO15 */ 196 BERLIN_PINCTRL_FUNCTION(0x1, "scrd0"), /* RST */ 197 BERLIN_PINCTRL_FUNCTION(0x3, "sd1a")), /* CLK */ 198 BERLIN_PINCTRL_GROUP("SCRD0_DCLK", 0xc, 0x3, 0x09, 199 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO16 */ 200 BERLIN_PINCTRL_FUNCTION(0x1, "scrd0"), /* DCLK */ 201 BERLIN_PINCTRL_FUNCTION(0x3, "sd1a")), /* CMD */ 202 BERLIN_PINCTRL_GROUP("SCRD0_GPIO0", 0xc, 0x3, 0x0c, 203 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO17 */ 204 BERLIN_PINCTRL_FUNCTION(0x1, "scrd0"), /* SCRD0 GPIO0 */ 205 BERLIN_PINCTRL_FUNCTION(0x2, "sif"), /* DIO */ 206 BERLIN_PINCTRL_FUNCTION(0x3, "sd1a")), /* DAT0 */ 207 BERLIN_PINCTRL_GROUP("SCRD0_GPIO1", 0xc, 0x3, 0x0f, 208 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO18 */ 209 BERLIN_PINCTRL_FUNCTION(0x1, "scrd0"), /* SCRD0 GPIO1 */ 210 BERLIN_PINCTRL_FUNCTION(0x2, "sif"), /* CLK */ 211 BERLIN_PINCTRL_FUNCTION(0x3, "sd1a")), /* DAT1 */ 212 BERLIN_PINCTRL_GROUP("SCRD0_DIO", 0xc, 0x3, 0x12, 213 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO19 */ 214 BERLIN_PINCTRL_FUNCTION(0x1, "scrd0"), /* DIO */ 215 BERLIN_PINCTRL_FUNCTION(0x2, "sif"), /* DEN */ 216 BERLIN_PINCTRL_FUNCTION(0x3, "sd1a")), /* DAT2 */ 217 BERLIN_PINCTRL_GROUP("SCRD0_CRD_PRES", 0xc, 0x3, 0x15, 218 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO20 */ 219 BERLIN_PINCTRL_FUNCTION(0x1, "scrd0"), /* crd pres */ 220 BERLIN_PINCTRL_FUNCTION(0x3, "sd1a")), /* DAT3 */ 221 BERLIN_PINCTRL_GROUP("SPI1_SS0n", 0xc, 0x3, 0x18, 222 BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SS0n */ 223 BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* GPIO37 */ 224 BERLIN_PINCTRL_FUNCTION(0x2, "sts2")), /* CLK */ 225 BERLIN_PINCTRL_GROUP("SPI1_SS1n", 0xc, 0x3, 0x1b, 226 BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SS1n */ 227 BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* GPIO38 */ 228 BERLIN_PINCTRL_FUNCTION(0x2, "sts2"), /* SOP */ 229 BERLIN_PINCTRL_FUNCTION(0x4, "pwm1")), 230 BERLIN_PINCTRL_GROUP("SPI1_SS2n", 0x10, 0x3, 0x00, 231 BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SS2n */ 232 BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* GPIO39 */ 233 BERLIN_PINCTRL_FUNCTION(0x2, "sts2"), /* SD */ 234 BERLIN_PINCTRL_FUNCTION(0x4, "pwm0")), 235 BERLIN_PINCTRL_GROUP("SPI1_SS3n", 0x10, 0x3, 0x03, 236 BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SS3n */ 237 BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* GPIO40 */ 238 BERLIN_PINCTRL_FUNCTION(0x2, "sts2")), /* VALD */ 239 BERLIN_PINCTRL_GROUP("SPI1_SCLK", 0x10, 0x3, 0x06, 240 BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SCLK */ 241 BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* GPIO41 */ 242 BERLIN_PINCTRL_FUNCTION(0x2, "sts3")), /* CLK */ 243 BERLIN_PINCTRL_GROUP("SPI1_SDO", 0x10, 0x3, 0x09, 244 BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SDO */ 245 BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* GPIO42 */ 246 BERLIN_PINCTRL_FUNCTION(0x2, "sts3")), /* SOP */ 247 BERLIN_PINCTRL_GROUP("SPI1_SDI", 0x10, 0x3, 0x0c, 248 BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SDI */ 249 BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* GPIO43 */ 250 BERLIN_PINCTRL_FUNCTION(0x2, "sts3")), /* SD */ 251 BERLIN_PINCTRL_GROUP("USB0_DRV_VBUS", 0x10, 0x3, 0x0f, 252 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO44 */ 253 BERLIN_PINCTRL_FUNCTION(0x1, "usb0"), /* VBUS */ 254 BERLIN_PINCTRL_FUNCTION(0x2, "sts3")), /* VALD */ 255 BERLIN_PINCTRL_GROUP("TW0_SCL", 0x10, 0x3, 0x12, 256 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO45 */ 257 BERLIN_PINCTRL_FUNCTION(0x1, "tw0")), /* SCL */ 258 BERLIN_PINCTRL_GROUP("TW0_SDA", 0x10, 0x3, 0x15, 259 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* GPIO46 */ 260 BERLIN_PINCTRL_FUNCTION(0x1, "tw0")), /* SDA */ 261 }; 262 263 static const struct berlin_desc_group berlin4ct_avio_pinctrl_groups[] = { 264 BERLIN_PINCTRL_GROUP("TX_EDDC_SCL", 0x0, 0x3, 0x00, 265 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO0 */ 266 BERLIN_PINCTRL_FUNCTION(0x1, "tx_eddc"), /* SCL */ 267 BERLIN_PINCTRL_FUNCTION(0x2, "tw1")), /* SCL */ 268 BERLIN_PINCTRL_GROUP("TX_EDDC_SDA", 0x0, 0x3, 0x03, 269 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO1 */ 270 BERLIN_PINCTRL_FUNCTION(0x1, "tx_eddc"), /* SDA */ 271 BERLIN_PINCTRL_FUNCTION(0x2, "tw1")), /* SDA */ 272 BERLIN_PINCTRL_GROUP("I2S1_LRCKO", 0x0, 0x3, 0x06, 273 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO2 */ 274 BERLIN_PINCTRL_FUNCTION(0x1, "i2s1"), /* LRCKO */ 275 BERLIN_PINCTRL_FUNCTION(0x3, "sts6"), /* CLK */ 276 BERLIN_PINCTRL_FUNCTION(0x4, "adac"), /* DBG0 */ 277 BERLIN_PINCTRL_FUNCTION(0x6, "sd1b"), /* CLK */ 278 BERLIN_PINCTRL_FUNCTION(0x7, "avio")), /* DBG0 */ 279 BERLIN_PINCTRL_GROUP("I2S1_BCLKO", 0x0, 0x3, 0x09, 280 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO3 */ 281 BERLIN_PINCTRL_FUNCTION(0x1, "i2s1"), /* BCLKO */ 282 BERLIN_PINCTRL_FUNCTION(0x3, "sts6"), /* SOP */ 283 BERLIN_PINCTRL_FUNCTION(0x4, "adac"), /* DBG1 */ 284 BERLIN_PINCTRL_FUNCTION(0x6, "sd1b"), /* CMD */ 285 BERLIN_PINCTRL_FUNCTION(0x7, "avio")), /* DBG1 */ 286 BERLIN_PINCTRL_GROUP("I2S1_DO", 0x0, 0x3, 0x0c, 287 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO4 */ 288 BERLIN_PINCTRL_FUNCTION(0x1, "i2s1"), /* DO */ 289 BERLIN_PINCTRL_FUNCTION(0x3, "sts6"), /* SD */ 290 BERLIN_PINCTRL_FUNCTION(0x4, "adac"), /* DBG2 */ 291 BERLIN_PINCTRL_FUNCTION(0x6, "sd1b"), /* DAT0 */ 292 BERLIN_PINCTRL_FUNCTION(0x7, "avio")), /* DBG2 */ 293 BERLIN_PINCTRL_GROUP("I2S1_MCLK", 0x0, 0x3, 0x0f, 294 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO5 */ 295 BERLIN_PINCTRL_FUNCTION(0x1, "i2s1"), /* MCLK */ 296 BERLIN_PINCTRL_FUNCTION(0x3, "sts6"), /* VALD */ 297 BERLIN_PINCTRL_FUNCTION(0x4, "adac_test"), /* MCLK */ 298 BERLIN_PINCTRL_FUNCTION(0x6, "sd1b"), /* DAT1 */ 299 BERLIN_PINCTRL_FUNCTION(0x7, "avio")), /* DBG3 */ 300 BERLIN_PINCTRL_GROUP("SPDIFO", 0x0, 0x3, 0x12, 301 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO6 */ 302 BERLIN_PINCTRL_FUNCTION(0x1, "spdifo"), 303 BERLIN_PINCTRL_FUNCTION(0x2, "avpll"), /* CLKO */ 304 BERLIN_PINCTRL_FUNCTION(0x4, "adac")), /* DBG3 */ 305 BERLIN_PINCTRL_GROUP("I2S2_MCLK", 0x0, 0x3, 0x15, 306 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO7 */ 307 BERLIN_PINCTRL_FUNCTION(0x1, "i2s2"), /* MCLK */ 308 BERLIN_PINCTRL_FUNCTION(0x4, "hdmi"), /* FBCLK */ 309 BERLIN_PINCTRL_FUNCTION(0x5, "pdm")), /* CLKO */ 310 BERLIN_PINCTRL_GROUP("I2S2_LRCKI", 0x0, 0x3, 0x18, 311 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO8 */ 312 BERLIN_PINCTRL_FUNCTION(0x1, "i2s2"), /* LRCKI */ 313 BERLIN_PINCTRL_FUNCTION(0x2, "pwm0"), 314 BERLIN_PINCTRL_FUNCTION(0x3, "sts7"), /* CLK */ 315 BERLIN_PINCTRL_FUNCTION(0x4, "adac_test"), /* LRCK */ 316 BERLIN_PINCTRL_FUNCTION(0x6, "sd1b")), /* DAT2 */ 317 BERLIN_PINCTRL_GROUP("I2S2_BCLKI", 0x0, 0x3, 0x1b, 318 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO9 */ 319 BERLIN_PINCTRL_FUNCTION(0x1, "i2s2"), /* BCLKI */ 320 BERLIN_PINCTRL_FUNCTION(0x2, "pwm1"), 321 BERLIN_PINCTRL_FUNCTION(0x3, "sts7"), /* SOP */ 322 BERLIN_PINCTRL_FUNCTION(0x4, "adac_test"), /* BCLK */ 323 BERLIN_PINCTRL_FUNCTION(0x6, "sd1b")), /* DAT3 */ 324 BERLIN_PINCTRL_GROUP("I2S2_DI0", 0x4, 0x3, 0x00, 325 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO10 */ 326 BERLIN_PINCTRL_FUNCTION(0x1, "i2s2"), /* DI0 */ 327 BERLIN_PINCTRL_FUNCTION(0x2, "pwm2"), 328 BERLIN_PINCTRL_FUNCTION(0x3, "sts7"), /* SD */ 329 BERLIN_PINCTRL_FUNCTION(0x4, "adac_test"), /* SDIN */ 330 BERLIN_PINCTRL_FUNCTION(0x5, "pdm"), /* DI0 */ 331 BERLIN_PINCTRL_FUNCTION(0x6, "sd1b")), /* CDn */ 332 BERLIN_PINCTRL_GROUP("I2S2_DI1", 0x4, 0x3, 0x03, 333 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* AVIO GPIO11 */ 334 BERLIN_PINCTRL_FUNCTION(0x1, "i2s2"), /* DI1 */ 335 BERLIN_PINCTRL_FUNCTION(0x2, "pwm3"), 336 BERLIN_PINCTRL_FUNCTION(0x3, "sts7"), /* VALD */ 337 BERLIN_PINCTRL_FUNCTION(0x4, "adac_test"), /* PWMCLK */ 338 BERLIN_PINCTRL_FUNCTION(0x5, "pdm"), /* DI1 */ 339 BERLIN_PINCTRL_FUNCTION(0x6, "sd1b")), /* WP */ 340 }; 341 342 static const struct berlin_desc_group berlin4ct_sysmgr_pinctrl_groups[] = { 343 BERLIN_PINCTRL_GROUP("SM_TW2_SCL", 0x0, 0x3, 0x00, 344 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO19 */ 345 BERLIN_PINCTRL_FUNCTION(0x1, "tw2")), /* SCL */ 346 BERLIN_PINCTRL_GROUP("SM_TW2_SDA", 0x0, 0x3, 0x03, 347 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO20 */ 348 BERLIN_PINCTRL_FUNCTION(0x1, "tw2")), /* SDA */ 349 BERLIN_PINCTRL_GROUP("SM_TW3_SCL", 0x0, 0x3, 0x06, 350 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO21 */ 351 BERLIN_PINCTRL_FUNCTION(0x1, "tw3")), /* SCL */ 352 BERLIN_PINCTRL_GROUP("SM_TW3_SDA", 0x0, 0x3, 0x09, 353 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO22 */ 354 BERLIN_PINCTRL_FUNCTION(0x1, "tw3")), /* SDA */ 355 BERLIN_PINCTRL_GROUP("SM_TMS", 0x0, 0x3, 0x0c, 356 BERLIN_PINCTRL_FUNCTION(0x0, "jtag"), /* TMS */ 357 BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* SM GPIO0 */ 358 BERLIN_PINCTRL_FUNCTION(0x2, "pwm0")), 359 BERLIN_PINCTRL_GROUP("SM_TDI", 0x0, 0x3, 0x0f, 360 BERLIN_PINCTRL_FUNCTION(0x0, "jtag"), /* TDI */ 361 BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* SM GPIO1 */ 362 BERLIN_PINCTRL_FUNCTION(0x2, "pwm1")), 363 BERLIN_PINCTRL_GROUP("SM_TDO", 0x0, 0x3, 0x12, 364 BERLIN_PINCTRL_FUNCTION(0x0, "jtag"), /* TDO */ 365 BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), /* SM GPIO2 */ 366 BERLIN_PINCTRL_GROUP("SM_URT0_TXD", 0x0, 0x3, 0x15, 367 BERLIN_PINCTRL_FUNCTION(0x0, "uart0"), /* TXD */ 368 BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), /* SM GPIO3 */ 369 BERLIN_PINCTRL_GROUP("SM_URT0_RXD", 0x0, 0x3, 0x18, 370 BERLIN_PINCTRL_FUNCTION(0x0, "uart0"), /* RXD */ 371 BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), /* SM GPIO4 */ 372 BERLIN_PINCTRL_GROUP("SM_URT1_TXD", 0x0, 0x3, 0x1b, 373 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO5 */ 374 BERLIN_PINCTRL_FUNCTION(0x1, "uart1"), /* TXD */ 375 BERLIN_PINCTRL_FUNCTION(0x2, "eth1"), /* RXCLK */ 376 BERLIN_PINCTRL_FUNCTION(0x3, "pwm2"), 377 BERLIN_PINCTRL_FUNCTION(0x4, "timer0"), 378 BERLIN_PINCTRL_FUNCTION(0x5, "clk_25m")), 379 BERLIN_PINCTRL_GROUP("SM_URT1_RXD", 0x4, 0x3, 0x00, 380 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO6 */ 381 BERLIN_PINCTRL_FUNCTION(0x1, "uart1"), /* RXD */ 382 BERLIN_PINCTRL_FUNCTION(0x3, "pwm3"), 383 BERLIN_PINCTRL_FUNCTION(0x4, "timer1")), 384 BERLIN_PINCTRL_GROUP("SM_SPI2_SS0n", 0x4, 0x3, 0x03, 385 BERLIN_PINCTRL_FUNCTION(0x0, "spi2"), /* SS0 n*/ 386 BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), /* SM GPIO7 */ 387 BERLIN_PINCTRL_GROUP("SM_SPI2_SS1n", 0x4, 0x3, 0x06, 388 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO8 */ 389 BERLIN_PINCTRL_FUNCTION(0x1, "spi2")), /* SS1n */ 390 BERLIN_PINCTRL_GROUP("SM_SPI2_SS2n", 0x4, 0x3, 0x09, 391 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO9 */ 392 BERLIN_PINCTRL_FUNCTION(0x1, "spi2"), /* SS2n */ 393 BERLIN_PINCTRL_FUNCTION(0x2, "eth1"), /* MDC */ 394 BERLIN_PINCTRL_FUNCTION(0x3, "pwm0"), 395 BERLIN_PINCTRL_FUNCTION(0x4, "timer0"), 396 BERLIN_PINCTRL_FUNCTION(0x5, "clk_25m")), 397 BERLIN_PINCTRL_GROUP("SM_SPI2_SS3n", 0x4, 0x3, 0x0c, 398 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO10 */ 399 BERLIN_PINCTRL_FUNCTION(0x1, "spi2"), /* SS3n */ 400 BERLIN_PINCTRL_FUNCTION(0x2, "eth1"), /* MDIO */ 401 BERLIN_PINCTRL_FUNCTION(0x3, "pwm1"), 402 BERLIN_PINCTRL_FUNCTION(0x4, "timer1")), 403 BERLIN_PINCTRL_GROUP("SM_SPI2_SDO", 0x4, 0x3, 0x0f, 404 BERLIN_PINCTRL_FUNCTION(0x0, "spi2"), /* SDO */ 405 BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), /* SM GPIO11 */ 406 BERLIN_PINCTRL_GROUP("SM_SPI2_SDI", 0x4, 0x3, 0x12, 407 BERLIN_PINCTRL_FUNCTION(0x0, "spi2"), /* SDI */ 408 BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), /* SM GPIO12 */ 409 BERLIN_PINCTRL_GROUP("SM_SPI2_SCLK", 0x4, 0x3, 0x15, 410 BERLIN_PINCTRL_FUNCTION(0x0, "spi2"), /* SCLK */ 411 BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), /* SM GPIO13 */ 412 BERLIN_PINCTRL_GROUP("SM_FE_LED0", 0x4, 0x3, 0x18, 413 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO14 */ 414 BERLIN_PINCTRL_FUNCTION(0x2, "led")), /* LED0 */ 415 BERLIN_PINCTRL_GROUP("SM_FE_LED1", 0x4, 0x3, 0x1b, 416 BERLIN_PINCTRL_FUNCTION(0x0, "pwr"), 417 BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), /* SM GPIO 15 */ 418 BERLIN_PINCTRL_FUNCTION(0x2, "led")), /* LED1 */ 419 BERLIN_PINCTRL_GROUP("SM_FE_LED2", 0x8, 0x3, 0x00, 420 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO16 */ 421 BERLIN_PINCTRL_FUNCTION(0x2, "led")), /* LED2 */ 422 BERLIN_PINCTRL_GROUP("SM_HDMI_HPD", 0x8, 0x3, 0x03, 423 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO17 */ 424 BERLIN_PINCTRL_FUNCTION(0x1, "hdmi")), /* HPD */ 425 BERLIN_PINCTRL_GROUP("SM_HDMI_CEC", 0x8, 0x3, 0x06, 426 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), /* SM GPIO18 */ 427 BERLIN_PINCTRL_FUNCTION(0x1, "hdmi")), /* CEC */ 428 }; 429 430 static const struct berlin_pinctrl_desc berlin4ct_soc_pinctrl_data = { 431 .groups = berlin4ct_soc_pinctrl_groups, 432 .ngroups = ARRAY_SIZE(berlin4ct_soc_pinctrl_groups), 433 }; 434 435 static const struct berlin_pinctrl_desc berlin4ct_avio_pinctrl_data = { 436 .groups = berlin4ct_avio_pinctrl_groups, 437 .ngroups = ARRAY_SIZE(berlin4ct_avio_pinctrl_groups), 438 }; 439 440 static const struct berlin_pinctrl_desc berlin4ct_sysmgr_pinctrl_data = { 441 .groups = berlin4ct_sysmgr_pinctrl_groups, 442 .ngroups = ARRAY_SIZE(berlin4ct_sysmgr_pinctrl_groups), 443 }; 444 445 static const struct of_device_id berlin4ct_pinctrl_match[] = { 446 { 447 .compatible = "marvell,berlin4ct-soc-pinctrl", 448 .data = &berlin4ct_soc_pinctrl_data, 449 }, 450 { 451 .compatible = "marvell,berlin4ct-avio-pinctrl", 452 .data = &berlin4ct_avio_pinctrl_data, 453 }, 454 { 455 .compatible = "marvell,berlin4ct-system-pinctrl", 456 .data = &berlin4ct_sysmgr_pinctrl_data, 457 }, 458 {} 459 }; 460 461 static int berlin4ct_pinctrl_probe(struct platform_device *pdev) 462 { 463 const struct of_device_id *match = 464 of_match_device(berlin4ct_pinctrl_match, &pdev->dev); 465 struct regmap_config *rmconfig; 466 struct regmap *regmap; 467 struct resource *res; 468 void __iomem *base; 469 470 rmconfig = devm_kzalloc(&pdev->dev, sizeof(*rmconfig), GFP_KERNEL); 471 if (!rmconfig) 472 return -ENOMEM; 473 474 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 475 base = devm_ioremap_resource(&pdev->dev, res); 476 if (IS_ERR(base)) 477 return PTR_ERR(base); 478 479 rmconfig->reg_bits = 32, 480 rmconfig->val_bits = 32, 481 rmconfig->reg_stride = 4, 482 rmconfig->max_register = resource_size(res); 483 484 regmap = devm_regmap_init_mmio(&pdev->dev, base, rmconfig); 485 if (IS_ERR(regmap)) 486 return PTR_ERR(regmap); 487 488 return berlin_pinctrl_probe_regmap(pdev, match->data, regmap); 489 } 490 491 static struct platform_driver berlin4ct_pinctrl_driver = { 492 .probe = berlin4ct_pinctrl_probe, 493 .driver = { 494 .name = "berlin4ct-pinctrl", 495 .of_match_table = berlin4ct_pinctrl_match, 496 }, 497 }; 498 builtin_platform_driver(berlin4ct_pinctrl_driver); 499