Lines Matching refs:adc
83 static inline void s3c_adc_convert(struct adc_device *adc) in s3c_adc_convert() argument
85 unsigned con = readl(adc->regs + S3C2410_ADCCON); in s3c_adc_convert()
88 writel(con, adc->regs + S3C2410_ADCCON); in s3c_adc_convert()
91 static inline void s3c_adc_select(struct adc_device *adc, in s3c_adc_select() argument
94 unsigned con = readl(adc->regs + S3C2410_ADCCON); in s3c_adc_select()
95 enum s3c_cpu_type cpu = platform_get_device_id(adc->pdev)->driver_data; in s3c_adc_select()
106 writel(client->channel & 0xf, adc->regs + S5P_ADCMUX); in s3c_adc_select()
109 adc->regs + S3C2443_ADCMUX); in s3c_adc_select()
114 writel(con, adc->regs + S3C2410_ADCCON); in s3c_adc_select()
117 static void s3c_adc_dbgshow(struct adc_device *adc) in s3c_adc_dbgshow() argument
119 adc_dbg(adc, "CON=%08x, TSC=%08x, DLY=%08x\n", in s3c_adc_dbgshow()
120 readl(adc->regs + S3C2410_ADCCON), in s3c_adc_dbgshow()
121 readl(adc->regs + S3C2410_ADCTSC), in s3c_adc_dbgshow()
122 readl(adc->regs + S3C2410_ADCDLY)); in s3c_adc_dbgshow()
125 static void s3c_adc_try(struct adc_device *adc) in s3c_adc_try() argument
127 struct s3c_adc_client *next = adc->ts_pend; in s3c_adc_try()
134 adc->ts_pend = NULL; in s3c_adc_try()
137 adc_dbg(adc, "new client is %p\n", next); in s3c_adc_try()
138 adc->cur = next; in s3c_adc_try()
139 s3c_adc_select(adc, next); in s3c_adc_try()
140 s3c_adc_convert(adc); in s3c_adc_try()
141 s3c_adc_dbgshow(adc); in s3c_adc_try()
148 struct adc_device *adc = adc_dev; in s3c_adc_start() local
151 if (!adc) { in s3c_adc_start()
156 spin_lock_irqsave(&adc->lock, flags); in s3c_adc_start()
158 if (client->is_ts && adc->ts_pend) { in s3c_adc_start()
159 spin_unlock_irqrestore(&adc->lock, flags); in s3c_adc_start()
167 adc->ts_pend = client; in s3c_adc_start()
171 if (!adc->cur) in s3c_adc_start()
172 s3c_adc_try(adc); in s3c_adc_start()
174 spin_unlock_irqrestore(&adc->lock, flags); in s3c_adc_start()
282 struct adc_device *adc = pw; in s3c_adc_irq() local
283 struct s3c_adc_client *client = adc->cur; in s3c_adc_irq()
284 enum s3c_cpu_type cpu = platform_get_device_id(adc->pdev)->driver_data; in s3c_adc_irq()
288 dev_warn(&adc->pdev->dev, "%s: no adc pending\n", __func__); in s3c_adc_irq()
292 data0 = readl(adc->regs + S3C2410_ADCDAT0); in s3c_adc_irq()
293 data1 = readl(adc->regs + S3C2410_ADCDAT1); in s3c_adc_irq()
294 adc_dbg(adc, "read %d: 0x%04x, 0x%04x\n", client->nr_samples, data0, data1); in s3c_adc_irq()
314 s3c_adc_convert(adc); in s3c_adc_irq()
316 spin_lock(&adc->lock); in s3c_adc_irq()
318 adc->cur = NULL; in s3c_adc_irq()
320 s3c_adc_try(adc); in s3c_adc_irq()
321 spin_unlock(&adc->lock); in s3c_adc_irq()
327 writel(0, adc->regs + S3C64XX_ADCCLRINT); in s3c_adc_irq()
335 struct adc_device *adc; in s3c_adc_probe() local
340 adc = devm_kzalloc(dev, sizeof(*adc), GFP_KERNEL); in s3c_adc_probe()
341 if (!adc) in s3c_adc_probe()
344 spin_lock_init(&adc->lock); in s3c_adc_probe()
346 adc->pdev = pdev; in s3c_adc_probe()
347 adc->prescale = S3C2410_ADCCON_PRSCVL(49); in s3c_adc_probe()
349 adc->vdd = devm_regulator_get(dev, "vdd"); in s3c_adc_probe()
350 if (IS_ERR(adc->vdd)) { in s3c_adc_probe()
352 return PTR_ERR(adc->vdd); in s3c_adc_probe()
355 adc->irq = platform_get_irq(pdev, 1); in s3c_adc_probe()
356 if (adc->irq <= 0) in s3c_adc_probe()
359 ret = devm_request_irq(dev, adc->irq, s3c_adc_irq, 0, dev_name(dev), in s3c_adc_probe()
360 adc); in s3c_adc_probe()
366 adc->clk = devm_clk_get(dev, "adc"); in s3c_adc_probe()
367 if (IS_ERR(adc->clk)) { in s3c_adc_probe()
369 return PTR_ERR(adc->clk); in s3c_adc_probe()
372 adc->regs = devm_platform_ioremap_resource(pdev, 0); in s3c_adc_probe()
373 if (IS_ERR(adc->regs)) in s3c_adc_probe()
374 return PTR_ERR(adc->regs); in s3c_adc_probe()
376 ret = regulator_enable(adc->vdd); in s3c_adc_probe()
380 clk_prepare_enable(adc->clk); in s3c_adc_probe()
382 tmp = adc->prescale | S3C2410_ADCCON_PRSCEN; in s3c_adc_probe()
390 writel(tmp, adc->regs + S3C2410_ADCCON); in s3c_adc_probe()
394 platform_set_drvdata(pdev, adc); in s3c_adc_probe()
395 adc_dev = adc; in s3c_adc_probe()
402 struct adc_device *adc = platform_get_drvdata(pdev); in s3c_adc_remove() local
404 clk_disable_unprepare(adc->clk); in s3c_adc_remove()
405 regulator_disable(adc->vdd); in s3c_adc_remove()
413 struct adc_device *adc = dev_get_drvdata(dev); in s3c_adc_suspend() local
417 spin_lock_irqsave(&adc->lock, flags); in s3c_adc_suspend()
419 con = readl(adc->regs + S3C2410_ADCCON); in s3c_adc_suspend()
421 writel(con, adc->regs + S3C2410_ADCCON); in s3c_adc_suspend()
423 disable_irq(adc->irq); in s3c_adc_suspend()
424 spin_unlock_irqrestore(&adc->lock, flags); in s3c_adc_suspend()
425 clk_disable(adc->clk); in s3c_adc_suspend()
426 regulator_disable(adc->vdd); in s3c_adc_suspend()
434 struct adc_device *adc = platform_get_drvdata(pdev); in s3c_adc_resume() local
439 ret = regulator_enable(adc->vdd); in s3c_adc_resume()
442 clk_enable(adc->clk); in s3c_adc_resume()
443 enable_irq(adc->irq); in s3c_adc_resume()
445 tmp = adc->prescale | S3C2410_ADCCON_PRSCEN; in s3c_adc_resume()
453 writel(tmp, adc->regs + S3C2410_ADCCON); in s3c_adc_resume()