Input: w90p910_ts - use clk API

Now that clk API is available on ARM we can use it in the driver.

Signed-off-by: Wan ZongShun <mcuos.com@gmail.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
This commit is contained in:
Wan ZongShun 2009-07-12 20:52:19 -07:00 committed by Dmitry Torokhov
parent f9c2273694
commit b7788c5ff9
2 changed files with 14 additions and 13 deletions

View File

@ -498,6 +498,7 @@ config TOUCHSCREEN_TSC2007
config TOUCHSCREEN_W90X900 config TOUCHSCREEN_W90X900
tristate "W90P910 touchscreen driver" tristate "W90P910 touchscreen driver"
depends on HAVE_CLK
help help
Say Y here if you have a W90P910 based touchscreen. Say Y here if you have a W90P910 based touchscreen.

View File

@ -13,6 +13,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/clk.h>
#include <linux/input.h> #include <linux/input.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
@ -47,8 +48,8 @@ enum ts_state {
struct w90p910_ts { struct w90p910_ts {
struct input_dev *input; struct input_dev *input;
struct timer_list timer; struct timer_list timer;
struct clk *clk;
int irq_num; int irq_num;
void __iomem *clocken;
void __iomem *ts_reg; void __iomem *ts_reg;
spinlock_t lock; spinlock_t lock;
enum ts_state state; enum ts_state state;
@ -166,8 +167,7 @@ static int w90p910_open(struct input_dev *dev)
unsigned long val; unsigned long val;
/* enable the ADC clock */ /* enable the ADC clock */
val = __raw_readl(w90p910_ts->clocken); clk_enable(w90p910_ts->clk);
__raw_writel(val | ADC_CLK_EN, w90p910_ts->clocken);
__raw_writel(ADC_RST1, w90p910_ts->ts_reg); __raw_writel(ADC_RST1, w90p910_ts->ts_reg);
msleep(1); msleep(1);
@ -211,8 +211,7 @@ static void w90p910_close(struct input_dev *dev)
del_timer_sync(&w90p910_ts->timer); del_timer_sync(&w90p910_ts->timer);
/* stop the ADC clock */ /* stop the ADC clock */
val = __raw_readl(w90p910_ts->clocken); clk_disable(w90p910_ts->clk);
__raw_writel(val & ~ADC_CLK_EN, w90p910_ts->clocken);
} }
static int __devinit w90x900ts_probe(struct platform_device *pdev) static int __devinit w90x900ts_probe(struct platform_device *pdev)
@ -253,14 +252,12 @@ static int __devinit w90x900ts_probe(struct platform_device *pdev)
goto fail2; goto fail2;
} }
res = platform_get_resource(pdev, IORESOURCE_MEM, 1); w90p910_ts->clk = clk_get(&pdev->dev, NULL);
if (!res) { if (IS_ERR(w90p910_ts->clk)) {
err = -ENXIO; err = PTR_ERR(w90p910_ts->clk);
goto fail3; goto fail3;
} }
w90p910_ts->clocken = (void __iomem *)res->start;
input_dev->name = "W90P910 TouchScreen"; input_dev->name = "W90P910 TouchScreen";
input_dev->phys = "w90p910ts/event0"; input_dev->phys = "w90p910ts/event0";
input_dev->id.bustype = BUS_HOST; input_dev->id.bustype = BUS_HOST;
@ -283,18 +280,19 @@ static int __devinit w90x900ts_probe(struct platform_device *pdev)
if (request_irq(w90p910_ts->irq_num, w90p910_ts_interrupt, if (request_irq(w90p910_ts->irq_num, w90p910_ts_interrupt,
IRQF_DISABLED, "w90p910ts", w90p910_ts)) { IRQF_DISABLED, "w90p910ts", w90p910_ts)) {
err = -EBUSY; err = -EBUSY;
goto fail3; goto fail4;
} }
err = input_register_device(w90p910_ts->input); err = input_register_device(w90p910_ts->input);
if (err) if (err)
goto fail4; goto fail5;
platform_set_drvdata(pdev, w90p910_ts); platform_set_drvdata(pdev, w90p910_ts);
return 0; return 0;
fail4: free_irq(w90p910_ts->irq_num, w90p910_ts); fail5: free_irq(w90p910_ts->irq_num, w90p910_ts);
fail4: clk_put(w90p910_ts->clk);
fail3: iounmap(w90p910_ts->ts_reg); fail3: iounmap(w90p910_ts->ts_reg);
fail2: release_mem_region(res->start, resource_size(res)); fail2: release_mem_region(res->start, resource_size(res));
fail1: input_free_device(input_dev); fail1: input_free_device(input_dev);
@ -311,6 +309,8 @@ static int __devexit w90x900ts_remove(struct platform_device *pdev)
del_timer_sync(&w90p910_ts->timer); del_timer_sync(&w90p910_ts->timer);
iounmap(w90p910_ts->ts_reg); iounmap(w90p910_ts->ts_reg);
clk_put(w90p910_ts->clk);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
release_mem_region(res->start, resource_size(res)); release_mem_region(res->start, resource_size(res));