diff options
author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2007-08-20 05:19:39 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2007-10-12 16:14:59 -0400 |
commit | 22d8a73a8b39ef236c80ea73704884f7a7862193 (patch) | |
tree | c504c30b00a11d8fbfcc7d70ddfed5ff778c658f | |
parent | c3cef3f3c07bb98e023e4d5441e60538516a4741 (diff) |
[ARM] pxa: update pxa27x keypad driver to use clk support
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r-- | drivers/input/keyboard/pxa27x_keyboard.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/drivers/input/keyboard/pxa27x_keyboard.c b/drivers/input/keyboard/pxa27x_keyboard.c index ebe5eacf2990..b7061aa38816 100644 --- a/drivers/input/keyboard/pxa27x_keyboard.c +++ b/drivers/input/keyboard/pxa27x_keyboard.c | |||
@@ -23,6 +23,8 @@ | |||
23 | #include <linux/input.h> | 23 | #include <linux/input.h> |
24 | #include <linux/device.h> | 24 | #include <linux/device.h> |
25 | #include <linux/platform_device.h> | 25 | #include <linux/platform_device.h> |
26 | #include <linux/clk.h> | ||
27 | #include <linux/err.h> | ||
26 | 28 | ||
27 | #include <asm/mach-types.h> | 29 | #include <asm/mach-types.h> |
28 | #include <asm/mach/arch.h> | 30 | #include <asm/mach/arch.h> |
@@ -40,6 +42,8 @@ | |||
40 | col/2 == 2 ? KPASMKP2 : KPASMKP3) | 42 | col/2 == 2 ? KPASMKP2 : KPASMKP3) |
41 | #define KPASMKPx_MKC(row, col) (1 << (row + 16 * (col % 2))) | 43 | #define KPASMKPx_MKC(row, col) (1 << (row + 16 * (col % 2))) |
42 | 44 | ||
45 | static struct clk *pxakbd_clk; | ||
46 | |||
43 | static irqreturn_t pxakbd_irq_handler(int irq, void *dev_id) | 47 | static irqreturn_t pxakbd_irq_handler(int irq, void *dev_id) |
44 | { | 48 | { |
45 | struct platform_device *pdev = dev_id; | 49 | struct platform_device *pdev = dev_id; |
@@ -104,7 +108,7 @@ static int pxakbd_open(struct input_dev *dev) | |||
104 | KPREC = 0x7F; | 108 | KPREC = 0x7F; |
105 | 109 | ||
106 | /* Enable unit clock */ | 110 | /* Enable unit clock */ |
107 | pxa_set_cken(CKEN_KEYPAD, 1); | 111 | clk_enable(pxakbd_clk); |
108 | 112 | ||
109 | return 0; | 113 | return 0; |
110 | } | 114 | } |
@@ -112,7 +116,7 @@ static int pxakbd_open(struct input_dev *dev) | |||
112 | static void pxakbd_close(struct input_dev *dev) | 116 | static void pxakbd_close(struct input_dev *dev) |
113 | { | 117 | { |
114 | /* Disable clock unit */ | 118 | /* Disable clock unit */ |
115 | pxa_set_cken(CKEN_KEYPAD, 0); | 119 | clk_disable(pxakbd_clk); |
116 | } | 120 | } |
117 | 121 | ||
118 | #ifdef CONFIG_PM | 122 | #ifdef CONFIG_PM |
@@ -140,7 +144,8 @@ static int pxakbd_resume(struct platform_device *pdev) | |||
140 | KPREC = pdata->reg_kprec; | 144 | KPREC = pdata->reg_kprec; |
141 | 145 | ||
142 | /* Enable unit clock */ | 146 | /* Enable unit clock */ |
143 | pxa_set_cken(CKEN_KEYPAD, 1); | 147 | clk_disable(pxakbd_clk); |
148 | clk_enable(pxakbd_clk); | ||
144 | } | 149 | } |
145 | 150 | ||
146 | mutex_unlock(&input_dev->mutex); | 151 | mutex_unlock(&input_dev->mutex); |
@@ -158,11 +163,18 @@ static int __devinit pxakbd_probe(struct platform_device *pdev) | |||
158 | struct input_dev *input_dev; | 163 | struct input_dev *input_dev; |
159 | int i, row, col, error; | 164 | int i, row, col, error; |
160 | 165 | ||
166 | pxakbd_clk = clk_get(&pdev->dev, "KBDCLK"); | ||
167 | if (IS_ERR(pxakbd_clk)) { | ||
168 | error = PTR_ERR(pxakbd_clk); | ||
169 | goto err_clk; | ||
170 | } | ||
171 | |||
161 | /* Create and register the input driver. */ | 172 | /* Create and register the input driver. */ |
162 | input_dev = input_allocate_device(); | 173 | input_dev = input_allocate_device(); |
163 | if (!input_dev) { | 174 | if (!input_dev) { |
164 | printk(KERN_ERR "Cannot request keypad device\n"); | 175 | printk(KERN_ERR "Cannot request keypad device\n"); |
165 | return -ENOMEM; | 176 | error = -ENOMEM; |
177 | goto err_alloc; | ||
166 | } | 178 | } |
167 | 179 | ||
168 | input_dev->name = DRIVER_NAME; | 180 | input_dev->name = DRIVER_NAME; |
@@ -185,7 +197,6 @@ static int __devinit pxakbd_probe(struct platform_device *pdev) | |||
185 | DRIVER_NAME, pdev); | 197 | DRIVER_NAME, pdev); |
186 | if (error) { | 198 | if (error) { |
187 | printk(KERN_ERR "Cannot request keypad IRQ\n"); | 199 | printk(KERN_ERR "Cannot request keypad IRQ\n"); |
188 | pxa_set_cken(CKEN_KEYPAD, 0); | ||
189 | goto err_free_dev; | 200 | goto err_free_dev; |
190 | } | 201 | } |
191 | 202 | ||
@@ -217,6 +228,9 @@ static int __devinit pxakbd_probe(struct platform_device *pdev) | |||
217 | free_irq(IRQ_KEYPAD, pdev); | 228 | free_irq(IRQ_KEYPAD, pdev); |
218 | err_free_dev: | 229 | err_free_dev: |
219 | input_free_device(input_dev); | 230 | input_free_device(input_dev); |
231 | err_alloc: | ||
232 | clk_put(pxakbd_clk); | ||
233 | err_clk: | ||
220 | return error; | 234 | return error; |
221 | } | 235 | } |
222 | 236 | ||
@@ -226,6 +240,7 @@ static int __devexit pxakbd_remove(struct platform_device *pdev) | |||
226 | 240 | ||
227 | input_unregister_device(input_dev); | 241 | input_unregister_device(input_dev); |
228 | free_irq(IRQ_KEYPAD, pdev); | 242 | free_irq(IRQ_KEYPAD, pdev); |
243 | clk_put(pxakbd_clk); | ||
229 | platform_set_drvdata(pdev, NULL); | 244 | platform_set_drvdata(pdev, NULL); |
230 | 245 | ||
231 | return 0; | 246 | return 0; |