From patchwork Tue Oct 2 08:13:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 11904 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 26D8324146 for ; Tue, 2 Oct 2012 08:13:41 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id B48EBA181F7 for ; Tue, 2 Oct 2012 08:13:40 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so13594640iej.11 for ; Tue, 02 Oct 2012 01:13:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=FcVi3pHZnhJmW97FRmbeF4/mOdUkGK48KA09HzHZY8w=; b=inZb6u/+kzDzegMYyk8FDVXc33kXVesH3Wr7B85TV6LR+i12tuO/JYqgBGCRDTh5w1 imB4Mh0k7n0RAHyq25sfNsSd8aTeQqAwuLccabmoUZlFp/eLgWYt2zz5jHbxLRigiKyw XqTCawGlOKw2i5LvAg8zdY7f/oC1VN6YwdUJjgOIEXwvcyP6scS9e1QMaFjsqqDoPKOT 2eM9WE010XSNHDoc3erxhqYiVfQdKmbA1eIyeXTomjIPrJcLYE9sISf/+th12NePmt46 QCvoO1FcHMJlqlsnvSZYHyKGekkm3LSXkrWKqGbupQRzbmDizQF7l/HWl5yF1PX7zMqE q6qw== Received: by 10.50.150.198 with SMTP id uk6mr8020364igb.43.1349165620461; Tue, 02 Oct 2012 01:13:40 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp69880igc; Tue, 2 Oct 2012 01:13:39 -0700 (PDT) Received: by 10.180.73.76 with SMTP id j12mr20124539wiv.11.1349165618949; Tue, 02 Oct 2012 01:13:38 -0700 (PDT) Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by mx.google.com with ESMTPS id by15si808019wib.34.2012.10.02.01.13.38 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 02 Oct 2012 01:13:38 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.178 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.212.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.178 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by mail-wi0-f178.google.com with SMTP id hr7so386331wib.13 for ; Tue, 02 Oct 2012 01:13:38 -0700 (PDT) Received: by 10.180.85.99 with SMTP id g3mr20114480wiz.5.1349165618456; Tue, 02 Oct 2012 01:13:38 -0700 (PDT) Received: from localhost.localdomain (cpc1-aztw13-0-0-cust473.18-1.cable.virginmedia.com. [77.102.241.218]) by mx.google.com with ESMTPS id p4sm1193936wix.0.2012.10.02.01.13.37 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 02 Oct 2012 01:13:37 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: arnd@arndb.de, linus.walleij@stericsson.com, Lee Jones , Dmitry Torokhov , linux-input@vger.kernel.org Subject: [PATCH 04/10] Input: bu21013_ts - Move GPIO init and exit functions into the driver Date: Tue, 2 Oct 2012 09:13:17 +0100 Message-Id: <1349165603-24401-5-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1349165603-24401-1-git-send-email-lee.jones@linaro.org> References: <1349165603-24401-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQkOkYc4f7ZgMrxv3N6YEy3fvrDmw+r+7gtfFDFVWwvJ1U+bY/5pvAl+wpzatlurx1SPwyZ2 These GPIO init and exit functions have no place in platform data. Instead they should be part of the driver. This patch moves them to their rightful place, which subsequently elevates platform data of yet more cruft. Cc: Dmitry Torokhov Cc: linux-input@vger.kernel.org Signed-off-by: Lee Jones --- arch/arm/mach-ux500/board-mop500-stuib.c | 70 +-------------------------- drivers/input/touchscreen/bu21013_ts.c | 76 ++++++++++++++++++++++++++---- include/linux/input/bu21013.h | 8 +--- 3 files changed, 70 insertions(+), 84 deletions(-) diff --git a/arch/arm/mach-ux500/board-mop500-stuib.c b/arch/arm/mach-ux500/board-mop500-stuib.c index 564f57d..eb19a7e 100644 --- a/arch/arm/mach-ux500/board-mop500-stuib.c +++ b/arch/arm/mach-ux500/board-mop500-stuib.c @@ -77,9 +77,6 @@ static struct i2c_board_info __initdata mop500_i2c0_devices_stuib[] = { * BU21013 ROHM touchscreen interface on the STUIBs */ -/* tracks number of bu21013 devices being enabled */ -static int bu21013_devices; - #define TOUCH_GPIO_PIN 84 #define TOUCH_XMAX 384 @@ -88,73 +85,8 @@ static int bu21013_devices; #define PRCMU_CLOCK_OCR 0x1CC #define TSC_EXT_CLOCK_9_6MHZ 0x840000 -/** - * bu21013_gpio_board_init : configures the touch panel. - * @reset_pin: reset pin number - * This function can be used to configures - * the voltage and reset the touch panel controller. - */ -static int bu21013_gpio_board_init(int reset_pin) -{ - int retval = 0; - - bu21013_devices++; - if (bu21013_devices == 1) { - retval = gpio_request(reset_pin, "touchp_reset"); - if (retval) { - printk(KERN_ERR "Unable to request gpio reset_pin"); - return retval; - } - retval = gpio_direction_output(reset_pin, 1); - if (retval < 0) { - printk(KERN_ERR "%s: gpio direction failed\n", - __func__); - return retval; - } - } - - return retval; -} - -/** - * bu21013_gpio_board_exit : deconfigures the touch panel controller - * @reset_pin: reset pin number - * This function can be used to deconfigures the chip selection - * for touch panel controller. - */ -static int bu21013_gpio_board_exit(int reset_pin) -{ - int retval = 0; - - if (bu21013_devices == 1) { - retval = gpio_direction_output(reset_pin, 0); - if (retval < 0) { - printk(KERN_ERR "%s: gpio direction failed\n", - __func__); - return retval; - } - gpio_set_value(reset_pin, 0); - } - bu21013_devices--; - - return retval; -} - -/** - * bu21013_read_pin_val : get the interrupt pin value - * This function can be used to get the interrupt pin value for touch panel - * controller. - */ -static int bu21013_read_pin_val(void) -{ - return gpio_get_value(TOUCH_GPIO_PIN); -} - static struct bu21013_platform_device tsc_plat_device = { - .cs_en = bu21013_gpio_board_init, - .cs_dis = bu21013_gpio_board_exit, - .irq_read_val = bu21013_read_pin_val, - .irq = NOMADIK_GPIO_TO_IRQ(TOUCH_GPIO_PIN), + .touch_pin = TOUCH_GPIO_PIN, .touch_x_max = TOUCH_XMAX, .touch_y_max = TOUCH_YMAX, .ext_clk = false, diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c index 2fae682..5d8fc75 100644 --- a/drivers/input/touchscreen/bu21013_ts.c +++ b/drivers/input/touchscreen/bu21013_ts.c @@ -14,6 +14,10 @@ #include #include #include +#include + +/* Reference tracking for multiple displays. */ +static int bu21013_devices = 0; #define PEN_DOWN_INTR 0 #define MAX_FINGERS 2 @@ -262,7 +266,7 @@ static irqreturn_t bu21013_gpio_irq(int irq, void *device_data) return IRQ_NONE; } - data->intr_pin = data->chip->irq_read_val(); + data->intr_pin = gpio_get_value(data->chip->touch_pin); if (data->intr_pin == PEN_DOWN_INTR) wait_event_timeout(data->wait, data->touch_stopped, msecs_to_jiffies(2)); @@ -272,6 +276,60 @@ static irqreturn_t bu21013_gpio_irq(int irq, void *device_data) } /** + * bu21013_gpio_board_init() - configures the touch panel + * @reset_pin: reset pin number + * + * This function is used to configure the voltage and + * reset the touch panel controller. + */ +static int bu21013_gpio_board_init(int reset_pin) +{ + int retval = 0; + + bu21013_devices++; + if (bu21013_devices == 1) { + retval = gpio_request(reset_pin, "touchp_reset"); + if (retval) { + printk(KERN_ERR "Unable to request gpio reset_pin"); + return retval; + } + retval = gpio_direction_output(reset_pin, 1); + if (retval < 0) { + printk(KERN_ERR "%s: gpio direction failed\n", + __func__); + return retval; + } + } + + return retval; +} + +/** + * bu21013_gpio_board_exit() - deconfigures the touch panel controller + * @reset_pin: reset pin number + * + * This function is used to deconfigure the chip selection + * for touch panel controller. + */ +static int bu21013_gpio_board_exit(int reset_pin) +{ + int retval = 0; + + if (bu21013_devices == 1) { + retval = gpio_direction_output(reset_pin, 0); + if (retval < 0) { + printk(KERN_ERR "%s: gpio direction failed\n", + __func__); + return retval; + } + gpio_set_value(reset_pin, 0); + } + bu21013_devices--; + + return retval; +} + +/** * bu21013_init_chip() - power on sequence for the bu21013 controller * @data: device structure pointer * @@ -449,6 +507,8 @@ static int __devinit bu21013_probe(struct i2c_client *client, return -EINVAL; } + pdata->irq = gpio_to_irq(pdata->touch_pin); + bu21013_data = kzalloc(sizeof(struct bu21013_ts_data), GFP_KERNEL); in_dev = input_allocate_device(); if (!bu21013_data || !in_dev) { @@ -478,12 +538,10 @@ static int __devinit bu21013_probe(struct i2c_client *client, init_waitqueue_head(&bu21013_data->wait); /* configure the gpio pins */ - if (pdata->cs_en) { - error = pdata->cs_en(pdata->cs_pin); - if (error < 0) { - dev_err(&client->dev, "chip init failed\n"); - goto err_disable_regulator; - } + error = bu21013_gpio_board_init(pdata->cs_pin); + if (error < 0) { + dev_err(&client->dev, "chip init failed\n"); + goto err_disable_regulator; } /* configure the touch panel controller */ @@ -531,7 +589,7 @@ static int __devinit bu21013_probe(struct i2c_client *client, err_free_irq: bu21013_free_irq(bu21013_data); err_cs_disable: - pdata->cs_dis(pdata->cs_pin); + bu21013_gpio_board_exit(pdata->cs_pin); err_disable_regulator: regulator_disable(bu21013_data->regulator); err_put_regulator: @@ -555,7 +613,7 @@ static int __devexit bu21013_remove(struct i2c_client *client) bu21013_free_irq(bu21013_data); - bu21013_data->chip->cs_dis(bu21013_data->chip->cs_pin); + bu21013_gpio_board_exit(bu21013_data->chip->cs_pin); input_unregister_device(bu21013_data->in_dev); diff --git a/include/linux/input/bu21013.h b/include/linux/input/bu21013.h index 05e0328..01a2975 100644 --- a/include/linux/input/bu21013.h +++ b/include/linux/input/bu21013.h @@ -9,13 +9,11 @@ /** * struct bu21013_platform_device - Handle the platform data - * @cs_en: pointer to the cs enable function - * @cs_dis: pointer to the cs disable function - * @irq_read_val: pointer to read the pen irq value function * @touch_x_max: touch x max * @touch_y_max: touch y max * @cs_pin: chip select pin * @irq: irq pin + * @touch_pin: touch gpio pin * @ext_clk: external clock flag * @x_flip: x flip flag * @y_flip: y flip flag @@ -24,13 +22,11 @@ * This is used to handle the platform data */ struct bu21013_platform_device { - int (*cs_en)(int reset_pin); - int (*cs_dis)(int reset_pin); - int (*irq_read_val)(void); int touch_x_max; int touch_y_max; unsigned int cs_pin; unsigned int irq; + unsigned int touch_pin; bool ext_clk; bool x_flip; bool y_flip;