14 #include <linux/module.h>
15 #include <linux/kernel.h>
17 #include <linux/sched.h>
18 #include <linux/list.h>
19 #include <linux/slab.h>
62 unsigned val1,
unsigned val2,
63 unsigned *samples_left);
85 #define adc_dbg(_adc, msg...) dev_dbg(&(_adc)->pdev->dev, msg)
108 if (!client->
is_ts) {
121 static void s3c_adc_dbgshow(
struct adc_device *adc)
123 adc_dbg(adc,
"CON=%08x, TSC=%08x, DLY=%08x\n",
129 static void s3c_adc_try(
struct adc_device *adc)
133 if (!next && !list_empty(&adc_pending)) {
141 adc_dbg(adc,
"new client is %p\n", next);
143 s3c_adc_select(adc, next);
144 s3c_adc_convert(adc);
145 s3c_adc_dbgshow(adc);
163 spin_unlock_irqrestore(&adc->
lock, flags);
178 spin_unlock_irqrestore(&adc->
lock, flags);
185 unsigned v,
unsigned u,
unsigned *
left)
197 client->
wait = &wake;
225 unsigned int selected),
227 unsigned d0,
unsigned d1,
228 unsigned *samples_left),
236 select = s3c_adc_default_select;
243 dev_err(&pdev->
dev,
"no memory for adc client\n");
263 if (adc_dev->
cur == client)
265 if (adc_dev->
ts_pend == client)
279 s3c_adc_try(adc_dev);
281 spin_unlock_irqrestore(&adc_dev->
lock, flags);
294 dev_warn(&adc->
pdev->dev,
"%s: no adc pending\n", __func__);
320 s3c_adc_convert(adc);
322 spin_lock(&adc->
lock);
327 spin_unlock(&adc->
lock);
349 dev_err(dev,
"failed to allocate adc_device\n");
359 if (IS_ERR(adc->
vdd)) {
360 dev_err(dev,
"operating without regulator \"vdd\" .\n");
361 ret = PTR_ERR(adc->
vdd);
367 dev_err(dev,
"failed to get adc irq\n");
374 dev_err(dev,
"failed to attach adc irq\n");
379 if (IS_ERR(adc->
clk)) {
380 dev_err(dev,
"failed to get adc clock\n");
381 ret = PTR_ERR(adc->
clk);
387 dev_err(dev,
"failed to find registers\n");
394 dev_err(dev,
"failed to map registers\n");
415 dev_info(dev,
"attached adc driver\n");
417 platform_set_drvdata(pdev, adc);
438 struct adc_device *adc = platform_get_drvdata(pdev);
456 struct adc_device *adc = platform_get_drvdata(pdev);
467 spin_unlock_irqrestore(&adc->
lock, flags);
478 struct adc_device *adc = platform_get_drvdata(pdev);
503 #define s3c_adc_suspend NULL
504 #define s3c_adc_resume NULL
509 .name =
"s3c24xx-adc",
512 .name =
"s3c2443-adc",
515 .name =
"s3c2416-adc",
518 .name =
"s3c64xx-adc",
521 .name =
"samsung-adc-v3",
534 .id_table = s3c_adc_driver_ids,
540 .probe = s3c_adc_probe,
544 static int __init adc_init(
void)