Skip to contentSkip to conversation

pinctrl: ralink: move all pinmux arch stuff into driver code

PATCH In review Sergio Paracuellos 2 participants 9 messages Jun 4, 2021 – Jun 7, 2021

Subsystems (5)
MIPS GPIO Arm MediaTek Pin control +1 more subsystems
lore
Share & tools
lore

Sergio Paracuellos

author maintainer
#0 lore raw

cover pinctrl: ralink: move all pinmux arch stuff into driver code

Ralink architecture have all pinmux config for different SoCs in architecture headers. This SoCs configs are:
- CONFIG_SOC_RT288X
- CONFIG_SOC_RT305X
- CONFIG_SOC_RT3883
- CONFIG_SOC_MT7620
- CONFIG_SOC_MT7621

We currently have 'drivers/pinctrl/ralink/' with common code to all of them in 'pinctrl-rt2880.c' file. Pinctrl data was being passed in SoC initilization to the driver. Instead of doing that just move all related code to the driver itself. We maintain for all of them compatible string to avoid to make more changes in dts's an so on. If a new compatible string is neccessary to be defined for each different SoC, we can change them after this series are applied.

I have only tested MT7621 platform using GNUBee PC1 board. I don't have other boards to test other SoC changes.

This series are rebased on the master branch of linux-pinctrl git tree so I expect this to be merged through pinctrl tree. Thomas, if 'linux-mips' is preferred to merge this series just let me know and I can rebase them to make you things easier.

Thanks in advance for your time.

Best regards,
Sergio Paracuellos

Sergio Paracuellos (6):
pinctrl: ralink: move ralink architecture pinmux header into the
driver
pinctrl: ralink: move MT7621 SoC pinmux config into a new

    'pinctrl-mt7621.c' file
  pinctrl: ralink: move RT3883 SoC pinmux config into a new
    'pinctrl-rt3883.c' file
  pinctrl: ralink: move RT305X SoC pinmux config into a new
    'pinctrl-rt305x.c' file
  pinctrl: ralink: move MT7620 SoC pinmux config into a new
    'pinctrl-mt7620.c' file
  pinctrl: ralink: move RT288X SoC pinmux config into a new
    'pinctrl-rt288x.c' file
 arch/mips/include/asm/mach-ralink/mt7620.h    |  53 +-
 arch/mips/include/asm/mach-ralink/rt288x.h    |   9 -
 arch/mips/include/asm/mach-ralink/rt305x.h    |  24 -
 arch/mips/include/asm/mach-ralink/rt3883.h    |  34 --
 arch/mips/ralink/mt7620.c                     | 320 ------------
 arch/mips/ralink/mt7621.c                     |  88 ----
 arch/mips/ralink/prom.c                       |   1 -
 arch/mips/ralink/rt288x.c                     |  21 -
 arch/mips/ralink/rt305x.c                     |  77 ---
 arch/mips/ralink/rt3883.c                     |  45 --
 drivers/pinctrl/ralink/Kconfig                |  25 +
 drivers/pinctrl/ralink/Makefile               |   6 +
 .../pinctrl/ralink/pinctrl-mt7620.c           | 472 +++---------------
 drivers/pinctrl/ralink/pinctrl-mt7621.c       | 116 +++++
 drivers/pinctrl/ralink/pinctrl-rt2880.c       |  30 +-
 drivers/pinctrl/ralink/pinctrl-rt288x.c       |  60 +++
 drivers/pinctrl/ralink/pinctrl-rt305x.c       | 136 +++++
 drivers/pinctrl/ralink/pinctrl-rt3883.c       | 107 ++++
 .../pinctrl/ralink}/pinmux.h                  |   3 +-
 19 files changed, 536 insertions(+), 1091 deletions(-)
 copy arch/mips/ralink/mt7620.c => drivers/pinctrl/ralink/pinctrl-mt7620.c (51%)
 create mode 100644 drivers/pinctrl/ralink/pinctrl-mt7621.c
 create mode 100644 drivers/pinctrl/ralink/pinctrl-rt288x.c
 create mode 100644 drivers/pinctrl/ralink/pinctrl-rt305x.c
 create mode 100644 drivers/pinctrl/ralink/pinctrl-rt3883.c
 rename {arch/mips/include/asm/mach-ralink => drivers/pinctrl/ralink}/pinmux.h (91%)
Signature · 1 line
2.25.1
author maintainer
#1 lore raw

PATCH 1/6 pinctrl: ralink: move ralink architecture pinmux header into the driver

Ralink architecture is making use of the header located in 'arch/mips/include/asm/mach-ralink/pinmux.h' to stablish the mechanisms to make derived SoCs to set its pin functions and groups. In order to move all architecture pinmux into a more accurate place which is 'drivers/pinctrl/ralink' we have to first of all move this file also there with a small modification which creates 'rt2880_pinmux_init' function to allow SoCs pinctrl drivers to pass its configuration to the common code located in 'pinctrl-rt2880.c' file.

---
 arch/mips/ralink/prom.c                       |  1 -
 drivers/pinctrl/ralink/pinctrl-rt2880.c       | 30 ++++---------------
 .../pinctrl/ralink}/pinmux.h                  |  3 +-
 3 files changed, 7 insertions(+), 27 deletions(-)
 rename {arch/mips/include/asm/mach-ralink => drivers/pinctrl/ralink}/pinmux.h (91%)
