[PATCH 26/90] ARM: OMAP: abstract debug card setup (smc, leds)

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-kernel@...>
Cc: David Brownell <dbrownell@...>, Tony Lindgren <tony@...>
Date: Wednesday, April 4, 2007 - 2:05 pm

From: David Brownell <dbrownell@users.sourceforge.net>

Additional cleanup for debug boards on H2/P2/H3/H4:  move the init
code that's not board-specific into a new file where it can be easily
shared between all the different boards (avoiding code duplication,
and making it easier to support more devices).  Make H4 use that.

This should be easy to drop in to the OMAP1 boards using these debug
cards; the only difference seems to be that the p2 does an extra reset
of the smc using the fpga (probably all boards could do that, if it's
necessary) and doesn't use the gpio mux or request APIs.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 arch/arm/mach-omap2/Kconfig        |    2 +-
 arch/arm/mach-omap2/board-h4.c     |   46 +------------------
 arch/arm/plat-omap/Kconfig         |    9 +++-
 arch/arm/plat-omap/Makefile        |    1 +
 arch/arm/plat-omap/debug-devices.c |   86 ++++++++++++++++++++++++++++++++++++
 include/asm-arm/arch-omap/board.h  |    4 ++
 6 files changed, 102 insertions(+), 46 deletions(-)

diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index 2a1aca7..4c90cc7 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -20,7 +20,7 @@ config MACH_OMAP_GENERIC
 config MACH_OMAP_H4
 	bool "OMAP 2420 H4 board"
 	depends on ARCH_OMAP2 && ARCH_OMAP24XX
-	select OMAP_DEBUG_LEDS if LEDS || LEDS_OMAP_DEBUG
+	select OMAP_DEBUG_DEVICES
 
 config MACH_OMAP_APOLLON
 	bool "OMAP 2420 Apollon board"
diff --git a/arch/arm/mach-omap2/board-h4.c b/arch/arm/mach-omap2/board-h4.c
index 452193f..f125f43 100644
--- a/arch/arm/mach-omap2/board-h4.c
+++ b/arch/arm/mach-omap2/board-h4.c
@@ -131,26 +131,6 @@ static struct platform_device h4_flash_device = {
 	.resource	= &h4_flash_resource,
 };
 
-static struct resource h4_smc91x_resources[] = {
-	[0] = {
-		.start  = OMAP24XX_ETHR_START,          /* Physical */
-		.end    = OMAP24XX_ETHR_START + 0xf,
-		.flags  = IORESOURCE_MEM,
-	},
-	[1] = {
-		.start  = OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ),
-		.end    = OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ),
-		.flags  = IORESOURCE_IRQ,
-	},
-};
-
-static struct platform_device h4_smc91x_device = {
-	.name		= "smc91x",
-	.id		= -1,
-	.num_resources	= ARRAY_SIZE(h4_smc91x_resources),
-	.resource	= h4_smc91x_resources,
-};
-
 /* Select between the IrDA and aGPS module
  */
 static int h4_select_irda(struct device *dev, int state)
@@ -266,29 +246,14 @@ static struct platform_device h4_lcd_device = {
 	.id		= -1,
 };
 
-static struct resource h4_led_resources[] = {
-	[0] = {
-		.flags	= IORESOURCE_MEM,
-	},
-};
-
-static struct platform_device h4_led_device = {
-	.name		= "omap_dbg_led",
-	.id		= -1,
-	.num_resources	= ARRAY_SIZE(h4_led_resources),
-	.resource	= h4_led_resources,
-};
-
 static struct platform_device *h4_devices[] __initdata = {
-	&h4_smc91x_device,
 	&h4_flash_device,
 	&h4_irda_device,
 	&h4_kp_device,
 	&h4_lcd_device,
-	&h4_led_device,
 };
 
-static inline void __init h4_init_smc91x(void)
+static inline void __init h4_init_debug(void)
 {
 	/* Make sure CS1 timings are correct */
 	GPMC_CONFIG1_1 = 0x00011200;
@@ -301,12 +266,8 @@ static inline void __init h4_init_smc91x(void)
 	udelay(100);
 
 	omap_cfg_reg(M15_24XX_GPIO92);
-	if (omap_request_gpio(OMAP24XX_ETHR_GPIO_IRQ) < 0) {
-		printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
-			OMAP24XX_ETHR_GPIO_IRQ);
-		return;
-	}
-	omap_set_gpio_direction(OMAP24XX_ETHR_GPIO_IRQ, 1);
+	if (debug_card_init(cs_mem_base, OMAP24XX_ETHR_GPIO_IRQ) < 0)
+		gpmc_cs_free(eth_cs);
 }
 
 static void __init omap_h4_init_irq(void)
