linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] omap: cleanup board files
@ 2011-04-24 22:09 Mike Rapoport
  2011-04-24 22:09 ` [PATCH 1/4] omap: consolidate touch screen initialization among different boards Mike Rapoport
                   ` (4 more replies)
  0 siblings, 5 replies; 29+ messages in thread
From: Mike Rapoport @ 2011-04-24 22:09 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Tony,

These patches cleanup some of the common code in the board files. The changes
are basically almost mechanically move the code shared among several boards
into some common place.
There are a lot of places for further improvement, especially DSS and TWL
initialization. I'll try to find some time to sort these out as well.

Special thanks to Igor Grinberg for the original idea :)

Mike Rapoport (4):
  omap: consolidate touch screen initialization among different boards
  omap: use common initialization for PMIC i2c bus
  omap: move detection of NAND CS to common-board-devices
  omap: musb: introduce default baord config

 arch/arm/mach-omap2/Makefile                 |    2 +
 arch/arm/mach-omap2/board-2430sdp.c          |   20 +---
 arch/arm/mach-omap2/board-3430sdp.c          |   85 ++-------------
 arch/arm/mach-omap2/board-4430sdp.c          |   16 +---
 arch/arm/mach-omap2/board-cm-t35.c           |   78 +-------------
 arch/arm/mach-omap2/board-devkit8000.c       |  119 +--------------------
 arch/arm/mach-omap2/board-igep0020.c         |   23 +----
 arch/arm/mach-omap2/board-igep0030.c         |   21 +---
 arch/arm/mach-omap2/board-ldp.c              |   77 +-------------
 arch/arm/mach-omap2/board-omap3beagle.c      |   66 +-----------
 arch/arm/mach-omap2/board-omap3evm.c         |   72 +------------
 arch/arm/mach-omap2/board-omap3logic.c       |   13 +--
 arch/arm/mach-omap2/board-omap3pandora.c     |   69 +-----------
 arch/arm/mach-omap2/board-omap3stalker.c     |   78 +-------------
 arch/arm/mach-omap2/board-omap3touchbook.c   |  101 ++----------------
 arch/arm/mach-omap2/board-omap4panda.c       |   17 +---
 arch/arm/mach-omap2/board-overo.c            |  108 +------------------
 arch/arm/mach-omap2/board-rm680.c            |   21 +---
 arch/arm/mach-omap2/board-rx51-peripherals.c |   13 +--
 arch/arm/mach-omap2/board-zoom-peripherals.c |   21 +---
 arch/arm/mach-omap2/common-board-devices.c   |  148 ++++++++++++++++++++++++++
 arch/arm/mach-omap2/common-board-devices.h   |   52 +++++++++
 arch/arm/mach-omap2/usb-musb.c               |   14 +++-
 23 files changed, 293 insertions(+), 941 deletions(-)
 create mode 100644 arch/arm/mach-omap2/common-board-devices.c
 create mode 100644 arch/arm/mach-omap2/common-board-devices.h

-- 
1.7.3.1

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 1/4] omap: consolidate touch screen initialization among different boards
  2011-04-24 22:09 [PATCH 0/4] omap: cleanup board files Mike Rapoport
@ 2011-04-24 22:09 ` Mike Rapoport
  2011-05-04  3:10   ` Oleg Drokin
  2011-05-04 14:02   ` Thomas Weber
  2011-04-24 22:09 ` [PATCH 2/4] omap: use common initialization for PMIC i2c bus Mike Rapoport
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 29+ messages in thread
From: Mike Rapoport @ 2011-04-24 22:09 UTC (permalink / raw)
  To: linux-arm-kernel

Add common-board-devices.c that will contain the code for peripheral
devices initializatoin shared between multiple boards.
Start small with touchscreen initialization.

Signed-off-by: Mike Rapoport <mike@compulab.co.il>
---
 arch/arm/mach-omap2/Makefile               |    2 +
 arch/arm/mach-omap2/board-3430sdp.c        |   65 ++-------------------
 arch/arm/mach-omap2/board-cm-t35.c         |   58 +------------------
 arch/arm/mach-omap2/board-devkit8000.c     |   56 +------------------
 arch/arm/mach-omap2/board-ldp.c            |   57 +------------------
 arch/arm/mach-omap2/board-omap3evm.c       |   51 +----------------
 arch/arm/mach-omap2/board-omap3pandora.c   |   49 +---------------
 arch/arm/mach-omap2/board-omap3stalker.c   |   49 +---------------
 arch/arm/mach-omap2/board-omap3touchbook.c |   36 +-----------
 arch/arm/mach-omap2/board-overo.c          |   46 +--------------
 arch/arm/mach-omap2/common-board-devices.c |   85 ++++++++++++++++++++++++++++
 arch/arm/mach-omap2/common-board-devices.h |   18 ++++++
 12 files changed, 128 insertions(+), 444 deletions(-)
 create mode 100644 arch/arm/mach-omap2/common-board-devices.c
 create mode 100644 arch/arm/mach-omap2/common-board-devices.h

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 512b152..43c5c22 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -270,3 +270,5 @@ obj-$(CONFIG_ARCH_OMAP4)		+= hwspinlock.o
 
 disp-$(CONFIG_OMAP2_DSS)		:= display.o
 obj-y					+= $(disp-m) $(disp-y)
+
+obj-y					+= common-board-devices.o
diff --git a/arch/arm/mach-omap2/board-3430sdp.c b/arch/arm/mach-omap2/board-3430sdp.c
index 9afd087..3726465 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -19,7 +19,6 @@
 #include <linux/input.h>
 #include <linux/input/matrix_keypad.h>
 #include <linux/spi/spi.h>
-#include <linux/spi/ads7846.h>
 #include <linux/i2c/twl.h>
 #include <linux/regulator/machine.h>
 #include <linux/io.h>
@@ -48,6 +47,7 @@
 #include "hsmmc.h"
 #include "pm.h"
 #include "control.h"
+#include "common-board-devices.h"
 
 #define CONFIG_DISABLE_HFCLK 1
 
@@ -123,58 +123,6 @@ static struct twl4030_keypad_data sdp3430_kp_data = {
 	.rep		= 1,
 };
 
-static int ts_gpio;	/* Needed for ads7846_get_pendown_state */
-
-/**
- * @brief ads7846_dev_init : Requests & sets GPIO line for pen-irq
- *
- * @return - void. If request gpio fails then Flag KERN_ERR.
- */
-static void ads7846_dev_init(void)
-{
-	if (gpio_request(ts_gpio, "ADS7846 pendown") < 0) {
-		printk(KERN_ERR "can't get ads746 pen down GPIO\n");
-		return;
-	}
-
-	gpio_direction_input(ts_gpio);
-	gpio_set_debounce(ts_gpio, 310);
-}
-
-static int ads7846_get_pendown_state(void)
-{
-	return !gpio_get_value(ts_gpio);
-}
-
-static struct ads7846_platform_data tsc2046_config __initdata = {
-	.get_pendown_state	= ads7846_get_pendown_state,
-	.keep_vref_on		= 1,
-	.wakeup				= true,
-};
-
-
-static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
-	.turbo_mode	= 0,
-	.single_channel	= 1,	/* 0: slave, 1: master */
-};
-
-static struct spi_board_info sdp3430_spi_board_info[] __initdata = {
-	[0] = {
-		/*
-		 * TSC2046 operates at a max freqency of 2MHz, so
-		 * operate slightly below@1.5MHz
-		 */
-		.modalias		= "ads7846",
-		.bus_num		= 1,
-		.chip_select		= 0,
-		.max_speed_hz		= 1500000,
-		.controller_data	= &tsc2046_mcspi_config,
-		.irq			= 0,
-		.platform_data		= &tsc2046_config,
-	},
-};
-
-
 #define SDP3430_LCD_PANEL_BACKLIGHT_GPIO	8
 #define SDP3430_LCD_PANEL_ENABLE_GPIO		5
 
@@ -880,6 +828,8 @@ static struct omap_musb_board_data musb_board_data = {
 
 static void __init omap_3430sdp_init(void)
 {
+	int gpio_pendown;
+
 	omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
 	omap_board_config = sdp3430_config;
 	omap_board_config_size = ARRAY_SIZE(sdp3430_config);
@@ -887,13 +837,10 @@ static void __init omap_3430sdp_init(void)
 	omap3430_i2c_init();
 	omap_display_init(&sdp3430_dss_data);
 	if (omap_rev() > OMAP3430_REV_ES1_0)
-		ts_gpio = SDP3430_TS_GPIO_IRQ_SDPV2;
+		gpio_pendown = SDP3430_TS_GPIO_IRQ_SDPV2;
 	else
-		ts_gpio = SDP3430_TS_GPIO_IRQ_SDPV1;
-	sdp3430_spi_board_info[0].irq = gpio_to_irq(ts_gpio);
-	spi_register_board_info(sdp3430_spi_board_info,
-				ARRAY_SIZE(sdp3430_spi_board_info));
-	ads7846_dev_init();
+		gpio_pendown = SDP3430_TS_GPIO_IRQ_SDPV1;
+	omap_ads7846_init(1, gpio_pendown, 310, NULL);
 	board_serial_init();
 	usb_musb_init(&musb_board_data);
 	board_smc91x_init();
diff --git a/arch/arm/mach-omap2/board-cm-t35.c b/arch/arm/mach-omap2/board-cm-t35.c
index b5772c1..9e5b8be 100644
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -54,6 +54,7 @@
 #include "mux.h"
 #include "sdram-micron-mt46h32m32lf-6.h"
 #include "hsmmc.h"
+#include "common-board-devices.h"
 
 #define CM_T35_GPIO_PENDOWN	57
 
@@ -175,61 +176,6 @@ static void __init cm_t35_init_nand(void)
 static inline void cm_t35_init_nand(void) {}
 #endif
 
-#if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
-	defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
-#include <linux/spi/ads7846.h>
-
-static struct omap2_mcspi_device_config ads7846_mcspi_config = {
-	.turbo_mode	= 0,
-	.single_channel	= 1,	/* 0: slave, 1: master */
-};
-
-static int ads7846_get_pendown_state(void)
-{
-	return !gpio_get_value(CM_T35_GPIO_PENDOWN);
-}
-
-static struct ads7846_platform_data ads7846_config = {
-	.x_max			= 0x0fff,
-	.y_max			= 0x0fff,
-	.x_plate_ohms		= 180,
-	.pressure_max		= 255,
-	.debounce_max		= 10,
-	.debounce_tol		= 3,
-	.debounce_rep		= 1,
-	.get_pendown_state	= ads7846_get_pendown_state,
-	.keep_vref_on		= 1,
-};
-
-static struct spi_board_info cm_t35_spi_board_info[] __initdata = {
-	{
-		.modalias		= "ads7846",
-		.bus_num		= 1,
-		.chip_select		= 0,
-		.max_speed_hz		= 1500000,
-		.controller_data	= &ads7846_mcspi_config,
-		.irq			= OMAP_GPIO_IRQ(CM_T35_GPIO_PENDOWN),
-		.platform_data		= &ads7846_config,
-	},
-};
-
-static void __init cm_t35_init_ads7846(void)
-{
-	if ((gpio_request(CM_T35_GPIO_PENDOWN, "ADS7846_PENDOWN") == 0) &&
-	    (gpio_direction_input(CM_T35_GPIO_PENDOWN) == 0)) {
-		gpio_export(CM_T35_GPIO_PENDOWN, 0);
-	} else {
-		pr_err("CM-T35: could not obtain gpio for ADS7846_PENDOWN\n");
-		return;
-	}
-
-	spi_register_board_info(cm_t35_spi_board_info,
-				ARRAY_SIZE(cm_t35_spi_board_info));
-}
-#else
-static inline void cm_t35_init_ads7846(void) {}
-#endif
-
 #define CM_T35_LCD_EN_GPIO 157
 #define CM_T35_LCD_BL_GPIO 58
 #define CM_T35_DVI_EN_GPIO 54
@@ -732,7 +678,7 @@ static void __init cm_t35_init(void)
 	omap_serial_init();
 	cm_t35_init_i2c();
 	cm_t35_init_nand();
-	cm_t35_init_ads7846();
+	omap_ads7846_init(1, CM_T35_GPIO_PENDOWN, 0, NULL);
 	cm_t35_init_ethernet();
 	cm_t35_init_led();
 	cm_t35_init_display();
diff --git a/arch/arm/mach-omap2/board-devkit8000.c b/arch/arm/mach-omap2/board-devkit8000.c
index 65f9fde..9f8338d 100644
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -51,7 +51,6 @@
 #include <plat/mcspi.h>
 #include <linux/input/matrix_keypad.h>
 #include <linux/spi/spi.h>
-#include <linux/spi/ads7846.h>
 #include <linux/dm9000.h>
 #include <linux/interrupt.h>
 
@@ -60,6 +59,7 @@
 #include "mux.h"
 #include "hsmmc.h"
 #include "timer-gp.h"
+#include "common-board-devices.h"
 
 #define NAND_BLOCK_SIZE		SZ_128K
 
@@ -463,56 +463,6 @@ static void __init devkit8000_init_irq(void)
 #endif
 }
 
-static void __init devkit8000_ads7846_init(void)
-{
-	int gpio = OMAP3_DEVKIT_TS_GPIO;
-	int ret;
-
-	ret = gpio_request(gpio, "ads7846_pen_down");
-	if (ret < 0) {
-		printk(KERN_ERR "Failed to request GPIO %d for "
-				"ads7846 pen down IRQ\n", gpio);
-		return;
-	}
-
-	gpio_direction_input(gpio);
-}
-
-static int ads7846_get_pendown_state(void)
-{
-	return !gpio_get_value(OMAP3_DEVKIT_TS_GPIO);
-}
-
-static struct ads7846_platform_data ads7846_config = {
-	.x_max                  = 0x0fff,
-	.y_max                  = 0x0fff,
-	.x_plate_ohms           = 180,
-	.pressure_max           = 255,
-	.debounce_max           = 10,
-	.debounce_tol           = 5,
-	.debounce_rep           = 1,
-	.get_pendown_state	= ads7846_get_pendown_state,
-	.keep_vref_on		= 1,
-	.settle_delay_usecs     = 150,
-};
-
-static struct omap2_mcspi_device_config ads7846_mcspi_config = {
-	.turbo_mode	= 0,
-	.single_channel	= 1,	/* 0: slave, 1: master */
-};
-
-static struct spi_board_info devkit8000_spi_board_info[] __initdata = {
-	{
-		.modalias		= "ads7846",
-		.bus_num		= 2,
-		.chip_select		= 0,
-		.max_speed_hz		= 1500000,
-		.controller_data	= &ads7846_mcspi_config,
-		.irq			= OMAP_GPIO_IRQ(OMAP3_DEVKIT_TS_GPIO),
-		.platform_data		= &ads7846_config,
-	}
-};
-
 #define OMAP_DM9000_BASE	0x2c000000
 
 static struct resource omap_dm9000_resources[] = {
@@ -795,10 +745,8 @@ static void __init devkit8000_init(void)
 			ARRAY_SIZE(devkit8000_devices));
 
 	omap_display_init(&devkit8000_dss_data);
-	spi_register_board_info(devkit8000_spi_board_info,
-	ARRAY_SIZE(devkit8000_spi_board_info));
 
-	devkit8000_ads7846_init();
+	omap_ads7846_init(2, OMAP3_DEVKIT_TS_GPIO, 0, NULL);
 
 	usb_musb_init(&musb_board_data);
 	usbhs_init(&usbhs_bdata);
diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
index ea9f049..155b423 100644
--- a/arch/arm/mach-omap2/board-ldp.c
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -22,7 +22,6 @@
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/spi/spi.h>
-#include <linux/spi/ads7846.h>
 #include <linux/regulator/machine.h>
 #include <linux/i2c/twl.h>
 #include <linux/io.h>
@@ -49,6 +48,7 @@
 #include "mux.h"
 #include "hsmmc.h"
 #include "control.h"
+#include "common-board-devices.h"
 
 #define LDP_SMSC911X_CS		1
 #define LDP_SMSC911X_GPIO	152
@@ -168,55 +168,6 @@ static struct platform_device ldp_gpio_keys_device = {
 	},
 };
 
-static int ts_gpio;
-
-/**
- * @brief ads7846_dev_init : Requests & sets GPIO line for pen-irq
- *
- * @return - void. If request gpio fails then Flag KERN_ERR.
- */
-static void ads7846_dev_init(void)
-{
-	if (gpio_request(ts_gpio, "ads7846 irq") < 0) {
-		printk(KERN_ERR "can't get ads746 pen down GPIO\n");
-		return;
-	}
-
-	gpio_direction_input(ts_gpio);
-	gpio_set_debounce(ts_gpio, 310);
-}
-
-static int ads7846_get_pendown_state(void)
-{
-	return !gpio_get_value(ts_gpio);
-}
-
-static struct ads7846_platform_data tsc2046_config __initdata = {
-	.get_pendown_state	= ads7846_get_pendown_state,
-	.keep_vref_on		= 1,
-};
-
-static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
-	.turbo_mode	= 0,
-	.single_channel	= 1,	/* 0: slave, 1: master */
-};
-
-static struct spi_board_info ldp_spi_board_info[] __initdata = {
-	[0] = {
-		/*
-		 * TSC2046 operates at a max freqency of 2MHz, so
-		 * operate slightly below@1.5MHz
-		 */
-		.modalias		= "ads7846",
-		.bus_num		= 1,
-		.chip_select		= 0,
-		.max_speed_hz		= 1500000,
-		.controller_data	= &tsc2046_mcspi_config,
-		.irq			= 0,
-		.platform_data		= &tsc2046_config,
-	},
-};
-
 static struct omap_smsc911x_platform_data smsc911x_cfg = {
 	.cs             = LDP_SMSC911X_CS,
 	.gpio_irq       = LDP_SMSC911X_GPIO,
@@ -399,11 +350,7 @@ static void __init omap_ldp_init(void)
 	ldp_init_smsc911x();
 	omap_i2c_init();
 	platform_add_devices(ldp_devices, ARRAY_SIZE(ldp_devices));
-	ts_gpio = 54;
-	ldp_spi_board_info[0].irq = gpio_to_irq(ts_gpio);
-	spi_register_board_info(ldp_spi_board_info,
-				ARRAY_SIZE(ldp_spi_board_info));
-	ads7846_dev_init();
+	omap_ads7846_init(1, 54, 310, NULL);
 	omap_serial_init();
 	usb_musb_init(&musb_board_data);
 	board_nand_init(ldp_nand_partitions,
diff --git a/arch/arm/mach-omap2/board-omap3evm.c b/arch/arm/mach-omap2/board-omap3evm.c
index 3fc85c6..376ea87 100644
--- a/arch/arm/mach-omap2/board-omap3evm.c
+++ b/arch/arm/mach-omap2/board-omap3evm.c
@@ -50,6 +50,7 @@
 #include "mux.h"
 #include "sdram-micron-mt46h32m32lf-6.h"
 #include "hsmmc.h"
+#include "common-board-devices.h"
 
 #define OMAP3_EVM_TS_GPIO	175
 #define OMAP3_EVM_EHCI_VBUS	22
@@ -630,51 +631,6 @@ static int __init omap3_evm_i2c_init(void)
 	return 0;
 }
 
-static void ads7846_dev_init(void)
-{
-	if (gpio_request(OMAP3_EVM_TS_GPIO, "ADS7846 pendown") < 0)
-		printk(KERN_ERR "can't get ads7846 pen down GPIO\n");
-
-	gpio_direction_input(OMAP3_EVM_TS_GPIO);
-	gpio_set_debounce(OMAP3_EVM_TS_GPIO, 310);
-}
-
-static int ads7846_get_pendown_state(void)
-{
-	return !gpio_get_value(OMAP3_EVM_TS_GPIO);
-}
-
-static struct ads7846_platform_data ads7846_config = {
-	.x_max			= 0x0fff,
-	.y_max			= 0x0fff,
-	.x_plate_ohms		= 180,
-	.pressure_max		= 255,
-	.debounce_max		= 10,
-	.debounce_tol		= 3,
-	.debounce_rep		= 1,
-	.get_pendown_state	= ads7846_get_pendown_state,
-	.keep_vref_on		= 1,
-	.settle_delay_usecs	= 150,
-	.wakeup				= true,
-};
-
-static struct omap2_mcspi_device_config ads7846_mcspi_config = {
-	.turbo_mode	= 0,
-	.single_channel	= 1,	/* 0: slave, 1: master */
-};
-
-static struct spi_board_info omap3evm_spi_board_info[] = {
-	[0] = {
-		.modalias		= "ads7846",
-		.bus_num		= 1,
-		.chip_select		= 0,
-		.max_speed_hz		= 1500000,
-		.controller_data	= &ads7846_mcspi_config,
-		.irq			= OMAP_GPIO_IRQ(OMAP3_EVM_TS_GPIO),
-		.platform_data		= &ads7846_config,
-	},
-};
-
 static struct omap_board_config_kernel omap3_evm_config[] __initdata = {
 };
 
@@ -792,9 +748,6 @@ static void __init omap3_evm_init(void)
 
 	omap_display_init(&omap3_evm_dss_data);
 
-	spi_register_board_info(omap3evm_spi_board_info,
-				ARRAY_SIZE(omap3evm_spi_board_info));
-
 	omap_serial_init();
 
 	/* OMAP3EVM uses ISP1504 phy and so register nop transceiver */
@@ -827,7 +780,7 @@ static void __init omap3_evm_init(void)
 	}
 	usb_musb_init(&musb_board_data);
 	usbhs_init(&usbhs_bdata);
