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.

iio: adc: exynos_adc: Drop touchscreen support

With last user of touchscreen via ADC (S3C24xx SoC) gone, drop the
remaining code from Samsung SoC ADC driver.

Reviewed-by: Andy Shevchenko <andy@kernel.org>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20250830-s3c-cleanup-adc-v2-2-4f8299343d32@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Krzysztof Kozlowski and committed by
Jonathan Cameron
1ef28bcc 117b6c08

+1 -195
+1 -195
drivers/iio/adc/exynos_adc.c
··· 19 19 #include <linux/clk.h> 20 20 #include <linux/completion.h> 21 21 #include <linux/of.h> 22 - #include <linux/of_irq.h> 23 22 #include <linux/regulator/consumer.h> 24 23 #include <linux/of_platform.h> 25 24 #include <linux/err.h> 26 - #include <linux/input.h> 27 25 28 26 #include <linux/iio/iio.h> 29 27 #include <linux/iio/machine.h> ··· 33 35 34 36 /* S3C/EXYNOS4412/5250 ADC_V1 registers definitions */ 35 37 #define ADC_V1_CON(x) ((x) + 0x00) 36 - #define ADC_V1_TSC(x) ((x) + 0x04) 37 38 #define ADC_V1_DLY(x) ((x) + 0x08) 38 39 #define ADC_V1_DATX(x) ((x) + 0x0C) 39 40 #define ADC_V1_DATY(x) ((x) + 0x10) 40 41 #define ADC_V1_UPDN(x) ((x) + 0x14) 41 42 #define ADC_V1_INTCLR(x) ((x) + 0x18) 42 43 #define ADC_V1_MUX(x) ((x) + 0x1c) 43 - #define ADC_V1_CLRINTPNDNUP(x) ((x) + 0x20) 44 44 45 45 /* Future ADC_V2 registers definitions */ 46 46 #define ADC_V2_CON1(x) ((x) + 0x00) ··· 57 61 /* Bit definitions for S3C2410 / S3C6410 ADC */ 58 62 #define ADC_S3C2410_CON_SELMUX(x) (((x) & 7) << 3) 59 63 60 - /* touch screen always uses channel 0 */ 61 - #define ADC_S3C2410_MUX_TS 0 62 - 63 64 /* ADCTSC Register Bits */ 64 65 #define ADC_S3C2443_TSC_UD_SEN (1u << 8) 65 66 #define ADC_S3C2410_TSC_YM_SEN (1u << 7) 66 67 #define ADC_S3C2410_TSC_YP_SEN (1u << 6) 67 68 #define ADC_S3C2410_TSC_XM_SEN (1u << 5) 68 69 #define ADC_S3C2410_TSC_XP_SEN (1u << 4) 69 - #define ADC_S3C2410_TSC_PULL_UP_DISABLE (1u << 3) 70 - #define ADC_S3C2410_TSC_AUTO_PST (1u << 2) 71 70 #define ADC_S3C2410_TSC_XY_PST(x) (((x) & 0x3) << 0) 72 71 73 72 #define ADC_TSC_WAIT4INT (ADC_S3C2410_TSC_YM_SEN | \ 74 73 ADC_S3C2410_TSC_YP_SEN | \ 75 74 ADC_S3C2410_TSC_XP_SEN | \ 76 75 ADC_S3C2410_TSC_XY_PST(3)) 77 - 78 - #define ADC_TSC_AUTOPST (ADC_S3C2410_TSC_YM_SEN | \ 79 - ADC_S3C2410_TSC_YP_SEN | \ 80 - ADC_S3C2410_TSC_XP_SEN | \ 81 - ADC_S3C2410_TSC_AUTO_PST | \ 82 - ADC_S3C2410_TSC_XY_PST(0)) 83 76 84 77 /* Bit definitions for ADC_V2 */ 85 78 #define ADC_V2_CON1_SOFT_RESET (1u << 2) ··· 101 116 struct exynos_adc { 102 117 struct exynos_adc_data *data; 103 118 struct device *dev; 104 - struct input_dev *input; 105 119 void __iomem *regs; 106 120 struct regmap *pmu_map; 107 121 struct clk *clk; 108 122 struct clk *sclk; 109 123 unsigned int irq; 110 - unsigned int tsirq; 111 124 unsigned int delay; 112 125 struct regulator *vdd; 113 126 ··· 113 130 114 131 u32 value; 115 132 unsigned int version; 116 - 117 - bool ts_enabled; 118 - 119 - bool read_ts; 120 - u32 ts_x; 121 - u32 ts_y; 122 133 123 134 /* 124 135 * Lock to protect from potential concurrent access to the ··· 484 507 return ret; 485 508 } 486 509 487 - static int exynos_read_s3c64xx_ts(struct iio_dev *indio_dev, int *x, int *y) 488 - { 489 - struct exynos_adc *info = iio_priv(indio_dev); 490 - unsigned long time_left; 491 - int ret; 492 - 493 - mutex_lock(&info->lock); 494 - info->read_ts = true; 495 - 496 - reinit_completion(&info->completion); 497 - 498 - writel(ADC_S3C2410_TSC_PULL_UP_DISABLE | ADC_TSC_AUTOPST, 499 - ADC_V1_TSC(info->regs)); 500 - 501 - /* Select the ts channel to be used and Trigger conversion */ 502 - info->data->start_conv(info, ADC_S3C2410_MUX_TS); 503 - 504 - time_left = wait_for_completion_timeout(&info->completion, 505 - EXYNOS_ADC_TIMEOUT); 506 - if (time_left == 0) { 507 - dev_warn(&indio_dev->dev, "Conversion timed out! Resetting\n"); 508 - if (info->data->init_hw) 509 - info->data->init_hw(info); 510 - ret = -ETIMEDOUT; 511 - } else { 512 - *x = info->ts_x; 513 - *y = info->ts_y; 514 - ret = 0; 515 - } 516 - 517 - info->read_ts = false; 518 - mutex_unlock(&info->lock); 519 - 520 - return ret; 521 - } 522 - 523 510 static irqreturn_t exynos_adc_isr(int irq, void *dev_id) 524 511 { 525 512 struct exynos_adc *info = dev_id; 526 513 u32 mask = info->data->mask; 527 514 528 515 /* Read value */ 529 - if (info->read_ts) { 530 - info->ts_x = readl(ADC_V1_DATX(info->regs)); 531 - info->ts_y = readl(ADC_V1_DATY(info->regs)); 532 - writel(ADC_TSC_WAIT4INT | ADC_S3C2443_TSC_UD_SEN, ADC_V1_TSC(info->regs)); 533 - } else { 534 - info->value = readl(ADC_V1_DATX(info->regs)) & mask; 535 - } 516 + info->value = readl(ADC_V1_DATX(info->regs)) & mask; 536 517 537 518 /* clear irq */ 538 519 if (info->data->clear_irq) 539 520 info->data->clear_irq(info); 540 521 541 522 complete(&info->completion); 542 - 543 - return IRQ_HANDLED; 544 - } 545 - 546 - /* 547 - * Here we (ab)use a threaded interrupt handler to stay running 548 - * for as long as the touchscreen remains pressed, we report 549 - * a new event with the latest data and then sleep until the 550 - * next timer tick. This mirrors the behavior of the old 551 - * driver, with much less code. 552 - */ 553 - static irqreturn_t exynos_ts_isr(int irq, void *dev_id) 554 - { 555 - struct exynos_adc *info = dev_id; 556 - struct iio_dev *dev = dev_get_drvdata(info->dev); 557 - u32 x, y; 558 - bool pressed; 559 - int ret; 560 - 561 - while (READ_ONCE(info->ts_enabled)) { 562 - ret = exynos_read_s3c64xx_ts(dev, &x, &y); 563 - if (ret == -ETIMEDOUT) 564 - break; 565 - 566 - pressed = x & y & ADC_DATX_PRESSED; 567 - if (!pressed) { 568 - input_report_key(info->input, BTN_TOUCH, 0); 569 - input_sync(info->input); 570 - break; 571 - } 572 - 573 - input_report_abs(info->input, ABS_X, x & ADC_DATX_MASK); 574 - input_report_abs(info->input, ABS_Y, y & ADC_DATY_MASK); 575 - input_report_key(info->input, BTN_TOUCH, 1); 576 - input_sync(info->input); 577 - 578 - usleep_range(1000, 1100); 579 - } 580 - 581 - writel(0, ADC_V1_CLRINTPNDNUP(info->regs)); 582 523 583 524 return IRQ_HANDLED; 584 525 } ··· 552 657 return 0; 553 658 } 554 659 555 - static int exynos_adc_ts_open(struct input_dev *dev) 556 - { 557 - struct exynos_adc *info = input_get_drvdata(dev); 558 - 559 - WRITE_ONCE(info->ts_enabled, true); 560 - enable_irq(info->tsirq); 561 - 562 - return 0; 563 - } 564 - 565 - static void exynos_adc_ts_close(struct input_dev *dev) 566 - { 567 - struct exynos_adc *info = input_get_drvdata(dev); 568 - 569 - WRITE_ONCE(info->ts_enabled, false); 570 - disable_irq(info->tsirq); 571 - } 572 - 573 - static int exynos_adc_ts_init(struct exynos_adc *info) 574 - { 575 - int ret; 576 - 577 - if (info->tsirq <= 0) 578 - return -ENODEV; 579 - 580 - info->input = input_allocate_device(); 581 - if (!info->input) 582 - return -ENOMEM; 583 - 584 - info->input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 585 - info->input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); 586 - 587 - input_set_abs_params(info->input, ABS_X, 0, 0x3FF, 0, 0); 588 - input_set_abs_params(info->input, ABS_Y, 0, 0x3FF, 0, 0); 589 - 590 - info->input->name = "S3C24xx TouchScreen"; 591 - info->input->id.bustype = BUS_HOST; 592 - info->input->open = exynos_adc_ts_open; 593 - info->input->close = exynos_adc_ts_close; 594 - 595 - input_set_drvdata(info->input, info); 596 - 597 - ret = input_register_device(info->input); 598 - if (ret) { 599 - input_free_device(info->input); 600 - return ret; 601 - } 602 - 603 - ret = request_threaded_irq(info->tsirq, NULL, exynos_ts_isr, 604 - IRQF_ONESHOT | IRQF_NO_AUTOEN, 605 - "touchscreen", info); 606 - if (ret) 607 - input_unregister_device(info->input); 608 - 609 - return ret; 610 - } 611 - 612 660 static int exynos_adc_probe(struct platform_device *pdev) 613 661 { 614 662 struct exynos_adc *info = NULL; 615 663 struct device_node *np = pdev->dev.of_node; 616 664 struct s3c2410_ts_mach_info *pdata = dev_get_platdata(&pdev->dev); 617 665 struct iio_dev *indio_dev = NULL; 618 - bool has_ts = false; 619 666 int ret; 620 667 int irq; 621 668 ··· 588 751 } 589 752 } 590 753 591 - /* leave out any TS related code if unreachable */ 592 - if (IS_REACHABLE(CONFIG_INPUT)) { 593 - has_ts = of_property_read_bool(pdev->dev.of_node, 594 - "has-touchscreen") || pdata; 595 - } 596 - 597 754 irq = platform_get_irq(pdev, 0); 598 755 if (irq < 0) 599 756 return irq; 600 757 info->irq = irq; 601 - 602 - if (has_ts) { 603 - irq = platform_get_irq(pdev, 1); 604 - if (irq == -EPROBE_DEFER) 605 - return irq; 606 - 607 - info->tsirq = irq; 608 - } else { 609 - info->tsirq = -1; 610 - } 611 - 612 758 info->dev = &pdev->dev; 613 759 614 760 init_completion(&info->completion); ··· 660 840 else 661 841 info->delay = 10000; 662 842 663 - if (has_ts) 664 - ret = exynos_adc_ts_init(info); 665 - if (ret) 666 - goto err_iio; 667 - 668 843 ret = of_platform_populate(np, exynos_adc_match, NULL, &indio_dev->dev); 669 844 if (ret < 0) { 670 845 dev_err(&pdev->dev, "failed adding child nodes\n"); ··· 671 856 err_of_populate: 672 857 device_for_each_child(&indio_dev->dev, NULL, 673 858 exynos_adc_remove_devices); 674 - if (has_ts) { 675 - input_unregister_device(info->input); 676 - free_irq(info->tsirq, info); 677 - } 678 - err_iio: 679 859 iio_device_unregister(indio_dev); 680 860 err_irq: 681 861 free_irq(info->irq, info); ··· 690 880 struct iio_dev *indio_dev = platform_get_drvdata(pdev); 691 881 struct exynos_adc *info = iio_priv(indio_dev); 692 882 693 - if (IS_REACHABLE(CONFIG_INPUT) && info->input) { 694 - free_irq(info->tsirq, info); 695 - input_unregister_device(info->input); 696 - } 697 883 device_for_each_child(&indio_dev->dev, NULL, 698 884 exynos_adc_remove_devices); 699 885 iio_device_unregister(indio_dev);