Skip to content

Commit 3a1b0ca

Browse files
parakalinusw
authored andcommitted
pinctrl: ralink: move RT305X SoC pinmux config into a new 'pinctrl-rt305x.c' file
Move all related code for SoC RT305X into a new driver located in 'pinctrl-rt305x.c' source file. Signed-off-by: Sergio Paracuellos <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 8b8b0fa commit 3a1b0ca

File tree

5 files changed

+142
-101
lines changed

5 files changed

+142
-101
lines changed

arch/mips/include/asm/mach-ralink/rt305x.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -114,30 +114,6 @@ static inline int soc_is_rt5350(void)
114114
#define RT305X_GPIO_GE0_TXD0 40
115115
#define RT305X_GPIO_GE0_RXCLK 51
116116

117-
#define RT305X_GPIO_MODE_UART0_SHIFT 2
118-
#define RT305X_GPIO_MODE_UART0_MASK 0x7
119-
#define RT305X_GPIO_MODE_UART0(x) ((x) << RT305X_GPIO_MODE_UART0_SHIFT)
120-
#define RT305X_GPIO_MODE_UARTF 0
121-
#define RT305X_GPIO_MODE_PCM_UARTF 1
122-
#define RT305X_GPIO_MODE_PCM_I2S 2
123-
#define RT305X_GPIO_MODE_I2S_UARTF 3
124-
#define RT305X_GPIO_MODE_PCM_GPIO 4
125-
#define RT305X_GPIO_MODE_GPIO_UARTF 5
126-
#define RT305X_GPIO_MODE_GPIO_I2S 6
127-
#define RT305X_GPIO_MODE_GPIO 7
128-
129-
#define RT305X_GPIO_MODE_I2C 0
130-
#define RT305X_GPIO_MODE_SPI 1
131-
#define RT305X_GPIO_MODE_UART1 5
132-
#define RT305X_GPIO_MODE_JTAG 6
133-
#define RT305X_GPIO_MODE_MDIO 7
134-
#define RT305X_GPIO_MODE_SDRAM 8
135-
#define RT305X_GPIO_MODE_RGMII 9
136-
#define RT5350_GPIO_MODE_PHY_LED 14
137-
#define RT5350_GPIO_MODE_SPI_CS1 21
138-
#define RT3352_GPIO_MODE_LNA 18
139-
#define RT3352_GPIO_MODE_PA 20
140-
141117
#define RT3352_SYSC_REG_SYSCFG0 0x010
142118
#define RT3352_SYSC_REG_SYSCFG1 0x014
143119
#define RT3352_SYSC_REG_CLKCFG1 0x030

arch/mips/ralink/rt305x.c

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -16,83 +16,9 @@
1616
#include <asm/mipsregs.h>
1717
#include <asm/mach-ralink/ralink_regs.h>
1818
#include <asm/mach-ralink/rt305x.h>
19-
#include <asm/mach-ralink/pinmux.h>
2019

2120
#include "common.h"
2221

