1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Marvell Berlin BG2 pinctrl driver. 4 * 5 * Copyright (C) 2014 Marvell Technology Group Ltd. 6 * 7 * Antoine Ténart <antoine.tenart@free-electrons.com> 8 */ 9 10 #include <linux/init.h> 11 #include <linux/of_device.h> 12 #include <linux/platform_device.h> 13 #include <linux/regmap.h> 14 15 #include "berlin.h" 16 17 static const struct berlin_desc_group berlin2_soc_pinctrl_groups[] = { 18 /* G */ 19 BERLIN_PINCTRL_GROUP("G0", 0x00, 0x1, 0x00, 20 BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SS0n */ 21 BERLIN_PINCTRL_FUNCTION(0x1, "gpio")), 22 BERLIN_PINCTRL_GROUP("G1", 0x00, 0x2, 0x01, 23 BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* SS1n */ 24 BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), 25 BERLIN_PINCTRL_FUNCTION(0x2, "usb1")), 26 BERLIN_PINCTRL_GROUP("G2", 0x00, 0x2, 0x02, 27 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 28 BERLIN_PINCTRL_FUNCTION(0x1, "spi1"), /* SS2n */ 29 BERLIN_PINCTRL_FUNCTION(0x2, "pwm"), 30 BERLIN_PINCTRL_FUNCTION(0x3, "i2s0")), 31 BERLIN_PINCTRL_GROUP("G3", 0x00, 0x2, 0x04, 32 BERLIN_PINCTRL_FUNCTION(0x0, "soc"), 33 BERLIN_PINCTRL_FUNCTION(0x1, "spi1"), /* SS3n */ 34 BERLIN_PINCTRL_FUNCTION(0x2, "gpio"), 35 BERLIN_PINCTRL_FUNCTION(0x3, "i2s1")), 36 BERLIN_PINCTRL_GROUP("G4", 0x00, 0x2, 0x06, 37 BERLIN_PINCTRL_FUNCTION(0x0, "spi1"), /* CLK/SDI/SDO */ 38 BERLIN_PINCTRL_FUNCTION(0x1, "gpio"), 39 BERLIN_PINCTRL_FUNCTION(0x2, "pwm")), 40 BERLIN_PINCTRL_GROUP("G5", 0x00, 0x3, 0x08, 41 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 42 BERLIN_PINCTRL_FUNCTION(0x1, "sts1"), 43 BERLIN_PINCTRL_FUNCTION(0x2, "et"), 44 /* 45 * Mode 0x3 mux i2s2 mclk *and* i2s3 mclk: 46 * add two functions so it can be used with other groups 47 * within the same subnode in the device tree 48 */ 49 BERLIN_PINCTRL_FUNCTION(0x3, "i2s2"), 50 BERLIN_PINCTRL_FUNCTION(0x3, "i2s3")), 51 BERLIN_PINCTRL_GROUP("G6", 0x00, 0x2, 0x0b, 52 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 53 BERLIN_PINCTRL_FUNCTION(0x1, "sts0"), 54 BERLIN_PINCTRL_FUNCTION(0x2, "et")), 55 BERLIN_PINCTRL_GROUP("G7", 0x00, 0x3, 0x0d, 56 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 57 BERLIN_PINCTRL_FUNCTION(0x1, "sts0"), 58 BERLIN_PINCTRL_FUNCTION(0x2, "et"), 59 BERLIN_PINCTRL_FUNCTION(0x3, "vdac")), 60 BERLIN_PINCTRL_GROUP("G8", 0x00, 0x3, 0x10, 61 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 62 BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), 63 BERLIN_PINCTRL_FUNCTION(0x2, "et"), 64 BERLIN_PINCTRL_FUNCTION(0x3, "usb0_dbg"), 65 BERLIN_PINCTRL_FUNCTION(0x4, "sata_dbg"), 66 BERLIN_PINCTRL_FUNCTION(0x7, "usb1_dbg")), 67 BERLIN_PINCTRL_GROUP("G9", 0x00, 0x3, 0x13, 68 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 69 BERLIN_PINCTRL_FUNCTION(0x1, "sd0"), 70 BERLIN_PINCTRL_FUNCTION(0x2, "et"), 71 BERLIN_PINCTRL_FUNCTION(0x3, "usb0_dbg"), 72 BERLIN_PINCTRL_FUNCTION(0x4, "sata_dbg"), 73 BERLIN_PINCTRL_FUNCTION(0x7, "usb1_dbg")), 74 BERLIN_PINCTRL_GROUP("G10", 0x00, 0x2, 0x16, 75 BERLIN_PINCTRL_FUNCTION(0x0, "soc"), 76 BERLIN_PINCTRL_FUNCTION(0x1, "twsi0"), 77 BERLIN_PINCTRL_FUNCTION(0x2, "gpio"), 78 BERLIN_PINCTRL_FUNCTION(0x3, "ptp")), 79 BERLIN_PINCTRL_GROUP("G11", 0x00, 0x2, 0x18, 80 BERLIN_PINCTRL_FUNCTION(0x0, "soc"), 81 BERLIN_PINCTRL_FUNCTION(0x1, "twsi1"), 82 BERLIN_PINCTRL_FUNCTION(0x2, "gpio"), 83 BERLIN_PINCTRL_FUNCTION(0x3, "eddc")), 84 BERLIN_PINCTRL_GROUP("G12", 0x00, 0x3, 0x1a, 85 BERLIN_PINCTRL_FUNCTION(0x0, "sts2"), 86 BERLIN_PINCTRL_FUNCTION(0x1, "sata"), 87 BERLIN_PINCTRL_FUNCTION(0x2, "sd1"), 88 BERLIN_PINCTRL_FUNCTION(0x3, "usb0_dbg"), 89 BERLIN_PINCTRL_FUNCTION(0x4, "sts1"), 90 BERLIN_PINCTRL_FUNCTION(0x7, "usb1_dbg")), 91 BERLIN_PINCTRL_GROUP("G13", 0x04, 0x3, 0x00, 92 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 93 BERLIN_PINCTRL_FUNCTION(0x1, "sata"), 94 BERLIN_PINCTRL_FUNCTION(0x2, "sd1"), 95 BERLIN_PINCTRL_FUNCTION(0x3, "usb0_dbg"), 96 BERLIN_PINCTRL_FUNCTION(0x4, "sts1"), 97 BERLIN_PINCTRL_FUNCTION(0x7, "usb1_dbg")), 98 BERLIN_PINCTRL_GROUP("G14", 0x04, 0x1, 0x03, 99 BERLIN_PINCTRL_FUNCTION_UNKNOWN), 100 BERLIN_PINCTRL_GROUP("G15", 0x04, 0x2, 0x04, 101 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 102 BERLIN_PINCTRL_FUNCTION(0x2, "et"), 103 BERLIN_PINCTRL_FUNCTION(0x3, "osco")), 104 BERLIN_PINCTRL_GROUP("G16", 0x04, 0x3, 0x06, 105 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 106 BERLIN_PINCTRL_FUNCTION(0x1, "dvio"), 107 BERLIN_PINCTRL_FUNCTION(0x2, "fp")), 108 BERLIN_PINCTRL_GROUP("G17", 0x04, 0x3, 0x09, 109 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 110 BERLIN_PINCTRL_FUNCTION(0x1, "dvio"), 111 BERLIN_PINCTRL_FUNCTION(0x2, "fp")), 112 BERLIN_PINCTRL_GROUP("G18", 0x04, 0x1, 0x0c, 113 BERLIN_PINCTRL_FUNCTION(0x0, "pll"), 114 BERLIN_PINCTRL_FUNCTION(0x1, "i2s0")), 115 BERLIN_PINCTRL_GROUP("G19", 0x04, 0x1, 0x0d, 116 BERLIN_PINCTRL_FUNCTION(0x0, "i2s0"), 117 BERLIN_PINCTRL_FUNCTION(0x1, "pwm")), 118 BERLIN_PINCTRL_GROUP("G20", 0x04, 0x1, 0x0e, 119 BERLIN_PINCTRL_FUNCTION(0x0, "spdif"), 120 BERLIN_PINCTRL_FUNCTION(0x1, "arc")), 121 BERLIN_PINCTRL_GROUP("G21", 0x04, 0x3, 0x0f, 122 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 123 BERLIN_PINCTRL_FUNCTION(0x1, "dvio"), 124 BERLIN_PINCTRL_FUNCTION(0x2, "fp"), 125 BERLIN_PINCTRL_FUNCTION(0x3, "adac_dbg"), 126 BERLIN_PINCTRL_FUNCTION(0x4, "pdm_a"), /* gpio17..19,pdm */ 127 BERLIN_PINCTRL_FUNCTION(0x7, "pdm_b")), /* gpio12..14,pdm */ 128 BERLIN_PINCTRL_GROUP("G22", 0x04, 0x3, 0x12, 129 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 130 BERLIN_PINCTRL_FUNCTION(0x1, "dv0"), 131 BERLIN_PINCTRL_FUNCTION(0x2, "fp"), 132 BERLIN_PINCTRL_FUNCTION(0x3, "twsi0"), 133 BERLIN_PINCTRL_FUNCTION(0x4, "pwm")), 134 BERLIN_PINCTRL_GROUP("G23", 0x04, 0x3, 0x15, 135 BERLIN_PINCTRL_FUNCTION(0x0, "vclki"), 136 BERLIN_PINCTRL_FUNCTION(0x1, "dv0"), 137 BERLIN_PINCTRL_FUNCTION(0x2, "fp"), 138 BERLIN_PINCTRL_FUNCTION(0x3, "i2s0"), 139 BERLIN_PINCTRL_FUNCTION(0x4, "pwm"), 140 BERLIN_PINCTRL_FUNCTION(0x7, "pdm")), 141 BERLIN_PINCTRL_GROUP("G24", 0x04, 0x2, 0x18, 142 BERLIN_PINCTRL_FUNCTION(0x0, "i2s2"), 143 BERLIN_PINCTRL_FUNCTION(0x1, "i2s1")), 144 BERLIN_PINCTRL_GROUP("G25", 0x04, 0x2, 0x1a, 145 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 146 BERLIN_PINCTRL_FUNCTION(0x1, "nand"), 147 BERLIN_PINCTRL_FUNCTION(0x2, "i2s2")), 148 BERLIN_PINCTRL_GROUP("G26", 0x04, 0x1, 0x1c, 149 BERLIN_PINCTRL_FUNCTION(0x0, "nand"), 150 BERLIN_PINCTRL_FUNCTION(0x1, "emmc")), 151 BERLIN_PINCTRL_GROUP("G27", 0x04, 0x1, 0x1d, 152 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 153 BERLIN_PINCTRL_FUNCTION(0x1, "nand")), 154 BERLIN_PINCTRL_GROUP("G28", 0x04, 0x2, 0x1e, 155 BERLIN_PINCTRL_FUNCTION(0x0, "dvo"), 156 BERLIN_PINCTRL_FUNCTION(0x2, "sp")), 157 }; 158 159 static const struct berlin_desc_group berlin2_sysmgr_pinctrl_groups[] = { 160 /* GSM */ 161 BERLIN_PINCTRL_GROUP("GSM0", 0x40, 0x2, 0x00, 162 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 163 BERLIN_PINCTRL_FUNCTION(0x1, "spi2"), /* SS0n */ 164 BERLIN_PINCTRL_FUNCTION(0x2, "eth1")), 165 BERLIN_PINCTRL_GROUP("GSM1", 0x40, 0x2, 0x02, 166 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 167 BERLIN_PINCTRL_FUNCTION(0x1, "spi2"), /* SS1n */ 168 BERLIN_PINCTRL_FUNCTION(0x2, "eth1")), 169 BERLIN_PINCTRL_GROUP("GSM2", 0x40, 0x2, 0x04, 170 BERLIN_PINCTRL_FUNCTION(0x0, "twsi2"), 171 BERLIN_PINCTRL_FUNCTION(0x1, "spi2")), /* SS2n/SS3n */ 172 BERLIN_PINCTRL_GROUP("GSM3", 0x40, 0x2, 0x06, 173 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 174 BERLIN_PINCTRL_FUNCTION(0x1, "uart0"), /* CTS/RTS */ 175 BERLIN_PINCTRL_FUNCTION(0x2, "uart2"), /* RX/TX */ 176 BERLIN_PINCTRL_FUNCTION(0x3, "twsi2")), 177 BERLIN_PINCTRL_GROUP("GSM4", 0x40, 0x2, 0x08, 178 BERLIN_PINCTRL_FUNCTION(0x0, "uart0"), /* RX/TX */ 179 BERLIN_PINCTRL_FUNCTION(0x1, "irda0")), 180 BERLIN_PINCTRL_GROUP("GSM5", 0x40, 0x2, 0x0a, 181 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 182 BERLIN_PINCTRL_FUNCTION(0x1, "uart1"), /* RX/TX */ 183 BERLIN_PINCTRL_FUNCTION(0x2, "irda1"), 184 BERLIN_PINCTRL_FUNCTION(0x3, "twsi3")), 185 BERLIN_PINCTRL_GROUP("GSM6", 0x40, 0x2, 0x0c, 186 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 187 BERLIN_PINCTRL_FUNCTION(0x1, "spi2"), /* CLK/SDO */ 188 BERLIN_PINCTRL_FUNCTION(0x1, "clki")), 189 BERLIN_PINCTRL_GROUP("GSM7", 0x40, 0x1, 0x0e, 190 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 191 BERLIN_PINCTRL_FUNCTION(0x1, "hdmi")), 192 BERLIN_PINCTRL_GROUP("GSM8", 0x40, 0x1, 0x0f, 193 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 194 BERLIN_PINCTRL_FUNCTION(0x1, "hdmi")), 195 BERLIN_PINCTRL_GROUP("GSM9", 0x40, 0x1, 0x10, 196 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 197 BERLIN_PINCTRL_FUNCTION(0x1, "led")), 198 BERLIN_PINCTRL_GROUP("GSM10", 0x40, 0x1, 0x11, 199 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 200 BERLIN_PINCTRL_FUNCTION(0x1, "led")), 201 BERLIN_PINCTRL_GROUP("GSM11", 0x40, 0x1, 0x12, 202 BERLIN_PINCTRL_FUNCTION(0x0, "gpio"), 203 BERLIN_PINCTRL_FUNCTION(0x1, "led")), 204 }; 205 206 static const struct berlin_pinctrl_desc berlin2_soc_pinctrl_data = { 207 .groups = berlin2_soc_pinctrl_groups, 208 .ngroups = ARRAY_SIZE(berlin2_soc_pinctrl_groups), 209 }; 210 211 static const struct berlin_pinctrl_desc berlin2_sysmgr_pinctrl_data = { 212 .groups = berlin2_sysmgr_pinctrl_groups, 213 .ngroups = ARRAY_SIZE(berlin2_sysmgr_pinctrl_groups), 214 }; 215 216 static const struct of_device_id berlin2_pinctrl_match[] = { 217 { 218 .compatible = "marvell,berlin2-soc-pinctrl", 219 .data = &berlin2_soc_pinctrl_data 220 }, 221 { 222 .compatible = "marvell,berlin2-system-pinctrl", 223 .data = &berlin2_sysmgr_pinctrl_data 224 }, 225 {} 226 }; 227 228 static int berlin2_pinctrl_probe(struct platform_device *pdev) 229 { 230 const struct of_device_id *match = 231 of_match_device(berlin2_pinctrl_match, &pdev->dev); 232 233 return berlin_pinctrl_probe(pdev, match->data); 234 } 235 236 static struct platform_driver berlin2_pinctrl_driver = { 237 .probe = berlin2_pinctrl_probe, 238 .driver = { 239 .name = "berlin-bg2-pinctrl", 240 .of_match_table = berlin2_pinctrl_match, 241 }, 242 }; 243 builtin_platform_driver(berlin2_pinctrl_driver); 244