Skip to contentSkip to conversation

sunxi: Cleanup to prepare for DM_GPIO/DM_PINCTRL

PATCH In review Samuel Holland 2 participants 7 messages Sep 11, 2021 – Sep 13, 2021

Subsystems (10)
lore
Share & tools
lore

Samuel Holland

author maintainer
#0 lore raw

cover sunxi: Cleanup to prepare for DM_GPIO/DM_PINCTRL

I have a patch series in progresss to migrate sunxi to a DM_PINCTRL driver and convert the remaining legacy GPIO users (outside of SPL).

This is one of several small independent sets of preparatory patches I will be sending in order to minimize the size of the main series (which has >100 patches at this point).

Samuel Holland (3):
sunxi: Clean up inclusions of asm/arch/gpio.h
sunxi: gpio: Remove name_to_gpio macro
sunxi: gpio: Remove bank-specific size macros

 arch/arm/include/asm/arch-sunxi/gpio.h | 15 ++-------------
 arch/arm/mach-sunxi/board.c            |  1 -
 arch/arm/mach-sunxi/clock.c            |  1 -
 arch/arm/mach-sunxi/clock_sun4i.c      |  1 -
 board/sunxi/board.c                    |  1 -
 board/sunxi/gmac.c                     |  1 -
 drivers/gpio/axp_gpio.c                |  1 -
 drivers/gpio/sunxi_gpio.c              |  3 ---
 drivers/mmc/sunxi_mmc.c                |  3 +--
 drivers/net/sun8i_emac.c               |  5 +----
 drivers/power/axp809.c                 |  1 -
 drivers/power/axp818.c                 |  1 -
 drivers/spi/spi-sunxi.c                |  2 +-
 drivers/usb/musb-new/sunxi.c           |  2 --
 drivers/video/Kconfig                  | 10 +++++-----
 drivers/video/hitachi_tx18d42vm_lcd.c  |  6 +++---
 drivers/video/sunxi/sunxi_display.c    | 11 +++++------
 drivers/video/sunxi/sunxi_lcd.c        |  1 -
 18 files changed, 18 insertions(+), 48 deletions(-)
Signature · 1 line
2.31.1
author maintainer
#1 lore raw

PATCH 1/3 sunxi: Clean up inclusions of asm/arch/gpio.h

As part of migrating to DM_GPIO and DM_PINCTRL, eventually we will remove the asm/arch/gpio.h header. In preparation, clean up the various files that include it.

Some files did not contain any GPIO code at all, so this header was completely unused.

A few files contained only legacy platform-specific GPIO code for setting up pin muxes. They were left unchanged, as that code will be completely removed by the DM_PINCTRL migration.

