diff mbox

davinci: DA830/OMAP-L137 EVM: simplify selection of UI card peripherals

Message ID 1254420121-5897-1-git-send-email-nsekhar@ti.com (mailing list archive)
State Changes Requested
Headers show

Commit Message

Sekhar Nori Oct. 1, 2009, 6:02 p.m. UTC
None
diff mbox

Patch

diff --git a/arch/arm/mach-davinci/Kconfig b/arch/arm/mach-davinci/Kconfig
index 5402da7..7077fa0 100644
--- a/arch/arm/mach-davinci/Kconfig
+++ b/arch/arm/mach-davinci/Kconfig
@@ -99,35 +99,10 @@  config MACH_DAVINCI_DA830_EVM
 	bool "TI DA830/OMAP-L137 Reference Platform"
 	default ARCH_DAVINCI_DA830
 	depends on ARCH_DAVINCI_DA830
+	select GPIO_PCF857X
 	help
 	  Say Y here to select the TI DA830/OMAP-L137 Evaluation Module.
 
-config DA830_UI
-	bool "DA830/OMAP-L137 UI (User Interface) board support"
-	depends on MACH_DAVINCI_DA830_EVM
-	help
-	  Say Y here if you have the DA830/OMAP-L137 UI
-	  (User Interface) board installed and you want to
-	  enable the peripherals located on User Interface
-	  board.
-
-choice
-	prompt "Select DA830/OMAP-L137 UI board peripheral"
-	depends on DA830_UI
-
-config DA830_UI_LCD
-	bool "LCD"
-	help
-	  Say Y here to use the LCD as a framebuffer or simple character
-	  display.
-
-config DA830_UI_NAND
-	bool "NAND flash"
-	help
-	  Say Y here to use the NAND flash.  Do not forget to setup
-	  the switch correctly.
-endchoice
-
 config MACH_DAVINCI_DA850_EVM
 	bool "TI DA850/OMAP-L138 Reference Platform"
 	default ARCH_DAVINCI_DA850
diff --git a/arch/arm/mach-davinci/board-da830-evm.c b/arch/arm/mach-davinci/board-da830-evm.c
index 9e79d9c..b1831a1 100644
--- a/arch/arm/mach-davinci/board-da830-evm.c
+++ b/arch/arm/mach-davinci/board-da830-evm.c
@@ -42,58 +42,6 @@ 
 #define DA830_EMIF25_ASYNC_DATA_CE3_BASE	0x62000000
 #define DA830_EMIF25_CONTROL_BASE		0x68000000
 
-static struct at24_platform_data da830_evm_i2c_eeprom_info = {
-	.byte_len	= SZ_256K / 8,
-	.page_size	= 64,
-	.flags		= AT24_FLAG_ADDR16,
-	.setup		= davinci_get_mac_addr,
-	.context	= (void *)0x7f00,
-};
-
-static int da830_evm_ui_expander_setup(struct i2c_client *client, int gpio,
-		unsigned ngpio, void *context)
-{
-	gpio_request(gpio + 6, "MUX_MODE");
-#ifdef CONFIG_DA830_UI_LCD
-	gpio_direction_output(gpio + 6, 0);
-#else /* Must be NAND or NOR */
-	gpio_direction_output(gpio + 6, 1);
-#endif
-	return 0;
-}
-
-static int da830_evm_ui_expander_teardown(struct i2c_client *client, int gpio,
-		unsigned ngpio, void *context)
-{
-	gpio_free(gpio + 6);
-	return 0;
-}
-
-static struct pcf857x_platform_data da830_evm_ui_expander_info = {
-	.gpio_base	= DAVINCI_N_GPIO,
-	.setup		= da830_evm_ui_expander_setup,
-	.teardown	= da830_evm_ui_expander_teardown,
-};
-
-static struct i2c_board_info __initdata da830_evm_i2c_devices[] = {
-	{
-		I2C_BOARD_INFO("24c256", 0x50),
-		.platform_data	= &da830_evm_i2c_eeprom_info,
-	},
-	{
-		I2C_BOARD_INFO("tlv320aic3x", 0x18),
-	},
-	{
-		I2C_BOARD_INFO("pcf8574", 0x3f),
-		.platform_data	= &da830_evm_ui_expander_info,
-	},
-};
-
-static struct davinci_i2c_platform_data da830_evm_i2c_0_pdata = {
-	.bus_freq	= 100,	/* kHz */
-	.bus_delay	= 0,	/* usec */
-};
-
 /*
  * USB1 VBUS is controlled by GPIO1[15], over-current is reported on GPIO2[4].
  */
@@ -278,7 +226,6 @@  static struct davinci_mmc_config da830_evm_mmc_config = {
 	.version		= MMC_CTLR_VERSION_2,
 };
 
