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