Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Driver for Motorola PCAP2 touchscreen as found in the EZX phone platform.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *  Copyright (C) 2006 Harald Welte <laforge@openezx.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *  Copyright (C) 2009 Daniel Ribeiro <drwyrm@gmail.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/pm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/timer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/mfd/ezx-pcap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) struct pcap_ts {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	struct pcap_chip *pcap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	struct input_dev *input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	struct delayed_work work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	u16 x, y;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	u16 pressure;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	u8 read_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #define SAMPLE_DELAY	20 /* msecs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #define X_AXIS_MIN	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #define X_AXIS_MAX	1023
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #define Y_AXIS_MAX	X_AXIS_MAX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #define Y_AXIS_MIN	X_AXIS_MIN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #define PRESSURE_MAX	X_AXIS_MAX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #define PRESSURE_MIN	X_AXIS_MIN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) static void pcap_ts_read_xy(void *data, u16 res[2])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	struct pcap_ts *pcap_ts = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	switch (pcap_ts->read_state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	case PCAP_ADC_TS_M_PRESSURE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 		/* pressure reading is unreliable */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 		if (res[0] > PRESSURE_MIN && res[0] < PRESSURE_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 			pcap_ts->pressure = res[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 		pcap_ts->read_state = PCAP_ADC_TS_M_XY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 		schedule_delayed_work(&pcap_ts->work, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	case PCAP_ADC_TS_M_XY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 		pcap_ts->y = res[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 		pcap_ts->x = res[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 		if (pcap_ts->x <= X_AXIS_MIN || pcap_ts->x >= X_AXIS_MAX ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		    pcap_ts->y <= Y_AXIS_MIN || pcap_ts->y >= Y_AXIS_MAX) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 			/* pen has been released */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 			input_report_abs(pcap_ts->input, ABS_PRESSURE, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 			input_report_key(pcap_ts->input, BTN_TOUCH, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 			pcap_ts->read_state = PCAP_ADC_TS_M_STANDBY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 			schedule_delayed_work(&pcap_ts->work, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 			/* pen is touching the screen */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 			input_report_abs(pcap_ts->input, ABS_X, pcap_ts->x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 			input_report_abs(pcap_ts->input, ABS_Y, pcap_ts->y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 			input_report_key(pcap_ts->input, BTN_TOUCH, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 			input_report_abs(pcap_ts->input, ABS_PRESSURE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 						pcap_ts->pressure);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 			/* switch back to pressure read mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 			pcap_ts->read_state = PCAP_ADC_TS_M_PRESSURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 			schedule_delayed_work(&pcap_ts->work,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 					msecs_to_jiffies(SAMPLE_DELAY));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		input_sync(pcap_ts->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		dev_warn(&pcap_ts->input->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 				"pcap_ts: Warning, unhandled read_state %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 				pcap_ts->read_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) static void pcap_ts_work(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	struct delayed_work *dw = to_delayed_work(work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	struct pcap_ts *pcap_ts = container_of(dw, struct pcap_ts, work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	u8 ch[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	pcap_set_ts_bits(pcap_ts->pcap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 			pcap_ts->read_state << PCAP_ADC_TS_M_SHIFT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	if (pcap_ts->read_state == PCAP_ADC_TS_M_STANDBY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	/* start adc conversion */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	ch[0] = PCAP_ADC_CH_TS_X1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	ch[1] = PCAP_ADC_CH_TS_Y1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	pcap_adc_async(pcap_ts->pcap, PCAP_ADC_BANK_1, 0, ch,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 						pcap_ts_read_xy, pcap_ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) static irqreturn_t pcap_ts_event_touch(int pirq, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	struct pcap_ts *pcap_ts = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	if (pcap_ts->read_state == PCAP_ADC_TS_M_STANDBY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		pcap_ts->read_state = PCAP_ADC_TS_M_PRESSURE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		schedule_delayed_work(&pcap_ts->work, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) static int pcap_ts_open(struct input_dev *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	struct pcap_ts *pcap_ts = input_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	pcap_ts->read_state = PCAP_ADC_TS_M_STANDBY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	schedule_delayed_work(&pcap_ts->work, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) static void pcap_ts_close(struct input_dev *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	struct pcap_ts *pcap_ts = input_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	cancel_delayed_work_sync(&pcap_ts->work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	pcap_ts->read_state = PCAP_ADC_TS_M_NONTS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	pcap_set_ts_bits(pcap_ts->pcap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 				pcap_ts->read_state << PCAP_ADC_TS_M_SHIFT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) static int pcap_ts_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	struct input_dev *input_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	struct pcap_ts *pcap_ts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	int err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	pcap_ts = kzalloc(sizeof(*pcap_ts), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	if (!pcap_ts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	pcap_ts->pcap = dev_get_drvdata(pdev->dev.parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	platform_set_drvdata(pdev, pcap_ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	input_dev = input_allocate_device();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	if (!input_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	INIT_DELAYED_WORK(&pcap_ts->work, pcap_ts_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	pcap_ts->read_state = PCAP_ADC_TS_M_NONTS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	pcap_set_ts_bits(pcap_ts->pcap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 				pcap_ts->read_state << PCAP_ADC_TS_M_SHIFT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	pcap_ts->input = input_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	input_set_drvdata(input_dev, pcap_ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	input_dev->name = "pcap-touchscreen";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	input_dev->phys = "pcap_ts/input0";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	input_dev->id.bustype = BUS_HOST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	input_dev->id.vendor = 0x0001;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	input_dev->id.product = 0x0002;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	input_dev->id.version = 0x0100;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	input_dev->dev.parent = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	input_dev->open = pcap_ts_open;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	input_dev->close = pcap_ts_close;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	input_set_abs_params(input_dev, ABS_X, X_AXIS_MIN, X_AXIS_MAX, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	input_set_abs_params(input_dev, ABS_Y, Y_AXIS_MIN, Y_AXIS_MAX, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	input_set_abs_params(input_dev, ABS_PRESSURE, PRESSURE_MIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 			     PRESSURE_MAX, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	err = input_register_device(pcap_ts->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		goto fail_allocate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	err = request_irq(pcap_to_irq(pcap_ts->pcap, PCAP_IRQ_TS),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 			pcap_ts_event_touch, 0, "Touch Screen", pcap_ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		goto fail_register;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) fail_register:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	input_unregister_device(input_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) fail_allocate:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	input_free_device(input_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) fail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	kfree(pcap_ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) static int pcap_ts_remove(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	struct pcap_ts *pcap_ts = platform_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	free_irq(pcap_to_irq(pcap_ts->pcap, PCAP_IRQ_TS), pcap_ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	cancel_delayed_work_sync(&pcap_ts->work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	input_unregister_device(pcap_ts->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	kfree(pcap_ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) #ifdef CONFIG_PM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) static int pcap_ts_suspend(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	struct pcap_ts *pcap_ts = dev_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	pcap_set_ts_bits(pcap_ts->pcap, PCAP_ADC_TS_REF_LOWPWR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) static int pcap_ts_resume(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	struct pcap_ts *pcap_ts = dev_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	pcap_set_ts_bits(pcap_ts->pcap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 				pcap_ts->read_state << PCAP_ADC_TS_M_SHIFT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) static const struct dev_pm_ops pcap_ts_pm_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	.suspend	= pcap_ts_suspend,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	.resume		= pcap_ts_resume,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) #define PCAP_TS_PM_OPS (&pcap_ts_pm_ops)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) #define PCAP_TS_PM_OPS NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) static struct platform_driver pcap_ts_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	.probe		= pcap_ts_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	.remove		= pcap_ts_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	.driver		= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		.name	= "pcap-ts",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		.pm	= PCAP_TS_PM_OPS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) module_platform_driver(pcap_ts_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) MODULE_DESCRIPTION("Motorola PCAP2 touchscreen driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) MODULE_AUTHOR("Daniel Ribeiro / Harald Welte");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) MODULE_ALIAS("platform:pcap_ts");