Skip to contentSkip to conversation

blackfin: make name_to_gpio be a weak symbol

PATCH In review Ian Campbell 2 participants 2 messages Mar 27, 2014 – Apr 18, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 blackfin: make name_to_gpio be a weak symbol

This required moving it into a C file from the header.

The only user of a non-default name_to_gpio is blackfin, therefore build tested with the blackfin bct-brettl2 build, which is one I picked at random. Also tested with a build for the ARM tec board which uses the default/fallback implementation. Inspection with objdump shows that both have done the right thing.

This change was requested by Marek during review of the sunxi patch series.

Cc Marek Vasut <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Sonic Zhang <[email protected]>
---
 arch/blackfin/cpu/gpio.c         | 48 +++++++++++++++++++++++++++++++++++++++
 arch/blackfin/include/asm/gpio.h | 49 ----------------------------------------
 common/cmd_gpio.c                |  7 +++---
 3 files changed, 52 insertions(+), 52 deletions(-)
arch/blackfin/cpu/gpio.c +48 -0
index 86da706..4b4cf93 100644
@@ -759,6 +759,54 @@ void bfin_reset_boot_spi_cs(unsigned short pin)
 	udelay(1);
 }
 
+int name_to_gpio(const char *name)
+{
+	int port_base;
+
+	if (tolower(*name) == 'p') {
+		++name;
+
+		switch (tolower(*name)) {
+#ifdef GPIO_PA0
+		case 'a': port_base = GPIO_PA0; break;
+#endif
+#ifdef GPIO_PB0
+		case 'b': port_base = GPIO_PB0; break;
+#endif
+#ifdef GPIO_PC0
+		case 'c': port_base = GPIO_PC0; break;
+#endif
+#ifdef GPIO_PD0
+		case 'd': port_base = GPIO_PD0; break;
+#endif
+#ifdef GPIO_PE0
+		case 'e': port_base = GPIO_PE0; break;
+#endif
+#ifdef GPIO_PF0
+		case 'f': port_base = GPIO_PF0; break;
+#endif
+#ifdef GPIO_PG0
+		case 'g': port_base = GPIO_PG0; break;
+#endif
+#ifdef GPIO_PH0
+		case 'h': port_base = GPIO_PH0; break;
+#endif
+#ifdef GPIO_PI0
+		case 'i': port_base = GPIO_PI0; break;
+#endif
+#ifdef GPIO_PJ
+		case 'j': port_base = GPIO_PJ0; break;
+#endif
+		default:  return -1;
+		}
+
+		++name;
+	} else
+		port_base = 0;
+
+	return port_base + simple_strtoul(name, NULL, 10);
+}
+
 void gpio_labels(void)
 {
 	int c, gpio;
arch/blackfin/include/asm/gpio.h +0 -49

55 lines not on this page · raw message

common/cmd_gpio.c +4 -3
index 778aa5f..aff0445 100644
@@ -11,9 +11,10 @@
 #include <dm.h>
 #include <asm/gpio.h>
 
-#ifndef name_to_gpio
-#define name_to_gpio(name) simple_strtoul(name, NULL, 10)
-#endif
+int __weak name_to_gpio(const char *name)
+{
+	return simple_strtoul(name, NULL, 10);
+}
 
 enum gpio_cmd {
 	GPIO_INPUT,
Signature · 1 line
1.9.0
#1 lore raw
Quoted 8 lines · Ian Campbell

This required moving it into a C file from the header.

The only user of a non-default name_to_gpio is blackfin, therefore build tested with the blackfin bct-brettl2 build, which is one I picked at random. Also tested with a build for the ARM tec board which uses the default/fallback implementation. Inspection with objdump shows that both have done the right thing.

Quoted 6 lines

This change was requested by Marek during review of the sunxi patch series.

Cc Marek Vasut <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Sonic Zhang <[email protected]>

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140418/494c1533/attachment.pgp>