diff options
-rw-r--r-- | arch/sh/boards/mach-migor/setup.c | 2 | ||||
-rw-r--r-- | arch/sh/boards/mach-se/7722/setup.c | 3 | ||||
-rw-r--r-- | drivers/input/keyboard/sh_keysc.c | 28 |
3 files changed, 25 insertions, 8 deletions
diff --git a/arch/sh/boards/mach-migor/setup.c b/arch/sh/boards/mach-migor/setup.c index 975281980299..95dea1b02565 100644 --- a/arch/sh/boards/mach-migor/setup.c +++ b/arch/sh/boards/mach-migor/setup.c | |||
@@ -89,6 +89,7 @@ static struct resource sh_keysc_resources[] = { | |||
89 | 89 | ||
90 | static struct platform_device sh_keysc_device = { | 90 | static struct platform_device sh_keysc_device = { |
91 | .name = "sh_keysc", | 91 | .name = "sh_keysc", |
92 | .id = 0, /* "keysc0" clock */ | ||
92 | .num_resources = ARRAY_SIZE(sh_keysc_resources), | 93 | .num_resources = ARRAY_SIZE(sh_keysc_resources), |
93 | .resource = sh_keysc_resources, | 94 | .resource = sh_keysc_resources, |
94 | .dev = { | 95 | .dev = { |
@@ -479,7 +480,6 @@ static int __init migor_devices_setup(void) | |||
479 | ctrl_outl(0x00110080, BSC_CS4WCR); | 480 | ctrl_outl(0x00110080, BSC_CS4WCR); |
480 | 481 | ||
481 | /* KEYSC */ | 482 | /* KEYSC */ |
482 | clk_always_enable("mstp214"); /* KEYSC */ | ||
483 | gpio_request(GPIO_FN_KEYOUT0, NULL); | 483 | gpio_request(GPIO_FN_KEYOUT0, NULL); |
484 | gpio_request(GPIO_FN_KEYOUT1, NULL); | 484 | gpio_request(GPIO_FN_KEYOUT1, NULL); |
485 | gpio_request(GPIO_FN_KEYOUT2, NULL); | 485 | gpio_request(GPIO_FN_KEYOUT2, NULL); |
diff --git a/arch/sh/boards/mach-se/7722/setup.c b/arch/sh/boards/mach-se/7722/setup.c index fe6f96517e12..02035bbf2cc2 100644 --- a/arch/sh/boards/mach-se/7722/setup.c +++ b/arch/sh/boards/mach-se/7722/setup.c | |||
@@ -130,6 +130,7 @@ static struct resource sh_keysc_resources[] = { | |||
130 | 130 | ||
131 | static struct platform_device sh_keysc_device = { | 131 | static struct platform_device sh_keysc_device = { |
132 | .name = "sh_keysc", | 132 | .name = "sh_keysc", |
133 | .id = 0, /* "keysc0" clock */ | ||
133 | .num_resources = ARRAY_SIZE(sh_keysc_resources), | 134 | .num_resources = ARRAY_SIZE(sh_keysc_resources), |
134 | .resource = sh_keysc_resources, | 135 | .resource = sh_keysc_resources, |
135 | .dev = { | 136 | .dev = { |
@@ -146,8 +147,6 @@ static struct platform_device *se7722_devices[] __initdata = { | |||
146 | 147 | ||
147 | static int __init se7722_devices_setup(void) | 148 | static int __init se7722_devices_setup(void) |
148 | { | 149 | { |
149 | clk_always_enable("mstp214"); /* KEYSC */ | ||
150 | |||
151 | return platform_add_devices(se7722_devices, | 150 | return platform_add_devices(se7722_devices, |
152 | ARRAY_SIZE(se7722_devices)); | 151 | ARRAY_SIZE(se7722_devices)); |
153 | } | 152 | } |
diff --git a/drivers/input/keyboard/sh_keysc.c b/drivers/input/keyboard/sh_keysc.c index c600ab7f93e8..5c8a1bcf7ca7 100644 --- a/drivers/input/keyboard/sh_keysc.c +++ b/drivers/input/keyboard/sh_keysc.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
19 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
20 | #include <linux/input.h> | 20 | #include <linux/input.h> |
21 | #include <linux/clk.h> | ||
21 | #include <linux/io.h> | 22 | #include <linux/io.h> |
22 | #include <asm/sh_keysc.h> | 23 | #include <asm/sh_keysc.h> |
23 | 24 | ||
@@ -39,6 +40,7 @@ static const struct { | |||
39 | 40 | ||
40 | struct sh_keysc_priv { | 41 | struct sh_keysc_priv { |
41 | void __iomem *iomem_base; | 42 | void __iomem *iomem_base; |
43 | struct clk *clk; | ||
42 | unsigned long last_keys; | 44 | unsigned long last_keys; |
43 | struct input_dev *input; | 45 | struct input_dev *input; |
44 | struct sh_keysc_info pdata; | 46 | struct sh_keysc_info pdata; |
@@ -125,6 +127,7 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev) | |||
125 | struct sh_keysc_info *pdata; | 127 | struct sh_keysc_info *pdata; |
126 | struct resource *res; | 128 | struct resource *res; |
127 | struct input_dev *input; | 129 | struct input_dev *input; |
130 | char clk_name[8]; | ||
128 | int i, k; | 131 | int i, k; |
129 | int irq, error; | 132 | int irq, error; |
130 | 133 | ||
@@ -165,11 +168,19 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev) | |||
165 | goto err1; | 168 | goto err1; |
166 | } | 169 | } |
167 | 170 | ||
171 | snprintf(clk_name, sizeof(clk_name), "keysc%d", pdev->id); | ||
172 | priv->clk = clk_get(&pdev->dev, clk_name); | ||
173 | if (IS_ERR(priv->clk)) { | ||
174 | dev_err(&pdev->dev, "cannot get clock \"%s\"\n", clk_name); | ||
175 | error = PTR_ERR(priv->clk); | ||
176 | goto err2; | ||
177 | } | ||
178 | |||
168 | priv->input = input_allocate_device(); | 179 | priv->input = input_allocate_device(); |
169 | if (!priv->input) { | 180 | if (!priv->input) { |
170 | dev_err(&pdev->dev, "failed to allocate input device\n"); | 181 | dev_err(&pdev->dev, "failed to allocate input device\n"); |
171 | error = -ENOMEM; | 182 | error = -ENOMEM; |
172 | goto err2; | 183 | goto err3; |
173 | } | 184 | } |
174 | 185 | ||
175 | input = priv->input; | 186 | input = priv->input; |
@@ -187,7 +198,7 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev) | |||
187 | error = request_irq(irq, sh_keysc_isr, 0, pdev->name, pdev); | 198 | error = request_irq(irq, sh_keysc_isr, 0, pdev->name, pdev); |
188 | if (error) { | 199 | if (error) { |
189 | dev_err(&pdev->dev, "failed to request IRQ\n"); | 200 | dev_err(&pdev->dev, "failed to request IRQ\n"); |
190 | goto err3; | 201 | goto err4; |
191 | } | 202 | } |
192 | 203 | ||
193 | for (i = 0; i < SH_KEYSC_MAXKEYS; i++) { | 204 | for (i = 0; i < SH_KEYSC_MAXKEYS; i++) { |
@@ -199,18 +210,22 @@ static int __devinit sh_keysc_probe(struct platform_device *pdev) | |||
199 | error = input_register_device(input); | 210 | error = input_register_device(input); |
200 | if (error) { | 211 | if (error) { |
201 | dev_err(&pdev->dev, "failed to register input device\n"); | 212 | dev_err(&pdev->dev, "failed to register input device\n"); |
202 | goto err4; | 213 | goto err5; |
203 | } | 214 | } |
204 | 215 | ||
216 | clk_enable(priv->clk); | ||
217 | |||
205 | iowrite16((sh_keysc_mode[pdata->mode].kymd << 8) | | 218 | iowrite16((sh_keysc_mode[pdata->mode].kymd << 8) | |
206 | pdata->scan_timing, priv->iomem_base + KYCR1_OFFS); | 219 | pdata->scan_timing, priv->iomem_base + KYCR1_OFFS); |
207 | iowrite16(0, priv->iomem_base + KYOUTDR_OFFS); | 220 | iowrite16(0, priv->iomem_base + KYOUTDR_OFFS); |
208 | iowrite16(KYCR2_IRQ_LEVEL, priv->iomem_base + KYCR2_OFFS); | 221 | iowrite16(KYCR2_IRQ_LEVEL, priv->iomem_base + KYCR2_OFFS); |
209 | return 0; | 222 | return 0; |
210 | err4: | 223 | err5: |
211 | free_irq(irq, pdev); | 224 | free_irq(irq, pdev); |
212 | err3: | 225 | err4: |
213 | input_free_device(input); | 226 | input_free_device(input); |
227 | err3: | ||
228 | clk_put(priv->clk); | ||
214 | err2: | 229 | err2: |
215 | iounmap(priv->iomem_base); | 230 | iounmap(priv->iomem_base); |
216 | err1: | 231 | err1: |
@@ -230,6 +245,9 @@ static int __devexit sh_keysc_remove(struct platform_device *pdev) | |||
230 | free_irq(platform_get_irq(pdev, 0), pdev); | 245 | free_irq(platform_get_irq(pdev, 0), pdev); |
231 | iounmap(priv->iomem_base); | 246 | iounmap(priv->iomem_base); |
232 | 247 | ||
248 | clk_disable(priv->clk); | ||
249 | clk_put(priv->clk); | ||
250 | |||
233 | platform_set_drvdata(pdev, NULL); | 251 | platform_set_drvdata(pdev, NULL); |
234 | kfree(priv); | 252 | kfree(priv); |
235 | return 0; | 253 | return 0; |