arch/mips/ralink/prom.c +0 -1
index 25728def3503..aaac1e6ec7d9 100644
@@ -18,7 +18,6 @@
 #include "common.h"
 
 struct ralink_soc_info soc_info;
-struct rt2880_pmx_group *rt2880_pinmux_data = NULL;
 
 enum ralink_soc_type ralink_soc;
 EXPORT_SYMBOL_GPL(ralink_soc);
drivers/pinctrl/ralink/pinctrl-rt2880.c +5 -25
index 1f4bca854add..abe31d4d448e 100644
@@ -17,9 +17,9 @@
 #include <linux/pinctrl/machine.h>
 
 #include <asm/mach-ralink/ralink_regs.h>
-#include <asm/mach-ralink/pinmux.h>
 #include <asm/mach-ralink/mt7620.h>
 
+#include "pinmux.h"
 #include "../core.h"
 #include "../pinctrl-utils.h"
 
@@ -311,13 +311,14 @@ static int rt2880_pinmux_pins(struct rt2880_priv *p)
 	return 0;
 }
 
-static int rt2880_pinmux_probe(struct platform_device *pdev)
+int rt2880_pinmux_init(struct platform_device *pdev,
+		       struct rt2880_pmx_group *data)
 {
 	struct rt2880_priv *p;
 	struct pinctrl_dev *dev;
 	int err;
 
-	if (!rt2880_pinmux_data)
+	if (!data)
 		return -ENOTSUPP;
 
 	/* setup the private data */
@@ -327,7 +328,7 @@ static int rt2880_pinmux_probe(struct platform_device *pdev)
 
 	p->dev = &pdev->dev;
 	p->desc = &rt2880_pctrl_desc;
-	p->groups = rt2880_pinmux_data;
+	p->groups = data;
 	platform_set_drvdata(pdev, p);
 
 	/* init the device */
@@ -346,24 +347,3 @@ static int rt2880_pinmux_probe(struct platform_device *pdev)
 
 	return PTR_ERR_OR_ZERO(dev);
 }
-
-static const struct of_device_id rt2880_pinmux_match[] = {
-	{ .compatible = "ralink,rt2880-pinmux" },
-	{},
-};
-MODULE_DEVICE_TABLE(of, rt2880_pinmux_match);
-
-static struct platform_driver rt2880_pinmux_driver = {
-	.probe = rt2880_pinmux_probe,
-	.driver = {
-		.name = "rt2880-pinmux",
-		.of_match_table = rt2880_pinmux_match,
-	},
-};
-
-static int __init rt2880_pinmux_init(void)
-{
-	return platform_driver_register(&rt2880_pinmux_driver);
-}
-
-core_initcall_sync(rt2880_pinmux_init);
drivers/pinctrl/ralink/pinmux.h renamed from arch/mips/include/asm/mach-ralink/pinmux.h +2 -1
similarity index 91%
rename from arch/mips/include/asm/mach-ralink/pinmux.h
rename to drivers/pinctrl/ralink/pinmux.h
index 048309348be0..0046abe3bcc7 100644
@@ -47,6 +47,7 @@ struct rt2880_pmx_group {
 	int func_count;
 };
 
-extern struct rt2880_pmx_group *rt2880_pinmux_data;
+int rt2880_pinmux_init(struct platform_device *pdev,
+		       struct rt2880_pmx_group *data);
 
 #endif
Signature · 1 line
2.25.1
author maintainer
#2 lore raw

PATCH 2/6 pinctrl: ralink: move MT7621 SoC pinmux config into a new 'pinctrl-mt7621.c' file

In reply to Sergio Paracuellos

Move all related code for SoC MT7621 into a new driver located in 'pinctrl-mt7621.c' source file.

---
 arch/mips/ralink/mt7621.c               |  88 ------------------
 drivers/pinctrl/ralink/Kconfig          |   5 +
 drivers/pinctrl/ralink/Makefile         |   2 +
 drivers/pinctrl/ralink/pinctrl-mt7621.c | 116 ++++++++++++++++++++++++
 4 files changed, 123 insertions(+), 88 deletions(-)
 create mode 100644 drivers/pinctrl/ralink/pinctrl-mt7621.c
arch/mips/ralink/mt7621.c +0 -88
index f82ad2a621f6..bd71f5b14238 100644
@@ -18,97 +18,10 @@
 #include <asm/mach-ralink/ralink_regs.h>
 #include <asm/mach-ralink/mt7621.h>
 
-#include <pinmux.h>
-
 #include "common.h"
 