-	ads7846_dev_init();
+	omap_ads7846_init(1, OMAP3_EVM_TS_GPIO, 310, NULL);
 	omap3evm_init_smsc911x();
 	omap3_evm_display_init();
 
diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
index 07dba88..517701a 100644
--- a/arch/arm/mach-omap2/board-omap3pandora.c
+++ b/arch/arm/mach-omap2/board-omap3pandora.c
@@ -22,7 +22,6 @@
 #include <linux/platform_device.h>
 
 #include <linux/spi/spi.h>
-#include <linux/spi/ads7846.h>
 #include <linux/regulator/machine.h>
 #include <linux/i2c/twl.h>
 #include <linux/wl12xx.h>
@@ -52,6 +51,7 @@
 #include "mux.h"
 #include "sdram-micron-mt46h32m32lf-6.h"
 #include "hsmmc.h"
+#include "common-board-devices.h"
 
 #define PANDORA_WIFI_IRQ_GPIO		21
 #define PANDORA_WIFI_NRESET_GPIO	23
@@ -570,53 +570,8 @@ static int __init omap3pandora_i2c_init(void)
 	return 0;
 }
 
-static void __init omap3pandora_ads7846_init(void)
-{
-	int gpio = OMAP3_PANDORA_TS_GPIO;
-	int ret;
-
-	ret = gpio_request(gpio, "ads7846_pen_down");
-	if (ret < 0) {
-		printk(KERN_ERR "Failed to request GPIO %d for "
-				"ads7846 pen down IRQ\n", gpio);
-		return;
-	}
-
-	gpio_direction_input(gpio);
-}
-
-static int ads7846_get_pendown_state(void)
-{
-	return !gpio_get_value(OMAP3_PANDORA_TS_GPIO);
-}
-
-static struct ads7846_platform_data ads7846_config = {
-	.x_max			= 0x0fff,
-	.y_max			= 0x0fff,
-	.x_plate_ohms		= 180,
-	.pressure_max		= 255,
-	.debounce_max		= 10,
-	.debounce_tol		= 3,
-	.debounce_rep		= 1,
-	.get_pendown_state	= ads7846_get_pendown_state,
-	.keep_vref_on		= 1,
-};
-
-static struct omap2_mcspi_device_config ads7846_mcspi_config = {
-	.turbo_mode	= 0,
-	.single_channel	= 1,	/* 0: slave, 1: master */
-};
-
 static struct spi_board_info omap3pandora_spi_board_info[] __initdata = {
 	{
-		.modalias		= "ads7846",
-		.bus_num		= 1,
-		.chip_select		= 0,
-		.max_speed_hz		= 1500000,
-		.controller_data	= &ads7846_mcspi_config,
-		.irq			= OMAP_GPIO_IRQ(OMAP3_PANDORA_TS_GPIO),
-		.platform_data		= &ads7846_config,
-	}, {
 		.modalias		= "tpo_td043mtea1_panel_spi",
 		.bus_num		= 1,
 		.chip_select		= 1,
@@ -705,7 +660,7 @@ static void __init omap3pandora_init(void)
 	omap_serial_init();
 	spi_register_board_info(omap3pandora_spi_board_info,
 			ARRAY_SIZE(omap3pandora_spi_board_info));
-	omap3pandora_ads7846_init();
+	omap_ads7846_init(1, OMAP3_PANDORA_TS_GPIO, 0, NULL);
 	usbhs_init(&usbhs_bdata);
 	usb_musb_init(&musb_board_data);
 	gpmc_nand_init(&pandora_nand_data);
diff --git a/arch/arm/mach-omap2/board-omap3stalker.c b/arch/arm/mach-omap2/board-omap3stalker.c
index 848016c..671ceb0 100644
--- a/arch/arm/mach-omap2/board-omap3stalker.c
+++ b/arch/arm/mach-omap2/board-omap3stalker.c
@@ -45,7 +45,6 @@
 #include <plat/mcspi.h>
 #include <linux/input/matrix_keypad.h>
 #include <linux/spi/spi.h>
-#include <linux/spi/ads7846.h>
 #include <linux/interrupt.h>
 #include <linux/smsc911x.h>
 #include <linux/i2c/at24.h>
@@ -54,6 +53,7 @@
 #include "mux.h"
 #include "hsmmc.h"
 #include "timer-gp.h"
+#include "common-board-devices.h"
 
 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
 #include <plat/gpmc-smsc911x.h>
@@ -498,49 +498,6 @@ static int __init omap3_stalker_i2c_init(void)
 }
 
 #define OMAP3_STALKER_TS_GPIO	175
-static void ads7846_dev_init(void)
-{
-	if (gpio_request(OMAP3_STALKER_TS_GPIO, "ADS7846 pendown") < 0)
-		printk(KERN_ERR "can't get ads7846 pen down GPIO\n");
-
-	gpio_direction_input(OMAP3_STALKER_TS_GPIO);
-	gpio_set_debounce(OMAP3_STALKER_TS_GPIO, 310);
-}
-
-static int ads7846_get_pendown_state(void)
-{
-	return !gpio_get_value(OMAP3_STALKER_TS_GPIO);
-}
-
-static struct ads7846_platform_data ads7846_config = {
-	.x_max			= 0x0fff,
-	.y_max			= 0x0fff,
-	.x_plate_ohms		= 180,
-	.pressure_max		= 255,
-	.debounce_max		= 10,
-	.debounce_tol		= 3,
-	.debounce_rep		= 1,
-	.get_pendown_state	= ads7846_get_pendown_state,
-	.keep_vref_on		= 1,
-	.settle_delay_usecs	= 150,
-};
-
-static struct omap2_mcspi_device_config ads7846_mcspi_config = {
-	.turbo_mode		= 0,
-	.single_channel		= 1,	/* 0: slave, 1: master */
-};
-
-static struct spi_board_info omap3stalker_spi_board_info[] = {
-	[0] = {
-	       .modalias	= "ads7846",
-	       .bus_num		= 1,
-	       .chip_select	= 0,
-	       .max_speed_hz	= 1500000,
-	       .controller_data	= &ads7846_mcspi_config,
-	       .irq		= OMAP_GPIO_IRQ(OMAP3_STALKER_TS_GPIO),
-	       .platform_data	= &ads7846_config,
-	},
-};
 
 static struct omap_board_config_kernel omap3_stalker_config[] __initdata = {
 };
@@ -602,13 +559,11 @@ static void __init omap3_stalker_init(void)
 			     ARRAY_SIZE(omap3_stalker_devices));
 
 	omap_display_init(&omap3_stalker_dss_data);
-	spi_register_board_info(omap3stalker_spi_board_info,
-				ARRAY_SIZE(omap3stalker_spi_board_info));
 
 	omap_serial_init();
 	usb_musb_init(&musb_board_data);
 	usbhs_init(&usbhs_bdata);
-	ads7846_dev_init();
+	omap_ads7846_init(1, OMAP3_STALKER_TS_GPIO, 310, NULL);
 
 	omap_mux_init_gpio(21, OMAP_PIN_OUTPUT);
 	omap_mux_init_gpio(18, OMAP_PIN_INPUT_PULLUP);
diff --git a/arch/arm/mach-omap2/board-omap3touchbook.c b/arch/arm/mach-omap2/board-omap3touchbook.c
index 127cb17..15f9d7d 100644
--- a/arch/arm/mach-omap2/board-omap3touchbook.c
+++ b/arch/arm/mach-omap2/board-omap3touchbook.c
@@ -52,6 +52,7 @@
 #include "mux.h"
 #include "hsmmc.h"
 #include "timer-gp.h"
+#include "common-board-devices.h"
 
 #include <asm/setup.h>
 
@@ -301,19 +302,7 @@ static int __init omap3_touchbook_i2c_init(void)
 	return 0;
 }
 
