linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: thomas.weber.linux@googlemail.com (Thomas Weber)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/4] omap: consolidate touch screen initialization among different boards
Date: Wed, 04 May 2011 16:02:08 +0200	[thread overview]
Message-ID: <4DC15C60.9060401@gmail.com> (raw)
In-Reply-To: <1738251a50b70224f124d4a54c157cc5e3c6db77.1303682352.git.mike@compulab.co.il>

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__ */

  parent reply	other threads:[~2011-05-04 14:02 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DC15C60.9060401@gmail.com \
    --to=thomas.weber.linux@googlemail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).