Lines Matching refs:ts

126 static void sun4i_ts_irq_handle_input(struct sun4i_ts_data *ts, u32 reg_val)  in sun4i_ts_irq_handle_input()  argument
131 x = readl(ts->base + TP_DATA); in sun4i_ts_irq_handle_input()
132 y = readl(ts->base + TP_DATA); in sun4i_ts_irq_handle_input()
134 if (!ts->ignore_fifo_data) { in sun4i_ts_irq_handle_input()
135 input_report_abs(ts->input, ABS_X, x); in sun4i_ts_irq_handle_input()
136 input_report_abs(ts->input, ABS_Y, y); in sun4i_ts_irq_handle_input()
142 input_report_key(ts->input, BTN_TOUCH, 1); in sun4i_ts_irq_handle_input()
143 input_sync(ts->input); in sun4i_ts_irq_handle_input()
145 ts->ignore_fifo_data = false; in sun4i_ts_irq_handle_input()
150 ts->ignore_fifo_data = true; in sun4i_ts_irq_handle_input()
151 input_report_key(ts->input, BTN_TOUCH, 0); in sun4i_ts_irq_handle_input()
152 input_sync(ts->input); in sun4i_ts_irq_handle_input()
158 struct sun4i_ts_data *ts = dev_id; in sun4i_ts_irq() local
161 reg_val = readl(ts->base + TP_INT_FIFOS); in sun4i_ts_irq()
164 ts->temp_data = readl(ts->base + TEMP_DATA); in sun4i_ts_irq()
166 if (ts->input) in sun4i_ts_irq()
167 sun4i_ts_irq_handle_input(ts, reg_val); in sun4i_ts_irq()
169 writel(reg_val, ts->base + TP_INT_FIFOS); in sun4i_ts_irq()
176 struct sun4i_ts_data *ts = input_get_drvdata(dev); in sun4i_ts_open() local
180 TP_UP_IRQ_EN(1), ts->base + TP_INT_FIFOC); in sun4i_ts_open()
187 struct sun4i_ts_data *ts = input_get_drvdata(dev); in sun4i_ts_close() local
190 writel(TEMP_IRQ_EN(1), ts->base + TP_INT_FIFOC); in sun4i_ts_close()
193 static int sun4i_get_temp(const struct sun4i_ts_data *ts, int *temp) in sun4i_get_temp() argument
196 if (ts->temp_data == -1) in sun4i_get_temp()
199 *temp = ts->temp_data * ts->temp_step - ts->temp_offset; in sun4i_get_temp()
216 struct sun4i_ts_data *ts = dev_get_drvdata(dev); in show_temp() local
220 error = sun4i_get_temp(ts, &temp); in show_temp()
245 struct sun4i_ts_data *ts; in sun4i_ts_probe() local
255 ts = devm_kzalloc(dev, sizeof(struct sun4i_ts_data), GFP_KERNEL); in sun4i_ts_probe()
256 if (!ts) in sun4i_ts_probe()
259 ts->dev = dev; in sun4i_ts_probe()
260 ts->ignore_fifo_data = true; in sun4i_ts_probe()
261 ts->temp_data = -1; in sun4i_ts_probe()
264 ts->temp_offset = 271000; in sun4i_ts_probe()
265 ts->temp_step = 167; in sun4i_ts_probe()
273 ts->temp_offset = 257000; in sun4i_ts_probe()
274 ts->temp_step = 133; in sun4i_ts_probe()
287 ts->temp_offset = 144700; in sun4i_ts_probe()
288 ts->temp_step = 100; in sun4i_ts_probe()
293 ts->input = devm_input_allocate_device(dev); in sun4i_ts_probe()
294 if (!ts->input) in sun4i_ts_probe()
297 ts->input->name = pdev->name; in sun4i_ts_probe()
298 ts->input->phys = "sun4i_ts/input0"; in sun4i_ts_probe()
299 ts->input->open = sun4i_ts_open; in sun4i_ts_probe()
300 ts->input->close = sun4i_ts_close; in sun4i_ts_probe()
301 ts->input->id.bustype = BUS_HOST; in sun4i_ts_probe()
302 ts->input->id.vendor = 0x0001; in sun4i_ts_probe()
303 ts->input->id.product = 0x0001; in sun4i_ts_probe()
304 ts->input->id.version = 0x0100; in sun4i_ts_probe()
305 ts->input->evbit[0] = BIT(EV_SYN) | BIT(EV_KEY) | BIT(EV_ABS); in sun4i_ts_probe()
306 __set_bit(BTN_TOUCH, ts->input->keybit); in sun4i_ts_probe()
307 input_set_abs_params(ts->input, ABS_X, 0, 4095, 0, 0); in sun4i_ts_probe()
308 input_set_abs_params(ts->input, ABS_Y, 0, 4095, 0, 0); in sun4i_ts_probe()
309 input_set_drvdata(ts->input, ts); in sun4i_ts_probe()
312 ts->base = devm_ioremap_resource(dev, in sun4i_ts_probe()
314 if (IS_ERR(ts->base)) in sun4i_ts_probe()
315 return PTR_ERR(ts->base); in sun4i_ts_probe()
317 ts->irq = platform_get_irq(pdev, 0); in sun4i_ts_probe()
318 error = devm_request_irq(dev, ts->irq, sun4i_ts_irq, 0, "sun4i-ts", ts); in sun4i_ts_probe()
327 ts->base + TP_CTRL0); in sun4i_ts_probe()
336 ts->base + TP_CTRL2); in sun4i_ts_probe()
343 writel(FILTER_EN(1) | FILTER_TYPE(filter_type), ts->base + TP_CTRL3); in sun4i_ts_probe()
346 writel(TEMP_ENABLE(1) | TEMP_PERIOD(1953), ts->base + TP_TPR); in sun4i_ts_probe()
357 writel(reg, ts->base + TP_CTRL1); in sun4i_ts_probe()
363 hwmon = devm_hwmon_device_register_with_groups(ts->dev, "sun4i_ts", in sun4i_ts_probe()
364 ts, sun4i_ts_groups); in sun4i_ts_probe()
368 devm_thermal_zone_of_sensor_register(ts->dev, 0, ts, &sun4i_ts_tz_ops); in sun4i_ts_probe()
370 writel(TEMP_IRQ_EN(1), ts->base + TP_INT_FIFOC); in sun4i_ts_probe()
373 error = input_register_device(ts->input); in sun4i_ts_probe()
375 writel(0, ts->base + TP_INT_FIFOC); in sun4i_ts_probe()
380 platform_set_drvdata(pdev, ts); in sun4i_ts_probe()
386 struct sun4i_ts_data *ts = platform_get_drvdata(pdev); in sun4i_ts_remove() local
389 if (ts->input) in sun4i_ts_remove()
390 input_unregister_device(ts->input); in sun4i_ts_remove()
393 writel(0, ts->base + TP_INT_FIFOC); in sun4i_ts_remove()