-static void __init omap3_ads7846_init(void)
-{
-	if (gpio_request(OMAP3_TS_GPIO, "ads7846_pen_down")) {
-		printk(KERN_ERR "Failed to request GPIO %d for "
-				"ads7846 pen down IRQ\n", OMAP3_TS_GPIO);
-		return;
-	}
-
-	gpio_direction_input(OMAP3_TS_GPIO);
-	gpio_set_debounce(OMAP3_TS_GPIO, 310);
-}
-
-static struct ads7846_platform_data ads7846_config = {
+static struct ads7846_platform_data ads7846_pdata = {
 	.x_min			= 100,
 	.y_min			= 265,
 	.x_max			= 3950,
@@ -327,23 +316,6 @@ static struct ads7846_platform_data ads7846_config = {
 	.keep_vref_on		= 1,
 };
 
-static struct omap2_mcspi_device_config ads7846_mcspi_config = {
-	.turbo_mode	= 0,
-	.single_channel	= 1,	/* 0: slave, 1: master */
-};
-
-static struct spi_board_info omap3_ads7846_spi_board_info[] __initdata = {
-	{
-		.modalias		= "ads7846",
-		.bus_num		= 4,
-		.chip_select		= 0,
-		.max_speed_hz		= 1500000,
-		.controller_data	= &ads7846_mcspi_config,
-		.irq			= OMAP_GPIO_IRQ(OMAP3_TS_GPIO),
-		.platform_data		= &ads7846_config,
-	}
-};
-
 static struct gpio_led gpio_leds[] = {
 	{
 		.name			= "touchbook::usr0",
@@ -526,9 +498,7 @@ static void __init omap3_touchbook_init(void)
 	gpio_direction_output(176, true);
 
 	/* Touchscreen and accelerometer */
-	spi_register_board_info(omap3_ads7846_spi_board_info,
-				ARRAY_SIZE(omap3_ads7846_spi_board_info));
-	omap3_ads7846_init();
+	omap_ads7846_init(4, OMAP3_TS_GPIO, 310, &ads7846_pdata);
 	usb_musb_init(&musb_board_data);
 	usbhs_init(&usbhs_bdata);
 	omap3touchbook_flash_init();
diff --git a/arch/arm/mach-omap2/board-overo.c b/arch/arm/mach-omap2/board-overo.c
index 4016166..abe4f14 100644
--- a/arch/arm/mach-omap2/board-overo.c
+++ b/arch/arm/mach-omap2/board-overo.c
@@ -56,6 +56,7 @@
 #include "mux.h"
 #include "sdram-micron-mt46h32m32lf-6.h"
 #include "hsmmc.h"
+#include "common-board-devices.h"
 
 #define OVERO_GPIO_BT_XGATE	15
 #define OVERO_GPIO_W2W_NRESET	16
@@ -74,30 +75,6 @@
 #if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
 	defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
 
-#include <linux/spi/ads7846.h>
-
-static struct omap2_mcspi_device_config ads7846_mcspi_config = {
-	.turbo_mode	= 0,
-	.single_channel	= 1,	/* 0: slave, 1: master */
-};
-
-static int ads7846_get_pendown_state(void)
-{
-	return !gpio_get_value(OVERO_GPIO_PENDOWN);
-}
-
-static struct ads7846_platform_data ads7846_config = {
-	.x_max			= 0x0fff,
-	.y_max			= 0x0fff,
-	.x_plate_ohms		= 180,
-	.pressure_max		= 255,
-	.debounce_max		= 10,
-	.debounce_tol		= 3,
-	.debounce_rep		= 1,
-	.get_pendown_state	= ads7846_get_pendown_state,
-	.keep_vref_on		= 1,
-};
-
 /* fixed regulator for ads7846 */
 static struct regulator_consumer_supply ads7846_supply =
 	REGULATOR_SUPPLY("vcc", "spi1.0");
@@ -128,14 +105,7 @@ static struct platform_device vads7846_device = {
 
 static void __init overo_ads7846_init(void)
 {
-	if ((gpio_request(OVERO_GPIO_PENDOWN, "ADS7846_PENDOWN") == 0) &&
-	    (gpio_direction_input(OVERO_GPIO_PENDOWN) == 0)) {
-		gpio_export(OVERO_GPIO_PENDOWN, 0);
-	} else {
-		printk(KERN_ERR "could not obtain gpio for ADS7846_PENDOWN\n");
-		return;
-	}
-
+	omap_ads7846_init(1, OVERO_GPIO_PENDOWN, 0, NULL);
 	platform_device_register(&vads7846_device);
 }
 
@@ -587,18 +557,6 @@ static int __init overo_i2c_init(void)
 }
 
 static struct spi_board_info overo_spi_board_info[] __initdata = {
-#if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
-	defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
-	{
-		.modalias		= "ads7846",
-		.bus_num		= 1,
-		.chip_select		= 0,
-		.max_speed_hz		= 1500000,
-		.controller_data	= &ads7846_mcspi_config,
-		.irq			= OMAP_GPIO_IRQ(OVERO_GPIO_PENDOWN),
-		.platform_data		= &ads7846_config,
-	},
-#endif
 #if defined(CONFIG_PANEL_LGPHILIPS_LB035Q02) || \
 	defined(CONFIG_PANEL_LGPHILIPS_LB035Q02_MODULE)
 	{
diff --git a/arch/arm/mach-omap2/common-board-devices.c b/arch/arm/mach-omap2/common-board-devices.c
new file mode 100644
index 0000000..fad41ec
--- /dev/null
+++ b/arch/arm/mach-omap2/common-board-devices.c
@@ -0,0 +1,85 @@
+/*
+ * common-board-devices.c
+ *
+ * Copyright (C) 2011 CompuLab, Ltd.
+ * Author: Mike Rapoport <mike@compulab.co.il>
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include <linux/gpio.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/ads7846.h>
+
+#include <plat/mcspi.h>
+
+#include "common-board-devices.h"
+
+static struct omap2_mcspi_device_config ads7846_mcspi_config = {
+	.turbo_mode	= 0,
+	.single_channel	= 1,	/* 0: slave, 1: master */
+};
+
+static struct ads7846_platform_data ads7846_config = {
+	.x_max			= 0x0fff,
+	.y_max			= 0x0fff,
+	.x_plate_ohms		= 180,
+	.pressure_max		= 255,
+	.debounce_max		= 10,
+	.debounce_tol		= 3,
+	.debounce_rep		= 1,
+	.gpio_pendown		= -EINVAL,
+	.keep_vref_on		= 1,
+};
+
+static struct spi_board_info ads7846_spi_board_info __initdata = {
+	.modalias		= "ads7846",
+	.bus_num		= -EINVAL,
+	.chip_select		= 0,
+	.max_speed_hz		= 1500000,
+	.controller_data	= &ads7846_mcspi_config,
+	.irq			= -EINVAL,
+	.platform_data		= &ads7846_config,
+};
+
+void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
+			      struct ads7846_platform_data *board_pdata)
+{
+	struct spi_board_info *spi_bi = &ads7846_spi_board_info;
+	int err;
+
+	err = gpio_request(gpio_pendown, "TS PenDown");
+	if (err) {
+		pr_err("Could not obtain gpio for TS PenDown: %d\n", err);
+		return;
+	}
+
+	gpio_direction_input(gpio_pendown);
+	gpio_export(gpio_pendown, 0);
+
+	if (gpio_debounce)
+		gpio_set_debounce(gpio_pendown, gpio_debounce);
+
+	ads7846_config.gpio_pendown = gpio_pendown;
+
+	spi_bi->bus_num	= bus_num;
+	spi_bi->irq	= OMAP_GPIO_IRQ(gpio_pendown);
+
+	if (board_pdata)
+		spi_bi->platform_data = board_pdata;
+
+	spi_register_board_info(&ads7846_spi_board_info, 1);
+}
diff --git a/arch/arm/mach-omap2/common-board-devices.h b/arch/arm/mach-omap2/common-board-devices.h
new file mode 100644
index 0000000..75f9248d
--- /dev/null
+++ b/arch/arm/mach-omap2/common-board-devices.h
@@ -0,0 +1,18 @@
+#ifndef __OMAP_COMMON_BOARD_DEVICES__
+#define __OMAP_COMMON_BOARD_DEVICES__
+
+#if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
+	defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
+struct ads7846_platform_data;
+
+void omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
+		       struct ads7846_platform_data *board_pdata);
+#else
+static inline void omap_ads7846_init(int bus_num,
+				     int gpio_pendown, int gpio_debounce,
+				     struct ads7846_platform_data *board_data)
+{
+}
+#endif
+
+#endif /* __OMAP_COMMON_BOARD_DEVICES__ */
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 2/4] omap: use common initialization for PMIC i2c bus
  2011-04-24 22:09 [PATCH 0/4] omap: cleanup board files Mike Rapoport
  2011-04-24 22:09 ` [PATCH 1/4] omap: consolidate touch screen initialization among different boards Mike Rapoport
@ 2011-04-24 22:09 ` Mike Rapoport
  2011-04-24 22:09 ` [PATCH 3/4] omap: move detection of NAND CS to common-board-devices Mike Rapoport
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 29+ messages in thread
From: Mike Rapoport @ 2011-04-24 22:09 UTC (permalink / raw)
  To: linux-arm-kernel

Introduce omap_pmic_init that registers i2c bus and PMIC device on that
bus and add omap2/3/4 wrappers for common cases.

Signed-off-by: Mike Rapoport <mike@compulab.co.il>
---
 arch/arm/mach-omap2/board-2430sdp.c          |   13 ++-----------
 arch/arm/mach-omap2/board-3430sdp.c          |   12 +-----------
 arch/arm/mach-omap2/board-4430sdp.c          |   16 ++--------------
 arch/arm/mach-omap2/board-cm-t35.c           |   12 +-----------
 arch/arm/mach-omap2/board-devkit8000.c       |   12 +-----------
 arch/arm/mach-omap2/board-igep0020.c         |   15 ++-------------
 arch/arm/mach-omap2/board-igep0030.c         |   13 ++-----------
 arch/arm/mach-omap2/board-ldp.c              |   12 +-----------
 arch/arm/mach-omap2/board-omap3beagle.c      |   13 ++-----------
 arch/arm/mach-omap2/board-omap3evm.c         |   21 +++------------------
 arch/arm/mach-omap2/board-omap3logic.c       |   13 ++-----------
 arch/arm/mach-omap2/board-omap3pandora.c     |   12 +-----------
 arch/arm/mach-omap2/board-omap3stalker.c     |   21 +++------------------
 arch/arm/mach-omap2/board-omap3touchbook.c   |   12 +-----------
 arch/arm/mach-omap2/board-omap4panda.c       |   17 ++---------------
 arch/arm/mach-omap2/board-overo.c            |   12 +-----------
 arch/arm/mach-omap2/board-rm680.c            |   13 ++-----------
 arch/arm/mach-omap2/board-rx51-peripherals.c |   13 ++-----------
 arch/arm/mach-omap2/board-zoom-peripherals.c |   13 ++-----------
 arch/arm/mach-omap2/common-board-devices.c   |   21 +++++++++++++++++++++
 arch/arm/mach-omap2/common-board-devices.h   |   24 ++++++++++++++++++++++++
 21 files changed, 78 insertions(+), 232 deletions(-)

diff --git a/arch/arm/mach-omap2/board-2430sdp.c b/arch/arm/mach-omap2/board-2430sdp.c
index 1fa6bb8..99b3f2d 100644
--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -41,6 +41,7 @@
 
 #include "mux.h"
 #include "hsmmc.h"
+#include "common-board-devices.h"
 
 #define SDP2430_CS0_BASE	0x04000000
 #define SECONDARY_LCD_GPIO		147
@@ -180,15 +181,6 @@ static struct twl4030_platform_data sdp2430_twldata = {
 	.vmmc1		= &sdp2430_vmmc1,
 };
 
-static struct i2c_board_info __initdata sdp2430_i2c_boardinfo[] = {
-	{
-		I2C_BOARD_INFO("twl4030", 0x48),
-		.flags = I2C_CLIENT_WAKE,
-		.irq = INT_24XX_SYS_NIRQ,
-		.platform_data = &sdp2430_twldata,
-	},
-};
-
 static struct i2c_board_info __initdata sdp2430_i2c1_boardinfo[] = {
 	{
 		I2C_BOARD_INFO("isp1301_omap", 0x2D),
@@ -201,8 +193,7 @@ static int __init omap2430_i2c_init(void)
 {
 	omap_register_i2c_bus(1, 100, sdp2430_i2c1_boardinfo,
 			ARRAY_SIZE(sdp2430_i2c1_boardinfo));
-	omap_register_i2c_bus(2, 2600, sdp2430_i2c_boardinfo,
-			ARRAY_SIZE(sdp2430_i2c_boardinfo));
+	omap2_pmic_init("twl4030", &sdp2430_twldata);
 	return 0;
 }
 
diff --git a/arch/arm/mach-omap2/board-3430sdp.c b/arch/arm/mach-omap2/board-3430sdp.c
index 3726465..b12400e 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -528,20 +528,10 @@ static struct twl4030_platform_data sdp3430_twldata = {
 	.vpll2		= &sdp3430_vpll2,
 };
 
-static struct i2c_board_info __initdata sdp3430_i2c_boardinfo[] = {
-	{
-		I2C_BOARD_INFO("twl4030", 0x48),
-		.flags = I2C_CLIENT_WAKE,
-		.irq = INT_34XX_SYS_NIRQ,
-		.platform_data = &sdp3430_twldata,
-	},
-};
-
 static int __init omap3430_i2c_init(void)
 {
 	/* i2c1 for PMIC only */
-	omap_register_i2c_bus(1, 2600, sdp3430_i2c_boardinfo,
-			ARRAY_SIZE(sdp3430_i2c_boardinfo));
+	omap3_pmic_init("twl4030", &sdp3430_twldata);
 	/* i2c2 on camera connector (for sensor control) and optional isp1301 */
 	omap_register_i2c_bus(2, 400, NULL, 0);
 	/* i2c3 on display connector (for DVI, tfp410) */
diff --git a/arch/arm/mach-omap2/board-4430sdp.c b/arch/arm/mach-omap2/board-4430sdp.c
index 56702c5..7073542 100644
--- a/arch/arm/mach-omap2/board-4430sdp.c
+++ b/arch/arm/mach-omap2/board-4430sdp.c
@@ -42,6 +42,7 @@
 #include "hsmmc.h"
 #include "timer-gp.h"
 #include "control.h"
+#include "common-board-devices.h"
 
 #define ETH_KS8851_IRQ			34
 #define ETH_KS8851_POWER_ON		48
@@ -575,14 +576,6 @@ static struct twl4030_platform_data sdp4430_twldata = {
 	.usb		= &omap4_usbphy_data
 };
 
-static struct i2c_board_info __initdata sdp4430_i2c_boardinfo[] = {
-	{
-		I2C_BOARD_INFO("twl6030", 0x48),
-		.flags = I2C_CLIENT_WAKE,
-		.irq = OMAP44XX_IRQ_SYS_1N,
-		.platform_data = &sdp4430_twldata,
-	},
-};
 static struct i2c_board_info __initdata sdp4430_i2c_3_boardinfo[] = {
 	{
 		I2C_BOARD_INFO("tmp105", 0x48),
@@ -598,12 +591,7 @@ static struct i2c_board_info __initdata sdp4430_i2c_4_boardinfo[] = {
 };
 static int __init omap4_i2c_init(void)
 {
-	/*
-	 * Phoenix Audio IC needs I2C1 to
-	 * start with 400 KHz or less
-	 */
-	omap_register_i2c_bus(1, 400, sdp4430_i2c_boardinfo,
-			ARRAY_SIZE(sdp4430_i2c_boardinfo));
+	omap4_pmic_init("twl6030", &sdp4430_twldata);
 	omap_register_i2c_bus(2, 400, NULL, 0);
 	omap_register_i2c_bus(3, 400, sdp4430_i2c_3_boardinfo,
 				ARRAY_SIZE(sdp4430_i2c_3_boardinfo));
diff --git a/arch/arm/mach-omap2/board-cm-t35.c b/arch/arm/mach-omap2/board-cm-t35.c
index 9e5b8be..1a9e6be 100644
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -539,19 +539,9 @@ static struct twl4030_platform_data cm_t35_twldata = {
 	.vpll2		= &cm_t35_vpll2,
 };
 
-static struct i2c_board_info __initdata cm_t35_i2c_boardinfo[] = {
-	{
-		I2C_BOARD_INFO("tps65930", 0x48),
-		.flags		= I2C_CLIENT_WAKE,
-		.irq		= INT_34XX_SYS_NIRQ,
-		.platform_data	= &cm_t35_twldata,
-	},
-};
-
 static void __init cm_t35_init_i2c(void)
 {
-	omap_register_i2c_bus(1, 2600, cm_t35_i2c_boardinfo,
-			      ARRAY_SIZE(cm_t35_i2c_boardinfo));
+	omap3_pmic_init("tps65930", &cm_t35_twldata);
 }
 
 static void __init cm_t35_init_early(void)
diff --git a/arch/arm/mach-omap2/board-devkit8000.c b/arch/arm/mach-omap2/board-devkit8000.c
index 9f8338d..983f44b 100644
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -366,19 +366,9 @@ static struct twl4030_platform_data devkit8000_twldata = {
 	.keypad		= &devkit8000_kp_data,
 };
 
-static struct i2c_board_info __initdata devkit8000_i2c_boardinfo[] = {
-	{
-		I2C_BOARD_INFO("tps65930", 0x48),
-		.flags = I2C_CLIENT_WAKE,
-		.irq = INT_34XX_SYS_NIRQ,
-		.platform_data = &devkit8000_twldata,
-	},
-};
-
 static int __init devkit8000_i2c_init(void)
 {
-	omap_register_i2c_bus(1, 2600, devkit8000_i2c_boardinfo,
-			ARRAY_SIZE(devkit8000_i2c_boardinfo));
+	omap3_pmic_init("tps65930", &devkit8000_twldata);
 	/* Bus 3 is attached to the DVI port where devices like the pico DLP
 	 * projector don't work reliably with 400kHz */
 	omap_register_i2c_bus(3, 400, NULL, 0);
diff --git a/arch/arm/mach-omap2/board-igep0020.c b/arch/arm/mach-omap2/board-igep0020.c
index 5b9bde7..a0fd10e 100644
--- a/arch/arm/mach-omap2/board-igep0020.c
+++ b/arch/arm/mach-omap2/board-igep0020.c
@@ -38,6 +38,7 @@
 #include "mux.h"
 #include "hsmmc.h"
 #include "sdram-numonyx-m65kxxxxam.h"
+#include "common-board-devices.h"
 
 #define IGEP2_SMSC911X_CS       5
 #define IGEP2_SMSC911X_GPIO     176
@@ -536,15 +537,6 @@ static struct twl4030_platform_data igep2_twldata = {
 	.vio		= &igep2_vio,
 };
 
-static struct i2c_board_info __initdata igep2_i2c1_boardinfo[] = {
-	{
-		I2C_BOARD_INFO("twl4030", 0x48),
-		.flags		= I2C_CLIENT_WAKE,
-		.irq		= INT_34XX_SYS_NIRQ,
-		.platform_data	= &igep2_twldata,
-	},
-};
-
 static struct i2c_board_info __initdata igep2_i2c3_boardinfo[] = {
 	{
 		I2C_BOARD_INFO("eeprom", 0x50),
@@ -555,10 +547,7 @@ static void __init igep2_i2c_init(void)
 {
 	int ret;
 
-	ret = omap_register_i2c_bus(1, 2600, igep2_i2c1_boardinfo,
-		ARRAY_SIZE(igep2_i2c1_boardinfo));
-	if (ret)
-		pr_warning("IGEP2: Could not register I2C1 bus (%d)\n", ret);
+	omap3_pmic_init("twl4030", &igep2_twldata);
 
 	/*
 	 * Bus 3 is attached to the DVI port where devices like the pico DLP
diff --git a/arch/arm/mach-omap2/board-igep0030.c b/arch/arm/mach-omap2/board-igep0030.c
index 2cf86c3..a831e85 100644
--- a/arch/arm/mach-omap2/board-igep0030.c
+++ b/arch/arm/mach-omap2/board-igep0030.c
@@ -35,6 +35,7 @@
 #include "mux.h"
 #include "hsmmc.h"
 #include "sdram-numonyx-m65kxxxxam.h"
+#include "common-board-devices.h"
 
 #define IGEP3_GPIO_LED0_GREEN	54
 #define IGEP3_GPIO_LED0_RED	53
@@ -349,19 +350,9 @@ static struct twl4030_platform_data igep3_twl4030_pdata = {
 	.vio		= &igep3_vio,
 };
 
-static struct i2c_board_info __initdata igep3_i2c_boardinfo[] = {
-	{
-		I2C_BOARD_INFO("twl4030", 0x48),
-		.flags		= I2C_CLIENT_WAKE,
-		.irq		= INT_34XX_SYS_NIRQ,
-		.platform_data	= &igep3_twl4030_pdata,
-	},
-};
-
 static int __init igep3_i2c_init(void)
 {
-	omap_register_i2c_bus(1, 2600, igep3_i2c_boardinfo,
-			ARRAY_SIZE(igep3_i2c_boardinfo));
+	omap3_pmic_init("twl4030", &igep3_twl4030_pdata);
 
 	return 0;
 }
diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
index 155b423..7482c75 100644
--- a/arch/arm/mach-omap2/board-ldp.c
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -265,19 +265,9 @@ static struct twl4030_platform_data ldp_twldata = {
 	.keypad		= &ldp_kp_twl4030_data,
 };
 
-static struct i2c_board_info __initdata ldp_i2c_boardinfo[] = {
-	{
-		I2C_BOARD_INFO("twl4030", 0x48),
-		.flags = I2C_CLIENT_WAKE,
-		.irq = INT_34XX_SYS_NIRQ,
-		.platform_data = &ldp_twldata,
-	},
-};
-
 static int __init omap_i2c_init(void)
 {
-	omap_register_i2c_bus(1, 2600, ldp_i2c_boardinfo,
-			ARRAY_SIZE(ldp_i2c_boardinfo));
+	omap3_pmic_init("twl4030", &ldp_twldata);
 	omap_register_i2c_bus(2, 400, NULL, 0);
 	omap_register_i2c_bus(3, 400, NULL, 0);
 	return 0;
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 33007fd..13a1664 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -52,6 +52,7 @@
 #include "hsmmc.h"
 #include "timer-gp.h"
 #include "pm.h"
+#include "common-board-devices.h"
 
 #define NAND_BLOCK_SIZE		SZ_128K
 
@@ -453,15 +454,6 @@ static struct twl4030_platform_data beagle_twldata = {
 	.vpll2		= &beagle_vpll2,
 };
 
-static struct i2c_board_info __initdata beagle_i2c_boardinfo[] = {
-	{
-		I2C_BOARD_INFO("twl4030", 0x48),
-		.flags = I2C_CLIENT_WAKE,
-		.irq = INT_34XX_SYS_NIRQ,
-		.platform_data = &beagle_twldata,
-	},
-};
-
 static struct i2c_board_info __initdata beagle_i2c_eeprom[] = {
        {
                I2C_BOARD_INFO("eeprom", 0x50),
@@ -470,8 +462,7 @@ static struct i2c_board_info __initdata beagle_i2c_eeprom[] = {
 
 static int __init omap3_beagle_i2c_init(void)
 {
-	omap_register_i2c_bus(1, 2600, beagle_i2c_boardinfo,
-			ARRAY_SIZE(beagle_i2c_boardinfo));
+	omap3_pmic_init("twl4030", &beagle_twldata);
 	/* Bus 3 is attached to the DVI port where devices like the pico DLP
 	 * projector don't work reliably with 400kHz */
 	omap_register_i2c_bus(3, 100, beagle_i2c_eeprom, ARRAY_SIZE(beagle_i2c_eeprom));
diff --git a/arch/arm/mach-omap2/board-omap3evm.c b/arch/arm/mach-omap2/board-omap3evm.c
index 376ea87..5066b0b 100644
--- a/arch/arm/mach-omap2/board-omap3evm.c
+++ b/arch/arm/mach-omap2/board-omap3evm.c
@@ -604,28 +604,13 @@ static struct twl4030_platform_data omap3evm_twldata = {
 	.vdac		= &omap3_evm_vdac,
 	.vpll2		= &omap3_evm_vpll2,
 	.vio		= &omap3evm_vio,
-};
-
-static struct i2c_board_info __initdata omap3evm_i2c_boardinfo[] = {
-	{
-		I2C_BOARD_INFO("twl4030", 0x48),
-		.flags = I2C_CLIENT_WAKE,
-		.irq = INT_34XX_SYS_NIRQ,
-		.platform_data = &omap3evm_twldata,
-	},
+	.vmmc1		= &omap3evm_vmmc1,
+	.vsim		= &omap3evm_vsim,
 };
 
 static int __init omap3_evm_i2c_init(void)
 {
-	/*
-	 * REVISIT: These entries can be set in omap3evm_twl_data
-	 * after a merge with MFD tree
-	 */
-	omap3evm_twldata.vmmc1 = &omap3evm_vmmc1;
-	omap3evm_twldata.vsim = &omap3evm_vsim;
-
-	omap_register_i2c_bus(1, 2600, omap3evm_i2c_boardinfo,
-			ARRAY_SIZE(omap3evm_i2c_boardinfo));
+	omap3_pmic_init("twl4030", &omap3evm_twldata);
 	omap_register_i2c_bus(2, 400, NULL, 0);
 	omap_register_i2c_bus(3, 400, NULL, 0);
 	return 0;
diff --git a/arch/arm/mach-omap2/board-omap3logic.c b/arch/arm/mach-omap2/board-omap3logic.c
index a49e6cf..60d9be4 100644
--- a/arch/arm/mach-omap2/board-omap3logic.c
+++ b/arch/arm/mach-omap2/board-omap3logic.c
@@ -37,6 +37,7 @@
 #include "hsmmc.h"
 #include "timer-gp.h"
 #include "control.h"
+#include "common-board-devices.h"
 
 #include <plat/mux.h>
 #include <plat/board.h>
@@ -93,19 +94,9 @@ static struct twl4030_platform_data omap3logic_twldata = {
 	.vmmc1		= &omap3logic_vmmc1,
 };
 
-static struct i2c_board_info __initdata omap3logic_i2c_boardinfo[] = {
-	{
-		I2C_BOARD_INFO("twl4030", 0x48),
-		.flags = I2C_CLIENT_WAKE,
-		.irq = INT_34XX_SYS_NIRQ,
-		.platform_data = &omap3logic_twldata,
-	},
-};
-
 static int __init omap3logic_i2c_init(void)
 {
-	omap_register_i2c_bus(1, 2600, omap3logic_i2c_boardinfo,
-				ARRAY_SIZE(omap3logic_i2c_boardinfo));
+	omap3_pmic_init("twl4030", &omap3logic_twldata);
 	return 0;
 }
 
diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
index 517701a..b99cc64 100644
--- a/arch/arm/mach-omap2/board-omap3pandora.c
+++ b/arch/arm/mach-omap2/board-omap3pandora.c
@@ -544,15 +544,6 @@ static struct twl4030_platform_data omap3pandora_twldata = {
 	.bci		= &pandora_bci_data,
 };
 
-static struct i2c_board_info __initdata omap3pandora_i2c_boardinfo[] = {
-	{
-		I2C_BOARD_INFO("tps65950", 0x48),
-		.flags = I2C_CLIENT_WAKE,
-		.irq = INT_34XX_SYS_NIRQ,
-		.platform_data = &omap3pandora_twldata,
-	},
-};
-
 static struct i2c_board_info __initdata omap3pandora_i2c3_boardinfo[] = {
 	{
 		I2C_BOARD_INFO("bq27500", 0x55),
@@ -562,8 +553,7 @@ static struct i2c_board_info __initdata omap3pandora_i2c3_boardinfo[] = {
 
 static int __init omap3pandora_i2c_init(void)
 {
-	omap_register_i2c_bus(1, 2600, omap3pandora_i2c_boardinfo,
-			ARRAY_SIZE(omap3pandora_i2c_boardinfo));
+	omap3_pmic_init("tps65950", &omap3pandora_twldata);
 	/* i2c2 pins are not connected */
 	omap_register_i2c_bus(3, 100, omap3pandora_i2c3_boardinfo,
 			ARRAY_SIZE(omap3pandora_i2c3_boardinfo));
diff --git a/arch/arm/mach-omap2/board-omap3stalker.c b/arch/arm/mach-omap2/board-omap3stalker.c
index 671ceb0..a1d550f 100644
--- a/arch/arm/mach-omap2/board-omap3stalker.c
+++ b/arch/arm/mach-omap2/board-omap3stalker.c
@@ -455,15 +455,8 @@ static struct twl4030_platform_data omap3stalker_twldata = {
 	.codec		= &omap3stalker_codec_data,
 	.vdac		= &omap3_stalker_vdac,
 	.vpll2		= &omap3_stalker_vpll2,
-};
-
-static struct i2c_board_info __initdata omap3stalker_i2c_boardinfo[] = {
-	{
-	 I2C_BOARD_INFO("twl4030", 0x48),
-	 .flags		= I2C_CLIENT_WAKE,
-	 .irq		= INT_34XX_SYS_NIRQ,
-	 .platform_data	= &omap3stalker_twldata,
-	 },
+	.vmmc1		= &omap3stalker_vmmc1,
+	.vsim		= &omap3stalker_vsim,
 };
 
 static struct at24_platform_data fram_info = {
@@ -482,15 +475,7 @@ static struct i2c_board_info __initdata omap3stalker_i2c_boardinfo3[] = {
 
 static int __init omap3_stalker_i2c_init(void)
 {
-	/*
-	 * REVISIT: These entries can be set in omap3evm_twl_data
-	 * after a merge with MFD tree
-	 */
-	omap3stalker_twldata.vmmc1 = &omap3stalker_vmmc1;
-	omap3stalker_twldata.vsim = &omap3stalker_vsim;
-
-	omap_register_i2c_bus(1, 2600, omap3stalker_i2c_boardinfo,
-			      ARRAY_SIZE(omap3stalker_i2c_boardinfo));
+	omap3_pmic_init("twl4030", &omap3stalker_twldata);
 	omap_register_i2c_bus(2, 400, NULL, 0);
 	omap_register_i2c_bus(3, 400, omap3stalker_i2c_boardinfo3,
 			      ARRAY_SIZE(omap3stalker_i2c_boardinfo3));
diff --git a/arch/arm/mach-omap2/board-omap3touchbook.c b/arch/arm/mach-omap2/board-omap3touchbook.c
index 15f9d7d..0a9b329 100644
--- a/arch/arm/mach-omap2/board-omap3touchbook.c
+++ b/arch/arm/mach-omap2/board-omap3touchbook.c
@@ -274,15 +274,6 @@ static struct twl4030_platform_data touchbook_twldata = {
 	.vpll2		= &touchbook_vpll2,
 };
 
-static struct i2c_board_info __initdata touchbook_i2c_boardinfo[] = {
-	{
-		I2C_BOARD_INFO("twl4030", 0x48),
-		.flags = I2C_CLIENT_WAKE,
-		.irq = INT_34XX_SYS_NIRQ,
-		.platform_data = &touchbook_twldata,
-	},
-};
-
 static struct i2c_board_info __initdata touchBook_i2c_boardinfo[] = {
 	{
 		I2C_BOARD_INFO("bq27200", 0x55),
@@ -292,8 +283,7 @@ static struct i2c_board_info __initdata touchBook_i2c_boardinfo[] = {
 static int __init omap3_touchbook_i2c_init(void)
 {
 	/* Standard TouchBook bus */
-	omap_register_i2c_bus(1, 2600, touchbook_i2c_boardinfo,
-			ARRAY_SIZE(touchbook_i2c_boardinfo));
+	omap3_pmic_init("twl4030", &touchbook_twldata);
 
 	/* Additional TouchBook bus */
 	omap_register_i2c_bus(3, 100, touchBook_i2c_boardinfo,
diff --git a/arch/arm/mach-omap2/board-omap4panda.c b/arch/arm/mach-omap2/board-omap4panda.c
index f3a7b10..7eaad62 100644
--- a/arch/arm/mach-omap2/board-omap4panda.c
+++ b/arch/arm/mach-omap2/board-omap4panda.c
@@ -46,6 +46,7 @@
 #include "hsmmc.h"
 #include "control.h"
 #include "mux.h"
+#include "common-board-devices.h"
 
 #define GPIO_HUB_POWER		1
 #define GPIO_HUB_NRESET		62
@@ -408,15 +409,6 @@ static struct twl4030_platform_data omap4_panda_twldata = {
 	.usb		= &omap4_usbphy_data,
 };
 
-static struct i2c_board_info __initdata omap4_panda_i2c_boardinfo[] = {
-	{
-		I2C_BOARD_INFO("twl6030", 0x48),
-		.flags = I2C_CLIENT_WAKE,
-		.irq = OMAP44XX_IRQ_SYS_1N,
-		.platform_data = &omap4_panda_twldata,
-	},
-};
-
 /*
  * Display monitor features are burnt in their EEPROM as EDID data. The EEPROM
  * is connected as I2C slave device, and can be accessed at address 0x50
@@ -429,12 +421,7 @@ static struct i2c_board_info __initdata panda_i2c_eeprom[] = {
 
 static int __init omap4_panda_i2c_init(void)
 {
-	/*
-	 * Phoenix Audio IC needs I2C1 to
-	 * start with 400 KHz or less
-	 */
-	omap_register_i2c_bus(1, 400, omap4_panda_i2c_boardinfo,
-			ARRAY_SIZE(omap4_panda_i2c_boardinfo));
+	omap4_pmic_init("twl6030", &omap4_panda_twldata);
 	omap_register_i2c_bus(2, 400, NULL, 0);
 	/*
 	 * Bus 3 is attached to the DVI port where devices like the pico DLP
diff --git a/arch/arm/mach-omap2/board-overo.c b/arch/arm/mach-omap2/board-overo.c
index abe4f14..d0621dc 100644
--- a/arch/arm/mach-omap2/board-overo.c
+++ b/arch/arm/mach-omap2/board-overo.c
@@ -538,19 +538,9 @@ static struct twl4030_platform_data overo_twldata = {
 	.vpll2		= &overo_vpll2,
 };
 
-static struct i2c_board_info __initdata overo_i2c_boardinfo[] = {
-	{
-		I2C_BOARD_INFO("tps65950", 0x48),
-		.flags = I2C_CLIENT_WAKE,
-		.irq = INT_34XX_SYS_NIRQ,
-		.platform_data = &overo_twldata,
-	},
-};
-
 static int __init overo_i2c_init(void)
 {
-	omap_register_i2c_bus(1, 2600, overo_i2c_boardinfo,
-			ARRAY_SIZE(overo_i2c_boardinfo));
+	omap3_pmic_init("tps65950", &overo_twldata);
 	/* i2c2 pins are used for gpio */
 	omap_register_i2c_bus(3, 400, NULL, 0);
 	return 0;
diff --git a/arch/arm/mach-omap2/board-rm680.c b/arch/arm/mach-omap2/board-rm680.c
index 2af8b05..8e710ff 100644
--- a/arch/arm/mach-omap2/board-rm680.c
+++ b/arch/arm/mach-omap2/board-rm680.c
@@ -31,6 +31,7 @@
 #include "mux.h"
 #include "hsmmc.h"
 #include "sdram-nokia.h"
+#include "common-board-devices.h"
 
 static struct regulator_consumer_supply rm680_vemmc_consumers[] = {
 	REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1"),
@@ -90,19 +91,9 @@ static struct twl4030_platform_data rm680_twl_data = {
 	/* add rest of the children here */
 };
 
-static struct i2c_board_info __initdata rm680_twl_i2c_board_info[] = {
-	{
-		I2C_BOARD_INFO("twl5031", 0x48),
-		.flags		= I2C_CLIENT_WAKE,
-		.irq		= INT_34XX_SYS_NIRQ,
-		.platform_data	= &rm680_twl_data,
-	},
-};
-
 static void __init rm680_i2c_init(void)
 {
-	omap_register_i2c_bus(1, 2900, rm680_twl_i2c_board_info,
-				ARRAY_SIZE(rm680_twl_i2c_board_info));
+	omap_pmic_init(1, 2900, "twl5031", INT_34XX_SYS_NIRQ, &rm680_twl_data);
 	omap_register_i2c_bus(2, 400, NULL, 0);
 	omap_register_i2c_bus(3, 400, NULL, 0);
 }
diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c b/arch/arm/mach-omap2/board-rx51-peripherals.c
index bbcb677..a5bf5e9 100644
--- a/arch/arm/mach-omap2/board-rx51-peripherals.c
+++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
@@ -43,6 +43,7 @@
 
 #include "mux.h"
 #include "hsmmc.h"
+#include "common-board-devices.h"
 
 #define SYSTEM_REV_B_USES_VAUX3	0x1699
 #define SYSTEM_REV_S_USES_VAUX3 0x8
@@ -777,15 +778,6 @@ static struct tpa6130a2_platform_data rx51_tpa6130a2_data __initdata_or_module =
 	.power_gpio		= 98,
 };
 
-static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_1[] = {
-	{
-		I2C_BOARD_INFO("twl5030", 0x48),
-		.flags = I2C_CLIENT_WAKE,
-		.irq = INT_34XX_SYS_NIRQ,
-		.platform_data = &rx51_twldata,
-	},
-};
-
 /* Audio setup data */
 static struct aic3x_setup_data rx51_aic34_setup = {
 	.gpio_func[0] = AIC3X_GPIO1_FUNC_DISABLED,
@@ -833,8 +825,7 @@ static int __init rx51_i2c_init(void)
 		rx51_twldata.vaux3 = &rx51_vaux3_cam;
 	}
 	rx51_twldata.vmmc2 = &rx51_vmmc2;
-	omap_register_i2c_bus(1, 2200, rx51_peripherals_i2c_board_info_1,
-			      ARRAY_SIZE(rx51_peripherals_i2c_board_info_1));
+	omap_pmic_init(1, 2200, "twl5030", INT_34XX_SYS_NIRQ, &rx51_twldata);
 	omap_register_i2c_bus(2, 100, rx51_peripherals_i2c_board_info_2,
 			      ARRAY_SIZE(rx51_peripherals_i2c_board_info_2));
 	omap_register_i2c_bus(3, 400, NULL, 0);
diff --git a/arch/arm/mach-omap2/board-zoom-peripherals.c b/arch/arm/mach-omap2/board-zoom-peripherals.c
index 8dee754..e4870c2 100644
--- a/arch/arm/mach-omap2/board-zoom-peripherals.c
+++ b/arch/arm/mach-omap2/board-zoom-peripherals.c
@@ -31,6 +31,7 @@
 
 #include "mux.h"
 #include "hsmmc.h"
+#include "common-board-devices.h"
 
 #define OMAP_ZOOM_WLAN_PMENA_GPIO	(101)
 #define OMAP_ZOOM_WLAN_IRQ_GPIO		(162)
@@ -349,15 +350,6 @@ static struct twl4030_platform_data zoom_twldata = {
 	.vdac		= &zoom_vdac,
 };
 
-static struct i2c_board_info __initdata zoom_i2c_boardinfo[] = {
-	{
-		I2C_BOARD_INFO("twl5030", 0x48),
-		.flags		= I2C_CLIENT_WAKE,
-		.irq		= INT_34XX_SYS_NIRQ,
-		.platform_data	= &zoom_twldata,
-	},
-};
-
 static int __init omap_i2c_init(void)
 {
 	if (machine_is_omap_zoom2()) {
@@ -365,8 +357,7 @@ static int __init omap_i2c_init(void)
 		zoom_audio_data.hs_extmute = 1;
 		zoom_audio_data.set_hs_extmute = zoom2_set_hs_extmute;
 	}
-	omap_register_i2c_bus(1, 2400, zoom_i2c_boardinfo,
-			ARRAY_SIZE(zoom_i2c_boardinfo));
+	omap_pmic_init(1, 2400, "twl5030", INT_34XX_SYS_NIRQ, &zoom_twldata);
 	omap_register_i2c_bus(2, 400, NULL, 0);
 	omap_register_i2c_bus(3, 400, NULL, 0);
 	return 0;
diff --git a/arch/arm/mach-omap2/common-board-devices.c b/arch/arm/mach-omap2/common-board-devices.c
index fad41ec..cea31dd 100644
--- a/arch/arm/mach-omap2/common-board-devices.c
+++ b/arch/arm/mach-omap2/common-board-devices.c
@@ -20,14 +20,35 @@
  *
  */
 
+#include <linux/i2c.h>
+#include <linux/i2c/twl.h>
+
 #include <linux/gpio.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/ads7846.h>
 
+#include <plat/i2c.h>
 #include <plat/mcspi.h>
 
 #include "common-board-devices.h"
 
+static struct i2c_board_info __initdata pmic_i2c_board_info = {
+	.addr		= 0x48,
+	.flags		= I2C_CLIENT_WAKE,
+};
+
+void __init omap_pmic_init(int bus, u32 clkrate,
+			   const char *pmic_type, int pmic_irq,
+			   struct twl4030_platform_data *pmic_data)
+{
+	strncpy(pmic_i2c_board_info.type, pmic_type,
+		sizeof(pmic_i2c_board_info.type));
+	pmic_i2c_board_info.irq = pmic_irq;
+	pmic_i2c_board_info.platform_data = pmic_data;
+
+	omap_register_i2c_bus(bus, clkrate, &pmic_i2c_board_info, 1);
+}
+
 static struct omap2_mcspi_device_config ads7846_mcspi_config = {
 	.turbo_mode	= 0,
 	.single_channel	= 1,	/* 0: slave, 1: master */
diff --git a/arch/arm/mach-omap2/common-board-devices.h b/arch/arm/mach-omap2/common-board-devices.h
index 75f9248d..0ec3e07 100644
--- a/arch/arm/mach-omap2/common-board-devices.h
+++ b/arch/arm/mach-omap2/common-board-devices.h
@@ -1,6 +1,30 @@
 #ifndef __OMAP_COMMON_BOARD_DEVICES__
 #define __OMAP_COMMON_BOARD_DEVICES__
 
+struct twl4030_platform_data;
+
+void omap_pmic_init(int bus, u32 clkrate, const char *pmic_type, int pmic_irq,
+		    struct twl4030_platform_data *pmic_data);
+
+static inline void omap2_pmic_init(const char *pmic_type,
+				   struct twl4030_platform_data *pmic_data)
+{
+	omap_pmic_init(2, 2600, pmic_type, INT_24XX_SYS_NIRQ, pmic_data);
+}
+
+static inline void omap3_pmic_init(const char *pmic_type,
+				   struct twl4030_platform_data *pmic_data)
+{
+	omap_pmic_init(1, 2600, pmic_type, INT_34XX_SYS_NIRQ, pmic_data);
+}
+
+static inline void omap4_pmic_init(const char *pmic_type,
+				   struct twl4030_platform_data *pmic_data)
+{
+	/* Phoenix Audio IC needs I2C1 to start with 400 KHz or less */
+	omap_pmic_init(1, 400, pmic_type, OMAP44XX_IRQ_SYS_1N, pmic_data);
+}
+
 #if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
 	defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
 struct ads7846_platform_data;
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 3/4] omap: move detection of NAND CS to common-board-devices
  2011-04-24 22:09 [PATCH 0/4] omap: cleanup board files Mike Rapoport
  2011-04-24 22:09 ` [PATCH 1/4] omap: consolidate touch screen initialization among different boards Mike Rapoport
  2011-04-24 22:09 ` [PATCH 2/4] omap: use common initialization for PMIC i2c bus Mike Rapoport
@ 2011-04-24 22:09 ` Mike Rapoport
  2011-05-04  3:12   ` Oleg Drokin
  2011-04-24 22:09 ` [PATCH 4/4] omap: musb: introduce default baord config Mike Rapoport
  2011-05-02 13:57 ` [PATCH 0/4] omap: cleanup board files Mike Rapoport
  4 siblings, 1 reply; 29+ messages in thread
From: Mike Rapoport @ 2011-04-24 22:09 UTC (permalink / raw)
  To: linux-arm-kernel

and reduce amount of copy/paste

Signed-off-by: Mike Rapoport <mike@compulab.co.il>
---
 arch/arm/mach-omap2/board-devkit8000.c     |   43 +-------------------------
 arch/arm/mach-omap2/board-omap3beagle.c    |   45 +--------------------------
 arch/arm/mach-omap2/board-omap3touchbook.c |   45 +--------------------------
 arch/arm/mach-omap2/board-overo.c          |   42 +------------------------
 arch/arm/mach-omap2/common-board-devices.c |   42 ++++++++++++++++++++++++++
 arch/arm/mach-omap2/common-board-devices.h |   10 ++++++
 6 files changed, 60 insertions(+), 167 deletions(-)

diff --git a/arch/arm/mach-omap2/board-devkit8000.c b/arch/arm/mach-omap2/board-devkit8000.c
index 983f44b..e7dc057 100644
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -97,13 +97,6 @@ static struct mtd_partition devkit8000_nand_partitions[] = {
 	},
 };
 
-static struct omap_nand_platform_data devkit8000_nand_data = {
-	.options	= NAND_BUSWIDTH_16,
-	.parts		= devkit8000_nand_partitions,
-	.nr_parts	= ARRAY_SIZE(devkit8000_nand_partitions),
-	.dma_channel	= -1,		/* disable DMA in OMAP NAND driver */
-};
-
 static struct omap2_hsmmc_info mmc[] = {
 	{
 		.mmc		= 1,
@@ -516,39 +509,6 @@ static struct platform_device *devkit8000_devices[] __initdata = {
 	&omap_dm9000_dev,
 };
 
-static void __init devkit8000_flash_init(void)
-{
-	u8 cs = 0;
-	u8 nandcs = GPMC_CS_NUM + 1;
-
-	/* find out the chip-select on which NAND exists */
-	while (cs < GPMC_CS_NUM) {
-		u32 ret = 0;
-		ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
-
-		if ((ret & 0xC00) == 0x800) {
-			printk(KERN_INFO "Found NAND on CS%d\n", cs);
-			if (nandcs > GPMC_CS_NUM)
-				nandcs = cs;
-		}
-		cs++;
-	}
-
-	if (nandcs > GPMC_CS_NUM) {
-		printk(KERN_INFO "NAND: Unable to find configuration "
-				 "in GPMC\n ");
-		return;
-	}
-
-	if (nandcs < GPMC_CS_NUM) {
-		devkit8000_nand_data.cs = nandcs;
-
-		printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
-		if (gpmc_nand_init(&devkit8000_nand_data) < 0)
-			printk(KERN_ERR "Unable to register NAND device\n");
-	}
-}
-
 static struct omap_musb_board_data musb_board_data = {
 	.interface_type		= MUSB_INTERFACE_ULPI,
 	.mode			= MUSB_OTG,
@@ -740,7 +700,8 @@ static void __init devkit8000_init(void)
 
 	usb_musb_init(&musb_board_data);
 	usbhs_init(&usbhs_bdata);
-	devkit8000_flash_init();
+	omap_nand_flash_init(NAND_BUSWIDTH_16, devkit8000_nand_partitions,
+			     ARRAY_SIZE(devkit8000_nand_partitions));
 
 	/* Ensure SDRC pins are mux'd for self-refresh */
 	omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 13a1664..ce3bc2d 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -174,15 +174,6 @@ static struct mtd_partition omap3beagle_nand_partitions[] = {
 	},
 };
 
-static struct omap_nand_platform_data omap3beagle_nand_data = {
-	.options	= NAND_BUSWIDTH_16,
-	.parts		= omap3beagle_nand_partitions,
-	.nr_parts	= ARRAY_SIZE(omap3beagle_nand_partitions),
-	.dma_channel	= -1,		/* disable DMA in OMAP NAND driver */
-	.nand_setup	= NULL,
-	.dev_ready	= NULL,
-};
-
 /* DSS */
 
 static int beagle_enable_dvi(struct omap_dss_device *dssdev)
@@ -542,39 +533,6 @@ static struct platform_device *omap3_beagle_devices[] __initdata = {
 	&keys_gpio,
 };
 
-static void __init omap3beagle_flash_init(void)
-{
-	u8 cs = 0;
-	u8 nandcs = GPMC_CS_NUM + 1;
-
-	/* find out the chip-select on which NAND exists */
-	while (cs < GPMC_CS_NUM) {
-		u32 ret = 0;
-		ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
-
-		if ((ret & 0xC00) == 0x800) {
-			printk(KERN_INFO "Found NAND on CS%d\n", cs);
-			if (nandcs > GPMC_CS_NUM)
-				nandcs = cs;
-		}
-		cs++;
-	}
-
-	if (nandcs > GPMC_CS_NUM) {
-		printk(KERN_INFO "NAND: Unable to find configuration "
-				 "in GPMC\n ");
-		return;
-	}
-
-	if (nandcs < GPMC_CS_NUM) {
-		omap3beagle_nand_data.cs = nandcs;
-
-		printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
-		if (gpmc_nand_init(&omap3beagle_nand_data) < 0)
-			printk(KERN_ERR "Unable to register NAND device\n");
-	}
-}
-
 static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
 
 	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
@@ -662,7 +620,8 @@ static void __init omap3_beagle_init(void)
 
 	usb_musb_init(&musb_board_data);
 	usbhs_init(&usbhs_bdata);
-	omap3beagle_flash_init();
+	omap_nand_flash_init(NAND_BUSWIDTH_16, omap3beagle_nand_partitions,
+			     ARRAY_SIZE(omap3beagle_nand_partitions));
 
 	/* Ensure SDRC pins are mux'd for self-refresh */
 	omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
diff --git a/arch/arm/mach-omap2/board-omap3touchbook.c b/arch/arm/mach-omap2/board-omap3touchbook.c
index 0a9b329..d770802 100644
--- a/arch/arm/mach-omap2/board-omap3touchbook.c
+++ b/arch/arm/mach-omap2/board-omap3touchbook.c
@@ -96,15 +96,6 @@ static struct mtd_partition omap3touchbook_nand_partitions[] = {
 	},
 };
 
-static struct omap_nand_platform_data omap3touchbook_nand_data = {
-	.options	= NAND_BUSWIDTH_16,
-	.parts		= omap3touchbook_nand_partitions,
-	.nr_parts	= ARRAY_SIZE(omap3touchbook_nand_partitions),
-	.dma_channel	= -1,		/* disable DMA in OMAP NAND driver */
-	.nand_setup	= NULL,
-	.dev_ready	= NULL,
-};
-
 #include "sdram-micron-mt46h32m32lf-6.h"
 
 static struct omap2_hsmmc_info mmc[] = {
@@ -396,39 +387,6 @@ static struct platform_device *omap3_touchbook_devices[] __initdata = {
 	&keys_gpio,
 };
 
-static void __init omap3touchbook_flash_init(void)
-{
-	u8 cs = 0;
-	u8 nandcs = GPMC_CS_NUM + 1;
-
-	/* find out the chip-select on which NAND exists */
-	while (cs < GPMC_CS_NUM) {
-		u32 ret = 0;
-		ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
-
-		if ((ret & 0xC00) == 0x800) {
-			printk(KERN_INFO "Found NAND on CS%d\n", cs);
-			if (nandcs > GPMC_CS_NUM)
-				nandcs = cs;
-		}
-		cs++;
-	}
-
-	if (nandcs > GPMC_CS_NUM) {
-		printk(KERN_INFO "NAND: Unable to find configuration "
-				 "in GPMC\n ");
-		return;
-	}
-
-	if (nandcs < GPMC_CS_NUM) {
-		omap3touchbook_nand_data.cs = nandcs;
-
-		printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
-		if (gpmc_nand_init(&omap3touchbook_nand_data) < 0)
-			printk(KERN_ERR "Unable to register NAND device\n");
-	}
-}
-
 static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
 
 	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
@@ -491,7 +449,8 @@ static void __init omap3_touchbook_init(void)
 	omap_ads7846_init(4, OMAP3_TS_GPIO, 310, &ads7846_pdata);
 	usb_musb_init(&musb_board_data);
 	usbhs_init(&usbhs_bdata);
-	omap3touchbook_flash_init();
+	omap_nand_flash_init(NAND_BUSWIDTH_16, omap3touchbook_nand_partitions,
+			     ARRAY_SIZE(omap3touchbook_nand_partitions));
 
 	/* Ensure SDRC pins are mux'd for self-refresh */
 	omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
diff --git a/arch/arm/mach-omap2/board-overo.c b/arch/arm/mach-omap2/board-overo.c
index d0621dc..9212442 100644
--- a/arch/arm/mach-omap2/board-overo.c
+++ b/arch/arm/mach-omap2/board-overo.c
@@ -302,45 +302,6 @@ static struct mtd_partition overo_nand_partitions[] = {
 	},
 };
 
-static struct omap_nand_platform_data overo_nand_data = {
-	.parts = overo_nand_partitions,
-	.nr_parts = ARRAY_SIZE(overo_nand_partitions),
-	.dma_channel = -1,	/* disable DMA in OMAP NAND driver */
-};
-
-static void __init overo_flash_init(void)
-{
-	u8 cs = 0;
-	u8 nandcs = GPMC_CS_NUM + 1;
-
-	/* find out the chip-select on which NAND exists */
-	while (cs < GPMC_CS_NUM) {
-		u32 ret = 0;
-		ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
-
-		if ((ret & 0xC00) == 0x800) {
-			printk(KERN_INFO "Found NAND on CS%d\n", cs);
-			if (nandcs > GPMC_CS_NUM)
-				nandcs = cs;
-		}
-		cs++;
-	}
-
-	if (nandcs > GPMC_CS_NUM) {
-		printk(KERN_INFO "NAND: Unable to find configuration "
-				 "in GPMC\n ");
-		return;
-	}
-
-	if (nandcs < GPMC_CS_NUM) {
-		overo_nand_data.cs = nandcs;
-
-		printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
-		if (gpmc_nand_init(&overo_nand_data) < 0)
-			printk(KERN_ERR "Unable to register NAND device\n");
-	}
-}
-
 static struct omap2_hsmmc_info mmc[] = {
 	{
 		.mmc		= 1,
@@ -602,7 +563,8 @@ static void __init overo_init(void)
 	overo_i2c_init();
 	omap_display_init(&overo_dss_data);
 	omap_serial_init();
-	overo_flash_init();
+	omap_nand_flash_init(0, overo_nand_partitions,
+			     ARRAY_SIZE(overo_nand_partitions));
 	usb_musb_init(&musb_board_data);
 	usbhs_init(&usbhs_bdata);
 	overo_spi_init();
diff --git a/arch/arm/mach-omap2/common-board-devices.c b/arch/arm/mach-omap2/common-board-devices.c
index cea31dd..d57c71d 100644
--- a/arch/arm/mach-omap2/common-board-devices.c
+++ b/arch/arm/mach-omap2/common-board-devices.c
@@ -29,6 +29,7 @@
 
 #include <plat/i2c.h>
 #include <plat/mcspi.h>
+#include <plat/nand.h>
 
 #include "common-board-devices.h"
 
@@ -104,3 +105,44 @@ void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
 
 	spi_register_board_info(&ads7846_spi_board_info, 1);
 }
+
+static struct omap_nand_platform_data nand_data = {
+	.dma_channel	= -1,		/* disable DMA in OMAP NAND driver */
+};
+
+void __init omap_nand_flash_init(int options, struct mtd_partition *parts,
+				 int nr_parts)
+{
+	u8 cs = 0;
+	u8 nandcs = GPMC_CS_NUM + 1;
+
+	/* find out the chip-select on which NAND exists */
+	while (cs < GPMC_CS_NUM) {
+		u32 ret = 0;
+		ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
+
+		if ((ret & 0xC00) == 0x800) {
+			printk(KERN_INFO "Found NAND on CS%d\n", cs);
+			if (nandcs > GPMC_CS_NUM)
+				nandcs = cs;
+		}
+		cs++;
+	}
+
+	if (nandcs > GPMC_CS_NUM) {
+		printk(KERN_INFO "NAND: Unable to find configuration "
+				 "in GPMC\n ");
+		return;
+	}
+
+	if (nandcs < GPMC_CS_NUM) {
+		nand_data.cs = nandcs;
+		nand_data.parts = parts;
+		nand_data.nr_parts = nr_parts;
+		nand_data.options = options;
+
+		printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
+		if (gpmc_nand_init(&nand_data) < 0)
+			printk(KERN_ERR "Unable to register NAND device\n");
+	}
+}
diff --git a/arch/arm/mach-omap2/common-board-devices.h b/arch/arm/mach-omap2/common-board-devices.h
index 0ec3e07..ca03abf 100644
--- a/arch/arm/mach-omap2/common-board-devices.h
+++ b/arch/arm/mach-omap2/common-board-devices.h
@@ -2,6 +2,7 @@
 #define __OMAP_COMMON_BOARD_DEVICES__
 
 struct twl4030_platform_data;
+struct mtd_partition;
 
 void omap_pmic_init(int bus, u32 clkrate, const char *pmic_type, int pmic_irq,
 		    struct twl4030_platform_data *pmic_data);
@@ -39,4 +40,13 @@ static inline void omap_ads7846_init(int bus_num,
 }
 #endif
 
+#if defined(CONFIG_MTD_NAND_OMAP2) || defined(CONFIG_MTD_NAND_OMAP2_MODULE)
+void omap_nand_flash_init(int opts, struct mtd_partition *parts, int n_parts);
+#else
+static inline void omap_nand_flash_init(int opts, struct mtd_partition *parts,
+					int nr_parts)
+{
+}
+#endif
+
 #endif /* __OMAP_COMMON_BOARD_DEVICES__ */
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 4/4] omap: musb: introduce default baord config
  2011-04-24 22:09 [PATCH 0/4] omap: cleanup board files Mike Rapoport
                   ` (2 preceding siblings ...)
  2011-04-24 22:09 ` [PATCH 3/4] omap: move detection of NAND CS to common-board-devices Mike Rapoport
@ 2011-04-24 22:09 ` Mike Rapoport
  2011-04-27  4:23   ` Oleg Drokin
  2011-04-27  8:56   ` [PATCH v2 4/4] omap: musb: introduce default board config Mike Rapoport
  2011-05-02 13:57 ` [PATCH 0/4] omap: cleanup board files Mike Rapoport
  4 siblings, 2 replies; 29+ messages in thread
From: Mike Rapoport @ 2011-04-24 22:09 UTC (permalink / raw)
  To: linux-arm-kernel

Most boards use exactly the same configuration for musb initialization.
Create a default that can be shared amount different boards.

Signed-off-by: Mike Rapoport <mike@compulab.co.il>
---
 arch/arm/mach-omap2/board-2430sdp.c          |    7 +------
 arch/arm/mach-omap2/board-3430sdp.c          |    8 +-------
 arch/arm/mach-omap2/board-cm-t35.c           |    8 +-------
 arch/arm/mach-omap2/board-devkit8000.c       |    8 +-------
 arch/arm/mach-omap2/board-igep0020.c         |    8 +-------
 arch/arm/mach-omap2/board-igep0030.c         |    8 +-------
 arch/arm/mach-omap2/board-ldp.c              |    8 +-------
 arch/arm/mach-omap2/board-omap3beagle.c      |    8 +-------
 arch/arm/mach-omap2/board-omap3pandora.c     |    8 +-------
 arch/arm/mach-omap2/board-omap3stalker.c     |    8 +-------
 arch/arm/mach-omap2/board-omap3touchbook.c   |    8 +-------
 arch/arm/mach-omap2/board-overo.c            |    8 +-------
 arch/arm/mach-omap2/board-rm680.c            |    8 +-------
 arch/arm/mach-omap2/board-zoom-peripherals.c |    8 +-------
 arch/arm/mach-omap2/usb-musb.c               |   14 +++++++++++++-
 15 files changed, 27 insertions(+), 98 deletions(-)

diff --git a/arch/arm/mach-omap2/board-2430sdp.c b/arch/arm/mach-omap2/board-2430sdp.c
index 99b3f2d..a8810f8 100644
--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -208,11 +208,6 @@ static struct omap2_hsmmc_info mmc[] __initdata = {
 	{}	/* Terminator */
 };
 
-static struct omap_musb_board_data musb_board_data = {
-	.interface_type		= MUSB_INTERFACE_ULPI,
-	.mode			= MUSB_OTG,
-	.power			= 100,
-};
 static struct omap_usb_config sdp2430_usb_config __initdata = {
 	.otg		= 1,
 #ifdef  CONFIG_USB_GADGET_OMAP
@@ -246,7 +241,7 @@ static void __init omap_2430sdp_init(void)
 	omap2_usbfs_init(&sdp2430_usb_config);
 
 	omap_mux_init_signal("usb0hs_stp", OMAP_PULL_ENA | OMAP_PULL_UP);
-	usb_musb_init(&musb_board_data);
+	usb_musb_init(NULL);
 
 	board_smc91x_init();
 
diff --git a/arch/arm/mach-omap2/board-3430sdp.c b/arch/arm/mach-omap2/board-3430sdp.c
index b12400e..951e585 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -810,12 +810,6 @@ static struct flash_partitions sdp_flash_partitions[] = {
 	},
 };
 
-static struct omap_musb_board_data musb_board_data = {
-	.interface_type		= MUSB_INTERFACE_ULPI,
-	.mode			= MUSB_OTG,
-	.power			= 100,
-};
-
 static void __init omap_3430sdp_init(void)
 {
 	int gpio_pendown;
@@ -832,7 +826,7 @@ static void __init omap_3430sdp_init(void)
 		gpio_pendown = SDP3430_TS_GPIO_IRQ_SDPV1;
 	omap_ads7846_init(1, gpio_pendown, 310, NULL);
 	board_serial_init();
-	usb_musb_init(&musb_board_data);
+	usb_musb_init(NULL);
 	board_smc91x_init();
 	board_flash_init(sdp_flash_partitions, chip_sel_3430, 0);
 	sdp3430_display_init();
diff --git a/arch/arm/mach-omap2/board-cm-t35.c b/arch/arm/mach-omap2/board-cm-t35.c
index 1a9e6be..286da17 100644
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -651,12 +651,6 @@ static struct omap_board_mux board_mux[] __initdata = {
 };
 #endif
 
-static struct omap_musb_board_data musb_board_data = {
-	.interface_type		= MUSB_INTERFACE_ULPI,
-	.mode			= MUSB_OTG,
-	.power			= 100,
-};
-
 static struct omap_board_config_kernel cm_t35_config[] __initdata = {
 };
 
@@ -673,7 +667,7 @@ static void __init cm_t35_init(void)
 	cm_t35_init_led();
 	cm_t35_init_display();
 
-	usb_musb_init(&musb_board_data);
+	usb_musb_init(NULL);
 	usbhs_init(&usbhs_bdata);
 }
 
diff --git a/arch/arm/mach-omap2/board-devkit8000.c b/arch/arm/mach-omap2/board-devkit8000.c
index e7dc057..405542a 100644
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -509,12 +509,6 @@ static struct platform_device *devkit8000_devices[] __initdata = {
 	&omap_dm9000_dev,
 };
 
-static struct omap_musb_board_data musb_board_data = {
-	.interface_type		= MUSB_INTERFACE_ULPI,
-	.mode			= MUSB_OTG,
-	.power			= 100,
-};
-
 static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
 
 	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
@@ -698,7 +692,7 @@ static void __init devkit8000_init(void)
 
 	omap_ads7846_init(2, OMAP3_DEVKIT_TS_GPIO, 0, NULL);
 
-	usb_musb_init(&musb_board_data);
+	usb_musb_init(NULL);
 	usbhs_init(&usbhs_bdata);
 	omap_nand_flash_init(NAND_BUSWIDTH_16, devkit8000_nand_partitions,
 			     ARRAY_SIZE(devkit8000_nand_partitions));
diff --git a/arch/arm/mach-omap2/board-igep0020.c b/arch/arm/mach-omap2/board-igep0020.c
index a0fd10e..2c9a919 100644
--- a/arch/arm/mach-omap2/board-igep0020.c
+++ b/arch/arm/mach-omap2/board-igep0020.c
@@ -559,12 +559,6 @@ static void __init igep2_i2c_init(void)
 		pr_warning("IGEP2: Could not register I2C3 bus (%d)\n", ret);
 }
 
-static struct omap_musb_board_data musb_board_data = {
-	.interface_type		= MUSB_INTERFACE_ULPI,
-	.mode			= MUSB_OTG,
-	.power			= 100,
-};
-
 static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
 	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
 	.port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
@@ -637,7 +631,7 @@ static void __init igep2_init(void)
 	platform_add_devices(igep2_devices, ARRAY_SIZE(igep2_devices));
 	omap_display_init(&igep2_dss_data);
 	omap_serial_init();
-	usb_musb_init(&musb_board_data);
+	usb_musb_init(NULL);
 	usbhs_init(&usbhs_bdata);
 
 	igep2_flash_init();
diff --git a/arch/arm/mach-omap2/board-igep0030.c b/arch/arm/mach-omap2/board-igep0030.c
index a831e85..512a7eb 100644
--- a/arch/arm/mach-omap2/board-igep0030.c
+++ b/arch/arm/mach-omap2/board-igep0030.c
@@ -357,12 +357,6 @@ static int __init igep3_i2c_init(void)
 	return 0;
 }
 
-static struct omap_musb_board_data musb_board_data = {
-	.interface_type	= MUSB_INTERFACE_ULPI,
-	.mode		= MUSB_OTG,
-	.power		= 100,
-};
-
 #if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE)
 
 static void __init igep3_wifi_bt_init(void)
@@ -424,7 +418,7 @@ static void __init igep3_init(void)
 	igep3_i2c_init();
 	platform_add_devices(igep3_devices, ARRAY_SIZE(igep3_devices));
 	omap_serial_init();
-	usb_musb_init(&musb_board_data);
+	usb_musb_init(NULL);
 	usbhs_init(&usbhs_bdata);
 
 	igep3_flash_init();
diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
index 7482c75..f7d6038 100644
--- a/arch/arm/mach-omap2/board-ldp.c
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -294,12 +294,6 @@ static struct omap_board_mux board_mux[] __initdata = {
 };
 #endif
 
-static struct omap_musb_board_data musb_board_data = {
-	.interface_type		= MUSB_INTERFACE_ULPI,
-	.mode			= MUSB_OTG,
-	.power			= 100,
-};
-
 static struct mtd_partition ldp_nand_partitions[] = {
 	/* All the partition sizes are listed in terms of NAND block size */
 	{
@@ -342,7 +336,7 @@ static void __init omap_ldp_init(void)
 	platform_add_devices(ldp_devices, ARRAY_SIZE(ldp_devices));
 	omap_ads7846_init(1, 54, 310, NULL);
 	omap_serial_init();
-	usb_musb_init(&musb_board_data);
+	usb_musb_init(NULL);
 	board_nand_init(ldp_nand_partitions,
 		ARRAY_SIZE(ldp_nand_partitions), ZOOM_NAND_CS, 0);
 
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index ce3bc2d..bc30ab0 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -551,12 +551,6 @@ static struct omap_board_mux board_mux[] __initdata = {
 };
 #endif
 
-static struct omap_musb_board_data musb_board_data = {
-	.interface_type		= MUSB_INTERFACE_ULPI,
-	.mode			= MUSB_OTG,
-	.power			= 100,
-};
-
 static void __init beagle_opp_init(void)
 {
 	int r = 0;
@@ -618,7 +612,7 @@ static void __init omap3_beagle_init(void)
 	/* REVISIT leave DVI powered down until it's needed ... */
 	gpio_direction_output(170, true);
 
-	usb_musb_init(&musb_board_data);
+	usb_musb_init(NULL);
 	usbhs_init(&usbhs_bdata);
 	omap_nand_flash_init(NAND_BUSWIDTH_16, omap3beagle_nand_partitions,
 			     ARRAY_SIZE(omap3beagle_nand_partitions));
diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
index b99cc64..6c22d3f 100644
--- a/arch/arm/mach-omap2/board-omap3pandora.c
+++ b/arch/arm/mach-omap2/board-omap3pandora.c
@@ -633,12 +633,6 @@ static struct omap_board_mux board_mux[] __initdata = {
 };
 #endif
 
-static struct omap_musb_board_data musb_board_data = {
-	.interface_type		= MUSB_INTERFACE_ULPI,
-	.mode			= MUSB_OTG,
-	.power			= 100,
-};
-
 static void __init omap3pandora_init(void)
 {
 	omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
@@ -652,7 +646,7 @@ static void __init omap3pandora_init(void)
 			ARRAY_SIZE(omap3pandora_spi_board_info));
 	omap_ads7846_init(1, OMAP3_PANDORA_TS_GPIO, 0, NULL);
 	usbhs_init(&usbhs_bdata);
-	usb_musb_init(&musb_board_data);
+	usb_musb_init(NULL);
 	gpmc_nand_init(&pandora_nand_data);
 
 	/* Ensure SDRC pins are mux'd for self-refresh */
diff --git a/arch/arm/mach-omap2/board-omap3stalker.c b/arch/arm/mach-omap2/board-omap3stalker.c
index a1d550f..9981d06 100644
--- a/arch/arm/mach-omap2/board-omap3stalker.c
+++ b/arch/arm/mach-omap2/board-omap3stalker.c
@@ -526,12 +526,6 @@ static struct omap_board_mux board_mux[] __initdata = {
 };
 #endif
 
-static struct omap_musb_board_data musb_board_data = {
-	.interface_type	= MUSB_INTERFACE_ULPI,
-	.mode		= MUSB_OTG,
-	.power		= 100,
-};
-
 static void __init omap3_stalker_init(void)
 {
 	omap3_mux_init(board_mux, OMAP_PACKAGE_CUS);
@@ -546,7 +540,7 @@ static void __init omap3_stalker_init(void)
 	omap_display_init(&omap3_stalker_dss_data);
 
 	omap_serial_init();
-	usb_musb_init(&musb_board_data);
+	usb_musb_init(NULL);
 	usbhs_init(&usbhs_bdata);
 	omap_ads7846_init(1, OMAP3_STALKER_TS_GPIO, 310, NULL);
 
diff --git a/arch/arm/mach-omap2/board-omap3touchbook.c b/arch/arm/mach-omap2/board-omap3touchbook.c
index d770802..392278d 100644
--- a/arch/arm/mach-omap2/board-omap3touchbook.c
+++ b/arch/arm/mach-omap2/board-omap3touchbook.c
@@ -421,12 +421,6 @@ static int __init early_touchbook_revision(char *p)
 }
 early_param("tbr", early_touchbook_revision);
 
-static struct omap_musb_board_data musb_board_data = {
-	.interface_type		= MUSB_INTERFACE_ULPI,
-	.mode			= MUSB_OTG,
-	.power			= 100,
-};
-
 static void __init omap3_touchbook_init(void)
 {
 	omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
@@ -447,7 +441,7 @@ static void __init omap3_touchbook_init(void)
 
 	/* Touchscreen and accelerometer */
 	omap_ads7846_init(4, OMAP3_TS_GPIO, 310, &ads7846_pdata);
-	usb_musb_init(&musb_board_data);
+	usb_musb_init(NULL);
 	usbhs_init(&usbhs_bdata);
 	omap_nand_flash_init(NAND_BUSWIDTH_16, omap3touchbook_nand_partitions,
 			     ARRAY_SIZE(omap3touchbook_nand_partitions));
diff --git a/arch/arm/mach-omap2/board-overo.c b/arch/arm/mach-omap2/board-overo.c
index 9212442..c7ec7fa 100644
--- a/arch/arm/mach-omap2/board-overo.c
+++ b/arch/arm/mach-omap2/board-overo.c
@@ -551,12 +551,6 @@ static struct omap_board_mux board_mux[] __initdata = {
 };
 #endif
 
-static struct omap_musb_board_data musb_board_data = {
-	.interface_type		= MUSB_INTERFACE_ULPI,
-	.mode			= MUSB_OTG,
-	.power			= 100,
-};
-
 static void __init overo_init(void)
 {
 	omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
@@ -565,7 +559,7 @@ static void __init overo_init(void)
 	omap_serial_init();
 	omap_nand_flash_init(0, overo_nand_partitions,
 			     ARRAY_SIZE(overo_nand_partitions));
-	usb_musb_init(&musb_board_data);
+	usb_musb_init(NULL);
 	usbhs_init(&usbhs_bdata);
 	overo_spi_init();
 	overo_ads7846_init();
diff --git a/arch/arm/mach-omap2/board-rm680.c b/arch/arm/mach-omap2/board-rm680.c
index 8e710ff..42d10b1 100644
--- a/arch/arm/mach-omap2/board-rm680.c
+++ b/arch/arm/mach-omap2/board-rm680.c
@@ -144,17 +144,11 @@ static struct omap_board_mux board_mux[] __initdata = {
 };
 #endif
 
-static struct omap_musb_board_data rm680_musb_data = {
-	.interface_type	= MUSB_INTERFACE_ULPI,
-	.mode		= MUSB_PERIPHERAL,
-	.power		= 100,
-};
-
 static void __init rm680_init(void)
 {
 	omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
 	omap_serial_init();
-	usb_musb_init(&rm680_musb_data);
+	usb_musb_init(NULL);
 	rm680_peripherals_init();
 }
 
diff --git a/arch/arm/mach-omap2/board-zoom-peripherals.c b/arch/arm/mach-omap2/board-zoom-peripherals.c
index e4870c2..489294a 100644
--- a/arch/arm/mach-omap2/board-zoom-peripherals.c
+++ b/arch/arm/mach-omap2/board-zoom-peripherals.c
@@ -363,12 +363,6 @@ static int __init omap_i2c_init(void)
 	return 0;
 }
 
-static struct omap_musb_board_data musb_board_data = {
-	.interface_type		= MUSB_INTERFACE_ULPI,
-	.mode			= MUSB_OTG,
-	.power			= 100,
-};
-
 static void enable_board_wakeup_source(void)
 {
 	/* T2 interrupt line (keypad) */
@@ -383,7 +377,7 @@ void __init zoom_peripherals_init(void)
 
 	omap_i2c_init();
 	platform_device_register(&omap_vwlan_device);
-	usb_musb_init(&musb_board_data);
+	usb_musb_init(NULL);
 	enable_board_wakeup_source();
 	omap_serial_init();
 }
diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c
index 35559f7..dfa5a3c 100644
--- a/arch/arm/mach-omap2/usb-musb.c
+++ b/arch/arm/mach-omap2/usb-musb.c
@@ -108,7 +108,13 @@ static void usb_musb_mux_init(struct omap_musb_board_data *board_data)
 	}
 }
 
-void __init usb_musb_init(struct omap_musb_board_data *board_data)
+static struct omap_musb_board_data musb_default_board_data = {
+	.interface_type		= MUSB_INTERFACE_ULPI,
+	.mode			= MUSB_OTG,
+	.power			= 100,
+};
+
+void __init usb_musb_init(struct omap_musb_board_data *musb_board_data)
 {
 	struct omap_hwmod		*oh;
 	struct omap_device		*od;
@@ -116,6 +122,12 @@ void __init usb_musb_init(struct omap_musb_board_data *board_data)
 	struct device			*dev;
 	int				bus_id = -1;
 	const char			*oh_name, *name;
+	struct omap_musb_board_data	*board_data;
+
+	if (musb_board_data)
+		board_data = musb_board_data;
+	else
+		board_data = &musb_default_board_data;
 
 	if (cpu_is_omap3517() || cpu_is_omap3505()) {
 	} else if (cpu_is_omap44xx()) {
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 4/4] omap: musb: introduce default baord config
  2011-04-24 22:09 ` [PATCH 4/4] omap: musb: introduce default baord config Mike Rapoport
@ 2011-04-27  4:23   ` Oleg Drokin
  2011-04-27  7:23     ` Mike Rapoport
  2011-04-28 14:18     ` Russell King - ARM Linux
  2011-04-27  8:56   ` [PATCH v2 4/4] omap: musb: introduce default board config Mike Rapoport
  1 sibling, 2 replies; 29+ messages in thread
From: Oleg Drokin @ 2011-04-27  4:23 UTC (permalink / raw)
  To: linux-arm-kernel

Hello!

On Apr 24, 2011, at 6:09 PM, Mike Rapoport wrote:
> -void __init usb_musb_init(struct omap_musb_board_data *board_data)
> +static struct omap_musb_board_data musb_default_board_data = {
> +	.interface_type		= MUSB_INTERFACE_ULPI,
> +	.mode			= MUSB_OTG,

In fact can you make it more generic with ifdefs like this?
(since there are tons of boards taht are client only or would like to be compiled in some other way):

+#ifdef CONFIG_USB_MUSB_OTG
+       .mode                   = MUSB_OTG,
+#elif defined(CONFIG_USB_MUSB_HDRC_HCD)
+       .mode                   = MUSB_HOST,
+#elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
+       .mode                   = MUSB_PERIPHERAL,
+#endif

> +	.power			= 100,
> +};
> +

Thanks!

Bye,
    Oleg

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 4/4] omap: musb: introduce default baord config
  2011-04-27  4:23   ` Oleg Drokin
@ 2011-04-27  7:23     ` Mike Rapoport
  2011-04-28 14:18     ` Russell King - ARM Linux
  1 sibling, 0 replies; 29+ messages in thread
From: Mike Rapoport @ 2011-04-27  7:23 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/27/11 07:23, Oleg Drokin wrote:
> Hello!
> 
> On Apr 24, 2011, at 6:09 PM, Mike Rapoport wrote:
>> -void __init usb_musb_init(struct omap_musb_board_data *board_data)
>> +static struct omap_musb_board_data musb_default_board_data = {
>> +	.interface_type		= MUSB_INTERFACE_ULPI,
>> +	.mode			= MUSB_OTG,
> 
> In fact can you make it more generic with ifdefs like this?
> (since there are tons of boards taht are client only or would like to be compiled in some other way):

I didn't want to change current functionality. The purpose of this patch is to
reduce amount of code shared among board files.
If certain board needs mode other than OTG it can still pass musb_board_data.

> +#ifdef CONFIG_USB_MUSB_OTG
> +       .mode                   = MUSB_OTG,
> +#elif defined(CONFIG_USB_MUSB_HDRC_HCD)
> +       .mode                   = MUSB_HOST,
> +#elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
> +       .mode                   = MUSB_PERIPHERAL,
> +#endif
> 
>> +	.power			= 100,
>> +};
>> +
> 
> Thanks!
> 
> Bye,
>     Oleg
> 


-- 
Sincerely yours,
Mike.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH v2 4/4] omap: musb: introduce default board config
  2011-04-24 22:09 ` [PATCH 4/4] omap: musb: introduce default baord config Mike Rapoport
  2011-04-27  4:23   ` Oleg Drokin
@ 2011-04-27  8:56   ` Mike Rapoport
  2011-05-03  8:24     ` Felipe Balbi
  1 sibling, 1 reply; 29+ messages in thread
From: Mike Rapoport @ 2011-04-27  8:56 UTC (permalink / raw)
  To: linux-arm-kernel

Most boards use exactly the same configuration for musb initialization.
Create a default that can be shared amount different boards.

Signed-off-by: Mike Rapoport <mike@compulab.co.il>
---
Fixed spelling in $SUBJ, thanks to Felipe Contreras

 arch/arm/mach-omap2/board-2430sdp.c          |    7 +------
 arch/arm/mach-omap2/board-3430sdp.c          |    8 +-------
 arch/arm/mach-omap2/board-cm-t35.c           |    8 +-------
 arch/arm/mach-omap2/board-devkit8000.c       |    8 +-------
 arch/arm/mach-omap2/board-igep0020.c         |    8 +-------
 arch/arm/mach-omap2/board-igep0030.c         |    8 +-------
 arch/arm/mach-omap2/board-ldp.c              |    8 +-------
 arch/arm/mach-omap2/board-omap3beagle.c      |    8 +-------
 arch/arm/mach-omap2/board-omap3pandora.c     |    8 +-------
 arch/arm/mach-omap2/board-omap3stalker.c     |    8 +-------
 arch/arm/mach-omap2/board-omap3touchbook.c   |    8 +-------
 arch/arm/mach-omap2/board-overo.c            |    8 +-------
 arch/arm/mach-omap2/board-rm680.c            |    8 +-------
 arch/arm/mach-omap2/board-zoom-peripherals.c |    8 +-------
 arch/arm/mach-omap2/usb-musb.c               |   14 +++++++++++++-
 15 files changed, 27 insertions(+), 98 deletions(-)

diff --git a/arch/arm/mach-omap2/board-2430sdp.c b/arch/arm/mach-omap2/board-2430sdp.c
index 99b3f2d..a8810f8 100644
--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -208,11 +208,6 @@ static struct omap2_hsmmc_info mmc[] __initdata = {
 	{}	/* Terminator */
 };
 
-static struct omap_musb_board_data musb_board_data = {
-	.interface_type		= MUSB_INTERFACE_ULPI,
-	.mode			= MUSB_OTG,
-	.power			= 100,
-};
 static struct omap_usb_config sdp2430_usb_config __initdata = {
 	.otg		= 1,
 #ifdef  CONFIG_USB_GADGET_OMAP
@@ -246,7 +241,7 @@ static void __init omap_2430sdp_init(void)
 	omap2_usbfs_init(&sdp2430_usb_config);
 
 	omap_mux_init_signal("usb0hs_stp", OMAP_PULL_ENA | OMAP_PULL_UP);
-	usb_musb_init(&musb_board_data);
+	usb_musb_init(NULL);
 
 	board_smc91x_init();
 
diff --git a/arch/arm/mach-omap2/board-3430sdp.c b/arch/arm/mach-omap2/board-3430sdp.c
index b12400e..951e585 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -810,12 +810,6 @@ static struct flash_partitions sdp_flash_partitions[] = {
 	},
 };
 
-static struct omap_musb_board_data musb_board_data = {
-	.interface_type		= MUSB_INTERFACE_ULPI,
-	.mode			= MUSB_OTG,
-	.power			= 100,
-};
-
 static void __init omap_3430sdp_init(void)
 {
 	int gpio_pendown;
@@ -832,7 +826,7 @@ static void __init omap_3430sdp_init(void)
 		gpio_pendown = SDP3430_TS_GPIO_IRQ_SDPV1;
 	omap_ads7846_init(1, gpio_pendown, 310, NULL);
 	board_serial_init();
-	usb_musb_init(&musb_board_data);
+	usb_musb_init(NULL);
 	board_smc91x_init();
 	board_flash_init(sdp_flash_partitions, chip_sel_3430, 0);
 	sdp3430_display_init();
diff --git a/arch/arm/mach-omap2/board-cm-t35.c b/arch/arm/mach-omap2/board-cm-t35.c
index 1a9e6be..286da17 100644
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -651,12 +651,6 @@ static struct omap_board_mux board_mux[] __initdata = {
 };
 #endif
 
-static struct omap_musb_board_data musb_board_data = {
-	.interface_type		= MUSB_INTERFACE_ULPI,
-	.mode			= MUSB_OTG,
-	.power			= 100,
-};
-
 static struct omap_board_config_kernel cm_t35_config[] __initdata = {
 };
 
@@ -673,7 +667,7 @@ static void __init cm_t35_init(void)
 	cm_t35_init_led();
 	cm_t35_init_display();
 
-	usb_musb_init(&musb_board_data);
+	usb_musb_init(NULL);
 	usbhs_init(&usbhs_bdata);
 }
 
diff --git a/arch/arm/mach-omap2/board-devkit8000.c b/arch/arm/mach-omap2/board-devkit8000.c
index e7dc057..405542a 100644
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -509,12 +509,6 @@ static struct platform_device *devkit8000_devices[] __initdata = {
 	&omap_dm9000_dev,
 };
 
-static struct omap_musb_board_data musb_board_data = {
-	.interface_type		= MUSB_INTERFACE_ULPI,
-	.mode			= MUSB_OTG,
-	.power			= 100,
-};
-
 static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
 
 	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
@@ -698,7 +692,7 @@ static void __init devkit8000_init(void)
 
 	omap_ads7846_init(2, OMAP3_DEVKIT_TS_GPIO, 0, NULL);
 
-	usb_musb_init(&musb_board_data);
+	usb_musb_init(NULL);
 	usbhs_init(&usbhs_bdata);
 	omap_nand_flash_init(NAND_BUSWIDTH_16, devkit8000_nand_partitions,
 			     ARRAY_SIZE(devkit8000_nand_partitions));
diff --git a/arch/arm/mach-omap2/board-igep0020.c b/arch/arm/mach-omap2/board-igep0020.c
index a0fd10e..2c9a919 100644
--- a/arch/arm/mach-omap2/board-igep0020.c
+++ b/arch/arm/mach-omap2/board-igep0020.c
@@ -559,12 +559,6 @@ static void __init igep2_i2c_init(void)
 		pr_warning("IGEP2: Could not register I2C3 bus (%d)\n", ret);
 }
 
-static struct omap_musb_board_data musb_board_data = {
-	.interface_type		= MUSB_INTERFACE_ULPI,
-	.mode			= MUSB_OTG,
-	.power			= 100,
-};
-
 static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
 	.port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
 	.port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
@@ -637,7 +631,7 @@ static void __init igep2_init(void)
 	platform_add_devices(igep2_devices, ARRAY_SIZE(igep2_devices));
 	omap_display_init(&igep2_dss_data);
 	omap_serial_init();
-	usb_musb_init(&musb_board_data);
+	usb_musb_init(NULL);
 	usbhs_init(&usbhs_bdata);
 
 	igep2_flash_init();
diff --git a/arch/arm/mach-omap2/board-igep0030.c b/arch/arm/mach-omap2/board-igep0030.c
index a831e85..512a7eb 100644
--- a/arch/arm/mach-omap2/board-igep0030.c
+++ b/arch/arm/mach-omap2/board-igep0030.c
@@ -357,12 +357,6 @@ static int __init igep3_i2c_init(void)
 	return 0;
 }
 
-static struct omap_musb_board_data musb_board_data = {
-	.interface_type	= MUSB_INTERFACE_ULPI,
-	.mode		= MUSB_OTG,
-	.power		= 100,
-};
-
 #if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE)
 
 static void __init igep3_wifi_bt_init(void)
@@ -424,7 +418,7 @@ static void __init igep3_init(void)
 	igep3_i2c_init();
 	platform_add_devices(igep3_devices, ARRAY_SIZE(igep3_devices));
 	omap_serial_init();
-	usb_musb_init(&musb_board_data);
+	usb_musb_init(NULL);
 	usbhs_init(&usbhs_bdata);
 
 	igep3_flash_init();
diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
index 7482c75..f7d6038 100644
--- a/arch/arm/mach-omap2/board-ldp.c
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -294,12 +294,6 @@ static struct omap_board_mux board_mux[] __initdata = {
 };
 #endif
 
-static struct omap_musb_board_data musb_board_data = {
-	.interface_type		= MUSB_INTERFACE_ULPI,
-	.mode			= MUSB_OTG,
-	.power			= 100,
-};
-
 static struct mtd_partition ldp_nand_partitions[] = {
 	/* All the partition sizes are listed in terms of NAND block size */
 	{
@@ -342,7 +336,7 @@ static void __init omap_ldp_init(void)
 	platform_add_devices(ldp_devices, ARRAY_SIZE(ldp_devices));
 	omap_ads7846_init(1, 54, 310, NULL);
 	omap_serial_init();
-	usb_musb_init(&musb_board_data);
+	usb_musb_init(NULL);
 	board_nand_init(ldp_nand_partitions,
 		ARRAY_SIZE(ldp_nand_partitions), ZOOM_NAND_CS, 0);
 
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index ce3bc2d..bc30ab0 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -551,12 +551,6 @@ static struct omap_board_mux board_mux[] __initdata = {
 };
 #endif
 
-static struct omap_musb_board_data musb_board_data = {
-	.interface_type		= MUSB_INTERFACE_ULPI,
-	.mode			= MUSB_OTG,
-	.power			= 100,
-};
-
 static void __init beagle_opp_init(void)
 {
 	int r = 0;
@@ -618,7 +612,7 @@ static void __init omap3_beagle_init(void)
 	/* REVISIT leave DVI powered down until it's needed ... */
 	gpio_direction_output(170, true);
 
-	usb_musb_init(&musb_board_data);
+	usb_musb_init(NULL);
 	usbhs_init(&usbhs_bdata);
 	omap_nand_flash_init(NAND_BUSWIDTH_16, omap3beagle_nand_partitions,
 			     ARRAY_SIZE(omap3beagle_nand_partitions));
diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
index b99cc64..6c22d3f 100644
--- a/arch/arm/mach-omap2/board-omap3pandora.c
+++ b/arch/arm/mach-omap2/board-omap3pandora.c
@@ -633,12 +633,6 @@ static struct omap_board_mux board_mux[] __initdata = {
 };
 #endif
 
-static struct omap_musb_board_data musb_board_data = {
-	.interface_type		= MUSB_INTERFACE_ULPI,
-	.mode			= MUSB_OTG,
-	.power			= 100,
-};
-
 static void __init omap3pandora_init(void)
 {
 	omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
@@ -652,7 +646,7 @@ static void __init omap3pandora_init(void)
 			ARRAY_SIZE(omap3pandora_spi_board_info));
 	omap_ads7846_init(1, OMAP3_PANDORA_TS_GPIO, 0, NULL);
 	usbhs_init(&usbhs_bdata);
-	usb_musb_init(&musb_board_data);
+	usb_musb_init(NULL);
 	gpmc_nand_init(&pandora_nand_data);
 
 	/* Ensure SDRC pins are mux'd for self-refresh */
diff --git a/arch/arm/mach-omap2/board-omap3stalker.c b/arch/arm/mach-omap2/board-omap3stalker.c
index a1d550f..9981d06 100644
--- a/arch/arm/mach-omap2/board-omap3stalker.c
+++ b/arch/arm/mach-omap2/board-omap3stalker.c
@@ -526,12 +526,6 @@ static struct omap_board_mux board_mux[] __initdata = {
 };
 #endif
 
-static struct omap_musb_board_data musb_board_data = {
-	.interface_type	= MUSB_INTERFACE_ULPI,
-	.mode		= MUSB_OTG,
-	.power		= 100,
-};
-
 static void __init omap3_stalker_init(void)
 {
 	omap3_mux_init(board_mux, OMAP_PACKAGE_CUS);
@@ -546,7 +540,7 @@ static void __init omap3_stalker_init(void)
 	omap_display_init(&omap3_stalker_dss_data);
 
 	omap_serial_init();
-	usb_musb_init(&musb_board_data);
+	usb_musb_init(NULL);
 	usbhs_init(&usbhs_bdata);
 	omap_ads7846_init(1, OMAP3_STALKER_TS_GPIO, 310, NULL);
 
diff --git a/arch/arm/mach-omap2/board-omap3touchbook.c b/arch/arm/mach-omap2/board-omap3touchbook.c
index d770802..392278d 100644
--- a/arch/arm/mach-omap2/board-omap3touchbook.c
+++ b/arch/arm/mach-omap2/board-omap3touchbook.c
@@ -421,12 +421,6 @@ static int __init early_touchbook_revision(char *p)
 }
 early_param("tbr", early_touchbook_revision);
 
-static struct omap_musb_board_data musb_board_data = {
-	.interface_type		= MUSB_INTERFACE_ULPI,
-	.mode			= MUSB_OTG,
-	.power			= 100,
-};
-
 static void __init omap3_touchbook_init(void)
 {
 	omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
@@ -447,7 +441,7 @@ static void __init omap3_touchbook_init(void)
 
 	/* Touchscreen and accelerometer */
 	omap_ads7846_init(4, OMAP3_TS_GPIO, 310, &ads7846_pdata);
-	usb_musb_init(&musb_board_data);
+	usb_musb_init(NULL);
 	usbhs_init(&usbhs_bdata);
 	omap_nand_flash_init(NAND_BUSWIDTH_16, omap3touchbook_nand_partitions,
 			     ARRAY_SIZE(omap3touchbook_nand_partitions));
diff --git a/arch/arm/mach-omap2/board-overo.c b/arch/arm/mach-omap2/board-overo.c
index 9212442..c7ec7fa 100644
--- a/arch/arm/mach-omap2/board-overo.c
+++ b/arch/arm/mach-omap2/board-overo.c
@@ -551,12 +551,6 @@ static struct omap_board_mux board_mux[] __initdata = {
 };
 #endif
 
-static struct omap_musb_board_data musb_board_data = {
-	.interface_type		= MUSB_INTERFACE_ULPI,
-	.mode			= MUSB_OTG,
-	.power			= 100,
-};
-
 static void __init overo_init(void)
 {
 	omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
@@ -565,7 +559,7 @@ static void __init overo_init(void)
 	omap_serial_init();
 	omap_nand_flash_init(0, overo_nand_partitions,
 			     ARRAY_SIZE(overo_nand_partitions));
-	usb_musb_init(&musb_board_data);
+	usb_musb_init(NULL);
 	usbhs_init(&usbhs_bdata);
 	overo_spi_init();
 	overo_ads7846_init();
diff --git a/arch/arm/mach-omap2/board-rm680.c b/arch/arm/mach-omap2/board-rm680.c
index 8e710ff..42d10b1 100644
--- a/arch/arm/mach-omap2/board-rm680.c
+++ b/arch/arm/mach-omap2/board-rm680.c
@@ -144,17 +144,11 @@ static struct omap_board_mux board_mux[] __initdata = {
 };
 #endif
 
-static struct omap_musb_board_data rm680_musb_data = {
-	.interface_type	= MUSB_INTERFACE_ULPI,
-	.mode		= MUSB_PERIPHERAL,
-	.power		= 100,
-};
-
 static void __init rm680_init(void)
 {
 	omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
 	omap_serial_init();
-	usb_musb_init(&rm680_musb_data);
+	usb_musb_init(NULL);
 	rm680_peripherals_init();
 }
 
diff --git a/arch/arm/mach-omap2/board-zoom-peripherals.c b/arch/arm/mach-omap2/board-zoom-peripherals.c
index e4870c2..489294a 100644
--- a/arch/arm/mach-omap2/board-zoom-peripherals.c
+++ b/arch/arm/mach-omap2/board-zoom-peripherals.c
@@ -363,12 +363,6 @@ static int __init omap_i2c_init(void)
 	return 0;
 }
 
-static struct omap_musb_board_data musb_board_data = {
-	.interface_type		= MUSB_INTERFACE_ULPI,
-	.mode			= MUSB_OTG,
-	.power			= 100,
-};
-
 static void enable_board_wakeup_source(void)
 {
 	/* T2 interrupt line (keypad) */
@@ -383,7 +377,7 @@ void __init zoom_peripherals_init(void)
 
 	omap_i2c_init();
 	platform_device_register(&omap_vwlan_device);
-	usb_musb_init(&musb_board_data);
+	usb_musb_init(NULL);
 	enable_board_wakeup_source();
 	omap_serial_init();
 }
diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c
index 35559f7..dfa5a3c 100644
--- a/arch/arm/mach-omap2/usb-musb.c
+++ b/arch/arm/mach-omap2/usb-musb.c
@@ -108,7 +108,13 @@ static void usb_musb_mux_init(struct omap_musb_board_data *board_data)
 	}
 }
 
-void __init usb_musb_init(struct omap_musb_board_data *board_data)
+static struct omap_musb_board_data musb_default_board_data = {
+	.interface_type		= MUSB_INTERFACE_ULPI,
+	.mode			= MUSB_OTG,
+	.power			= 100,
+};
+
+void __init usb_musb_init(struct omap_musb_board_data *musb_board_data)
 {
 	struct omap_hwmod		*oh;
 	struct omap_device		*od;
@@ -116,6 +122,12 @@ void __init usb_musb_init(struct omap_musb_board_data *board_data)
 	struct device			*dev;
 	int				bus_id = -1;
 	const char			*oh_name, *name;
+	struct omap_musb_board_data	*board_data;
+
+	if (musb_board_data)
+		board_data = musb_board_data;
+	else
+		board_data = &musb_default_board_data;
 
 	if (cpu_is_omap3517() || cpu_is_omap3505()) {
 	} else if (cpu_is_omap44xx()) {
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 4/4] omap: musb: introduce default baord config
  2011-04-27  4:23   ` Oleg Drokin
  2011-04-27  7:23     ` Mike Rapoport
@ 2011-04-28 14:18     ` Russell King - ARM Linux
  2011-04-28 16:21       ` Oleg Drokin
  1 sibling, 1 reply; 29+ messages in thread
From: Russell King - ARM Linux @ 2011-04-28 14:18 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Apr 27, 2011 at 12:23:18AM -0400, Oleg Drokin wrote:
> Hello!
> 
> On Apr 24, 2011, at 6:09 PM, Mike Rapoport wrote:
> > -void __init usb_musb_init(struct omap_musb_board_data *board_data)
> > +static struct omap_musb_board_data musb_default_board_data = {
> > +	.interface_type		= MUSB_INTERFACE_ULPI,
> > +	.mode			= MUSB_OTG,
> 
> In fact can you make it more generic with ifdefs like this?
> (since there are tons of boards taht are client only or would like to be compiled in some other way):
> 
> +#ifdef CONFIG_USB_MUSB_OTG
> +       .mode                   = MUSB_OTG,
> +#elif defined(CONFIG_USB_MUSB_HDRC_HCD)
> +       .mode                   = MUSB_HOST,
> +#elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
> +       .mode                   = MUSB_PERIPHERAL,
> +#endif

If this is something that's desired, then it should not be done via ifdefs
but by platforms passing the mode argument into an initialization function.
Eventually, when we switch to some DT like system, this is the kind of
information that would be obtained from DT, and identifying this stuff
now will help when DT stuff comes along.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 4/4] omap: musb: introduce default baord config
  2011-04-28 14:18     ` Russell King - ARM Linux
@ 2011-04-28 16:21       ` Oleg Drokin
  2011-04-28 16:28         ` Russell King - ARM Linux
  0 siblings, 1 reply; 29+ messages in thread
From: Oleg Drokin @ 2011-04-28 16:21 UTC (permalink / raw)
  To: linux-arm-kernel

Hello!

On Apr 28, 2011, at 10:18 AM, Russell King - ARM Linux wrote:
>>> -void __init usb_musb_init(struct omap_musb_board_data *board_data)
>>> +static struct omap_musb_board_data musb_default_board_data = {
>>> +	.interface_type		= MUSB_INTERFACE_ULPI,
>>> +	.mode			= MUSB_OTG,
>> 
>> In fact can you make it more generic with ifdefs like this?
>> (since there are tons of boards taht are client only or would like to be compiled in some other way):
>> 
>> +#ifdef CONFIG_USB_MUSB_OTG
>> +       .mode                   = MUSB_OTG,
>> +#elif defined(CONFIG_USB_MUSB_HDRC_HCD)
>> +       .mode                   = MUSB_HOST,
>> +#elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
>> +       .mode                   = MUSB_PERIPHERAL,
>> +#endif
> If this is something that's desired, then it should not be done via ifdefs
> but by platforms passing the mode argument into an initialization function.
> Eventually, when we switch to some DT like system, this is the kind of
> information that would be obtained from DT, and identifying this stuff
> now will help when DT stuff comes along.

Frankly, I am not even sure why the mode needs to be supplied by the board at all.
The musb code already  has a very similar switch in musb_plat and so it totally looks like
a duplicated specification of the same thing from the board file and from
generic musb code where the original init value is then ignored.

I see that in .29 the board file did not need to specify usb mode and it was all decided
in musb-specific code, and I have no idea why that was later changed to the way it is now.

Would it just be better if a patch removing mode field from struct omap_musb_board_data
is adopted like this (warning - not a real patch)?
diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c
index 35559f7..c7f834f 100644
--- a/arch/arm/mach-omap2/usb-musb.c
+++ b/arch/arm/mach-omap2/usb-musb.c
@@ -129,7 +129,6 @@ void __init usb_musb_init(struct omap_musb_board_data *board
        musb_plat.clock = "ick";
        musb_plat.board_data = board_data;
        musb_plat.power = board_data->power >> 1;
-       musb_plat.mode = board_data->mode;
        musb_plat.extvbus = board_data->extvbus;
 
        if (cpu_is_omap44xx())

Bye,
    Oleg

^ permalink raw reply related	[flat|nested] 29+ messages in thread

* [PATCH 4/4] omap: musb: introduce default baord config
  2011-04-28 16:21       ` Oleg Drokin
@ 2011-04-28 16:28         ` Russell King - ARM Linux
  2011-04-28 16:36           ` Oleg Drokin
  0 siblings, 1 reply; 29+ messages in thread
From: Russell King - ARM Linux @ 2011-04-28 16:28 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Apr 28, 2011 at 12:21:47PM -0400, Oleg Drokin wrote:
> Frankly, I am not even sure why the mode needs to be supplied by the board at all.
> The musb code already  has a very similar switch in musb_plat and so it totally looks like
> a duplicated specification of the same thing from the board file and from
> generic musb code where the original init value is then ignored.
> 
> I see that in .29 the board file did not need to specify usb mode and it was all decided
> in musb-specific code, and I have no idea why that was later changed to the way it is now.
> 
> Would it just be better if a patch removing mode field from struct omap_musb_board_data
> is adopted like this (warning - not a real patch)?

Hmm, it looks to me like we're ending up with two layers on top of
each other, both trying to provide some kind of generic board interface.

I think they should be squashed together.  And that:

static struct musb_hdrc_platform_data musb_plat = {
#ifdef CONFIG_USB_MUSB_OTG
        .mode           = MUSB_OTG,
#elif defined(CONFIG_USB_MUSB_HDRC_HCD)
        .mode           = MUSB_HOST,
#elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
        .mode           = MUSB_PERIPHERAL,
#endif

in usb-musb.c needs the same treatment as I mentioned in the previous
message if it really is board specific.  If not, I see no reason why
the above can't go into the musb driver itself.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 4/4] omap: musb: introduce default baord config
  2011-04-28 16:28         ` Russell King - ARM Linux
@ 2011-04-28 16:36           ` Oleg Drokin
  2011-05-02 14:20             ` Tony Lindgren
  0 siblings, 1 reply; 29+ messages in thread
From: Oleg Drokin @ 2011-04-28 16:36 UTC (permalink / raw)
  To: linux-arm-kernel

Hello!
On Apr 28, 2011, at 12:28 PM, Russell King - ARM Linux wrote:
> mm, it looks to me like we're ending up with two layers on top of
> each other, both trying to provide some kind of generic board interface.
> 
> I think they should be squashed together.  And that:
> 
> static struct musb_hdrc_platform_data musb_plat = {
> #ifdef CONFIG_USB_MUSB_OTG
>        .mode           = MUSB_OTG,
> #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
>        .mode           = MUSB_HOST,
> #elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
>        .mode           = MUSB_PERIPHERAL,
> #endif
> 
> in usb-musb.c needs the same treatment as I mentioned in the previous
> message if it really is board specific.  If not, I see no reason why
> the above can't go into the musb driver itself.

In the end it's chip dependent. And the musb can work in all three modes.
Of course the board dictates if the power is supplied to the bus in host
mode and such, but even that could be worked around as nokia 9x0 saga for
USB host shows.
So to me it looks like something totally in realm of musb driver itself.
Nothing bad happens if you configure your MUSB as say OTG while in fact only
peripheral mode was implemented, it continues to work as it did.
Of course enabling HOST mode may not magically make things work, but
I suspect this could be addressed from Kconfig itself instead.

Now I totally expect musb maintainer to jump in and explain
how many misconceptions I have ;)

Bye,
    Oleg

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 0/4] omap: cleanup board files
  2011-04-24 22:09 [PATCH 0/4] omap: cleanup board files Mike Rapoport
                   ` (3 preceding siblings ...)
  2011-04-24 22:09 ` [PATCH 4/4] omap: musb: introduce default baord config Mike Rapoport
@ 2011-05-02 13:57 ` Mike Rapoport
  2011-05-02 14:22   ` Tony Lindgren
  4 siblings, 1 reply; 29+ messages in thread
From: Mike Rapoport @ 2011-05-02 13:57 UTC (permalink / raw)
  To: linux-arm-kernel

ping?

On Mon, Apr 25, 2011 at 1:09 PM, Mike Rapoport <mike@compulab.co.il> wrote:

> Hi Tony,
> 
> These patches cleanup some of the common code in the board files. The
> changes
> are basically almost mechanically move the code shared among several
> boards
> into some common place.
> There are a lot of places for further improvement, especially DSS and
> TWL
> initialization. I'll try to find some time to sort these out as well.
> 
> Special thanks to Igor Grinberg for the original idea :)
> 
> Mike Rapoport (4):
> omap: consolidate touch screen initialization among different boards
> omap: use common initialization for PMIC i2c bus
> omap: move detection of NAND CS to common-board-devices
> omap: musb: introduce default baord config
> 
> arch/arm/mach-omap2/Makefile | 2 +
> arch/arm/mach-omap2/board-2430sdp.c | 20 +---
> arch/arm/mach-omap2/board-3430sdp.c | 85 ++-------------
> arch/arm/mach-omap2/board-4430sdp.c | 16 +---
> arch/arm/mach-omap2/board-cm-t35.c | 78 +-------------
> arch/arm/mach-omap2/board-devkit8000.c | 119 +--------------------
> arch/arm/mach-omap2/board-igep0020.c | 23 +----
> arch/arm/mach-omap2/board-igep0030.c | 21 +---
> arch/arm/mach-omap2/board-ldp.c | 77 +-------------
> arch/arm/mach-omap2/board-omap3beagle.c | 66 +-----------
> arch/arm/mach-omap2/board-omap3evm.c | 72 +------------
> arch/arm/mach-omap2/board-omap3logic.c | 13 +--
> arch/arm/mach-omap2/board-omap3pandora.c | 69 +-----------
> arch/arm/mach-omap2/board-omap3stalker.c | 78 +-------------
> arch/arm/mach-omap2/board-omap3touchbook.c | 101 ++----------------
> arch/arm/mach-omap2/board-omap4panda.c | 17 +---
> arch/arm/mach-omap2/board-overo.c | 108 +------------------
> arch/arm/mach-omap2/board-rm680.c | 21 +---
> arch/arm/mach-omap2/board-rx51-peripherals.c | 13 +--
> arch/arm/mach-omap2/board-zoom-peripherals.c | 21 +---
> arch/arm/mach-omap2/common-board-devices.c | 148
> ++++++++++++++++++++++++++
> arch/arm/mach-omap2/common-board-devices.h | 52 +++++++++
> arch/arm/mach-omap2/usb-musb.c | 14 +++-
> 23 files changed, 293 insertions(+), 941 deletions(-)
> create mode 100644 arch/arm/mach-omap2/common-board-devices.c
> create mode 100644 arch/arm/mach-omap2/common-board-devices.h
> 
> --
> 1.7.3.1

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 4/4] omap: musb: introduce default baord config
  2011-04-28 16:36           ` Oleg Drokin
@ 2011-05-02 14:20             ` Tony Lindgren
  2011-05-02 14:25               ` Felipe Balbi
  0 siblings, 1 reply; 29+ messages in thread
From: Tony Lindgren @ 2011-05-02 14:20 UTC (permalink / raw)
  To: linux-arm-kernel

* Oleg Drokin <green@linuxhacker.ru> [110428 09:33]:
> Hello!
> On Apr 28, 2011, at 12:28 PM, Russell King - ARM Linux wrote:
> > mm, it looks to me like we're ending up with two layers on top of
> > each other, both trying to provide some kind of generic board interface.
> > 
> > I think they should be squashed together.  And that:
> > 
> > static struct musb_hdrc_platform_data musb_plat = {
> > #ifdef CONFIG_USB_MUSB_OTG
> >        .mode           = MUSB_OTG,
> > #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
> >        .mode           = MUSB_HOST,
> > #elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
> >        .mode           = MUSB_PERIPHERAL,
> > #endif
> > 
> > in usb-musb.c needs the same treatment as I mentioned in the previous
> > message if it really is board specific.  If not, I see no reason why
> > the above can't go into the musb driver itself.
> 
> In the end it's chip dependent. And the musb can work in all three modes.
> Of course the board dictates if the power is supplied to the bus in host
> mode and such, but even that could be worked around as nokia 9x0 saga for
> USB host shows.
> So to me it looks like something totally in realm of musb driver itself.
> Nothing bad happens if you configure your MUSB as say OTG while in fact only
> peripheral mode was implemented, it continues to work as it did.
> Of course enabling HOST mode may not magically make things work, but
> I suspect this could be addressed from Kconfig itself instead.
> 
> Now I totally expect musb maintainer to jump in and explain
> how many misconceptions I have ;)

As far as I remember MUSB always relies on the OTG hardware to enable
the host mode.. So I don't even know if the driver is usable with
host only configuration. And for the peripheral mode, it should be
possible to have OTG enabled, for cert testing some strings need
to be changed in that case for peripheral only configuration.

I think Felipe already has some patches to remove the various Kconfig
options for musb?  In any case, the musb configuration should be a
runtime configuration passed in the platform data or cmdline.

Regards,

Tony

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 0/4] omap: cleanup board files
  2011-05-02 13:57 ` [PATCH 0/4] omap: cleanup board files Mike Rapoport
