Lines Matching +full:3 +full:base +full:- +full:x

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (C) 2013 - 2014 Hans de Goede <hdegoede@redhat.com>
12 * The sun4i-ts controller is capable of detecting a second touch, but when a
18 * open / close movement, and then reports emulated multi-touch events around
19 * the last touch coordinate (as the dual-touch coordinates are worthless).
26 * (looks like the description in the A20 User Manual v1.3 is better
54 #define ADC_FIRST_DLY(x) ((x) << 24) /* 8 bits */ argument
55 #define ADC_FIRST_DLY_MODE(x) ((x) << 23) argument
56 #define ADC_CLK_SEL(x) ((x) << 22) argument
57 #define ADC_CLK_DIV(x) ((x) << 20) /* 3 bits */ argument
58 #define FS_DIV(x) ((x) << 16) /* 4 bits */ argument
59 #define T_ACQ(x) ((x) << 0) /* 16 bits */ argument
62 #define STYLUS_UP_DEBOUN(x) ((x) << 12) /* 8 bits */ argument
63 #define STYLUS_UP_DEBOUN_EN(x) ((x) << 9) argument
64 #define TOUCH_PAN_CALI_EN(x) ((x) << 6) argument
65 #define TP_DUAL_EN(x) ((x) << 5) argument
66 #define TP_MODE_EN(x) ((x) << 4) argument
67 #define TP_ADC_SELECT(x) ((x) << 3) argument
68 #define ADC_CHAN_SELECT(x) ((x) << 0) /* 3 bits */ argument
70 /* on sun6i, bits 3~6 are left shifted by 1 to 4~7 */
71 #define SUN6I_TP_MODE_EN(x) ((x) << 5) argument
74 #define TP_SENSITIVE_ADJUST(x) ((x) << 28) /* 4 bits */ argument
75 #define TP_MODE_SELECT(x) ((x) << 26) /* 2 bits */ argument
76 #define PRE_MEA_EN(x) ((x) << 24) argument
77 #define PRE_MEA_THRE_CNT(x) ((x) << 0) /* 24 bits */ argument
80 #define FILTER_EN(x) ((x) << 2) argument
81 #define FILTER_TYPE(x) ((x) << 0) /* 2 bits */ argument
84 #define TEMP_IRQ_EN(x) ((x) << 18) argument
85 #define OVERRUN_IRQ_EN(x) ((x) << 17) argument
86 #define DATA_IRQ_EN(x) ((x) << 16) argument
87 #define TP_DATA_XY_CHANGE(x) ((x) << 13) argument
88 #define FIFO_TRIG(x) ((x) << 8) /* 5 bits */ argument
89 #define DATA_DRQ_EN(x) ((x) << 7) argument
90 #define FIFO_FLUSH(x) ((x) << 4) argument
91 #define TP_UP_IRQ_EN(x) ((x) << 1) argument
92 #define TP_DOWN_IRQ_EN(x) ((x) << 0) argument
103 #define TEMP_ENABLE(x) ((x) << 16) argument
104 #define TEMP_PERIOD(x) ((x) << 0) /* t = x * 256 * 16 / clkin */ argument
109 void __iomem *base; member
119 u32 x, y; in sun4i_ts_irq_handle_input() local
122 x = readl(ts->base + TP_DATA); in sun4i_ts_irq_handle_input()
123 y = readl(ts->base + TP_DATA); in sun4i_ts_irq_handle_input()
125 if (!ts->ignore_fifo_data) { in sun4i_ts_irq_handle_input()
126 input_report_abs(ts->input, ABS_X, x); in sun4i_ts_irq_handle_input()
127 input_report_abs(ts->input, ABS_Y, y); in sun4i_ts_irq_handle_input()
133 input_report_key(ts->input, BTN_TOUCH, 1); in sun4i_ts_irq_handle_input()
134 input_sync(ts->input); in sun4i_ts_irq_handle_input()
136 ts->ignore_fifo_data = false; in sun4i_ts_irq_handle_input()
141 ts->ignore_fifo_data = true; in sun4i_ts_irq_handle_input()
142 input_report_key(ts->input, BTN_TOUCH, 0); in sun4i_ts_irq_handle_input()
143 input_sync(ts->input); in sun4i_ts_irq_handle_input()
152 reg_val = readl(ts->base + TP_INT_FIFOS); in sun4i_ts_irq()
155 ts->temp_data = readl(ts->base + TEMP_DATA); in sun4i_ts_irq()
157 if (ts->input) in sun4i_ts_irq()
160 writel(reg_val, ts->base + TP_INT_FIFOS); in sun4i_ts_irq()
171 TP_UP_IRQ_EN(1), ts->base + TP_INT_FIFOC); in sun4i_ts_open()
181 writel(TEMP_IRQ_EN(1), ts->base + TP_INT_FIFOC); in sun4i_ts_close()
187 if (ts->temp_data == -1) in sun4i_get_temp()
188 return -EAGAIN; in sun4i_get_temp()
190 *temp = ts->temp_data * ts->temp_step - ts->temp_offset; in sun4i_get_temp()
237 struct device *dev = &pdev->dev; in sun4i_ts_probe()
238 struct device_node *np = dev->of_node; in sun4i_ts_probe()
249 return -ENOMEM; in sun4i_ts_probe()
251 ts->dev = dev; in sun4i_ts_probe()
252 ts->ignore_fifo_data = true; in sun4i_ts_probe()
253 ts->temp_data = -1; in sun4i_ts_probe()
254 if (of_device_is_compatible(np, "allwinner,sun6i-a31-ts")) { in sun4i_ts_probe()
255 /* Allwinner SDK has temperature (C) = (value / 6) - 271 */ in sun4i_ts_probe()
256 ts->temp_offset = 271000; in sun4i_ts_probe()
257 ts->temp_step = 167; in sun4i_ts_probe()
258 } else if (of_device_is_compatible(np, "allwinner,sun4i-a10-ts")) { in sun4i_ts_probe()
263 * temp_step from 0.096 - 0.170 and temp_offset from 176 - 331. in sun4i_ts_probe()
265 ts->temp_offset = 257000; in sun4i_ts_probe()
266 ts->temp_step = 133; in sun4i_ts_probe()
271 * which is designed by X-Powers, an affiliate of Allwinner: in sun4i_ts_probe()
273 * temperature (C) = (value * 0.1) - 144.7 in sun4i_ts_probe()
279 ts->temp_offset = 144700; in sun4i_ts_probe()
280 ts->temp_step = 100; in sun4i_ts_probe()
283 ts_attached = of_property_read_bool(np, "allwinner,ts-attached"); in sun4i_ts_probe()
285 ts->input = devm_input_allocate_device(dev); in sun4i_ts_probe()
286 if (!ts->input) in sun4i_ts_probe()
287 return -ENOMEM; in sun4i_ts_probe()
289 ts->input->name = pdev->name; in sun4i_ts_probe()
290 ts->input->phys = "sun4i_ts/input0"; in sun4i_ts_probe()
291 ts->input->open = sun4i_ts_open; in sun4i_ts_probe()
292 ts->input->close = sun4i_ts_close; in sun4i_ts_probe()
293 ts->input->id.bustype = BUS_HOST; in sun4i_ts_probe()
294 ts->input->id.vendor = 0x0001; in sun4i_ts_probe()
295 ts->input->id.product = 0x0001; in sun4i_ts_probe()
296 ts->input->id.version = 0x0100; in sun4i_ts_probe()
297 ts->input->evbit[0] = BIT(EV_SYN) | BIT(EV_KEY) | BIT(EV_ABS); in sun4i_ts_probe()
298 __set_bit(BTN_TOUCH, ts->input->keybit); in sun4i_ts_probe()
299 input_set_abs_params(ts->input, ABS_X, 0, 4095, 0, 0); in sun4i_ts_probe()
300 input_set_abs_params(ts->input, ABS_Y, 0, 4095, 0, 0); in sun4i_ts_probe()
301 input_set_drvdata(ts->input, ts); in sun4i_ts_probe()
304 ts->base = devm_platform_ioremap_resource(pdev, 0); in sun4i_ts_probe()
305 if (IS_ERR(ts->base)) in sun4i_ts_probe()
306 return PTR_ERR(ts->base); in sun4i_ts_probe()
308 ts->irq = platform_get_irq(pdev, 0); in sun4i_ts_probe()
309 error = devm_request_irq(dev, ts->irq, sun4i_ts_irq, 0, "sun4i-ts", ts); in sun4i_ts_probe()
318 ts->base + TP_CTRL0); in sun4i_ts_probe()
322 * tp_mode = 0 : only x and y coordinates, as we don't use dual touch in sun4i_ts_probe()
324 of_property_read_u32(np, "allwinner,tp-sensitive-adjust", in sun4i_ts_probe()
327 ts->base + TP_CTRL2); in sun4i_ts_probe()
333 of_property_read_u32(np, "allwinner,filter-type", &filter_type); in sun4i_ts_probe()
334 writel(FILTER_EN(1) | FILTER_TYPE(filter_type), ts->base + TP_CTRL3); in sun4i_ts_probe()
337 writel(TEMP_ENABLE(1) | TEMP_PERIOD(1953), ts->base + TP_TPR); in sun4i_ts_probe()
344 if (of_device_is_compatible(np, "allwinner,sun6i-a31-ts")) in sun4i_ts_probe()
348 writel(reg, ts->base + TP_CTRL1); in sun4i_ts_probe()
351 * The thermal core does not register hwmon devices for DT-based in sun4i_ts_probe()
354 hwmon = devm_hwmon_device_register_with_groups(ts->dev, "sun4i_ts", in sun4i_ts_probe()
359 thermal = devm_thermal_of_zone_register(ts->dev, 0, ts, in sun4i_ts_probe()
364 writel(TEMP_IRQ_EN(1), ts->base + TP_INT_FIFOC); in sun4i_ts_probe()
367 error = input_register_device(ts->input); in sun4i_ts_probe()
369 writel(0, ts->base + TP_INT_FIFOC); in sun4i_ts_probe()
383 if (ts->input) in sun4i_ts_remove()
384 input_unregister_device(ts->input); in sun4i_ts_remove()
387 writel(0, ts->base + TP_INT_FIFOC); in sun4i_ts_remove()
391 { .compatible = "allwinner,sun4i-a10-ts", },
392 { .compatible = "allwinner,sun5i-a13-ts", },
393 { .compatible = "allwinner,sun6i-a31-ts", },
400 .name = "sun4i-ts",