-#define MT7621_GPIO_MODE_UART1		1
-#define MT7621_GPIO_MODE_I2C		2
-#define MT7621_GPIO_MODE_UART3_MASK	0x3
-#define MT7621_GPIO_MODE_UART3_SHIFT	3
-#define MT7621_GPIO_MODE_UART3_GPIO	1
-#define MT7621_GPIO_MODE_UART2_MASK	0x3
-#define MT7621_GPIO_MODE_UART2_SHIFT	5
-#define MT7621_GPIO_MODE_UART2_GPIO	1
-#define MT7621_GPIO_MODE_JTAG		7
-#define MT7621_GPIO_MODE_WDT_MASK	0x3
-#define MT7621_GPIO_MODE_WDT_SHIFT	8
-#define MT7621_GPIO_MODE_WDT_GPIO	1
-#define MT7621_GPIO_MODE_PCIE_RST	0
-#define MT7621_GPIO_MODE_PCIE_REF	2
-#define MT7621_GPIO_MODE_PCIE_MASK	0x3
-#define MT7621_GPIO_MODE_PCIE_SHIFT	10
-#define MT7621_GPIO_MODE_PCIE_GPIO	1
-#define MT7621_GPIO_MODE_MDIO_MASK	0x3
-#define MT7621_GPIO_MODE_MDIO_SHIFT	12
-#define MT7621_GPIO_MODE_MDIO_GPIO	1
-#define MT7621_GPIO_MODE_RGMII1		14
-#define MT7621_GPIO_MODE_RGMII2		15
-#define MT7621_GPIO_MODE_SPI_MASK	0x3
-#define MT7621_GPIO_MODE_SPI_SHIFT	16
-#define MT7621_GPIO_MODE_SPI_GPIO	1
-#define MT7621_GPIO_MODE_SDHCI_MASK	0x3
-#define MT7621_GPIO_MODE_SDHCI_SHIFT	18
-#define MT7621_GPIO_MODE_SDHCI_GPIO	1
-
 static void *detect_magic __initdata = detect_memory_region;
 
-static struct rt2880_pmx_func uart1_grp[] =  { FUNC("uart1", 0, 1, 2) };
-static struct rt2880_pmx_func i2c_grp[] =  { FUNC("i2c", 0, 3, 2) };
-static struct rt2880_pmx_func uart3_grp[] = {
-	FUNC("uart3", 0, 5, 4),
-	FUNC("i2s", 2, 5, 4),
-	FUNC("spdif3", 3, 5, 4),
-};
-static struct rt2880_pmx_func uart2_grp[] = {
-	FUNC("uart2", 0, 9, 4),
-	FUNC("pcm", 2, 9, 4),
-	FUNC("spdif2", 3, 9, 4),
-};
-static struct rt2880_pmx_func jtag_grp[] = { FUNC("jtag", 0, 13, 5) };
-static struct rt2880_pmx_func wdt_grp[] = {
-	FUNC("wdt rst", 0, 18, 1),
-	FUNC("wdt refclk", 2, 18, 1),
-};
-static struct rt2880_pmx_func pcie_rst_grp[] = {
-	FUNC("pcie rst", MT7621_GPIO_MODE_PCIE_RST, 19, 1),
-	FUNC("pcie refclk", MT7621_GPIO_MODE_PCIE_REF, 19, 1)
-};
-static struct rt2880_pmx_func mdio_grp[] = { FUNC("mdio", 0, 20, 2) };
-static struct rt2880_pmx_func rgmii2_grp[] = { FUNC("rgmii2", 0, 22, 12) };
-static struct rt2880_pmx_func spi_grp[] = {
-	FUNC("spi", 0, 34, 7),
-	FUNC("nand1", 2, 34, 7),
-};
-static struct rt2880_pmx_func sdhci_grp[] = {
-	FUNC("sdhci", 0, 41, 8),
-	FUNC("nand2", 2, 41, 8),
-};
-static struct rt2880_pmx_func rgmii1_grp[] = { FUNC("rgmii1", 0, 49, 12) };
-
-static struct rt2880_pmx_group mt7621_pinmux_data[] = {
-	GRP("uart1", uart1_grp, 1, MT7621_GPIO_MODE_UART1),
-	GRP("i2c", i2c_grp, 1, MT7621_GPIO_MODE_I2C),
-	GRP_G("uart3", uart3_grp, MT7621_GPIO_MODE_UART3_MASK,
-		MT7621_GPIO_MODE_UART3_GPIO, MT7621_GPIO_MODE_UART3_SHIFT),
-	GRP_G("uart2", uart2_grp, MT7621_GPIO_MODE_UART2_MASK,
-		MT7621_GPIO_MODE_UART2_GPIO, MT7621_GPIO_MODE_UART2_SHIFT),
-	GRP("jtag", jtag_grp, 1, MT7621_GPIO_MODE_JTAG),
-	GRP_G("wdt", wdt_grp, MT7621_GPIO_MODE_WDT_MASK,
-		MT7621_GPIO_MODE_WDT_GPIO, MT7621_GPIO_MODE_WDT_SHIFT),
-	GRP_G("pcie", pcie_rst_grp, MT7621_GPIO_MODE_PCIE_MASK,
-		MT7621_GPIO_MODE_PCIE_GPIO, MT7621_GPIO_MODE_PCIE_SHIFT),
-	GRP_G("mdio", mdio_grp, MT7621_GPIO_MODE_MDIO_MASK,
-		MT7621_GPIO_MODE_MDIO_GPIO, MT7621_GPIO_MODE_MDIO_SHIFT),
-	GRP("rgmii2", rgmii2_grp, 1, MT7621_GPIO_MODE_RGMII2),
-	GRP_G("spi", spi_grp, MT7621_GPIO_MODE_SPI_MASK,
-		MT7621_GPIO_MODE_SPI_GPIO, MT7621_GPIO_MODE_SPI_SHIFT),
-	GRP_G("sdhci", sdhci_grp, MT7621_GPIO_MODE_SDHCI_MASK,
-		MT7621_GPIO_MODE_SDHCI_GPIO, MT7621_GPIO_MODE_SDHCI_SHIFT),
-	GRP("rgmii1", rgmii1_grp, 1, MT7621_GPIO_MODE_RGMII1),
-	{ 0 }
-};
-
 phys_addr_t mips_cpc_default_phys_base(void)
 {
 	panic("Cannot detect cpc address");
@@ -219,7 +132,6 @@ void __init prom_soc_init(struct ralink_soc_info *soc_info)
 		(rev & CHIP_REV_ECO_MASK));
 
 	soc_info->mem_detect = mt7621_memory_detect;
