Lines Matching refs: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
131 tscadc = devm_kzalloc(&pdev->dev, sizeof(*tscadc), GFP_KERNEL); in ti_tscadc_probe()
132 if (!tscadc) in ti_tscadc_probe()
135 tscadc->dev = &pdev->dev; in ti_tscadc_probe()
142 tscadc->data = of_device_get_match_data(&pdev->dev); in ti_tscadc_probe()
144 if (ti_adc_with_touchscreen(tscadc)) { in ti_tscadc_probe()
202 tscadc->irq = err; in ti_tscadc_probe()
205 tscadc->tscadc_base = devm_ioremap_resource(&pdev->dev, res); in ti_tscadc_probe()
206 if (IS_ERR(tscadc->tscadc_base)) in ti_tscadc_probe()
207 return PTR_ERR(tscadc->tscadc_base); in ti_tscadc_probe()
209 tscadc->tscadc_phys_base = res->start; in ti_tscadc_probe()
210 tscadc->regmap = devm_regmap_init_mmio(&pdev->dev, in ti_tscadc_probe()
211 tscadc->tscadc_base, in ti_tscadc_probe()
213 if (IS_ERR(tscadc->regmap)) { in ti_tscadc_probe()
215 return PTR_ERR(tscadc->regmap); in ti_tscadc_probe()
218 spin_lock_init(&tscadc->reg_lock); in ti_tscadc_probe()
219 init_waitqueue_head(&tscadc->reg_se_wait); in ti_tscadc_probe()
240 tscadc->clk_div = (clk_get_rate(clk) / tscadc->data->target_clk_rate) - 1; in ti_tscadc_probe()
241 regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div); in ti_tscadc_probe()
248 tscadc->ctrl = CNTRLREG_STEPID; in ti_tscadc_probe()
249 if (ti_adc_with_touchscreen(tscadc)) { in ti_tscadc_probe()
250 tscadc->ctrl |= CNTRLREG_TSC_STEPCONFIGWRT; in ti_tscadc_probe()
252 tscadc->ctrl |= CNTRLREG_TSC_ENB; in ti_tscadc_probe()
254 tscadc->ctrl |= CNTRLREG_TSC_5WIRE; in ti_tscadc_probe()
256 tscadc->ctrl |= CNTRLREG_TSC_4WIRE; in ti_tscadc_probe()
259 tscadc->ctrl |= CNTRLREG_MAG_PREAMP_PWRDOWN | in ti_tscadc_probe()
262 regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl); in ti_tscadc_probe()
264 tscadc_idle_config(tscadc); in ti_tscadc_probe()
267 regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl | CNTRLREG_SSENB); in ti_tscadc_probe()
271 cell = &tscadc->cells[cell_idx++]; in ti_tscadc_probe()
272 cell->name = tscadc->data->secondary_feature_name; in ti_tscadc_probe()
273 cell->of_compatible = tscadc->data->secondary_feature_compatible; in ti_tscadc_probe()
274 cell->platform_data = &tscadc; in ti_tscadc_probe()
275 cell->pdata_size = sizeof(tscadc); in ti_tscadc_probe()
280 cell = &tscadc->cells[cell_idx++]; in ti_tscadc_probe()
281 cell->name = tscadc->data->adc_feature_name; in ti_tscadc_probe()
282 cell->of_compatible = tscadc->data->adc_feature_compatible; in ti_tscadc_probe()
283 cell->platform_data = &tscadc; in ti_tscadc_probe()
284 cell->pdata_size = sizeof(tscadc); in ti_tscadc_probe()
288 tscadc->cells, cell_idx, NULL, 0, NULL); in ti_tscadc_probe()
292 platform_set_drvdata(pdev, tscadc); in ti_tscadc_probe()
304 struct ti_tscadc_dev *tscadc = platform_get_drvdata(pdev); in ti_tscadc_remove() local
306 regmap_write(tscadc->regmap, REG_SE, 0x00); in ti_tscadc_remove()
311 mfd_remove_devices(tscadc->dev); in ti_tscadc_remove()
323 struct ti_tscadc_dev *tscadc = dev_get_drvdata(dev); in tscadc_suspend() local
325 regmap_write(tscadc->regmap, REG_SE, 0x00); in tscadc_suspend()
329 regmap_read(tscadc->regmap, REG_CTRL, &ctrl); in tscadc_suspend()
332 regmap_write(tscadc->regmap, REG_CTRL, ctrl); in tscadc_suspend()
341 struct ti_tscadc_dev *tscadc = dev_get_drvdata(dev); in tscadc_resume() local
345 regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div); in tscadc_resume()
346 regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl); in tscadc_resume()
347 tscadc_idle_config(tscadc); in tscadc_resume()
348 regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl | CNTRLREG_SSENB); in tscadc_resume()