-#ifdef CONFIG_DA830_UI_NAND
 static struct mtd_partition da830_evm_nand_partitions[] = {
 	/* bootloader (U-Boot, etc) in first sector */
 	[0] = {
@@ -368,13 +315,6 @@  static struct platform_device da830_evm_nand_device = {
 	.num_resources	= ARRAY_SIZE(da830_evm_nand_resources),
 	.resource	= da830_evm_nand_resources,
 };
-#endif
-
-static struct platform_device *da830_evm_devices[] __initdata = {
-#ifdef CONFIG_DA830_UI_NAND
-	&da830_evm_nand_device,
-#endif
-};
 
 /*
  * UI board NAND/NOR flashes only use 8-bit data bus.
@@ -390,6 +330,108 @@  static const short da830_evm_emif25_pins[] = {
 	-1
 };
 
+static struct at24_platform_data da830_evm_i2c_eeprom_info = {
+	.byte_len	= SZ_256K / 8,
+	.page_size	= 64,
+	.flags		= AT24_FLAG_ADDR16,
+	.setup		= davinci_get_mac_addr,
+	.context	= (void *)0x7f00,
+};
+
+#if defined(CONFIG_MTD_NAND_DAVINCI) || \
+    defined(CONFIG_MTD_NAND_DAVINCI_MODULE)
+#define HAS_NAND 1
+#else
+#define HAS_NAND 0
+#endif
+
+#if defined(CONFIG_FB_DA8XX) || \
+	defined(CONFIG_FB_DA8XX_MODULE)
+#define HAS_LCD	1
+#else
+#define HAS_LCD	0
+#endif
+
+#if defined(CONFIG_MMC_DAVINCI) || \
+	defined(CONFIG_MMC_DAVINCI_MODULE)
+#define HAS_MMC	1
+#else
+#define HAS_MMC	0
+#endif
+
+static int da830_evm_ui_board_setup(struct i2c_client *client, int gpio,
+		unsigned ngpio, void *context)
+{
+	int ret;
+
+	gpio_request(gpio + 6, "MUX_MODE");
+
+	pr_info("DA830 EVM UI card detected.\n");
+
+	if (HAS_LCD || HAS_MMC) {
+		gpio_direction_output(gpio + 6, 0);
+		if (HAS_NAND)
+			pr_warning("WARNING: both LCD or MMC/SD and NAND are "
+				"enabled, the IO expander on UI card will "
+				"allow only one of them to work.\n\tDisable "
+				"LCD and MMC/SD for NAND support.\n");
+	} else if (HAS_NAND) {
+		gpio_direction_output(gpio + 6, 1);
+
+		ret = da8xx_pinmux_setup(da830_evm_emif25_pins);
+		if (ret)
+			pr_warning("%s: emif25 mux setup failed: %d\n",
+								__func__, ret);
+		platform_device_register(&da830_evm_nand_device);
+	}
+
+	if (HAS_LCD) {
+		ret = da8xx_pinmux_setup(da830_lcdcntl_pins);
+		if (ret)
+			pr_warning("%s: lcdcntl mux setup failed: %d\n",
+								__func__, ret);
+
+		ret = da8xx_register_lcdc(&sharp_lcd035q3dg01_pdata);
+		if (ret)
+			pr_warning("%s: lcd setup failed: %d\n",
+								__func__, ret);
+	}
+
+	return 0;
+}
+
+static int da830_evm_ui_expander_teardown(struct i2c_client *client, int gpio,
+		unsigned ngpio, void *context)
+{
+	gpio_free(gpio + 6);
+	return 0;
+}
+
+static struct pcf857x_platform_data da830_evm_ui_expander_info = {
+	.gpio_base	= DAVINCI_N_GPIO,
+	.setup		= da830_evm_ui_board_setup,
+	.teardown	= da830_evm_ui_expander_teardown,
+};
+
+static struct i2c_board_info __initdata da830_evm_i2c_devices[] = {
+	{
+		I2C_BOARD_INFO("24c256", 0x50),
+		.platform_data	= &da830_evm_i2c_eeprom_info,
+	},
+	{
+		I2C_BOARD_INFO("tlv320aic3x", 0x18),
+	},
+	{
+		I2C_BOARD_INFO("pcf8574", 0x3f),
+		.platform_data	= &da830_evm_ui_expander_info,
+	},
+};
+
+static struct davinci_i2c_platform_data da830_evm_i2c_0_pdata = {
+	.bus_freq	= 100,	/* kHz */
+	.bus_delay	= 0,	/* usec */
+};
+
 static __init void da830_evm_init(void)
 {
 	struct davinci_soc_info *soc_info = &davinci_soc_info;
@@ -452,29 +494,6 @@  static __init void da830_evm_init(void)
 		pr_warning("da830_evm_init: mmc/sd registration failed: %d\n",
 				ret);
 
-#ifdef CONFIG_DA830_UI
-#ifdef CONFIG_DA830_UI_LCD
-	ret = da8xx_pinmux_setup(da830_lcdcntl_pins);
-	if (ret)
-		pr_warning("da830_evm_init: lcdcntl mux setup failed: %d\n",
-				ret);
-
-	ret = da8xx_register_lcdc(&sharp_lcd035q3dg01_pdata);
-	if (ret)
-		pr_warning("da830_evm_init: lcd setup failed: %d\n", ret);
-#else /* Must be NAND or NOR */
-	ret = da8xx_pinmux_setup(da830_evm_emif25_pins);
-	if (ret)
-		pr_warning("da830_evm_init: emif25 mux setup failed: %d\n",
-				ret);
-
-	ret = platform_add_devices(da830_evm_devices,
-			ARRAY_SIZE(da830_evm_devices));
-	if (ret)
-		pr_warning("da830_evm_init: EVM devices not added\n");
-#endif
-#endif
-
 	ret = da8xx_register_rtc();
 	if (ret)
 		pr_warning("da830_evm_init: rtc setup failed: %d\n", ret);