-	rt2880_pinmux_data = mt7621_pinmux_data;
 
 	soc_dev_init(soc_info, rev);
 
drivers/pinctrl/ralink/Kconfig +5 -0
index 8c5f6341477f..ef8990a4c1eb 100644
@@ -11,4 +11,9 @@ config PINCTRL_RT2880
         select PINMUX
         select GENERIC_PINCONF
 
+config PINCTRL_MT7621
+        bool "mt7621 pinctrl driver for RALINK/Mediatek SOCs"
+        depends on RALINK && SOC_MT7621
+        select PINCTRL_RT2880
+
 endmenu
drivers/pinctrl/ralink/Makefile +2 -0
index 242554298d07..470855290ff6 100644
@@ -1,2 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_PINCTRL_RT2880)   += pinctrl-rt2880.o
+
+obj-$(CONFIG_PINCTRL_MT7621)   += pinctrl-mt7621.o
drivers/pinctrl/ralink/pinctrl-mt7621.c new file +116 -0

116 lines not on this page · raw message

Signature · 1 line
2.25.1
author maintainer
#3 lore raw

PATCH 3/6 pinctrl: ralink: move RT3883 SoC pinmux config into a new 'pinctrl-rt3883.c' file

In reply to Sergio Paracuellos

Move all related code for SoC RT3883 into a new driver located in 'pinctrl-rt3883.c' source file

---
 arch/mips/include/asm/mach-ralink/rt3883.h |  34 -------
 arch/mips/ralink/rt3883.c                  |  45 ---------
 drivers/pinctrl/ralink/Kconfig             |   5 +
 drivers/pinctrl/ralink/Makefile            |   1 +
 drivers/pinctrl/ralink/pinctrl-rt3883.c    | 107 +++++++++++++++++++++
 5 files changed, 113 insertions(+), 79 deletions(-)
 create mode 100644 drivers/pinctrl/ralink/pinctrl-rt3883.c
arch/mips/include/asm/mach-ralink/rt3883.h +0 -34
index 565f2548496a..f250de9c055b 100644
@@ -109,40 +109,6 @@
 #define RT3883_CLKCFG1_PCI_CLK_EN	BIT(19)
 #define RT3883_CLKCFG1_UPHY0_CLK_EN	BIT(18)
 
-#define RT3883_GPIO_MODE_UART0_SHIFT	2
-#define RT3883_GPIO_MODE_UART0_MASK	0x7
-#define RT3883_GPIO_MODE_UART0(x)	((x) << RT3883_GPIO_MODE_UART0_SHIFT)
-#define RT3883_GPIO_MODE_UARTF		0x0
-#define RT3883_GPIO_MODE_PCM_UARTF	0x1
-#define RT3883_GPIO_MODE_PCM_I2S	0x2
-#define RT3883_GPIO_MODE_I2S_UARTF	0x3
-#define RT3883_GPIO_MODE_PCM_GPIO	0x4
-#define RT3883_GPIO_MODE_GPIO_UARTF	0x5
-#define RT3883_GPIO_MODE_GPIO_I2S	0x6
-#define RT3883_GPIO_MODE_GPIO		0x7
-
-#define RT3883_GPIO_MODE_I2C		0
-#define RT3883_GPIO_MODE_SPI		1
-#define RT3883_GPIO_MODE_UART1		5
-#define RT3883_GPIO_MODE_JTAG		6
-#define RT3883_GPIO_MODE_MDIO		7
-#define RT3883_GPIO_MODE_GE1		9
-#define RT3883_GPIO_MODE_GE2		10
-
-#define RT3883_GPIO_MODE_PCI_SHIFT	11
-#define RT3883_GPIO_MODE_PCI_MASK	0x7
-#define RT3883_GPIO_MODE_PCI		(RT3883_GPIO_MODE_PCI_MASK << RT3883_GPIO_MODE_PCI_SHIFT)
-#define RT3883_GPIO_MODE_LNA_A_SHIFT	16
-#define RT3883_GPIO_MODE_LNA_A_MASK	0x3
-#define _RT3883_GPIO_MODE_LNA_A(_x)	((_x) << RT3883_GPIO_MODE_LNA_A_SHIFT)
-#define RT3883_GPIO_MODE_LNA_A_GPIO	0x3
-#define RT3883_GPIO_MODE_LNA_A		_RT3883_GPIO_MODE_LNA_A(RT3883_GPIO_MODE_LNA_A_MASK)
-#define RT3883_GPIO_MODE_LNA_G_SHIFT	18
-#define RT3883_GPIO_MODE_LNA_G_MASK	0x3
-#define _RT3883_GPIO_MODE_LNA_G(_x)	((_x) << RT3883_GPIO_MODE_LNA_G_SHIFT)
-#define RT3883_GPIO_MODE_LNA_G_GPIO	0x3
-#define RT3883_GPIO_MODE_LNA_G		_RT3883_GPIO_MODE_LNA_G(RT3883_GPIO_MODE_LNA_G_MASK)
-
 #define RT3883_GPIO_I2C_SD		1
 #define RT3883_GPIO_I2C_SCLK		2
 #define RT3883_GPIO_SPI_CS0		3
