diff options
| author | Lee Jones <lee.jones@linaro.org> | 2012-09-28 05:29:07 -0400 |
|---|---|---|
| committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-11-28 02:05:11 -0500 |
| commit | 31fbcda71489d8cbe2b82819eaab4818524e3a49 (patch) | |
| tree | 0f19938312a79b229877e31dc728fba75c73a688 | |
| parent | 8c587f7709f7f6377842968562bcf51ee6f47f09 (diff) | |
Input: bu21013_ts - move GPIO init and exit functions into the driver
These GPIO init and exit functions have no place in platform data, they
should be part of the driver instead,
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
| -rw-r--r-- | arch/arm/mach-ux500/board-mop500-stuib.c | 71 | ||||
| -rw-r--r-- | drivers/input/touchscreen/bu21013_ts.c | 69 | ||||
| -rw-r--r-- | include/linux/input/bu21013.h | 10 |
3 files changed, 53 insertions, 97 deletions
diff --git a/arch/arm/mach-ux500/board-mop500-stuib.c b/arch/arm/mach-ux500/board-mop500-stuib.c index 564f57d5d8a7..7e1f294f0434 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[] = { | |||
| 77 | * BU21013 ROHM touchscreen interface on the STUIBs | 77 | * BU21013 ROHM touchscreen interface on the STUIBs |
| 78 | */ | 78 | */ |
| 79 | 79 | ||
| 80 | /* tracks number of bu21013 devices being enabled */ | ||
| 81 | static int bu21013_devices; | ||
| 82 | |||
| 83 | #define TOUCH_GPIO_PIN 84 | 80 | #define TOUCH_GPIO_PIN 84 |
| 84 | 81 | ||
| 85 | #define TOUCH_XMAX 384 | 82 | #define TOUCH_XMAX 384 |
| @@ -88,73 +85,8 @@ static int bu21013_devices; | |||
| 88 | #define PRCMU_CLOCK_OCR 0x1CC | 85 | #define PRCMU_CLOCK_OCR 0x1CC |
| 89 | #define TSC_EXT_CLOCK_9_6MHZ 0x840000 | 86 | #define TSC_EXT_CLOCK_9_6MHZ 0x840000 |
| 90 | 87 | ||
| 91 | /** | ||
| 92 | * bu21013_gpio_board_init : configures the touch panel. | ||
| 93 | * @reset_pin: reset pin number | ||
| 94 | * This function can be used to configures | ||
| 95 | * the voltage and reset the touch panel controller. | ||
| 96 | */ | ||
| 97 | static int bu21013_gpio_board_init(int reset_pin) | ||
| 98 | { | ||
| 99 | int retval = 0; | ||
| 100 | |||
| 101 | bu21013_devices++; | ||
| 102 | if (bu21013_devices == 1) { | ||
| 103 | retval = gpio_request(reset_pin, "touchp_reset"); | ||
| 104 | if (retval) { | ||
| 105 | printk(KERN_ERR "Unable to request gpio reset_pin"); | ||
| 106 | return retval; | ||
| 107 | } | ||
| 108 | retval = gpio_direction_output(reset_pin, 1); | ||
| 109 | if (retval < 0) { | ||
| 110 | printk(KERN_ERR "%s: gpio direction failed\n", | ||
| 111 | __func__); | ||
| 112 | return retval; | ||
| 113 | } | ||
| 114 | } | ||
| 115 | |||
| 116 | return retval; | ||
| 117 | } | ||
| 118 | |||
| 119 | /** | ||
| 120 | * bu21013_gpio_board_exit : deconfigures the touch panel controller | ||
| 121 | * @reset_pin: reset pin number | ||
| 122 | * This function can be used to deconfigures the chip selection | ||
| 123 | * for touch panel controller. | ||
| 124 | */ | ||
| 125 | static int bu21013_gpio_board_exit(int reset_pin) | ||
| 126 | { | ||
| 127 | int retval = 0; | ||
| 128 | |||
| 129 | if (bu21013_devices == 1) { | ||
| 130 | retval = gpio_direction_output(reset_pin, 0); | ||
| 131 | if (retval < 0) { | ||
| 132 | printk(KERN_ERR "%s: gpio direction failed\n", | ||
| 133 | __func__); | ||
| 134 | return retval; | ||
| 135 | } | ||
| 136 | gpio_set_value(reset_pin, 0); | ||
| 137 | } | ||
| 138 | bu21013_devices--; | ||
| 139 | |||
| 140 | return retval; | ||
| 141 | } | ||
| 142 | |||
| 143 | /** | ||
| 144 | * bu21013_read_pin_val : get the interrupt pin value | ||
| 145 | * This function can be used to get the interrupt pin value for touch panel | ||
| 146 | * controller. | ||
| 147 | */ | ||
| 148 | static int bu21013_read_pin_val(void) | ||
| 149 | { | ||
| 150 | return gpio_get_value(TOUCH_GPIO_PIN); | ||
| 151 | } | ||
| 152 | |||
| 153 | static struct bu21013_platform_device tsc_plat_device = { | 88 | static struct bu21013_platform_device tsc_plat_device = { |
| 154 | .cs_en = bu21013_gpio_board_init, | 89 | .touch_pin = TOUCH_GPIO_PIN, |
| 155 | .cs_dis = bu21013_gpio_board_exit, | ||
| 156 | .irq_read_val = bu21013_read_pin_val, | ||
| 157 | .irq = NOMADIK_GPIO_TO_IRQ(TOUCH_GPIO_PIN), | ||
| 158 | .touch_x_max = TOUCH_XMAX, | 90 | .touch_x_max = TOUCH_XMAX, |
| 159 | .touch_y_max = TOUCH_YMAX, | 91 | .touch_y_max = TOUCH_YMAX, |
| 160 | .ext_clk = false, | 92 | .ext_clk = false, |
| @@ -171,7 +103,6 @@ static struct i2c_board_info __initdata u8500_i2c3_devices_stuib[] = { | |||
| 171 | I2C_BOARD_INFO("bu21013_tp", 0x5D), | 103 | I2C_BOARD_INFO("bu21013_tp", 0x5D), |
| 172 | .platform_data = &tsc_plat_device, | 104 | .platform_data = &tsc_plat_device, |
| 173 | }, | 105 | }, |
| 174 | |||
| 175 | }; | 106 | }; |
| 176 | 107 | ||
| 177 | void __init mop500_stuib_init(void) | 108 | void __init mop500_stuib_init(void) |
diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c index 1e8cddd06c60..c6f6a04ec673 100644 --- a/drivers/input/touchscreen/bu21013_ts.c +++ b/drivers/input/touchscreen/bu21013_ts.c | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
| 15 | #include <linux/regulator/consumer.h> | 15 | #include <linux/regulator/consumer.h> |
| 16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
| 17 | #include <linux/gpio.h> | ||
| 17 | 18 | ||
| 18 | #define PEN_DOWN_INTR 0 | 19 | #define PEN_DOWN_INTR 0 |
| 19 | #define MAX_FINGERS 2 | 20 | #define MAX_FINGERS 2 |
| @@ -148,11 +149,12 @@ | |||
| 148 | struct bu21013_ts_data { | 149 | struct bu21013_ts_data { |
| 149 | struct i2c_client *client; | 150 | struct i2c_client *client; |
| 150 | wait_queue_head_t wait; | 151 | wait_queue_head_t wait; |
| 151 | bool touch_stopped; | ||
| 152 | const struct bu21013_platform_device *chip; | 152 | const struct bu21013_platform_device *chip; |
| 153 | struct input_dev *in_dev; | 153 | struct input_dev *in_dev; |
| 154 | unsigned int intr_pin; | ||
| 155 | struct regulator *regulator; | 154 | struct regulator *regulator; |
| 155 | unsigned int irq; | ||
| 156 | unsigned int intr_pin; | ||
| 157 | bool touch_stopped; | ||
| 156 | }; | 158 | }; |
| 157 | 159 | ||
| 158 | /** | 160 | /** |
| @@ -262,7 +264,7 @@ static irqreturn_t bu21013_gpio_irq(int irq, void *device_data) | |||
| 262 | return IRQ_NONE; | 264 | return IRQ_NONE; |
| 263 | } | 265 | } |
| 264 | 266 | ||
| 265 | data->intr_pin = data->chip->irq_read_val(); | 267 | data->intr_pin = gpio_get_value(data->chip->touch_pin); |
| 266 | if (data->intr_pin == PEN_DOWN_INTR) | 268 | if (data->intr_pin == PEN_DOWN_INTR) |
| 267 | wait_event_timeout(data->wait, data->touch_stopped, | 269 | wait_event_timeout(data->wait, data->touch_stopped, |
| 268 | msecs_to_jiffies(2)); | 270 | msecs_to_jiffies(2)); |
| @@ -418,10 +420,33 @@ static void bu21013_free_irq(struct bu21013_ts_data *bu21013_data) | |||
| 418 | { | 420 | { |
| 419 | bu21013_data->touch_stopped = true; | 421 | bu21013_data->touch_stopped = true; |
| 420 | wake_up(&bu21013_data->wait); | 422 | wake_up(&bu21013_data->wait); |
| 421 | free_irq(bu21013_data->chip->irq, bu21013_data); | 423 | free_irq(bu21013_data->irq, bu21013_data); |
| 422 | } | 424 | } |
| 423 | 425 | ||
| 424 | /** | 426 | /** |
| 427 | * bu21013_cs_disable() - deconfigures the touch panel controller | ||
| 428 | * @bu21013_data: device structure pointer | ||
| 429 | * | ||
| 430 | * This function is used to deconfigure the chip selection | ||
| 431 | * for touch panel controller. | ||
| 432 | */ | ||
| 433 | static void bu21013_cs_disable(struct bu21013_ts_data *bu21013_data) | ||
| 434 | { | ||
| 435 | int error; | ||
| 436 | |||
| 437 | error = gpio_direction_output(bu21013_data->chip->cs_pin, 0); | ||
| 438 | if (error < 0) | ||
| 439 | dev_warn(&bu21013_data->client->dev, | ||
| 440 | "%s: gpio direction failed, error: %d\n", | ||
| 441 | __func__, error); | ||
| 442 | else | ||
| 443 | gpio_set_value(bu21013_data->chip->cs_pin, 0); | ||
| 444 | |||
| 445 | gpio_free(bu21013_data->chip->cs_pin); | ||
| 446 | } | ||
| 447 | |||
| 448 | |||
| 449 | /** | ||
| 425 | * bu21013_probe() - initializes the i2c-client touchscreen driver | 450 | * bu21013_probe() - initializes the i2c-client touchscreen driver |
| 426 | * @client: i2c client structure pointer | 451 | * @client: i2c client structure pointer |
| 427 | * @id: i2c device id pointer | 452 | * @id: i2c device id pointer |
| @@ -430,7 +455,7 @@ static void bu21013_free_irq(struct bu21013_ts_data *bu21013_data) | |||
| 430 | * driver and returns integer. | 455 | * driver and returns integer. |
| 431 | */ | 456 | */ |
| 432 | static int bu21013_probe(struct i2c_client *client, | 457 | static int bu21013_probe(struct i2c_client *client, |
| 433 | const struct i2c_device_id *id) | 458 | const struct i2c_device_id *id) |
| 434 | { | 459 | { |
| 435 | struct bu21013_ts_data *bu21013_data; | 460 | struct bu21013_ts_data *bu21013_data; |
| 436 | struct input_dev *in_dev; | 461 | struct input_dev *in_dev; |
| @@ -449,6 +474,11 @@ static int bu21013_probe(struct i2c_client *client, | |||
| 449 | return -EINVAL; | 474 | return -EINVAL; |
| 450 | } | 475 | } |
| 451 | 476 | ||
| 477 | if (!gpio_is_valid(pdata->touch_pin)) { | ||
| 478 | dev_err(&client->dev, "invalid touch_pin supplied\n"); | ||
| 479 | return -EINVAL; | ||
| 480 | } | ||
| 481 | |||
| 452 | bu21013_data = kzalloc(sizeof(struct bu21013_ts_data), GFP_KERNEL); | 482 | bu21013_data = kzalloc(sizeof(struct bu21013_ts_data), GFP_KERNEL); |
| 453 | in_dev = input_allocate_device(); | 483 | in_dev = input_allocate_device(); |
| 454 | if (!bu21013_data || !in_dev) { | 484 | if (!bu21013_data || !in_dev) { |
| @@ -460,6 +490,7 @@ static int bu21013_probe(struct i2c_client *client, | |||
| 460 | bu21013_data->in_dev = in_dev; | 490 | bu21013_data->in_dev = in_dev; |
| 461 | bu21013_data->chip = pdata; | 491 | bu21013_data->chip = pdata; |
| 462 | bu21013_data->client = client; | 492 | bu21013_data->client = client; |
| 493 | bu21013_data->irq = gpio_to_irq(pdata->touch_pin); | ||
| 463 | 494 | ||
| 464 | bu21013_data->regulator = regulator_get(&client->dev, "avdd"); | 495 | bu21013_data->regulator = regulator_get(&client->dev, "avdd"); |
| 465 | if (IS_ERR(bu21013_data->regulator)) { | 496 | if (IS_ERR(bu21013_data->regulator)) { |
| @@ -478,12 +509,11 @@ static int bu21013_probe(struct i2c_client *client, | |||
| 478 | init_waitqueue_head(&bu21013_data->wait); | 509 | init_waitqueue_head(&bu21013_data->wait); |
| 479 | 510 | ||
| 480 | /* configure the gpio pins */ | 511 | /* configure the gpio pins */ |
| 481 | if (pdata->cs_en) { | 512 | error = gpio_request_one(pdata->cs_pin, GPIOF_OUT_INIT_HIGH, |
| 482 | error = pdata->cs_en(pdata->cs_pin); | 513 | "touchp_reset"); |
| 483 | if (error < 0) { | 514 | if (error < 0) { |
| 484 | dev_err(&client->dev, "chip init failed\n"); | 515 | dev_err(&client->dev, "Unable to request gpio reset_pin\n"); |
| 485 | goto err_disable_regulator; | 516 | goto err_disable_regulator; |
| 486 | } | ||
| 487 | } | 517 | } |
| 488 | 518 | ||
| 489 | /* configure the touch panel controller */ | 519 | /* configure the touch panel controller */ |
| @@ -508,12 +538,13 @@ static int bu21013_probe(struct i2c_client *client, | |||
| 508 | pdata->touch_y_max, 0, 0); | 538 | pdata->touch_y_max, 0, 0); |
| 509 | input_set_drvdata(in_dev, bu21013_data); | 539 | input_set_drvdata(in_dev, bu21013_data); |
| 510 | 540 | ||
| 511 | error = request_threaded_irq(pdata->irq, NULL, bu21013_gpio_irq, | 541 | error = request_threaded_irq(bu21013_data->irq, NULL, bu21013_gpio_irq, |
| 512 | IRQF_TRIGGER_FALLING | IRQF_SHARED | | 542 | IRQF_TRIGGER_FALLING | IRQF_SHARED | |
| 513 | IRQF_ONESHOT, | 543 | IRQF_ONESHOT, |
| 514 | DRIVER_TP, bu21013_data); | 544 | DRIVER_TP, bu21013_data); |
| 515 | if (error) { | 545 | if (error) { |
| 516 | dev_err(&client->dev, "request irq %d failed\n", pdata->irq); | 546 | dev_err(&client->dev, "request irq %d failed\n", |
| 547 | bu21013_data->irq); | ||
| 517 | goto err_cs_disable; | 548 | goto err_cs_disable; |
| 518 | } | 549 | } |
| 519 | 550 | ||
| @@ -531,7 +562,7 @@ static int bu21013_probe(struct i2c_client *client, | |||
| 531 | err_free_irq: | 562 | err_free_irq: |
| 532 | bu21013_free_irq(bu21013_data); | 563 | bu21013_free_irq(bu21013_data); |
| 533 | err_cs_disable: | 564 | err_cs_disable: |
| 534 | pdata->cs_dis(pdata->cs_pin); | 565 | bu21013_cs_disable(bu21013_data); |
| 535 | err_disable_regulator: | 566 | err_disable_regulator: |
| 536 | regulator_disable(bu21013_data->regulator); | 567 | regulator_disable(bu21013_data->regulator); |
| 537 | err_put_regulator: | 568 | err_put_regulator: |
| @@ -555,7 +586,7 @@ static int bu21013_remove(struct i2c_client *client) | |||
| 555 | 586 | ||
| 556 | bu21013_free_irq(bu21013_data); | 587 | bu21013_free_irq(bu21013_data); |
| 557 | 588 | ||
| 558 | bu21013_data->chip->cs_dis(bu21013_data->chip->cs_pin); | 589 | bu21013_cs_disable(bu21013_data); |
| 559 | 590 | ||
| 560 | input_unregister_device(bu21013_data->in_dev); | 591 | input_unregister_device(bu21013_data->in_dev); |
| 561 | 592 | ||
| @@ -584,9 +615,9 @@ static int bu21013_suspend(struct device *dev) | |||
| 584 | 615 | ||
| 585 | bu21013_data->touch_stopped = true; | 616 | bu21013_data->touch_stopped = true; |
| 586 | if (device_may_wakeup(&client->dev)) | 617 | if (device_may_wakeup(&client->dev)) |
| 587 | enable_irq_wake(bu21013_data->chip->irq); | 618 | enable_irq_wake(bu21013_data->irq); |
| 588 | else | 619 | else |
| 589 | disable_irq(bu21013_data->chip->irq); | 620 | disable_irq(bu21013_data->irq); |
| 590 | 621 | ||
| 591 | regulator_disable(bu21013_data->regulator); | 622 | regulator_disable(bu21013_data->regulator); |
| 592 | 623 | ||
| @@ -621,9 +652,9 @@ static int bu21013_resume(struct device *dev) | |||
| 621 | bu21013_data->touch_stopped = false; | 652 | bu21013_data->touch_stopped = false; |
| 622 | 653 | ||
| 623 | if (device_may_wakeup(&client->dev)) | 654 | if (device_may_wakeup(&client->dev)) |
| 624 | disable_irq_wake(bu21013_data->chip->irq); | 655 | disable_irq_wake(bu21013_data->irq); |
| 625 | else | 656 | else |
| 626 | enable_irq(bu21013_data->chip->irq); | 657 | enable_irq(bu21013_data->irq); |
| 627 | 658 | ||
| 628 | return 0; | 659 | return 0; |
| 629 | } | 660 | } |
diff --git a/include/linux/input/bu21013.h b/include/linux/input/bu21013.h index 05e03284b92a..6230d76bde5d 100644 --- a/include/linux/input/bu21013.h +++ b/include/linux/input/bu21013.h | |||
| @@ -9,13 +9,10 @@ | |||
| 9 | 9 | ||
| 10 | /** | 10 | /** |
| 11 | * struct bu21013_platform_device - Handle the platform data | 11 | * struct bu21013_platform_device - Handle the platform data |
| 12 | * @cs_en: pointer to the cs enable function | ||
| 13 | * @cs_dis: pointer to the cs disable function | ||
| 14 | * @irq_read_val: pointer to read the pen irq value function | ||
| 15 | * @touch_x_max: touch x max | 12 | * @touch_x_max: touch x max |
| 16 | * @touch_y_max: touch y max | 13 | * @touch_y_max: touch y max |
| 17 | * @cs_pin: chip select pin | 14 | * @cs_pin: chip select pin |
| 18 | * @irq: irq pin | 15 | * @touch_pin: touch gpio pin |
| 19 | * @ext_clk: external clock flag | 16 | * @ext_clk: external clock flag |
| 20 | * @x_flip: x flip flag | 17 | * @x_flip: x flip flag |
| 21 | * @y_flip: y flip flag | 18 | * @y_flip: y flip flag |
| @@ -24,13 +21,10 @@ | |||
| 24 | * This is used to handle the platform data | 21 | * This is used to handle the platform data |
| 25 | */ | 22 | */ |
| 26 | struct bu21013_platform_device { | 23 | struct bu21013_platform_device { |
| 27 | int (*cs_en)(int reset_pin); | ||
| 28 | int (*cs_dis)(int reset_pin); | ||
| 29 | int (*irq_read_val)(void); | ||
| 30 | int touch_x_max; | 24 | int touch_x_max; |
| 31 | int touch_y_max; | 25 | int touch_y_max; |
| 32 | unsigned int cs_pin; | 26 | unsigned int cs_pin; |
| 33 | unsigned int irq; | 27 | unsigned int touch_pin; |
| 34 | bool ext_clk; | 28 | bool ext_clk; |
| 35 | bool x_flip; | 29 | bool x_flip; |
| 36 | bool y_flip; | 30 | bool y_flip; |
