Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Input: auo-pixcir-ts - drop support for platform data

Currently there are no users of auo_pixcir_ts_platdata in the mainline, and
having it (with legacy gpio numbers) prevents us from converting the driver
to gpiod API, so let's drop it.

If, in the future, someone wants to use this driver on non-device tree,
non-ACPI system, they should use static device properties instead of
platform data.

Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Link: https://lore.kernel.org/r/20220914141428.2201784-1-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+56 -106
+56 -62
drivers/input/touchscreen/auo-pixcir-ts.c
··· 20 20 #include <linux/mutex.h> 21 21 #include <linux/delay.h> 22 22 #include <linux/gpio.h> 23 - #include <linux/input/auo-pixcir-ts.h> 24 23 #include <linux/of.h> 25 24 #include <linux/of_gpio.h> 26 25 ··· 68 69 #define AUO_PIXCIR_INT_RELEASE (1 << 4) 69 70 #define AUO_PIXCIR_INT_ENABLE (1 << 3) 70 71 #define AUO_PIXCIR_INT_POL_HIGH (1 << 2) 72 + 73 + /* 74 + * Interrupt modes: 75 + * periodical: interrupt is asserted periodicaly 76 + * compare coordinates: interrupt is asserted when coordinates change 77 + * indicate touch: interrupt is asserted during touch 78 + */ 79 + #define AUO_PIXCIR_INT_PERIODICAL 0x00 80 + #define AUO_PIXCIR_INT_COMP_COORD 0x01 81 + #define AUO_PIXCIR_INT_TOUCH_IND 0x02 71 82 #define AUO_PIXCIR_INT_MODE_MASK 0x03 72 83 73 84 /* ··· 112 103 struct auo_pixcir_ts { 113 104 struct i2c_client *client; 114 105 struct input_dev *input; 115 - const struct auo_pixcir_ts_platdata *pdata; 106 + int gpio_int; 107 + int gpio_rst; 116 108 char phys[32]; 117 109 118 - /* special handling for touch_indicate interupt mode */ 110 + unsigned int x_max; 111 + unsigned int y_max; 112 + 113 + /* special handling for touch_indicate interrupt mode */ 119 114 bool touch_ind_mode; 120 115 121 116 wait_queue_head_t wait; ··· 138 125 struct auo_point_t *point) 139 126 { 140 127 struct i2c_client *client = ts->client; 141 - const struct auo_pixcir_ts_platdata *pdata = ts->pdata; 142 128 uint8_t raw_coord[8]; 143 129 uint8_t raw_area[4]; 144 130 int i, ret; ··· 164 152 point[i].coord_y = 165 153 raw_coord[4 * i + 3] << 8 | raw_coord[4 * i + 2]; 166 154 167 - if (point[i].coord_x > pdata->x_max || 168 - point[i].coord_y > pdata->y_max) { 155 + if (point[i].coord_x > ts->x_max || 156 + point[i].coord_y > ts->y_max) { 169 157 dev_warn(&client->dev, "coordinates (%d,%d) invalid\n", 170 158 point[i].coord_x, point[i].coord_y); 171 159 point[i].coord_x = point[i].coord_y = 0; ··· 183 171 static irqreturn_t auo_pixcir_interrupt(int irq, void *dev_id) 184 172 { 185 173 struct auo_pixcir_ts *ts = dev_id; 186 - const struct auo_pixcir_ts_platdata *pdata = ts->pdata; 187 174 struct auo_point_t point[AUO_PIXCIR_REPORT_POINTS]; 188 175 int i; 189 176 int ret; ··· 193 182 194 183 /* check for up event in touch touch_ind_mode */ 195 184 if (ts->touch_ind_mode) { 196 - if (gpio_get_value(pdata->gpio_int) == 0) { 185 + if (gpio_get_value(ts->gpio_int) == 0) { 197 186 input_mt_sync(ts->input); 198 187 input_report_key(ts->input, BTN_TOUCH, 0); 199 188 input_sync(ts->input); ··· 289 278 return 0; 290 279 } 291 280 292 - static int auo_pixcir_int_config(struct auo_pixcir_ts *ts, 293 - int int_setting) 281 + static int auo_pixcir_int_config(struct auo_pixcir_ts *ts, int int_setting) 294 282 { 295 283 struct i2c_client *client = ts->client; 296 - const struct auo_pixcir_ts_platdata *pdata = ts->pdata; 297 284 int ret; 298 285 299 286 ret = i2c_smbus_read_byte_data(client, AUO_PIXCIR_REG_INT_SETTING); ··· 313 304 return ret; 314 305 } 315 306 316 - ts->touch_ind_mode = pdata->int_setting == AUO_PIXCIR_INT_TOUCH_IND; 307 + ts->touch_ind_mode = int_setting == AUO_PIXCIR_INT_TOUCH_IND; 317 308 318 309 return 0; 319 310 } ··· 475 466 auo_pixcir_suspend, auo_pixcir_resume); 476 467 477 468 #ifdef CONFIG_OF 478 - static struct auo_pixcir_ts_platdata *auo_pixcir_parse_dt(struct device *dev) 469 + static int auo_pixcir_parse_dt(struct device *dev, struct auo_pixcir_ts *ts) 479 470 { 480 - struct auo_pixcir_ts_platdata *pdata; 481 471 struct device_node *np = dev->of_node; 482 472 483 473 if (!np) 484 - return ERR_PTR(-ENOENT); 474 + return -ENOENT; 485 475 486 - pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); 487 - if (!pdata) 488 - return ERR_PTR(-ENOMEM); 489 - 490 - pdata->gpio_int = of_get_gpio(np, 0); 491 - if (!gpio_is_valid(pdata->gpio_int)) { 476 + ts->gpio_int = of_get_gpio(np, 0); 477 + if (!gpio_is_valid(ts->gpio_int)) { 492 478 dev_err(dev, "failed to get interrupt gpio\n"); 493 - return ERR_PTR(-EINVAL); 479 + return -EINVAL; 494 480 } 495 481 496 - pdata->gpio_rst = of_get_gpio(np, 1); 497 - if (!gpio_is_valid(pdata->gpio_rst)) { 482 + ts->gpio_rst = of_get_gpio(np, 1); 483 + if (!gpio_is_valid(ts->gpio_rst)) { 498 484 dev_err(dev, "failed to get reset gpio\n"); 499 - return ERR_PTR(-EINVAL); 485 + return -EINVAL; 500 486 } 501 487 502 - if (of_property_read_u32(np, "x-size", &pdata->x_max)) { 488 + if (of_property_read_u32(np, "x-size", &ts->x_max)) { 503 489 dev_err(dev, "failed to get x-size property\n"); 504 - return ERR_PTR(-EINVAL); 490 + return -EINVAL; 505 491 } 506 492 507 - if (of_property_read_u32(np, "y-size", &pdata->y_max)) { 493 + if (of_property_read_u32(np, "y-size", &ts->y_max)) { 508 494 dev_err(dev, "failed to get y-size property\n"); 509 - return ERR_PTR(-EINVAL); 495 + return -EINVAL; 510 496 } 511 497 512 - /* default to asserting the interrupt when the screen is touched */ 513 - pdata->int_setting = AUO_PIXCIR_INT_TOUCH_IND; 514 - 515 - return pdata; 498 + return 0; 516 499 } 517 500 #else 518 - static struct auo_pixcir_ts_platdata *auo_pixcir_parse_dt(struct device *dev) 501 + static int auo_pixcir_parse_dt(struct device *dev, struct auo_pixcir_ts *ts) 519 502 { 520 - return ERR_PTR(-EINVAL); 503 + return -EINVAL; 521 504 } 522 505 #endif 523 506 ··· 517 516 { 518 517 struct auo_pixcir_ts *ts = data; 519 518 520 - gpio_set_value(ts->pdata->gpio_rst, 0); 519 + gpio_set_value(ts->gpio_rst, 0); 521 520 } 522 521 523 522 static int auo_pixcir_probe(struct i2c_client *client, 524 523 const struct i2c_device_id *id) 525 524 { 526 - const struct auo_pixcir_ts_platdata *pdata; 527 525 struct auo_pixcir_ts *ts; 528 526 struct input_dev *input_dev; 529 527 int version; 530 528 int error; 531 529 532 - pdata = dev_get_platdata(&client->dev); 533 - if (!pdata) { 534 - pdata = auo_pixcir_parse_dt(&client->dev); 535 - if (IS_ERR(pdata)) 536 - return PTR_ERR(pdata); 537 - } 538 - 539 - ts = devm_kzalloc(&client->dev, 540 - sizeof(struct auo_pixcir_ts), GFP_KERNEL); 530 + ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL); 541 531 if (!ts) 542 532 return -ENOMEM; 543 533 ··· 538 546 return -ENOMEM; 539 547 } 540 548 541 - ts->pdata = pdata; 542 549 ts->client = client; 543 550 ts->input = input_dev; 544 551 ts->touch_ind_mode = 0; ··· 546 555 547 556 snprintf(ts->phys, sizeof(ts->phys), 548 557 "%s/input0", dev_name(&client->dev)); 558 + 559 + error = auo_pixcir_parse_dt(&client->dev, ts); 560 + if (error) 561 + return error; 549 562 550 563 input_dev->name = "AUO-Pixcir touchscreen"; 551 564 input_dev->phys = ts->phys; ··· 564 569 __set_bit(BTN_TOUCH, input_dev->keybit); 565 570 566 571 /* For single touch */ 567 - input_set_abs_params(input_dev, ABS_X, 0, pdata->x_max, 0, 0); 568 - input_set_abs_params(input_dev, ABS_Y, 0, pdata->y_max, 0, 0); 572 + input_set_abs_params(input_dev, ABS_X, 0, ts->x_max, 0, 0); 573 + input_set_abs_params(input_dev, ABS_Y, 0, ts->y_max, 0, 0); 569 574 570 575 /* For multi touch */ 571 - input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, 572 - pdata->x_max, 0, 0); 573 - input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, 574 - pdata->y_max, 0, 0); 575 - input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, 576 - AUO_PIXCIR_MAX_AREA, 0, 0); 577 - input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0, 578 - AUO_PIXCIR_MAX_AREA, 0, 0); 576 + input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, ts->x_max, 0, 0); 577 + input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, ts->y_max, 0, 0); 578 + input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 579 + 0, AUO_PIXCIR_MAX_AREA, 0, 0); 580 + input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 581 + 0, AUO_PIXCIR_MAX_AREA, 0, 0); 579 582 input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0); 580 583 581 584 input_set_drvdata(ts->input, ts); 582 585 583 - error = devm_gpio_request_one(&client->dev, pdata->gpio_int, 586 + error = devm_gpio_request_one(&client->dev, ts->gpio_int, 584 587 GPIOF_DIR_IN, "auo_pixcir_ts_int"); 585 588 if (error) { 586 589 dev_err(&client->dev, "request of gpio %d failed, %d\n", 587 - pdata->gpio_int, error); 590 + ts->gpio_int, error); 588 591 return error; 589 592 } 590 593 591 - error = devm_gpio_request_one(&client->dev, pdata->gpio_rst, 594 + error = devm_gpio_request_one(&client->dev, ts->gpio_rst, 592 595 GPIOF_DIR_OUT | GPIOF_INIT_HIGH, 593 596 "auo_pixcir_ts_rst"); 594 597 if (error) { 595 598 dev_err(&client->dev, "request of gpio %d failed, %d\n", 596 - pdata->gpio_rst, error); 599 + ts->gpio_rst, error); 597 600 return error; 598 601 } 599 602 ··· 612 619 613 620 dev_info(&client->dev, "firmware version 0x%X\n", version); 614 621 615 - error = auo_pixcir_int_config(ts, pdata->int_setting); 622 + /* default to asserting the interrupt when the screen is touched */ 623 + error = auo_pixcir_int_config(ts, AUO_PIXCIR_INT_TOUCH_IND); 616 624 if (error) 617 625 return error; 618 626
-44
include/linux/input/auo-pixcir-ts.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-only */ 2 - /* 3 - * Driver for AUO in-cell touchscreens 4 - * 5 - * Copyright (c) 2011 Heiko Stuebner <heiko@sntech.de> 6 - * 7 - * based on auo_touch.h from Dell Streak kernel 8 - * 9 - * Copyright (c) 2008 QUALCOMM Incorporated. 10 - * Copyright (c) 2008 QUALCOMM USA, INC. 11 - */ 12 - 13 - #ifndef __AUO_PIXCIR_TS_H__ 14 - #define __AUO_PIXCIR_TS_H__ 15 - 16 - /* 17 - * Interrupt modes: 18 - * periodical: interrupt is asserted periodicaly 19 - * compare coordinates: interrupt is asserted when coordinates change 20 - * indicate touch: interrupt is asserted during touch 21 - */ 22 - #define AUO_PIXCIR_INT_PERIODICAL 0x00 23 - #define AUO_PIXCIR_INT_COMP_COORD 0x01 24 - #define AUO_PIXCIR_INT_TOUCH_IND 0x02 25 - 26 - /* 27 - * @gpio_int interrupt gpio 28 - * @int_setting one of AUO_PIXCIR_INT_* 29 - * @init_hw hardwarespecific init 30 - * @exit_hw hardwarespecific shutdown 31 - * @x_max x-resolution 32 - * @y_max y-resolution 33 - */ 34 - struct auo_pixcir_ts_platdata { 35 - int gpio_int; 36 - int gpio_rst; 37 - 38 - int int_setting; 39 - 40 - unsigned int x_max; 41 - unsigned int y_max; 42 - }; 43 - 44 - #endif