arch/mips/ralink/rt3883.c +0 -45

59 lines not on this page · raw message

drivers/pinctrl/ralink/Kconfig +5 -0
index ef8990a4c1eb..6f5fb3dc0a41 100644
@@ -16,4 +16,9 @@ config PINCTRL_MT7621
         depends on RALINK && SOC_MT7621
         select PINCTRL_RT2880
 
+config PINCTRL_RT3883
+        bool "RT3883 pinctrl driver for RALINK/Mediatek SOCs"
+        depends on RALINK && SOC_RT3883
+        select PINCTRL_RT2880
+
 endmenu
drivers/pinctrl/ralink/Makefile +1 -0
index 470855290ff6..86d6f8253afa 100644
@@ -2,3 +2,4 @@
 obj-$(CONFIG_PINCTRL_RT2880)   += pinctrl-rt2880.o
 
 obj-$(CONFIG_PINCTRL_MT7621)   += pinctrl-mt7621.o
+obj-$(CONFIG_PINCTRL_RT3883)   += pinctrl-rt3883.o
drivers/pinctrl/ralink/pinctrl-rt3883.c new file +107 -0

107 lines not on this page · raw message

Signature · 1 line
2.25.1
author maintainer
#4 lore raw

PATCH 4/6 pinctrl: ralink: move RT305X SoC pinmux config into a new 'pinctrl-rt305x.c' file

In reply to Sergio Paracuellos

Move all related code for SoC RT305X into a new driver located in 'pinctrl-rt305x.c' source file.

---
 arch/mips/include/asm/mach-ralink/rt305x.h |  24 ----
 arch/mips/ralink/rt305x.c                  |  77 ------------
 drivers/pinctrl/ralink/Kconfig             |   5 +
 drivers/pinctrl/ralink/Makefile            |   1 +
 drivers/pinctrl/ralink/pinctrl-rt305x.c    | 136 +++++++++++++++++++++
 5 files changed, 142 insertions(+), 101 deletions(-)
 create mode 100644 drivers/pinctrl/ralink/pinctrl-rt305x.c
arch/mips/include/asm/mach-ralink/rt305x.h +0 -24
index b54619dc4b88..4d8e8c8d83ce 100644
@@ -114,30 +114,6 @@ static inline int soc_is_rt5350(void)
 #define RT305X_GPIO_GE0_TXD0		40
 #define RT305X_GPIO_GE0_RXCLK		51
 
-#define RT305X_GPIO_MODE_UART0_SHIFT	2
-#define RT305X_GPIO_MODE_UART0_MASK	0x7
-#define RT305X_GPIO_MODE_UART0(x)	((x) << RT305X_GPIO_MODE_UART0_SHIFT)
-#define RT305X_GPIO_MODE_UARTF		0
-#define RT305X_GPIO_MODE_PCM_UARTF	1
-#define RT305X_GPIO_MODE_PCM_I2S	2
-#define RT305X_GPIO_MODE_I2S_UARTF	3
-#define RT305X_GPIO_MODE_PCM_GPIO	4
-#define RT305X_GPIO_MODE_GPIO_UARTF	5
-#define RT305X_GPIO_MODE_GPIO_I2S	6
-#define RT305X_GPIO_MODE_GPIO		7
-
-#define RT305X_GPIO_MODE_I2C		0
-#define RT305X_GPIO_MODE_SPI		1
-#define RT305X_GPIO_MODE_UART1		5
-#define RT305X_GPIO_MODE_JTAG		6
-#define RT305X_GPIO_MODE_MDIO		7
-#define RT305X_GPIO_MODE_SDRAM		8
-#define RT305X_GPIO_MODE_RGMII		9
-#define RT5350_GPIO_MODE_PHY_LED	14
-#define RT5350_GPIO_MODE_SPI_CS1	21
-#define RT3352_GPIO_MODE_LNA		18
-#define RT3352_GPIO_MODE_PA		20
-
 #define RT3352_SYSC_REG_SYSCFG0		0x010
 #define RT3352_SYSC_REG_SYSCFG1         0x014
 #define RT3352_SYSC_REG_CLKCFG1         0x030
arch/mips/ralink/rt305x.c +0 -77

97 lines not on this page · raw message

drivers/pinctrl/ralink/Kconfig +5 -0
index 6f5fb3dc0a41..705a63d34d3c 100644
@@ -16,6 +16,11 @@ config PINCTRL_MT7621
         depends on RALINK && SOC_MT7621
         select PINCTRL_RT2880
 
