Lines Matching +full:charge +full:- +full:ctrl +full:- +full:value

4  * Copyright (C) 2012 Texas Instruments Incorporated - https://www.ti.com/
41 spin_lock_irqsave(&tscadc->reg_lock, flags); in am335x_tsc_se_set_cache()
42 tscadc->reg_se_cache |= val; in am335x_tsc_se_set_cache()
43 if (tscadc->adc_waiting) in am335x_tsc_se_set_cache()
44 wake_up(&tscadc->reg_se_wait); in am335x_tsc_se_set_cache()
45 else if (!tscadc->adc_in_use) in am335x_tsc_se_set_cache()
46 regmap_write(tscadc->regmap, REG_SE, tscadc->reg_se_cache); in am335x_tsc_se_set_cache()
48 spin_unlock_irqrestore(&tscadc->reg_lock, flags); in am335x_tsc_se_set_cache()
57 regmap_read(tscadc->regmap, REG_ADCFSM, &reg); in am335x_tscadc_need_adc()
59 tscadc->adc_waiting = true; in am335x_tscadc_need_adc()
60 prepare_to_wait(&tscadc->reg_se_wait, &wait, in am335x_tscadc_need_adc()
62 spin_unlock_irq(&tscadc->reg_lock); in am335x_tscadc_need_adc()
66 spin_lock_irq(&tscadc->reg_lock); in am335x_tscadc_need_adc()
67 finish_wait(&tscadc->reg_se_wait, &wait); in am335x_tscadc_need_adc()
71 * busy applying the charge step. in am335x_tscadc_need_adc()
73 regmap_read(tscadc->regmap, REG_ADCFSM, &reg); in am335x_tscadc_need_adc()
75 tscadc->adc_waiting = false; in am335x_tscadc_need_adc()
77 tscadc->adc_in_use = true; in am335x_tscadc_need_adc()
82 spin_lock_irq(&tscadc->reg_lock); in am335x_tsc_se_set_once()
85 regmap_write(tscadc->regmap, REG_SE, val); in am335x_tsc_se_set_once()
86 spin_unlock_irq(&tscadc->reg_lock); in am335x_tsc_se_set_once()
94 spin_lock_irqsave(&tscadc->reg_lock, flags); in am335x_tsc_se_adc_done()
95 tscadc->adc_in_use = false; in am335x_tsc_se_adc_done()
96 regmap_write(tscadc->regmap, REG_SE, tscadc->reg_se_cache); in am335x_tsc_se_adc_done()
97 spin_unlock_irqrestore(&tscadc->reg_lock, flags); in am335x_tsc_se_adc_done()
105 spin_lock_irqsave(&tscadc->reg_lock, flags); in am335x_tsc_se_clr()
106 tscadc->reg_se_cache &= ~val; in am335x_tsc_se_clr()
107 regmap_write(tscadc->regmap, REG_SE, tscadc->reg_se_cache); in am335x_tsc_se_clr()
108 spin_unlock_irqrestore(&tscadc->reg_lock, flags); in am335x_tsc_se_clr()
119 regmap_write(tscadc->regmap, REG_IDLECONFIG, idleconfig); in tscadc_idle_config()
132 int err, ctrl; in ti_tscadc_probe() local
137 if (!pdev->dev.of_node) { in ti_tscadc_probe()
138 dev_err(&pdev->dev, "Could not find valid DT data.\n"); in ti_tscadc_probe()
139 return -EINVAL; in ti_tscadc_probe()
142 node = of_get_child_by_name(pdev->dev.of_node, "tsc"); in ti_tscadc_probe()
144 of_property_read_u32(node, "ti,coordiante-readouts", &readouts); in ti_tscadc_probe()
146 node = of_get_child_by_name(pdev->dev.of_node, "adc"); in ti_tscadc_probe()
147 of_property_for_each_u32(node, "ti,adc-channels", prop, cur, val) { in ti_tscadc_probe()
150 dev_err(&pdev->dev, " PIN numbers are 0..7 (not %d)\n", in ti_tscadc_probe()
152 return -EINVAL; in ti_tscadc_probe()
157 dev_err(&pdev->dev, "Number of i/p channels more than 8\n"); in ti_tscadc_probe()
158 return -EINVAL; in ti_tscadc_probe()
161 dev_err(&pdev->dev, "Need atleast one channel.\n"); in ti_tscadc_probe()
162 return -EINVAL; in ti_tscadc_probe()
166 dev_err(&pdev->dev, "Too many step configurations requested\n"); in ti_tscadc_probe()
167 return -EINVAL; in ti_tscadc_probe()
171 tscadc = devm_kzalloc(&pdev->dev, sizeof(*tscadc), GFP_KERNEL); in ti_tscadc_probe()
173 return -ENOMEM; in ti_tscadc_probe()
175 tscadc->dev = &pdev->dev; in ti_tscadc_probe()
179 dev_err(&pdev->dev, "no irq ID is specified.\n"); in ti_tscadc_probe()
182 tscadc->irq = err; in ti_tscadc_probe()
185 tscadc->tscadc_base = devm_ioremap_resource(&pdev->dev, res); in ti_tscadc_probe()
186 if (IS_ERR(tscadc->tscadc_base)) in ti_tscadc_probe()
187 return PTR_ERR(tscadc->tscadc_base); in ti_tscadc_probe()
189 tscadc->tscadc_phys_base = res->start; in ti_tscadc_probe()
190 tscadc->regmap = devm_regmap_init_mmio(&pdev->dev, in ti_tscadc_probe()
191 tscadc->tscadc_base, &tscadc_regmap_config); in ti_tscadc_probe()
192 if (IS_ERR(tscadc->regmap)) { in ti_tscadc_probe()
193 dev_err(&pdev->dev, "regmap init failed\n"); in ti_tscadc_probe()
194 err = PTR_ERR(tscadc->regmap); in ti_tscadc_probe()
198 spin_lock_init(&tscadc->reg_lock); in ti_tscadc_probe()
199 init_waitqueue_head(&tscadc->reg_se_wait); in ti_tscadc_probe()
201 pm_runtime_enable(&pdev->dev); in ti_tscadc_probe()
202 pm_runtime_get_sync(&pdev->dev); in ti_tscadc_probe()
208 * and expected to capture 12-bit data at a rate of 200 KSPS. in ti_tscadc_probe()
212 clk = devm_clk_get(&pdev->dev, "adc_tsc_fck"); in ti_tscadc_probe()
214 dev_err(&pdev->dev, "failed to get TSC fck\n"); in ti_tscadc_probe()
219 tscadc->clk_div = clock_rate / ADC_CLK; in ti_tscadc_probe()
221 /* TSCADC_CLKDIV needs to be configured to the value minus 1 */ in ti_tscadc_probe()
222 tscadc->clk_div--; in ti_tscadc_probe()
223 regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div); in ti_tscadc_probe()
226 ctrl = CNTRLREG_STEPCONFIGWRT | CNTRLREG_STEPID; in ti_tscadc_probe()
227 regmap_write(tscadc->regmap, REG_CTRL, ctrl); in ti_tscadc_probe()
231 tscadc->tsc_wires = tsc_wires; in ti_tscadc_probe()
233 ctrl |= CNTRLREG_5WIRE | CNTRLREG_TSCENB; in ti_tscadc_probe()
235 ctrl |= CNTRLREG_4WIRE | CNTRLREG_TSCENB; in ti_tscadc_probe()
240 ctrl |= CNTRLREG_TSCSSENB; in ti_tscadc_probe()
241 regmap_write(tscadc->regmap, REG_CTRL, ctrl); in ti_tscadc_probe()
243 tscadc->used_cells = 0; in ti_tscadc_probe()
244 tscadc->tsc_cell = -1; in ti_tscadc_probe()
245 tscadc->adc_cell = -1; in ti_tscadc_probe()
249 tscadc->tsc_cell = tscadc->used_cells; in ti_tscadc_probe()
250 cell = &tscadc->cells[tscadc->used_cells++]; in ti_tscadc_probe()
251 cell->name = "TI-am335x-tsc"; in ti_tscadc_probe()
252 cell->of_compatible = "ti,am3359-tsc"; in ti_tscadc_probe()
253 cell->platform_data = &tscadc; in ti_tscadc_probe()
254 cell->pdata_size = sizeof(tscadc); in ti_tscadc_probe()
259 tscadc->adc_cell = tscadc->used_cells; in ti_tscadc_probe()
260 cell = &tscadc->cells[tscadc->used_cells++]; in ti_tscadc_probe()
261 cell->name = "TI-am335x-adc"; in ti_tscadc_probe()
262 cell->of_compatible = "ti,am3359-adc"; in ti_tscadc_probe()
263 cell->platform_data = &tscadc; in ti_tscadc_probe()
264 cell->pdata_size = sizeof(tscadc); in ti_tscadc_probe()
267 err = mfd_add_devices(&pdev->dev, PLATFORM_DEVID_AUTO, in ti_tscadc_probe()
268 tscadc->cells, tscadc->used_cells, NULL, in ti_tscadc_probe()
277 pm_runtime_put_sync(&pdev->dev); in ti_tscadc_probe()
278 pm_runtime_disable(&pdev->dev); in ti_tscadc_probe()
287 regmap_write(tscadc->regmap, REG_SE, 0x00); in ti_tscadc_remove()
289 pm_runtime_put_sync(&pdev->dev); in ti_tscadc_remove()
290 pm_runtime_disable(&pdev->dev); in ti_tscadc_remove()
292 mfd_remove_devices(tscadc->dev); in ti_tscadc_remove()
306 regmap_write(tscadc->regmap, REG_SE, 0x00); in tscadc_suspend()
308 u32 ctrl; in tscadc_suspend() local
310 regmap_read(tscadc->regmap, REG_CTRL, &ctrl); in tscadc_suspend()
311 ctrl &= ~(CNTRLREG_POWERDOWN); in tscadc_suspend()
312 ctrl |= CNTRLREG_TSCSSENB; in tscadc_suspend()
313 regmap_write(tscadc->regmap, REG_CTRL, ctrl); in tscadc_suspend()
323 u32 ctrl; in tscadc_resume() local
328 ctrl = CNTRLREG_STEPCONFIGWRT | CNTRLREG_STEPID; in tscadc_resume()
329 regmap_write(tscadc->regmap, REG_CTRL, ctrl); in tscadc_resume()
331 if (tscadc->tsc_cell != -1) { in tscadc_resume()
332 if (tscadc->tsc_wires == 5) in tscadc_resume()
333 ctrl |= CNTRLREG_5WIRE | CNTRLREG_TSCENB; in tscadc_resume()
335 ctrl |= CNTRLREG_4WIRE | CNTRLREG_TSCENB; in tscadc_resume()
338 ctrl |= CNTRLREG_TSCSSENB; in tscadc_resume()
339 regmap_write(tscadc->regmap, REG_CTRL, ctrl); in tscadc_resume()
341 regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div); in tscadc_resume()
349 { .compatible = "ti,am3359-tscadc", },
356 .name = "ti_am3359-tscadc",