Lines Matching full:tscadc

29 void am335x_tsc_se_set_cache(struct ti_tscadc_dev *tscadc, u32 val)  in am335x_tsc_se_set_cache()  argument
33 spin_lock_irqsave(&tscadc->reg_lock, flags); in am335x_tsc_se_set_cache()
34 tscadc->reg_se_cache |= val; in am335x_tsc_se_set_cache()
35 if (tscadc->adc_waiting) in am335x_tsc_se_set_cache()
36 wake_up(&tscadc->reg_se_wait); in am335x_tsc_se_set_cache()
37 else if (!tscadc->adc_in_use) in am335x_tsc_se_set_cache()
38 regmap_write(tscadc->regmap, REG_SE, tscadc->reg_se_cache); in am335x_tsc_se_set_cache()
40 spin_unlock_irqrestore(&tscadc->reg_lock, flags); in am335x_tsc_se_set_cache()
44 static void am335x_tscadc_need_adc(struct ti_tscadc_dev *tscadc) in am335x_tscadc_need_adc() argument
49 regmap_read(tscadc->regmap, REG_ADCFSM, &reg); in am335x_tscadc_need_adc()
51 tscadc->adc_waiting = true; in am335x_tscadc_need_adc()
52 prepare_to_wait(&tscadc->reg_se_wait, &wait, in am335x_tscadc_need_adc()
54 spin_unlock_irq(&tscadc->reg_lock); in am335x_tscadc_need_adc()
58 spin_lock_irq(&tscadc->reg_lock); in am335x_tscadc_need_adc()
59 finish_wait(&tscadc->reg_se_wait, &wait); in am335x_tscadc_need_adc()
65 regmap_read(tscadc->regmap, REG_ADCFSM, &reg); in am335x_tscadc_need_adc()
67 tscadc->adc_waiting = false; in am335x_tscadc_need_adc()
69 tscadc->adc_in_use = true; in am335x_tscadc_need_adc()
72 void am335x_tsc_se_set_once(struct ti_tscadc_dev *tscadc, u32 val) in am335x_tsc_se_set_once() argument
74 spin_lock_irq(&tscadc->reg_lock); in am335x_tsc_se_set_once()
75 am335x_tscadc_need_adc(tscadc); in am335x_tsc_se_set_once()
77 regmap_write(tscadc->regmap, REG_SE, val); in am335x_tsc_se_set_once()
78 spin_unlock_irq(&tscadc->reg_lock); in am335x_tsc_se_set_once()
82 void am335x_tsc_se_adc_done(struct ti_tscadc_dev *tscadc) in am335x_tsc_se_adc_done() argument
86 spin_lock_irqsave(&tscadc->reg_lock, flags); in am335x_tsc_se_adc_done()
87 tscadc->adc_in_use = false; in am335x_tsc_se_adc_done()
88 regmap_write(tscadc->regmap, REG_SE, tscadc->reg_se_cache); in am335x_tsc_se_adc_done()
89 spin_unlock_irqrestore(&tscadc->reg_lock, flags); in am335x_tsc_se_adc_done()
93 void am335x_tsc_se_clr(struct ti_tscadc_dev *tscadc, u32 val) in am335x_tsc_se_clr() argument
97 spin_lock_irqsave(&tscadc->reg_lock, flags); in am335x_tsc_se_clr()
98 tscadc->reg_se_cache &= ~val; in am335x_tsc_se_clr()
99 regmap_write(tscadc->regmap, REG_SE, tscadc->reg_se_cache); in am335x_tsc_se_clr()
100 spin_unlock_irqrestore(&tscadc->reg_lock, flags); in am335x_tsc_se_clr()
104 static void tscadc_idle_config(struct ti_tscadc_dev *tscadc) in tscadc_idle_config() argument
109 if (ti_adc_with_touchscreen(tscadc)) in tscadc_idle_config()
112 regmap_write(tscadc->regmap, REG_IDLECONFIG, idleconfig); in tscadc_idle_config()
117 struct ti_tscadc_dev *tscadc; in ti_tscadc_probe() local
129 tscadc = devm_kzalloc(&pdev->dev, sizeof(*tscadc), GFP_KERNEL); in ti_tscadc_probe()
130 if (!tscadc) in ti_tscadc_probe()
133 tscadc->dev = &pdev->dev; in ti_tscadc_probe()
140 tscadc->data = of_device_get_match_data(&pdev->dev); in ti_tscadc_probe()
142 if (ti_adc_with_touchscreen(tscadc)) { in ti_tscadc_probe()
200 tscadc->irq = err; in ti_tscadc_probe()
202 tscadc->tscadc_base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); in ti_tscadc_probe()
203 if (IS_ERR(tscadc->tscadc_base)) in ti_tscadc_probe()
204 return PTR_ERR(tscadc->tscadc_base); in ti_tscadc_probe()
206 tscadc->tscadc_phys_base = res->start; in ti_tscadc_probe()
207 tscadc->regmap = devm_regmap_init_mmio(&pdev->dev, in ti_tscadc_probe()
208 tscadc->tscadc_base, in ti_tscadc_probe()
210 if (IS_ERR(tscadc->regmap)) { in ti_tscadc_probe()
212 return PTR_ERR(tscadc->regmap); in ti_tscadc_probe()
215 spin_lock_init(&tscadc->reg_lock); in ti_tscadc_probe()
216 init_waitqueue_head(&tscadc->reg_se_wait); in ti_tscadc_probe()
237 tscadc->clk_div = (clk_get_rate(clk) / tscadc->data->target_clk_rate) - 1; in ti_tscadc_probe()
238 regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div); in ti_tscadc_probe()
241 * Set the control register bits. tscadc->ctrl stores the configuration in ti_tscadc_probe()
245 tscadc->ctrl = CNTRLREG_STEPID; in ti_tscadc_probe()
246 if (ti_adc_with_touchscreen(tscadc)) { in ti_tscadc_probe()
247 tscadc->ctrl |= CNTRLREG_TSC_STEPCONFIGWRT; in ti_tscadc_probe()
249 tscadc->ctrl |= CNTRLREG_TSC_ENB; in ti_tscadc_probe()
251 tscadc->ctrl |= CNTRLREG_TSC_5WIRE; in ti_tscadc_probe()
253 tscadc->ctrl |= CNTRLREG_TSC_4WIRE; in ti_tscadc_probe()
256 tscadc->ctrl |= CNTRLREG_MAG_PREAMP_PWRDOWN | in ti_tscadc_probe()
259 regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl); in ti_tscadc_probe()
261 tscadc_idle_config(tscadc); in ti_tscadc_probe()
264 regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl | CNTRLREG_SSENB); in ti_tscadc_probe()
268 cell = &tscadc->cells[cell_idx++]; in ti_tscadc_probe()
269 cell->name = tscadc->data->secondary_feature_name; in ti_tscadc_probe()
270 cell->of_compatible = tscadc->data->secondary_feature_compatible; in ti_tscadc_probe()
271 cell->platform_data = &tscadc; in ti_tscadc_probe()
272 cell->pdata_size = sizeof(tscadc); in ti_tscadc_probe()
277 cell = &tscadc->cells[cell_idx++]; in ti_tscadc_probe()
278 cell->name = tscadc->data->adc_feature_name; in ti_tscadc_probe()
279 cell->of_compatible = tscadc->data->adc_feature_compatible; in ti_tscadc_probe()
280 cell->platform_data = &tscadc; in ti_tscadc_probe()
281 cell->pdata_size = sizeof(tscadc); in ti_tscadc_probe()
285 tscadc->cells, cell_idx, NULL, 0, NULL); in ti_tscadc_probe()
289 platform_set_drvdata(pdev, tscadc); in ti_tscadc_probe()
301 struct ti_tscadc_dev *tscadc = platform_get_drvdata(pdev); in ti_tscadc_remove() local
303 regmap_write(tscadc->regmap, REG_SE, 0x00); in ti_tscadc_remove()
308 mfd_remove_devices(tscadc->dev); in ti_tscadc_remove()
318 struct ti_tscadc_dev *tscadc = dev_get_drvdata(dev); in tscadc_suspend() local
320 regmap_write(tscadc->regmap, REG_SE, 0x00); in tscadc_suspend()
324 regmap_read(tscadc->regmap, REG_CTRL, &ctrl); in tscadc_suspend()
327 regmap_write(tscadc->regmap, REG_CTRL, ctrl); in tscadc_suspend()
336 struct ti_tscadc_dev *tscadc = dev_get_drvdata(dev); in tscadc_resume() local
340 regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div); in tscadc_resume()
341 regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl); in tscadc_resume()
342 tscadc_idle_config(tscadc); in tscadc_resume()
343 regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl | CNTRLREG_SSENB); in tscadc_resume()
367 { .compatible = "ti,am3359-tscadc", .data = &tscdata },
375 .name = "ti_am3359-tscadc",