+config PINCTRL_RT305X
+        bool "RT305X pinctrl driver for RALINK/Mediatek SOCs"
+        depends on RALINK && SOC_RT305X
+        select PINCTRL_RT2880
+
 config PINCTRL_RT3883
         bool "RT3883 pinctrl driver for RALINK/Mediatek SOCs"
         depends on RALINK && SOC_RT3883
drivers/pinctrl/ralink/Makefile +1 -0
index 86d6f8253afa..119d30ecea98 100644
@@ -2,4 +2,5 @@
 obj-$(CONFIG_PINCTRL_RT2880)   += pinctrl-rt2880.o
 
 obj-$(CONFIG_PINCTRL_MT7621)   += pinctrl-mt7621.o
+obj-$(CONFIG_PINCTRL_RT305X)   += pinctrl-rt305x.o
 obj-$(CONFIG_PINCTRL_RT3883)   += pinctrl-rt3883.o
drivers/pinctrl/ralink/pinctrl-rt305x.c new file +136 -0

136 lines not on this page · raw message

Signature · 1 line
2.25.1
author maintainer
#5 lore raw

PATCH 5/6 pinctrl: ralink: move MT7620 SoC pinmux config into a new 'pinctrl-mt7620.c' file

In reply to Sergio Paracuellos

Move all related code for SoC MT7620 into a new driver located in 'pinctrl-mt7620.c' source file.

---
 arch/mips/include/asm/mach-ralink/mt7620.h    |  53 +-
 arch/mips/ralink/mt7620.c                     | 320 ------------
 drivers/pinctrl/ralink/Kconfig                |   5 +
 drivers/pinctrl/ralink/Makefile               |   1 +
 .../pinctrl/ralink/pinctrl-mt7620.c           | 472 +++---------------
 5 files changed, 85 insertions(+), 766 deletions(-)
 copy arch/mips/ralink/mt7620.c => drivers/pinctrl/ralink/pinctrl-mt7620.c (51%)
arch/mips/include/asm/mach-ralink/mt7620.h +7 -46
index 757ce53d00e6..d51dfad8f543 100644
@@ -83,52 +83,13 @@
 #define MT7620_DDR2_SIZE_MIN		32
 #define MT7620_DDR2_SIZE_MAX		256
 
-#define MT7620_GPIO_MODE_UART0_SHIFT	2
-#define MT7620_GPIO_MODE_UART0_MASK	0x7
-#define MT7620_GPIO_MODE_UART0(x)	((x) << MT7620_GPIO_MODE_UART0_SHIFT)
-#define MT7620_GPIO_MODE_UARTF		0x0
-#define MT7620_GPIO_MODE_PCM_UARTF	0x1
-#define MT7620_GPIO_MODE_PCM_I2S	0x2
-#define MT7620_GPIO_MODE_I2S_UARTF	0x3
-#define MT7620_GPIO_MODE_PCM_GPIO	0x4
-#define MT7620_GPIO_MODE_GPIO_UARTF	0x5
-#define MT7620_GPIO_MODE_GPIO_I2S	0x6
-#define MT7620_GPIO_MODE_GPIO		0x7
-
-#define MT7620_GPIO_MODE_NAND		0
-#define MT7620_GPIO_MODE_SD		1
-#define MT7620_GPIO_MODE_ND_SD_GPIO	2
-#define MT7620_GPIO_MODE_ND_SD_MASK	0x3
-#define MT7620_GPIO_MODE_ND_SD_SHIFT	18
-
-#define MT7620_GPIO_MODE_PCIE_RST	0
-#define MT7620_GPIO_MODE_PCIE_REF	1
-#define MT7620_GPIO_MODE_PCIE_GPIO	2
-#define MT7620_GPIO_MODE_PCIE_MASK	0x3
-#define MT7620_GPIO_MODE_PCIE_SHIFT	16
-
-#define MT7620_GPIO_MODE_WDT_RST	0
-#define MT7620_GPIO_MODE_WDT_REF	1
-#define MT7620_GPIO_MODE_WDT_GPIO	2
-#define MT7620_GPIO_MODE_WDT_MASK	0x3
-#define MT7620_GPIO_MODE_WDT_SHIFT	21
-
-#define MT7620_GPIO_MODE_MDIO		0
-#define MT7620_GPIO_MODE_MDIO_REFCLK	1
-#define MT7620_GPIO_MODE_MDIO_GPIO	2
-#define MT7620_GPIO_MODE_MDIO_MASK	0x3
-#define MT7620_GPIO_MODE_MDIO_SHIFT	7
-
-#define MT7620_GPIO_MODE_I2C		0
-#define MT7620_GPIO_MODE_UART1		5
-#define MT7620_GPIO_MODE_RGMII1		9
-#define MT7620_GPIO_MODE_RGMII2		10
-#define MT7620_GPIO_MODE_SPI		11
-#define MT7620_GPIO_MODE_SPI_REF_CLK	12
-#define MT7620_GPIO_MODE_WLED		13
-#define MT7620_GPIO_MODE_JTAG		15
-#define MT7620_GPIO_MODE_EPHY		15
-#define MT7620_GPIO_MODE_PA		20
+extern enum ralink_soc_type ralink_soc;
+
+static inline int is_mt76x8(void)
+{
+	return ralink_soc == MT762X_SOC_MT7628AN ||
+	       ralink_soc == MT762X_SOC_MT7688;
+}
 
 static inline int mt7620_get_eco(void)
 {
arch/mips/ralink/mt7620.c +0 -320

336 lines not on this page · raw message

drivers/pinctrl/ralink/Kconfig +5 -0
index 705a63d34d3c..6edf0589cf0a 100644
@@ -11,6 +11,11 @@ config PINCTRL_RT2880
         select PINMUX
         select GENERIC_PINCONF
 
+config PINCTRL_MT7620
+        bool "mt7620 pinctrl driver for RALINK/Mediatek SOCs"
+        depends on RALINK && SOC_MT7620
+        select PINCTRL_RT2880
+
 config PINCTRL_MT7621
         bool "mt7621 pinctrl driver for RALINK/Mediatek SOCs"
         depends on RALINK && SOC_MT7621
drivers/pinctrl/ralink/Makefile +1 -0
index 119d30ecea98..9b99b20e51e6 100644
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_PINCTRL_RT2880)   += pinctrl-rt2880.o
 