@@ -314,7 +275,6 @@ static void __init omap_h4_init_irq(void)
 	omap2_init_common_hw();
 	omap_init_irq();
 	omap_gpio_init();
-	h4_init_smc91x();
 }
 
 static struct omap_uart_config h4_uart_config __initdata = {
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index ce8bc33..e5a7d22 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -19,10 +19,15 @@ endchoice
 
 comment "OMAP Feature Selections"
 
-config OMAP_DEBUG_LEDS
+config OMAP_DEBUG_DEVICES
 	bool
 	help
-	  For debug card leds on TI reference boards.
+	  For debug cards on TI reference boards.
+
+config OMAP_DEBUG_LEDS
+	bool
+	depends on OMAP_DEBUG_DEVICES
+	default y if LEDS || LEDS_OMAP_DEBUG
 
 config OMAP_RESET_CLOCKS
 	bool "Reset unused clocks during boot"
diff --git a/arch/arm/plat-omap/Makefile b/arch/arm/plat-omap/Makefile
index 4ce277d..405f89b 100644
--- a/arch/arm/plat-omap/Makefile
+++ b/arch/arm/plat-omap/Makefile
@@ -16,4 +16,5 @@ obj-$(CONFIG_ARCH_OMAP16XX) += ocpi.o
 
 obj-$(CONFIG_CPU_FREQ) += cpu-omap.o
 obj-$(CONFIG_OMAP_DM_TIMER) += dmtimer.o
+obj-$(CONFIG_OMAP_DEBUG_DEVICES) += debug-devices.o
 obj-$(CONFIG_OMAP_DEBUG_LEDS) += debug-leds.o
diff --git a/arch/arm/plat-omap/debug-devices.c b/arch/arm/plat-omap/debug-devices.c
new file mode 100644
index 0000000..83a5f8b
--- /dev/null
+++ b/arch/arm/plat-omap/debug-devices.c
@@ -0,0 +1,86 @@
+/*
+ * linux/arch/arm/plat-omap/debug-devices.c
+ *
+ * Copyright (C) 2005 Nokia Corporation
+ * Modified from mach-omap2/board-h4.c
+ *
+ * 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 <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+
+#include <asm/hardware.h>
+#include <asm/io.h>
+
+#include <asm/arch/board.h>
+#include <asm/arch/gpio.h>
+
+
+/* Many OMAP development platforms reuse the same "debug board"; these
+ * platforms include H2, H3, H4, and Perseus2.
+ */
+
+static struct resource smc91x_resources[] = {
+	[0] = {
+		.flags  = IORESOURCE_MEM,
+	},
+	[1] = {
+		.flags  = IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device smc91x_device = {
+	.name		= "smc91x",
+	.id		= -1,
+	.num_resources	= ARRAY_SIZE(smc91x_resources),
+	.resource	= smc91x_resources,
+};
+
+static struct resource led_resources[] = {
+	[0] = {
+		.flags	= IORESOURCE_MEM,
+	},
+};
+
+static struct platform_device led_device = {
+	.name		= "omap_dbg_led",
+	.id		= -1,
+	.num_resources	= ARRAY_SIZE(led_resources),
+	.resource	= led_resources,
+};
+
+static struct platform_device *debug_devices[] __initdata = {
+	&smc91x_device,
+	&led_device,
+	/* ps2 kbd + mouse ports */
+	/* 4 extra uarts */
+	/* 6 input dip switches */
+	/* 8 output pins */
+};
+
+int __init debug_card_init(u32 addr, unsigned gpio)
+{
+	int	status;
+
+	smc91x_resources[0].start = addr + 0x300;
+	smc91x_resources[0].end   = addr + 0x30f;
+
+	smc91x_resources[1].start = OMAP_GPIO_IRQ(gpio);
+	smc91x_resources[1].end   = OMAP_GPIO_IRQ(gpio);
+
+	status = omap_request_gpio(gpio);
+	if (status < 0) {
+		printk(KERN_ERR "GPIO%d unavailable for smc91x IRQ\n", gpio);
+		return status;
+	}
+	omap_set_gpio_direction(gpio, 1);
+
+	led_resources[0].start = addr;
+	led_resources[0].end   = addr + SZ_4K - 1;
+
+	return platform_add_devices(debug_devices, ARRAY_SIZE(debug_devices));
+}
diff --git a/include/asm-arm/arch-omap/board.h b/include/asm-arm/arch-omap/board.h
index edf1dc6..1cefce2 100644
--- a/include/asm-arm/arch-omap/board.h
+++ b/include/asm-arm/arch-omap/board.h
@@ -172,4 +172,8 @@ extern const void *omap_get_var_config(u16 tag, size_t *len);
 extern struct omap_board_config_kernel *omap_board_config;
 extern int omap_board_config_size;
 
+
+/* for TI reference platforms sharing the same debug card */
+extern int debug_card_init(u32 addr, unsigned gpio);
+
 #endif
-- 
1.4.4.2

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 20/90] ARM: OMAP: gpio init section cleanups, Tony Lindgren, (Wed Apr 4, 2:04 pm)
[PATCH 21/90] ARM: OMAP: gpio object shrinkage, cleanup, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 23/90] ARM: OMAP: PalmZ71 extra brace fix, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 24/90] ARM: OMAP: Fix typo in gpio, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 25/90] ARM: OMAP: h4 must have blinky leds!!, Tony Lindgren, (Wed Apr 4, 2:05 pm)
Re: [PATCH 25/90] ARM: OMAP: h4 must have blinky leds!!, Dmitry Torokhov, (Wed Apr 4, 4:47 pm)
Re: [PATCH 25/90] ARM: OMAP: h4 must have blinky leds!!, David Brownell, (Wed Apr 4, 4:59 pm)
Re: [PATCH 25/90] ARM: OMAP: h4 must have blinky leds!!, Jan Engelhardt, (Wed Apr 4, 4:06 pm)
Re: [PATCH 25/90] ARM: OMAP: h4 must have blinky leds!!, David Brownell, (Wed Apr 4, 4:51 pm)
Re: [PATCH 25/90] ARM: OMAP: h4 must have blinky leds!!, Jan Engelhardt, (Wed Apr 4, 10:15 pm)
Re: [PATCH 25/90] ARM: OMAP: h4 must have blinky leds!!, Randy Dunlap, (Thu Apr 5, 12:18 am)
Re: [PATCH 25/90] ARM: OMAP: h4 must have blinky leds!!, David Brownell, (Thu Apr 5, 2:19 pm)
Re: [PATCH 25/90] ARM: OMAP: h4 must have blinky leds!!, Jan Engelhardt, (Thu Apr 5, 4:35 pm)
Re: coding style for long conditions, Junio C Hamano, (Sat Apr 7, 4:01 am)
Re: coding style for long conditions, David Brownell, (Mon Apr 9, 11:14 am)
Re: coding style for long conditions, Roland Dreier, (Fri Apr 6, 5:38 pm)
Re: coding style for long conditions, Scott Preece, (Mon Apr 9, 11:45 am)
Re: coding style for long conditions, David Brownell, (Fri Apr 6, 6:05 pm)
Re: coding style for long conditions, Jan Engelhardt, (Fri Apr 6, 6:07 pm)
Re: coding style for long conditions, David Brownell, (Fri Apr 6, 6:43 pm)
Re: coding style for long conditions, Zan Lynx, (Fri Apr 6, 5:50 pm)
Re: coding style for long conditions (WAS: Re: [PATCH 25/90]..., Jeremy Fitzhardinge, (Fri Apr 6, 5:37 pm)
Re: [PATCH 25/90] ARM: OMAP: h4 must have blinky leds!!, Dmitry Torokhov, (Wed Apr 4, 4:42 pm)
Re: [PATCH 25/90] ARM: OMAP: h4 must have blinky leds!!, David Brownell, (Wed Apr 4, 3:13 pm)
[PATCH 26/90] ARM: OMAP: abstract debug card setup (smc, leds), Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 27/90] ARM: OMAP: Add minimal OMAP2430 support, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 28/90] ARM: OMAP: USB peripheral support on H4, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 29/90] ARM: OMAP: Palm Tungsten|T support, Tony Lindgren, (Wed Apr 4, 2:05 pm)
Re: [PATCH 29/90] ARM: OMAP: Palm Tungsten|T support, Pavel Machek, (Fri Apr 6, 8:09 am)
Re: [PATCH 29/90] ARM: OMAP: Palm Tungsten|T support, Russell King, (Sun Apr 8, 8:07 am)
Re: [PATCH 29/90] ARM: OMAP: Palm Tungsten|T support, Pavel Machek, (Sun Apr 8, 8:12 am)
Re: [PATCH 29/90] ARM: OMAP: Palm Tungsten|T support, Russell King, (Sun Apr 8, 10:40 am)
Re: [PATCH 29/90] ARM: OMAP: Palm Tungsten|T support, Pavel Machek, (Mon Apr 9, 7:13 am)
Re: [PATCH 29/90] ARM: OMAP: Palm Tungsten|T support, Russell King, (Sun Apr 8, 9:58 am)
Re: [PATCH 29/90] ARM: OMAP: Palm Tungsten|T support, Dagfinn Ilmari , (Sun Apr 8, 8:31 am)
[PATCH 30/90] ARM: OMAP: Palm Zire71 minor fixes, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 31/90] ARM: OMAP: plat-omap changes for 2430 SDP, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 32/90] ARM: OMAP: Basic support for siemens sx1, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 35/90] ARM: OMAP: speed up gpio irq handling, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 36/90] ARM: OMAP: Fix typo in board-h4.h, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 37/90] ARM: OMAP: MPUIO wake updates, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 38/90] ARM: OMAP: Sync headers with linux-omap, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 39/90] ARM: OMAP: Sync core code with linux-omap, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 42/90] ARM: OMAP: Tabify mux.c, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 43/90] ARM: OMAP: TUSB EVM init, Tony Lindgren, (Wed Apr 4, 2:05 pm)
Re: [PATCH 43/90] ARM: OMAP: TUSB EVM init, Randy Dunlap, (Wed Apr 4, 2:44 pm)
Re: [PATCH 43/90] ARM: OMAP: TUSB EVM init, Tony Lindgren, (Thu Apr 5, 10:42 am)
[PATCH 44/90] ARM: OMAP: Add mailbox support for IVA, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 45/90] ARM: OMAP: Update omap h2 defconfig, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 46/90] ARM: OMAP: Add omap osk defconfig, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 47/90] ARM: OMAP: Fix gpmc header, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 48/90] ARM: OMAP: I2C-1 init fix for 2430, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 52/90] ARM: OMAP: cleanup apollon board, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 53/90] ARM: OMAP: Fix warning in timer32k.c, Tony Lindgren, (Wed Apr 4, 2:05 pm)
Re: [PATCH 53/90] ARM: OMAP: Fix warning in timer32k.c, Randy Dunlap, (Wed Apr 4, 3:14 pm)
Re: [PATCH 53/90] ARM: OMAP: Fix warning in timer32k.c, Tony Lindgren, (Thu Apr 5, 11:15 am)
[PATCH 54/90] ARM: OMAP: Update timer32k.c to compile, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 55/90] ARM: OMAP: H3 workqueue fixes, Tony Lindgren, (Wed Apr 4, 2:05 pm)
Re: [PATCH 55/90] ARM: OMAP: H3 workqueue fixes, Tony Lindgren, (Thu Apr 5, 11:17 am)
[PATCH 63/90] ARM: OMAP: Merge PM code from N800 tree, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 64/90] ARM: OMAP: Fix warning in pm.c, Tony Lindgren, (Wed Apr 4, 2:05 pm)
Re: [PATCH 64/90] ARM: OMAP: Fix warning in pm.c, Tony Lindgren, (Thu Apr 5, 11:18 am)
[PATCH 69/90] ARM: OMAP: add SoSSI clock, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 79/90] ARM: OMAP: fix H4 dependencies again, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 80/90] ARM: OMAP: partial LED fixes, Tony Lindgren, (Wed Apr 4, 2:05 pm)
[PATCH 81/90] ARM: OMAP: omap2/pm.c build fix, Tony Lindgren, (Wed Apr 4, 2:06 pm)
[PATCH 82/90] ARM: OMAP: restore CONFIG_GENERIC_TIME, Tony Lindgren, (Wed Apr 4, 2:06 pm)
[PATCH 88/90] ARM: OMAP: OSK led fixes, Tony Lindgren, (Wed Apr 4, 2:06 pm)