@ 2011-05-02 14:22   ` Tony Lindgren
  2011-05-03 10:25     ` Tony Lindgren
  0 siblings, 1 reply; 29+ messages in thread
From: Tony Lindgren @ 2011-05-02 14:22 UTC (permalink / raw)
  To: linux-arm-kernel

* Mike Rapoport <mike@compulab.co.il> [110502 06:54]:
> ping?

Looks OK to me, let's wait on Felipe's comments on the
musb related stuff.

Tony

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 4/4] omap: musb: introduce default baord config
  2011-05-02 14:20             ` Tony Lindgren
@ 2011-05-02 14:25               ` Felipe Balbi
  2011-05-03  7:50                 ` Tony Lindgren
  0 siblings, 1 reply; 29+ messages in thread
From: Felipe Balbi @ 2011-05-02 14:25 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, May 02, 2011 at 07:20:52AM -0700, Tony Lindgren wrote:
> * Oleg Drokin <green@linuxhacker.ru> [110428 09:33]:
> > Hello!
> > On Apr 28, 2011, at 12:28 PM, Russell King - ARM Linux wrote:
> > > mm, it looks to me like we're ending up with two layers on top of
> > > each other, both trying to provide some kind of generic board interface.
> > > 
> > > I think they should be squashed together.  And that:
> > > 
> > > static struct musb_hdrc_platform_data musb_plat = {
> > > #ifdef CONFIG_USB_MUSB_OTG
> > >        .mode           = MUSB_OTG,
> > > #elif defined(CONFIG_USB_MUSB_HDRC_HCD)
> > >        .mode           = MUSB_HOST,
> > > #elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
> > >        .mode           = MUSB_PERIPHERAL,
> > > #endif
> > > 
> > > in usb-musb.c needs the same treatment as I mentioned in the previous
> > > message if it really is board specific.  If not, I see no reason why
> > > the above can't go into the musb driver itself.
> > 
> > In the end it's chip dependent. And the musb can work in all three modes.
> > Of course the board dictates if the power is supplied to the bus in host
> > mode and such, but even that could be worked around as nokia 9x0 saga for
> > USB host shows.
> > So to me it looks like something totally in realm of musb driver itself.
> > Nothing bad happens if you configure your MUSB as say OTG while in fact only
> > peripheral mode was implemented, it continues to work as it did.
> > Of course enabling HOST mode may not magically make things work, but
> > I suspect this could be addressed from Kconfig itself instead.
> > 
> > Now I totally expect musb maintainer to jump in and explain
> > how many misconceptions I have ;)
> 
> As far as I remember MUSB always relies on the OTG hardware to enable
> the host mode.. So I don't even know if the driver is usable with
> host only configuration. And for the peripheral mode, it should be

yes, it is :-)

> possible to have OTG enabled, for cert testing some strings need
> to be changed in that case for peripheral only configuration.
> 
> I think Felipe already has some patches to remove the various Kconfig
> options for musb?  In any case, the musb configuration should be a
> runtime configuration passed in the platform data or cmdline.

Yeah, I'm planning to get rid of all the ifdeferry and always compile it
with HOST and Peripheral support. It's only few extra tens of bytes
anyway. Still, I doubt I can get that done for this merge window, I
already have pending the debugging rework.

-- 
balbi

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 4/4] omap: musb: introduce default baord config
  2011-05-02 14:25               ` Felipe Balbi