+obj-$(CONFIG_PINCTRL_MT7620)   += pinctrl-mt7620.o
 obj-$(CONFIG_PINCTRL_MT7621)   += pinctrl-mt7621.o
 obj-$(CONFIG_PINCTRL_RT305X)   += pinctrl-rt305x.o
 obj-$(CONFIG_PINCTRL_RT3883)   += pinctrl-rt3883.o
drivers/pinctrl/ralink/pinctrl-mt7620.c renamed from arch/mips/ralink/mt7620.c +72 -400

487 lines not on this page · raw message

Signature · 1 line
2.25.1
author maintainer
#6 lore raw

PATCH 6/6 pinctrl: ralink: move RT288X SoC pinmux config into a new 'pinctrl-rt288x.c' file

In reply to Sergio Paracuellos

Move all related code for SoC RT288X into a new driver located in 'pinctrl-rt288x.c' source file.

---
 arch/mips/include/asm/mach-ralink/rt288x.h |  9 ----
 arch/mips/ralink/rt288x.c                  | 21 --------
 drivers/pinctrl/ralink/Kconfig             |  5 ++
 drivers/pinctrl/ralink/Makefile            |  1 +
 drivers/pinctrl/ralink/pinctrl-rt288x.c    | 60 ++++++++++++++++++++++
 5 files changed, 66 insertions(+), 30 deletions(-)
 create mode 100644 drivers/pinctrl/ralink/pinctrl-rt288x.c
arch/mips/include/asm/mach-ralink/rt288x.h +0 -9
index 5d10178f26af..5f213534f0f5 100644
@@ -33,15 +33,6 @@
 #define SYSTEM_CONFIG_CPUCLK_280	0x2
 #define SYSTEM_CONFIG_CPUCLK_300	0x3
 
-#define RT2880_GPIO_MODE_I2C		BIT(0)
-#define RT2880_GPIO_MODE_UART0		BIT(1)
-#define RT2880_GPIO_MODE_SPI		BIT(2)
-#define RT2880_GPIO_MODE_UART1		BIT(3)
-#define RT2880_GPIO_MODE_JTAG		BIT(4)
-#define RT2880_GPIO_MODE_MDIO		BIT(5)
-#define RT2880_GPIO_MODE_SDRAM		BIT(6)
-#define RT2880_GPIO_MODE_PCI		BIT(7)
-
 #define CLKCFG_SRAM_CS_N_WDT		BIT(9)
 
 #define RT2880_SDRAM_BASE		0x08000000
arch/mips/ralink/rt288x.c +0 -21
index 34083c70ec68..493335db2fe1 100644
@@ -14,29 +14,9 @@
 #include <asm/mipsregs.h>
 #include <asm/mach-ralink/ralink_regs.h>
 #include <asm/mach-ralink/rt288x.h>
-#include <asm/mach-ralink/pinmux.h>
 
 #include "common.h"
 
-static struct rt2880_pmx_func i2c_func[] = { FUNC("i2c", 0, 1, 2) };
-static struct rt2880_pmx_func spi_func[] = { FUNC("spi", 0, 3, 4) };
-static struct rt2880_pmx_func uartlite_func[] = { FUNC("uartlite", 0, 7, 8) };
-static struct rt2880_pmx_func jtag_func[] = { FUNC("jtag", 0, 17, 5) };
-static struct rt2880_pmx_func mdio_func[] = { FUNC("mdio", 0, 22, 2) };
-static struct rt2880_pmx_func sdram_func[] = { FUNC("sdram", 0, 24, 16) };
-static struct rt2880_pmx_func pci_func[] = { FUNC("pci", 0, 40, 32) };
-
-static struct rt2880_pmx_group rt2880_pinmux_data_act[] = {
-	GRP("i2c", i2c_func, 1, RT2880_GPIO_MODE_I2C),
-	GRP("spi", spi_func, 1, RT2880_GPIO_MODE_SPI),
-	GRP("uartlite", uartlite_func, 1, RT2880_GPIO_MODE_UART0),
-	GRP("jtag", jtag_func, 1, RT2880_GPIO_MODE_JTAG),
-	GRP("mdio", mdio_func, 1, RT2880_GPIO_MODE_MDIO),
-	GRP("sdram", sdram_func, 1, RT2880_GPIO_MODE_SDRAM),
-	GRP("pci", pci_func, 1, RT2880_GPIO_MODE_PCI),
-	{ 0 }
-};
-
 void __init ralink_clk_init(void)
 {
 	unsigned long cpu_rate, wmac_rate = 40000000;
@@ -106,6 +86,5 @@ void __init prom_soc_init(struct ralink_soc_info *soc_info)
 	soc_info->mem_size_min = RT2880_MEM_SIZE_MIN;
 	soc_info->mem_size_max = RT2880_MEM_SIZE_MAX;
 
-	rt2880_pinmux_data = rt2880_pinmux_data_act;
 	ralink_soc = RT2880_SOC;
 }
