Skip to contentSkip to conversation

Enable driver model for GPIOs on Tegra and Exynos

PATCH Superseded Simon Glass 2 participants 16 messages Aug 11, 2014 – Aug 26, 2014 1 message not in the archive

Subsystems (6)

v6 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

v6 cover Enable driver model for GPIOs on Tegra and Exynos

Now that driver model is part of U-Boot, the task of converting drivers over to it begins. GPIO is one of the easiest to convert, since it already has a sandbox driver and a uclass driver.

The Tegra GPIO driver is relatively simple since it has a linear numbering and already uses the generic GPIO framework. Each GPIO bank has a separate device. Some arguments have been made that a single device should support all the GPIO banks, but currently the driver model uclass does not work that way and it would require a second-level data structure to handle the bank feature.

This driver has been tested on Beaver (Tegra 30).

For exynos, the pinctrl device tree files are brought in from the kernel and cut down to remove the groupings which we don't yet use. Very small additions are made to avoid replicating the awful tables that Linux has for every exynos SoC. This series sits on top of the exynos refactors.

The 'gpio' command is updated to support display of only the allocated GPIOs. This is much more friendly than displaying a large table.

A few related clean-ups are provided as well.

This series is available at u-boot-dm.git, branch working.

Changes in v6:
- Add new patch to allow gpio command to adjust GPIOs that are busy
- Use base_gpio instead of base_port for simplicity
- Add an implementation of the get_function() method
- Fix typo in compatible string
- Remove exynos5420.dtsi which is not used in U-Boot
- Move U-Boot changes into their own file
- Use exynos54xx everywhere instead of exynos5420

Changes in v5:
- Put this patch before the others to avoid breaking bisectability
- Add additional gpio_request() calls for other samsung boards
- Use a mask instead of division in gpio_request() naming call
- Avoid reordering functions
- Remove RFC label now that build errors are fixed
- Tidy up and update cover letter message

Changes in v4:
- Add new patch to enhance 'gpio' command
- Rename struct device to struct udevice
- Add patches for exynos GPIO support

Changes in v3:
- Move dm command enable to previous patch
- Use gpio number for the internal helper functions

Changes in v2:
- Split out driver model changes into separate patches
- Correct bugs found during testing

Simon Glass (12):
dm: gpio: Enhance gpio command to show only active GPIOs
dm: gpio: Allow gpio command to adjust GPIOs that are busy
tegra: Convert tegra GPIO driver to use driver model
exynos: dts: Convert /include/ to #include
exynos: Bring in pinctrl dts files from Linux kernel
exynos: dts: Remove unused pinctrl information to save space
exynos: dts: Adjust device tree files for U-Boot
exynos: Tidy up GPIO headers
exynos: Tidy up GPIO defines
exynos: Make sure that GPIOs are requested
exynos: gpio: Convert to driver model
dm: sandbox: dts: Add a GPIO bank

 arch/arm/cpu/armv7/exynos/pinmux.c         |   5 +-
 arch/arm/dts/exynos4.dtsi                  |   9 +-
 arch/arm/dts/exynos4210-origen.dts         |   4 +-
 arch/arm/dts/exynos4210-pinctrl-uboot.dtsi |  27 ++
 arch/arm/dts/exynos4210-pinctrl.dtsi       | 306 ++++++++++++++++++++
 arch/arm/dts/exynos4210-smdkv310.dts       |   2 +-
 arch/arm/dts/exynos4210-trats.dts          |   2 +-
 arch/arm/dts/exynos4210-universal_c210.dts |   2 +-
 arch/arm/dts/exynos4210.dtsi               | 155 ++++++++++
 arch/arm/dts/exynos4412-trats2.dts         |   2 +-
 arch/arm/dts/exynos4412.dtsi               |  38 +++
 arch/arm/dts/exynos4x12-pinctrl-uboot.dtsi |  46 +++
 arch/arm/dts/exynos4x12-pinctrl.dtsi       | 346 ++++++++++++++++++++++
 arch/arm/dts/exynos4x12.dtsi               | 114 ++++++++
 arch/arm/dts/exynos5.dtsi                  |  56 +++-
 arch/arm/dts/exynos5250-pinctrl-uboot.dtsi |  40 +++
 arch/arm/dts/exynos5250-pinctrl.dtsi       | 333 ++++++++++++++++++++++
 arch/arm/dts/exynos5250-smdk5250.dts       |   2 +-
 arch/arm/dts/exynos5250-snow.dts           |   2 +-
 arch/arm/dts/exynos5250.dtsi               |  40 ++-
 arch/arm/dts/exynos5420-peach-pit.dts      |   2 +-
 arch/arm/dts/exynos5420-smdk5420.dts       |   2 +-
 arch/arm/dts/exynos54xx-pinctrl-uboot.dtsi |  52 ++++
 arch/arm/dts/exynos54xx-pinctrl.dtsi       | 305 ++++++++++++++++++++
 arch/arm/dts/exynos54xx.dtsi               |  57 +++-
 arch/arm/dts/s5pc1xx-goni.dts              |   2 +-
 arch/arm/dts/s5pc1xx-smdkc100.dts          |   2 +-
 arch/arm/include/asm/arch-exynos/gpio.h    |   5 -
 arch/arm/include/asm/arch-s5pc1xx/gpio.h   |   4 -
 arch/arm/include/asm/arch-tegra/gpio.h     |  15 +-
 arch/sandbox/dts/sandbox.dts               |   8 +
 board/nvidia/seaboard/seaboard.c           |   2 +-
 board/samsung/arndale/arndale.c            |   4 +-
 board/samsung/common/board.c               |   2 +-
 board/samsung/common/misc.c                |   3 +-
 board/samsung/goni/goni.c                  |   4 +-
 board/samsung/origen/origen.c              |   2 +-
 board/samsung/smdk5250/exynos5-dt.c        |   7 +
 board/samsung/smdk5420/smdk5420.c          |   6 +-
 board/samsung/smdkc100/smdkc100.c          |   2 +-
 board/samsung/smdkv310/smdkv310.c          |   2 +-
 board/samsung/trats/trats.c                |  17 +-
 board/samsung/trats2/trats2.c              |  27 +-
 board/samsung/universal_c210/universal.c   |   4 +-
 common/cmd_gpio.c                          | 110 ++++---
 drivers/gpio/s5p_gpio.c                    | 444 +++++++++++++++++++----------
 drivers/gpio/tegra_gpio.c                  | 326 +++++++++++++++++----
 drivers/mmc/s5p_sdhci.c                    |   7 +-
 include/asm-generic/gpio.h                 |  15 +-
 include/configs/exynos-common.h            |   4 +
 include/configs/tegra-common.h             |   1 +
 51 files changed, 2683 insertions(+), 291 deletions(-)
 create mode 100644 arch/arm/dts/exynos4210-pinctrl-uboot.dtsi
 create mode 100644 arch/arm/dts/exynos4210-pinctrl.dtsi
 create mode 100644 arch/arm/dts/exynos4210.dtsi
 create mode 100644 arch/arm/dts/exynos4412.dtsi
 create mode 100644 arch/arm/dts/exynos4x12-pinctrl-uboot.dtsi
 create mode 100644 arch/arm/dts/exynos4x12-pinctrl.dtsi
 create mode 100644 arch/arm/dts/exynos4x12.dtsi
 create mode 100644 arch/arm/dts/exynos5250-pinctrl-uboot.dtsi
 create mode 100644 arch/arm/dts/exynos5250-pinctrl.dtsi
 create mode 100644 arch/arm/dts/exynos54xx-pinctrl-uboot.dtsi
 create mode 100644 arch/arm/dts/exynos54xx-pinctrl.dtsi
Signature · 1 line
2.0.0.526.g5318336
#1 lore raw

PATCH v6 1/12 dm: gpio: Enhance gpio command to show only active GPIOs

The GPIO list is very long in many cases and most of them are not used. By default, show only the GPIOs that are in use, and provide a flag to show all of them. This makes the 'gpio status' command much more pleasant.

In order to do this, driver model now exposes a method for obtaining the 'function' of a GPIO, which describes whether it is an input or output, for example. Implementation of this method is optional.

---

Changes in v6: None
Changes in v5: None
Changes in v4:
- Add new patch to enhance 'gpio' command

Changes in v3: None
Changes in v2: None

 common/cmd_gpio.c          | 101 +++++++++++++++++++++++++++++++--------------
 include/asm-generic/gpio.h |  15 ++++++-
 2 files changed, 82 insertions(+), 34 deletions(-)
common/cmd_gpio.c +69 -32
index 4634f91..b97533f 100644
@@ -24,18 +24,46 @@ enum gpio_cmd {
 };
 
 #if defined(CONFIG_DM_GPIO) && !defined(gpio_status)
-static const char * const gpio_function[] = {
+static const char * const gpio_function[GPIOF_COUNT] = {
 	"input",
 	"output",
+	"unused",
 	"unknown",
+	"func",
 };
 
-static void show_gpio(struct udevice *dev, const char *bank_name, int offset)
+/* A few flags used by show_gpio() */
+enum {
+	FLAG_SHOW_ALL		= 1 << 0,
+	FLAG_SHOW_BANK		= 1 << 1,
+	FLAG_SHOW_NEWLINE	= 1 << 2,
+};
+
+static void show_gpio(struct udevice *dev, const char *bank_name, int offset,
+		      int *flagsp)
 {
 	struct dm_gpio_ops *ops = gpio_get_ops(dev);
+	int func = GPIOF_UNKNOWN;
 	char buf[80];
 	int ret;
 
+	BUILD_BUG_ON(GPIOF_COUNT != ARRAY_SIZE(gpio_function));
+
+	if (ops->get_function) {
+		ret = ops->get_function(dev, offset);
+		if (ret >= 0 && ret < ARRAY_SIZE(gpio_function))
+			func = ret;
+	}
+	if (!(*flagsp & FLAG_SHOW_ALL) && func == GPIOF_UNUSED)
+		return;
+	if ((*flagsp & FLAG_SHOW_BANK) && bank_name) {
+		if (*flagsp & FLAG_SHOW_NEWLINE) {
+			putc('\n');
+			*flagsp &= ~FLAG_SHOW_NEWLINE;
+		}
+		printf("Bank %s:\n", bank_name);
+		*flagsp &= ~FLAG_SHOW_BANK;
+	}
 	*buf = '\0';
 	if (ops->get_state) {
 		ret = ops->get_state(dev, offset, buf, sizeof(buf));
@@ -44,14 +72,6 @@ static void show_gpio(struct udevice *dev, const char *bank_name, int offset)
 			return;
 		}
 	} else {
-		int func =  GPIOF_UNKNOWN;
-		int ret;
-
-		if (ops->get_function) {
-			ret = ops->get_function(dev, offset);
-			if (ret >= 0 && ret < ARRAY_SIZE(gpio_function))
-				func = ret;
-		}
 		sprintf(buf, "%s%u: %8s %d", bank_name, offset,
 			gpio_function[func], ops->get_value(dev, offset));
 	}
@@ -60,12 +80,14 @@ static void show_gpio(struct udevice *dev, const char *bank_name, int offset)
 	puts("\n");
 }
 