@ 2011-05-03  7:50                 ` Tony Lindgren
  0 siblings, 0 replies; 29+ messages in thread
From: Tony Lindgren @ 2011-05-03  7:50 UTC (permalink / raw)
  To: linux-arm-kernel

* Felipe Balbi <balbi@ti.com> [110502 07:22]:
> On Mon, May 02, 2011 at 07:20:52AM -0700, Tony Lindgren wrote:
> > * Oleg Drokin <green@linuxhacker.ru> [110428 09:33]:
> > > 
> > > So to me it looks like something totally in realm of musb driver itself.
> > > Nothing bad happens if you configure your MUSB as say OTG while in fact only
> > > peripheral mode was implemented, it continues to work as it did.
> > > Of course enabling HOST mode may not magically make things work, but
> > > I suspect this could be addressed from Kconfig itself instead.

So based on the discussion it sounds like we still the board specific
configuration for the mode in some cases.

> > I think Felipe already has some patches to remove the various Kconfig
> > options for musb?  In any case, the musb configuration should be a
> > runtime configuration passed in the platform data or cmdline.
> 
> Yeah, I'm planning to get rid of all the ifdeferry and always compile it
> with HOST and Peripheral support. It's only few extra tens of bytes
> anyway. Still, I doubt I can get that done for this merge window, I
> already have pending the debugging rework.

So care to ack the original patch then? It still allows overriding
the default mode from board-*.c file as needed.

Regards,

Tony

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH v2 4/4] omap: musb: introduce default board config
  2011-04-27  8:56   ` [PATCH v2 4/4] omap: musb: introduce default board config Mike Rapoport