drivers/pinctrl/ralink/Kconfig +5 -0
index 6edf0589cf0a..a76ee3deb8c3 100644
@@ -21,6 +21,11 @@ config PINCTRL_MT7621
         depends on RALINK && SOC_MT7621
         select PINCTRL_RT2880
 
+config PINCTRL_RT288X
+        bool "RT288X pinctrl driver for RALINK/Mediatek SOCs"
+        depends on RALINK && SOC_RT288X
+        select PINCTRL_RT2880
+
 config PINCTRL_RT305X
         bool "RT305X pinctrl driver for RALINK/Mediatek SOCs"
         depends on RALINK && SOC_RT305X
drivers/pinctrl/ralink/Makefile +1 -0
index 9b99b20e51e6..a15610206ced 100644
@@ -3,5 +3,6 @@ obj-$(CONFIG_PINCTRL_RT2880)   += pinctrl-rt2880.o
 
 obj-$(CONFIG_PINCTRL_MT7620)   += pinctrl-mt7620.o
 obj-$(CONFIG_PINCTRL_MT7621)   += pinctrl-mt7621.o
+obj-$(CONFIG_PINCTRL_RT288X)   += pinctrl-rt288x.o
 obj-$(CONFIG_PINCTRL_RT305X)   += pinctrl-rt305x.o
 obj-$(CONFIG_PINCTRL_RT3883)   += pinctrl-rt3883.o
drivers/pinctrl/ralink/pinctrl-rt288x.c new file +60 -0

60 lines not on this page · raw message

Signature · 1 line
2.25.1
#7 lore raw
In reply to Sergio Paracuellos
Quoted 11 lines · Sergio Paracuellos

We currently have 'drivers/pinctrl/ralink/' with common code to all of them in 'pinctrl-rt2880.c' file. Pinctrl data was being passed in SoC initilization to the driver. Instead of doing that just move all related code to the driver itself. We maintain for all of them compatible string to avoid to make more changes in dts's an so on. If a new compatible string is neccessary to be defined for each different SoC, we can change them after this series are applied.

I have only tested MT7621 platform using GNUBee PC1 board. I don't have other boards to test other SoC changes.

Quoted 6 lines

This series are rebased on the master branch of linux-pinctrl git tree so I expect this to be merged through pinctrl tree. Thomas, if 'linux-mips' is preferred to merge this series just let me know and I can rebase them to make you things easier.

Thanks in advance for your time.

I have simply applied all patches so we get some testing in linux-next (last time we found some snags through linux-next).

This is an important modernization of the ralink SoCs so I am pushing the fastforward button a bit.

If some ralink maintainer has opinions they can either patch it or complain loudly so I can take the patches out again.

Yours,
Linus Walleij

author maintainer
#8 lore raw

Hi Linus,

Quoted 20 lines · Linus Walleij
Quoted 16 lines · Sergio Paracuellos

We currently have 'drivers/pinctrl/ralink/' with common code to all of them in 'pinctrl-rt2880.c' file. Pinctrl data was being passed in SoC initilization to the driver. Instead of doing that just move all related code to the driver itself. We maintain for all of them compatible string to avoid to make more changes in dts's an so on. If a new compatible string is neccessary to be defined for each different SoC, we can change them after this series are applied.

I have only tested MT7621 platform using GNUBee PC1 board. I don't have other boards to test other SoC changes.

This series are rebased on the master branch of linux-pinctrl git tree so I expect this to be merged through pinctrl tree. Thomas, if 'linux-mips' is preferred to merge this series just let me know and I can rebase them to make you things easier.

Quoted 4 lines
Quoted 1 line

Thanks in advance for your time.

I have simply applied all patches so we get some testing in linux-next (last time we found some snags through linux-next).

Good! Let's see what happen, then :)

Quoted 3 lines

This is an important modernization of the ralink SoCs so I am pushing the fastforward button a bit.

I also do believe that having moved all of this stuff from the arch headers to the driver itself is a very good step.

Quoted 3 lines

If some ralink maintainer has opinions they can either patch it or complain loudly so I can take the patches out again.

Please, complain loudly if necessary :). As I said I only tested the changes for mt7621 SoC, so it might be something wrong there.

Quoted 3 lines

Yours,
Linus Walleij

Thanks!
Sergio Paracuellos