-static int do_gpio_status(const char *gpio_name)
+static int do_gpio_status(bool all, const char *gpio_name)
 {
 	struct udevice *dev;
-	int newline = 0;
+	int banklen;
+	int flags;
 	int ret;
 
+	flags = 0;
 	if (gpio_name && !*gpio_name)
 		gpio_name = NULL;
 	for (ret = uclass_first_device(UCLASS_GPIO, &dev);
@@ -74,28 +96,33 @@ static int do_gpio_status(const char *gpio_name)
 		const char *bank_name;
 		int num_bits;
 
+		flags |= FLAG_SHOW_BANK;
+		if (all)
+			flags |= FLAG_SHOW_ALL;
 		bank_name = gpio_get_bank_info(dev, &num_bits);
+		if (!num_bits)
+			continue;
+		banklen = bank_name ? strlen(bank_name) : 0;
 
 		if (!gpio_name || !bank_name ||
-		    !strncmp(gpio_name, bank_name, strlen(bank_name))) {
+		    !strncmp(gpio_name, bank_name, banklen)) {
 			const char *p = NULL;
 			int offset;
 
-			if (bank_name) {
-				if (newline)
-					putc('\n');
-				printf("Bank %s:\n", bank_name);
-			}
-			newline = 1;
-			if (gpio_name && bank_name) {
-				p = gpio_name + strlen(bank_name);
+			p = gpio_name + banklen;
+			if (gpio_name && *p) {
 				offset = simple_strtoul(p, NULL, 10);
-				show_gpio(dev, bank_name, offset);
+				show_gpio(dev, bank_name, offset, &flags);
 			} else {
-				for (offset = 0; offset < num_bits; offset++)
-					show_gpio(dev, bank_name, offset);
+				for (offset = 0; offset < num_bits; offset++) {
+					show_gpio(dev, bank_name, offset,
+						  &flags);
+				}
 			}
 		}
+		/* Add a newline between bank names */
+		if (!(flags & FLAG_SHOW_BANK))
+			flags |= FLAG_SHOW_NEWLINE;
 	}
 
 	return ret;
@@ -109,6 +136,7 @@ static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	ulong value;
 	const char *str_cmd, *str_gpio = NULL;
 #ifdef CONFIG_DM_GPIO
+	bool all = false;
 	int ret;
 #endif
 
@@ -116,15 +144,24 @@ static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  show_usage:
 		return CMD_RET_USAGE;
 	str_cmd = argv[1];
-	if (argc > 2)
-		str_gpio = argv[2];
+	argc -= 2;
+	argv += 2;
+#ifdef CONFIG_DM_GPIO
+	if (argc > 0 && !strcmp(*argv, "-a")) {
+		all = true;
+		argc--;
+		argv++;
+	}
+#endif
+	if (argc > 0)
+		str_gpio = *argv;
 	if (!strcmp(str_cmd, "status")) {
 		/* Support deprecated gpio_status() */
 #ifdef gpio_status
 		gpio_status();
 		return 0;
 #elif defined(CONFIG_DM_GPIO)
-		return cmd_process_error(cmdtp, do_gpio_status(str_gpio));
+		return cmd_process_error(cmdtp, do_gpio_status(all, str_gpio));
 #else
 		goto show_usage;
 #endif
@@ -186,8 +223,8 @@ static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return value;
 }
 
-U_BOOT_CMD(gpio, 3, 0, do_gpio,
-	"query and control gpio pins",
-	"<input|set|clear|toggle> <pin>\n"
-	"    - input/set/clear/toggle the specified pin\n"
-	"gpio status [<bank> | <pin>]");
+U_BOOT_CMD(gpio, 4, 0, do_gpio,
+	   "query and control gpio pins",
+	   "<input|set|clear|toggle> <pin>\n"
+	   "    - input/set/clear/toggle the specified pin\n"
+	   "gpio status [-a] [<bank> | <pin>]  - show [all/claimed] GPIOs");
include/asm-generic/gpio.h +13 -2
index a6e52a0..60539d8 100644
@@ -79,11 +79,15 @@ int gpio_get_value(unsigned gpio);
  */
 int gpio_set_value(unsigned gpio, int value);
 
-/* State of a GPIO, as reported by get_state() */
+/* State of a GPIO, as reported by get_function() */
 enum {
 	GPIOF_INPUT = 0,
 	GPIOF_OUTPUT,
-	GPIOF_UNKNOWN,
+	GPIOF_UNUSED,		/* Not claimed */
+	GPIOF_UNKNOWN,		/* Not known */
+	GPIOF_FUNC,		/* Not used as a GPIO */
+
+	GPIOF_COUNT,
 };
 
 struct udevice;
@@ -123,6 +127,13 @@ struct dm_gpio_ops {
 				int value);
 	int (*get_value)(struct udevice *dev, unsigned offset);
 	int (*set_value)(struct udevice *dev, unsigned offset, int value);
+	/**
+	 * get_function() Get the GPIO function
+	 *
+	 * @dev:     Device to check
+	 * @offset:  GPIO offset within that device
+	 * @return current function - GPIOF_...
+	 */
 	int (*get_function)(struct udevice *dev, unsigned offset);
 	int (*get_state)(struct udevice *dev, unsigned offset, char *state,
 			 int maxlen);
Signature · 1 line
2.0.0.526.g5318336
#2 lore raw

PATCH v6 2/12 dm: gpio: Allow gpio command to adjust GPIOs that are busy

In reply to Simon Glass

The gpio command mostly relies on gpio_request() and gpio_free() being nops, in that you can request a GPIO twice. With driver model this is now implemented correctly, so it fails.

Change the command to deal with a failure to claim the GPIO.

---

Changes in v6:
- Add new patch to allow gpio command to adjust GPIOs that are busy

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 common/cmd_gpio.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
common/cmd_gpio.c +6 -3
index b97533f..11f4e40 100644
@@ -8,6 +8,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <errno.h>
 #include <dm.h>
 #include <asm/gpio.h>
 
@@ -135,9 +136,9 @@ static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	enum gpio_cmd sub_cmd;
 	ulong value;
 	const char *str_cmd, *str_gpio = NULL;
+	int ret;
 #ifdef CONFIG_DM_GPIO
 	bool all = false;
-	int ret;
 #endif
 
 	if (argc < 2)
@@ -197,7 +198,8 @@ static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		goto show_usage;
 #endif
 	/* grab the pin before we tweak it */
-	if (gpio_request(gpio, "cmd_gpio")) {
+	ret = gpio_request(gpio, "cmd_gpio");
+	if (ret && ret != -EBUSY) {
 		printf("gpio: requesting pin %u failed\n", gpio);
 		return -1;
 	}
@@ -218,7 +220,8 @@ static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	printf("gpio: pin %s (gpio %i) value is %lu\n",
 		str_gpio, gpio, value);
 
-	gpio_free(gpio);
+	if (ret != -EBUSY)
+		gpio_free(gpio);
 
 	return value;
 }
Signature · 1 line
2.0.0.526.g5318336
#3 lore raw

PATCH v6 3/12 tegra: Convert tegra GPIO driver to use driver model

In reply to Simon Glass

This is an implementation of GPIOs for Tegra that uses driver model. It has been tested on trimslice and also using the new iotrace feature.

The implementation uses a top-level GPIO device (which has no actual GPIOS). Under this all the banks are created as separate GPIO devices.

The GPIOs are named as per the Tegra datasheet/header files: A0..A7, B0..B7, ..., Z0..Z7, AA0..AA7, etc.

Since driver model is not yet available before relocation, or in SPL, a special function is provided for seaboard's SPL code.

---

Changes in v6:
- Use base_gpio instead of base_port for simplicity
- Add an implementation of the get_function() method

Changes in v5: None
Changes in v4:
- Rename struct device to struct udevice

Changes in v3:
- Move dm command enable to previous patch
- Use gpio number for the internal helper functions

Changes in v2:
- Split out driver model changes into separate patches
- Correct bugs found during testing

 arch/arm/include/asm/arch-tegra/gpio.h |  15 +-
 board/nvidia/seaboard/seaboard.c       |   2 +-
 drivers/gpio/tegra_gpio.c              | 326 +++++++++++++++++++++++++++------
 include/configs/tegra-common.h         |   1 +
 4 files changed, 282 insertions(+), 62 deletions(-)
arch/arm/include/asm/arch-tegra/gpio.h +9 -6
index 44cd455..7334e0c 100644
@@ -6,6 +6,8 @@
 #ifndef _TEGRA_GPIO_H_
 #define _TEGRA_GPIO_H_
 
+#define TEGRA_GPIOS_PER_PORT	8
+#define TEGRA_PORTS_PER_BANK	4
 #define MAX_NUM_GPIOS           (TEGRA_GPIO_PORTS * TEGRA_GPIO_BANKS * 8)
 #define GPIO_NAME_SIZE		20	/* gpio_request max label len */
 
@@ -25,9 +27,14 @@ struct tegra_gpio_config {
 	u32 init:2;
 };
 
-/*
- * Tegra-specific GPIO API
+/**
+ * tegra_spl_gpio_direction_output() - set the output value of a GPIO
+ *
+ * This function is only used from SPL on seaboard, which needs to enable a
+ * GPIO to get the UART running. It could be done in U-Boot rather than SPL,
+ * but for now, this gets it working
  */
+int tegra_spl_gpio_direction_output(int gpio, int value);
 
 /**
  * Configure a list of GPIOs
@@ -37,8 +44,4 @@ struct tegra_gpio_config {
  */
 void gpio_config_table(const struct tegra_gpio_config *config, int len);
 
-void gpio_info(void);
-
-#define gpio_status()	gpio_info()
-
 #endif	/* TEGRA_GPIO_H_ */
board/nvidia/seaboard/seaboard.c +1 -1
index ce2db40..6a243f0 100644
@@ -22,7 +22,7 @@ void gpio_early_init_uart(void)
 #ifndef CONFIG_SPL_BUILD
 	gpio_request(GPIO_PI3, NULL);
 #endif
-	gpio_direction_output(GPIO_PI3, 0);
+	tegra_spl_gpio_direction_output(GPIO_PI3, 0);
 }
 #endif
 
drivers/gpio/tegra_gpio.c +271 -55

408 lines not on this page · raw message

include/configs/tegra-common.h +1 -0
index 717cd61..157d4ca 100644
@@ -21,6 +21,7 @@
 
 #define CONFIG_DM
 #define CONFIG_CMD_DM
+#define CONFIG_DM_GPIO
 
 #define CONFIG_SYS_TIMER_RATE		1000000
 #define CONFIG_SYS_TIMER_COUNTER	NV_PA_TMRUS_BASE
Signature · 1 line
2.0.0.526.g5318336
#4 lore raw

PATCH v6 3/12 tegra: Convert tegra GPIO driver to use driver model

Hi,

Quoted 7 lines · Simon Glass

This is an implementation of GPIOs for Tegra that uses driver model. It has been tested on trimslice and also using the new iotrace feature.

The implementation uses a top-level GPIO device (which has no actual GPIOS). Under this all the banks are created as separate GPIO devices.

Quoted 7 lines

The GPIOs are named as per the Tegra datasheet/header files: A0..A7, B0..B7, ..., Z0..Z7, AA0..AA7, etc.

Since driver model is not yet available before relocation, or in SPL, a special function is provided for seaboard's SPL code.

Any comments on this one please?

Quoted 19 lines

---

Changes in v6:
- Use base_gpio instead of base_port for simplicity
- Add an implementation of the get_function() method

Changes in v5: None
Changes in v4:
- Rename struct device to struct udevice

Changes in v3:
- Move dm command enable to previous patch
- Use gpio number for the internal helper functions

Changes in v2:
- Split out driver model changes into separate patches
- Correct bugs found during testing

Quoted 6 lines
 arch/arm/include/asm/arch-tegra/gpio.h |  15 +-
 board/nvidia/seaboard/seaboard.c       |   2 +-
 drivers/gpio/tegra_gpio.c              | 326 +++++++++++++++++++++++++++------
 include/configs/tegra-common.h         |   1 +
 4 files changed, 282 insertions(+), 62 deletions(-)

Regards,
Simon

#5 lore raw

PATCH v6 3/12 tegra: Convert tegra GPIO driver to use driver model

Quoted 13 lines · Simon Glass

Hi,

Quoted 10 lines · Simon Glass

This is an implementation of GPIOs for Tegra that uses driver model. It has been tested on trimslice and also using the new iotrace feature.

The implementation uses a top-level GPIO device (which has no actual GPIOS). Under this all the banks are created as separate GPIO devices.

The GPIOs are named as per the Tegra datasheet/header files: A0..A7, B0..B7, ..., Z0..Z7, AA0..AA7, etc.

Quoted 6 lines
Quoted 4 lines

Since driver model is not yet available before relocation, or in SPL, a special function is provided for seaboard's SPL code.

Any comments on this one please?

Tom, can you please review this patch/series? Thanks.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw

PATCH v6 3/12 tegra: Convert tegra GPIO driver to use driver model

Hi Stephen,

Quoted 1 line · Tom Warren

Sorry, very low priority for me right now. Try to get someone else to do it, as it may be a long while until I can get to it.

Are you able to test it on your board? I can pull it through the DM tree but would like some sort of independent verification. I will go through the patch once more very carefully.

Quoted 29 lines

Tom

Quoted 26 lines

-----Original Message-----
From: Stephen Warren [mailto:swarren at wwwdotorg.org]
Sent: Monday, August 25, 2014 11:50 AM
To: Simon Glass; Tom Warren
Cc: U-Boot Mailing List; u-boot-review; Stephen Warren
Subject: Re: [PATCH v6 03/12] tegra: Convert tegra GPIO driver to use driver model

Quoted 8 lines · Simon Glass

Hi,

Quoted 5 lines · Simon Glass

This is an implementation of GPIOs for Tegra that uses driver model. It has been tested on trimslice and also using the new iotrace feature.

The implementation uses a top-level GPIO device (which has no actual

GPIOS).

Quoted 8 lines
Quoted 8 lines

Under this all the banks are created as separate GPIO devices.

The GPIOs are named as per the Tegra datasheet/header files: A0..A7, B0..B7, ..., Z0..Z7, AA0..AA7, etc.

Since driver model is not yet available before relocation, or in SPL, a special function is provided for seaboard's SPL code.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Any comments on this one please?

Tom, can you please review this patch/series? Thanks.

--
nvpublic

Regards,
Simon

#8 lore raw

PATCH v6 4/12 exynos: dts: Convert /include/ to #include

In reply to Simon Glass

We should be consistent about this. The kernel has moved to #include which breaks error reporting to some extent but does allow us to include binding files.

---

Changes in v6: None
Changes in v5:
- Put this patch before the others to avoid breaking bisectability

Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/arm/dts/exynos4.dtsi                  | 2 +-
 arch/arm/dts/exynos4210-origen.dts         | 4 ++--
 arch/arm/dts/exynos4210-smdkv310.dts       | 2 +-
 arch/arm/dts/exynos4210-trats.dts          | 2 +-
 arch/arm/dts/exynos4210-universal_c210.dts | 2 +-
 arch/arm/dts/exynos4412-trats2.dts         | 2 +-
 arch/arm/dts/exynos5.dtsi                  | 2 +-
 arch/arm/dts/exynos5250-smdk5250.dts       | 2 +-
 arch/arm/dts/exynos5250-snow.dts           | 2 +-
 arch/arm/dts/exynos5250.dtsi               | 2 +-
 arch/arm/dts/exynos5420-peach-pit.dts      | 2 +-
 arch/arm/dts/exynos5420-smdk5420.dts       | 2 +-
 arch/arm/dts/exynos54xx.dtsi               | 2 +-
 arch/arm/dts/s5pc1xx-goni.dts              | 2 +-
 arch/arm/dts/s5pc1xx-smdkc100.dts          | 2 +-
 15 files changed, 16 insertions(+), 16 deletions(-)
arch/arm/dts/exynos4.dtsi +1 -1
index 110eb43..6b83516 100644
@@ -7,7 +7,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-/include/ "skeleton.dtsi"
+#include "skeleton.dtsi"
 
 / {
 	serial at 13800000 {
arch/arm/dts/exynos4210-origen.dts +2 -2
index 15059d2..556a3a2 100644
@@ -8,8 +8,8 @@
  */
 
 /dts-v1/;
-/include/ "skeleton.dtsi"
-/include/ "exynos4.dtsi"
+#include "skeleton.dtsi"
+#include "exynos4.dtsi"
 
 / {
 	model = "Insignal Origen evaluation board based on Exynos4210";
arch/arm/dts/exynos4210-smdkv310.dts +1 -1
index c390c8f..00cad04 100644
@@ -7,7 +7,7 @@
  */
 
 /dts-v1/;
-/include/ "exynos4.dtsi"
+#include "exynos4.dtsi"
 
 / {
 	model = "Samsung SMDKV310 on Exynos4210";
arch/arm/dts/exynos4210-trats.dts +1 -1
index 0ff6939..71202d0 100644
@@ -8,7 +8,7 @@
  */
 
 /dts-v1/;
-/include/ "exynos4.dtsi"
+#include "exynos4.dtsi"
 
 / {
 	model = "Samsung Trats based on Exynos4210";
arch/arm/dts/exynos4210-universal_c210.dts +1 -1
index 6941906..d30f131 100644
@@ -8,7 +8,7 @@
  */
 
 /dts-v1/;
-/include/ "exynos4.dtsi"
+#include "exynos4.dtsi"
 
 / {
 	model = "Samsung Universal C210 based on Exynos4210 rev0";
arch/arm/dts/exynos4412-trats2.dts +1 -1
index cc58c87..9d22de7 100644
@@ -8,7 +8,7 @@
  */
 
 /dts-v1/;
-/include/ "exynos4.dtsi"
+#include "exynos4.dtsi"
 
 / {
 	model = "Samsung Trats2 based on Exynos4412";
arch/arm/dts/exynos5.dtsi +1 -1
index a2b533a..329a89a 100644
@@ -5,7 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-/include/ "skeleton.dtsi"
+#include "skeleton.dtsi"
 
 / {
 	compatible = "samsung,exynos5";
arch/arm/dts/exynos5250-smdk5250.dts +1 -1
index 9020382..8850409 100644
@@ -10,7 +10,7 @@
 */
 
 /dts-v1/;
-/include/ "exynos5250.dtsi"
+#include "exynos5250.dtsi"
 
 / {
 	model = "SAMSUNG SMDK5250 board based on EXYNOS5250";
arch/arm/dts/exynos5250-snow.dts +1 -1
index ab4f2f8..2003412 100644
@@ -10,7 +10,7 @@
 */
 
 /dts-v1/;
-/include/ "exynos5250.dtsi"
+#include "exynos5250.dtsi"
 
 / {
 	model = "Google Snow";
arch/arm/dts/exynos5250.dtsi +1 -1
index 0c644e7..771f8d3 100644
@@ -5,7 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-/include/ "exynos5.dtsi"
+#include "exynos5.dtsi"
 
 / {
 	i2c at 12ca0000 {
arch/arm/dts/exynos5420-peach-pit.dts +1 -1
index 995e62b..c4c4b8e 100644
@@ -8,7 +8,7 @@
  */
 
 /dts-v1/;
-/include/ "exynos54xx.dtsi"
+#include "exynos54xx.dtsi"
 
 / {
 	model = "Samsung/Google Peach Pit board based on Exynos5420";
arch/arm/dts/exynos5420-smdk5420.dts +1 -1
index 1bc6256..6855027 100644
@@ -8,7 +8,7 @@
  */
 
 /dts-v1/;
-/include/ "exynos54xx.dtsi"
+#include "exynos54xx.dtsi"
 
 / {
 	model = "SAMSUNG SMDK5420 board based on EXYNOS5420";
arch/arm/dts/exynos54xx.dtsi +1 -1
index c21d798..7892345 100644
@@ -5,7 +5,7 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-/include/ "exynos5.dtsi"
+#include "exynos5.dtsi"
 
 / {
 	config {
arch/arm/dts/s5pc1xx-goni.dts +1 -1
index c390c8f..00cad04 100644
@@ -7,7 +7,7 @@
  */
 
 /dts-v1/;
-/include/ "exynos4.dtsi"
+#include "exynos4.dtsi"
 
 / {
 	model = "Samsung SMDKV310 on Exynos4210";
arch/arm/dts/s5pc1xx-smdkc100.dts +1 -1
index 409812d..e8448f4 100644
@@ -7,7 +7,7 @@
  */
 
 /dts-v1/;
-/include/ "exynos4.dtsi"
+#include "exynos4.dtsi"
 
 / {
 	model = "Samsung SMDKC100";
Signature · 1 line
2.0.0.526.g5318336
#9 lore raw

PATCH v6 5/12 exynos: Bring in pinctrl dts files from Linux kernel

In reply to Simon Glass

Bring in required device tree files for pinctrl from Linux v3.14. These are initially unchanged and have a number of pieces not needed by U-Boot.

Note that exynos5420 is renamed to exynos54xx here since we want to support exynos5422 also.

---

Changes in v6:
- Fix typo in compatible string
- Remove exynos5420.dtsi which is not used in U-Boot

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/arm/dts/exynos4.dtsi                  |   7 +
 arch/arm/dts/exynos4210-origen.dts         |   2 +-
 arch/arm/dts/exynos4210-pinctrl.dtsi       | 847 +++++++++++++++++++++++++
 arch/arm/dts/exynos4210-trats.dts          |   2 +-
 arch/arm/dts/exynos4210-universal_c210.dts |   2 +-
 arch/arm/dts/exynos4210.dtsi               | 155 +++++
 arch/arm/dts/exynos4412-trats2.dts         |   2 +-
 arch/arm/dts/exynos4412.dtsi               |  38 ++
 arch/arm/dts/exynos4x12-pinctrl.dtsi       | 956 +++++++++++++++++++++++++++++
 arch/arm/dts/exynos4x12.dtsi               | 214 +++++++
 arch/arm/dts/exynos5.dtsi                  |  54 ++
 arch/arm/dts/exynos5250-pinctrl.dtsi       | 790 ++++++++++++++++++++++++
 arch/arm/dts/exynos5250.dtsi               |  38 ++
 arch/arm/dts/exynos54xx-pinctrl.dtsi       | 687 +++++++++++++++++++++
 arch/arm/dts/exynos54xx.dtsi               |  44 ++
 15 files changed, 3834 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/dts/exynos4210-pinctrl.dtsi
 create mode 100644 arch/arm/dts/exynos4210.dtsi
 create mode 100644 arch/arm/dts/exynos4412.dtsi
 create mode 100644 arch/arm/dts/exynos4x12-pinctrl.dtsi
 create mode 100644 arch/arm/dts/exynos4x12.dtsi
 create mode 100644 arch/arm/dts/exynos5250-pinctrl.dtsi
 create mode 100644 arch/arm/dts/exynos54xx-pinctrl.dtsi
arch/arm/dts/exynos4.dtsi +7 -0
index 6b83516..77fad48 100644
@@ -10,6 +10,13 @@
 #include "skeleton.dtsi"
 
 / {
+	combiner: interrupt-controller at 10440000 {
+		compatible = "samsung,exynos4210-combiner";
+		#interrupt-cells = <2>;
+		interrupt-controller;
+		reg = <0x10440000 0x1000>;
+	};
+
 	serial at 13800000 {
 		compatible = "samsung,exynos4210-uart";
 		reg = <0x13800000 0x3c>;
arch/arm/dts/exynos4210-origen.dts +1 -1
index 556a3a2..dd2476c 100644
@@ -9,7 +9,7 @@
 
 /dts-v1/;
 #include "skeleton.dtsi"
-#include "exynos4.dtsi"
+#include "exynos4210.dtsi"
 
 / {
 	model = "Insignal Origen evaluation board based on Exynos4210";
arch/arm/dts/exynos4210-pinctrl.dtsi new file +847 -0

847 lines not on this page · raw message

arch/arm/dts/exynos4210-trats.dts +1 -1
index 71202d0..81188bc 100644
@@ -8,7 +8,7 @@
  */
 
 /dts-v1/;
-#include "exynos4.dtsi"
+#include "exynos4210.dtsi"
 
 / {
 	model = "Samsung Trats based on Exynos4210";
arch/arm/dts/exynos4210-universal_c210.dts +1 -1
index d30f131..cf3354f 100644
@@ -8,7 +8,7 @@
  */
 
 /dts-v1/;
-#include "exynos4.dtsi"
+#include "exynos4210.dtsi"
 
 / {
 	model = "Samsung Universal C210 based on Exynos4210 rev0";
arch/arm/dts/exynos4210.dtsi new file +155 -0

155 lines not on this page · raw message

arch/arm/dts/exynos4412-trats2.dts +1 -1
index 9d22de7..3b1e458 100644
@@ -8,7 +8,7 @@
  */
 
 /dts-v1/;
-#include "exynos4.dtsi"
+#include "exynos4412.dtsi"
 
 / {
 	model = "Samsung Trats2 based on Exynos4412";
arch/arm/dts/exynos4412.dtsi new file +38 -0
new file mode 100644
index 0000000..87b339c
@@ -0,0 +1,38 @@
+/*
+ * Samsung's Exynos4412 SoC device tree source
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *		http://www.samsung.com
+ *
+ * Samsung's Exynos4412 SoC device nodes are listed in this file. Exynos4412
+ * based board files can include this file and provide values for board specfic
+ * bindings.
+ *
+ * Note: This file does not include device nodes for all the controllers in
+ * Exynos4412 SoC. As device tree coverage for Exynos4412 increases, additional
+ * nodes can be added to this file.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#include "exynos4x12.dtsi"
+
+/ {
+	compatible = "samsung,exynos4412";
+
+	gic: interrupt-controller at 10490000 {
+		cpu-offset = <0x4000>;
+	};
+
+	interrupt-controller at 10440000 {
+		samsung,combiner-nr = <20>;
+		interrupts = <0 0 0>, <0 1 0>, <0 2 0>, <0 3 0>,
+			     <0 4 0>, <0 5 0>, <0 6 0>, <0 7 0>,
+			     <0 8 0>, <0 9 0>, <0 10 0>, <0 11 0>,
+			     <0 12 0>, <0 13 0>, <0 14 0>, <0 15 0>,
+			     <0 107 0>, <0 108 0>, <0 48 0>, <0 42 0>;
+	};
+
+};
arch/arm/dts/exynos4x12-pinctrl.dtsi new file +956 -0

956 lines not on this page · raw message

arch/arm/dts/exynos4x12.dtsi new file +214 -0

214 lines not on this page · raw message

arch/arm/dts/exynos5.dtsi +54 -0

66 lines not on this page · raw message

arch/arm/dts/exynos5250-pinctrl.dtsi new file +790 -0

679 lines not on this page · raw message

arch/arm/dts/exynos5250.dtsi +38 -0
index 771f8d3..16581dd 100644

Lines of this file are not shown. View the raw message.

arch/arm/dts/exynos54xx-pinctrl.dtsi new file +687 -0

687 lines not on this page · raw message

arch/arm/dts/exynos54xx.dtsi +44 -0

44 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.0.0.526.g5318336

Part of the diff is not shown here. View the raw message.

#10 lore raw

PATCH v6 6/12 exynos: dts: Remove unused pinctrl information to save space

In reply to Simon Glass

We don't include the pinctrl functions for U-Boot as they use up quite a bit of space and are not used.

We could instead perhaps eliminate this material with fdtgrep, but so far this tool has not made it to upstream.

---

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/arm/dts/exynos4210-pinctrl.dtsi | 543 -------------------------------
 arch/arm/dts/exynos4x12-pinctrl.dtsi | 612 -----------------------------------
 arch/arm/dts/exynos4x12.dtsi         | 100 ------
 arch/arm/dts/exynos5250-pinctrl.dtsi | 459 --------------------------
 arch/arm/dts/exynos54xx-pinctrl.dtsi | 384 ----------------------
 5 files changed, 2098 deletions(-)
arch/arm/dts/exynos4210-pinctrl.dtsi +0 -543
index a7c2128..bda17f7 100644
@@ -144,281 +144,6 @@
 			#interrupt-cells = <2>;
 		};
 
-		uart0_data: uart0-data {
-			samsung,pins = "gpa0-0", "gpa0-1";
-			samsung,pin-function = <0x2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		uart0_fctl: uart0-fctl {
-			samsung,pins = "gpa0-2", "gpa0-3";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		uart1_data: uart1-data {
-			samsung,pins = "gpa0-4", "gpa0-5";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		uart1_fctl: uart1-fctl {
-			samsung,pins = "gpa0-6", "gpa0-7";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		i2c2_bus: i2c2-bus {
-			samsung,pins = "gpa0-6", "gpa0-7";
-			samsung,pin-function = <3>;
-			samsung,pin-pud = <3>;
-			samsung,pin-drv = <0>;
-		};
-
-		uart2_data: uart2-data {
-			samsung,pins = "gpa1-0", "gpa1-1";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		uart2_fctl: uart2-fctl {
-			samsung,pins = "gpa1-2", "gpa1-3";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		uart_audio_a: uart-audio-a {
-			samsung,pins = "gpa1-0", "gpa1-1";
-			samsung,pin-function = <4>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		i2c3_bus: i2c3-bus {
-			samsung,pins = "gpa1-2", "gpa1-3";
-			samsung,pin-function = <3>;
-			samsung,pin-pud = <3>;
-			samsung,pin-drv = <0>;
-		};
-
-		uart3_data: uart3-data {
-			samsung,pins = "gpa1-4", "gpa1-5";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		uart_audio_b: uart-audio-b {
-			samsung,pins = "gpa1-4", "gpa1-5";
-			samsung,pin-function = <4>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		spi0_bus: spi0-bus {
-			samsung,pins = "gpb-0", "gpb-2", "gpb-3";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <3>;
-			samsung,pin-drv = <0>;
-		};
-
-		i2c4_bus: i2c4-bus {
-			samsung,pins = "gpb-2", "gpb-3";
-			samsung,pin-function = <3>;
-			samsung,pin-pud = <3>;
-			samsung,pin-drv = <0>;
-		};
-
-		spi1_bus: spi1-bus {
-			samsung,pins = "gpb-4", "gpb-6", "gpb-7";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <3>;
-			samsung,pin-drv = <0>;
-		};
-
-		i2c5_bus: i2c5-bus {
-			samsung,pins = "gpb-6", "gpb-7";
-			samsung,pin-function = <3>;
-			samsung,pin-pud = <3>;
-			samsung,pin-drv = <0>;
-		};
-
-		i2s1_bus: i2s1-bus {
-			samsung,pins = "gpc0-0", "gpc0-1", "gpc0-2", "gpc0-3",
-					"gpc0-4";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		pcm1_bus: pcm1-bus {
-			samsung,pins = "gpc0-0", "gpc0-1", "gpc0-2", "gpc0-3",
-					"gpc0-4";
-			samsung,pin-function = <3>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		ac97_bus: ac97-bus {
-			samsung,pins = "gpc0-0", "gpc0-1", "gpc0-2", "gpc0-3",
-					"gpc0-4";
-			samsung,pin-function = <4>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		i2s2_bus: i2s2-bus {
-			samsung,pins = "gpc1-0", "gpc1-1", "gpc1-2", "gpc1-3",
-					"gpc1-4";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		pcm2_bus: pcm2-bus {
-			samsung,pins = "gpc1-0", "gpc1-1", "gpc1-2", "gpc1-3",
-					"gpc1-4";
-			samsung,pin-function = <3>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		spdif_bus: spdif-bus {
-			samsung,pins = "gpc1-0", "gpc1-1";
-			samsung,pin-function = <4>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		i2c6_bus: i2c6-bus {
-			samsung,pins = "gpc1-3", "gpc1-4";
-			samsung,pin-function = <4>;
-			samsung,pin-pud = <3>;
-			samsung,pin-drv = <0>;
-		};
-
-		spi2_bus: spi2-bus {
-			samsung,pins = "gpc1-1", "gpc1-2", "gpc1-3", "gpc1-4";
-			samsung,pin-function = <5>;
-			samsung,pin-pud = <3>;
-			samsung,pin-drv = <0>;
-		};
-
-		i2c7_bus: i2c7-bus {
-			samsung,pins = "gpd0-2", "gpd0-3";
-			samsung,pin-function = <3>;
-			samsung,pin-pud = <3>;
-			samsung,pin-drv = <0>;
-		};
-
-		i2c0_bus: i2c0-bus {
-			samsung,pins = "gpd1-0", "gpd1-1";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <3>;
-			samsung,pin-drv = <0>;
-		};
-
-		i2c1_bus: i2c1-bus {
-			samsung,pins = "gpd1-2", "gpd1-3";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <3>;
-			samsung,pin-drv = <0>;
-		};
-
-		pwm0_out: pwm0-out {
-			samsung,pins = "gpd0-0";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		pwm1_out: pwm1-out {
-			samsung,pins = "gpd0-1";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		pwm2_out: pwm2-out {
-			samsung,pins = "gpd0-2";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		pwm3_out: pwm3-out {
-			samsung,pins = "gpd0-3";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		lcd_ctrl: lcd-ctrl {
-			samsung,pins = "gpd0-0", "gpd0-1";
-			samsung,pin-function = <3>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		lcd_sync: lcd-sync {
-			samsung,pins = "gpf0-0", "gpf0-1";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		lcd_en: lcd-en {
-			samsung,pins = "gpe3-4";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		lcd_clk: lcd-clk {
-			samsung,pins = "gpf0-0", "gpf0-1", "gpf0-2", "gpf0-3";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		lcd_data16: lcd-data-width16 {
-			samsung,pins = "gpf0-7", "gpf1-0", "gpf1-1", "gpf1-2",
-					"gpf1-3", "gpf1-6", "gpf1-7", "gpf2-0",
-					"gpf2-1", "gpf2-2", "gpf2-3", "gpf2-7",
-					"gpf3-0", "gpf3-1", "gpf3-2", "gpf3-3";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		lcd_data18: lcd-data-width18 {
-			samsung,pins = "gpf0-6", "gpf0-7", "gpf1-0", "gpf1-1",
-					"gpf1-2", "gpf1-3", "gpf1-6", "gpf1-7",
-					"gpf2-0", "gpf2-1", "gpf2-2", "gpf2-3",
-					"gpf2-6", "gpf2-7", "gpf3-0", "gpf3-1",
-					"gpf3-2", "gpf3-3";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		lcd_data24: lcd-data-width24 {
-			samsung,pins = "gpf0-4", "gpf0-5", "gpf0-6", "gpf0-7",
-					"gpf1-0", "gpf1-1", "gpf1-2", "gpf1-3",
-					"gpf1-4", "gpf1-5", "gpf1-6", "gpf1-7",
-					"gpf2-0", "gpf2-1", "gpf2-2", "gpf2-3",
-					"gpf2-4", "gpf2-5", "gpf2-6", "gpf2-7",
-					"gpf3-0", "gpf3-1", "gpf3-2", "gpf3-3";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
 	};
 
 	pinctrl at 11000000 {
@@ -567,259 +292,6 @@
 			#interrupt-cells = <2>;
 		};
 
-		sd0_clk: sd0-clk {
-			samsung,pins = "gpk0-0";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <3>;
-		};
-
-		sd0_cmd: sd0-cmd {
-			samsung,pins = "gpk0-1";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <3>;
-		};
-
-		sd0_cd: sd0-cd {
-			samsung,pins = "gpk0-2";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <3>;
-			samsung,pin-drv = <3>;
-		};
-
-		sd0_bus1: sd0-bus-width1 {
-			samsung,pins = "gpk0-3";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <3>;
-			samsung,pin-drv = <3>;
-		};
-
-		sd0_bus4: sd0-bus-width4 {
-			samsung,pins = "gpk0-3", "gpk0-4", "gpk0-5", "gpk0-6";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <3>;
-			samsung,pin-drv = <3>;
-		};
-
-		sd0_bus8: sd0-bus-width8 {
-			samsung,pins = "gpk1-3", "gpk1-4", "gpk1-5", "gpk1-6";
-			samsung,pin-function = <3>;
-			samsung,pin-pud = <3>;
-			samsung,pin-drv = <3>;
-		};
-
-		sd4_clk: sd4-clk {
-			samsung,pins = "gpk0-0";
-			samsung,pin-function = <3>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <3>;
-		};
-
-		sd4_cmd: sd4-cmd {
-			samsung,pins = "gpk0-1";
-			samsung,pin-function = <3>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <3>;
-		};
-
-		sd4_cd: sd4-cd {
-			samsung,pins = "gpk0-2";
-			samsung,pin-function = <3>;
-			samsung,pin-pud = <3>;
-			samsung,pin-drv = <3>;
-		};
-
-		sd4_bus1: sd4-bus-width1 {
-			samsung,pins = "gpk0-3";
-			samsung,pin-function = <3>;
-			samsung,pin-pud = <3>;
-			samsung,pin-drv = <3>;
-		};
-
-		sd4_bus4: sd4-bus-width4 {
-			samsung,pins = "gpk0-3", "gpk0-4", "gpk0-5", "gpk0-6";
-			samsung,pin-function = <3>;
-			samsung,pin-pud = <3>;
-			samsung,pin-drv = <3>;
-		};
-
-		sd4_bus8: sd4-bus-width8 {
-			samsung,pins = "gpk1-3", "gpk1-4", "gpk1-5", "gpk1-6";
-			samsung,pin-function = <3>;
-			samsung,pin-pud = <4>;
-			samsung,pin-drv = <3>;
-		};
-
-		sd1_clk: sd1-clk {
-			samsung,pins = "gpk1-0";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <3>;
-		};
-
-		sd1_cmd: sd1-cmd {
-			samsung,pins = "gpk1-1";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <3>;
-		};
-
-		sd1_cd: sd1-cd {
-			samsung,pins = "gpk1-2";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <3>;
-			samsung,pin-drv = <3>;
-		};
-
-		sd1_bus1: sd1-bus-width1 {
-			samsung,pins = "gpk1-3";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <3>;
-			samsung,pin-drv = <3>;
-		};
-
-		sd1_bus4: sd1-bus-width4 {
-			samsung,pins = "gpk1-3", "gpk1-4", "gpk1-5", "gpk1-6";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <3>;
-			samsung,pin-drv = <3>;
-		};
-
-		sd2_clk: sd2-clk {
-			samsung,pins = "gpk2-0";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <3>;
-		};
-
-		sd2_cmd: sd2-cmd {
-			samsung,pins = "gpk2-1";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <3>;
-		};
-
-		sd2_cd: sd2-cd {
-			samsung,pins = "gpk2-2";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <3>;
-			samsung,pin-drv = <3>;
-		};
-
-		sd2_bus1: sd2-bus-width1 {
-			samsung,pins = "gpk2-3";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <3>;
-			samsung,pin-drv = <3>;
-		};
-
-		sd2_bus4: sd2-bus-width4 {
-			samsung,pins = "gpk2-3", "gpk2-4", "gpk2-5", "gpk2-6";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <3>;
-			samsung,pin-drv = <3>;
-		};
-
-		sd2_bus8: sd2-bus-width8 {
-			samsung,pins = "gpk3-3", "gpk3-4", "gpk3-5", "gpk3-6";
-			samsung,pin-function = <3>;
-			samsung,pin-pud = <3>;
-			samsung,pin-drv = <3>;
-		};
-
-		sd3_clk: sd3-clk {
-			samsung,pins = "gpk3-0";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <3>;
-		};
-
-		sd3_cmd: sd3-cmd {
-			samsung,pins = "gpk3-1";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <3>;
-		};
-
-		sd3_cd: sd3-cd {
-			samsung,pins = "gpk3-2";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <3>;
-			samsung,pin-drv = <3>;
-		};
-
-		sd3_bus1: sd3-bus-width1 {
-			samsung,pins = "gpk3-3";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <3>;
-			samsung,pin-drv = <3>;
-		};
-
-		sd3_bus4: sd3-bus-width4 {
-			samsung,pins = "gpk3-3", "gpk3-4", "gpk3-5", "gpk3-6";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <3>;
-			samsung,pin-drv = <3>;
-		};
-
-		eint0: ext-int0 {
-			samsung,pins = "gpx0-0";
-			samsung,pin-function = <0xf>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		eint8: ext-int8 {
-			samsung,pins = "gpx1-0";
-			samsung,pin-function = <0xf>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		eint15: ext-int15 {
-			samsung,pins = "gpx1-7";
-			samsung,pin-function = <0xf>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		eint16: ext-int16 {
-			samsung,pins = "gpx2-0";
-			samsung,pin-function = <0xf>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		eint31: ext-int31 {
-			samsung,pins = "gpx3-7";
-			samsung,pin-function = <0xf>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		cam_port_a_io: cam-port-a-io {
-			samsung,pins = "gpj0-0", "gpj0-1", "gpj0-2", "gpj0-3",
-					"gpj0-4", "gpj0-5", "gpj0-6", "gpj0-7",
-					"gpj1-0", "gpj1-1", "gpj1-2", "gpj1-4";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		cam_port_a_clk_active: cam-port-a-clk-active {
-			samsung,pins = "gpj1-3";
-			samsung,pin-function = <2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <3>;
-		};
-
-		cam_port_a_clk_idle: cam-port-a-clk-idle {
-			samsung,pins = "gpj1-3";
-			samsung,pin-function = <0>;
-			samsung,pin-pud = <1>;
-			samsung,pin-drv = <0>;
-		};
 	};
 
 	pinctrl at 03860000 {
@@ -828,20 +300,5 @@
 			#gpio-cells = <2>;
 		};
 
-		i2s0_bus: i2s0-bus {
-			samsung,pins = "gpz-0", "gpz-1", "gpz-2", "gpz-3",
-					"gpz-4", "gpz-5", "gpz-6";
-			samsung,pin-function = <0x2>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
-
-		pcm0_bus: pcm0-bus {
-			samsung,pins = "gpz-0", "gpz-1", "gpz-2", "gpz-3",
-					"gpz-4";
-			samsung,pin-function = <0x3>;
-			samsung,pin-pud = <0>;
-			samsung,pin-drv = <0>;
-		};
 	};
 };
arch/arm/dts/exynos4x12-pinctrl.dtsi +0 -612

635 lines not on this page · raw message

arch/arm/dts/exynos4x12.dtsi +0 -100

112 lines not on this page · raw message

arch/arm/dts/exynos5250-pinctrl.dtsi +0 -459

482 lines not on this page · raw message

arch/arm/dts/exynos54xx-pinctrl.dtsi +0 -384

413 lines not on this page · raw message

Signature · 1 line
2.0.0.526.g5318336
#11 lore raw

PATCH v6 7/12 exynos: dts: Adjust device tree files for U-Boot

In reply to Simon Glass

The pinctrl bindings used by Linux are an incomplete description of the hardware. It is possible in most cases to determine the register address of each, but not in all cases. By adding an additional property we can fix this, and avoid adding a table to U-Boot for every single Exynos SOC.

---

Changes in v6:
- Move U-Boot changes into their own file
- Use exynos54xx everywhere instead of exynos5420

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/arm/dts/exynos4210-pinctrl-uboot.dtsi | 27 ++++++++++++++++
 arch/arm/dts/exynos4210-pinctrl.dtsi       |  2 ++
 arch/arm/dts/exynos4x12-pinctrl-uboot.dtsi | 46 ++++++++++++++++++++++++++
 arch/arm/dts/exynos4x12-pinctrl.dtsi       |  2 ++
 arch/arm/dts/exynos5250-pinctrl-uboot.dtsi | 40 +++++++++++++++++++++++
 arch/arm/dts/exynos5250-pinctrl.dtsi       |  2 ++
 arch/arm/dts/exynos54xx-pinctrl-uboot.dtsi | 52 ++++++++++++++++++++++++++++++
 arch/arm/dts/exynos54xx-pinctrl.dtsi       |  2 ++
 arch/arm/dts/exynos54xx.dtsi               | 11 +++++++
 9 files changed, 184 insertions(+)
 create mode 100644 arch/arm/dts/exynos4210-pinctrl-uboot.dtsi
 create mode 100644 arch/arm/dts/exynos4x12-pinctrl-uboot.dtsi
 create mode 100644 arch/arm/dts/exynos5250-pinctrl-uboot.dtsi
 create mode 100644 arch/arm/dts/exynos54xx-pinctrl-uboot.dtsi
arch/arm/dts/exynos4210-pinctrl-uboot.dtsi new file +27 -0
new file mode 100644
index 0000000..ee071c1
@@ -0,0 +1,27 @@
+/*
+ * U-Boot additions to enable a generic Exynos GPIO driver
+ *
+ * Copyright (c) 2014 Google, Inc
+ */
+
+/{
+	pinctrl_0: pinctrl at 11400000 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		compatible = "samsung,exynos4210-pinctrl";
+	};
+
+	pinctrl_1: pinctrl at 11000000 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		gpy0: gpy0 {
+			reg = <0xc00>;
+		};
+	};
+
+	pinctrl_2: pinctrl at 03860000 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+	};
+
+};
arch/arm/dts/exynos4210-pinctrl.dtsi +2 -0
index bda17f7..87f162b 100644
@@ -14,6 +14,8 @@
  * published by the Free Software Foundation.
 */
 
+#include "exynos4210-pinctrl-uboot.dtsi"
+
 / {
 	pinctrl at 11400000 {
 		gpa0: gpa0 {
arch/arm/dts/exynos4x12-pinctrl-uboot.dtsi new file +46 -0

46 lines not on this page · raw message

arch/arm/dts/exynos4x12-pinctrl.dtsi +2 -0
index 93f3998..f40de1f 100644
@@ -12,6 +12,8 @@
  * published by the Free Software Foundation.
 */
 
+#include "exynos4x12-pinctrl-uboot.dtsi"
+
 / {
 	pinctrl at 11400000 {
 		gpa0: gpa0 {
arch/arm/dts/exynos5250-pinctrl-uboot.dtsi new file +40 -0
new file mode 100644
index 0000000..7edb0ca
@@ -0,0 +1,40 @@
+/*
+ * U-Boot additions to enable a generic Exynos GPIO driver
+ *
+ * Copyright (c) 2014 Google, Inc
+ */
+
+/{
+	pinctrl_0: pinctrl at 11400000 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		gpc4: gpc4 {
+			reg = <0x2e0>;
+		};
+		gpx0: gpx0 {
+			reg = <0xc00>;
+		};
+	};
+
+	pinctrl_1: pinctrl at 13400000 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+	};
+
+	pinctrl_2: pinctrl at 10d10000 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		gpv2: gpv2 {
+			reg = <0x060>;
+		};
+		gpv4: gpv4 {
+			reg = <0xc0>;
+		};
+	};
+
+	pinctrl_3: pinctrl at 03860000 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+	};
+
+};
arch/arm/dts/exynos5250-pinctrl.dtsi +2 -0
index 67755a1..706b888 100644
@@ -12,6 +12,8 @@
  * published by the Free Software Foundation.
 */
 
+#include "exynos5250-pinctrl-uboot.dtsi"
+
 / {
 	pinctrl at 11400000 {
 		gpa0: gpa0 {
arch/arm/dts/exynos54xx-pinctrl-uboot.dtsi new file +52 -0

52 lines not on this page · raw message

arch/arm/dts/exynos54xx-pinctrl.dtsi +2 -0
index b3e63d1..775d956 100644
@@ -12,6 +12,8 @@
  * published by the Free Software Foundation.
 */
 
+#include "exynos54xx-pinctrl-uboot.dtsi"
+
 / {
 	pinctrl at 13400000 {
 		gpy7: gpy7 {
arch/arm/dts/exynos54xx.dtsi +11 -0
index 1a765ab..22792e3 100644
@@ -6,6 +6,7 @@
  */
 
 #include "exynos5.dtsi"
+#include "exynos54xx-pinctrl.dtsi"
 
 / {
 	aliases {
@@ -132,6 +133,8 @@
 	};
 
 	pinctrl_0: pinctrl at 13400000 {
+		#address-cells = <1>;
+		#size-cells = <0>;
 		compatible = "samsung,exynos5420-pinctrl";
 		reg = <0x13400000 0x1000>;
 		interrupts = <0 45 0>;
@@ -144,24 +147,32 @@
 	};
 
 	pinctrl_1: pinctrl at 13410000 {
+		#address-cells = <1>;
+		#size-cells = <0>;
 		compatible = "samsung,exynos5420-pinctrl";
 		reg = <0x13410000 0x1000>;
 		interrupts = <0 78 0>;
 	};
 
 	pinctrl_2: pinctrl at 14000000 {
+		#address-cells = <1>;
+		#size-cells = <0>;
 		compatible = "samsung,exynos5420-pinctrl";
 		reg = <0x14000000 0x1000>;
 		interrupts = <0 46 0>;
 	};
 
 	pinctrl_3: pinctrl at 14010000 {
+		#address-cells = <1>;
+		#size-cells = <0>;
 		compatible = "samsung,exynos5420-pinctrl";
 		reg = <0x14010000 0x1000>;
 		interrupts = <0 50 0>;
 	};
 
 	pinctrl_4: pinctrl at 03860000 {
+		#address-cells = <1>;
+		#size-cells = <0>;
 		compatible = "samsung,exynos5420-pinctrl";
 		reg = <0x03860000 0x1000>;
 		interrupts = <0 47 0>;
Signature · 1 line
2.0.0.526.g5318336
#12 lore raw

PATCH v6 8/12 exynos: Tidy up GPIO headers

In reply to Simon Glass

The wrong header is being included, thus requiring the code to re-declare the generic GPIO interface in each GPIO header.

Fix this.

---

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/arm/cpu/armv7/exynos/pinmux.c       | 2 +-
 arch/arm/include/asm/arch-exynos/gpio.h  | 5 -----
 arch/arm/include/asm/arch-s5pc1xx/gpio.h | 4 ----
 board/samsung/arndale/arndale.c          | 2 +-
 board/samsung/common/board.c             | 2 +-
 board/samsung/common/misc.c              | 1 -
 board/samsung/goni/goni.c                | 2 +-
 board/samsung/origen/origen.c            | 2 +-
 board/samsung/smdk5420/smdk5420.c        | 2 +-
 board/samsung/smdkc100/smdkc100.c        | 2 +-
 board/samsung/smdkv310/smdkv310.c        | 2 +-
 board/samsung/trats/trats.c              | 2 +-
 board/samsung/trats2/trats2.c            | 1 +
 board/samsung/universal_c210/universal.c | 1 -
 drivers/gpio/s5p_gpio.c                  | 3 +--
 15 files changed, 11 insertions(+), 22 deletions(-)
arch/arm/cpu/armv7/exynos/pinmux.c +1 -1
index 86a0c75..8cc4e9c 100644
@@ -7,7 +7,7 @@
 
 #include <common.h>
 #include <fdtdec.h>
-#include <asm/arch/gpio.h>
+#include <asm/gpio.h>
 #include <asm/arch/pinmux.h>
 #include <asm/arch/sromc.h>
 
arch/arm/include/asm/arch-exynos/gpio.h +0 -5
index 8fb5c23..ba169b9 100644
@@ -1504,12 +1504,7 @@ static const struct gpio_name_num_table exynos5420_gpio_table[] = {
 void gpio_cfg_pin(int gpio, int cfg);
 void gpio_set_pull(int gpio, int mode);
 void gpio_set_drv(int gpio, int mode);
-int gpio_direction_input(unsigned gpio);
-int gpio_direction_output(unsigned gpio, int value);
-int gpio_set_value(unsigned gpio, int value);
-int gpio_get_value(unsigned gpio);
 void gpio_set_rate(int gpio, int mode);
-struct s5p_gpio_bank *s5p_gpio_get_bank(unsigned gpio);
 int s5p_gpio_get_pin(unsigned gpio);
 #endif
 
arch/arm/include/asm/arch-s5pc1xx/gpio.h +0 -4
index d5dbc22..bd6f2d2 100644
@@ -815,11 +815,7 @@ static const struct gpio_name_num_table s5pc110_gpio_table[] = {
 void gpio_cfg_pin(int gpio, int cfg);
 void gpio_set_pull(int gpio, int mode);
 void gpio_set_drv(int gpio, int mode);
-int gpio_direction_output(unsigned gpio, int value);
-int gpio_set_value(unsigned gpio, int value);
-int gpio_get_value(unsigned gpio);
 void gpio_set_rate(int gpio, int mode);
-struct s5p_gpio_bank *s5p_gpio_get_bank(unsigned gpio);
 int s5p_gpio_get_pin(unsigned gpio);
 
 /* GPIO pins per bank  */
board/samsung/arndale/arndale.c +1 -1
index ef88314..c0f00cf 100644
@@ -6,9 +6,9 @@
 
 #include <common.h>
 #include <usb.h>
+#include <asm/gpio.h>
 #include <asm/arch/pinmux.h>
 #include <asm/arch/dwmmc.h>
-#include <asm/arch/gpio.h>
 #include <asm/arch/power.h>
 
 DECLARE_GLOBAL_DATA_PTR;
board/samsung/common/board.c +1 -1
index 1f6f0a0..82595d1 100644
@@ -13,10 +13,10 @@
 #include <tmu.h>
 #include <netdev.h>
 #include <asm/io.h>
+#include <asm/gpio.h>
 #include <asm/arch/board.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/dwmmc.h>
-#include <asm/arch/gpio.h>
 #include <asm/arch/mmc.h>
 #include <asm/arch/pinmux.h>
 #include <asm/arch/power.h>
board/samsung/common/misc.c +0 -1
index 03106fd..a79119a 100644
@@ -13,7 +13,6 @@
 #include <version.h>
 #include <linux/sizes.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/gpio.h>
 #include <asm/gpio.h>
 #include <linux/input.h>
 #include <power/pmic.h>
board/samsung/goni/goni.c +1 -1
index eb0f9bf..01be714 100644
@@ -7,7 +7,7 @@
  */
 
 #include <common.h>
-#include <asm/arch/gpio.h>
+#include <asm/gpio.h>
 #include <asm/arch/mmc.h>
 #include <power/pmic.h>
 #include <usb/s3c_udc.h>
board/samsung/origen/origen.c +1 -1
index a539267..99a2fac 100644
@@ -6,8 +6,8 @@
 
 #include <common.h>
 #include <asm/io.h>
+#include <asm/gpio.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/gpio.h>
 #include <asm/arch/mmc.h>
 #include <asm/arch/periph.h>
 #include <asm/arch/pinmux.h>
board/samsung/smdk5420/smdk5420.c +1 -1
index 270ee83..47998ab 100644
@@ -11,9 +11,9 @@
 #include <lcd.h>
 #include <spi.h>
 #include <errno.h>
+#include <asm/gpio.h>
 #include <asm/arch/board.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/gpio.h>
 #include <asm/arch/pinmux.h>
 #include <asm/arch/system.h>
 #include <asm/arch/dp_info.h>
board/samsung/smdkc100/smdkc100.c +1 -1
index e009564..66b6a98 100644
@@ -7,9 +7,9 @@
  */
 
 #include <common.h>
+#include <asm/gpio.h>
 #include <asm/io.h>
 #include <asm/arch/sromc.h>
-#include <asm/arch/gpio.h>
 #include <netdev.h>
 
 DECLARE_GLOBAL_DATA_PTR;
board/samsung/smdkv310/smdkv310.c +1 -1
index 8eca358..cb7f9b0 100644
@@ -5,10 +5,10 @@
  */
 
 #include <common.h>
+#include <asm/gpio.h>
 #include <asm/io.h>
 #include <netdev.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/gpio.h>
 #include <asm/arch/mmc.h>
 #include <asm/arch/periph.h>
 #include <asm/arch/pinmux.h>
board/samsung/trats/trats.c +1 -1
index 3dd340b..9e76b5d 100644
@@ -10,8 +10,8 @@
 #include <common.h>
 #include <lcd.h>
 #include <asm/io.h>
+#include <asm/gpio.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/gpio.h>
 #include <asm/arch/pinmux.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/mipi_dsim.h>
board/samsung/trats2/trats2.c +1 -0
index fa26e61..2924ee6 100644
@@ -8,6 +8,7 @@
 
 #include <common.h>
 #include <lcd.h>
+#include <asm/gpio.h>
 #include <asm/arch/pinmux.h>
 #include <asm/arch/power.h>
 #include <asm/arch/mipi_dsim.h>
board/samsung/universal_c210/universal.c +0 -1
index 47e7f53..f9d3325 100644
@@ -12,7 +12,6 @@
 #include <asm/io.h>
 #include <asm/gpio.h>
 #include <asm/arch/adc.h>
-#include <asm/arch/gpio.h>
 #include <asm/arch/pinmux.h>
 #include <asm/arch/watchdog.h>
 #include <ld9040.h>
drivers/gpio/s5p_gpio.c +1 -2
index db7b673..aa60188 100644
@@ -8,7 +8,6 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/gpio.h>
-#include <asm/arch/gpio.h>
 
 #define S5P_GPIO_GET_PIN(x)	(x % GPIO_PER_BANK)
 
@@ -222,7 +221,7 @@ static void s5p_gpio_set_rate(struct s5p_gpio_bank *bank, int gpio, int mode)
 	writel(value, &bank->drv);
 }
 
-struct s5p_gpio_bank *s5p_gpio_get_bank(unsigned int gpio)
+static struct s5p_gpio_bank *s5p_gpio_get_bank(unsigned int gpio)
 {
 	const struct gpio_info *data;
 	unsigned int upto;
Signature · 1 line
2.0.0.526.g5318336
#13 lore raw

PATCH v6 9/12 exynos: Tidy up GPIO defines

In reply to Simon Glass

The defines at the top of the GPIO driver use single-character names for parameters which are not very descriptive.

Improve these to use descriptive parameter names.

---

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/gpio/s5p_gpio.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/gpio/s5p_gpio.c +11 -10
index aa60188..99f2dd8 100644
@@ -11,19 +11,20 @@
 
 #define S5P_GPIO_GET_PIN(x)	(x % GPIO_PER_BANK)
 
-#define CON_MASK(x)		(0xf << ((x) << 2))
-#define CON_SFR(x, v)		((v) << ((x) << 2))
+#define CON_MASK(val)			(0xf << ((val) << 2))
+#define CON_SFR(gpio, cfg)		((cfg) << ((gpio) << 2))
+#define CON_SFR_UNSHIFT(val, gpio)	((val) >> ((gpio) << 2))
 
-#define DAT_MASK(x)		(0x1 << (x))
-#define DAT_SET(x)		(0x1 << (x))
+#define DAT_MASK(gpio)			(0x1 << (gpio))
+#define DAT_SET(gpio)			(0x1 << (gpio))
 
-#define PULL_MASK(x)		(0x3 << ((x) << 1))
-#define PULL_MODE(x, v)		((v) << ((x) << 1))
+#define PULL_MASK(gpio)		(0x3 << ((gpio) << 1))
+#define PULL_MODE(gpio, pull)		((pull) << ((gpio) << 1))
 
-#define DRV_MASK(x)		(0x3 << ((x) << 1))
-#define DRV_SET(x, m)		((m) << ((x) << 1))
-#define RATE_MASK(x)		(0x1 << (x + 16))
-#define RATE_SET(x)		(0x1 << (x + 16))
+#define DRV_MASK(gpio)			(0x3 << ((gpio) << 1))
+#define DRV_SET(gpio, mode)		((mode) << ((gpio) << 1))
+#define RATE_MASK(gpio)		(0x1 << (gpio + 16))
+#define RATE_SET(gpio)			(0x1 << (gpio + 16))
 
 #define name_to_gpio(n) s5p_name_to_gpio(n)
 static inline int s5p_name_to_gpio(const char *name)
Signature · 1 line
2.0.0.526.g5318336
#14 lore raw

PATCH v6 10/12 exynos: Make sure that GPIOs are requested

In reply to Simon Glass

With driver model GPIOs must be requested before use. Make sure this is done correctly.

(Note that the soft SPI part of universal is omitted, since this driver is about to be replaced with a driver-model-aware version)

---

Changes in v6: None
Changes in v5:
- Add additional gpio_request() calls for other samsung boards
- Use a mask instead of division in gpio_request() naming call

Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/arm/cpu/armv7/exynos/pinmux.c       |  3 +++
 board/samsung/arndale/arndale.c          |  2 ++
 board/samsung/common/misc.c              |  2 ++
 board/samsung/goni/goni.c                |  2 ++
 board/samsung/smdk5250/exynos5-dt.c      |  7 +++++++
 board/samsung/smdk5420/smdk5420.c        |  4 ++++
 board/samsung/trats/trats.c              | 15 ++++++++++++---
 board/samsung/trats2/trats2.c            | 26 +++++++++++++++++++++-----
 board/samsung/universal_c210/universal.c |  3 +++
 drivers/mmc/s5p_sdhci.c                  |  7 ++++++-
 10 files changed, 62 insertions(+), 9 deletions(-)
arch/arm/cpu/armv7/exynos/pinmux.c +3 -0
index 8cc4e9c..fb1375d 100644
@@ -172,6 +172,9 @@ static int exynos5420_mmc_config(int peripheral, int flags)
 		 * this same assumption.
 		 */
 		if ((peripheral == PERIPH_ID_SDMMC0) && (i == (start + 2))) {
+#ifndef CONFIG_SPL_BUILD
+			gpio_request(i, "sdmmc0_vdden");
+#endif
 			gpio_set_value(i, 1);
 			gpio_cfg_pin(i, S5P_GPIO_OUTPUT);
 		} else {
board/samsung/arndale/arndale.c +2 -0
index c0f00cf..9ce2fca 100644
@@ -19,6 +19,8 @@ int board_usb_init(int index, enum usb_init_type init)
 	/* Configure gpios for usb 3503 hub:
 	 * disconnect, toggle reset and connect
 	 */
+	gpio_request(EXYNOS5_GPIO_D17, "usb_connect");
+	gpio_request(EXYNOS5_GPIO_X35, "usb_reset");
 	gpio_direction_output(EXYNOS5_GPIO_D17, 0);
 	gpio_direction_output(EXYNOS5_GPIO_X35, 0);
 
board/samsung/common/misc.c +2 -0
index a79119a..d274eb6 100644
@@ -362,6 +362,8 @@ void check_boot_mode(void)
 void keys_init(void)
 {
 	/* Set direction to input */
+	gpio_request(KEY_VOL_UP_GPIO, "volume-up");
+	gpio_request(KEY_VOL_DOWN_GPIO, "volume-down");
 	gpio_direction_input(KEY_VOL_UP_GPIO);
 	gpio_direction_input(KEY_VOL_DOWN_GPIO);
 }
board/samsung/goni/goni.c +2 -0
index 01be714..22f4995 100644
@@ -80,6 +80,7 @@ int board_mmc_init(bd_t *bis)
 	int i, ret, ret_sd = 0;
 
 	/* MASSMEMORY_EN: XMSMDATA7: GPJ2[7] output high */
+	gpio_request(S5PC110_GPIO_J27, "massmemory_en");
 	gpio_direction_output(S5PC110_GPIO_J27, 1);
 
 	/*
@@ -108,6 +109,7 @@ int board_mmc_init(bd_t *bis)
 	 * SD card (T_FLASH) detect and init
 	 * T_FLASH_DETECT: EINT28: GPH3[4] input mode
 	 */
+	gpio_request(S5PC110_GPIO_H34, "t_flash_detect");
 	gpio_cfg_pin(S5PC110_GPIO_H34, S5P_GPIO_INPUT);
 	gpio_set_pull(S5PC110_GPIO_H34, S5P_GPIO_PULL_UP);
 
board/samsung/smdk5250/exynos5-dt.c +7 -0
index d6ce133..53ff706 100644
@@ -29,6 +29,7 @@ DECLARE_GLOBAL_DATA_PTR;
 static void board_enable_audio_codec(void)
 {
 	/* Enable MAX98095 Codec */
+	gpio_request(EXYNOS5_GPIO_X17, "max98095_enable");
 	gpio_direction_output(EXYNOS5_GPIO_X17, 1);
 	gpio_set_pull(EXYNOS5_GPIO_X17, S5P_GPIO_PULL_NONE);
 }
@@ -199,16 +200,19 @@ static int board_dp_bridge_setup(void)
 	/* Setup the GPIOs */
 
 	/* PD is ACTIVE_LOW, and initially de-asserted */
+	gpio_request(EXYNOS5_GPIO_Y25, "dp_bridge_pd");
 	gpio_set_pull(EXYNOS5_GPIO_Y25, S5P_GPIO_PULL_NONE);
 	gpio_direction_output(EXYNOS5_GPIO_Y25, 1);
 
 	/* Reset is ACTIVE_LOW */
+	gpio_request(EXYNOS5_GPIO_X15, "dp_bridge_reset");
 	gpio_set_pull(EXYNOS5_GPIO_X15, S5P_GPIO_PULL_NONE);
 	gpio_direction_output(EXYNOS5_GPIO_X15, 0);
 
 	udelay(10);
 	gpio_set_value(EXYNOS5_GPIO_X15, 1);
 
+	gpio_request(EXYNOS5_GPIO_X07, "dp_bridge_hpd");
 	gpio_direction_input(EXYNOS5_GPIO_X07);
 
 	/*
@@ -236,10 +240,12 @@ static int board_dp_bridge_setup(void)
 void exynos_cfg_lcd_gpio(void)
 {
 	/* For Backlight */
+	gpio_request(EXYNOS5_GPIO_B20, "lcd_backlight");
 	gpio_cfg_pin(EXYNOS5_GPIO_B20, S5P_GPIO_OUTPUT);
 	gpio_set_value(EXYNOS5_GPIO_B20, 1);
 
 	/* LCD power on */
+	gpio_request(EXYNOS5_GPIO_X15, "lcd_power");
 	gpio_cfg_pin(EXYNOS5_GPIO_X15, S5P_GPIO_OUTPUT);
 	gpio_set_value(EXYNOS5_GPIO_X15, 1);
 
@@ -276,6 +282,7 @@ void exynos_backlight_on(unsigned int on)
 	mdelay(10);
 
 	/* board_dp_backlight_en */
+	gpio_request(EXYNOS5_GPIO_X30, "board_dp_backlight_en");
 	gpio_direction_output(EXYNOS5_GPIO_X30, 1);
 #endif
 }
board/samsung/smdk5420/smdk5420.c +4 -0
index 47998ab..a691222 100644
@@ -74,9 +74,12 @@ void exynos_lcd_power_on(void)
 	mdelay(5);
 
 	/* TODO(ajaykumar.rs at samsung.com): Use device tree */
+	gpio_request(EXYNOS5420_GPIO_X35, "edp_slp#");
 	gpio_direction_output(EXYNOS5420_GPIO_X35, 1);	/* EDP_SLP# */
 	mdelay(10);
+	gpio_request(EXYNOS5420_GPIO_Y77, "edp_rst#");
 	gpio_direction_output(EXYNOS5420_GPIO_Y77, 1);	/* EDP_RST# */
+	gpio_request(EXYNOS5420_GPIO_X26, "edp_hpd");
 	gpio_direction_input(EXYNOS5420_GPIO_X26);	/* EDP_HPD */
 	gpio_set_pull(EXYNOS5420_GPIO_X26, S5P_GPIO_PULL_NONE);
 
@@ -88,6 +91,7 @@ void exynos_lcd_power_on(void)
 void exynos_backlight_on(unsigned int onoff)
 {
 	/* For PWM */
+	gpio_request(EXYNOS5420_GPIO_B20, "backlight_on");
 	gpio_cfg_pin(EXYNOS5420_GPIO_B20, S5P_GPIO_FUNC(0x1));
 	gpio_set_value(EXYNOS5420_GPIO_B20, 1);
 
board/samsung/trats/trats.c +12 -3
index 9e76b5d..e163e45 100644
@@ -63,6 +63,8 @@ void i2c_init_board(void)
 	}
 
 	/* I2C_8 -> FG */
+	gpio_request(EXYNOS4_GPIO_Y40, "i2c_clk");
+	gpio_request(EXYNOS4_GPIO_Y41, "i2c_data");
 	gpio_direction_output(EXYNOS4_GPIO_Y40, 1);
 	gpio_direction_output(EXYNOS4_GPIO_Y41, 1);
 }
@@ -346,12 +348,17 @@ int exynos_power_init(void)
 static unsigned int get_hw_revision(void)
 {
 	int hwrev = 0;
+	char str[10];
 	int i;
 
 	/* hw_rev[3:0] == GPE1[3:0] */
-	for (i = EXYNOS4_GPIO_E10; i < EXYNOS4_GPIO_E14; i++) {
-		gpio_cfg_pin(i, S5P_GPIO_INPUT);
-		gpio_set_pull(i, S5P_GPIO_PULL_NONE);
+	for (i = 0; i < 4; i++) {
+		int pin = i + EXYNOS4_GPIO_E10;
+
+		sprintf(str, "hw_rev%d", i);
+		gpio_request(pin, str);
+		gpio_cfg_pin(pin, S5P_GPIO_INPUT);
+		gpio_set_pull(pin, S5P_GPIO_PULL_NONE);
 	}
 
 	udelay(1);
@@ -517,6 +524,7 @@ static void board_power_init(void)
 static void exynos_uart_init(void)
 {
 	/* UART_SEL GPY4[7] (part2)@EXYNOS4 */
+	gpio_request(EXYNOS4_GPIO_Y47, "uart_sel");
 	gpio_set_pull(EXYNOS4_GPIO_Y47, S5P_GPIO_PULL_UP);
 	gpio_direction_output(EXYNOS4_GPIO_Y47, 1);
 }
@@ -534,6 +542,7 @@ int exynos_early_init_f(void)
 
 void exynos_reset_lcd(void)
 {
+	gpio_request(EXYNOS4_GPIO_Y45, "lcd_reset");
 	gpio_direction_output(EXYNOS4_GPIO_Y45, 1);
 	udelay(10000);
 	gpio_direction_output(EXYNOS4_GPIO_Y45, 0);
board/samsung/trats2/trats2.c +21 -5
index 2924ee6..a737749 100644
@@ -33,6 +33,7 @@ static inline u32 get_model_rev(void);
 static void check_hw_revision(void)
 {
 	int modelrev = 0;
+	char str[12];
 	int i;
 
 	/*
@@ -41,13 +42,22 @@ static void check_hw_revision(void)
 	 * TRM say that it may cause unexcepted state and leakage current.
 	 * and pull-none is only for output function.
 	 */
-	for (i = EXYNOS4X12_GPIO_M10; i < EXYNOS4X12_GPIO_M12; i++)
-		gpio_cfg_pin(i, S5P_GPIO_INPUT);
+	for (i = 0; i < 2; i++) {
+		int pin = i + EXYNOS4X12_GPIO_M10;
+
+		sprintf(str, "model_rev%d", i);
+		gpio_request(pin, str);
+		gpio_cfg_pin(pin, S5P_GPIO_INPUT);
+	}
 
 	/* GPM1[5:2]: HW_REV[3:0] */
-	for (i = EXYNOS4X12_GPIO_M12; i < EXYNOS4X12_GPIO_M16; i++) {
-		gpio_cfg_pin(i, S5P_GPIO_INPUT);
-		gpio_set_pull(i, S5P_GPIO_PULL_NONE);
+	for (i = 0; i < 4; i++) {
+		int pin = i + EXYNOS4X12_GPIO_M12;
+
+		sprintf(str, "hw_rev%d", i);
+		gpio_request(pin, str);
+		gpio_cfg_pin(pin, S5P_GPIO_INPUT);
+		gpio_set_pull(pin, S5P_GPIO_PULL_NONE);
 	}
 
 	/* GPM1[1:0]: MODEL_REV[1:0] */
@@ -103,10 +113,14 @@ static void board_init_i2c(void)
 	}
 
 	/* I2C_8 */
+	gpio_request(EXYNOS4X12_GPIO_F14, "i2c8_clk");
+	gpio_request(EXYNOS4X12_GPIO_F15, "i2c8_data");
 	gpio_direction_output(EXYNOS4X12_GPIO_F14, 1);
 	gpio_direction_output(EXYNOS4X12_GPIO_F15, 1);
 
 	/* I2C_9 */
+	gpio_request(EXYNOS4X12_GPIO_M21, "i2c9_clk");
+	gpio_request(EXYNOS4X12_GPIO_M20, "i2c9_data");
 	gpio_direction_output(EXYNOS4X12_GPIO_M21, 1);
 	gpio_direction_output(EXYNOS4X12_GPIO_M20, 1);
 }
@@ -388,6 +402,7 @@ void exynos_lcd_power_on(void)
 	struct pmic *p = pmic_get("MAX77686_PMIC");
 
 	/* LCD_2.2V_EN: GPC0[1] */
+	gpio_request(EXYNOS4X12_GPIO_C01, "lcd_2v2_en");
 	gpio_set_pull(EXYNOS4X12_GPIO_C01, S5P_GPIO_PULL_UP);
 	gpio_direction_output(EXYNOS4X12_GPIO_C01, 1);
 
@@ -400,6 +415,7 @@ void exynos_lcd_power_on(void)
 void exynos_reset_lcd(void)
 {
 	/* reset lcd */
+	gpio_request(EXYNOS4X12_GPIO_F21, "lcd_reset");
 	gpio_direction_output(EXYNOS4X12_GPIO_F21, 0);
 	udelay(10);
 	gpio_set_value(EXYNOS4X12_GPIO_F21, 1);
board/samsung/universal_c210/universal.c +3 -0
index f9d3325..c04f48c 100644
@@ -330,6 +330,7 @@ void exynos_cfg_lcd_gpio(void)
 	}
 
 	/* gpio pad configuration for LCD reset. */
+	gpio_request(EXYNOS4_GPIO_Y45, "lcd_reset");
 	gpio_cfg_pin(EXYNOS4_GPIO_Y45, S5P_GPIO_OUTPUT);
 
 	spi_init();
@@ -386,6 +387,7 @@ int exynos_init(void)
 		 * you should set it HIGH since it removes the inverter
 		 */
 		/* MASSMEMORY_EN: XMDMDATA_6: GPE3[6] */
+		gpio_request(EXYNOS4_GPIO_E36, "ldo_en");
 		gpio_direction_output(EXYNOS4_GPIO_E36, 0);
 		break;
 	default:
@@ -394,6 +396,7 @@ int exynos_init(void)
 		 * But set it as HIGH to ensure
 		 */
 		/* MASSMEMORY_EN: XMDMADDR_3: GPE1[3] */
+		gpio_request(EXYNOS4_GPIO_E13, "massmemory_en");
 		gpio_direction_output(EXYNOS4_GPIO_E13, 1);
 		break;
 	}
drivers/mmc/s5p_sdhci.c +6 -1
index 637dd97..0dea45d 100644
@@ -102,6 +102,7 @@ struct sdhci_host sdhci_host[SDHCI_MAX_HOSTS];
 
 static int do_sdhci_init(struct sdhci_host *host)
 {
+	char str[20];
 	int dev_id, flag;
 	int err = 0;
 
@@ -109,6 +110,8 @@ static int do_sdhci_init(struct sdhci_host *host)
 	dev_id = host->index + PERIPH_ID_SDMMC0;
 
 	if (fdt_gpio_isvalid(&host->pwr_gpio)) {
+		sprintf(str, "sdhci%d_power", host->index & 0xf);
+		gpio_request(host->pwr_gpio.gpio, str);
 		gpio_direction_output(host->pwr_gpio.gpio, 1);
 		err = exynos_pinmux_config(dev_id, flag);
 		if (err) {
@@ -118,7 +121,9 @@ static int do_sdhci_init(struct sdhci_host *host)
 	}
 
 	if (fdt_gpio_isvalid(&host->cd_gpio)) {
-		gpio_direction_output(host->cd_gpio.gpio, 0xf);
+		sprintf(str, "sdhci%d_cd", host->index & 0xf);
+		gpio_request(host->cd_gpio.gpio, str);
+		gpio_direction_output(host->cd_gpio.gpio, 1);
 		if (gpio_get_value(host->cd_gpio.gpio))
 			return -ENODEV;
 
Signature · 1 line
2.0.0.526.g5318336
#15 lore raw

PATCH v6 11/12 exynos: gpio: Convert to driver model

In reply to Simon Glass

Convert the exynos GPIO driver to driver model. This implements the generic GPIO interface but not the extra Exynos-specific functions.

---

Changes in v6: None
Changes in v5:
- Avoid reordering functions

Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/gpio/s5p_gpio.c         | 422 +++++++++++++++++++++++++++-------------
 include/configs/exynos-common.h |   4 +
 2 files changed, 290 insertions(+), 136 deletions(-)
drivers/gpio/s5p_gpio.c +286 -136
index 99f2dd8..38ef14d 100644
@@ -6,8 +6,15 @@
  */
 
 #include <common.h>
+#include <dm.h>
+#include <errno.h>
+#include <fdtdec.h>
+#include <malloc.h>
 #include <asm/io.h>
 #include <asm/gpio.h>
+#include <dm/device-internal.h>
+
+DECLARE_GLOBAL_DATA_PTR;
 
 #define S5P_GPIO_GET_PIN(x)	(x % GPIO_PER_BANK)
 
@@ -26,100 +33,45 @@
 #define RATE_MASK(gpio)		(0x1 << (gpio + 16))
 #define RATE_SET(gpio)			(0x1 << (gpio + 16))
 
-#define name_to_gpio(n) s5p_name_to_gpio(n)
-static inline int s5p_name_to_gpio(const char *name)
+#define GPIO_NAME_SIZE			20
+
+/* Platform data for each bank */
+struct exynos_gpio_platdata {
+	struct s5p_gpio_bank *bank;
+	const char *bank_name;	/* Name of port, e.g. 'gpa0" */
+};
+
+/* Information about each bank@run-time */
+struct exynos_bank_info {
+	char label[GPIO_PER_BANK][GPIO_NAME_SIZE];
+	struct s5p_gpio_bank *bank;
+};
+
+static struct s5p_gpio_bank *s5p_gpio_get_bank(unsigned int gpio)
 {
-	unsigned num, irregular_set_number, irregular_bank_base;
-	const struct gpio_name_num_table *tabp;
-	char this_bank, bank_name, irregular_bank_name;
-	char *endp;
-
-	/*
-	 * The gpio name starts with either 'g' or 'gp' followed by the bank
-	 * name character. Skip one or two characters depending on the prefix.
-	 */
-	if (name[0] == 'g' && name[1] == 'p')
-		name += 2;
-	else if (name[0] == 'g')
-		name++;
-	else
-		return -1; /* Name must start with 'g' */
-
-	bank_name = *name++;
-	if (!*name)
-		return -1; /* At least one digit is required/expected. */
-
-	/*
-	 * On both exynos5 and exynos5420 architectures there is a bank of
-	 * GPIOs which does not fall into the regular address pattern. Those
-	 * banks are c4 on Exynos5 and y7 on Exynos5420. The rest of the below
-	 * assignments help to handle these irregularities.
-	 */
-#if defined(CONFIG_EXYNOS4) || defined(CONFIG_EXYNOS5)
-	if (cpu_is_exynos5()) {
-		if (proid_is_exynos5420()) {
-			tabp = exynos5420_gpio_table;
-			irregular_bank_name = 'y';
-			irregular_set_number = '7';
-			irregular_bank_base = EXYNOS5420_GPIO_Y70;
-		} else {
-			tabp = exynos5_gpio_table;
-			irregular_bank_name = 'c';
-			irregular_set_number = '4';
-			irregular_bank_base = EXYNOS5_GPIO_C40;
-		}
-	} else {
-		if (proid_is_exynos4412())
-			tabp = exynos4x12_gpio_table;
-		else
-			tabp = exynos4_gpio_table;
-		irregular_bank_name = 0;
-		irregular_set_number = 0;
-		irregular_bank_base = 0;
-	}
-#else
-	if (cpu_is_s5pc110())
-		tabp = s5pc110_gpio_table;
-	else
-		tabp = s5pc100_gpio_table;
-	irregular_bank_name = 0;
-	irregular_set_number = 0;
-	irregular_bank_base = 0;
-#endif
+	const struct gpio_info *data;
+	unsigned int upto;
+	int i, count;
 
-	this_bank = tabp->bank;
-	do {
-		if (bank_name == this_bank) {
-			unsigned pin_index; /* pin number within the bank */
-			if ((bank_name == irregular_bank_name) &&
-			    (name[0] == irregular_set_number)) {
-				pin_index = name[1] - '0';
-				/* Irregular sets have 8 pins. */
-				if (pin_index >= GPIO_PER_BANK)
-					return -1;
-				num = irregular_bank_base + pin_index;
-			} else {
-				pin_index = simple_strtoul(name, &endp, 8);
-				pin_index -= tabp->bank_offset;
-				/*
-				 * Sanity check: bunk 'z' has no set number,
-				 * for all other banks there must be exactly
-				 * two octal digits, and the resulting number
-				 * should not exceed the number of pins in the
-				 * bank.
-				 */
-				if (((bank_name != 'z') && !name[1]) ||
-				    *endp ||
-				    (pin_index >= tabp->bank_size))
-					return -1;
-				num = tabp->base + pin_index;
-			}
-			return num;
+	data = get_gpio_data();
+	count = get_bank_num();
+	upto = 0;
+
+	for (i = 0; i < count; i++) {
+		debug("i=%d, upto=%d\n", i, upto);
+		if (gpio < data->max_gpio) {
+			struct s5p_gpio_bank *bank;
+			bank = (struct s5p_gpio_bank *)data->reg_addr;
+			bank += (gpio - upto) / GPIO_PER_BANK;
+			debug("gpio=%d, bank=%p\n", gpio, bank);
+			return bank;
 		}
-		this_bank = (++tabp)->bank;
-	} while (this_bank);
 
-	return -1;
+		upto = data->max_gpio;
+		data++;
+	}
+
+	return NULL;
 }
 
 static void s5p_gpio_cfg_pin(struct s5p_gpio_bank *bank, int gpio, int cfg)
@@ -143,16 +95,23 @@ static void s5p_gpio_set_value(struct s5p_gpio_bank *bank, int gpio, int en)
 	writel(value, &bank->dat);
 }
 
-static void s5p_gpio_direction_output(struct s5p_gpio_bank *bank,
-				      int gpio, int en)
+#ifdef CONFIG_SPL_BUILD
+/* Common GPIO API - SPL does not support driver model yet */
+int gpio_set_value(unsigned gpio, int value)
 {
-	s5p_gpio_cfg_pin(bank, gpio, S5P_GPIO_OUTPUT);
-	s5p_gpio_set_value(bank, gpio, en);
-}
+	s5p_gpio_set_value(s5p_gpio_get_bank(gpio),
+			   s5p_gpio_get_pin(gpio), value);
 
-static void s5p_gpio_direction_input(struct s5p_gpio_bank *bank, int gpio)
+	return 0;
+}
+#else
+static int s5p_gpio_get_cfg_pin(struct s5p_gpio_bank *bank, int gpio)
 {
-	s5p_gpio_cfg_pin(bank, gpio, S5P_GPIO_INPUT);
+	unsigned int value;
+
+	value = readl(&bank->con);
+	value &= CON_MASK(gpio);
+	return CON_SFR_UNSHIFT(value, gpio);
 }
 
 static unsigned int s5p_gpio_get_value(struct s5p_gpio_bank *bank, int gpio)
@@ -162,6 +121,7 @@ static unsigned int s5p_gpio_get_value(struct s5p_gpio_bank *bank, int gpio)
 	value = readl(&bank->dat);
 	return !!(value & DAT_MASK(gpio));
 }
+#endif /* CONFIG_SPL_BUILD */
 
 static void s5p_gpio_set_pull(struct s5p_gpio_bank *bank, int gpio, int mode)
 {
@@ -222,78 +182,156 @@ static void s5p_gpio_set_rate(struct s5p_gpio_bank *bank, int gpio, int mode)
 	writel(value, &bank->drv);
 }
 
-static struct s5p_gpio_bank *s5p_gpio_get_bank(unsigned int gpio)
+int s5p_gpio_get_pin(unsigned gpio)
 {
-	const struct gpio_info *data;
-	unsigned int upto;
-	int i, count;
+	return S5P_GPIO_GET_PIN(gpio);
+}
 
-	data = get_gpio_data();
-	count = get_bank_num();
-	upto = 0;
+/* Driver model interface */
+#ifndef CONFIG_SPL_BUILD
+static int exynos_gpio_get_state(struct udevice *dev, unsigned int offset,
+				char *buf, int bufsize)
+{
+	struct gpio_dev_priv *uc_priv = dev->uclass_priv;
+	struct exynos_bank_info *state = dev_get_priv(dev);
+	const char *label;
+	bool is_output;
+	int size;
+	int cfg;
+
+	label = state->label[offset];
+	cfg = s5p_gpio_get_cfg_pin(state->bank, offset);
+	is_output = cfg == S5P_GPIO_OUTPUT;
+	size = snprintf(buf, bufsize, "%s%d: ",
+			uc_priv->bank_name ? uc_priv->bank_name : "", offset);
+	buf += size;
+	bufsize -= size;
+	if (is_output || cfg == S5P_GPIO_INPUT) {
+		snprintf(buf, bufsize, "%s: %d [%c]%s%s",
+			 is_output ? "out" : " in",
+			 s5p_gpio_get_value(state->bank, offset),
+			 *label ? 'x' : ' ',
+			 *label ? " " : "",
+			 label);
+	} else {
+		snprintf(buf, bufsize, "sfpio");
+	}
 
-	for (i = 0; i < count; i++) {
-		debug("i=%d, upto=%d\n", i, upto);
-		if (gpio < data->max_gpio) {
-			struct s5p_gpio_bank *bank;
-			bank = (struct s5p_gpio_bank *)data->reg_addr;
-			bank += (gpio - upto) / GPIO_PER_BANK;
-			debug("gpio=%d, bank=%p\n", gpio, bank);
-			return bank;
-		}
+	return 0;
+}
 
-		upto = data->max_gpio;
-		data++;
+static int check_reserved(struct udevice *dev, unsigned offset,
+			  const char *func)
+{
+	struct exynos_bank_info *state = dev_get_priv(dev);
+	struct gpio_dev_priv *uc_priv = dev->uclass_priv;
+
+	if (!*state->label[offset]) {
+		printf("exynos_gpio: %s: error: gpio %s%d not reserved\n",
+		       func, uc_priv->bank_name, offset);
+		return -EPERM;
 	}
 
-	return NULL;
+	return 0;
 }
 
-int s5p_gpio_get_pin(unsigned gpio)
+/* set GPIO pin 'gpio' as an input */
+static int exynos_gpio_direction_input(struct udevice *dev, unsigned offset)
 {
-	return S5P_GPIO_GET_PIN(gpio);
-}
+	struct exynos_bank_info *state = dev_get_priv(dev);
+	int ret;
 
-/* Common GPIO API */
+	ret = check_reserved(dev, offset, __func__);
+	if (ret)
+		return ret;
+
+	/* Configure GPIO direction as input. */
+	s5p_gpio_cfg_pin(state->bank, offset, S5P_GPIO_INPUT);
 
-int gpio_request(unsigned gpio, const char *label)
-{
 	return 0;
 }
 
-int gpio_free(unsigned gpio)
+/* set GPIO pin 'gpio' as an output, with polarity 'value' */
+static int exynos_gpio_direction_output(struct udevice *dev, unsigned offset,
+				       int value)
 {
+	struct exynos_bank_info *state = dev_get_priv(dev);
+	int ret;
+
+	ret = check_reserved(dev, offset, __func__);
+	if (ret)
+		return ret;
+
+	/* Configure GPIO output value. */
+	s5p_gpio_set_value(state->bank, offset, value);
+
+	/* Configure GPIO direction as output. */
+	s5p_gpio_cfg_pin(state->bank, offset, S5P_GPIO_OUTPUT);
+
 	return 0;
 }
 
-int gpio_direction_input(unsigned gpio)
+/* read GPIO IN value of pin 'gpio' */
+static int exynos_gpio_get_value(struct udevice *dev, unsigned offset)
 {
-	s5p_gpio_direction_input(s5p_gpio_get_bank(gpio),
-				s5p_gpio_get_pin(gpio));
-	return 0;
+	struct exynos_bank_info *state = dev_get_priv(dev);
+	int ret;
+
+	ret = check_reserved(dev, offset, __func__);
+	if (ret)
+		return ret;
+
+	return s5p_gpio_get_value(state->bank, offset);
 }
 
-int gpio_direction_output(unsigned gpio, int value)
+/* write GPIO OUT value to pin 'gpio' */
+static int exynos_gpio_set_value(struct udevice *dev, unsigned offset,
+				 int value)
 {
-	s5p_gpio_direction_output(s5p_gpio_get_bank(gpio),
-				 s5p_gpio_get_pin(gpio), value);
+	struct exynos_bank_info *state = dev_get_priv(dev);
+	int ret;
+
+	ret = check_reserved(dev, offset, __func__);
+	if (ret)
+		return ret;
+
+	s5p_gpio_set_value(state->bank, offset, value);
+
 	return 0;
 }
 
-int gpio_get_value(unsigned gpio)
+static int exynos_gpio_request(struct udevice *dev, unsigned offset,
+			      const char *label)
 {
-	return (int) s5p_gpio_get_value(s5p_gpio_get_bank(gpio),
-				       s5p_gpio_get_pin(gpio));
+	struct exynos_bank_info *state = dev_get_priv(dev);
+
+	if (*state->label[offset])
+		return -EBUSY;
+
+	strncpy(state->label[offset], label, GPIO_NAME_SIZE);
+	state->label[offset][GPIO_NAME_SIZE - 1] = '\0';
+
+	return 0;
 }
 
-int gpio_set_value(unsigned gpio, int value)
+static int exynos_gpio_free(struct udevice *dev, unsigned offset)
 {
-	s5p_gpio_set_value(s5p_gpio_get_bank(gpio),
-			  s5p_gpio_get_pin(gpio), value);
+	struct exynos_bank_info *state = dev_get_priv(dev);
+	int ret;
+
+	ret = check_reserved(dev, offset, __func__);
+	if (ret)
+		return ret;
+	state->label[offset][0] = '\0';
 
 	return 0;
 }
+#endif /* nCONFIG_SPL_BUILD */
 
+/*
+ * There is no common GPIO API for pull, drv, pin, rate (yet). These
+ * functions are kept here to preserve function ordering for review.
+ */
 void gpio_set_pull(int gpio, int mode)
 {
 	s5p_gpio_set_pull(s5p_gpio_get_bank(gpio),
@@ -317,3 +355,115 @@ void gpio_set_rate(int gpio, int mode)
 	s5p_gpio_set_rate(s5p_gpio_get_bank(gpio),
 			  s5p_gpio_get_pin(gpio), mode);
 }
+
+#ifndef CONFIG_SPL_BUILD
+static int exynos_gpio_get_function(struct udevice *dev, unsigned offset)
+{
+	struct exynos_bank_info *state = dev_get_priv(dev);
+	int cfg;
+
+	if (!*state->label[offset])
+		return GPIOF_UNUSED;
+	cfg = s5p_gpio_get_cfg_pin(state->bank, offset);
+	if (cfg == S5P_GPIO_OUTPUT)
+		return GPIOF_OUTPUT;
+	else if (cfg == S5P_GPIO_INPUT)
+		return GPIOF_INPUT;
+	else
+		return GPIOF_FUNC;
+}
+
+static const struct dm_gpio_ops gpio_exynos_ops = {
+	.request		= exynos_gpio_request,
+	.free			= exynos_gpio_free,
+	.direction_input	= exynos_gpio_direction_input,
+	.direction_output	= exynos_gpio_direction_output,
+	.get_value		= exynos_gpio_get_value,
+	.set_value		= exynos_gpio_set_value,
+	.get_function		= exynos_gpio_get_function,
+	.get_state		= exynos_gpio_get_state,
+};
+
+static int gpio_exynos_probe(struct udevice *dev)
+{
+	struct gpio_dev_priv *uc_priv = dev->uclass_priv;
+	struct exynos_bank_info *priv = dev->priv;
+	struct exynos_gpio_platdata *plat = dev->platdata;
+
+	/* Only child devices have ports */
+	if (!plat)
+		return 0;
+
+	priv->bank = plat->bank;
+
+	uc_priv->gpio_count = GPIO_PER_BANK;
+	uc_priv->bank_name = plat->bank_name;
+
+	return 0;
+}
+
+/**
+ * We have a top-level GPIO device with no actual GPIOs. It has a child
+ * device for each Exynos GPIO bank.
+ */
+static int gpio_exynos_bind(struct udevice *parent)
+{
+	struct exynos_gpio_platdata *plat = parent->platdata;
+	struct s5p_gpio_bank *bank, *base;
+	const void *blob = gd->fdt_blob;
+	int node;
+
+	/* If this is a child device, there is nothing to do here */
+	if (plat)
+		return 0;
+
+	base = (struct s5p_gpio_bank *)fdtdec_get_addr(gd->fdt_blob,
+						   parent->of_offset, "reg");
+	for (node = fdt_first_subnode(blob, parent->of_offset), bank = base;
+	     node > 0;
+	     node = fdt_next_subnode(blob, node), bank++) {
+		struct exynos_gpio_platdata *plat;
+		struct udevice *dev;
+		fdt_addr_t reg;
+		int ret;
+
+		if (!fdtdec_get_bool(blob, node, "gpio-controller"))
+			continue;
+		plat = calloc(1, sizeof(*plat));
+		if (!plat)
+			return -ENOMEM;
+		reg = fdtdec_get_addr(blob, node, "reg");
+		if (reg != FDT_ADDR_T_NONE)
+			bank = (struct s5p_gpio_bank *)((ulong)base + reg);
+		plat->bank = bank;
+		plat->bank_name = fdt_get_name(blob, node, NULL);
+		debug("dev at %p: %s\n", bank, plat->bank_name);
+
+		ret = device_bind(parent, parent->driver,
+					plat->bank_name, plat, -1, &dev);
+		if (ret)
+			return ret;
+		dev->of_offset = parent->of_offset;
+	}
+
+	return 0;
+}
+
+static const struct udevice_id exynos_gpio_ids[] = {
+	{ .compatible = "samsung,exynos4210-pinctrl" },
+	{ .compatible = "samsung,exynos4x12-pinctrl" },
+	{ .compatible = "samsung,exynos5250-pinctrl" },
+	{ .compatible = "samsung,exynos5420-pinctrl" },
+	{ }
+};
+
+U_BOOT_DRIVER(gpio_exynos) = {
+	.name	= "gpio_exynos",
+	.id	= UCLASS_GPIO,
+	.of_match = exynos_gpio_ids,
+	.bind	= gpio_exynos_bind,
+	.probe = gpio_exynos_probe,
+	.priv_auto_alloc_size = sizeof(struct exynos_bank_info),
+	.ops	= &gpio_exynos_ops,
+};
+#endif
include/configs/exynos-common.h +4 -0
index 7be7d12..79dd9dc 100644
@@ -17,6 +17,10 @@
 #include <linux/sizes.h>
 
 #define CONFIG_SYS_GENERIC_BOARD
+#define CONFIG_DM
+#define CONFIG_CMD_DM
+#define CONFIG_DM_GPIO
+
 #define CONFIG_ARCH_CPU_INIT
 #define CONFIG_DISPLAY_CPUINFO
 #define CONFIG_DISPLAY_BOARDINFO
Signature · 1 line
2.0.0.526.g5318336
#16 lore raw

PATCH v6 12/12 dm: sandbox: dts: Add a GPIO bank

In reply to Simon Glass

Add a bank of GPIOs for sandbox which can be used for testing this functionality.

---

Changes in v6: None
Changes in v5:
- Remove RFC label now that build errors are fixed
- Tidy up and update cover letter message

Changes in v4:
- Add patches for exynos GPIO support

Changes in v3: None
Changes in v2: None

 arch/sandbox/dts/sandbox.dts | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/sandbox/dts/sandbox.dts +8 -0
index 62d8037..efffacb 100644
@@ -113,4 +113,12 @@
 			0x070b0067 0x070c0069>;
 	};
 
+	gpio_a: gpios {
+		gpio-controller;
+		compatible = "sandbox,gpio";
+		#gpio-cells = <1>;
+		gpio-bank-name = "a";
+		num-gpios = <20>;
+	};
+
 };
Signature · 1 line
2.0.0.526.g5318336