23-
static struct rt2880_pmx_func i2c_func[] = { FUNC("i2c", 0, 1, 2) };
24-
static struct rt2880_pmx_func spi_func[] = { FUNC("spi", 0, 3, 4) };
25-
static struct rt2880_pmx_func uartf_func[] = {
26-
FUNC("uartf", RT305X_GPIO_MODE_UARTF, 7, 8),
27-
FUNC("pcm uartf", RT305X_GPIO_MODE_PCM_UARTF, 7, 8),
28-
FUNC("pcm i2s", RT305X_GPIO_MODE_PCM_I2S, 7, 8),
29-
FUNC("i2s uartf", RT305X_GPIO_MODE_I2S_UARTF, 7, 8),
30-
FUNC("pcm gpio", RT305X_GPIO_MODE_PCM_GPIO, 11, 4),
31-
FUNC("gpio uartf", RT305X_GPIO_MODE_GPIO_UARTF, 7, 4),
32-
FUNC("gpio i2s", RT305X_GPIO_MODE_GPIO_I2S, 7, 4),
33-
};
34-
static struct rt2880_pmx_func uartlite_func[] = { FUNC("uartlite", 0, 15, 2) };
35-
static struct rt2880_pmx_func jtag_func[] = { FUNC("jtag", 0, 17, 5) };
36-
static struct rt2880_pmx_func mdio_func[] = { FUNC("mdio", 0, 22, 2) };
37-
static struct rt2880_pmx_func rt5350_led_func[] = { FUNC("led", 0, 22, 5) };
38-
static struct rt2880_pmx_func rt5350_cs1_func[] = {
39-
FUNC("spi_cs1", 0, 27, 1),
40-
FUNC("wdg_cs1", 1, 27, 1),
41-
};
42-
static struct rt2880_pmx_func sdram_func[] = { FUNC("sdram", 0, 24, 16) };
43-
static struct rt2880_pmx_func rt3352_rgmii_func[] = {
44-
FUNC("rgmii", 0, 24, 12)
45-
};
46-
static struct rt2880_pmx_func rgmii_func[] = { FUNC("rgmii", 0, 40, 12) };
47-
static struct rt2880_pmx_func rt3352_lna_func[] = { FUNC("lna", 0, 36, 2) };
48-
static struct rt2880_pmx_func rt3352_pa_func[] = { FUNC("pa", 0, 38, 2) };
49-
static struct rt2880_pmx_func rt3352_led_func[] = { FUNC("led", 0, 40, 5) };
50-
static struct rt2880_pmx_func rt3352_cs1_func[] = {
51-
FUNC("spi_cs1", 0, 45, 1),
52-
FUNC("wdg_cs1", 1, 45, 1),
53-
};
54-
55-
static struct rt2880_pmx_group rt3050_pinmux_data[] = {
56-
GRP("i2c", i2c_func, 1, RT305X_GPIO_MODE_I2C),
57-
GRP("spi", spi_func, 1, RT305X_GPIO_MODE_SPI),
58-
GRP("uartf", uartf_func, RT305X_GPIO_MODE_UART0_MASK,
59-
RT305X_GPIO_MODE_UART0_SHIFT),
60-
GRP("uartlite", uartlite_func, 1, RT305X_GPIO_MODE_UART1),
61-
GRP("jtag", jtag_func, 1, RT305X_GPIO_MODE_JTAG),
62-
GRP("mdio", mdio_func, 1, RT305X_GPIO_MODE_MDIO),
63-
GRP("rgmii", rgmii_func, 1, RT305X_GPIO_MODE_RGMII),
64-
GRP("sdram", sdram_func, 1, RT305X_GPIO_MODE_SDRAM),
65-
{ 0 }
66-
};
67-
68-
static struct rt2880_pmx_group rt3352_pinmux_data[] = {
69-
GRP("i2c", i2c_func, 1, RT305X_GPIO_MODE_I2C),
70-
GRP("spi", spi_func, 1, RT305X_GPIO_MODE_SPI),
71-
GRP("uartf", uartf_func, RT305X_GPIO_MODE_UART0_MASK,
72-
RT305X_GPIO_MODE_UART0_SHIFT),
73-
GRP("uartlite", uartlite_func, 1, RT305X_GPIO_MODE_UART1),
74-
GRP("jtag", jtag_func, 1, RT305X_GPIO_MODE_JTAG),
75-
GRP("mdio", mdio_func, 1, RT305X_GPIO_MODE_MDIO),
76-
GRP("rgmii", rt3352_rgmii_func, 1, RT305X_GPIO_MODE_RGMII),
77-
GRP("lna", rt3352_lna_func, 1, RT3352_GPIO_MODE_LNA),
78-
GRP("pa", rt3352_pa_func, 1, RT3352_GPIO_MODE_PA),
79-
GRP("led", rt3352_led_func, 1, RT5350_GPIO_MODE_PHY_LED),
80-
GRP("spi_cs1", rt3352_cs1_func, 2, RT5350_GPIO_MODE_SPI_CS1),
81-
{ 0 }
82-
};
83-
84-
static struct rt2880_pmx_group rt5350_pinmux_data[] = {
85-
GRP("i2c", i2c_func, 1, RT305X_GPIO_MODE_I2C),
86-
GRP("spi", spi_func, 1, RT305X_GPIO_MODE_SPI),
87-
GRP("uartf", uartf_func, RT305X_GPIO_MODE_UART0_MASK,
88-
RT305X_GPIO_MODE_UART0_SHIFT),
89-
GRP("uartlite", uartlite_func, 1, RT305X_GPIO_MODE_UART1),
90-
GRP("jtag", jtag_func, 1, RT305X_GPIO_MODE_JTAG),
91-
GRP("led", rt5350_led_func, 1, RT5350_GPIO_MODE_PHY_LED),
92-
GRP("spi_cs1", rt5350_cs1_func, 2, RT5350_GPIO_MODE_SPI_CS1),
93-
{ 0 }
94-
};
95-
9622
static unsigned long rt5350_get_mem_size(void)
9723
{
9824
void __iomem *sysc = (void __iomem *) KSEG1ADDR(RT305X_SYSC_BASE);
@@ -265,14 +191,11 @@ void __init prom_soc_init(struct ralink_soc_info *soc_info)
265191
soc_info->mem_base = RT305X_SDRAM_BASE;
266192
if (soc_is_rt5350()) {
267193
soc_info->mem_size = rt5350_get_mem_size();
268-
rt2880_pinmux_data = rt5350_pinmux_data;
269194
} else if (soc_is_rt305x() || soc_is_rt3350()) {
270195
soc_info->mem_size_min = RT305X_MEM_SIZE_MIN;
271196
soc_info->mem_size_max = RT305X_MEM_SIZE_MAX;
272-
rt2880_pinmux_data = rt3050_pinmux_data;
273197
} else if (soc_is_rt3352()) {
274198
soc_info->mem_size_min = RT3352_MEM_SIZE_MIN;
275199
soc_info->mem_size_max = RT3352_MEM_SIZE_MAX;
276-
rt2880_pinmux_data = rt3352_pinmux_data;
277200
}
278201
}

