1 // SPDX-License-Identifier: (GPL-2.0 OR MIT)
3 * Microsemi SoCs pinctrl driver
6 * Copyright (c) 2019 Microsemi Corporation
12 #include <dm/device-internal.h>
14 #include <dm/pinctrl.h>
20 #include <asm/system.h>
21 #include "mscc-common.h"
73 static char * const servalt_function_names[] = {
76 [FUNC_IRQ0_IN] = "irq0_in",
77 [FUNC_IRQ0_OUT] = "irq0_out",
78 [FUNC_IRQ1_IN] = "irq1_in",
79 [FUNC_IRQ1_OUT] = "irq1_out",
80 [FUNC_MIIM1] = "miim1",
81 [FUNC_MIIM2] = "miim2",
82 [FUNC_PCI_WAKE] = "pci_wake",
88 [FUNC_RCVRD_CLK0] = "rcvrd_clk0",
89 [FUNC_RCVRD_CLK1] = "rcvrd_clk1",
90 [FUNC_RCVRD_CLK2] = "rcvrd_clk2",
91 [FUNC_RCVRD_CLK3] = "rcvrd_clk3",
92 [FUNC_REF_CLK0] = "ref_clk0",
93 [FUNC_REF_CLK1] = "ref_clk1",
94 [FUNC_REF_CLK2] = "ref_clk2",
95 [FUNC_REF_CLK3] = "ref_clk3",
100 [FUNC_SFP4] = "sfp4",
101 [FUNC_SFP5] = "sfp5",
102 [FUNC_SFP6] = "sfp6",
103 [FUNC_SFP7] = "sfp7",
104 [FUNC_SFP8] = "sfp8",
105 [FUNC_SFP9] = "sfp9",
106 [FUNC_SFP10] = "sfp10",
107 [FUNC_SFP11] = "sfp11",
108 [FUNC_SFP12] = "sfp12",
109 [FUNC_SFP13] = "sfp13",
110 [FUNC_SFP14] = "sfp14",
111 [FUNC_SFP15] = "sfp15",
114 [FUNC_TACHO] = "tacho",
116 [FUNC_TWI2] = "twi2",
117 [FUNC_TWI_SCL_M] = "twi_scl_m",
118 [FUNC_UART] = "uart",
119 [FUNC_UART2] = "uart2",
122 MSCC_P(0, SIO, NONE, NONE);
123 MSCC_P(1, SIO, NONE, NONE);
124 MSCC_P(2, SIO, NONE, NONE);
125 MSCC_P(3, SIO, NONE, NONE);
126 MSCC_P(4, IRQ0_IN, IRQ0_OUT, TWI_SCL_M);
127 MSCC_P(5, IRQ1_IN, IRQ1_OUT, TWI_SCL_M);
128 MSCC_P(6, UART, NONE, NONE);
129 MSCC_P(7, UART, NONE, NONE);
130 MSCC_P(8, SPI, SFP0, TWI_SCL_M);
131 MSCC_P(9, PCI_WAKE, SFP1, SPI);
132 MSCC_P(10, PTP0, SFP2, TWI_SCL_M);
133 MSCC_P(11, PTP1, SFP3, TWI_SCL_M);
134 MSCC_P(12, REF_CLK0, SFP4, TWI_SCL_M);
135 MSCC_P(13, REF_CLK1, SFP5, TWI_SCL_M);
136 MSCC_P(14, REF_CLK2, IRQ0_OUT, SPI);
137 MSCC_P(15, REF_CLK3, IRQ1_OUT, SPI);
138 MSCC_P(16, TACHO, SFP6, SPI);
139 MSCC_P(17, PWM, NONE, TWI_SCL_M);
140 MSCC_P(18, PTP2, SFP7, SPI);
141 MSCC_P(19, PTP3, SFP8, SPI);
142 MSCC_P(20, UART2, SFP9, SPI);
143 MSCC_P(21, UART2, NONE, NONE);
144 MSCC_P(22, MIIM1, SFP10, TWI2);
145 MSCC_P(23, MIIM1, SFP11, TWI2);
146 MSCC_P(24, TWI, NONE, NONE);
147 MSCC_P(25, TWI, SFP12, TWI_SCL_M);
148 MSCC_P(26, TWI_SCL_M, SFP13, SPI);
149 MSCC_P(27, TWI_SCL_M, SFP14, SPI);
150 MSCC_P(28, TWI_SCL_M, SFP15, SPI);
151 MSCC_P(29, TWI_SCL_M, NONE, NONE);
152 MSCC_P(30, TWI_SCL_M, NONE, NONE);
153 MSCC_P(31, TWI_SCL_M, NONE, NONE);
154 MSCC_P(32, TWI_SCL_M, NONE, NONE);
155 MSCC_P(33, RCVRD_CLK0, NONE, NONE);
156 MSCC_P(34, RCVRD_CLK1, NONE, NONE);
157 MSCC_P(35, RCVRD_CLK2, NONE, NONE);
158 MSCC_P(36, RCVRD_CLK3, NONE, NONE);
160 #define SERVALT_PIN(n) { \
162 .drv_data = &mscc_pin_##n \
165 static const struct mscc_pin_data servalt_pins[] = {
205 static const unsigned long servalt_gpios[] = {
206 [MSCC_GPIO_OUT_SET] = 0x00,
207 [MSCC_GPIO_OUT_CLR] = 0x08,
208 [MSCC_GPIO_OUT] = 0x10,
209 [MSCC_GPIO_IN] = 0x18,
210 [MSCC_GPIO_OE] = 0x20,
211 [MSCC_GPIO_INTR] = 0x28,
212 [MSCC_GPIO_INTR_ENA] = 0x30,
213 [MSCC_GPIO_INTR_IDENT] = 0x38,
214 [MSCC_GPIO_ALT0] = 0x40,
215 [MSCC_GPIO_ALT1] = 0x48,
218 static int servalt_gpio_probe(struct udevice *dev)
220 struct gpio_dev_priv *uc_priv;
222 uc_priv = dev_get_uclass_priv(dev);
223 uc_priv->bank_name = "servalt-gpio";
224 uc_priv->gpio_count = ARRAY_SIZE(servalt_pins);
229 static struct driver servalt_gpio_driver = {
230 .name = "servalt-gpio",
232 .probe = servalt_gpio_probe,
233 .ops = &mscc_gpio_ops,
236 static int servalt_pinctrl_probe(struct udevice *dev)
240 ret = mscc_pinctrl_probe(dev, FUNC_MAX, servalt_pins,
241 ARRAY_SIZE(servalt_pins),
242 servalt_function_names,
248 ret = device_bind(dev, &servalt_gpio_driver, "servalt-gpio", NULL,
249 dev_ofnode(dev), NULL);
257 static const struct udevice_id servalt_pinctrl_of_match[] = {
258 { .compatible = "mscc,servalt-pinctrl" },
262 U_BOOT_DRIVER(servalt_pinctrl) = {
263 .name = "servalt-pinctrl",
264 .id = UCLASS_PINCTRL,
265 .of_match = of_match_ptr(servalt_pinctrl_of_match),
266 .probe = servalt_pinctrl_probe,
267 .priv_auto = sizeof(struct mscc_pinctrl),
268 .ops = &mscc_pinctrl_ops,