@ 2011-05-03  8:24     ` Felipe Balbi
  0 siblings, 0 replies; 29+ messages in thread
From: Felipe Balbi @ 2011-05-03  8:24 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

> Most boards use exactly the same configuration for musb initialization.
> Create a default that can be shared amount different boards.
> 
> Signed-off-by: Mike Rapoport <mike@compulab.co.il>

Acked-by: Felipe Balbi <balbi@ti.com>

-- 
balbi

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 0/4] omap: cleanup board files
  2011-05-02 14:22   ` Tony Lindgren
@ 2011-05-03 10:25     ` Tony Lindgren
  0 siblings, 0 replies; 29+ messages in thread
From: Tony Lindgren @ 2011-05-03 10:25 UTC (permalink / raw)
  To: linux-arm-kernel

* Tony Lindgren <tony@atomide.com> [110502 07:18]:
> * Mike Rapoport <mike@compulab.co.il> [110502 06:54]:
> > ping?
> 
> Looks OK to me, let's wait on Felipe's comments on the
> musb related stuff.

Applying this series into devel-cleanup for next merge
window.

Regards,

Tony

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 1/4] omap: consolidate touch screen initialization among different boards
  2011-04-24 22:09 ` [PATCH 1/4] omap: consolidate touch screen initialization among different boards Mike Rapoport