drivers/pinctrl/ralink/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ config PINCTRL_MT7621
1616
depends on RALINK && SOC_MT7621
1717
select PINCTRL_RT2880
1818

19+
config PINCTRL_RT305X
20+
bool "RT305X pinctrl driver for RALINK/Mediatek SOCs"
21+
depends on RALINK && SOC_RT305X
22+
select PINCTRL_RT2880
23+
1924
config PINCTRL_RT3883
2025
bool "RT3883 pinctrl driver for RALINK/Mediatek SOCs"
2126
depends on RALINK && SOC_RT3883

drivers/pinctrl/ralink/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
obj-$(CONFIG_PINCTRL_RT2880) += pinctrl-rt2880.o
33

44
obj-$(CONFIG_PINCTRL_MT7621) += pinctrl-mt7621.o
5+
obj-$(CONFIG_PINCTRL_RT305X) += pinctrl-rt305x.o
56
obj-$(CONFIG_PINCTRL_RT3883) += pinctrl-rt3883.o
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
3+
#include <asm/mach-ralink/rt305x.h>
4+
#include <linux/module.h>
5+
#include <linux/platform_device.h>
6+
#include <linux/of.h>
7+
#include "pinmux.h"
8+
9+
#define RT305X_GPIO_MODE_UART0_SHIFT 2
10+
#define RT305X_GPIO_MODE_UART0_MASK 0x7
11+
#define RT305X_GPIO_MODE_UART0(x) ((x) << RT305X_GPIO_MODE_UART0_SHIFT)
12+
#define RT305X_GPIO_MODE_UARTF 0
13+
#define RT305X_GPIO_MODE_PCM_UARTF 1
14+
#define RT305X_GPIO_MODE_PCM_I2S 2
15+
#define RT305X_GPIO_MODE_I2S_UARTF 3
16+
#define RT305X_GPIO_MODE_PCM_GPIO 4
17+
#define RT305X_GPIO_MODE_GPIO_UARTF 5
18+
#define RT305X_GPIO_MODE_GPIO_I2S 6
19+
#define RT305X_GPIO_MODE_GPIO 7
20+
21+
#define RT305X_GPIO_MODE_I2C 0
22+
#define RT305X_GPIO_MODE_SPI 1
23+
#define RT305X_GPIO_MODE_UART1 5
24+
#define RT305X_GPIO_MODE_JTAG 6
25+
#define RT305X_GPIO_MODE_MDIO 7
26+
#define RT305X_GPIO_MODE_SDRAM 8
27+
#define RT305X_GPIO_MODE_RGMII 9
28+
#define RT5350_GPIO_MODE_PHY_LED 14
29+
#define RT5350_GPIO_MODE_SPI_CS1 21
30+
#define RT3352_GPIO_MODE_LNA 18
31+
#define RT3352_GPIO_MODE_PA 20
32+
33+
static struct rt2880_pmx_func i2c_func[] = { FUNC("i2c", 0, 1, 2) };
34+
static struct rt2880_pmx_func spi_func[] = { FUNC("spi", 0, 3, 4) };
35+
static struct rt2880_pmx_func uartf_func[] = {
36+
FUNC("uartf", RT305X_GPIO_MODE_UARTF, 7, 8),
37+
FUNC("pcm uartf", RT305X_GPIO_MODE_PCM_UARTF, 7, 8),
38+
FUNC("pcm i2s", RT305X_GPIO_MODE_PCM_I2S, 7, 8),
39+
FUNC("i2s uartf", RT305X_GPIO_MODE_I2S_UARTF, 7, 8),
40+
FUNC("pcm gpio", RT305X_GPIO_MODE_PCM_GPIO, 11, 4),
41+
FUNC("gpio uartf", RT305X_GPIO_MODE_GPIO_UARTF, 7, 4),
42+
FUNC("gpio i2s", RT305X_GPIO_MODE_GPIO_I2S, 7, 4),
43+
};
44+
static struct rt2880_pmx_func uartlite_func[] = { FUNC("uartlite", 0, 15, 2) };
45+
static struct rt2880_pmx_func jtag_func[] = { FUNC("jtag", 0, 17, 5) };
46+
static struct rt2880_pmx_func mdio_func[] = { FUNC("mdio", 0, 22, 2) };
47+
static struct rt2880_pmx_func rt5350_led_func[] = { FUNC("led", 0, 22, 5) };
48+
static struct rt2880_pmx_func rt5350_cs1_func[] = {
49+
FUNC("spi_cs1", 0, 27, 1),
50+
FUNC("wdg_cs1", 1, 27, 1),
51+
};
52+
static struct rt2880_pmx_func sdram_func[] = { FUNC("sdram", 0, 24, 16) };
53+
static struct rt2880_pmx_func rt3352_rgmii_func[] = {
54+
FUNC("rgmii", 0, 24, 12)
55+
};
56+
static struct rt2880_pmx_func rgmii_func[] = { FUNC("rgmii", 0, 40, 12) };
57+
static struct rt2880_pmx_func rt3352_lna_func[] = { FUNC("lna", 0, 36, 2) };
58+
static struct rt2880_pmx_func rt3352_pa_func[] = { FUNC("pa", 0, 38, 2) };
59+
static struct rt2880_pmx_func rt3352_led_func[] = { FUNC("led", 0, 40, 5) };
60+
static struct rt2880_pmx_func rt3352_cs1_func[] = {
61+
FUNC("spi_cs1", 0, 45, 1),
62+
FUNC("wdg_cs1", 1, 45, 1),
63+
};
64+
65+
static struct rt2880_pmx_group rt3050_pinmux_data[] = {
66+
GRP("i2c", i2c_func, 1, RT305X_GPIO_MODE_I2C),
67+
GRP("spi", spi_func, 1, RT305X_GPIO_MODE_SPI),
68+
GRP("uartf", uartf_func, RT305X_GPIO_MODE_UART0_MASK,
69+
RT305X_GPIO_MODE_UART0_SHIFT),
70+
GRP("uartlite", uartlite_func, 1, RT305X_GPIO_MODE_UART1),
71+
GRP("jtag", jtag_func, 1, RT305X_GPIO_MODE_JTAG),
72+
GRP("mdio", mdio_func, 1, RT305X_GPIO_MODE_MDIO),
73+
GRP("rgmii", rgmii_func, 1, RT305X_GPIO_MODE_RGMII),
74+
GRP("sdram", sdram_func, 1, RT305X_GPIO_MODE_SDRAM),
75+
{ 0 }
76+
};
77+
78+
static struct rt2880_pmx_group rt3352_pinmux_data[] = {
79+
GRP("i2c", i2c_func, 1, RT305X_GPIO_MODE_I2C),
80+
GRP("spi", spi_func, 1, RT305X_GPIO_MODE_SPI),
81+
GRP("uartf", uartf_func, RT305X_GPIO_MODE_UART0_MASK,
82+
RT305X_GPIO_MODE_UART0_SHIFT),
83+
GRP("uartlite", uartlite_func, 1, RT305X_GPIO_MODE_UART1),
84+
GRP("jtag", jtag_func, 1, RT305X_GPIO_MODE_JTAG),
85+
GRP("mdio", mdio_func, 1, RT305X_GPIO_MODE_MDIO),
86+
GRP("rgmii", rt3352_rgmii_func, 1, RT305X_GPIO_MODE_RGMII),
87+
GRP("lna", rt3352_lna_func, 1, RT3352_GPIO_MODE_LNA),
88+
GRP("pa", rt3352_pa_func, 1, RT3352_GPIO_MODE_PA),
89+
GRP("led", rt3352_led_func, 1, RT5350_GPIO_MODE_PHY_LED),
90+
GRP("spi_cs1", rt3352_cs1_func, 2, RT5350_GPIO_MODE_SPI_CS1),
91+
{ 0 }
92+
};
93+
94+
static struct rt2880_pmx_group rt5350_pinmux_data[] = {
95+
GRP("i2c", i2c_func, 1, RT305X_GPIO_MODE_I2C),
96+
GRP("spi", spi_func, 1, RT305X_GPIO_MODE_SPI),
97+
GRP("uartf", uartf_func, RT305X_GPIO_MODE_UART0_MASK,
98+
RT305X_GPIO_MODE_UART0_SHIFT),
99+
GRP("uartlite", uartlite_func, 1, RT305X_GPIO_MODE_UART1),
100+
GRP("jtag", jtag_func, 1, RT305X_GPIO_MODE_JTAG),
101+
GRP("led", rt5350_led_func, 1, RT5350_GPIO_MODE_PHY_LED),
102+
GRP("spi_cs1", rt5350_cs1_func, 2, RT5350_GPIO_MODE_SPI_CS1),
103+
{ 0 }
104+
};
105+
106+
static int rt305x_pinmux_probe(struct platform_device *pdev)
107+
{
108+
if (soc_is_rt5350())
109+
return rt2880_pinmux_init(pdev, rt5350_pinmux_data);
110+
else if (soc_is_rt305x() || soc_is_rt3350())
111+
return rt2880_pinmux_init(pdev, rt3050_pinmux_data);
112+
else if (soc_is_rt3352())
113+
return rt2880_pinmux_init(pdev, rt3352_pinmux_data);
114+
else
115+
return -EINVAL;
116+
}
117+
118+
static const struct of_device_id rt305x_pinmux_match[] = {
119+
{ .compatible = "ralink,rt2880-pinmux" },
120+
{}
121+
};
122+
MODULE_DEVICE_TABLE(of, rt305x_pinmux_match);
123+
124+
static struct platform_driver rt305x_pinmux_driver = {
125+
.probe = rt305x_pinmux_probe,
126+
.driver = {
127+
.name = "rt2880-pinmux",
128+
.of_match_table = rt305x_pinmux_match,
129+
},
130+
};
131+
132+
static int __init rt305x_pinmux_init(void)
133+
{
134+
return platform_driver_register(&rt305x_pinmux_driver);
135+
}
136+
core_initcall_sync(rt305x_pinmux_init);

0 commit comments

Comments
 (0)