aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/misc
diff options
context:
space:
mode:
authorSonic Zhang <sonic.zhang@analog.com>2015-02-06 00:32:59 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2015-02-15 19:06:28 -0500
commit71adf22f476aae18bfe1fb7605d41f9cf95d0e5f (patch)
tree96fe2109cf379cc9371dc5185eefbdb1d8f365b7 /drivers/input/misc
parent5ea0699a7b452c9e1ecdc81e354fa91dfe8da4f6 (diff)
Input: bfin_rotary - use generic IO functions
Instead of using arch-specific accessors remap rotary register physical address into kernel space in probe and use standard readw and writew to access rotary MMRs. Signed-off-by: Sonic Zhang <sonic.zhang@analog.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/misc')
-rw-r--r--drivers/input/misc/bfin_rotary.c62
1 files changed, 43 insertions, 19 deletions
diff --git a/drivers/input/misc/bfin_rotary.c b/drivers/input/misc/bfin_rotary.c
index 8312b29ab18d..791ea6a48984 100644
--- a/drivers/input/misc/bfin_rotary.c
+++ b/drivers/input/misc/bfin_rotary.c
@@ -7,6 +7,7 @@
7 7
8#include <linux/module.h> 8#include <linux/module.h>
9#include <linux/interrupt.h> 9#include <linux/interrupt.h>
10#include <linux/io.h>
10#include <linux/irq.h> 11#include <linux/irq.h>
11#include <linux/pm.h> 12#include <linux/pm.h>
12#include <linux/platform_device.h> 13#include <linux/platform_device.h>
@@ -16,8 +17,18 @@
16 17
17#include <asm/portmux.h> 18#include <asm/portmux.h>
18 19
20#define CNT_CONFIG_OFF 0 /* CNT Config Offset */
21#define CNT_IMASK_OFF 4 /* CNT Interrupt Mask Offset */
22#define CNT_STATUS_OFF 8 /* CNT Status Offset */
23#define CNT_COMMAND_OFF 12 /* CNT Command Offset */
24#define CNT_DEBOUNCE_OFF 16 /* CNT Debounce Offset */
25#define CNT_COUNTER_OFF 20 /* CNT Counter Offset */
26#define CNT_MAX_OFF 24 /* CNT Maximum Count Offset */
27#define CNT_MIN_OFF 28 /* CNT Minimum Count Offset */
28
19struct bfin_rot { 29struct bfin_rot {
20 struct input_dev *input; 30 struct input_dev *input;
31 void __iomem *base;
21 int irq; 32 int irq;
22 unsigned int up_key; 33 unsigned int up_key;
23 unsigned int down_key; 34 unsigned int down_key;
@@ -55,14 +66,14 @@ static irqreturn_t bfin_rotary_isr(int irq, void *dev_id)
55 struct bfin_rot *rotary = dev_id; 66 struct bfin_rot *rotary = dev_id;
56 int delta; 67 int delta;
57 68
58 switch (bfin_read_CNT_STATUS()) { 69 switch (readw(rotary->base + CNT_STATUS_OFF)) {
59 70
60 case ICII: 71 case ICII:
61 break; 72 break;
62 73
63 case UCII: 74 case UCII:
64 case DCII: 75 case DCII:
65 delta = bfin_read_CNT_COUNTER(); 76 delta = readl(rotary->base + CNT_COUNTER_OFF);
66 if (delta) 77 if (delta)
67 report_rotary_event(rotary, delta); 78 report_rotary_event(rotary, delta);
68 break; 79 break;
@@ -75,8 +86,8 @@ static irqreturn_t bfin_rotary_isr(int irq, void *dev_id)
75 break; 86 break;
76 } 87 }
77 88
78 bfin_write_CNT_COMMAND(W1LCNT_ZERO); /* Clear COUNTER */ 89 writew(W1LCNT_ZERO, rotary->base + CNT_COMMAND_OFF); /* Clear COUNTER */
79 bfin_write_CNT_STATUS(-1); /* Clear STATUS */ 90 writew(-1, rotary->base + CNT_STATUS_OFF); /* Clear STATUS */
80 91
81 return IRQ_HANDLED; 92 return IRQ_HANDLED;
82} 93}
@@ -85,7 +96,9 @@ static int bfin_rotary_probe(struct platform_device *pdev)
85{ 96{
86 const struct bfin_rotary_platform_data *pdata = 97 const struct bfin_rotary_platform_data *pdata =
87 dev_get_platdata(&pdev->dev); 98 dev_get_platdata(&pdev->dev);
99 struct device *dev = &pdev->dev;
88 struct bfin_rot *rotary; 100 struct bfin_rot *rotary;
101 struct resource *res;
89 struct input_dev *input; 102 struct input_dev *input;
90 int error; 103 int error;
91 104
@@ -111,6 +124,13 @@ static int bfin_rotary_probe(struct platform_device *pdev)
111 goto out1; 124 goto out1;
112 } 125 }
113 126
127 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
128 rotary->base = devm_ioremap_resource(dev, res);
129 if (IS_ERR(rotary->base)) {
130 error = PTR_ERR(rotary->base);
131 goto out1;
132 }
133
114 rotary->input = input; 134 rotary->input = input;
115 135
116 rotary->up_key = pdata->rotary_up_key; 136 rotary->up_key = pdata->rotary_up_key;
@@ -164,17 +184,21 @@ static int bfin_rotary_probe(struct platform_device *pdev)
164 } 184 }
165 185
166 if (pdata->rotary_button_key) 186 if (pdata->rotary_button_key)
167 bfin_write_CNT_IMASK(CZMIE); 187 writew(CZMIE, rotary->base + CNT_IMASK_OFF);
168 188
169 if (pdata->mode & ROT_DEBE) 189 if (pdata->mode & ROT_DEBE)
170 bfin_write_CNT_DEBOUNCE(pdata->debounce & DPRESCALE); 190 writew(pdata->debounce & DPRESCALE,
191 rotary->base + CNT_DEBOUNCE_OFF);
171 192
172 if (pdata->mode) 193 if (pdata->mode)
173 bfin_write_CNT_CONFIG(bfin_read_CNT_CONFIG() | 194 writew(readw(rotary->base + CNT_CONFIG_OFF) |
174 (pdata->mode & ~CNTE)); 195 (pdata->mode & ~CNTE),
196 rotary->base + CNT_CONFIG_OFF);
175 197
176 bfin_write_CNT_IMASK(bfin_read_CNT_IMASK() | UCIE | DCIE); 198 writew(readw(rotary->base + CNT_IMASK_OFF) | UCIE | DCIE,
177 bfin_write_CNT_CONFIG(bfin_read_CNT_CONFIG() | CNTE); 199 rotary->base + CNT_IMASK_OFF);
200 writew(readw(rotary->base + CNT_CONFIG_OFF) | CNTE,
201 rotary->base + CNT_CONFIG_OFF);
178 202
179 platform_set_drvdata(pdev, rotary); 203 platform_set_drvdata(pdev, rotary);
180 device_init_wakeup(&pdev->dev, 1); 204 device_init_wakeup(&pdev->dev, 1);
@@ -198,8 +222,8 @@ static int bfin_rotary_remove(struct platform_device *pdev)
198 dev_get_platdata(&pdev->dev); 222 dev_get_platdata(&pdev->dev);
199 struct bfin_rot *rotary = platform_get_drvdata(pdev); 223 struct bfin_rot *rotary = platform_get_drvdata(pdev);
200 224
201 bfin_write_CNT_CONFIG(0); 225 writew(0, rotary->base + CNT_CONFIG_OFF);
202 bfin_write_CNT_IMASK(0); 226 writew(0, rotary->base + CNT_IMASK_OFF);
203 227
204 free_irq(rotary->irq, rotary); 228 free_irq(rotary->irq, rotary);
205 input_unregister_device(rotary->input); 229 input_unregister_device(rotary->input);
@@ -217,9 +241,9 @@ static int __maybe_unused bfin_rotary_suspend(struct device *dev)
217 struct platform_device *pdev = to_platform_device(dev); 241 struct platform_device *pdev = to_platform_device(dev);
218 struct bfin_rot *rotary = platform_get_drvdata(pdev); 242 struct bfin_rot *rotary = platform_get_drvdata(pdev);
219 243
220 rotary->cnt_config = bfin_read_CNT_CONFIG(); 244 rotary->cnt_config = readw(rotary->base + CNT_CONFIG_OFF);
221 rotary->cnt_imask = bfin_read_CNT_IMASK(); 245 rotary->cnt_imask = readw(rotary->base + CNT_IMASK_OFF);
222 rotary->cnt_debounce = bfin_read_CNT_DEBOUNCE(); 246 rotary->cnt_debounce = readw(rotary->base + CNT_DEBOUNCE_OFF);
223 247
224 if (device_may_wakeup(&pdev->dev)) 248 if (device_may_wakeup(&pdev->dev))
225 enable_irq_wake(rotary->irq); 249 enable_irq_wake(rotary->irq);
@@ -232,15 +256,15 @@ static int __maybe_unused bfin_rotary_resume(struct device *dev)
232 struct platform_device *pdev = to_platform_device(dev); 256 struct platform_device *pdev = to_platform_device(dev);
233 struct bfin_rot *rotary = platform_get_drvdata(pdev); 257 struct bfin_rot *rotary = platform_get_drvdata(pdev);
234 258
235 bfin_write_CNT_DEBOUNCE(rotary->cnt_debounce); 259 writew(rotary->cnt_debounce, rotary->base + CNT_DEBOUNCE_OFF);
236 bfin_write_CNT_IMASK(rotary->cnt_imask); 260 writew(rotary->cnt_imask, rotary->base + CNT_IMASK_OFF);
237 bfin_write_CNT_CONFIG(rotary->cnt_config & ~CNTE); 261 writew(rotary->cnt_config & ~CNTE, rotary->base + CNT_CONFIG_OFF);
238 262
239 if (device_may_wakeup(&pdev->dev)) 263 if (device_may_wakeup(&pdev->dev))
240 disable_irq_wake(rotary->irq); 264 disable_irq_wake(rotary->irq);
241 265
242 if (rotary->cnt_config & CNTE) 266 if (rotary->cnt_config & CNTE)
243 bfin_write_CNT_CONFIG(rotary->cnt_config); 267 writew(rotary->cnt_config, rotary->base + CNT_CONFIG_OFF);
244 268
245 return 0; 269 return 0;
246} 270}