Re: [PATCH 1/4] omap: consolidate touch screen initialization among different boards

2011-05-04 Thread Thomas Weber
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 m...@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   = 150,
 - .controller_data= ads7846_mcspi_config,
 - .irq= OMAP_GPIO_IRQ(OMAP3_DEVKIT_TS_GPIO),
 - .platform_data  = ads7846_config,
 - }
 -};
 -
  #define OMAP_DM9000_BASE 0x2c00
  
  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 000..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 m...@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 

Re: [PATCH 1/4] omap: consolidate touch screen initialization among different boards

2011-05-04 Thread Igor Grinberg
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.

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/4] omap: consolidate touch screen initialization among different boards

2011-05-03 Thread Oleg Drokin
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 000..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--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/4] omap: consolidate touch screen initialization among different boards

2011-04-24 Thread 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 m...@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 at 1.5MHz
-*/
-   .modalias   = ads7846,
-   .bus_num= 1,
-   .chip_select= 0,
-   .max_speed_hz   = 150,
-   .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,