diff options
author | Vasily Khoruzhick <anarsoul@gmail.com> | 2009-10-24 03:05:02 -0500 |
---|---|---|
committer | Lars-Peter Clausen <lars@metafoo.de> | 2009-12-21 17:15:40 +0100 |
commit | 871c0b38ef349686071b055d012bff712088aa61 (patch) | |
tree | d6207f0a824e62af8d8dae3563e1c5c071a769d4 | |
parent | 7f90a049d8ddcb6c485e2a6889cb3b5d4a5be1c0 (diff) |
Fix resume conversions
This patch fixes a bug where the TS might stop working after suspend/resume.
This patch is under upstream review and it seems it will change a lot.
Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
Signed-off-by: Nelson Castillo <arhuaco@freaks-unidos.net>
-rw-r--r-- | arch/arm/plat-s3c24xx/adc.c | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/arch/arm/plat-s3c24xx/adc.c b/arch/arm/plat-s3c24xx/adc.c index a1dbd0ce59e..3b16670b003 100644 --- a/arch/arm/plat-s3c24xx/adc.c +++ b/arch/arm/plat-s3c24xx/adc.c @@ -46,6 +46,7 @@ struct s3c_adc_client { int result; unsigned char is_ts; unsigned char channel; + unsigned int selected; void (*select_cb)(struct s3c_adc_client *c, unsigned selected); void (*convert_cb)(struct s3c_adc_client *c, @@ -69,6 +70,8 @@ struct adc_device { static struct adc_device *adc_dev; +static struct work_struct resume_work; + static LIST_HEAD(adc_pending); #define adc_dbg(_adc, msg...) dev_dbg(&(_adc)->pdev->dev, msg) @@ -86,7 +89,10 @@ static inline void s3c_adc_select(struct adc_device *adc, { unsigned con = readl(adc->regs + S3C2410_ADCCON); - client->select_cb(client, 1); + if (!client->selected) { + client->selected = 1; + client->select_cb(client, 1); + } con &= ~S3C2410_ADCCON_MUXMASK; con &= ~S3C2410_ADCCON_STDBM; @@ -110,12 +116,9 @@ static void s3c_adc_try(struct adc_device *adc) { struct s3c_adc_client *next = adc->ts_pend; - if (!next && !list_empty(&adc_pending)) { + if (!next && !list_empty(&adc_pending)) next = list_first_entry(&adc_pending, struct s3c_adc_client, pend); - list_del(&next->pend); - } else - adc->ts_pend = NULL; if (next) { adc_dbg(adc, "new client is %p\n", next); @@ -278,14 +281,20 @@ static irqreturn_t s3c_adc_irq(int irq, void *pw) if (client->nr_samples > 0) { /* fire another conversion for this */ - + client->selected = 1; client->select_cb(client, 1); s3c_adc_convert(adc); } else { local_irq_save(flags); - (client->select_cb)(client, 0); + client->selected = 0; + if (!adc->cur->is_ts) + list_del(&adc->cur->pend); + else + adc->ts_pend = NULL; adc->cur = NULL; + (client->select_cb)(client, 0); + s3c_adc_try(adc); local_irq_restore(flags); } @@ -392,20 +401,43 @@ static int s3c_adc_suspend(struct platform_device *pdev, pm_message_t state) writel(con, adc->regs + S3C2410_ADCCON); clk_disable(adc->clk); + disable_irq(IRQ_ADC); + if (!list_empty(&adc_pending) || adc->ts_pend) + dev_info(&pdev->dev, "We still have adc clients pending\n"); return 0; } +/* It seems this is not needed. This is under upstream review now. */ +static void adc_resume_work(struct work_struct *work) +{ + if (!adc_dev) /* Have no ADC here */ + return; + + if (!list_empty(&adc_pending) || adc_dev->ts_pend) + /* We still have adc clients pending */ + s3c_adc_try(adc_dev); +} + static int s3c_adc_resume(struct platform_device *pdev) { struct adc_device *adc = platform_get_drvdata(pdev); + enable_irq(IRQ_ADC); clk_enable(adc->clk); writel(adc->prescale | S3C2410_ADCCON_PRSCEN, adc->regs + S3C2410_ADCCON); writel(adc->delay, adc->regs + S3C2410_ADCDLY); + /* Schedule task if there are clients pending. */ + if (!list_empty(&adc_pending) || adc_dev->ts_pend) { + INIT_WORK(&resume_work, adc_resume_work); + if (!schedule_work(&resume_work)) + dev_err(&pdev->dev, + "Failed to schedule adc_resume work!\n"); + } + return 0; } |