The remaining files contain some combination of DM_GPIO and legacy GPIO code. For those, switch to including asm/gpio.h (if it wasn't included already). Right now, this header provides both sets of functions, because ARCH_SUNXI selects GPIO_EXTRA_HEADER. This will still be the right header to include once the DM_GPIO migration is complete and GPIO_EXTRA_HEADER is no longer needed.

---

 arch/arm/mach-sunxi/board.c         | 1 -
 arch/arm/mach-sunxi/clock.c         | 1 -
 arch/arm/mach-sunxi/clock_sun4i.c   | 1 -
 board/sunxi/board.c                 | 1 -
 board/sunxi/gmac.c                  | 1 -
 drivers/gpio/axp_gpio.c             | 1 -
 drivers/gpio/sunxi_gpio.c           | 1 -
 drivers/mmc/sunxi_mmc.c             | 3 +--
 drivers/net/sun8i_emac.c            | 5 +----
 drivers/power/axp809.c              | 1 -
 drivers/power/axp818.c              | 1 -
 drivers/usb/musb-new/sunxi.c        | 2 --
 drivers/video/sunxi/sunxi_display.c | 1 -
 drivers/video/sunxi/sunxi_lcd.c     | 1 -
 14 files changed, 2 insertions(+), 19 deletions(-)
arch/arm/mach-sunxi/board.c +0 -1
index d9b04f75fc4..373cb56db49 100644
@@ -21,7 +21,6 @@
 #include <asm/gpio.h>
 #include <asm/io.h>
 #include <asm/arch/clock.h>
-#include <asm/arch/gpio.h>
 #include <asm/arch/spl.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/timer.h>
arch/arm/mach-sunxi/clock.c +0 -1
index f591affebf7..de7e8752988 100644
@@ -10,7 +10,6 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/arch/clock.h>
-#include <asm/arch/gpio.h>
 #include <asm/arch/prcm.h>
 #include <asm/arch/gtbus.h>
 #include <asm/arch/sys_proto.h>
arch/arm/mach-sunxi/clock_sun4i.c +0 -1
index 57ee018eaa2..471609764d2 100644
@@ -12,7 +12,6 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/arch/clock.h>
-#include <asm/arch/gpio.h>
 #include <asm/arch/sys_proto.h>
 
 #ifdef CONFIG_SPL_BUILD
board/sunxi/board.c +0 -1
index 2b7d655678d..dcd7f0b4375 100644
@@ -25,7 +25,6 @@
 #include <asm/arch/cpu.h>
 #include <asm/arch/display.h>
 #include <asm/arch/dram.h>
-#include <asm/arch/gpio.h>
 #include <asm/arch/mmc.h>
 #include <asm/arch/prcm.h>
 #include <asm/arch/spl.h>
board/sunxi/gmac.c +0 -1
index d8fdf7728e0..1fa54ed72de 100644
@@ -4,7 +4,6 @@
 #include <asm/gpio.h>
 #include <asm/io.h>
 #include <asm/arch/clock.h>
-#include <asm/arch/gpio.h>
 
 void eth_init_board(void)
 {
drivers/gpio/axp_gpio.c +0 -1
index 73058cf40b4..35585dc8ac9 100644
@@ -6,7 +6,6 @@
  */
 
 #include <common.h>
-#include <asm/arch/gpio.h>
 #include <asm/arch/pmic_bus.h>
 #include <asm/gpio.h>
 #include <axp_pmic.h>
drivers/gpio/sunxi_gpio.c +0 -1
index 24cb604e3e3..7ce3ef73b46 100644
@@ -14,7 +14,6 @@
 #include <errno.h>
 #include <fdtdec.h>
 #include <malloc.h>
-#include <asm/arch/gpio.h>
 #include <asm/io.h>
 #include <asm/gpio.h>
 #include <dm/device-internal.h>
drivers/mmc/sunxi_mmc.c +1 -2
index 178b8cf106d..c62b5f5a6f9 100644
@@ -15,12 +15,11 @@
 #include <mmc.h>
 #include <clk.h>
 #include <reset.h>
+#include <asm/gpio.h>
 #include <asm/io.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/gpio.h>
 #include <asm/arch/mmc.h>
-#include <asm-generic/gpio.h>
 #include <linux/delay.h>
 
 #ifndef CCM_MMC_CTRL_MODE_SEL_NEW
drivers/net/sun8i_emac.c +1 -4
index d7553fe1634..46786d9f764 100644
@@ -14,9 +14,9 @@
 #include <log.h>
 #include <asm/cache.h>
 #include <asm/global_data.h>
+#include <asm/gpio.h>
 #include <asm/io.h>
 #include <asm/arch/clock.h>
-#include <asm/arch/gpio.h>
 #include <common.h>
 #include <clk.h>
 #include <dm.h>
@@ -31,9 +31,6 @@
 #include <reset.h>
 #include <dt-bindings/pinctrl/sun4i-a10.h>
 #include <wait_bit.h>
-#if CONFIG_IS_ENABLED(DM_GPIO)
-#include <asm-generic/gpio.h>
-#endif
 
 #define MDIO_CMD_MII_BUSY		BIT(0)
 #define MDIO_CMD_MII_WRITE		BIT(1)
drivers/power/axp809.c +0 -1
index 6323492b66d..0396502cdb5 100644
@@ -13,7 +13,6 @@
 #include <common.h>
 #include <command.h>
 #include <errno.h>
-#include <asm/arch/gpio.h>
 #include <asm/arch/pmic_bus.h>
 #include <axp_pmic.h>
 
drivers/power/axp818.c +0 -1
index 0531707c8aa..2dc736467bb 100644
@@ -13,7 +13,6 @@
 #include <common.h>
 #include <command.h>
 #include <errno.h>
-#include <asm/arch/gpio.h>
 #include <asm/arch/pmic_bus.h>
 #include <axp_pmic.h>
 
drivers/usb/musb-new/sunxi.c +0 -2
index fea4105f3d1..7e62e3fe6ea 100644
@@ -25,8 +25,6 @@
 #include <reset.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/clock.h>
-#include <asm/arch/gpio.h>
-#include <asm-generic/gpio.h>
 #include <dm/device_compat.h>
 #include <dm/lists.h>
 #include <dm/root.h>
drivers/video/sunxi/sunxi_display.c +0 -1
index 4361a58cd7e..128888f7af1 100644
@@ -17,7 +17,6 @@
 
 #include <asm/arch/clock.h>
 #include <asm/arch/display.h>
-#include <asm/arch/gpio.h>
 #include <asm/arch/lcdc.h>
 #include <asm/arch/pwm.h>
 #include <asm/arch/tve.h>
drivers/video/sunxi/sunxi_lcd.c +0 -1
index 7a9eba1ed42..8b9c3b2bfa9 100644
@@ -15,7 +15,6 @@
 #include <asm/io.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/lcdc.h>
-#include <asm/arch/gpio.h>
 #include <asm/global_data.h>
 #include <asm/gpio.h>
 
Signature · 1 line
2.31.1
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] sunxi: Clean up inclusions of asm/arch/gpio.h

Quoted 11 lines · On Sat, 11 Sep 2021 16:50:47 -0500 Samuel Holland <[email protected]> wrote:

As part of migrating to DM_GPIO and DM_PINCTRL, eventually we will remove the asm/arch/gpio.h header. In preparation, clean up the various files that include it.

Some files did not contain any GPIO code at all, so this header was completely unused.

A few files contained only legacy platform-specific GPIO code for setting up pin muxes. They were left unchanged, as that code will be completely removed by the DM_PINCTRL migration.

Quoted 6 lines

The remaining files contain some combination of DM_GPIO and legacy GPIO code. For those, switch to including asm/gpio.h (if it wasn't included already). Right now, this header provides both sets of functions, because ARCH_SUNXI selects GPIO_EXTRA_HEADER. This will still be the right header to include once the DM_GPIO migration is complete and GPIO_EXTRA_HEADER is no longer needed.

Nice cleanup, and it survived a buildman sunxi (all 158 boards).

Quoted 1 line

Cheers,
Andre

Quoted 206 lines

---

 arch/arm/mach-sunxi/board.c         | 1 -
 arch/arm/mach-sunxi/clock.c         | 1 -
 arch/arm/mach-sunxi/clock_sun4i.c   | 1 -
 board/sunxi/board.c                 | 1 -
 board/sunxi/gmac.c                  | 1 -
 drivers/gpio/axp_gpio.c             | 1 -
 drivers/gpio/sunxi_gpio.c           | 1 -
 drivers/mmc/sunxi_mmc.c             | 3 +--
 drivers/net/sun8i_emac.c            | 5 +----
 drivers/power/axp809.c              | 1 -
 drivers/power/axp818.c              | 1 -
 drivers/usb/musb-new/sunxi.c        | 2 --
 drivers/video/sunxi/sunxi_display.c | 1 -
 drivers/video/sunxi/sunxi_lcd.c     | 1 -
 14 files changed, 2 insertions(+), 19 deletions(-)
arch/arm/mach-sunxi/board.c +0 -1
index d9b04f75fc4..373cb56db49 100644
@@ -21,7 +21,6 @@
 #include <asm/gpio.h>
 #include <asm/io.h>
 #include <asm/arch/clock.h>
-#include <asm/arch/gpio.h>
 #include <asm/arch/spl.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/timer.h>
arch/arm/mach-sunxi/clock.c +0 -1
index f591affebf7..de7e8752988 100644
@@ -10,7 +10,6 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/arch/clock.h>
-#include <asm/arch/gpio.h>
 #include <asm/arch/prcm.h>
 #include <asm/arch/gtbus.h>
 #include <asm/arch/sys_proto.h>
arch/arm/mach-sunxi/clock_sun4i.c +0 -1
index 57ee018eaa2..471609764d2 100644
@@ -12,7 +12,6 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/arch/clock.h>
-#include <asm/arch/gpio.h>
 #include <asm/arch/sys_proto.h>
 
 #ifdef CONFIG_SPL_BUILD
board/sunxi/board.c +0 -1
index 2b7d655678d..dcd7f0b4375 100644
@@ -25,7 +25,6 @@
 #include <asm/arch/cpu.h>
 #include <asm/arch/display.h>
 #include <asm/arch/dram.h>
-#include <asm/arch/gpio.h>
 #include <asm/arch/mmc.h>
 #include <asm/arch/prcm.h>
 #include <asm/arch/spl.h>
board/sunxi/gmac.c +0 -1
index d8fdf7728e0..1fa54ed72de 100644
@@ -4,7 +4,6 @@
 #include <asm/gpio.h>
 #include <asm/io.h>
 #include <asm/arch/clock.h>
-#include <asm/arch/gpio.h>
 
 void eth_init_board(void)
 {
drivers/gpio/axp_gpio.c +0 -1
index 73058cf40b4..35585dc8ac9 100644
@@ -6,7 +6,6 @@
  */
 
 #include <common.h>
-#include <asm/arch/gpio.h>
 #include <asm/arch/pmic_bus.h>
 #include <asm/gpio.h>
 #include <axp_pmic.h>
drivers/gpio/sunxi_gpio.c +0 -1
index 24cb604e3e3..7ce3ef73b46 100644
@@ -14,7 +14,6 @@
 #include <errno.h>
 #include <fdtdec.h>
 #include <malloc.h>
-#include <asm/arch/gpio.h>
 #include <asm/io.h>
 #include <asm/gpio.h>
 #include <dm/device-internal.h>
drivers/mmc/sunxi_mmc.c +1 -2
index 178b8cf106d..c62b5f5a6f9 100644
@@ -15,12 +15,11 @@
 #include <mmc.h>
 #include <clk.h>
 #include <reset.h>
+#include <asm/gpio.h>
 #include <asm/io.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/gpio.h>
 #include <asm/arch/mmc.h>
-#include <asm-generic/gpio.h>
 #include <linux/delay.h>
 
 #ifndef CCM_MMC_CTRL_MODE_SEL_NEW
drivers/net/sun8i_emac.c +1 -4
index d7553fe1634..46786d9f764 100644
@@ -14,9 +14,9 @@
 #include <log.h>
 #include <asm/cache.h>
 #include <asm/global_data.h>
+#include <asm/gpio.h>
 #include <asm/io.h>
 #include <asm/arch/clock.h>
-#include <asm/arch/gpio.h>
 #include <common.h>
 #include <clk.h>
 #include <dm.h>
@@ -31,9 +31,6 @@
 #include <reset.h>
 #include <dt-bindings/pinctrl/sun4i-a10.h>
 #include <wait_bit.h>
-#if CONFIG_IS_ENABLED(DM_GPIO)
-#include <asm-generic/gpio.h>
-#endif
 
 #define MDIO_CMD_MII_BUSY		BIT(0)
 #define MDIO_CMD_MII_WRITE		BIT(1)
drivers/power/axp809.c +0 -1
index 6323492b66d..0396502cdb5 100644
@@ -13,7 +13,6 @@
 #include <common.h>
 #include <command.h>
 #include <errno.h>
-#include <asm/arch/gpio.h>
 #include <asm/arch/pmic_bus.h>
 #include <axp_pmic.h>
 
drivers/power/axp818.c +0 -1
index 0531707c8aa..2dc736467bb 100644
@@ -13,7 +13,6 @@
 #include <common.h>
 #include <command.h>
 #include <errno.h>
-#include <asm/arch/gpio.h>
 #include <asm/arch/pmic_bus.h>
 #include <axp_pmic.h>
 
drivers/usb/musb-new/sunxi.c +0 -2
index fea4105f3d1..7e62e3fe6ea 100644
@@ -25,8 +25,6 @@
 #include <reset.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/clock.h>
-#include <asm/arch/gpio.h>
-#include <asm-generic/gpio.h>
 #include <dm/device_compat.h>
 #include <dm/lists.h>
 #include <dm/root.h>
drivers/video/sunxi/sunxi_display.c +0 -1
index 4361a58cd7e..128888f7af1 100644
@@ -17,7 +17,6 @@
 
 #include <asm/arch/clock.h>
 #include <asm/arch/display.h>
-#include <asm/arch/gpio.h>
 #include <asm/arch/lcdc.h>
 #include <asm/arch/pwm.h>
 #include <asm/arch/tve.h>
drivers/video/sunxi/sunxi_lcd.c +0 -1
index 7a9eba1ed42..8b9c3b2bfa9 100644
@@ -15,7 +15,6 @@
 #include <asm/io.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/lcdc.h>
-#include <asm/arch/gpio.h>
 #include <asm/global_data.h>
 #include <asm/gpio.h>
 
author maintainer
#3 lore raw

PATCH 2/3 sunxi: gpio: Remove name_to_gpio macro

In reply to Samuel Holland

This clarifies which callers must be updated to complete the DM_GPIO conversion.

The only remaining caller of name_to_gpio in generic code is inside the !DM_GPIO block in cmd/gpio.c. DM_GPIO is always selected on sunxi, so that code cannot be reached. And after this commit, there are only two remaining implementations of name_to_gpio.

---

 arch/arm/include/asm/arch-sunxi/gpio.h |  1 -
 drivers/spi/spi-sunxi.c                |  2 +-
 drivers/video/Kconfig                  | 10 +++++-----
 drivers/video/hitachi_tx18d42vm_lcd.c  |  6 +++---
 drivers/video/sunxi/sunxi_display.c    | 10 +++++-----
 5 files changed, 14 insertions(+), 15 deletions(-)
arch/arm/include/asm/arch-sunxi/gpio.h +0 -1
index 2969a530ae1..c93c051a19f 100644
@@ -244,7 +244,6 @@ int sunxi_gpio_set_drv(u32 pin, u32 val);
 int sunxi_gpio_set_pull(u32 pin, u32 val);
 int sunxi_name_to_gpio_bank(const char *name);
 int sunxi_name_to_gpio(const char *name);
-#define name_to_gpio(name) sunxi_name_to_gpio(name)
 
 #if !defined CONFIG_SPL_BUILD && defined CONFIG_AXP_GPIO
 int axp_gpio_init(void);
drivers/spi/spi-sunxi.c +1 -1
index 4ca5d3a93ac..bc2f544e863 100644
@@ -245,7 +245,7 @@ static int sun4i_spi_parse_pins(struct udevice *dev)
 					break;
 			}
 
-			pin = name_to_gpio(pin_name);
+			pin = sunxi_name_to_gpio(pin_name);
 			if (pin < 0)
 				break;
 
drivers/video/Kconfig +5 -5
index b1f8a9c1e62..b0c52a500df 100644
@@ -452,7 +452,7 @@ config VIDEO_LCD_SSD2828_RESET
 	default ""
 	---help---
 	The reset pin of SSD2828 chip. This takes a string in the format
-	understood by 'name_to_gpio' function, e.g. PH1 for pin 1 of port H.
+	understood by 'sunxi_name_to_gpio' function, e.g. PH1 for pin 1 of port H.
 
 config VIDEO_LCD_TDO_TL070WSH30
 	bool "TDO TL070WSH30 DSI LCD panel support"
@@ -477,7 +477,7 @@ config VIDEO_LCD_SPI_CS
 	This is one of the SPI communication pins, involved in setting up a
 	working LCD configuration. The exact role of SPI may differ for
 	different hardware setups. The option takes a string in the format
-	understood by 'name_to_gpio' function, e.g. PH1 for pin 1 of port H.
+	understood by 'sunxi_name_to_gpio' function, e.g. PH1 for pin 1 of port H.
 
 config VIDEO_LCD_SPI_SCLK
 	string "SPI SCLK pin for LCD related config job"
@@ -487,7 +487,7 @@ config VIDEO_LCD_SPI_SCLK
 	This is one of the SPI communication pins, involved in setting up a
 	working LCD configuration. The exact role of SPI may differ for
 	different hardware setups. The option takes a string in the format
-	understood by 'name_to_gpio' function, e.g. PH1 for pin 1 of port H.
+	understood by 'sunxi_name_to_gpio' function, e.g. PH1 for pin 1 of port H.
 
 config VIDEO_LCD_SPI_MOSI
 	string "SPI MOSI pin for LCD related config job"
@@ -497,7 +497,7 @@ config VIDEO_LCD_SPI_MOSI
 	This is one of the SPI communication pins, involved in setting up a
 	working LCD configuration. The exact role of SPI may differ for
 	different hardware setups. The option takes a string in the format
-	understood by 'name_to_gpio' function, e.g. PH1 for pin 1 of port H.
+	understood by 'sunxi_name_to_gpio' function, e.g. PH1 for pin 1 of port H.
 
 config VIDEO_LCD_SPI_MISO
 	string "SPI MISO pin for LCD related config job (optional)"
@@ -509,7 +509,7 @@ config VIDEO_LCD_SPI_MISO
 	different hardware setups. If wired up, this pin may provide additional
 	useful functionality. Such as bi-directional communication with the
 	hardware and LCD panel id retrieval (if the panel can report it). The
-	option takes a string in the format understood by 'name_to_gpio'
+	option takes a string in the format understood by 'sunxi_name_to_gpio'
 	function, e.g. PH1 for pin 1 of port H.
 
 source "drivers/video/meson/Kconfig"
drivers/video/hitachi_tx18d42vm_lcd.c +3 -3
index c6c8df6a96e..87c4d27438a 100644
@@ -49,9 +49,9 @@ int hitachi_tx18d42vm_init(void)
 	};
 	int i, cs, clk, mosi, ret = 0;
 
-	cs = name_to_gpio(CONFIG_VIDEO_LCD_SPI_CS);
-	clk = name_to_gpio(CONFIG_VIDEO_LCD_SPI_SCLK);
-	mosi = name_to_gpio(CONFIG_VIDEO_LCD_SPI_MOSI);
+	cs = sunxi_name_to_gpio(CONFIG_VIDEO_LCD_SPI_CS);
+	clk = sunxi_name_to_gpio(CONFIG_VIDEO_LCD_SPI_SCLK);
+	mosi = sunxi_name_to_gpio(CONFIG_VIDEO_LCD_SPI_MOSI);
 
 	if (cs == -1 || clk == -1 || mosi == 1) {
 		printf("Error tx18d42vm spi gpio config is invalid\n");
drivers/video/sunxi/sunxi_display.c +5 -5
index 128888f7af1..da3e8988296 100644
@@ -871,11 +871,11 @@ static void sunxi_vga_external_dac_enable(void)
 static int sunxi_ssd2828_init(const struct ctfb_res_modes *mode)
 {
 	struct ssd2828_config cfg = {
-		.csx_pin = name_to_gpio(CONFIG_VIDEO_LCD_SPI_CS),
-		.sck_pin = name_to_gpio(CONFIG_VIDEO_LCD_SPI_SCLK),
-		.sdi_pin = name_to_gpio(CONFIG_VIDEO_LCD_SPI_MOSI),
-		.sdo_pin = name_to_gpio(CONFIG_VIDEO_LCD_SPI_MISO),
-		.reset_pin = name_to_gpio(CONFIG_VIDEO_LCD_SSD2828_RESET),
+		.csx_pin = sunxi_name_to_gpio(CONFIG_VIDEO_LCD_SPI_CS),
+		.sck_pin = sunxi_name_to_gpio(CONFIG_VIDEO_LCD_SPI_SCLK),
+		.sdi_pin = sunxi_name_to_gpio(CONFIG_VIDEO_LCD_SPI_MOSI),
+		.sdo_pin = sunxi_name_to_gpio(CONFIG_VIDEO_LCD_SPI_MISO),
+		.reset_pin = sunxi_name_to_gpio(CONFIG_VIDEO_LCD_SSD2828_RESET),
 		.ssd2828_tx_clk_khz  = CONFIG_VIDEO_LCD_SSD2828_TX_CLK * 1000,
 		.ssd2828_color_depth = 24,
 #ifdef CONFIG_VIDEO_LCD_PANEL_MIPI_4_LANE_513_MBPS_VIA_SSD2828
Signature · 1 line
2.31.1
Acked-by on v1 2/3
#4 lore raw

Re: [PATCH 2/3] sunxi: gpio: Remove name_to_gpio macro

Quoted 9 lines · On Sat, 11 Sep 2021 16:50:48 -0500 Samuel Holland <[email protected]> wrote:

This clarifies which callers must be updated to complete the DM_GPIO conversion.

The only remaining caller of name_to_gpio in generic code is inside the !DM_GPIO block in cmd/gpio.c. DM_GPIO is always selected on sunxi, so that code cannot be reached. And after this commit, there are only two remaining implementations of name_to_gpio.

Compile tested on all sunxi boards.

Cheers,
Andre

Quoted 121 lines

---

 arch/arm/include/asm/arch-sunxi/gpio.h |  1 -
 drivers/spi/spi-sunxi.c                |  2 +-
 drivers/video/Kconfig                  | 10 +++++-----
 drivers/video/hitachi_tx18d42vm_lcd.c  |  6 +++---
 drivers/video/sunxi/sunxi_display.c    | 10 +++++-----
 5 files changed, 14 insertions(+), 15 deletions(-)
arch/arm/include/asm/arch-sunxi/gpio.h +0 -1
index 2969a530ae1..c93c051a19f 100644
@@ -244,7 +244,6 @@ int sunxi_gpio_set_drv(u32 pin, u32 val);
 int sunxi_gpio_set_pull(u32 pin, u32 val);
 int sunxi_name_to_gpio_bank(const char *name);
 int sunxi_name_to_gpio(const char *name);
-#define name_to_gpio(name) sunxi_name_to_gpio(name)
 
 #if !defined CONFIG_SPL_BUILD && defined CONFIG_AXP_GPIO
 int axp_gpio_init(void);
drivers/spi/spi-sunxi.c +1 -1
index 4ca5d3a93ac..bc2f544e863 100644
@@ -245,7 +245,7 @@ static int sun4i_spi_parse_pins(struct udevice *dev)
 					break;
 			}
 
-			pin = name_to_gpio(pin_name);
+			pin = sunxi_name_to_gpio(pin_name);
 			if (pin < 0)
 				break;
 
drivers/video/Kconfig +5 -5
index b1f8a9c1e62..b0c52a500df 100644
@@ -452,7 +452,7 @@ config VIDEO_LCD_SSD2828_RESET
 	default ""
 	---help---
 	The reset pin of SSD2828 chip. This takes a string in the format
-	understood by 'name_to_gpio' function, e.g. PH1 for pin 1 of port H.
+	understood by 'sunxi_name_to_gpio' function, e.g. PH1 for pin 1 of port H.
 
 config VIDEO_LCD_TDO_TL070WSH30
 	bool "TDO TL070WSH30 DSI LCD panel support"
@@ -477,7 +477,7 @@ config VIDEO_LCD_SPI_CS
 	This is one of the SPI communication pins, involved in setting up a
 	working LCD configuration. The exact role of SPI may differ for
 	different hardware setups. The option takes a string in the format
-	understood by 'name_to_gpio' function, e.g. PH1 for pin 1 of port H.
+	understood by 'sunxi_name_to_gpio' function, e.g. PH1 for pin 1 of port H.
 
 config VIDEO_LCD_SPI_SCLK
 	string "SPI SCLK pin for LCD related config job"
@@ -487,7 +487,7 @@ config VIDEO_LCD_SPI_SCLK
 	This is one of the SPI communication pins, involved in setting up a
 	working LCD configuration. The exact role of SPI may differ for
 	different hardware setups. The option takes a string in the format
-	understood by 'name_to_gpio' function, e.g. PH1 for pin 1 of port H.
+	understood by 'sunxi_name_to_gpio' function, e.g. PH1 for pin 1 of port H.
 
 config VIDEO_LCD_SPI_MOSI
 	string "SPI MOSI pin for LCD related config job"
@@ -497,7 +497,7 @@ config VIDEO_LCD_SPI_MOSI
 	This is one of the SPI communication pins, involved in setting up a
 	working LCD configuration. The exact role of SPI may differ for
 	different hardware setups. The option takes a string in the format
-	understood by 'name_to_gpio' function, e.g. PH1 for pin 1 of port H.
+	understood by 'sunxi_name_to_gpio' function, e.g. PH1 for pin 1 of port H.
 
 config VIDEO_LCD_SPI_MISO
 	string "SPI MISO pin for LCD related config job (optional)"
@@ -509,7 +509,7 @@ config VIDEO_LCD_SPI_MISO
 	different hardware setups. If wired up, this pin may provide additional
 	useful functionality. Such as bi-directional communication with the
 	hardware and LCD panel id retrieval (if the panel can report it). The
-	option takes a string in the format understood by 'name_to_gpio'
+	option takes a string in the format understood by 'sunxi_name_to_gpio'
 	function, e.g. PH1 for pin 1 of port H.
 
 source "drivers/video/meson/Kconfig"
drivers/video/hitachi_tx18d42vm_lcd.c +3 -3
index c6c8df6a96e..87c4d27438a 100644
@@ -49,9 +49,9 @@ int hitachi_tx18d42vm_init(void)
 	};
 	int i, cs, clk, mosi, ret = 0;
 
-	cs = name_to_gpio(CONFIG_VIDEO_LCD_SPI_CS);
-	clk = name_to_gpio(CONFIG_VIDEO_LCD_SPI_SCLK);
-	mosi = name_to_gpio(CONFIG_VIDEO_LCD_SPI_MOSI);
+	cs = sunxi_name_to_gpio(CONFIG_VIDEO_LCD_SPI_CS);
+	clk = sunxi_name_to_gpio(CONFIG_VIDEO_LCD_SPI_SCLK);
+	mosi = sunxi_name_to_gpio(CONFIG_VIDEO_LCD_SPI_MOSI);
 
 	if (cs == -1 || clk == -1 || mosi == 1) {
 		printf("Error tx18d42vm spi gpio config is invalid\n");
drivers/video/sunxi/sunxi_display.c +5 -5
index 128888f7af1..da3e8988296 100644
@@ -871,11 +871,11 @@ static void sunxi_vga_external_dac_enable(void)
 static int sunxi_ssd2828_init(const struct ctfb_res_modes *mode)
 {
 	struct ssd2828_config cfg = {
-		.csx_pin = name_to_gpio(CONFIG_VIDEO_LCD_SPI_CS),
-		.sck_pin = name_to_gpio(CONFIG_VIDEO_LCD_SPI_SCLK),
-		.sdi_pin = name_to_gpio(CONFIG_VIDEO_LCD_SPI_MOSI),
-		.sdo_pin = name_to_gpio(CONFIG_VIDEO_LCD_SPI_MISO),
-		.reset_pin = name_to_gpio(CONFIG_VIDEO_LCD_SSD2828_RESET),
+		.csx_pin = sunxi_name_to_gpio(CONFIG_VIDEO_LCD_SPI_CS),
+		.sck_pin = sunxi_name_to_gpio(CONFIG_VIDEO_LCD_SPI_SCLK),
+		.sdi_pin = sunxi_name_to_gpio(CONFIG_VIDEO_LCD_SPI_MOSI),
+		.sdo_pin = sunxi_name_to_gpio(CONFIG_VIDEO_LCD_SPI_MISO),
+		.reset_pin = sunxi_name_to_gpio(CONFIG_VIDEO_LCD_SSD2828_RESET),
 		.ssd2828_tx_clk_khz  = CONFIG_VIDEO_LCD_SSD2828_TX_CLK * 1000,
 		.ssd2828_color_depth = 24,
 #ifdef CONFIG_VIDEO_LCD_PANEL_MIPI_4_LANE_513_MBPS_VIA_SSD2828
author maintainer
#5 lore raw

PATCH 3/3 sunxi: gpio: Remove bank-specific size macros

In reply to Samuel Holland

Since the beginning, all banks have had space for 32 pins, even when not all pins were implemented. Let's use a single constant for the GPIO bank size here, like the GPIO driver is already doing.

---

 arch/arm/include/asm/arch-sunxi/gpio.h | 14 ++------------
 drivers/gpio/sunxi_gpio.c              |  2 --
 2 files changed, 2 insertions(+), 14 deletions(-)
arch/arm/include/asm/arch-sunxi/gpio.h +2 -12
index c93c051a19f..cd5e85988b1 100644
@@ -93,20 +93,10 @@ struct sunxi_gpio_reg {
 #define GPIO_PULL_OFFSET(pin)	((((pin) & 0x1f) & 0xf) << 1)
 
 /* GPIO bank sizes */
-#define SUNXI_GPIO_A_NR		32
-#define SUNXI_GPIO_B_NR		32
-#define SUNXI_GPIO_C_NR		32
-#define SUNXI_GPIO_D_NR		32
-#define SUNXI_GPIO_E_NR		32
-#define SUNXI_GPIO_F_NR		32
-#define SUNXI_GPIO_G_NR		32
-#define SUNXI_GPIO_H_NR		32
-#define SUNXI_GPIO_I_NR		32
-#define SUNXI_GPIO_L_NR		32
-#define SUNXI_GPIO_M_NR		32
+#define SUNXI_GPIOS_PER_BANK	32
 
 #define SUNXI_GPIO_NEXT(__gpio) \
-	((__gpio##_START) + (__gpio##_NR) + 0)
+	((__gpio##_START) + SUNXI_GPIOS_PER_BANK)
 
 enum sunxi_gpio_number {
 	SUNXI_GPIO_A_START = 0,
drivers/gpio/sunxi_gpio.c +0 -2
index 7ce3ef73b46..ed26eb011f4 100644
@@ -19,8 +19,6 @@
 #include <dm/device-internal.h>
 #include <dt-bindings/gpio/gpio.h>
 
-#define SUNXI_GPIOS_PER_BANK	SUNXI_GPIO_A_NR
-
 struct sunxi_gpio_plat {
 	struct sunxi_gpio *regs;
 	const char *bank_name;	/* Name of bank, e.g. "B" */
Signature · 1 line
2.31.1
Reviewed-by on v1 3/3
#6 lore raw

Re: [PATCH 3/3] sunxi: gpio: Remove bank-specific size macros

Quoted 3 lines · On Sat, 11 Sep 2021 16:50:49 -0500 Samuel Holland <[email protected]> wrote:

Since the beginning, all banks have had space for 32 pins, even when not all pins were implemented. Let's use a single constant for the GPIO bank size here, like the GPIO driver is already doing.

Yeah, I always found some code in there a bit over the top, thanks for cleaning this up.

Quoted 1 line

Cheers,
Andre

Quoted 46 lines

---

 arch/arm/include/asm/arch-sunxi/gpio.h | 14 ++------------
 drivers/gpio/sunxi_gpio.c              |  2 --
 2 files changed, 2 insertions(+), 14 deletions(-)
arch/arm/include/asm/arch-sunxi/gpio.h +2 -12
index c93c051a19f..cd5e85988b1 100644
@@ -93,20 +93,10 @@ struct sunxi_gpio_reg {
 #define GPIO_PULL_OFFSET(pin)	((((pin) & 0x1f) & 0xf) << 1)
 
 /* GPIO bank sizes */
-#define SUNXI_GPIO_A_NR		32
-#define SUNXI_GPIO_B_NR		32
-#define SUNXI_GPIO_C_NR		32
-#define SUNXI_GPIO_D_NR		32
-#define SUNXI_GPIO_E_NR		32
-#define SUNXI_GPIO_F_NR		32
-#define SUNXI_GPIO_G_NR		32
-#define SUNXI_GPIO_H_NR		32
-#define SUNXI_GPIO_I_NR		32
-#define SUNXI_GPIO_L_NR		32
-#define SUNXI_GPIO_M_NR		32
+#define SUNXI_GPIOS_PER_BANK	32
 
 #define SUNXI_GPIO_NEXT(__gpio) \
-	((__gpio##_START) + (__gpio##_NR) + 0)
+	((__gpio##_START) + SUNXI_GPIOS_PER_BANK)
 
 enum sunxi_gpio_number {
 	SUNXI_GPIO_A_START = 0,
drivers/gpio/sunxi_gpio.c +0 -2
index 7ce3ef73b46..ed26eb011f4 100644
@@ -19,8 +19,6 @@
 #include <dm/device-internal.h>
 #include <dt-bindings/gpio/gpio.h>
 
-#define SUNXI_GPIOS_PER_BANK	SUNXI_GPIO_A_NR
-
 struct sunxi_gpio_plat {
 	struct sunxi_gpio *regs;
 	const char *bank_name;	/* Name of bank, e.g. "B" */