@ 2011-05-04  3:10   ` Oleg Drokin
  2011-05-04 14:02   ` Thomas Weber
  1 sibling, 0 replies; 29+ messages in thread
From: Oleg Drokin @ 2011-05-04  3:10 UTC (permalink / raw)
  To: linux-arm-kernel

Hello!

This patch breaks compile for me.

On Apr 24, 2011, at 6:09 PM, Mike Rapoport wrote:

> --- /dev/null
> +++ b/arch/arm/mach-omap2/common-board-devices.c
> @@ -0,0 +1,85 @@
> 
> +void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
> +			      struct ads7846_platform_data *board_pdata)
> +{
> ...

> +}
> diff --git a/arch/arm/mach-omap2/common-board-devices.h b/arch/arm/mach-omap2/common-board-devices.h
> new file mode 100644
> index 0000000..75f9248d
> --- /dev/null
> +++ b/arch/arm/mach-omap2/common-board-devices.h
> @@ -0,0 +1,18 @@
> +#ifndef __OMAP_COMMON_BOARD_DEVICES__
> +#define __OMAP_COMMON_BOARD_DEVICES__
> +
> +#if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
> +	defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
> +struct ads7846_platform_data;
> +
> +void omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
> +		       struct ads7846_platform_data *board_pdata);
> +#else


arch/arm/mach-omap2/common-board-devices.c:80: error: redefinition of 'omap_ads7846_init'
arch/arm/mach-omap2/common-board-devices.h:36: note: previous definition of 'omap_ads7846_init' was here

Of course I don't have the CONFIG_TOUCHSCREEN_ADS7846 defined.

Bye,
    Oleg

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 3/4] omap: move detection of NAND CS to common-board-devices
  2011-04-24 22:09 ` [PATCH 3/4] omap: move detection of NAND CS to common-board-devices Mike Rapoport
@ 2011-05-04  3:12   ` Oleg Drokin
  2011-05-04  4:10     ` Oleg Drokin
  0 siblings, 1 reply; 29+ messages in thread
From: Oleg Drokin @ 2011-05-04  3:12 UTC (permalink / raw)
  To: linux-arm-kernel

Hello!

  This patch breaks compile for me:

On Apr 24, 2011, at 6:09 PM, Mike Rapoport wrote:

> --- a/arch/arm/mach-omap2/common-board-devices.c
> +++ b/arch/arm/mach-omap2/common-board-devices.c
> @@ -29,6 +29,7 @@

...

> +void __init omap_nand_flash_init(int options, struct mtd_partition *parts,
> +				 int nr_parts)
> +{
...
> +}
> diff --git a/arch/arm/mach-omap2/common-board-devices.h b/arch/arm/mach-omap2/common-board-devices.h
> index 0ec3e07..ca03abf 100644
> --- a/arch/arm/mach-omap2/common-board-devices.h
> +++ b/arch/arm/mach-omap2/common-board-devices.h
> @@ -39,4 +40,13 @@ static inline void omap_ads7846_init(int bus_num,
> }
> #endif
> 
> +#if defined(CONFIG_MTD_NAND_OMAP2) || defined(CONFIG_MTD_NAND_OMAP2_MODULE)
> +void omap_nand_flash_init(int opts, struct mtd_partition *parts, int n_parts);
> +#else
> +static inline void omap_nand_flash_init(int opts, struct mtd_partition *parts,
> +					int nr_parts)
> +{
> +}

arch/arm/mach-omap2/common-board-devices.c:113: error: redefinition of 'omap_nand_flash_init'
arch/arm/mach-omap2/common-board-devices.h:46: note: previous definition of 'omap_nand_flash_init' was here

I don't have CONFIG_MTD_NAND_OMAP2 defined of course as there is no NAND flash on my board.

Bye,
    Oleg

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 3/4] omap: move detection of NAND CS to common-board-devices
  2011-05-04  3:12   ` Oleg Drokin
