aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-01-07 13:45:22 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-07 13:45:22 -0500
commit8995b161eb142b843094dd614b80e4cce1d66352 (patch)
treeffd9988879441d5ec45ab96b2e06f4fcb1210158 /drivers
parentcc918c7ab7da017bfaf9661420bb5c462e057cfb (diff)
parentfe5dd7c73d328b255286b6b65ca19dd34447f709 (diff)
Merge master.kernel.org:/home/rmk/linux-2.6-arm
Diffstat (limited to 'drivers')
-rw-r--r--drivers/Makefile1
-rw-r--r--drivers/amba/Makefile2
-rw-r--r--drivers/amba/bus.c359
-rw-r--r--drivers/char/s3c2410-rtc.c2
-rw-r--r--drivers/char/watchdog/s3c2410_wdt.c4
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c4
-rw-r--r--drivers/input/serio/ambakmi.c15
-rw-r--r--drivers/mmc/mmci.c13
-rw-r--r--drivers/mtd/nand/s3c2410.c4
-rw-r--r--drivers/pcmcia/pxa2xx_sharpsl.c24
-rw-r--r--drivers/serial/amba-pl010.c4
-rw-r--r--drivers/serial/amba-pl011.c13
-rw-r--r--drivers/serial/s3c2410.c7
-rw-r--r--drivers/usb/host/ohci-omap.c2
-rw-r--r--drivers/usb/host/ohci-s3c2410.c4
-rw-r--r--drivers/video/amba-clcd.c16
-rw-r--r--drivers/video/backlight/corgi_bl.c1
-rw-r--r--drivers/video/imxfb.c6
-rw-r--r--drivers/video/s3c2410fb.c5
19 files changed, 402 insertions, 84 deletions
diff --git a/drivers/Makefile b/drivers/Makefile
index ea410b6b764..7fc3f0f08b2 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -13,6 +13,7 @@ obj-$(CONFIG_ACPI) += acpi/
13# PnP must come after ACPI since it will eventually need to check if acpi 13# PnP must come after ACPI since it will eventually need to check if acpi
14# was used and do nothing if so 14# was used and do nothing if so
15obj-$(CONFIG_PNP) += pnp/ 15obj-$(CONFIG_PNP) += pnp/
16obj-$(CONFIG_ARM_AMBA) += amba/
16 17
17# char/ comes before serial/ etc so that the VT console is the boot-time 18# char/ comes before serial/ etc so that the VT console is the boot-time
18# default. 19# default.
diff --git a/drivers/amba/Makefile b/drivers/amba/Makefile
new file mode 100644
index 00000000000..40fe74097be
--- /dev/null
+++ b/drivers/amba/Makefile
@@ -0,0 +1,2 @@
1obj-y += bus.o
2
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
new file mode 100644
index 00000000000..1bbdd1693d5
--- /dev/null
+++ b/drivers/amba/bus.c
@@ -0,0 +1,359 @@
1/*
2 * linux/arch/arm/common/amba.c
3 *
4 * Copyright (C) 2003 Deep Blue Solutions Ltd, All Rights Reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/module.h>
11#include <linux/init.h>
12#include <linux/device.h>
13#include <linux/string.h>
14#include <linux/slab.h>
15#include <linux/amba/bus.h>
16
17#include <asm/io.h>
18#include <asm/irq.h>
19#include <asm/sizes.h>
20
21#define to_amba_device(d) container_of(d, struct amba_device, dev)
22#define to_amba_driver(d) container_of(d, struct amba_driver, drv)
23
24static struct amba_id *
25amba_lookup(struct amba_id *table, struct amba_device *dev)
26{
27 int ret = 0;
28
29 while (table->mask) {
30 ret = (dev->periphid & table->mask) == table->id;
31 if (ret)
32 break;
33 table++;
34 }
35
36 return ret ? table : NULL;
37}
38
39static int amba_match(struct device *dev, struct device_driver *drv)
40{
41 struct amba_device *pcdev = to_amba_device(dev);
42 struct amba_driver *pcdrv = to_amba_driver(drv);
43
44 return amba_lookup(pcdrv->id_table, pcdev) != NULL;
45}
46
47#ifdef CONFIG_HOTPLUG
48static int amba_uevent(struct device *dev, char **envp, int nr_env, char *buf, int bufsz)
49{
50 struct amba_device *pcdev = to_amba_device(dev);
51
52 if (nr_env < 2)
53 return -ENOMEM;
54
55 snprintf(buf, bufsz, "AMBA_ID=%08x", pcdev->periphid);
56 *envp++ = buf;
57 *envp++ = NULL;
58 return 0;
59}
60#else
61#define amba_uevent NULL
62#endif
63
64static int amba_suspend(struct device *dev, pm_message_t state)
65{
66 struct amba_driver *drv = to_amba_driver(dev->driver);
67 int ret = 0;
68
69 if (dev->driver && drv->suspend)
70 ret = drv->suspend(to_amba_device(dev), state);
71 return ret;
72}
73
74static int amba_resume(struct device *dev)
75{
76 struct amba_driver *drv = to_amba_driver(dev->driver);
77 int ret = 0;
78
79 if (dev->driver && drv->resume)
80 ret = drv->resume(to_amba_device(dev));
81 return ret;
82}
83
84/*
85 * Primecells are part of the Advanced Microcontroller Bus Architecture,
86 * so we call the bus "amba".
87 */
88static struct bus_type amba_bustype = {
89 .name = "amba",
90 .match = amba_match,
91 .uevent = amba_uevent,
92 .suspend = amba_suspend,
93 .resume = amba_resume,
94};
95
96static int __init amba_init(void)
97{
98 return bus_register(&amba_bustype);
99}
100
101postcore_initcall(amba_init);
102
103/*
104 * These are the device model conversion veneers; they convert the
105 * device model structures to our more specific structures.
106 */
107static int amba_probe(struct device *dev)
108{
109 struct amba_device *pcdev = to_amba_device(dev);
110 struct amba_driver *pcdrv = to_amba_driver(dev->driver);
111 struct amba_id *id;
112
113 id = amba_lookup(pcdrv->id_table, pcdev);
114
115 return pcdrv->probe(pcdev, id);
116}
117
118static int amba_remove(struct device *dev)
119{
120 struct amba_driver *drv = to_amba_driver(dev->driver);
121 return drv->remove(to_amba_device(dev));
122}
123
124static void amba_shutdown(struct device *dev)
125{
126 struct amba_driver *drv = to_amba_driver(dev->driver);
127 drv->shutdown(to_amba_device(dev));
128}
129
130/**
131 * amba_driver_register - register an AMBA device driver
132 * @drv: amba device driver structure
133 *
134 * Register an AMBA device driver with the Linux device model
135 * core. If devices pre-exist, the drivers probe function will
136 * be called.
137 */
138int amba_driver_register(struct amba_driver *drv)
139{
140 drv->drv.bus = &amba_bustype;
141
142#define SETFN(fn) if (drv->fn) drv->drv.fn = amba_##fn
143 SETFN(probe);
144 SETFN(remove);
145 SETFN(shutdown);
146
147 return driver_register(&drv->drv);
148}
149
150/**
151 * amba_driver_unregister - remove an AMBA device driver
152 * @drv: AMBA device driver structure to remove
153 *
154 * Unregister an AMBA device driver from the Linux device
155 * model. The device model will call the drivers remove function
156 * for each device the device driver is currently handling.
157 */
158void amba_driver_unregister(struct amba_driver *drv)
159{
160 driver_unregister(&drv->drv);
161}
162
163
164static void amba_device_release(struct device *dev)
165{
166 struct amba_device *d = to_amba_device(dev);
167
168 if (d->res.parent)
169 release_resource(&d->res);
170 kfree(d);
171}
172
173#define amba_attr(name,fmt,arg...) \
174static ssize_t show_##name(struct device *_dev, struct device_attribute *attr, char *buf) \
175{ \
176 struct amba_device *dev = to_amba_device(_dev); \
177 return sprintf(buf, fmt, arg); \
178} \
179static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
180
181amba_attr(id, "%08x\n", dev->periphid);
182amba_attr(irq0, "%u\n", dev->irq[0]);
183amba_attr(irq1, "%u\n", dev->irq[1]);
184amba_attr(resource, "\t%08lx\t%08lx\t%08lx\n",
185 dev->res.start, dev->res.end, dev->res.flags);
186
187/**
188 * amba_device_register - register an AMBA device
189 * @dev: AMBA device to register
190 * @parent: parent memory resource
191 *
192 * Setup the AMBA device, reading the cell ID if present.
193 * Claim the resource, and register the AMBA device with
194 * the Linux device manager.
195 */
196int amba_device_register(struct amba_device *dev, struct resource *parent)
197{
198 u32 pid, cid;
199 void __iomem *tmp;
200 int i, ret;
201
202 dev->dev.release = amba_device_release;
203 dev->dev.bus = &amba_bustype;
204 dev->dev.dma_mask = &dev->dma_mask;
205 dev->res.name = dev->dev.bus_id;
206
207 if (!dev->dev.coherent_dma_mask && dev->dma_mask)
208 dev_warn(&dev->dev, "coherent dma mask is unset\n");
209
210 ret = request_resource(parent, &dev->res);
211 if (ret == 0) {
212 tmp = ioremap(dev->res.start, SZ_4K);
213 if (!tmp) {
214 ret = -ENOMEM;
215 goto out;
216 }
217
218 for (pid = 0, i = 0; i < 4; i++)
219 pid |= (readl(tmp + 0xfe0 + 4 * i) & 255) << (i * 8);
220 for (cid = 0, i = 0; i < 4; i++)
221 cid |= (readl(tmp + 0xff0 + 4 * i) & 255) << (i * 8);
222
223 iounmap(tmp);
224
225 if (cid == 0xb105f00d)
226 dev->periphid = pid;
227
228 if (dev->periphid)
229 ret = device_register(&dev->dev);
230 else
231 ret = -ENODEV;
232
233 if (ret == 0) {
234 device_create_file(&dev->dev, &dev_attr_id);
235 if (dev->irq[0] != NO_IRQ)
236 device_create_file(&dev->dev, &dev_attr_irq0);
237 if (dev->irq[1] != NO_IRQ)
238 device_create_file(&dev->dev, &dev_attr_irq1);
239 device_create_file(&dev->dev, &dev_attr_resource);
240 } else {
241 out:
242 release_resource(&dev->res);
243 }
244 }
245 return ret;
246}
247
248/**
249 * amba_device_unregister - unregister an AMBA device
250 * @dev: AMBA device to remove
251 *
252 * Remove the specified AMBA device from the Linux device
253 * manager. All files associated with this object will be
254 * destroyed, and device drivers notified that the device has
255 * been removed. The AMBA device's resources including
256 * the amba_device structure will be freed once all
257 * references to it have been dropped.
258 */
259void amba_device_unregister(struct amba_device *dev)
260{
261 device_unregister(&dev->dev);
262}
263
264
265struct find_data {
266 struct amba_device *dev;
267 struct device *parent;
268 const char *busid;
269 unsigned int id;
270 unsigned int mask;
271};
272
273static int amba_find_match(struct device *dev, void *data)
274{
275 struct find_data *d = data;
276 struct amba_device *pcdev = to_amba_device(dev);
277 int r;
278
279 r = (pcdev->periphid & d->mask) == d->id;
280 if (d->parent)
281 r &= d->parent == dev->parent;
282 if (d->busid)
283 r &= strcmp(dev->bus_id, d->busid) == 0;
284
285 if (r) {
286 get_device(dev);
287 d->dev = pcdev;
288 }
289
290 return r;
291}
292
293/**
294 * amba_find_device - locate an AMBA device given a bus id
295 * @busid: bus id for device (or NULL)
296 * @parent: parent device (or NULL)
297 * @id: peripheral ID (or 0)
298 * @mask: peripheral ID mask (or 0)
299 *
300 * Return the AMBA device corresponding to the supplied parameters.
301 * If no device matches, returns NULL.
302 *
303 * NOTE: When a valid device is found, its refcount is
304 * incremented, and must be decremented before the returned
305 * reference.
306 */
307struct amba_device *
308amba_find_device(const char *busid, struct device *parent, unsigned int id,
309 unsigned int mask)
310{
311 struct find_data data;
312
313 data.dev = NULL;
314 data.parent = parent;
315 data.busid = busid;
316 data.id = id;
317 data.mask = mask;
318
319 bus_for_each_dev(&amba_bustype, NULL, &data, amba_find_match);
320
321 return data.dev;
322}
323
324/**
325 * amba_request_regions - request all mem regions associated with device
326 * @dev: amba_device structure for device
327 * @name: name, or NULL to use driver name
328 */
329int amba_request_regions(struct amba_device *dev, const char *name)
330{
331 int ret = 0;
332
333 if (!name)
334 name = dev->dev.driver->name;
335
336 if (!request_mem_region(dev->res.start, SZ_4K, name))
337 ret = -EBUSY;
338
339 return ret;
340}
341
342/**
343 * amba_release_regions - release mem regions assoicated with device
344 * @dev: amba_device structure for device
345 *
346 * Release regions claimed by a successful call to amba_request_regions.
347 */
348void amba_release_regions(struct amba_device *dev)
349{
350 release_mem_region(dev->res.start, SZ_4K);
351}
352
353EXPORT_SYMBOL(amba_driver_register);
354EXPORT_SYMBOL(amba_driver_unregister);
355EXPORT_SYMBOL(amba_device_register);
356EXPORT_SYMBOL(amba_device_unregister);
357EXPORT_SYMBOL(amba_find_device);
358EXPORT_SYMBOL(amba_request_regions);
359EXPORT_SYMBOL(amba_release_regions);
diff --git a/drivers/char/s3c2410-rtc.c b/drivers/char/s3c2410-rtc.c
index 3df7a574267..2e308657f6f 100644
--- a/drivers/char/s3c2410-rtc.c
+++ b/drivers/char/s3c2410-rtc.c
@@ -24,6 +24,7 @@
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/rtc.h> 25#include <linux/rtc.h>
26#include <linux/bcd.h> 26#include <linux/bcd.h>
27#include <linux/clk.h>
27 28
28#include <asm/hardware.h> 29#include <asm/hardware.h>
29#include <asm/uaccess.h> 30#include <asm/uaccess.h>
@@ -33,7 +34,6 @@
33 34
34#include <asm/mach/time.h> 35#include <asm/mach/time.h>
35 36
36#include <asm/hardware/clock.h>
37#include <asm/arch/regs-rtc.h> 37#include <asm/arch/regs-rtc.h>
38 38
39/* need this for the RTC_AF definitions */ 39/* need this for the RTC_AF definitions */
diff --git a/drivers/char/watchdog/s3c2410_wdt.c b/drivers/char/watchdog/s3c2410_wdt.c
index eb667daee19..9dc54736e4e 100644
--- a/drivers/char/watchdog/s3c2410_wdt.c
+++ b/drivers/char/watchdog/s3c2410_wdt.c
@@ -46,12 +46,12 @@
46#include <linux/init.h> 46#include <linux/init.h>
47#include <linux/platform_device.h> 47#include <linux/platform_device.h>
48#include <linux/interrupt.h> 48#include <linux/interrupt.h>
49#include <linux/clk.h>
49 50
50#include <asm/uaccess.h> 51#include <asm/uaccess.h>
51#include <asm/io.h> 52#include <asm/io.h>
52 53
53#include <asm/arch/map.h> 54#include <asm/arch/map.h>
54#include <asm/hardware/clock.h>
55 55
56#undef S3C24XX_VA_WATCHDOG 56#undef S3C24XX_VA_WATCHDOG
57#define S3C24XX_VA_WATCHDOG (0) 57#define S3C24XX_VA_WATCHDOG (0)
@@ -397,7 +397,6 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
397 return -ENOENT; 397 return -ENOENT;
398 } 398 }
399 399
400 clk_use(wdt_clock);
401 clk_enable(wdt_clock); 400 clk_enable(wdt_clock);
402 401
403 /* see if we can actually set the requested timer margin, and if 402 /* see if we can actually set the requested timer margin, and if
@@ -444,7 +443,6 @@ static int s3c2410wdt_remove(struct platform_device *dev)
444 443
445 if (wdt_clock != NULL) { 444 if (wdt_clock != NULL) {
446 clk_disable(wdt_clock); 445 clk_disable(wdt_clock);
447 clk_unuse(wdt_clock);
448 clk_put(wdt_clock); 446 clk_put(wdt_clock);
449 wdt_clock = NULL; 447 wdt_clock = NULL;
450 } 448 }
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 58cfd3111ef..f7d40f8e5f5 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -34,12 +34,12 @@
34#include <linux/errno.h> 34#include <linux/errno.h>
35#include <linux/err.h> 35#include <linux/err.h>
36#include <linux/platform_device.h> 36#include <linux/platform_device.h>
37#include <linux/clk.h>
37 38
38#include <asm/hardware.h> 39#include <asm/hardware.h>
39#include <asm/irq.h> 40#include <asm/irq.h>
40#include <asm/io.h> 41#include <asm/io.h>
41 42
42#include <asm/hardware/clock.h>
43#include <asm/arch/regs-gpio.h> 43#include <asm/arch/regs-gpio.h>
44#include <asm/arch/regs-iic.h> 44#include <asm/arch/regs-iic.h>
45#include <asm/arch/iic.h> 45#include <asm/arch/iic.h>
@@ -738,7 +738,6 @@ static void s3c24xx_i2c_free(struct s3c24xx_i2c *i2c)
738{ 738{
739 if (i2c->clk != NULL && !IS_ERR(i2c->clk)) { 739 if (i2c->clk != NULL && !IS_ERR(i2c->clk)) {
740 clk_disable(i2c->clk); 740 clk_disable(i2c->clk);
741 clk_unuse(i2c->clk);
742 clk_put(i2c->clk); 741 clk_put(i2c->clk);
743 i2c->clk = NULL; 742 i2c->clk = NULL;
744 } 743 }
@@ -778,7 +777,6 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
778 777
779 dev_dbg(&pdev->dev, "clock source %p\n", i2c->clk); 778 dev_dbg(&pdev->dev, "clock source %p\n", i2c->clk);
780 779
781 clk_use(i2c->clk);
782 clk_enable(i2c->clk); 780 clk_enable(i2c->clk);
783 781
784 /* map the registers */ 782 /* map the registers */
diff --git a/drivers/input/serio/ambakmi.c b/drivers/input/serio/ambakmi.c
index 9b1ab5e7a98..3df5eedf8f3 100644
--- a/drivers/input/serio/ambakmi.c
+++ b/drivers/input/serio/ambakmi.c
@@ -19,12 +19,12 @@
19#include <linux/delay.h> 19#include <linux/delay.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/err.h> 21#include <linux/err.h>
22#include <linux/amba/bus.h>
23#include <linux/amba/kmi.h>
24#include <linux/clk.h>
22 25
23#include <asm/io.h> 26#include <asm/io.h>
24#include <asm/irq.h> 27#include <asm/irq.h>
25#include <asm/hardware/amba.h>
26#include <asm/hardware/amba_kmi.h>
27#include <asm/hardware/clock.h>
28 28
29#define KMI_BASE (kmi->base) 29#define KMI_BASE (kmi->base)
30 30
@@ -72,13 +72,9 @@ static int amba_kmi_open(struct serio *io)
72 unsigned int divisor; 72 unsigned int divisor;
73 int ret; 73 int ret;
74 74
75 ret = clk_use(kmi->clk);
76 if (ret)
77 goto out;
78
79 ret = clk_enable(kmi->clk); 75 ret = clk_enable(kmi->clk);
80 if (ret) 76 if (ret)
81 goto clk_unuse; 77 goto out;
82 78
83 divisor = clk_get_rate(kmi->clk) / 8000000 - 1; 79 divisor = clk_get_rate(kmi->clk) / 8000000 - 1;
84 writeb(divisor, KMICLKDIV); 80 writeb(divisor, KMICLKDIV);
@@ -97,8 +93,6 @@ static int amba_kmi_open(struct serio *io)
97 93
98 clk_disable: 94 clk_disable:
99 clk_disable(kmi->clk); 95 clk_disable(kmi->clk);
100 clk_unuse:
101 clk_unuse(kmi->clk);
102 out: 96 out:
103 return ret; 97 return ret;
104} 98}
@@ -111,7 +105,6 @@ static void amba_kmi_close(struct serio *io)
111 105
112 free_irq(kmi->irq, kmi); 106 free_irq(kmi->irq, kmi);
113 clk_disable(kmi->clk); 107 clk_disable(kmi->clk);
114 clk_unuse(kmi->clk);
115} 108}
116 109
117static int amba_kmi_probe(struct amba_device *dev, void *id) 110static int amba_kmi_probe(struct amba_device *dev, void *id)
diff --git a/drivers/mmc/mmci.c b/drivers/mmc/mmci.c
index 2b10a2d4ae0..634ef53e85a 100644
--- a/drivers/mmc/mmci.c
+++ b/drivers/mmc/mmci.c
@@ -19,14 +19,14 @@
19#include <linux/highmem.h> 19#include <linux/highmem.h>
20#include <linux/mmc/host.h> 20#include <linux/mmc/host.h>
21#include <linux/mmc/protocol.h> 21#include <linux/mmc/protocol.h>
22#include <linux/amba/bus.h>
23#include <linux/clk.h>
22 24
23#include <asm/cacheflush.h> 25#include <asm/cacheflush.h>
24#include <asm/div64.h> 26#include <asm/div64.h>
25#include <asm/io.h> 27#include <asm/io.h>
26#include <asm/scatterlist.h> 28#include <asm/scatterlist.h>
27#include <asm/sizes.h> 29#include <asm/sizes.h>
28#include <asm/hardware/amba.h>
29#include <asm/hardware/clock.h>
30#include <asm/mach/mmc.h> 30#include <asm/mach/mmc.h>
31 31
32#include "mmci.h" 32#include "mmci.h"
@@ -494,13 +494,9 @@ static int mmci_probe(struct amba_device *dev, void *id)
494 goto host_free; 494 goto host_free;
495 } 495 }
496 496
497 ret = clk_use(host->clk);
498 if (ret)
499 goto clk_free;
500
501 ret = clk_enable(host->clk); 497 ret = clk_enable(host->clk);
502 if (ret) 498 if (ret)
503 goto clk_unuse; 499 goto clk_free;
504 500
505 host->plat = plat; 501 host->plat = plat;
506 host->mclk = clk_get_rate(host->clk); 502 host->mclk = clk_get_rate(host->clk);
@@ -573,8 +569,6 @@ static int mmci_probe(struct amba_device *dev, void *id)
573 iounmap(host->base); 569 iounmap(host->base);
574 clk_disable: 570 clk_disable:
575 clk_disable(host->clk); 571 clk_disable(host->clk);
576 clk_unuse:
577 clk_unuse(host->clk);
578 clk_free: 572 clk_free:
579 clk_put(host->clk); 573 clk_put(host->clk);
580 host_free: 574 host_free:
@@ -609,7 +603,6 @@ static int mmci_remove(struct amba_device *dev)
609 603
610 iounmap(host->base); 604 iounmap(host->base);
611 clk_disable(host->clk); 605 clk_disable(host->clk);
612 clk_unuse(host->clk);
613 clk_put(host->clk); 606 clk_put(host->clk);
614 607
615 mmc_free_host(mmc); 608 mmc_free_host(mmc);
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c
index d209214b131..5b55599739f 100644
--- a/drivers/mtd/nand/s3c2410.c
+++ b/drivers/mtd/nand/s3c2410.c
@@ -53,6 +53,7 @@
53#include <linux/delay.h> 53#include <linux/delay.h>
54#include <linux/err.h> 54#include <linux/err.h>
55#include <linux/slab.h> 55#include <linux/slab.h>
56#include <linux/clk.h>
56 57
57#include <linux/mtd/mtd.h> 58#include <linux/mtd/mtd.h>
58#include <linux/mtd/nand.h> 59#include <linux/mtd/nand.h>
@@ -60,7 +61,6 @@
60#include <linux/mtd/partitions.h> 61#include <linux/mtd/partitions.h>
61 62
62#include <asm/io.h> 63#include <asm/io.h>
63#include <asm/hardware/clock.h>
64 64
65#include <asm/arch/regs-nand.h> 65#include <asm/arch/regs-nand.h>
66#include <asm/arch/nand.h> 66#include <asm/arch/nand.h>
@@ -460,7 +460,6 @@ static int s3c2410_nand_remove(struct platform_device *pdev)
460 460
461 if (info->clk != NULL && !IS_ERR(info->clk)) { 461 if (info->clk != NULL && !IS_ERR(info->clk)) {
462 clk_disable(info->clk); 462 clk_disable(info->clk);
463 clk_unuse(info->clk);
464 clk_put(info->clk); 463 clk_put(info->clk);
465 } 464 }
466 465
@@ -598,7 +597,6 @@ static int s3c24xx_nand_probe(struct platform_device *pdev, int is_s3c2440)
598 goto exit_error; 597 goto exit_error;
599 } 598 }
600 599
601 clk_use(info->clk);
602 clk_enable(info->clk); 600 clk_enable(info->clk);
603 601
604 /* allocate and map the resource */ 602 /* allocate and map the resource */
diff --git a/drivers/pcmcia/pxa2xx_sharpsl.c b/drivers/pcmcia/pxa2xx_sharpsl.c
index b5fdeec20b1..12a7244a5ec 100644
--- a/drivers/pcmcia/pxa2xx_sharpsl.c
+++ b/drivers/pcmcia/pxa2xx_sharpsl.c
@@ -36,9 +36,18 @@
36struct scoop_pcmcia_config *platform_scoop_config; 36struct scoop_pcmcia_config *platform_scoop_config;
37#define SCOOP_DEV platform_scoop_config->devs 37#define SCOOP_DEV platform_scoop_config->devs
38 38
39static void sharpsl_pcmcia_init_reset(struct scoop_pcmcia_dev *scoopdev) 39static void sharpsl_pcmcia_init_reset(struct soc_pcmcia_socket *skt)
40{ 40{
41 struct scoop_pcmcia_dev *scoopdev = &SCOOP_DEV[skt->nr];
42
41 reset_scoop(scoopdev->dev); 43 reset_scoop(scoopdev->dev);
44
45 /* Shared power controls need to be handled carefully */
46 if (platform_scoop_config->power_ctrl)
47 platform_scoop_config->power_ctrl(scoopdev->dev, 0x0000, skt->nr);
48 else
49 write_scoop_reg(scoopdev->dev, SCOOP_CPR, 0x0000);
50
42 scoopdev->keep_vs = NO_KEEP_VS; 51 scoopdev->keep_vs = NO_KEEP_VS;
43 scoopdev->keep_rd = 0; 52 scoopdev->keep_rd = 0;
44} 53}
@@ -208,26 +217,17 @@ static int sharpsl_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
208 217
209static void sharpsl_pcmcia_socket_init(struct soc_pcmcia_socket *skt) 218static void sharpsl_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
210{ 219{
211 sharpsl_pcmcia_init_reset(&SCOOP_DEV[skt->nr]); 220 sharpsl_pcmcia_init_reset(skt);
212 221
213 /* Enable interrupt */ 222 /* Enable interrupt */
214 write_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_IMR, 0x00C0); 223 write_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_IMR, 0x00C0);
215 write_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_MCR, 0x0101); 224 write_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_MCR, 0x0101);
216 SCOOP_DEV[skt->nr].keep_vs = NO_KEEP_VS; 225 SCOOP_DEV[skt->nr].keep_vs = NO_KEEP_VS;
217
218 if (machine_is_collie())
219 /* We need to disable SS_OUTPUT_ENA here. */
220 write_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_CPR, read_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_CPR) & ~0x0080);
221} 226}
222 227
223static void sharpsl_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt) 228static void sharpsl_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
224{ 229{
225 /* CF_BUS_OFF */ 230 sharpsl_pcmcia_init_reset(skt);
226 sharpsl_pcmcia_init_reset(&SCOOP_DEV[skt->nr]);
227
228 if (machine_is_collie())
229 /* We need to disable SS_OUTPUT_ENA here. */
230 write_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_CPR, read_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_CPR) & ~0x0080);
231} 231}
232 232
233static struct pcmcia_low_level sharpsl_pcmcia_ops = { 233static struct pcmcia_low_level sharpsl_pcmcia_ops = {
diff --git a/drivers/serial/amba-pl010.c b/drivers/serial/amba-pl010.c
index ddd0307fece..48f6e872314 100644
--- a/drivers/serial/amba-pl010.c
+++ b/drivers/serial/amba-pl010.c
@@ -47,12 +47,12 @@
47#include <linux/tty_flip.h> 47#include <linux/tty_flip.h>
48#include <linux/serial_core.h> 48#include <linux/serial_core.h>
49#include <linux/serial.h> 49#include <linux/serial.h>
50#include <linux/amba/bus.h>
51#include <linux/amba/serial.h>
50 52
51#include <asm/io.h> 53#include <asm/io.h>
52#include <asm/irq.h> 54#include <asm/irq.h>
53#include <asm/hardware.h> 55#include <asm/hardware.h>
54#include <asm/hardware/amba.h>
55#include <asm/hardware/amba_serial.h>
56 56
57#define UART_NR 2 57#define UART_NR 2
58 58
diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c
index d84476ee659..12967055616 100644
--- a/drivers/serial/amba-pl011.c
+++ b/drivers/serial/amba-pl011.c
@@ -47,12 +47,12 @@
47#include <linux/tty_flip.h> 47#include <linux/tty_flip.h>
48#include <linux/serial_core.h> 48#include <linux/serial_core.h>
49#include <linux/serial.h> 49#include <linux/serial.h>
50#include <linux/amba/bus.h>
51#include <linux/amba/serial.h>
52#include <linux/clk.h>
50 53
51#include <asm/io.h> 54#include <asm/io.h>
52#include <asm/sizes.h> 55#include <asm/sizes.h>
53#include <asm/hardware/amba.h>
54#include <asm/hardware/clock.h>
55#include <asm/hardware/amba_serial.h>
56 56
57#define UART_NR 14 57#define UART_NR 14
58 58
@@ -761,10 +761,6 @@ static int pl011_probe(struct amba_device *dev, void *id)
761 goto unmap; 761 goto unmap;
762 } 762 }
763 763
764 ret = clk_use(uap->clk);
765 if (ret)
766 goto putclk;
767
768 uap->port.dev = &dev->dev; 764 uap->port.dev = &dev->dev;
769 uap->port.mapbase = dev->res.start; 765 uap->port.mapbase = dev->res.start;
770 uap->port.membase = base; 766 uap->port.membase = base;
@@ -782,8 +778,6 @@ static int pl011_probe(struct amba_device *dev, void *id)
782 if (ret) { 778 if (ret) {
783 amba_set_drvdata(dev, NULL); 779 amba_set_drvdata(dev, NULL);
784 amba_ports[i] = NULL; 780 amba_ports[i] = NULL;
785 clk_unuse(uap->clk);
786 putclk:
787 clk_put(uap->clk); 781 clk_put(uap->clk);
788 unmap: 782 unmap:
789 iounmap(base); 783 iounmap(base);
@@ -808,7 +802,6 @@ static int pl011_remove(struct amba_device *dev)
808 amba_ports[i] = NULL; 802 amba_ports[i] = NULL;
809 803
810 iounmap(uap->port.membase); 804 iounmap(uap->port.membase);
811 clk_unuse(uap->clk);
812 clk_put(uap->clk); 805 clk_put(uap->clk);
813 kfree(uap); 806 kfree(uap);
814 return 0; 807 return 0;
diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c
index 47681c4654e..fe83ce6fef5 100644
--- a/drivers/serial/s3c2410.c
+++ b/drivers/serial/s3c2410.c
@@ -72,12 +72,12 @@
72#include <linux/serial_core.h> 72#include <linux/serial_core.h>
73#include <linux/serial.h> 73#include <linux/serial.h>
74#include <linux/delay.h> 74#include <linux/delay.h>
75#include <linux/clk.h>
75 76
76#include <asm/io.h> 77#include <asm/io.h>
77#include <asm/irq.h> 78#include <asm/irq.h>
78 79
79#include <asm/hardware.h> 80#include <asm/hardware.h>
80#include <asm/hardware/clock.h>
81 81
82#include <asm/arch/regs-serial.h> 82#include <asm/arch/regs-serial.h>
83#include <asm/arch/regs-gpio.h> 83#include <asm/arch/regs-gpio.h>
@@ -782,11 +782,9 @@ static void s3c24xx_serial_set_termios(struct uart_port *port,
782 782
783 if (ourport->baudclk != NULL && !IS_ERR(ourport->baudclk)) { 783 if (ourport->baudclk != NULL && !IS_ERR(ourport->baudclk)) {
784 clk_disable(ourport->baudclk); 784 clk_disable(ourport->baudclk);
785 clk_unuse(ourport->baudclk);
786 ourport->baudclk = NULL; 785 ourport->baudclk = NULL;
787 } 786 }
788 787
789 clk_use(clk);
790 clk_enable(clk); 788 clk_enable(clk);
791 789
792 ourport->clksrc = clksrc; 790 ourport->clksrc = clksrc;
@@ -1077,9 +1075,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
1077 1075
1078 ourport->clk = clk_get(&platdev->dev, "uart"); 1076 ourport->clk = clk_get(&platdev->dev, "uart");
1079 1077
1080 if (ourport->clk != NULL && !IS_ERR(ourport->clk))
1081 clk_use(ourport->clk);
1082
1083 dbg("port: map=%08x, mem=%08x, irq=%d, clock=%ld\n", 1078 dbg("port: map=%08x, mem=%08x, irq=%d, clock=%ld\n",
1084 port->mapbase, port->membase, port->irq, port->uartclk); 1079 port->mapbase, port->membase, port->irq, port->uartclk);
1085 1080
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
index c9e29d80871..3785b3f7df1 100644
--- a/drivers/usb/host/ohci-omap.c
+++ b/drivers/usb/host/ohci-omap.c
@@ -17,6 +17,7 @@
17#include <linux/signal.h> /* SA_INTERRUPT */ 17#include <linux/signal.h> /* SA_INTERRUPT */
18#include <linux/jiffies.h> 18#include <linux/jiffies.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/clk.h>
20 21
21#include <asm/hardware.h> 22#include <asm/hardware.h>
22#include <asm/io.h> 23#include <asm/io.h>
@@ -27,7 +28,6 @@
27#include <asm/arch/gpio.h> 28#include <asm/arch/gpio.h>
28#include <asm/arch/fpga.h> 29#include <asm/arch/fpga.h>
29#include <asm/arch/usb.h> 30#include <asm/arch/usb.h>
30#include <asm/hardware/clock.h>
31 31
32 32
33/* OMAP-1510 OHCI has its own MMU for DMA */ 33/* OMAP-1510 OHCI has its own MMU for DMA */
diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c
index 35cc9402adc..372527a8359 100644
--- a/drivers/usb/host/ohci-s3c2410.c
+++ b/drivers/usb/host/ohci-s3c2410.c
@@ -20,9 +20,9 @@
20*/ 20*/
21 21
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/clk.h>
23 24
24#include <asm/hardware.h> 25#include <asm/hardware.h>
25#include <asm/hardware/clock.h>
26#include <asm/arch/usb-control.h> 26#include <asm/arch/usb-control.h>
27 27
28#define valid_port(idx) ((idx) == 1 || (idx) == 2) 28#define valid_port(idx) ((idx) == 1 || (idx) == 2)
@@ -363,7 +363,6 @@ int usb_hcd_s3c2410_probe (const struct hc_driver *driver,
363 goto err1; 363 goto err1;
364 } 364 }
365 365
366 clk_use(clk);
367 s3c2410_start_hc(dev, hcd); 366 s3c2410_start_hc(dev, hcd);
368 367
369 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); 368 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
@@ -384,7 +383,6 @@ int usb_hcd_s3c2410_probe (const struct hc_driver *driver,
384 err2: 383 err2:
385 s3c2410_stop_hc(dev); 384 s3c2410_stop_hc(dev);
386 iounmap(hcd->regs); 385 iounmap(hcd->regs);
387 clk_unuse(clk);
388 clk_put(clk); 386 clk_put(clk);
389 387
390 err1: 388 err1:
diff --git a/drivers/video/amba-clcd.c b/drivers/video/amba-clcd.c
index a3c2c45e29e..0da4083ba90 100644
--- a/drivers/video/amba-clcd.c
+++ b/drivers/video/amba-clcd.c
@@ -21,12 +21,11 @@
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/ioport.h> 22#include <linux/ioport.h>
23#include <linux/list.h> 23#include <linux/list.h>
24#include <linux/amba/bus.h>
25#include <linux/amba/clcd.h>
26#include <linux/clk.h>
24 27
25#include <asm/sizes.h> 28#include <asm/sizes.h>
26#include <asm/hardware/amba.h>
27#include <asm/hardware/clock.h>
28
29#include <asm/hardware/amba_clcd.h>
30 29
31#define to_clcd(info) container_of(info, struct clcd_fb, fb) 30#define to_clcd(info) container_of(info, struct clcd_fb, fb)
32 31
@@ -346,10 +345,6 @@ static int clcdfb_register(struct clcd_fb *fb)
346 goto out; 345 goto out;
347 } 346 }
348 347
349 ret = clk_use(fb->clk);
350 if (ret)
351 goto free_clk;
352
353 fb->fb.fix.mmio_start = fb->dev->res.start; 348 fb->fb.fix.mmio_start = fb->dev->res.start;
354 fb->fb.fix.mmio_len = SZ_4K; 349 fb->fb.fix.mmio_len = SZ_4K;
355 350
@@ -357,7 +352,7 @@ static int clcdfb_register(struct clcd_fb *fb)
357 if (!fb->regs) { 352 if (!fb->regs) {
358 printk(KERN_ERR "CLCD: unable to remap registers\n"); 353 printk(KERN_ERR "CLCD: unable to remap registers\n");
359 ret = -ENOMEM; 354 ret = -ENOMEM;
360 goto unuse_clk; 355 goto free_clk;
361 } 356 }
362 357
363 fb->fb.fbops = &clcdfb_ops; 358 fb->fb.fbops = &clcdfb_ops;
@@ -427,8 +422,6 @@ static int clcdfb_register(struct clcd_fb *fb)
427 printk(KERN_ERR "CLCD: cannot register framebuffer (%d)\n", ret); 422 printk(KERN_ERR "CLCD: cannot register framebuffer (%d)\n", ret);
428 423
429 iounmap(fb->regs); 424 iounmap(fb->regs);
430 unuse_clk:
431 clk_unuse(fb->clk);
432 free_clk: 425 free_clk:
433 clk_put(fb->clk); 426 clk_put(fb->clk);
434 out: 427 out:
@@ -489,7 +482,6 @@ static int clcdfb_remove(struct amba_device *dev)
489 clcdfb_disable(fb); 482 clcdfb_disable(fb);
490 unregister_framebuffer(&fb->fb); 483 unregister_framebuffer(&fb->fb);
491 iounmap(fb->regs); 484 iounmap(fb->regs);
492 clk_unuse(fb->clk);
493 clk_put(fb->clk); 485 clk_put(fb->clk);
494 486
495 fb->board->remove(fb); 487 fb->board->remove(fb);
diff --git a/drivers/video/backlight/corgi_bl.c b/drivers/video/backlight/corgi_bl.c
index 6a219b2c77e..d0aaf450e8c 100644
--- a/drivers/video/backlight/corgi_bl.c
+++ b/drivers/video/backlight/corgi_bl.c
@@ -20,6 +20,7 @@
20#include <linux/backlight.h> 20#include <linux/backlight.h>
21 21
22#include <asm/arch/sharpsl.h> 22#include <asm/arch/sharpsl.h>
23#include <asm/hardware/sharpsl_pm.h>
23 24
24#define CORGI_DEFAULT_INTENSITY 0x1f 25#define CORGI_DEFAULT_INTENSITY 0x1f
25#define CORGI_LIMIT_MASK 0x0b 26#define CORGI_LIMIT_MASK 0x0b
diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c
index 5924cc225c9..1718baaeed2 100644
--- a/drivers/video/imxfb.c
+++ b/drivers/video/imxfb.c
@@ -554,7 +554,7 @@ static int __init imxfb_probe(struct platform_device *pdev)
554 554
555 inf = pdev->dev.platform_data; 555 inf = pdev->dev.platform_data;
556 if(!inf) { 556 if(!inf) {
557 dev_err(dev,"No platform_data available\n"); 557 dev_err(&pdev->dev,"No platform_data available\n");
558 return -ENOMEM; 558 return -ENOMEM;
559 } 559 }
560 560
@@ -579,7 +579,7 @@ static int __init imxfb_probe(struct platform_device *pdev)
579 if (!inf->fixed_screen_cpu) { 579 if (!inf->fixed_screen_cpu) {
580 ret = imxfb_map_video_memory(info); 580 ret = imxfb_map_video_memory(info);
581 if (ret) { 581 if (ret) {
582 dev_err(dev, "Failed to allocate video RAM: %d\n", ret); 582 dev_err(&pdev->dev, "Failed to allocate video RAM: %d\n", ret);
583 ret = -ENOMEM; 583 ret = -ENOMEM;
584 goto failed_map; 584 goto failed_map;
585 } 585 }
@@ -608,7 +608,7 @@ static int __init imxfb_probe(struct platform_device *pdev)
608 imxfb_set_par(info); 608 imxfb_set_par(info);
609 ret = register_framebuffer(info); 609 ret = register_framebuffer(info);
610 if (ret < 0) { 610 if (ret < 0) {
611 dev_err(dev, "failed to register framebuffer\n"); 611 dev_err(&pdev->dev, "failed to register framebuffer\n");
612 goto failed_register; 612 goto failed_register;
613 } 613 }
614 614
diff --git a/drivers/video/s3c2410fb.c b/drivers/video/s3c2410fb.c
index ce6e749db3a..fe99d17a21d 100644
--- a/drivers/video/s3c2410fb.c
+++ b/drivers/video/s3c2410fb.c
@@ -87,6 +87,7 @@
87#include <linux/workqueue.h> 87#include <linux/workqueue.h>
88#include <linux/wait.h> 88#include <linux/wait.h>
89#include <linux/platform_device.h> 89#include <linux/platform_device.h>
90#include <linux/clk.h>
90 91
91#include <asm/io.h> 92#include <asm/io.h>
92#include <asm/uaccess.h> 93#include <asm/uaccess.h>
@@ -96,7 +97,6 @@
96#include <asm/arch/regs-lcd.h> 97#include <asm/arch/regs-lcd.h>
97#include <asm/arch/regs-gpio.h> 98#include <asm/arch/regs-gpio.h>
98#include <asm/arch/fb.h> 99#include <asm/arch/fb.h>
99#include <asm/hardware/clock.h>
100 100
101#ifdef CONFIG_PM 101#ifdef CONFIG_PM
102#include <linux/pm.h> 102#include <linux/pm.h>
@@ -746,7 +746,6 @@ int __init s3c2410fb_probe(struct platform_device *pdev)
746 goto release_irq; 746 goto release_irq;
747 } 747 }
748 748
749 clk_use(info->clk);
750 clk_enable(info->clk); 749 clk_enable(info->clk);
751 dprintk("got and enabled clock\n"); 750 dprintk("got and enabled clock\n");
752 751
@@ -783,7 +782,6 @@ free_video_memory:
783 s3c2410fb_unmap_video_memory(info); 782 s3c2410fb_unmap_video_memory(info);
784release_clock: 783release_clock:
785 clk_disable(info->clk); 784 clk_disable(info->clk);
786 clk_unuse(info->clk);
787 clk_put(info->clk); 785 clk_put(info->clk);
788release_irq: 786release_irq:
789 free_irq(irq,info); 787 free_irq(irq,info);
@@ -828,7 +826,6 @@ static int s3c2410fb_remove(struct platform_device *pdev)
828 826
829 if (info->clk) { 827 if (info->clk) {
830 clk_disable(info->clk); 828 clk_disable(info->clk);
831 clk_unuse(info->clk);
832 clk_put(info->clk); 829 clk_put(info->clk);
833 info->clk = NULL; 830 info->clk = NULL;
834 } 831 }