aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/mach-omap2/Makefile2
-rw-r--r--arch/arm/mach-omap2/board-3430sdp.c65
-rw-r--r--arch/arm/mach-omap2/board-cm-t35.c58
-rw-r--r--arch/arm/mach-omap2/board-devkit8000.c56
-rw-r--r--arch/arm/mach-omap2/board-ldp.c57
-rw-r--r--arch/arm/mach-omap2/board-omap3evm.c51
-rw-r--r--arch/arm/mach-omap2/board-omap3pandora.c49
-rw-r--r--arch/arm/mach-omap2/board-omap3stalker.c49
-rw-r--r--arch/arm/mach-omap2/board-omap3touchbook.c36
-rw-r--r--arch/arm/mach-omap2/board-overo.c46
-rw-r--r--arch/arm/mach-omap2/common-board-devices.c85
-rw-r--r--arch/arm/mach-omap2/common-board-devices.h18
12 files changed, 128 insertions, 444 deletions
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index a45cd6409686..a0c2caefc747 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -270,3 +270,5 @@ obj-$(CONFIG_ARCH_OMAP4) += hwspinlock.o
270 270
271disp-$(CONFIG_OMAP2_DSS) := display.o 271disp-$(CONFIG_OMAP2_DSS) := display.o
272obj-y += $(disp-m) $(disp-y) 272obj-y += $(disp-m) $(disp-y)
273
274obj-y += common-board-devices.o
diff --git a/arch/arm/mach-omap2/board-3430sdp.c b/arch/arm/mach-omap2/board-3430sdp.c
index 9afd087cc29c..3726465d34e3 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -19,7 +19,6 @@
19#include <linux/input.h> 19#include <linux/input.h>
20#include <linux/input/matrix_keypad.h> 20#include <linux/input/matrix_keypad.h>
21#include <linux/spi/spi.h> 21#include <linux/spi/spi.h>
22#include <linux/spi/ads7846.h>
23#include <linux/i2c/twl.h> 22#include <linux/i2c/twl.h>
24#include <linux/regulator/machine.h> 23#include <linux/regulator/machine.h>
25#include <linux/io.h> 24#include <linux/io.h>
@@ -48,6 +47,7 @@
48#include "hsmmc.h" 47#include "hsmmc.h"
49#include "pm.h" 48#include "pm.h"
50#include "control.h" 49#include "control.h"
50#include "common-board-devices.h"
51 51
52#define CONFIG_DISABLE_HFCLK 1 52#define CONFIG_DISABLE_HFCLK 1
53 53
@@ -123,58 +123,6 @@ static struct twl4030_keypad_data sdp3430_kp_data = {
123 .rep = 1, 123 .rep = 1,
124}; 124};
125 125
126static int ts_gpio; /* Needed for ads7846_get_pendown_state */
127
128/**
129 * @brief ads7846_dev_init : Requests & sets GPIO line for pen-irq
130 *
131 * @return - void. If request gpio fails then Flag KERN_ERR.
132 */
133static void ads7846_dev_init(void)
134{
135 if (gpio_request(ts_gpio, "ADS7846 pendown") < 0) {
136 printk(KERN_ERR "can't get ads746 pen down GPIO\n");
137 return;
138 }
139
140 gpio_direction_input(ts_gpio);
141 gpio_set_debounce(ts_gpio, 310);
142}
143
144static int ads7846_get_pendown_state(void)
145{
146 return !gpio_get_value(ts_gpio);
147}
148
149static struct ads7846_platform_data tsc2046_config __initdata = {
150 .get_pendown_state = ads7846_get_pendown_state,
151 .keep_vref_on = 1,
152 .wakeup = true,
153};
154
155
156static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
157 .turbo_mode = 0,
158 .single_channel = 1, /* 0: slave, 1: master */
159};
160
161static struct spi_board_info sdp3430_spi_board_info[] __initdata = {
162 [0] = {
163 /*
164 * TSC2046 operates at a max freqency of 2MHz, so
165 * operate slightly below at 1.5MHz
166 */
167 .modalias = "ads7846",
168 .bus_num = 1,
169 .chip_select = 0,
170 .max_speed_hz = 1500000,
171 .controller_data = &tsc2046_mcspi_config,
172 .irq = 0,
173 .platform_data = &tsc2046_config,
174 },
175};
176
177
178#define SDP3430_LCD_PANEL_BACKLIGHT_GPIO 8 126#define SDP3430_LCD_PANEL_BACKLIGHT_GPIO 8
179#define SDP3430_LCD_PANEL_ENABLE_GPIO 5 127#define SDP3430_LCD_PANEL_ENABLE_GPIO 5
180 128
@@ -880,6 +828,8 @@ static struct omap_musb_board_data musb_board_data = {
880 828
881static void __init omap_3430sdp_init(void) 829static void __init omap_3430sdp_init(void)
882{ 830{
831 int gpio_pendown;
832
883 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB); 833 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
884 omap_board_config = sdp3430_config; 834 omap_board_config = sdp3430_config;
885 omap_board_config_size = ARRAY_SIZE(sdp3430_config); 835 omap_board_config_size = ARRAY_SIZE(sdp3430_config);
@@ -887,13 +837,10 @@ static void __init omap_3430sdp_init(void)
887 omap3430_i2c_init(); 837 omap3430_i2c_init();
888 omap_display_init(&sdp3430_dss_data); 838 omap_display_init(&sdp3430_dss_data);
889 if (omap_rev() > OMAP3430_REV_ES1_0) 839 if (omap_rev() > OMAP3430_REV_ES1_0)
890 ts_gpio = SDP3430_TS_GPIO_IRQ_SDPV2; 840 gpio_pendown = SDP3430_TS_GPIO_IRQ_SDPV2;
891 else 841 else
892 ts_gpio = SDP3430_TS_GPIO_IRQ_SDPV1; 842 gpio_pendown = SDP3430_TS_GPIO_IRQ_SDPV1;
893 sdp3430_spi_board_info[0].irq = gpio_to_irq(ts_gpio); 843 omap_ads7846_init(1, gpio_pendown, 310, NULL);
894 spi_register_board_info(sdp3430_spi_board_info,
895 ARRAY_SIZE(sdp3430_spi_board_info));
896 ads7846_dev_init();
897 board_serial_init(); 844 board_serial_init();
898 usb_musb_init(&musb_board_data); 845 usb_musb_init(&musb_board_data);
899 board_smc91x_init(); 846 board_smc91x_init();
diff --git a/arch/arm/mach-omap2/board-cm-t35.c b/arch/arm/mach-omap2/board-cm-t35.c
index 7c70f56d628c..4af5cf9ef43a 100644
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -54,6 +54,7 @@
54#include "mux.h" 54#include "mux.h"
55#include "sdram-micron-mt46h32m32lf-6.h" 55#include "sdram-micron-mt46h32m32lf-6.h"
56#include "hsmmc.h" 56#include "hsmmc.h"
57#include "common-board-devices.h"
57 58
58#define CM_T35_GPIO_PENDOWN 57 59#define CM_T35_GPIO_PENDOWN 57
59 60
@@ -177,61 +178,6 @@ static void __init cm_t35_init_nand(void)
177static inline void cm_t35_init_nand(void) {} 178static inline void cm_t35_init_nand(void) {}
178#endif 179#endif
179 180
180#if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
181 defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
182#include <linux/spi/ads7846.h>
183
184static struct omap2_mcspi_device_config ads7846_mcspi_config = {
185 .turbo_mode = 0,
186 .single_channel = 1, /* 0: slave, 1: master */
187};
188
189static int ads7846_get_pendown_state(void)
190{
191 return !gpio_get_value(CM_T35_GPIO_PENDOWN);
192}
193
194static struct ads7846_platform_data ads7846_config = {
195 .x_max = 0x0fff,
196 .y_max = 0x0fff,
197 .x_plate_ohms = 180,
198 .pressure_max = 255,
199 .debounce_max = 10,
200 .debounce_tol = 3,
201 .debounce_rep = 1,
202 .get_pendown_state = ads7846_get_pendown_state,
203 .keep_vref_on = 1,
204};
205
206static struct spi_board_info cm_t35_spi_board_info[] __initdata = {
207 {
208 .modalias = "ads7846",
209 .bus_num = 1,
210 .chip_select = 0,
211 .max_speed_hz = 1500000,
212 .controller_data = &ads7846_mcspi_config,
213 .irq = OMAP_GPIO_IRQ(CM_T35_GPIO_PENDOWN),
214 .platform_data = &ads7846_config,
215 },
216};
217
218static void __init cm_t35_init_ads7846(void)
219{
220 if ((gpio_request(CM_T35_GPIO_PENDOWN, "ADS7846_PENDOWN") == 0) &&
221 (gpio_direction_input(CM_T35_GPIO_PENDOWN) == 0)) {
222 gpio_export(CM_T35_GPIO_PENDOWN, 0);
223 } else {
224 pr_err("CM-T35: could not obtain gpio for ADS7846_PENDOWN\n");
225 return;
226 }
227
228 spi_register_board_info(cm_t35_spi_board_info,
229 ARRAY_SIZE(cm_t35_spi_board_info));
230}
231#else
232static inline void cm_t35_init_ads7846(void) {}
233#endif
234
235#define CM_T35_LCD_EN_GPIO 157 181#define CM_T35_LCD_EN_GPIO 157
236#define CM_T35_LCD_BL_GPIO 58 182#define CM_T35_LCD_BL_GPIO 58
237#define CM_T35_DVI_EN_GPIO 54 183#define CM_T35_DVI_EN_GPIO 54
@@ -734,7 +680,7 @@ static void __init cm_t35_init(void)
734 omap_serial_init(); 680 omap_serial_init();
735 cm_t35_init_i2c(); 681 cm_t35_init_i2c();
736 cm_t35_init_nand(); 682 cm_t35_init_nand();
737 cm_t35_init_ads7846(); 683 omap_ads7846_init(1, CM_T35_GPIO_PENDOWN, 0, NULL);
738 cm_t35_init_ethernet(); 684 cm_t35_init_ethernet();
739 cm_t35_init_led(); 685 cm_t35_init_led();
740 cm_t35_init_display(); 686 cm_t35_init_display();
diff --git a/arch/arm/mach-omap2/board-devkit8000.c b/arch/arm/mach-omap2/board-devkit8000.c
index 65f9fde2c567..9f8338d15a21 100644
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -51,7 +51,6 @@
51#include <plat/mcspi.h> 51#include <plat/mcspi.h>
52#include <linux/input/matrix_keypad.h> 52#include <linux/input/matrix_keypad.h>
53#include <linux/spi/spi.h> 53#include <linux/spi/spi.h>
54#include <linux/spi/ads7846.h>
55#include <linux/dm9000.h> 54#include <linux/dm9000.h>
56#include <linux/interrupt.h> 55#include <linux/interrupt.h>
57 56
@@ -60,6 +59,7 @@
60#include "mux.h" 59#include "mux.h"
61#include "hsmmc.h" 60#include "hsmmc.h"
62#include "timer-gp.h" 61#include "timer-gp.h"
62#include "common-board-devices.h"
63 63
64#define NAND_BLOCK_SIZE SZ_128K 64#define NAND_BLOCK_SIZE SZ_128K
65 65
@@ -463,56 +463,6 @@ static void __init devkit8000_init_irq(void)
463#endif 463#endif
464} 464}
465 465
466static void __init devkit8000_ads7846_init(void)
467{
468 int gpio = OMAP3_DEVKIT_TS_GPIO;
469 int ret;
470
471 ret = gpio_request(gpio, "ads7846_pen_down");
472 if (ret < 0) {
473 printk(KERN_ERR "Failed to request GPIO %d for "
474 "ads7846 pen down IRQ\n", gpio);
475 return;
476 }
477
478 gpio_direction_input(gpio);
479}
480
481static int ads7846_get_pendown_state(void)
482{
483 return !gpio_get_value(OMAP3_DEVKIT_TS_GPIO);
484}
485
486static struct ads7846_platform_data ads7846_config = {
487 .x_max = 0x0fff,
488 .y_max = 0x0fff,
489 .x_plate_ohms = 180,
490 .pressure_max = 255,
491 .debounce_max = 10,
492 .debounce_tol = 5,
493 .debounce_rep = 1,
494 .get_pendown_state = ads7846_get_pendown_state,
495 .keep_vref_on = 1,
496 .settle_delay_usecs = 150,
497};
498
499static struct omap2_mcspi_device_config ads7846_mcspi_config = {
500 .turbo_mode = 0,
501 .single_channel = 1, /* 0: slave, 1: master */
502};
503
504static struct spi_board_info devkit8000_spi_board_info[] __initdata = {
505 {
506 .modalias = "ads7846",
507 .bus_num = 2,
508 .chip_select = 0,
509 .max_speed_hz = 1500000,
510 .controller_data = &ads7846_mcspi_config,
511 .irq = OMAP_GPIO_IRQ(OMAP3_DEVKIT_TS_GPIO),
512 .platform_data = &ads7846_config,
513 }
514};
515
516#define OMAP_DM9000_BASE 0x2c000000 466#define OMAP_DM9000_BASE 0x2c000000
517 467
518static struct resource omap_dm9000_resources[] = { 468static struct resource omap_dm9000_resources[] = {
@@ -795,10 +745,8 @@ static void __init devkit8000_init(void)
795 ARRAY_SIZE(devkit8000_devices)); 745 ARRAY_SIZE(devkit8000_devices));
796 746
797 omap_display_init(&devkit8000_dss_data); 747 omap_display_init(&devkit8000_dss_data);
798 spi_register_board_info(devkit8000_spi_board_info,
799 ARRAY_SIZE(devkit8000_spi_board_info));
800 748
801 devkit8000_ads7846_init(); 749 omap_ads7846_init(2, OMAP3_DEVKIT_TS_GPIO, 0, NULL);
802 750
803 usb_musb_init(&musb_board_data); 751 usb_musb_init(&musb_board_data);
804 usbhs_init(&usbhs_bdata); 752 usbhs_init(&usbhs_bdata);
diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
index ea9f049f9965..155b423784c5 100644
--- a/arch/arm/mach-omap2/board-ldp.c
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -22,7 +22,6 @@
22#include <linux/err.h> 22#include <linux/err.h>
23#include <linux/clk.h> 23#include <linux/clk.h>
24#include <linux/spi/spi.h> 24#include <linux/spi/spi.h>
25#include <linux/spi/ads7846.h>
26#include <linux/regulator/machine.h> 25#include <linux/regulator/machine.h>
27#include <linux/i2c/twl.h> 26#include <linux/i2c/twl.h>
28#include <linux/io.h> 27#include <linux/io.h>
@@ -49,6 +48,7 @@
49#include "mux.h" 48#include "mux.h"
50#include "hsmmc.h" 49#include "hsmmc.h"
51#include "control.h" 50#include "control.h"
51#include "common-board-devices.h"
52 52
53#define LDP_SMSC911X_CS 1 53#define LDP_SMSC911X_CS 1
54#define LDP_SMSC911X_GPIO 152 54#define LDP_SMSC911X_GPIO 152
@@ -168,55 +168,6 @@ static struct platform_device ldp_gpio_keys_device = {
168 }, 168 },
169}; 169};
170 170
171static int ts_gpio;
172
173/**
174 * @brief ads7846_dev_init : Requests & sets GPIO line for pen-irq
175 *
176 * @return - void. If request gpio fails then Flag KERN_ERR.
177 */
178static void ads7846_dev_init(void)
179{
180 if (gpio_request(ts_gpio, "ads7846 irq") < 0) {
181 printk(KERN_ERR "can't get ads746 pen down GPIO\n");
182 return;
183 }
184
185 gpio_direction_input(ts_gpio);
186 gpio_set_debounce(ts_gpio, 310);
187}
188
189static int ads7846_get_pendown_state(void)
190{
191 return !gpio_get_value(ts_gpio);
192}
193
194static struct ads7846_platform_data tsc2046_config __initdata = {
195 .get_pendown_state = ads7846_get_pendown_state,
196 .keep_vref_on = 1,
197};
198
199static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
200 .turbo_mode = 0,
201 .single_channel = 1, /* 0: slave, 1: master */
202};
203
204static struct spi_board_info ldp_spi_board_info[] __initdata = {
205 [0] = {
206 /*
207 * TSC2046 operates at a max freqency of 2MHz, so
208 * operate slightly below at 1.5MHz
209 */
210 .modalias = "ads7846",
211 .bus_num = 1,
212 .chip_select = 0,
213 .max_speed_hz = 1500000,
214 .controller_data = &tsc2046_mcspi_config,
215 .irq = 0,
216 .platform_data = &tsc2046_config,
217 },
218};
219
220static struct omap_smsc911x_platform_data smsc911x_cfg = { 171static struct omap_smsc911x_platform_data smsc911x_cfg = {
221 .cs = LDP_SMSC911X_CS, 172 .cs = LDP_SMSC911X_CS,
222 .gpio_irq = LDP_SMSC911X_GPIO, 173 .gpio_irq = LDP_SMSC911X_GPIO,
@@ -399,11 +350,7 @@ static void __init omap_ldp_init(void)
399 ldp_init_smsc911x(); 350 ldp_init_smsc911x();
400 omap_i2c_init(); 351 omap_i2c_init();
401 platform_add_devices(ldp_devices, ARRAY_SIZE(ldp_devices)); 352 platform_add_devices(ldp_devices, ARRAY_SIZE(ldp_devices));
402 ts_gpio = 54; 353 omap_ads7846_init(1, 54, 310, NULL);
403 ldp_spi_board_info[0].irq = gpio_to_irq(ts_gpio);
404 spi_register_board_info(ldp_spi_board_info,
405 ARRAY_SIZE(ldp_spi_board_info));
406 ads7846_dev_init();
407 omap_serial_init(); 354 omap_serial_init();
408 usb_musb_init(&musb_board_data); 355 usb_musb_init(&musb_board_data);
409 board_nand_init(ldp_nand_partitions, 356 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 3fc85c6fc559..376ea87dce68 100644
--- a/arch/arm/mach-omap2/board-omap3evm.c
+++ b/arch/arm/mach-omap2/board-omap3evm.c
@@ -50,6 +50,7 @@
50#include "mux.h" 50#include "mux.h"
51#include "sdram-micron-mt46h32m32lf-6.h" 51#include "sdram-micron-mt46h32m32lf-6.h"
52#include "hsmmc.h" 52#include "hsmmc.h"
53#include "common-board-devices.h"
53 54
54#define OMAP3_EVM_TS_GPIO 175 55#define OMAP3_EVM_TS_GPIO 175
55#define OMAP3_EVM_EHCI_VBUS 22 56#define OMAP3_EVM_EHCI_VBUS 22
@@ -630,51 +631,6 @@ static int __init omap3_evm_i2c_init(void)
630 return 0; 631 return 0;
631} 632}
632 633
633static void ads7846_dev_init(void)
634{
635 if (gpio_request(OMAP3_EVM_TS_GPIO, "ADS7846 pendown") < 0)
636 printk(KERN_ERR "can't get ads7846 pen down GPIO\n");
637
638 gpio_direction_input(OMAP3_EVM_TS_GPIO);
639 gpio_set_debounce(OMAP3_EVM_TS_GPIO, 310);
640}
641
642static int ads7846_get_pendown_state(void)
643{
644 return !gpio_get_value(OMAP3_EVM_TS_GPIO);
645}
646
647static struct ads7846_platform_data ads7846_config = {
648 .x_max = 0x0fff,
649 .y_max = 0x0fff,
650 .x_plate_ohms = 180,
651 .pressure_max = 255,
652 .debounce_max = 10,
653 .debounce_tol = 3,
654 .debounce_rep = 1,
655 .get_pendown_state = ads7846_get_pendown_state,
656 .keep_vref_on = 1,
657 .settle_delay_usecs = 150,
658 .wakeup = true,
659};
660
661static struct omap2_mcspi_device_config ads7846_mcspi_config = {
662 .turbo_mode = 0,
663 .single_channel = 1, /* 0: slave, 1: master */
664};
665
666static struct spi_board_info omap3evm_spi_board_info[] = {
667 [0] = {
668 .modalias = "ads7846",
669 .bus_num = 1,
670 .chip_select = 0,
671 .max_speed_hz = 1500000,
672 .controller_data = &ads7846_mcspi_config,
673 .irq = OMAP_GPIO_IRQ(OMAP3_EVM_TS_GPIO),
674 .platform_data = &ads7846_config,
675 },
676};
677
678static struct omap_board_config_kernel omap3_evm_config[] __initdata = { 634static struct omap_board_config_kernel omap3_evm_config[] __initdata = {
679}; 635};
680 636
@@ -792,9 +748,6 @@ static void __init omap3_evm_init(void)
792 748
793 omap_display_init(&omap3_evm_dss_data); 749 omap_display_init(&omap3_evm_dss_data);
794 750
795 spi_register_board_info(omap3evm_spi_board_info,
796 ARRAY_SIZE(omap3evm_spi_board_info));
797
798 omap_serial_init(); 751 omap_serial_init();
799 752
800 /* OMAP3EVM uses ISP1504 phy and so register nop transceiver */ 753 /* OMAP3EVM uses ISP1504 phy and so register nop transceiver */
@@ -827,7 +780,7 @@ static void __init omap3_evm_init(void)
827 } 780 }
828 usb_musb_init(&musb_board_data); 781 usb_musb_init(&musb_board_data);
829 usbhs_init(&usbhs_bdata); 782 usbhs_init(&usbhs_bdata);
830 ads7846_dev_init(); 783 omap_ads7846_init(1, OMAP3_EVM_TS_GPIO, 310, NULL);
831 omap3evm_init_smsc911x(); 784 omap3evm_init_smsc911x();
832 omap3_evm_display_init(); 785 omap3_evm_display_init();
833 786
diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
index 07dba888f450..517701aae3ca 100644
--- a/arch/arm/mach-omap2/board-omap3pandora.c
+++ b/arch/arm/mach-omap2/board-omap3pandora.c
@@ -22,7 +22,6 @@
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23 23
24#include <linux/spi/spi.h> 24#include <linux/spi/spi.h>
25#include <linux/spi/ads7846.h>
26#include <linux/regulator/machine.h> 25#include <linux/regulator/machine.h>
27#include <linux/i2c/twl.h> 26#include <linux/i2c/twl.h>
28#include <linux/wl12xx.h> 27#include <linux/wl12xx.h>
@@ -52,6 +51,7 @@
52#include "mux.h" 51#include "mux.h"
53#include "sdram-micron-mt46h32m32lf-6.h" 52#include "sdram-micron-mt46h32m32lf-6.h"
54#include "hsmmc.h" 53#include "hsmmc.h"
54#include "common-board-devices.h"
55 55
56#define PANDORA_WIFI_IRQ_GPIO 21 56#define PANDORA_WIFI_IRQ_GPIO 21
57#define PANDORA_WIFI_NRESET_GPIO 23 57#define PANDORA_WIFI_NRESET_GPIO 23
@@ -570,53 +570,8 @@ static int __init omap3pandora_i2c_init(void)
570 return 0; 570 return 0;
571} 571}
572 572
573static void __init omap3pandora_ads7846_init(void)
574{
575 int gpio = OMAP3_PANDORA_TS_GPIO;
576 int ret;
577
578 ret = gpio_request(gpio, "ads7846_pen_down");
579 if (ret < 0) {
580 printk(KERN_ERR "Failed to request GPIO %d for "
581 "ads7846 pen down IRQ\n", gpio);
582 return;
583 }
584
585 gpio_direction_input(gpio);
586}
587
588static int ads7846_get_pendown_state(void)
589{
590 return !gpio_get_value(OMAP3_PANDORA_TS_GPIO);
591}
592
593static struct ads7846_platform_data ads7846_config = {
594 .x_max = 0x0fff,
595 .y_max = 0x0fff,
596 .x_plate_ohms = 180,
597 .pressure_max = 255,
598 .debounce_max = 10,
599 .debounce_tol = 3,
600 .debounce_rep = 1,
601 .get_pendown_state = ads7846_get_pendown_state,
602 .keep_vref_on = 1,
603};
604
605static struct omap2_mcspi_device_config ads7846_mcspi_config = {
606 .turbo_mode = 0,
607 .single_channel = 1, /* 0: slave, 1: master */
608};
609
610static struct spi_board_info omap3pandora_spi_board_info[] __initdata = { 573static struct spi_board_info omap3pandora_spi_board_info[] __initdata = {
611 { 574 {
612 .modalias = "ads7846",
613 .bus_num = 1,
614 .chip_select = 0,
615 .max_speed_hz = 1500000,
616 .controller_data = &ads7846_mcspi_config,
617 .irq = OMAP_GPIO_IRQ(OMAP3_PANDORA_TS_GPIO),
618 .platform_data = &ads7846_config,
619 }, {
620 .modalias = "tpo_td043mtea1_panel_spi", 575 .modalias = "tpo_td043mtea1_panel_spi",
621 .bus_num = 1, 576 .bus_num = 1,
622 .chip_select = 1, 577 .chip_select = 1,
@@ -705,7 +660,7 @@ static void __init omap3pandora_init(void)
705 omap_serial_init(); 660 omap_serial_init();
706 spi_register_board_info(omap3pandora_spi_board_info, 661 spi_register_board_info(omap3pandora_spi_board_info,
707 ARRAY_SIZE(omap3pandora_spi_board_info)); 662 ARRAY_SIZE(omap3pandora_spi_board_info));
708 omap3pandora_ads7846_init(); 663 omap_ads7846_init(1, OMAP3_PANDORA_TS_GPIO, 0, NULL);
709 usbhs_init(&usbhs_bdata); 664 usbhs_init(&usbhs_bdata);
710 usb_musb_init(&musb_board_data); 665 usb_musb_init(&musb_board_data);
711 gpmc_nand_init(&pandora_nand_data); 666 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 848016c6a245..671ceb0c7a6f 100644
--- a/arch/arm/mach-omap2/board-omap3stalker.c
+++ b/arch/arm/mach-omap2/board-omap3stalker.c
@@ -45,7 +45,6 @@
45#include <plat/mcspi.h> 45#include <plat/mcspi.h>
46#include <linux/input/matrix_keypad.h> 46#include <linux/input/matrix_keypad.h>
47#include <linux/spi/spi.h> 47#include <linux/spi/spi.h>
48#include <linux/spi/ads7846.h>
49#include <linux/interrupt.h> 48#include <linux/interrupt.h>
50#include <linux/smsc911x.h> 49#include <linux/smsc911x.h>
51#include <linux/i2c/at24.h> 50#include <linux/i2c/at24.h>
@@ -54,6 +53,7 @@
54#include "mux.h" 53#include "mux.h"
55#include "hsmmc.h" 54#include "hsmmc.h"
56#include "timer-gp.h" 55#include "timer-gp.h"
56#include "common-board-devices.h"
57 57
58#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE) 58#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
59#include <plat/gpmc-smsc911x.h> 59#include <plat/gpmc-smsc911x.h>
@@ -498,49 +498,6 @@ static int __init omap3_stalker_i2c_init(void)
498} 498}
499 499
500#define OMAP3_STALKER_TS_GPIO 175 500#define OMAP3_STALKER_TS_GPIO 175
501static void ads7846_dev_init(void)
502{
503 if (gpio_request(OMAP3_STALKER_TS_GPIO, "ADS7846 pendown") < 0)
504 printk(KERN_ERR "can't get ads7846 pen down GPIO\n");
505
506 gpio_direction_input(OMAP3_STALKER_TS_GPIO);
507 gpio_set_debounce(OMAP3_STALKER_TS_GPIO, 310);
508}
509
510static int ads7846_get_pendown_state(void)
511{
512 return !gpio_get_value(OMAP3_STALKER_TS_GPIO);
513}
514
515static struct ads7846_platform_data ads7846_config = {
516 .x_max = 0x0fff,
517 .y_max = 0x0fff,
518 .x_plate_ohms = 180,
519 .pressure_max = 255,
520 .debounce_max = 10,
521 .debounce_tol = 3,
522 .debounce_rep = 1,
523 .get_pendown_state = ads7846_get_pendown_state,
524 .keep_vref_on = 1,
525 .settle_delay_usecs = 150,
526};
527
528static struct omap2_mcspi_device_config ads7846_mcspi_config = {
529 .turbo_mode = 0,
530 .single_channel = 1, /* 0: slave, 1: master */
531};
532
533static struct spi_board_info omap3stalker_spi_board_info[] = {
534 [0] = {
535 .modalias = "ads7846",
536 .bus_num = 1,
537 .chip_select = 0,
538 .max_speed_hz = 1500000,
539 .controller_data = &ads7846_mcspi_config,
540 .irq = OMAP_GPIO_IRQ(OMAP3_STALKER_TS_GPIO),
541 .platform_data = &ads7846_config,
542 },
543};
544 501
545static struct omap_board_config_kernel omap3_stalker_config[] __initdata = { 502static struct omap_board_config_kernel omap3_stalker_config[] __initdata = {
546}; 503};
@@ -602,13 +559,11 @@ static void __init omap3_stalker_init(void)
602 ARRAY_SIZE(omap3_stalker_devices)); 559 ARRAY_SIZE(omap3_stalker_devices));
603 560
604 omap_display_init(&omap3_stalker_dss_data); 561 omap_display_init(&omap3_stalker_dss_data);
605 spi_register_board_info(omap3stalker_spi_board_info,
606 ARRAY_SIZE(omap3stalker_spi_board_info));
607 562
608 omap_serial_init(); 563 omap_serial_init();
609 usb_musb_init(&musb_board_data); 564 usb_musb_init(&musb_board_data);
610 usbhs_init(&usbhs_bdata); 565 usbhs_init(&usbhs_bdata);
611 ads7846_dev_init(); 566 omap_ads7846_init(1, OMAP3_STALKER_TS_GPIO, 310, NULL);
612 567
613 omap_mux_init_gpio(21, OMAP_PIN_OUTPUT); 568 omap_mux_init_gpio(21, OMAP_PIN_OUTPUT);
614 omap_mux_init_gpio(18, OMAP_PIN_INPUT_PULLUP); 569 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 127cb1752bdd..15f9d7ddc230 100644
--- a/arch/arm/mach-omap2/board-omap3touchbook.c
+++ b/arch/arm/mach-omap2/board-omap3touchbook.c
@@ -52,6 +52,7 @@
52#include "mux.h" 52#include "mux.h"
53#include "hsmmc.h" 53#include "hsmmc.h"
54#include "timer-gp.h" 54#include "timer-gp.h"
55#include "common-board-devices.h"
55 56
56#include <asm/setup.h> 57#include <asm/setup.h>
57 58
@@ -301,19 +302,7 @@ static int __init omap3_touchbook_i2c_init(void)
301 return 0; 302 return 0;
302} 303}
303 304
304static void __init omap3_ads7846_init(void) 305static struct ads7846_platform_data ads7846_pdata = {
305{
306 if (gpio_request(OMAP3_TS_GPIO, "ads7846_pen_down")) {
307 printk(KERN_ERR "Failed to request GPIO %d for "
308 "ads7846 pen down IRQ\n", OMAP3_TS_GPIO);
309 return;
310 }
311
312 gpio_direction_input(OMAP3_TS_GPIO);
313 gpio_set_debounce(OMAP3_TS_GPIO, 310);
314}
315
316static struct ads7846_platform_data ads7846_config = {
317 .x_min = 100, 306 .x_min = 100,
318 .y_min = 265, 307 .y_min = 265,
319 .x_max = 3950, 308 .x_max = 3950,
@@ -327,23 +316,6 @@ static struct ads7846_platform_data ads7846_config = {
327 .keep_vref_on = 1, 316 .keep_vref_on = 1,
328}; 317};
329 318
330static struct omap2_mcspi_device_config ads7846_mcspi_config = {
331 .turbo_mode = 0,
332 .single_channel = 1, /* 0: slave, 1: master */
333};
334
335static struct spi_board_info omap3_ads7846_spi_board_info[] __initdata = {
336 {
337 .modalias = "ads7846",
338 .bus_num = 4,
339 .chip_select = 0,
340 .max_speed_hz = 1500000,
341 .controller_data = &ads7846_mcspi_config,
342 .irq = OMAP_GPIO_IRQ(OMAP3_TS_GPIO),
343 .platform_data = &ads7846_config,
344 }
345};
346
347static struct gpio_led gpio_leds[] = { 319static struct gpio_led gpio_leds[] = {
348 { 320 {
349 .name = "touchbook::usr0", 321 .name = "touchbook::usr0",
@@ -526,9 +498,7 @@ static void __init omap3_touchbook_init(void)
526 gpio_direction_output(176, true); 498 gpio_direction_output(176, true);
527 499
528 /* Touchscreen and accelerometer */ 500 /* Touchscreen and accelerometer */
529 spi_register_board_info(omap3_ads7846_spi_board_info, 501 omap_ads7846_init(4, OMAP3_TS_GPIO, 310, &ads7846_pdata);
530 ARRAY_SIZE(omap3_ads7846_spi_board_info));
531 omap3_ads7846_init();
532 usb_musb_init(&musb_board_data); 502 usb_musb_init(&musb_board_data);
533 usbhs_init(&usbhs_bdata); 503 usbhs_init(&usbhs_bdata);
534 omap3touchbook_flash_init(); 504 omap3touchbook_flash_init();
diff --git a/arch/arm/mach-omap2/board-overo.c b/arch/arm/mach-omap2/board-overo.c
index 165e1faea1b7..4a02f8434f59 100644
--- a/arch/arm/mach-omap2/board-overo.c
+++ b/arch/arm/mach-omap2/board-overo.c
@@ -56,6 +56,7 @@
56#include "mux.h" 56#include "mux.h"
57#include "sdram-micron-mt46h32m32lf-6.h" 57#include "sdram-micron-mt46h32m32lf-6.h"
58#include "hsmmc.h" 58#include "hsmmc.h"
59#include "common-board-devices.h"
59 60
60#define OVERO_GPIO_BT_XGATE 15 61#define OVERO_GPIO_BT_XGATE 15
61#define OVERO_GPIO_W2W_NRESET 16 62#define OVERO_GPIO_W2W_NRESET 16
@@ -74,30 +75,6 @@
74#if defined(CONFIG_TOUCHSCREEN_ADS7846) || \ 75#if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
75 defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) 76 defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
76 77
77#include <linux/spi/ads7846.h>
78
79static struct omap2_mcspi_device_config ads7846_mcspi_config = {
80 .turbo_mode = 0,
81 .single_channel = 1, /* 0: slave, 1: master */
82};
83
84static int ads7846_get_pendown_state(void)
85{
86 return !gpio_get_value(OVERO_GPIO_PENDOWN);
87}
88
89static struct ads7846_platform_data ads7846_config = {
90 .x_max = 0x0fff,
91 .y_max = 0x0fff,
92 .x_plate_ohms = 180,
93 .pressure_max = 255,
94 .debounce_max = 10,
95 .debounce_tol = 3,
96 .debounce_rep = 1,
97 .get_pendown_state = ads7846_get_pendown_state,
98 .keep_vref_on = 1,
99};
100
101/* fixed regulator for ads7846 */ 78/* fixed regulator for ads7846 */
102static struct regulator_consumer_supply ads7846_supply = 79static struct regulator_consumer_supply ads7846_supply =
103 REGULATOR_SUPPLY("vcc", "spi1.0"); 80 REGULATOR_SUPPLY("vcc", "spi1.0");
@@ -128,14 +105,7 @@ static struct platform_device vads7846_device = {
128 105
129static void __init overo_ads7846_init(void) 106static void __init overo_ads7846_init(void)
130{ 107{
131 if ((gpio_request(OVERO_GPIO_PENDOWN, "ADS7846_PENDOWN") == 0) && 108 omap_ads7846_init(1, OVERO_GPIO_PENDOWN, 0, NULL);
132 (gpio_direction_input(OVERO_GPIO_PENDOWN) == 0)) {
133 gpio_export(OVERO_GPIO_PENDOWN, 0);
134 } else {
135 printk(KERN_ERR "could not obtain gpio for ADS7846_PENDOWN\n");
136 return;
137 }
138
139 platform_device_register(&vads7846_device); 109 platform_device_register(&vads7846_device);
140} 110}
141 111
@@ -589,18 +559,6 @@ static int __init overo_i2c_init(void)
589} 559}
590 560
591static struct spi_board_info overo_spi_board_info[] __initdata = { 561static struct spi_board_info overo_spi_board_info[] __initdata = {
592#if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
593 defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
594 {
595 .modalias = "ads7846",
596 .bus_num = 1,
597 .chip_select = 0,
598 .max_speed_hz = 1500000,
599 .controller_data = &ads7846_mcspi_config,
600 .irq = OMAP_GPIO_IRQ(OVERO_GPIO_PENDOWN),
601 .platform_data = &ads7846_config,
602 },
603#endif
604#if defined(CONFIG_PANEL_LGPHILIPS_LB035Q02) || \ 562#if defined(CONFIG_PANEL_LGPHILIPS_LB035Q02) || \
605 defined(CONFIG_PANEL_LGPHILIPS_LB035Q02_MODULE) 563 defined(CONFIG_PANEL_LGPHILIPS_LB035Q02_MODULE)
606 { 564 {
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 000000000000..fad41ec62300
--- /dev/null
+++ b/arch/arm/mach-omap2/common-board-devices.c
@@ -0,0 +1,85 @@
1/*
2 * common-board-devices.c
3 *
4 * Copyright (C) 2011 CompuLab, Ltd.
5 * Author: Mike Rapoport <mike@compulab.co.il>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2 as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19 * 02110-1301 USA
20 *
21 */
22
23#include <linux/gpio.h>
24#include <linux/spi/spi.h>
25#include <linux/spi/ads7846.h>
26
27#include <plat/mcspi.h>
28
29#include "common-board-devices.h"
30
31static struct omap2_mcspi_device_config ads7846_mcspi_config = {
32 .turbo_mode = 0,
33 .single_channel = 1, /* 0: slave, 1: master */
34};
35
36static struct ads7846_platform_data ads7846_config = {
37 .x_max = 0x0fff,
38 .y_max = 0x0fff,
39 .x_plate_ohms = 180,
40 .pressure_max = 255,
41 .debounce_max = 10,
42 .debounce_tol = 3,
43 .debounce_rep = 1,
44 .gpio_pendown = -EINVAL,
45 .keep_vref_on = 1,
46};
47
48static struct spi_board_info ads7846_spi_board_info __initdata = {
49 .modalias = "ads7846",
50 .bus_num = -EINVAL,
51 .chip_select = 0,
52 .max_speed_hz = 1500000,
53 .controller_data = &ads7846_mcspi_config,
54 .irq = -EINVAL,
55 .platform_data = &ads7846_config,
56};
57
58void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
59 struct ads7846_platform_data *board_pdata)
60{
61 struct spi_board_info *spi_bi = &ads7846_spi_board_info;
62 int err;
63
64 err = gpio_request(gpio_pendown, "TS PenDown");
65 if (err) {
66 pr_err("Could not obtain gpio for TS PenDown: %d\n", err);
67 return;
68 }
69
70 gpio_direction_input(gpio_pendown);
71 gpio_export(gpio_pendown, 0);
72
73 if (gpio_debounce)
74 gpio_set_debounce(gpio_pendown, gpio_debounce);
75
76 ads7846_config.gpio_pendown = gpio_pendown;
77
78 spi_bi->bus_num = bus_num;
79 spi_bi->irq = OMAP_GPIO_IRQ(gpio_pendown);
80
81 if (board_pdata)
82 spi_bi->platform_data = board_pdata;
83
84 spi_register_board_info(&ads7846_spi_board_info, 1);
85}
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 000000000000..75f9248d0bf2
--- /dev/null
+++ b/arch/arm/mach-omap2/common-board-devices.h
@@ -0,0 +1,18 @@
1#ifndef __OMAP_COMMON_BOARD_DEVICES__
2#define __OMAP_COMMON_BOARD_DEVICES__
3
4#if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
5 defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
6struct ads7846_platform_data;
7
8void omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
9 struct ads7846_platform_data *board_pdata);
10#else
11static inline void omap_ads7846_init(int bus_num,
12 int gpio_pendown, int gpio_debounce,
13 struct ads7846_platform_data *board_data)
14{
15}
16#endif
17
18#endif /* __OMAP_COMMON_BOARD_DEVICES__ */