@ 2011-05-04  4:10     ` Oleg Drokin
  2011-05-04  6:38       ` Mike Rapoport
  0 siblings, 1 reply; 29+ messages in thread
From: Oleg Drokin @ 2011-05-04  4:10 UTC (permalink / raw)
  To: linux-arm-kernel

Ok, so here's a simple patch to save everyone trouble, I guess.

Though on the other hand I can imagine that perhaps including this generic common-board-devices.c
might not be desirable for people that don't use anything from that file.
Would it be a better idea to split it to a file-per-feature?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: compile-fix.diff
Type: application/octet-stream
Size: 1123 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110504/b83fcf3f/attachment.obj>

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 3/4] omap: move detection of NAND CS to common-board-devices
  2011-05-04  4:10     ` Oleg Drokin
@ 2011-05-04  6:38       ` Mike Rapoport
  2011-05-04  6:46         ` Tony Lindgren
  2011-05-04 15:54         ` Oleg Drokin
  0 siblings, 2 replies; 29+ messages in thread
From: Mike Rapoport @ 2011-05-04  6:38 UTC (permalink / raw)
  To: linux-arm-kernel

On 05/04/11 07:10, Oleg Drokin wrote:
> Ok, so here's a simple patch to save everyone trouble, I guess.
> 
> Though on the other hand I can imagine that perhaps including this generic common-board-devices.c
> might not be desirable for people that don't use anything from that file.

Since the common-board-devices.c has TWL initialization I doubt there would a
board that does not use it at all...

> Would it be a better idea to split it to a file-per-feature?

Splitting the common-board-devices into a file-per-feature will diminish its
added value, IMO.
We can either continue to use #ifdef CONFIG_SOMETHING in both
common-board-devices.[ch] as your fix proposes or just drop #ifdefs and inlines
from the header.
Tony, what is your preference?

-- 
Sincerely yours,
Mike.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 3/4] omap: move detection of NAND CS to common-board-devices
  2011-05-04  6:38       ` Mike Rapoport
@ 2011-05-04  6:46         ` Tony Lindgren
  2011-05-04  7:17           ` Mike Rapoport
  2011-05-04 15:54         ` Oleg Drokin
  1 sibling, 1 reply; 29+ messages in thread
From: Tony Lindgren @ 2011-05-04  6:46 UTC (permalink / raw)
  To: linux-arm-kernel

* Mike Rapoport <mike@compulab.co.il> [110504 09:35]:
> On 05/04/11 07:10, Oleg Drokin wrote:
> > Ok, so here's a simple patch to save everyone trouble, I guess.
> > 
> > Though on the other hand I can imagine that perhaps including this generic common-board-devices.c
> > might not be desirable for people that don't use anything from that file.
> 
> Since the common-board-devices.c has TWL initialization I doubt there would a
> board that does not use it at all...
> 
> > Would it be a better idea to split it to a file-per-feature?
> 
> Splitting the common-board-devices into a file-per-feature will diminish its
> added value, IMO.
> We can either continue to use #ifdef CONFIG_SOMETHING in both
> common-board-devices.[ch] as your fix proposes or just drop #ifdefs and inlines
> from the header.
> Tony, what is your preference?

We should consider the code size too.. Maybe see if you can make them
weak instead of the ifdefs?

Tony

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 3/4] omap: move detection of NAND CS to common-board-devices
  2011-05-04  6:46         ` Tony Lindgren
@ 2011-05-04  7:17           ` Mike Rapoport
  2011-05-04  8:38             ` Tony Lindgren
  0 siblings, 1 reply; 29+ messages in thread
From: Mike Rapoport @ 2011-05-04  7:17 UTC (permalink / raw)
  To: linux-arm-kernel

On 05/04/11 09:46, Tony Lindgren wrote:
> * Mike Rapoport <mike@compulab.co.il> [110504 09:35]:
>> On 05/04/11 07:10, Oleg Drokin wrote:
>>> Ok, so here's a simple patch to save everyone trouble, I guess.
>>>
>>> Though on the other hand I can imagine that perhaps including this generic common-board-devices.c
>>> might not be desirable for people that don't use anything from that file.
>>
>> Since the common-board-devices.c has TWL initialization I doubt there would a
>> board that does not use it at all...
>>
>>> Would it be a better idea to split it to a file-per-feature?
>>
>> Splitting the common-board-devices into a file-per-feature will diminish its
>> added value, IMO.
>> We can either continue to use #ifdef CONFIG_SOMETHING in both
>> common-board-devices.[ch] as your fix proposes or just drop #ifdefs and inlines
>> from the header.
>> Tony, what is your preference?
> 
> We should consider the code size too.. Maybe see if you can make them
> weak instead of the ifdefs?

Unless I completely misunderstand how weak works, we'll still have ifdefs in .c
file, i.e.

common-board-devices.h:

void __omap_nand_flash_init(int opts, struct mtd_partition *parts, int n_parts)
{
}

void omap_nand_flash_init(int opts, struct mtd_partition *parts, int n_parts)
__attribute__((weak, alias("__omap_nand_flash_init")));

common-board-devices.c:
#if defined(CONFIG_MTD_NAND_OMAP2) || defined(CONFIG_MTD_NAND_OMAP2_MODULE)
void omap_nand_flash_init(int opts, struct mtd_partition *parts, int n_parts)
{
...
}
#endif

Yet, we can keep the ifdefs only in common-board-devices.c and get rid if
inlines in the header.
Also, all the code in common-board-devices.c is __init, so it's eventually
dropped in runtime

> Tony


-- 
Sincerely yours,
Mike.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 3/4] omap: move detection of NAND CS to common-board-devices
  2011-05-04  7:17           ` Mike Rapoport
@ 2011-05-04  8:38             ` Tony Lindgren
  0 siblings, 0 replies; 29+ messages in thread
From: Tony Lindgren @ 2011-05-04  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

* Mike Rapoport <mike@compulab.co.il> [110504 10:13]:
> On 05/04/11 09:46, Tony Lindgren wrote:
> > * Mike Rapoport <mike@compulab.co.il> [110504 09:35]:
> >> On 05/04/11 07:10, Oleg Drokin wrote:
> >>> Ok, so here's a simple patch to save everyone trouble, I guess.
> >>>
> >>> Though on the other hand I can imagine that perhaps including this generic common-board-devices.c
> >>> might not be desirable for people that don't use anything from that file.
> >>
> >> Since the common-board-devices.c has TWL initialization I doubt there would a
> >> board that does not use it at all...
> >>
> >>> Would it be a better idea to split it to a file-per-feature?
> >>
> >> Splitting the common-board-devices into a file-per-feature will diminish its
> >> added value, IMO.
> >> We can either continue to use #ifdef CONFIG_SOMETHING in both
> >> common-board-devices.[ch] as your fix proposes or just drop #ifdefs and inlines
> >> from the header.
> >> Tony, what is your preference?
> > 
> > We should consider the code size too.. Maybe see if you can make them
> > weak instead of the ifdefs?
> 
> Unless I completely misunderstand how weak works, we'll still have ifdefs in .c
> file, i.e.
> 
> common-board-devices.h:
> 
> void __omap_nand_flash_init(int opts, struct mtd_partition *parts, int n_parts)
> {
> }
> 
> void omap_nand_flash_init(int opts, struct mtd_partition *parts, int n_parts)
> __attribute__((weak, alias("__omap_nand_flash_init")));
> 
> common-board-devices.c:
> #if defined(CONFIG_MTD_NAND_OMAP2) || defined(CONFIG_MTD_NAND_OMAP2_MODULE)
> void omap_nand_flash_init(int opts, struct mtd_partition *parts, int n_parts)
> {
> ...
> }
> #endif
> 
> Yet, we can keep the ifdefs only in common-board-devices.c and get rid if
> inlines in the header.
> Also, all the code in common-board-devices.c is __init, so it's eventually
> dropped in runtime

Sounds OK to me for the simple platform init functions used for most
common devices.

For anything more complex, we can have a separate file with ifdef in the
header and Makefile compiling it in only as selected.

Regards,

Tony

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 1/4] omap: consolidate touch screen initialization among different boards
  2011-04-24 22:09 ` [PATCH 1/4] omap: consolidate touch screen initialization among different boards Mike Rapoport
  2011-05-04  3:10   ` Oleg Drokin
@ 2011-05-04 14:02   ` Thomas Weber
  2011-05-04 15:10     ` Igor Grinberg
  1 sibling, 1 reply; 29+ messages in thread
From: Thomas Weber @ 2011-05-04 14:02 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

because ads7846_get_pendown_state() is not longer set in
ads7846_platform_data, the ads7846_setup_pendown tries to request the
pendown gpio and fails because the gpio is already requested.

Thomas

Am 25.04.2011 00:09, schrieb Mike Rapoport:
> Add common-board-devices.c that will contain the code for peripheral
> devices initializatoin shared between multiple boards.
> Start small with touchscreen initialization.
> 
> Signed-off-by: Mike Rapoport <mike@compulab.co.il>
> ---
>  arch/arm/mach-omap2/Makefile               |    2 +
>  arch/arm/mach-omap2/board-3430sdp.c        |   65 ++-------------------
>  arch/arm/mach-omap2/board-cm-t35.c         |   58 +------------------
>  arch/arm/mach-omap2/board-devkit8000.c     |   56 +------------------
>  arch/arm/mach-omap2/board-ldp.c            |   57 +------------------
>  arch/arm/mach-omap2/board-omap3evm.c       |   51 +----------------
>  arch/arm/mach-omap2/board-omap3pandora.c   |   49 +---------------
>  arch/arm/mach-omap2/board-omap3stalker.c   |   49 +---------------
>  arch/arm/mach-omap2/board-omap3touchbook.c |   36 +-----------
>  arch/arm/mach-omap2/board-overo.c          |   46 +--------------
>  arch/arm/mach-omap2/common-board-devices.c |   85 ++++++++++++++++++++++++++++
>  arch/arm/mach-omap2/common-board-devices.h |   18 ++++++
>  12 files changed, 128 insertions(+), 444 deletions(-)
>  create mode 100644 arch/arm/mach-omap2/common-board-devices.c
>  create mode 100644 arch/arm/mach-omap2/common-board-devices.h
>...


> diff --git a/arch/arm/mach-omap2/board-devkit8000.c b/arch/arm/mach-omap2/board-devkit8000.c
> index 65f9fde..9f8338d 100644
> --- a/arch/arm/mach-omap2/board-devkit8000.c
> +++ b/arch/arm/mach-omap2/board-devkit8000.c
> @@ -51,7 +51,6 @@
>  #include <plat/mcspi.h>
>  #include <linux/input/matrix_keypad.h>
>  #include <linux/spi/spi.h>
> -#include <linux/spi/ads7846.h>
>  #include <linux/dm9000.h>
>  #include <linux/interrupt.h>
>  
> @@ -60,6 +59,7 @@
>  #include "mux.h"
>  #include "hsmmc.h"
>  #include "timer-gp.h"
> +#include "common-board-devices.h"
>  
>  #define NAND_BLOCK_SIZE		SZ_128K
>  
> @@ -463,56 +463,6 @@ static void __init devkit8000_init_irq(void)
>  #endif
>  }
>  
> -static void __init devkit8000_ads7846_init(void)
> -{
> -	int gpio = OMAP3_DEVKIT_TS_GPIO;
> -	int ret;
> -
> -	ret = gpio_request(gpio, "ads7846_pen_down");
> -	if (ret < 0) {
> -		printk(KERN_ERR "Failed to request GPIO %d for "
> -				"ads7846 pen down IRQ\n", gpio);
> -		return;
> -	}
> -
> -	gpio_direction_input(gpio);
> -}
> -
> -static int ads7846_get_pendown_state(void)
> -{
> -	return !gpio_get_value(OMAP3_DEVKIT_TS_GPIO);
> -}
> -
> -static struct ads7846_platform_data ads7846_config = {
> -	.x_max                  = 0x0fff,
> -	.y_max                  = 0x0fff,
> -	.x_plate_ohms           = 180,
> -	.pressure_max           = 255,
> -	.debounce_max           = 10,
> -	.debounce_tol           = 5,
> -	.debounce_rep           = 1,
> -	.get_pendown_state	= ads7846_get_pendown_state,
> -	.keep_vref_on		= 1,
> -	.settle_delay_usecs     = 150,
> -};
> -
> -static struct omap2_mcspi_device_config ads7846_mcspi_config = {
> -	.turbo_mode	= 0,
> -	.single_channel	= 1,	/* 0: slave, 1: master */
> -};
> -
> -static struct spi_board_info devkit8000_spi_board_info[] __initdata = {
> -	{
> -		.modalias		= "ads7846",
> -		.bus_num		= 2,
> -		.chip_select		= 0,
> -		.max_speed_hz		= 1500000,
> -		.controller_data	= &ads7846_mcspi_config,
> -		.irq			= OMAP_GPIO_IRQ(OMAP3_DEVKIT_TS_GPIO),
> -		.platform_data		= &ads7846_config,
> -	}
> -};
> -
>  #define OMAP_DM9000_BASE	0x2c000000
>  
>  static struct resource omap_dm9000_resources[] = {
> @@ -795,10 +745,8 @@ static void __init devkit8000_init(void)
>  			ARRAY_SIZE(devkit8000_devices));
>  
>  	omap_display_init(&devkit8000_dss_data);
> -	spi_register_board_info(devkit8000_spi_board_info,
> -	ARRAY_SIZE(devkit8000_spi_board_info));
>  
> -	devkit8000_ads7846_init();
> +	omap_ads7846_init(2, OMAP3_DEVKIT_TS_GPIO, 0, NULL);
>  
>  	usb_musb_init(&musb_board_data);
>  	usbhs_init(&usbhs_bdata);
...
> diff --git a/arch/arm/mach-omap2/common-board-devices.c b/arch/arm/mach-omap2/common-board-devices.c
> new file mode 100644
> index 0000000..fad41ec
> --- /dev/null
> +++ b/arch/arm/mach-omap2/common-board-devices.c
> @@ -0,0 +1,85 @@
> +/*
> + * common-board-devices.c
> + *
> + * Copyright (C) 2011 CompuLab, Ltd.
> + * Author: Mike Rapoport <mike@compulab.co.il>
> + *
> + * 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.
> + *
> + * This program is distributed in the hope that it will be useful, but
> + * WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> + * 02110-1301 USA
> + *
> + */
> +
> +#include <linux/gpio.h>
> +#include <linux/spi/spi.h>
> +#include <linux/spi/ads7846.h>
> +
> +#include <plat/mcspi.h>
> +
> +#include "common-board-devices.h"
> +
> +static struct omap2_mcspi_device_config ads7846_mcspi_config = {
> +	.turbo_mode	= 0,
> +	.single_channel	= 1,	/* 0: slave, 1: master */
> +};
> +
> +static struct ads7846_platform_data ads7846_config = {
> +	.x_max			= 0x0fff,
> +	.y_max			= 0x0fff,
> +	.x_plate_ohms		= 180,
> +	.pressure_max		= 255,
> +	.debounce_max		= 10,
> +	.debounce_tol		= 3,
> +	.debounce_rep		= 1,
> +	.gpio_pendown		= -EINVAL,
> +	.keep_vref_on		= 1,
> +};
> +
> +static struct spi_board_info ads7846_spi_board_info __initdata = {
> +	.modalias		= "ads7846",
> +	.bus_num		= -EINVAL,
> +	.chip_select		= 0,
> +	.max_speed_hz		= 1500000,
> +	.controller_data	= &ads7846_mcspi_config,
> +	.irq			= -EINVAL,
> +	.platform_data		= &ads7846_config,
> +};
> +
> +void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
> +			      struct ads7846_platform_data *board_pdata)
> +{
> +	struct spi_board_info *spi_bi = &ads7846_spi_board_info;
> +	int err;
> +
> +	err = gpio_request(gpio_pendown, "TS PenDown");
> +	if (err) {
> +		pr_err("Could not obtain gpio for TS PenDown: %d\n", err);
> +		return;
> +	}
> +
> +	gpio_direction_input(gpio_pendown);
> +	gpio_export(gpio_pendown, 0);
> +
> +	if (gpio_debounce)
> +		gpio_set_debounce(gpio_pendown, gpio_debounce);
> +
> +	ads7846_config.gpio_pendown = gpio_pendown;
> +
> +	spi_bi->bus_num	= bus_num;
> +	spi_bi->irq	= OMAP_GPIO_IRQ(gpio_pendown);
> +
> +	if (board_pdata)
> +		spi_bi->platform_data = board_pdata;
> +
> +	spi_register_board_info(&ads7846_spi_board_info, 1);
> +}
> diff --git a/arch/arm/mach-omap2/common-board-devices.h b/arch/arm/mach-omap2/common-board-devices.h
> new file mode 100644
> index 0000000..75f9248d
> --- /dev/null
> +++ b/arch/arm/mach-omap2/common-board-devices.h
> @@ -0,0 +1,18 @@
> +#ifndef __OMAP_COMMON_BOARD_DEVICES__
> +#define __OMAP_COMMON_BOARD_DEVICES__
> +
> +#if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
> +	defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
> +struct ads7846_platform_data;
> +
> +void omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
> +		       struct ads7846_platform_data *board_pdata);
> +#else
> +static inline void omap_ads7846_init(int bus_num,
> +				     int gpio_pendown, int gpio_debounce,
> +				     struct ads7846_platform_data *board_data)
> +{
> +}
> +#endif
> +
> +#endif /* __OMAP_COMMON_BOARD_DEVICES__ */

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 1/4] omap: consolidate touch screen initialization among different boards
  2011-05-04 14:02   ` Thomas Weber
@ 2011-05-04 15:10     ` Igor Grinberg
  0 siblings, 0 replies; 29+ messages in thread
From: Igor Grinberg @ 2011-05-04 15:10 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Thomas,

On 05/04/11 17:02, Thomas Weber wrote:

> Hello,
>
> because ads7846_get_pendown_state() is not longer set in
> ads7846_platform_data, the ads7846_setup_pendown tries to request the
> pendown gpio and fails because the gpio is already requested.

Thanks, for testing.

I've sent a patch for this a couple of minutes ago.


-- 
Regards,
Igor.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 3/4] omap: move detection of NAND CS to common-board-devices
  2011-05-04  6:38       ` Mike Rapoport
  2011-05-04  6:46         ` Tony Lindgren
@ 2011-05-04 15:54         ` Oleg Drokin
  1 sibling, 0 replies; 29+ messages in thread
From: Oleg Drokin @ 2011-05-04 15:54 UTC (permalink / raw)
  To: linux-arm-kernel

Hello!

On May 4, 2011, at 2:38 AM, Mike Rapoport wrote:

> On 05/04/11 07:10, Oleg Drokin wrote:
>> Ok, so here's a simple patch to save everyone trouble, I guess.
>> 
>> Though on the other hand I can imagine that perhaps including this generic common-board-devices.c
>> might not be desirable for people that don't use anything from that file.
> Since the common-board-devices.c has TWL initialization I doubt there would a
> board that does not use it at all...

Actually the twl init you have is somewhat inflexible.
E.g. on the Nook Color the 1st i2c bus has the twl and some other devices, but I don't see how
to put more than just the twl on the first bus with your common code.

Bye,
    Oleg

^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2011-05-04 15:54 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-24 22:09 [PATCH 0/4] omap: cleanup board files Mike Rapoport
2011-04-24 22:09 ` [PATCH 1/4] omap: consolidate touch screen initialization among different boards Mike Rapoport
2011-05-04  3:10   ` Oleg Drokin
2011-05-04 14:02   ` Thomas Weber
2011-05-04 15:10     ` Igor Grinberg
2011-04-24 22:09 ` [PATCH 2/4] omap: use common initialization for PMIC i2c bus Mike Rapoport
2011-04-24 22:09 ` [PATCH 3/4] omap: move detection of NAND CS to common-board-devices Mike Rapoport
2011-05-04  3:12   ` Oleg Drokin
2011-05-04  4:10     ` Oleg Drokin
2011-05-04  6:38       ` Mike Rapoport
2011-05-04  6:46         ` Tony Lindgren
2011-05-04  7:17           ` Mike Rapoport
2011-05-04  8:38             ` Tony Lindgren
2011-05-04 15:54         ` Oleg Drokin
2011-04-24 22:09 ` [PATCH 4/4] omap: musb: introduce default baord config Mike Rapoport
2011-04-27  4:23   ` Oleg Drokin
2011-04-27  7:23     ` Mike Rapoport
2011-04-28 14:18     ` Russell King - ARM Linux
2011-04-28 16:21       ` Oleg Drokin
2011-04-28 16:28         ` Russell King - ARM Linux
2011-04-28 16:36           ` Oleg Drokin
2011-05-02 14:20             ` Tony Lindgren
2011-05-02 14:25               ` Felipe Balbi
2011-05-03  7:50                 ` Tony Lindgren
2011-04-27  8:56   ` [PATCH v2 4/4] omap: musb: introduce default board config Mike Rapoport
2011-05-03  8:24     ` Felipe Balbi
2011-05-02 13:57 ` [PATCH 0/4] omap: cleanup board files Mike Rapoport
2011-05-02 14:22   ` Tony Lindgren
2011-05-03 10:25     ` Tony Lindgren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).