aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/Kconfig7
-rw-r--r--arch/arm/Makefile15
-rw-r--r--arch/arm/boot/Makefile2
-rw-r--r--arch/arm/common/Kconfig3
-rw-r--r--arch/arm/common/Makefile2
-rw-r--r--arch/arm/common/amba.c359
-rw-r--r--arch/arm/common/scoop.c2
-rw-r--r--arch/arm/common/sharpsl_pm.c839
-rw-r--r--arch/arm/configs/ixp4xx_defconfig84
-rw-r--r--arch/arm/kernel/Makefile5
-rw-r--r--arch/arm/kernel/apm.c19
-rw-r--r--arch/arm/kernel/dma-isa.c22
-rw-r--r--arch/arm/kernel/dma.c73
-rw-r--r--arch/arm/kernel/entry-armv.S2
-rw-r--r--arch/arm/kernel/head.S2
-rw-r--r--arch/arm/kernel/irq.c2
-rw-r--r--arch/arm/kernel/process.c3
-rw-r--r--arch/arm/kernel/setup.c2
-rw-r--r--arch/arm/kernel/time.c3
-rw-r--r--arch/arm/kernel/traps.c1
-rw-r--r--arch/arm/kernel/vmlinux.lds.S12
-rw-r--r--arch/arm/mach-aaec2000/clock.c13
-rw-r--r--arch/arm/mach-aaec2000/core.c2
-rw-r--r--arch/arm/mach-aaec2000/core.h2
-rw-r--r--arch/arm/mach-clps711x/dma.c27
-rw-r--r--arch/arm/mach-epxa10db/dma.c28
-rw-r--r--arch/arm/mach-footbridge/dma.c1
-rw-r--r--arch/arm/mach-imx/mx1ads.c55
-rw-r--r--arch/arm/mach-integrator/clock.c13
-rw-r--r--arch/arm/mach-integrator/core.c2
-rw-r--r--arch/arm/mach-integrator/dma.c35
-rw-r--r--arch/arm/mach-integrator/impd1.c4
-rw-r--r--arch/arm/mach-integrator/integrator_ap.c4
-rw-r--r--arch/arm/mach-integrator/integrator_cp.c6
-rw-r--r--arch/arm/mach-integrator/time.c2
-rw-r--r--arch/arm/mach-iop3xx/iop331-setup.c94
-rw-r--r--arch/arm/mach-ixp4xx/Kconfig8
-rw-r--r--arch/arm/mach-ixp4xx/Makefile1
-rw-r--r--arch/arm/mach-ixp4xx/common-pci.c23
-rw-r--r--arch/arm/mach-ixp4xx/common.c20
-rw-r--r--arch/arm/mach-ixp4xx/coyote-pci.c3
-rw-r--r--arch/arm/mach-ixp4xx/coyote-setup.c10
-rw-r--r--arch/arm/mach-ixp4xx/gtwx5715-setup.c15
-rw-r--r--arch/arm/mach-ixp4xx/ixdp425-pci.c5
-rw-r--r--arch/arm/mach-ixp4xx/ixdp425-setup.c13
-rw-r--r--arch/arm/mach-ixp4xx/ixdpg425-pci.c3
-rw-r--r--arch/arm/mach-ixp4xx/nas100d-pci.c71
-rw-r--r--arch/arm/mach-ixp4xx/nas100d-power.c67
-rw-r--r--arch/arm/mach-ixp4xx/nas100d-setup.c135
-rw-r--r--arch/arm/mach-ixp4xx/nslu2-pci.c8
-rw-r--r--arch/arm/mach-ixp4xx/nslu2-power.c3
-rw-r--r--arch/arm/mach-omap1/board-palmte.c2
-rw-r--r--arch/arm/mach-omap1/clock.c2
-rw-r--r--arch/arm/mach-omap1/serial.c2
-rw-r--r--arch/arm/mach-omap2/clock.c2
-rw-r--r--arch/arm/mach-omap2/serial.c2
-rw-r--r--arch/arm/mach-omap2/timer-gp.c3
-rw-r--r--arch/arm/mach-pxa/Kconfig2
-rw-r--r--arch/arm/mach-pxa/corgi_pm.c44
-rw-r--r--arch/arm/mach-pxa/mainstone.c6
-rw-r--r--arch/arm/mach-pxa/sharpsl.h101
-rw-r--r--arch/arm/mach-pxa/sharpsl_pm.c824
-rw-r--r--arch/arm/mach-pxa/spitz.c35
-rw-r--r--arch/arm/mach-pxa/spitz_pm.c46
-rw-r--r--arch/arm/mach-realview/clock.c13
-rw-r--r--arch/arm/mach-realview/core.c4
-rw-r--r--arch/arm/mach-realview/core.h3
-rw-r--r--arch/arm/mach-realview/realview_eb.c2
-rw-r--r--arch/arm/mach-rpc/dma.c19
-rw-r--r--arch/arm/mach-s3c2410/clock.c18
-rw-r--r--arch/arm/mach-s3c2410/clock.h1
-rw-r--r--arch/arm/mach-s3c2410/s3c2440-clock.c3
-rw-r--r--arch/arm/mach-s3c2410/s3c2440.c2
-rw-r--r--arch/arm/mach-s3c2410/time.c3
-rw-r--r--arch/arm/mach-sa1100/pm.c18
-rw-r--r--arch/arm/mach-versatile/clock.c13
-rw-r--r--arch/arm/mach-versatile/core.c4
-rw-r--r--arch/arm/mach-versatile/core.h2
-rw-r--r--arch/arm/mach-versatile/versatile_ab.c2
-rw-r--r--arch/arm/mach-versatile/versatile_pb.c2
-rw-r--r--arch/arm/mm/consistent.c1
-rw-r--r--arch/arm/mm/discontig.c4
-rw-r--r--arch/arm/mm/mm-armv.c1
-rw-r--r--arch/arm/plat-omap/clock.c2
-rw-r--r--arch/arm/plat-omap/common.c2
-rw-r--r--arch/arm/plat-omap/cpu-omap.c3
-rw-r--r--arch/arm/plat-omap/gpio.c2
-rw-r--r--arch/arm/plat-omap/mcbsp.c3
-rw-r--r--arch/arm/plat-omap/ocpi.c2
89 files changed, 1570 insertions, 1762 deletions
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 4b15f5f1e254..16a5d522b2f2 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -154,6 +154,7 @@ config ARCH_RPC
154 select FIQ 154 select FIQ
155 select TIMER_ACORN 155 select TIMER_ACORN
156 select ARCH_MAY_HAVE_PC_FDC 156 select ARCH_MAY_HAVE_PC_FDC
157 select ISA_DMA_API
157 help 158 help
158 On the Acorn Risc-PC, Linux can support the internal IDE disk and 159 On the Acorn Risc-PC, Linux can support the internal IDE disk and
159 CD-ROM interface, serial and parallel port, and the floppy drive. 160 CD-ROM interface, serial and parallel port, and the floppy drive.
@@ -206,6 +207,7 @@ config ARCH_IMX
206 207
207config ARCH_H720X 208config ARCH_H720X
208 bool "Hynix-HMS720x-based" 209 bool "Hynix-HMS720x-based"
210 select ISA_DMA_API
209 help 211 help
210 This enables support for systems based on the Hynix HMS720x 212 This enables support for systems based on the Hynix HMS720x
211 213
@@ -290,12 +292,14 @@ config ISA
290 (MCA) or VESA. ISA is an older system, now being displaced by PCI; 292 (MCA) or VESA. ISA is an older system, now being displaced by PCI;
291 newer boards don't support it. If you have ISA, say Y, otherwise N. 293 newer boards don't support it. If you have ISA, say Y, otherwise N.
292 294
295# Select ISA DMA controller support
293config ISA_DMA 296config ISA_DMA
294 bool 297 bool
298 select ISA_DMA_API
295 299
300# Select ISA DMA interface
296config ISA_DMA_API 301config ISA_DMA_API
297 bool 302 bool
298 default y
299 303
300config PCI 304config PCI
301 bool "PCI support" if ARCH_INTEGRATOR_AP || ARCH_VERSATILE_PB 305 bool "PCI support" if ARCH_INTEGRATOR_AP || ARCH_VERSATILE_PB
@@ -656,7 +660,6 @@ source "kernel/power/Kconfig"
656 660
657config APM 661config APM
658 tristate "Advanced Power Management Emulation" 662 tristate "Advanced Power Management Emulation"
659 depends on PM_LEGACY
660 ---help--- 663 ---help---
661 APM is a BIOS specification for saving power using several different 664 APM is a BIOS specification for saving power using several different
662 techniques. This is mostly useful for battery powered laptops with 665 techniques. This is mostly useful for battery powered laptops with
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 81bd2193fe6d..afaf3a1e903c 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -8,7 +8,7 @@
8# Copyright (C) 1995-2001 by Russell King 8# Copyright (C) 1995-2001 by Russell King
9 9
10LDFLAGS_vmlinux :=-p --no-undefined -X 10LDFLAGS_vmlinux :=-p --no-undefined -X
11CPPFLAGS_vmlinux.lds = -DKERNEL_RAM_ADDR=$(TEXTADDR) 11CPPFLAGS_vmlinux.lds = -DTEXT_OFFSET=$(TEXT_OFFSET)
12OBJCOPYFLAGS :=-O binary -R .note -R .comment -S 12OBJCOPYFLAGS :=-O binary -R .note -R .comment -S
13GZFLAGS :=-9 13GZFLAGS :=-9
14#CFLAGS +=-pipe 14#CFLAGS +=-pipe
@@ -65,7 +65,7 @@ CHECKFLAGS += -D__arm__
65 65
66#Default value 66#Default value
67head-y := arch/arm/kernel/head.o arch/arm/kernel/init_task.o 67head-y := arch/arm/kernel/head.o arch/arm/kernel/init_task.o
68textaddr-y := 0xC0008000 68textofs-y := 0x00008000
69 69
70 machine-$(CONFIG_ARCH_RPC) := rpc 70 machine-$(CONFIG_ARCH_RPC) := rpc
71 machine-$(CONFIG_ARCH_EBSA110) := ebsa110 71 machine-$(CONFIG_ARCH_EBSA110) := ebsa110
@@ -73,22 +73,20 @@ textaddr-y := 0xC0008000
73 incdir-$(CONFIG_ARCH_CLPS7500) := cl7500 73 incdir-$(CONFIG_ARCH_CLPS7500) := cl7500
74 machine-$(CONFIG_FOOTBRIDGE) := footbridge 74 machine-$(CONFIG_FOOTBRIDGE) := footbridge
75 incdir-$(CONFIG_FOOTBRIDGE) := ebsa285 75 incdir-$(CONFIG_FOOTBRIDGE) := ebsa285
76textaddr-$(CONFIG_ARCH_CO285) := 0x60008000
77 machine-$(CONFIG_ARCH_CO285) := footbridge 76 machine-$(CONFIG_ARCH_CO285) := footbridge
78 incdir-$(CONFIG_ARCH_CO285) := ebsa285 77 incdir-$(CONFIG_ARCH_CO285) := ebsa285
79 machine-$(CONFIG_ARCH_SHARK) := shark 78 machine-$(CONFIG_ARCH_SHARK) := shark
80 machine-$(CONFIG_ARCH_SA1100) := sa1100 79 machine-$(CONFIG_ARCH_SA1100) := sa1100
81ifeq ($(CONFIG_ARCH_SA1100),y) 80ifeq ($(CONFIG_ARCH_SA1100),y)
82# SA1111 DMA bug: we don't want the kernel to live in precious DMA-able memory 81# SA1111 DMA bug: we don't want the kernel to live in precious DMA-able memory
83textaddr-$(CONFIG_SA1111) := 0xc0208000 82 textofs-$(CONFIG_SA1111) := 0x00208000
84endif 83endif
85 machine-$(CONFIG_ARCH_PXA) := pxa 84 machine-$(CONFIG_ARCH_PXA) := pxa
86 machine-$(CONFIG_ARCH_L7200) := l7200 85 machine-$(CONFIG_ARCH_L7200) := l7200
87 machine-$(CONFIG_ARCH_INTEGRATOR) := integrator 86 machine-$(CONFIG_ARCH_INTEGRATOR) := integrator
88 machine-$(CONFIG_ARCH_CAMELOT) := epxa10db 87 machine-$(CONFIG_ARCH_CAMELOT) := epxa10db
89textaddr-$(CONFIG_ARCH_CLPS711X) := 0xc0028000 88 textofs-$(CONFIG_ARCH_CLPS711X) := 0x00028000
90 machine-$(CONFIG_ARCH_CLPS711X) := clps711x 89 machine-$(CONFIG_ARCH_CLPS711X) := clps711x
91textaddr-$(CONFIG_ARCH_FORTUNET) := 0xc0008000
92 machine-$(CONFIG_ARCH_IOP3XX) := iop3xx 90 machine-$(CONFIG_ARCH_IOP3XX) := iop3xx
93 machine-$(CONFIG_ARCH_IXP4XX) := ixp4xx 91 machine-$(CONFIG_ARCH_IXP4XX) := ixp4xx
94 machine-$(CONFIG_ARCH_IXP2000) := ixp2000 92 machine-$(CONFIG_ARCH_IXP2000) := ixp2000
@@ -110,7 +108,8 @@ CFLAGS_3c589_cs.o :=-DISA_SIXTEEN_BIT_PERIPHERAL
110export CFLAGS_3c589_cs.o 108export CFLAGS_3c589_cs.o
111endif 109endif
112 110
113TEXTADDR := $(textaddr-y) 111# The byte offset of the kernel image in RAM from the start of RAM.
112TEXT_OFFSET := $(textofs-y)
114 113
115ifeq ($(incdir-y),) 114ifeq ($(incdir-y),)
116incdir-y := $(machine-y) 115incdir-y := $(machine-y)
@@ -123,7 +122,7 @@ else
123MACHINE := 122MACHINE :=
124endif 123endif
125 124
126export TEXTADDR GZFLAGS 125export TEXT_OFFSET GZFLAGS
127 126
128# Do we have FASTFPE? 127# Do we have FASTFPE?
129FASTFPE :=arch/arm/fastfpe 128FASTFPE :=arch/arm/fastfpe
diff --git a/arch/arm/boot/Makefile b/arch/arm/boot/Makefile
index 937a353bc37c..a174d63395ea 100644
--- a/arch/arm/boot/Makefile
+++ b/arch/arm/boot/Makefile
@@ -15,7 +15,7 @@ include $(srctree)/$(MACHINE)/Makefile.boot
15endif 15endif
16 16
17# Note: the following conditions must always be true: 17# Note: the following conditions must always be true:
18# ZRELADDR == virt_to_phys(TEXTADDR) 18# ZRELADDR == virt_to_phys(PAGE_OFFSET + TEXT_OFFSET)
19# PARAMS_PHYS must be within 4MB of ZRELADDR 19# PARAMS_PHYS must be within 4MB of ZRELADDR
20# INITRD_PHYS must be in RAM 20# INITRD_PHYS must be in RAM
21ZRELADDR := $(zreladdr-y) 21ZRELADDR := $(zreladdr-y)
diff --git a/arch/arm/common/Kconfig b/arch/arm/common/Kconfig
index 666ba393575b..d7509c7a3c5e 100644
--- a/arch/arm/common/Kconfig
+++ b/arch/arm/common/Kconfig
@@ -23,5 +23,8 @@ config SHARP_LOCOMO
23config SHARP_PARAM 23config SHARP_PARAM
24 bool 24 bool
25 25
26config SHARPSL_PM
27 bool
28
26config SHARP_SCOOP 29config SHARP_SCOOP
27 bool 30 bool
diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile
index a87886564b19..ec8d17c96906 100644
--- a/arch/arm/common/Makefile
+++ b/arch/arm/common/Makefile
@@ -3,7 +3,6 @@
3# 3#
4 4
5obj-y += rtctime.o 5obj-y += rtctime.o
6obj-$(CONFIG_ARM_AMBA) += amba.o
7obj-$(CONFIG_ARM_GIC) += gic.o 6obj-$(CONFIG_ARM_GIC) += gic.o
8obj-$(CONFIG_ICST525) += icst525.o 7obj-$(CONFIG_ICST525) += icst525.o
9obj-$(CONFIG_ICST307) += icst307.o 8obj-$(CONFIG_ICST307) += icst307.o
@@ -13,4 +12,5 @@ obj-$(CONFIG_DMABOUNCE) += dmabounce.o
13obj-$(CONFIG_TIMER_ACORN) += time-acorn.o 12obj-$(CONFIG_TIMER_ACORN) += time-acorn.o
14obj-$(CONFIG_SHARP_LOCOMO) += locomo.o 13obj-$(CONFIG_SHARP_LOCOMO) += locomo.o
15obj-$(CONFIG_SHARP_PARAM) += sharpsl_param.o 14obj-$(CONFIG_SHARP_PARAM) += sharpsl_param.o
15obj-$(CONFIG_SHARPSL_PM) += sharpsl_pm.o
16obj-$(CONFIG_SHARP_SCOOP) += scoop.o 16obj-$(CONFIG_SHARP_SCOOP) += scoop.o
diff --git a/arch/arm/common/amba.c b/arch/arm/common/amba.c
deleted file mode 100644
index c95ec9eab996..000000000000
--- a/arch/arm/common/amba.c
+++ /dev/null
@@ -1,359 +0,0 @@
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
16#include <asm/io.h>
17#include <asm/irq.h>
18#include <asm/hardware/amba.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/arch/arm/common/scoop.c b/arch/arm/common/scoop.c
index 0c3cbd9a388b..b6de43e73699 100644
--- a/arch/arm/common/scoop.c
+++ b/arch/arm/common/scoop.c
@@ -33,7 +33,6 @@ void reset_scoop(struct device *dev)
33 33
34 SCOOP_REG(sdev->base,SCOOP_MCR) = 0x0100; // 00 34 SCOOP_REG(sdev->base,SCOOP_MCR) = 0x0100; // 00
35 SCOOP_REG(sdev->base,SCOOP_CDR) = 0x0000; // 04 35 SCOOP_REG(sdev->base,SCOOP_CDR) = 0x0000; // 04
36 SCOOP_REG(sdev->base,SCOOP_CPR) = 0x0000; // 0C
37 SCOOP_REG(sdev->base,SCOOP_CCR) = 0x0000; // 10 36 SCOOP_REG(sdev->base,SCOOP_CCR) = 0x0000; // 10
38 SCOOP_REG(sdev->base,SCOOP_IMR) = 0x0000; // 18 37 SCOOP_REG(sdev->base,SCOOP_IMR) = 0x0000; // 18
39 SCOOP_REG(sdev->base,SCOOP_IRM) = 0x00FF; // 14 38 SCOOP_REG(sdev->base,SCOOP_IRM) = 0x00FF; // 14
@@ -154,6 +153,7 @@ int __init scoop_probe(struct platform_device *pdev)
154 153
155 SCOOP_REG(devptr->base, SCOOP_MCR) = 0x0140; 154 SCOOP_REG(devptr->base, SCOOP_MCR) = 0x0140;
156 reset_scoop(&pdev->dev); 155 reset_scoop(&pdev->dev);
156 SCOOP_REG(devptr->base, SCOOP_CPR) = 0x0000;
157 SCOOP_REG(devptr->base, SCOOP_GPCR) = inf->io_dir & 0xffff; 157 SCOOP_REG(devptr->base, SCOOP_GPCR) = inf->io_dir & 0xffff;
158 SCOOP_REG(devptr->base, SCOOP_GPWR) = inf->io_out & 0xffff; 158 SCOOP_REG(devptr->base, SCOOP_GPWR) = inf->io_out & 0xffff;
159 159
diff --git a/arch/arm/common/sharpsl_pm.c b/arch/arm/common/sharpsl_pm.c
new file mode 100644
index 000000000000..978d32e82d39
--- /dev/null
+++ b/arch/arm/common/sharpsl_pm.c
@@ -0,0 +1,839 @@
1/*
2 * Battery and Power Management code for the Sharp SL-C7xx and SL-Cxx00
3 * series of PDAs
4 *
5 * Copyright (c) 2004-2005 Richard Purdie
6 *
7 * Based on code written by Sharp for 2.4 kernels
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 */
14
15#undef DEBUG
16
17#include <linux/module.h>
18#include <linux/timer.h>
19#include <linux/init.h>
20#include <linux/kernel.h>
21#include <linux/apm_bios.h>
22#include <linux/delay.h>
23#include <linux/interrupt.h>
24#include <linux/platform_device.h>
25
26#include <asm/hardware.h>
27#include <asm/mach-types.h>
28#include <asm/irq.h>
29#include <asm/apm.h>
30#include <asm/arch/pm.h>
31#include <asm/arch/pxa-regs.h>
32#include <asm/arch/sharpsl.h>
33#include <asm/hardware/sharpsl_pm.h>
34
35/*
36 * Constants
37 */
38#define SHARPSL_CHARGE_ON_TIME_INTERVAL (msecs_to_jiffies(1*60*1000)) /* 1 min */
39#define SHARPSL_CHARGE_FINISH_TIME (msecs_to_jiffies(10*60*1000)) /* 10 min */
40#define SHARPSL_BATCHK_TIME (msecs_to_jiffies(15*1000)) /* 15 sec */
41#define SHARPSL_BATCHK_TIME_SUSPEND (60*10) /* 10 min */
42#define SHARPSL_WAIT_CO_TIME 15 /* 15 sec */
43#define SHARPSL_WAIT_DISCHARGE_ON 100 /* 100 msec */
44#define SHARPSL_CHECK_BATTERY_WAIT_TIME_TEMP 10 /* 10 msec */
45#define SHARPSL_CHECK_BATTERY_WAIT_TIME_VOLT 10 /* 10 msec */
46#define SHARPSL_CHECK_BATTERY_WAIT_TIME_ACIN 10 /* 10 msec */
47#define SHARPSL_CHARGE_WAIT_TIME 15 /* 15 msec */
48#define SHARPSL_CHARGE_CO_CHECK_TIME 5 /* 5 msec */
49#define SHARPSL_CHARGE_RETRY_CNT 1 /* eqv. 10 min */
50
51#define SHARPSL_CHARGE_ON_VOLT 0x99 /* 2.9V */
52#define SHARPSL_CHARGE_ON_TEMP 0xe0 /* 2.9V */
53#define SHARPSL_CHARGE_ON_ACIN_HIGH 0x9b /* 6V */
54#define SHARPSL_CHARGE_ON_ACIN_LOW 0x34 /* 2V */
55#define SHARPSL_FATAL_ACIN_VOLT 182 /* 3.45V */
56#define SHARPSL_FATAL_NOACIN_VOLT 170 /* 3.40V */
57
58/*
59 * Prototypes
60 */
61static int sharpsl_off_charge_battery(void);
62static int sharpsl_check_battery_temp(void);
63static int sharpsl_check_battery_voltage(void);
64static int sharpsl_ac_check(void);
65static int sharpsl_fatal_check(void);
66static int sharpsl_average_value(int ad);
67static void sharpsl_average_clear(void);
68static void sharpsl_charge_toggle(void *private_);
69static void sharpsl_battery_thread(void *private_);
70
71
72/*
73 * Variables
74 */
75struct sharpsl_pm_status sharpsl_pm;
76DECLARE_WORK(toggle_charger, sharpsl_charge_toggle, NULL);
77DECLARE_WORK(sharpsl_bat, sharpsl_battery_thread, NULL);
78
79
80static int get_percentage(int voltage)
81{
82 int i = sharpsl_pm.machinfo->bat_levels - 1;
83 struct battery_thresh *thresh;
84
85 if (sharpsl_pm.charge_mode == CHRG_ON)
86 thresh=sharpsl_pm.machinfo->bat_levels_acin;
87 else
88 thresh=sharpsl_pm.machinfo->bat_levels_noac;
89
90 while (i > 0 && (voltage > thresh[i].voltage))
91 i--;
92
93 return thresh[i].percentage;
94}
95
96static int get_apm_status(int voltage)
97{
98 int low_thresh, high_thresh;
99
100 if (sharpsl_pm.charge_mode == CHRG_ON) {
101 high_thresh = sharpsl_pm.machinfo->status_high_acin;
102 low_thresh = sharpsl_pm.machinfo->status_low_acin;
103 } else {
104 high_thresh = sharpsl_pm.machinfo->status_high_noac;
105 low_thresh = sharpsl_pm.machinfo->status_low_noac;
106 }
107
108 if (voltage >= high_thresh)
109 return APM_BATTERY_STATUS_HIGH;
110 if (voltage >= low_thresh)
111 return APM_BATTERY_STATUS_LOW;
112 return APM_BATTERY_STATUS_CRITICAL;
113}
114
115void sharpsl_battery_kick(void)
116{
117 schedule_delayed_work(&sharpsl_bat, msecs_to_jiffies(125));
118}
119EXPORT_SYMBOL(sharpsl_battery_kick);
120
121
122static void sharpsl_battery_thread(void *private_)
123{
124 int voltage, percent, apm_status, i = 0;
125
126 if (!sharpsl_pm.machinfo)
127 return;
128
129 sharpsl_pm.battstat.ac_status = (sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN) ? APM_AC_ONLINE : APM_AC_OFFLINE);
130
131 /* Corgi cannot confirm when battery fully charged so periodically kick! */
132 if (machine_is_corgi() && (sharpsl_pm.charge_mode == CHRG_ON)
133 && time_after(jiffies, sharpsl_pm.charge_start_time + SHARPSL_CHARGE_ON_TIME_INTERVAL))
134 schedule_work(&toggle_charger);
135
136 while(1) {
137 voltage = sharpsl_pm.machinfo->read_devdata(SHARPSL_BATT_VOLT);
138
139 if (voltage > 0) break;
140 if (i++ > 5) {
141 voltage = sharpsl_pm.machinfo->bat_levels_noac[0].voltage;
142 dev_warn(sharpsl_pm.dev, "Warning: Cannot read main battery!\n");
143 break;
144 }
145 }
146
147 voltage = sharpsl_average_value(voltage);
148 apm_status = get_apm_status(voltage);
149 percent = get_percentage(voltage);
150
151 /* At low battery voltages, the voltage has a tendency to start
152 creeping back up so we try to avoid this here */
153 if ((sharpsl_pm.battstat.ac_status == APM_AC_ONLINE) || (apm_status == APM_BATTERY_STATUS_HIGH) || percent <= sharpsl_pm.battstat.mainbat_percent) {
154 sharpsl_pm.battstat.mainbat_voltage = voltage;
155 sharpsl_pm.battstat.mainbat_status = apm_status;
156 sharpsl_pm.battstat.mainbat_percent = percent;
157 }
158
159 dev_dbg(sharpsl_pm.dev, "Battery: voltage: %d, status: %d, percentage: %d, time: %d\n", voltage,
160 sharpsl_pm.battstat.mainbat_status, sharpsl_pm.battstat.mainbat_percent, jiffies);
161
162 /* If battery is low. limit backlight intensity to save power. */
163 if ((sharpsl_pm.battstat.ac_status != APM_AC_ONLINE)
164 && ((sharpsl_pm.battstat.mainbat_status == APM_BATTERY_STATUS_LOW) ||
165 (sharpsl_pm.battstat.mainbat_status == APM_BATTERY_STATUS_CRITICAL))) {
166 if (!(sharpsl_pm.flags & SHARPSL_BL_LIMIT)) {
167 corgibl_limit_intensity(1);
168 sharpsl_pm.flags |= SHARPSL_BL_LIMIT;
169 }
170 } else if (sharpsl_pm.flags & SHARPSL_BL_LIMIT) {
171 corgibl_limit_intensity(0);
172 sharpsl_pm.flags &= ~SHARPSL_BL_LIMIT;
173 }
174
175 /* Suspend if critical battery level */
176 if ((sharpsl_pm.battstat.ac_status != APM_AC_ONLINE)
177 && (sharpsl_pm.battstat.mainbat_status == APM_BATTERY_STATUS_CRITICAL)
178 && !(sharpsl_pm.flags & SHARPSL_APM_QUEUED)) {
179 sharpsl_pm.flags |= SHARPSL_APM_QUEUED;
180 dev_err(sharpsl_pm.dev, "Fatal Off\n");
181 apm_queue_event(APM_CRITICAL_SUSPEND);
182 }
183
184 schedule_delayed_work(&sharpsl_bat, SHARPSL_BATCHK_TIME);
185}
186
187void sharpsl_pm_led(int val)
188{
189 if (val == SHARPSL_LED_ERROR) {
190 dev_err(sharpsl_pm.dev, "Charging Error!\n");
191 } else if (val == SHARPSL_LED_ON) {
192 dev_dbg(sharpsl_pm.dev, "Charge LED On\n");
193
194 } else {
195 dev_dbg(sharpsl_pm.dev, "Charge LED Off\n");
196
197 }
198}
199
200static void sharpsl_charge_on(void)
201{
202 dev_dbg(sharpsl_pm.dev, "Turning Charger On\n");
203
204 sharpsl_pm.full_count = 0;
205 sharpsl_pm.charge_mode = CHRG_ON;
206 schedule_delayed_work(&toggle_charger, msecs_to_jiffies(250));
207 schedule_delayed_work(&sharpsl_bat, msecs_to_jiffies(500));
208}
209
210static void sharpsl_charge_off(void)
211{
212 dev_dbg(sharpsl_pm.dev, "Turning Charger Off\n");
213
214 sharpsl_pm.machinfo->charge(0);
215 sharpsl_pm_led(SHARPSL_LED_OFF);
216 sharpsl_pm.charge_mode = CHRG_OFF;
217
218 schedule_work(&sharpsl_bat);
219}
220
221static void sharpsl_charge_error(void)
222{
223 sharpsl_pm_led(SHARPSL_LED_ERROR);
224 sharpsl_pm.machinfo->charge(0);
225 sharpsl_pm.charge_mode = CHRG_ERROR;
226}
227
228static void sharpsl_charge_toggle(void *private_)
229{
230 dev_dbg(sharpsl_pm.dev, "Toogling Charger at time: %lx\n", jiffies);
231
232 if (!sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN)) {
233 sharpsl_charge_off();
234 return;
235 } else if ((sharpsl_check_battery_temp() < 0) || (sharpsl_ac_check() < 0)) {
236 sharpsl_charge_error();
237 return;
238 }
239
240 sharpsl_pm_led(SHARPSL_LED_ON);
241 sharpsl_pm.machinfo->charge(0);
242 mdelay(SHARPSL_CHARGE_WAIT_TIME);
243 sharpsl_pm.machinfo->charge(1);
244
245 sharpsl_pm.charge_start_time = jiffies;
246}
247
248static void sharpsl_ac_timer(unsigned long data)
249{
250 int acin = sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN);
251
252 dev_dbg(sharpsl_pm.dev, "AC Status: %d\n",acin);
253
254 sharpsl_average_clear();
255 if (acin && (sharpsl_pm.charge_mode != CHRG_ON))
256 sharpsl_charge_on();
257 else if (sharpsl_pm.charge_mode == CHRG_ON)
258 sharpsl_charge_off();
259
260 schedule_work(&sharpsl_bat);
261}
262
263
264irqreturn_t sharpsl_ac_isr(int irq, void *dev_id, struct pt_regs *fp)
265{
266 /* Delay the event slightly to debounce */
267 /* Must be a smaller delay than the chrg_full_isr below */
268 mod_timer(&sharpsl_pm.ac_timer, jiffies + msecs_to_jiffies(250));
269
270 return IRQ_HANDLED;
271}
272
273static void sharpsl_chrg_full_timer(unsigned long data)
274{
275 dev_dbg(sharpsl_pm.dev, "Charge Full at time: %lx\n", jiffies);
276
277 sharpsl_pm.full_count++;
278
279 if (!sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN)) {
280 dev_dbg(sharpsl_pm.dev, "Charge Full: AC removed - stop charging!\n");
281 if (sharpsl_pm.charge_mode == CHRG_ON)
282 sharpsl_charge_off();
283 } else if (sharpsl_pm.full_count < 2) {
284 dev_dbg(sharpsl_pm.dev, "Charge Full: Count too low\n");
285 schedule_work(&toggle_charger);
286 } else if (time_after(jiffies, sharpsl_pm.charge_start_time + SHARPSL_CHARGE_FINISH_TIME)) {
287 dev_dbg(sharpsl_pm.dev, "Charge Full: Interrupt generated too slowly - retry.\n");
288 schedule_work(&toggle_charger);
289 } else {
290 sharpsl_charge_off();
291 sharpsl_pm.charge_mode = CHRG_DONE;
292 dev_dbg(sharpsl_pm.dev, "Charge Full: Charging Finished\n");
293 }
294}
295
296/* Charging Finished Interrupt (Not present on Corgi) */
297/* Can trigger at the same time as an AC staus change so
298 delay until after that has been processed */
299irqreturn_t sharpsl_chrg_full_isr(int irq, void *dev_id, struct pt_regs *fp)
300{
301 if (sharpsl_pm.flags & SHARPSL_SUSPENDED)
302 return IRQ_HANDLED;
303
304 /* delay until after any ac interrupt */
305 mod_timer(&sharpsl_pm.chrg_full_timer, jiffies + msecs_to_jiffies(500));
306
307 return IRQ_HANDLED;
308}
309
310irqreturn_t sharpsl_fatal_isr(int irq, void *dev_id, struct pt_regs *fp)
311{
312 int is_fatal = 0;
313
314 if (!sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_LOCK)) {
315 dev_err(sharpsl_pm.dev, "Battery now Unlocked! Suspending.\n");
316 is_fatal = 1;
317 }
318
319 if (!sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_FATAL)) {
320 dev_err(sharpsl_pm.dev, "Fatal Batt Error! Suspending.\n");
321 is_fatal = 1;
322 }
323
324 if (!(sharpsl_pm.flags & SHARPSL_APM_QUEUED) && is_fatal) {
325 sharpsl_pm.flags |= SHARPSL_APM_QUEUED;
326 apm_queue_event(APM_CRITICAL_SUSPEND);
327 }
328
329 return IRQ_HANDLED;
330}
331
332/*
333 * Maintain an average of the last 10 readings
334 */
335#define SHARPSL_CNV_VALUE_NUM 10
336static int sharpsl_ad_index;
337
338static void sharpsl_average_clear(void)
339{
340 sharpsl_ad_index = 0;
341}
342
343static int sharpsl_average_value(int ad)
344{
345 int i, ad_val = 0;
346 static int sharpsl_ad[SHARPSL_CNV_VALUE_NUM+1];
347
348 if (sharpsl_pm.battstat.mainbat_status != APM_BATTERY_STATUS_HIGH) {
349 sharpsl_ad_index = 0;
350 return ad;
351 }
352
353 sharpsl_ad[sharpsl_ad_index] = ad;
354 sharpsl_ad_index++;
355 if (sharpsl_ad_index >= SHARPSL_CNV_VALUE_NUM) {
356 for (i=0; i < (SHARPSL_CNV_VALUE_NUM-1); i++)
357 sharpsl_ad[i] = sharpsl_ad[i+1];
358 sharpsl_ad_index = SHARPSL_CNV_VALUE_NUM - 1;
359 }
360 for (i=0; i < sharpsl_ad_index; i++)
361 ad_val += sharpsl_ad[i];
362
363 return (ad_val / sharpsl_ad_index);
364}
365
366/*
367 * Take an array of 5 integers, remove the maximum and minimum values
368 * and return the average.
369 */
370static int get_select_val(int *val)
371{
372 int i, j, k, temp, sum = 0;
373
374 /* Find MAX val */
375 temp = val[0];
376 j=0;
377 for (i=1; i<5; i++) {
378 if (temp < val[i]) {
379 temp = val[i];
380 j = i;
381 }
382 }
383
384 /* Find MIN val */
385 temp = val[4];
386 k=4;
387 for (i=3; i>=0; i--) {
388 if (temp > val[i]) {
389 temp = val[i];
390 k = i;
391 }
392 }
393
394 for (i=0; i<5; i++)
395 if (i != j && i != k )
396 sum += val[i];
397
398 dev_dbg(sharpsl_pm.dev, "Average: %d from values: %d, %d, %d, %d, %d\n", sum/3, val[0], val[1], val[2], val[3], val[4]);
399
400 return (sum/3);
401}
402
403static int sharpsl_check_battery_temp(void)
404{
405 int val, i, buff[5];
406
407 /* Check battery temperature */
408 for (i=0; i<5; i++) {
409 mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_TEMP);
410 sharpsl_pm.machinfo->measure_temp(1);
411 mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_TEMP);
412 buff[i] = sharpsl_pm.machinfo->read_devdata(SHARPSL_BATT_TEMP);
413 sharpsl_pm.machinfo->measure_temp(0);
414 }
415
416 val = get_select_val(buff);
417
418 dev_dbg(sharpsl_pm.dev, "Temperature: %d\n", val);
419 if (val > SHARPSL_CHARGE_ON_TEMP)
420 return -1;
421
422 return 0;
423}
424
425static int sharpsl_check_battery_voltage(void)
426{
427 int val, i, buff[5];
428
429 /* disable charge, enable discharge */
430 sharpsl_pm.machinfo->charge(0);
431 sharpsl_pm.machinfo->discharge(1);
432 mdelay(SHARPSL_WAIT_DISCHARGE_ON);
433
434 if (sharpsl_pm.machinfo->discharge1)
435 sharpsl_pm.machinfo->discharge1(1);
436
437 /* Check battery voltage */
438 for (i=0; i<5; i++) {
439 buff[i] = sharpsl_pm.machinfo->read_devdata(SHARPSL_BATT_VOLT);
440 mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_VOLT);
441 }
442
443 if (sharpsl_pm.machinfo->discharge1)
444 sharpsl_pm.machinfo->discharge1(0);
445
446 sharpsl_pm.machinfo->discharge(0);
447
448 val = get_select_val(buff);
449 dev_dbg(sharpsl_pm.dev, "Battery Voltage: %d\n", val);
450
451 if (val < SHARPSL_CHARGE_ON_VOLT)
452 return -1;
453
454 return 0;
455}
456
457static int sharpsl_ac_check(void)
458{
459 int temp, i, buff[5];
460
461 for (i=0; i<5; i++) {
462 buff[i] = sharpsl_pm.machinfo->read_devdata(SHARPSL_ACIN_VOLT);
463 mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_ACIN);
464 }
465
466 temp = get_select_val(buff);
467 dev_dbg(sharpsl_pm.dev, "AC Voltage: %d\n",temp);
468
469 if ((temp > SHARPSL_CHARGE_ON_ACIN_HIGH) || (temp < SHARPSL_CHARGE_ON_ACIN_LOW)) {
470 dev_err(sharpsl_pm.dev, "Error: AC check failed.\n");
471 return -1;
472 }
473
474 return 0;
475}
476
477#ifdef CONFIG_PM
478static int sharpsl_pm_suspend(struct platform_device *pdev, pm_message_t state)
479{
480 sharpsl_pm.flags |= SHARPSL_SUSPENDED;
481 flush_scheduled_work();
482
483 if (sharpsl_pm.charge_mode == CHRG_ON)
484 sharpsl_pm.flags |= SHARPSL_DO_OFFLINE_CHRG;
485 else
486 sharpsl_pm.flags &= ~SHARPSL_DO_OFFLINE_CHRG;
487
488 return 0;
489}
490
491static int sharpsl_pm_resume(struct platform_device *pdev)
492{
493 /* Clear the reset source indicators as they break the bootloader upon reboot */
494 RCSR = 0x0f;
495 sharpsl_average_clear();
496 sharpsl_pm.flags &= ~SHARPSL_APM_QUEUED;
497 sharpsl_pm.flags &= ~SHARPSL_SUSPENDED;
498
499 return 0;
500}
501
502static void corgi_goto_sleep(unsigned long alarm_time, unsigned int alarm_enable, suspend_state_t state)
503{
504 dev_dbg(sharpsl_pm.dev, "Time is: %08x\n",RCNR);
505
506 dev_dbg(sharpsl_pm.dev, "Offline Charge Activate = %d\n",sharpsl_pm.flags & SHARPSL_DO_OFFLINE_CHRG);
507 /* not charging and AC-IN! */
508
509 if ((sharpsl_pm.flags & SHARPSL_DO_OFFLINE_CHRG) && (sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN))) {
510 dev_dbg(sharpsl_pm.dev, "Activating Offline Charger...\n");
511 sharpsl_pm.charge_mode = CHRG_OFF;
512 sharpsl_pm.flags &= ~SHARPSL_DO_OFFLINE_CHRG;
513 sharpsl_off_charge_battery();
514 }
515
516 sharpsl_pm.machinfo->presuspend();
517
518 PEDR = 0xffffffff; /* clear it */
519
520 sharpsl_pm.flags &= ~SHARPSL_ALARM_ACTIVE;
521 if ((sharpsl_pm.charge_mode == CHRG_ON) && ((alarm_enable && ((alarm_time - RCNR) > (SHARPSL_BATCHK_TIME_SUSPEND + 30))) || !alarm_enable)) {
522 RTSR &= RTSR_ALE;
523 RTAR = RCNR + SHARPSL_BATCHK_TIME_SUSPEND;
524 dev_dbg(sharpsl_pm.dev, "Charging alarm at: %08x\n",RTAR);
525 sharpsl_pm.flags |= SHARPSL_ALARM_ACTIVE;
526 } else if (alarm_enable) {
527 RTSR &= RTSR_ALE;
528 RTAR = alarm_time;
529 dev_dbg(sharpsl_pm.dev, "User alarm at: %08x\n",RTAR);
530 } else {
531 dev_dbg(sharpsl_pm.dev, "No alarms set.\n");
532 }
533
534 pxa_pm_enter(state);
535
536 sharpsl_pm.machinfo->postsuspend();
537
538 dev_dbg(sharpsl_pm.dev, "Corgi woken up from suspend: %08x\n",PEDR);
539}
540
541static int corgi_enter_suspend(unsigned long alarm_time, unsigned int alarm_enable, suspend_state_t state)
542{
543 if (!sharpsl_pm.machinfo->should_wakeup(!(sharpsl_pm.flags & SHARPSL_ALARM_ACTIVE) && alarm_enable) )
544 {
545 if (!(sharpsl_pm.flags & SHARPSL_ALARM_ACTIVE)) {
546 dev_dbg(sharpsl_pm.dev, "No user triggered wakeup events and not charging. Strange. Suspend.\n");
547 corgi_goto_sleep(alarm_time, alarm_enable, state);
548 return 1;
549 }
550 if(sharpsl_off_charge_battery()) {
551 dev_dbg(sharpsl_pm.dev, "Charging. Suspend...\n");
552 corgi_goto_sleep(alarm_time, alarm_enable, state);
553 return 1;
554 }
555 dev_dbg(sharpsl_pm.dev, "User triggered wakeup in offline charger.\n");
556 }
557
558 if ((!sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_LOCK)) || (sharpsl_fatal_check() < 0) )
559 {
560 dev_err(sharpsl_pm.dev, "Fatal condition. Suspend.\n");
561 corgi_goto_sleep(alarm_time, alarm_enable, state);
562 return 1;
563 }
564
565 return 0;
566}
567
568static int corgi_pxa_pm_enter(suspend_state_t state)
569{
570 unsigned long alarm_time = RTAR;
571 unsigned int alarm_status = ((RTSR & RTSR_ALE) != 0);
572
573 dev_dbg(sharpsl_pm.dev, "SharpSL suspending for first time.\n");
574
575 corgi_goto_sleep(alarm_time, alarm_status, state);
576
577 while (corgi_enter_suspend(alarm_time,alarm_status,state))
578 {}
579
580 dev_dbg(sharpsl_pm.dev, "SharpSL resuming...\n");
581
582 return 0;
583}
584#endif
585
586
587/*
588 * Check for fatal battery errors
589 * Fatal returns -1
590 */
591static int sharpsl_fatal_check(void)
592{
593 int buff[5], temp, i, acin;
594
595 dev_dbg(sharpsl_pm.dev, "sharpsl_fatal_check entered\n");
596
597 /* Check AC-Adapter */
598 acin = sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN);
599
600 if (acin && (sharpsl_pm.charge_mode == CHRG_ON)) {
601 sharpsl_pm.machinfo->charge(0);
602 udelay(100);
603 sharpsl_pm.machinfo->discharge(1); /* enable discharge */
604 mdelay(SHARPSL_WAIT_DISCHARGE_ON);
605 }
606
607 if (sharpsl_pm.machinfo->discharge1)
608 sharpsl_pm.machinfo->discharge1(1);
609
610 /* Check battery : check inserting battery ? */
611 for (i=0; i<5; i++) {
612 buff[i] = sharpsl_pm.machinfo->read_devdata(SHARPSL_BATT_VOLT);
613 mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_VOLT);
614 }
615
616 if (sharpsl_pm.machinfo->discharge1)
617 sharpsl_pm.machinfo->discharge1(0);
618
619 if (acin && (sharpsl_pm.charge_mode == CHRG_ON)) {
620 udelay(100);
621 sharpsl_pm.machinfo->charge(1);
622 sharpsl_pm.machinfo->discharge(0);
623 }
624
625 temp = get_select_val(buff);
626 dev_dbg(sharpsl_pm.dev, "sharpsl_fatal_check: acin: %d, discharge voltage: %d, no discharge: %d\n", acin, temp, sharpsl_pm.machinfo->read_devdata(SHARPSL_BATT_VOLT));
627
628 if ((acin && (temp < SHARPSL_FATAL_ACIN_VOLT)) ||
629 (!acin && (temp < SHARPSL_FATAL_NOACIN_VOLT)))
630 return -1;
631 return 0;
632}
633
634static int sharpsl_off_charge_error(void)
635{
636 dev_err(sharpsl_pm.dev, "Offline Charger: Error occured.\n");
637 sharpsl_pm.machinfo->charge(0);
638 sharpsl_pm_led(SHARPSL_LED_ERROR);
639 sharpsl_pm.charge_mode = CHRG_ERROR;
640 return 1;
641}
642
643/*
644 * Charging Control while suspended
645 * Return 1 - go straight to sleep
646 * Return 0 - sleep or wakeup depending on other factors
647 */
648static int sharpsl_off_charge_battery(void)
649{
650 int time;
651
652 dev_dbg(sharpsl_pm.dev, "Charge Mode: %d\n", sharpsl_pm.charge_mode);
653
654 if (sharpsl_pm.charge_mode == CHRG_OFF) {
655 dev_dbg(sharpsl_pm.dev, "Offline Charger: Step 1\n");
656
657 /* AC Check */
658 if ((sharpsl_ac_check() < 0) || (sharpsl_check_battery_temp() < 0))
659 return sharpsl_off_charge_error();
660
661 /* Start Charging */
662 sharpsl_pm_led(SHARPSL_LED_ON);
663 sharpsl_pm.machinfo->charge(0);
664 mdelay(SHARPSL_CHARGE_WAIT_TIME);
665 sharpsl_pm.machinfo->charge(1);
666
667 sharpsl_pm.charge_mode = CHRG_ON;
668 sharpsl_pm.full_count = 0;
669
670 return 1;
671 } else if (sharpsl_pm.charge_mode != CHRG_ON) {
672 return 1;
673 }
674
675 if (sharpsl_pm.full_count == 0) {
676 int time;
677
678 dev_dbg(sharpsl_pm.dev, "Offline Charger: Step 2\n");
679
680 if ((sharpsl_check_battery_temp() < 0) || (sharpsl_check_battery_voltage() < 0))
681 return sharpsl_off_charge_error();
682
683 sharpsl_pm.machinfo->charge(0);
684 mdelay(SHARPSL_CHARGE_WAIT_TIME);
685 sharpsl_pm.machinfo->charge(1);
686 sharpsl_pm.charge_mode = CHRG_ON;
687
688 mdelay(SHARPSL_CHARGE_CO_CHECK_TIME);
689
690 time = RCNR;
691 while(1) {
692 /* Check if any wakeup event had occured */
693 if (sharpsl_pm.machinfo->charger_wakeup() != 0)
694 return 0;
695 /* Check for timeout */
696 if ((RCNR - time) > SHARPSL_WAIT_CO_TIME)
697 return 1;
698 if (sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_CHRGFULL)) {
699 dev_dbg(sharpsl_pm.dev, "Offline Charger: Charge full occured. Retrying to check\n");
700 sharpsl_pm.full_count++;
701 sharpsl_pm.machinfo->charge(0);
702 mdelay(SHARPSL_CHARGE_WAIT_TIME);
703 sharpsl_pm.machinfo->charge(1);
704 return 1;
705 }
706 }
707 }
708
709 dev_dbg(sharpsl_pm.dev, "Offline Charger: Step 3\n");
710
711 mdelay(SHARPSL_CHARGE_CO_CHECK_TIME);
712
713 time = RCNR;
714 while(1) {
715 /* Check if any wakeup event had occured */
716 if (sharpsl_pm.machinfo->charger_wakeup() != 0)
717 return 0;
718 /* Check for timeout */
719 if ((RCNR-time) > SHARPSL_WAIT_CO_TIME) {
720 if (sharpsl_pm.full_count > SHARPSL_CHARGE_RETRY_CNT) {
721 dev_dbg(sharpsl_pm.dev, "Offline Charger: Not charged sufficiently. Retrying.\n");
722 sharpsl_pm.full_count = 0;
723 }
724 sharpsl_pm.full_count++;
725 return 1;
726 }
727 if (sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_CHRGFULL)) {
728 dev_dbg(sharpsl_pm.dev, "Offline Charger: Charging complete.\n");
729 sharpsl_pm_led(SHARPSL_LED_OFF);
730 sharpsl_pm.machinfo->charge(0);
731 sharpsl_pm.charge_mode = CHRG_DONE;
732 return 1;
733 }
734 }
735}
736
737
738static ssize_t battery_percentage_show(struct device *dev, struct device_attribute *attr, char *buf)
739{
740 return sprintf(buf, "%d\n",sharpsl_pm.battstat.mainbat_percent);
741}
742
743static ssize_t battery_voltage_show(struct device *dev, struct device_attribute *attr, char *buf)
744{
745 return sprintf(buf, "%d\n",sharpsl_pm.battstat.mainbat_voltage);
746}
747
748static DEVICE_ATTR(battery_percentage, 0444, battery_percentage_show, NULL);
749static DEVICE_ATTR(battery_voltage, 0444, battery_voltage_show, NULL);
750
751extern void (*apm_get_power_status)(struct apm_power_info *);
752
753static void sharpsl_apm_get_power_status(struct apm_power_info *info)
754{
755 info->ac_line_status = sharpsl_pm.battstat.ac_status;
756
757 if (sharpsl_pm.charge_mode == CHRG_ON)
758 info->battery_status = APM_BATTERY_STATUS_CHARGING;
759 else
760 info->battery_status = sharpsl_pm.battstat.mainbat_status;
761
762 info->battery_flag = (1 << info->battery_status);
763 info->battery_life = sharpsl_pm.battstat.mainbat_percent;
764}
765
766static struct pm_ops sharpsl_pm_ops = {
767 .pm_disk_mode = PM_DISK_FIRMWARE,
768 .prepare = pxa_pm_prepare,
769 .enter = corgi_pxa_pm_enter,
770 .finish = pxa_pm_finish,
771};
772
773static int __init sharpsl_pm_probe(struct platform_device *pdev)
774{
775 if (!pdev->dev.platform_data)
776 return -EINVAL;
777
778 sharpsl_pm.dev = &pdev->dev;
779 sharpsl_pm.machinfo = pdev->dev.platform_data;
780 sharpsl_pm.charge_mode = CHRG_OFF;
781 sharpsl_pm.flags = 0;
782
783 init_timer(&sharpsl_pm.ac_timer);
784 sharpsl_pm.ac_timer.function = sharpsl_ac_timer;
785
786 init_timer(&sharpsl_pm.chrg_full_timer);
787 sharpsl_pm.chrg_full_timer.function = sharpsl_chrg_full_timer;
788
789 sharpsl_pm.machinfo->init();
790
791 device_create_file(&pdev->dev, &dev_attr_battery_percentage);
792 device_create_file(&pdev->dev, &dev_attr_battery_voltage);
793
794 apm_get_power_status = sharpsl_apm_get_power_status;
795
796 pm_set_ops(&sharpsl_pm_ops);
797
798 mod_timer(&sharpsl_pm.ac_timer, jiffies + msecs_to_jiffies(250));
799
800 return 0;
801}
802
803static int sharpsl_pm_remove(struct platform_device *pdev)
804{
805 pm_set_ops(NULL);
806
807 device_remove_file(&pdev->dev, &dev_attr_battery_percentage);
808 device_remove_file(&pdev->dev, &dev_attr_battery_voltage);
809
810 sharpsl_pm.machinfo->exit();
811
812 del_timer_sync(&sharpsl_pm.chrg_full_timer);
813 del_timer_sync(&sharpsl_pm.ac_timer);
814
815 return 0;
816}
817
818static struct platform_driver sharpsl_pm_driver = {
819 .probe = sharpsl_pm_probe,
820 .remove = sharpsl_pm_remove,
821 .suspend = sharpsl_pm_suspend,
822 .resume = sharpsl_pm_resume,
823 .driver = {
824 .name = "sharpsl-pm",
825 },
826};
827
828static int __devinit sharpsl_pm_init(void)
829{
830 return platform_driver_register(&sharpsl_pm_driver);
831}
832
833static void sharpsl_pm_exit(void)
834{
835 platform_driver_unregister(&sharpsl_pm_driver);
836}
837
838late_initcall(sharpsl_pm_init);
839module_exit(sharpsl_pm_exit);
diff --git a/arch/arm/configs/ixp4xx_defconfig b/arch/arm/configs/ixp4xx_defconfig
index f74c926beb42..613afab62720 100644
--- a/arch/arm/configs/ixp4xx_defconfig
+++ b/arch/arm/configs/ixp4xx_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.14-rc1-git5 3# Linux kernel version: 2.6.15
4# Tue Sep 20 17:26:28 2005 4# Tue Jan 3 03:20:40 2006
5# 5#
6CONFIG_ARM=y 6CONFIG_ARM=y
7CONFIG_MMU=y 7CONFIG_MMU=y
@@ -33,6 +33,7 @@ CONFIG_SYSCTL=y
33CONFIG_KOBJECT_UEVENT=y 33CONFIG_KOBJECT_UEVENT=y
34# CONFIG_IKCONFIG is not set 34# CONFIG_IKCONFIG is not set
35CONFIG_INITRAMFS_SOURCE="" 35CONFIG_INITRAMFS_SOURCE=""
36CONFIG_CC_OPTIMIZE_FOR_SIZE=y
36CONFIG_EMBEDDED=y 37CONFIG_EMBEDDED=y
37CONFIG_KALLSYMS=y 38CONFIG_KALLSYMS=y
38# CONFIG_KALLSYMS_ALL is not set 39# CONFIG_KALLSYMS_ALL is not set
@@ -42,7 +43,6 @@ CONFIG_BUG=y
42CONFIG_BASE_FULL=y 43CONFIG_BASE_FULL=y
43CONFIG_FUTEX=y 44CONFIG_FUTEX=y
44CONFIG_EPOLL=y 45CONFIG_EPOLL=y
45CONFIG_CC_OPTIMIZE_FOR_SIZE=y
46CONFIG_SHMEM=y 46CONFIG_SHMEM=y
47CONFIG_CC_ALIGN_FUNCTIONS=0 47CONFIG_CC_ALIGN_FUNCTIONS=0
48CONFIG_CC_ALIGN_LABELS=0 48CONFIG_CC_ALIGN_LABELS=0
@@ -62,6 +62,23 @@ CONFIG_MODVERSIONS=y
62CONFIG_KMOD=y 62CONFIG_KMOD=y
63 63
64# 64#
65# Block layer
66#
67
68#
69# IO Schedulers
70#
71CONFIG_IOSCHED_NOOP=y
72CONFIG_IOSCHED_AS=y
73CONFIG_IOSCHED_DEADLINE=y
74CONFIG_IOSCHED_CFQ=y
75CONFIG_DEFAULT_AS=y
76# CONFIG_DEFAULT_DEADLINE is not set
77# CONFIG_DEFAULT_CFQ is not set
78# CONFIG_DEFAULT_NOOP is not set
79CONFIG_DEFAULT_IOSCHED="anticipatory"
80
81#
65# System Type 82# System Type
66# 83#
67# CONFIG_ARCH_CLPS7500 is not set 84# CONFIG_ARCH_CLPS7500 is not set
@@ -83,6 +100,7 @@ CONFIG_ARCH_IXP4XX=y
83# CONFIG_ARCH_LH7A40X is not set 100# CONFIG_ARCH_LH7A40X is not set
84# CONFIG_ARCH_OMAP is not set 101# CONFIG_ARCH_OMAP is not set
85# CONFIG_ARCH_VERSATILE is not set 102# CONFIG_ARCH_VERSATILE is not set
103# CONFIG_ARCH_REALVIEW is not set
86# CONFIG_ARCH_IMX is not set 104# CONFIG_ARCH_IMX is not set
87# CONFIG_ARCH_H720X is not set 105# CONFIG_ARCH_H720X is not set
88# CONFIG_ARCH_AAEC2000 is not set 106# CONFIG_ARCH_AAEC2000 is not set
@@ -102,6 +120,7 @@ CONFIG_MACH_IXDPG425=y
102CONFIG_MACH_IXDP465=y 120CONFIG_MACH_IXDP465=y
103CONFIG_ARCH_IXCDP1100=y 121CONFIG_ARCH_IXCDP1100=y
104CONFIG_ARCH_PRPMC1100=y 122CONFIG_ARCH_PRPMC1100=y
123CONFIG_MACH_NAS100D=y
105CONFIG_ARCH_IXDP4XX=y 124CONFIG_ARCH_IXDP4XX=y
106CONFIG_CPU_IXP46X=y 125CONFIG_CPU_IXP46X=y
107# CONFIG_MACH_GTWX5715 is not set 126# CONFIG_MACH_GTWX5715 is not set
@@ -155,6 +174,7 @@ CONFIG_FLATMEM_MANUAL=y
155CONFIG_FLATMEM=y 174CONFIG_FLATMEM=y
156CONFIG_FLAT_NODE_MEM_MAP=y 175CONFIG_FLAT_NODE_MEM_MAP=y
157# CONFIG_SPARSEMEM_STATIC is not set 176# CONFIG_SPARSEMEM_STATIC is not set
177CONFIG_SPLIT_PTLOCK_CPUS=4096
158CONFIG_ALIGNMENT_TRAP=y 178CONFIG_ALIGNMENT_TRAP=y
159 179
160# 180#
@@ -173,6 +193,7 @@ CONFIG_CMDLINE="console=ttyS0,115200 ip=bootp root=/dev/nfs"
173# At least one emulation must be selected 193# At least one emulation must be selected
174# 194#
175CONFIG_FPE_NWFPE=y 195CONFIG_FPE_NWFPE=y
196# CONFIG_FPE_NWFPE_XP is not set
176# CONFIG_FPE_FASTFPE is not set 197# CONFIG_FPE_FASTFPE is not set
177 198
178# 199#
@@ -187,6 +208,8 @@ CONFIG_BINFMT_ELF=y
187# Power management options 208# Power management options
188# 209#
189CONFIG_PM=y 210CONFIG_PM=y
211CONFIG_PM_LEGACY=y
212# CONFIG_PM_DEBUG is not set
190CONFIG_APM=y 213CONFIG_APM=y
191 214
192# 215#
@@ -271,6 +294,10 @@ CONFIG_IP_VS_SH=m
271CONFIG_NETFILTER=y 294CONFIG_NETFILTER=y
272# CONFIG_NETFILTER_DEBUG is not set 295# CONFIG_NETFILTER_DEBUG is not set
273CONFIG_BRIDGE_NETFILTER=y 296CONFIG_BRIDGE_NETFILTER=y
297
298#
299# Core Netfilter Configuration
300#
274# CONFIG_NETFILTER_NETLINK is not set 301# CONFIG_NETFILTER_NETLINK is not set
275 302
276# 303#
@@ -286,6 +313,7 @@ CONFIG_IP_NF_IRC=m
286# CONFIG_IP_NF_NETBIOS_NS is not set 313# CONFIG_IP_NF_NETBIOS_NS is not set
287# CONFIG_IP_NF_TFTP is not set 314# CONFIG_IP_NF_TFTP is not set
288# CONFIG_IP_NF_AMANDA is not set 315# CONFIG_IP_NF_AMANDA is not set
316# CONFIG_IP_NF_PPTP is not set
289CONFIG_IP_NF_QUEUE=m 317CONFIG_IP_NF_QUEUE=m
290CONFIG_IP_NF_IPTABLES=m 318CONFIG_IP_NF_IPTABLES=m
291CONFIG_IP_NF_MATCH_LIMIT=m 319CONFIG_IP_NF_MATCH_LIMIT=m
@@ -319,6 +347,7 @@ CONFIG_IP_NF_TARGET_REJECT=m
319CONFIG_IP_NF_TARGET_LOG=m 347CONFIG_IP_NF_TARGET_LOG=m
320CONFIG_IP_NF_TARGET_ULOG=m 348CONFIG_IP_NF_TARGET_ULOG=m
321CONFIG_IP_NF_TARGET_TCPMSS=m 349CONFIG_IP_NF_TARGET_TCPMSS=m
350# CONFIG_IP_NF_TARGET_NFQUEUE is not set
322CONFIG_IP_NF_NAT=m 351CONFIG_IP_NF_NAT=m
323CONFIG_IP_NF_NAT_NEEDED=y 352CONFIG_IP_NF_NAT_NEEDED=y
324CONFIG_IP_NF_TARGET_MASQUERADE=m 353CONFIG_IP_NF_TARGET_MASQUERADE=m
@@ -380,10 +409,18 @@ CONFIG_ECONET=m
380CONFIG_ECONET_AUNUDP=y 409CONFIG_ECONET_AUNUDP=y
381CONFIG_ECONET_NATIVE=y 410CONFIG_ECONET_NATIVE=y
382CONFIG_WAN_ROUTER=m 411CONFIG_WAN_ROUTER=m
412
413#
414# QoS and/or fair queueing
415#
383CONFIG_NET_SCHED=y 416CONFIG_NET_SCHED=y
384CONFIG_NET_SCH_CLK_JIFFIES=y 417CONFIG_NET_SCH_CLK_JIFFIES=y
385# CONFIG_NET_SCH_CLK_GETTIMEOFDAY is not set 418# CONFIG_NET_SCH_CLK_GETTIMEOFDAY is not set
386# CONFIG_NET_SCH_CLK_CPU is not set 419# CONFIG_NET_SCH_CLK_CPU is not set
420
421#
422# Queueing/Scheduling
423#
387CONFIG_NET_SCH_CBQ=m 424CONFIG_NET_SCH_CBQ=m
388CONFIG_NET_SCH_HTB=m 425CONFIG_NET_SCH_HTB=m
389# CONFIG_NET_SCH_HFSC is not set 426# CONFIG_NET_SCH_HFSC is not set
@@ -397,8 +434,10 @@ CONFIG_NET_SCH_GRED=m
397CONFIG_NET_SCH_DSMARK=m 434CONFIG_NET_SCH_DSMARK=m
398# CONFIG_NET_SCH_NETEM is not set 435# CONFIG_NET_SCH_NETEM is not set
399CONFIG_NET_SCH_INGRESS=m 436CONFIG_NET_SCH_INGRESS=m
400CONFIG_NET_QOS=y 437
401CONFIG_NET_ESTIMATOR=y 438#
439# Classification
440#
402CONFIG_NET_CLS=y 441CONFIG_NET_CLS=y
403# CONFIG_NET_CLS_BASIC is not set 442# CONFIG_NET_CLS_BASIC is not set
404CONFIG_NET_CLS_TCINDEX=m 443CONFIG_NET_CLS_TCINDEX=m
@@ -407,13 +446,14 @@ CONFIG_NET_CLS_ROUTE=y
407CONFIG_NET_CLS_FW=m 446CONFIG_NET_CLS_FW=m
408CONFIG_NET_CLS_U32=m 447CONFIG_NET_CLS_U32=m
409# CONFIG_CLS_U32_PERF is not set 448# CONFIG_CLS_U32_PERF is not set
410# CONFIG_NET_CLS_IND is not set
411# CONFIG_CLS_U32_MARK is not set 449# CONFIG_CLS_U32_MARK is not set
412CONFIG_NET_CLS_RSVP=m 450CONFIG_NET_CLS_RSVP=m
413CONFIG_NET_CLS_RSVP6=m 451CONFIG_NET_CLS_RSVP6=m
414# CONFIG_NET_EMATCH is not set 452# CONFIG_NET_EMATCH is not set
415# CONFIG_NET_CLS_ACT is not set 453# CONFIG_NET_CLS_ACT is not set
416CONFIG_NET_CLS_POLICE=y 454CONFIG_NET_CLS_POLICE=y
455# CONFIG_NET_CLS_IND is not set
456CONFIG_NET_ESTIMATOR=y
417 457
418# 458#
419# Network testing 459# Network testing
@@ -437,6 +477,11 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
437# CONFIG_DEBUG_DRIVER is not set 477# CONFIG_DEBUG_DRIVER is not set
438 478
439# 479#
480# Connector - unified userspace <-> kernelspace linker
481#
482# CONFIG_CONNECTOR is not set
483
484#
440# Memory Technology Devices (MTD) 485# Memory Technology Devices (MTD)
441# 486#
442CONFIG_MTD=y 487CONFIG_MTD=y
@@ -458,6 +503,7 @@ CONFIG_MTD_BLOCK=y
458# CONFIG_FTL is not set 503# CONFIG_FTL is not set
459# CONFIG_NFTL is not set 504# CONFIG_NFTL is not set
460# CONFIG_INFTL is not set 505# CONFIG_INFTL is not set
506# CONFIG_RFD_FTL is not set
461 507
462# 508#
463# RAM/ROM/Flash chip drivers 509# RAM/ROM/Flash chip drivers
@@ -492,7 +538,6 @@ CONFIG_MTD_COMPLEX_MAPPINGS=y
492# CONFIG_MTD_PHYSMAP is not set 538# CONFIG_MTD_PHYSMAP is not set
493# CONFIG_MTD_ARM_INTEGRATOR is not set 539# CONFIG_MTD_ARM_INTEGRATOR is not set
494CONFIG_MTD_IXP4XX=y 540CONFIG_MTD_IXP4XX=y
495# CONFIG_MTD_EDB7312 is not set
496# CONFIG_MTD_PCI is not set 541# CONFIG_MTD_PCI is not set
497# CONFIG_MTD_PLATRAM is not set 542# CONFIG_MTD_PLATRAM is not set
498 543
@@ -523,6 +568,11 @@ CONFIG_MTD_NAND_IDS=m
523# CONFIG_MTD_NAND_NANDSIM is not set 568# CONFIG_MTD_NAND_NANDSIM is not set
524 569
525# 570#
571# OneNAND Flash Device Drivers
572#
573# CONFIG_MTD_ONENAND is not set
574
575#
526# Parallel port support 576# Parallel port support
527# 577#
528# CONFIG_PARPORT is not set 578# CONFIG_PARPORT is not set
@@ -548,14 +598,6 @@ CONFIG_BLK_DEV_RAM_COUNT=16
548CONFIG_BLK_DEV_RAM_SIZE=8192 598CONFIG_BLK_DEV_RAM_SIZE=8192
549CONFIG_BLK_DEV_INITRD=y 599CONFIG_BLK_DEV_INITRD=y
550# CONFIG_CDROM_PKTCDVD is not set 600# CONFIG_CDROM_PKTCDVD is not set
551
552#
553# IO Schedulers
554#
555CONFIG_IOSCHED_NOOP=y
556CONFIG_IOSCHED_AS=y
557CONFIG_IOSCHED_DEADLINE=y
558CONFIG_IOSCHED_CFQ=y
559# CONFIG_ATA_OVER_ETH is not set 601# CONFIG_ATA_OVER_ETH is not set
560 602
561# 603#
@@ -668,6 +710,7 @@ CONFIG_NET_ETHERNET=y
668CONFIG_MII=y 710CONFIG_MII=y
669# CONFIG_HAPPYMEAL is not set 711# CONFIG_HAPPYMEAL is not set
670# CONFIG_SUNGEM is not set 712# CONFIG_SUNGEM is not set
713# CONFIG_CASSINI is not set
671# CONFIG_NET_VENDOR_3COM is not set 714# CONFIG_NET_VENDOR_3COM is not set
672# CONFIG_SMC91X is not set 715# CONFIG_SMC91X is not set
673# CONFIG_DM9000 is not set 716# CONFIG_DM9000 is not set
@@ -739,6 +782,7 @@ CONFIG_NET_RADIO=y
739# 782#
740# Wireless 802.11b ISA/PCI cards support 783# Wireless 802.11b ISA/PCI cards support
741# 784#
785# CONFIG_AIRO is not set
742CONFIG_HERMES=y 786CONFIG_HERMES=y
743# CONFIG_PLX_HERMES is not set 787# CONFIG_PLX_HERMES is not set
744# CONFIG_TMD_HERMES is not set 788# CONFIG_TMD_HERMES is not set
@@ -782,6 +826,7 @@ CONFIG_WAN_ROUTER_DRIVERS=y
782# 826#
783# ATM drivers 827# ATM drivers
784# 828#
829# CONFIG_ATM_DUMMY is not set
785CONFIG_ATM_TCP=m 830CONFIG_ATM_TCP=m
786# CONFIG_ATM_LANAI is not set 831# CONFIG_ATM_LANAI is not set
787# CONFIG_ATM_ENI is not set 832# CONFIG_ATM_ENI is not set
@@ -902,6 +947,7 @@ CONFIG_IXP4XX_WATCHDOG=y
902# TPM devices 947# TPM devices
903# 948#
904# CONFIG_TCG_TPM is not set 949# CONFIG_TCG_TPM is not set
950# CONFIG_TELCLOCK is not set
905 951
906# 952#
907# I2C support 953# I2C support
@@ -954,6 +1000,7 @@ CONFIG_SENSORS_EEPROM=y
954# CONFIG_SENSORS_PCF8591 is not set 1000# CONFIG_SENSORS_PCF8591 is not set
955# CONFIG_SENSORS_RTC8564 is not set 1001# CONFIG_SENSORS_RTC8564 is not set
956# CONFIG_SENSORS_MAX6875 is not set 1002# CONFIG_SENSORS_MAX6875 is not set
1003# CONFIG_RTC_X1205_I2C is not set
957# CONFIG_I2C_DEBUG_CORE is not set 1004# CONFIG_I2C_DEBUG_CORE is not set
958# CONFIG_I2C_DEBUG_ALGO is not set 1005# CONFIG_I2C_DEBUG_ALGO is not set
959# CONFIG_I2C_DEBUG_BUS is not set 1006# CONFIG_I2C_DEBUG_BUS is not set
@@ -1036,6 +1083,10 @@ CONFIG_USB_ARCH_HAS_OHCI=y
1036# CONFIG_USB is not set 1083# CONFIG_USB is not set
1037 1084
1038# 1085#
1086# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
1087#
1088
1089#
1039# USB Gadget Support 1090# USB Gadget Support
1040# 1091#
1041# CONFIG_USB_GADGET is not set 1092# CONFIG_USB_GADGET is not set
@@ -1110,6 +1161,7 @@ CONFIG_RAMFS=y
1110CONFIG_JFFS2_FS=y 1161CONFIG_JFFS2_FS=y
1111CONFIG_JFFS2_FS_DEBUG=0 1162CONFIG_JFFS2_FS_DEBUG=0
1112CONFIG_JFFS2_FS_WRITEBUFFER=y 1163CONFIG_JFFS2_FS_WRITEBUFFER=y
1164# CONFIG_JFFS2_SUMMARY is not set
1113# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set 1165# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
1114CONFIG_JFFS2_ZLIB=y 1166CONFIG_JFFS2_ZLIB=y
1115CONFIG_JFFS2_RTIME=y 1167CONFIG_JFFS2_RTIME=y
@@ -1190,7 +1242,9 @@ CONFIG_DETECT_SOFTLOCKUP=y
1190CONFIG_DEBUG_BUGVERBOSE=y 1242CONFIG_DEBUG_BUGVERBOSE=y
1191# CONFIG_DEBUG_INFO is not set 1243# CONFIG_DEBUG_INFO is not set
1192# CONFIG_DEBUG_FS is not set 1244# CONFIG_DEBUG_FS is not set
1245# CONFIG_DEBUG_VM is not set
1193CONFIG_FRAME_POINTER=y 1246CONFIG_FRAME_POINTER=y
1247# CONFIG_RCU_TORTURE_TEST is not set
1194# CONFIG_DEBUG_USER is not set 1248# CONFIG_DEBUG_USER is not set
1195# CONFIG_DEBUG_WAITQ is not set 1249# CONFIG_DEBUG_WAITQ is not set
1196CONFIG_DEBUG_ERRORS=y 1250CONFIG_DEBUG_ERRORS=y
diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
index c11169b5ed9a..de94b0f3ee2a 100644
--- a/arch/arm/kernel/Makefile
+++ b/arch/arm/kernel/Makefile
@@ -2,15 +2,16 @@
2# Makefile for the linux kernel. 2# Makefile for the linux kernel.
3# 3#
4 4
5AFLAGS_head.o := -DKERNEL_RAM_ADDR=$(TEXTADDR) 5AFLAGS_head.o := -DTEXT_OFFSET=$(TEXT_OFFSET)
6 6
7# Object file lists. 7# Object file lists.
8 8
9obj-y := compat.o dma.o entry-armv.o entry-common.o irq.o \ 9obj-y := compat.o entry-armv.o entry-common.o irq.o \
10 process.o ptrace.o semaphore.o setup.o signal.o sys_arm.o \ 10 process.o ptrace.o semaphore.o setup.o signal.o sys_arm.o \
11 time.o traps.o 11 time.o traps.o
12 12
13obj-$(CONFIG_APM) += apm.o 13obj-$(CONFIG_APM) += apm.o
14obj-$(CONFIG_ISA_DMA_API) += dma.o
14obj-$(CONFIG_ARCH_ACORN) += ecard.o 15obj-$(CONFIG_ARCH_ACORN) += ecard.o
15obj-$(CONFIG_FOOTBRIDGE) += isa.o 16obj-$(CONFIG_FOOTBRIDGE) += isa.o
16obj-$(CONFIG_FIQ) += fiq.o 17obj-$(CONFIG_FIQ) += fiq.o
diff --git a/arch/arm/kernel/apm.c b/arch/arm/kernel/apm.c
index a2843be05557..b9df1b782bb1 100644
--- a/arch/arm/kernel/apm.c
+++ b/arch/arm/kernel/apm.c
@@ -20,7 +20,6 @@
20#include <linux/apm_bios.h> 20#include <linux/apm_bios.h>
21#include <linux/sched.h> 21#include <linux/sched.h>
22#include <linux/pm.h> 22#include <linux/pm.h>
23#include <linux/pm_legacy.h>
24#include <linux/device.h> 23#include <linux/device.h>
25#include <linux/kernel.h> 24#include <linux/kernel.h>
26#include <linux/list.h> 25#include <linux/list.h>
@@ -81,6 +80,7 @@ struct apm_user {
81 */ 80 */
82static int suspends_pending; 81static int suspends_pending;
83static int apm_disabled; 82static int apm_disabled;
83static int arm_apm_active;
84 84
85static DECLARE_WAIT_QUEUE_HEAD(apm_waitqueue); 85static DECLARE_WAIT_QUEUE_HEAD(apm_waitqueue);
86static DECLARE_WAIT_QUEUE_HEAD(apm_suspend_waitqueue); 86static DECLARE_WAIT_QUEUE_HEAD(apm_suspend_waitqueue);
@@ -477,9 +477,9 @@ static int kapmd(void *arg)
477 apm_event_t event; 477 apm_event_t event;
478 478
479 wait_event_interruptible(kapmd_wait, 479 wait_event_interruptible(kapmd_wait,
480 !queue_empty(&kapmd_queue) || !pm_active); 480 !queue_empty(&kapmd_queue) || !arm_apm_active);
481 481
482 if (!pm_active) 482 if (!arm_apm_active)
483 break; 483 break;
484 484
485 spin_lock_irq(&kapmd_queue_lock); 485 spin_lock_irq(&kapmd_queue_lock);
@@ -522,16 +522,11 @@ static int __init apm_init(void)
522 return -ENODEV; 522 return -ENODEV;
523 } 523 }
524 524
525 if (PM_IS_ACTIVE()) { 525 arm_apm_active = 1;
526 printk(KERN_NOTICE "apm: overridden by ACPI.\n");
527 return -EINVAL;
528 }
529
530 pm_active = 1;
531 526
532 ret = kernel_thread(kapmd, NULL, CLONE_KERNEL); 527 ret = kernel_thread(kapmd, NULL, CLONE_KERNEL);
533 if (ret < 0) { 528 if (ret < 0) {
534 pm_active = 0; 529 arm_apm_active = 0;
535 return ret; 530 return ret;
536 } 531 }
537 532
@@ -543,7 +538,7 @@ static int __init apm_init(void)
543 if (ret != 0) { 538 if (ret != 0) {
544 remove_proc_entry("apm", NULL); 539 remove_proc_entry("apm", NULL);
545 540
546 pm_active = 0; 541 arm_apm_active = 0;
547 wake_up(&kapmd_wait); 542 wake_up(&kapmd_wait);
548 wait_for_completion(&kapmd_exit); 543 wait_for_completion(&kapmd_exit);
549 } 544 }
@@ -556,7 +551,7 @@ static void __exit apm_exit(void)
556 misc_deregister(&apm_device); 551 misc_deregister(&apm_device);
557 remove_proc_entry("apm", NULL); 552 remove_proc_entry("apm", NULL);
558 553
559 pm_active = 0; 554 arm_apm_active = 0;
560 wake_up(&kapmd_wait); 555 wake_up(&kapmd_wait);
561 wait_for_completion(&kapmd_exit); 556 wait_for_completion(&kapmd_exit);
562} 557}
diff --git a/arch/arm/kernel/dma-isa.c b/arch/arm/kernel/dma-isa.c
index e9a36304ec3e..03532769a97f 100644
--- a/arch/arm/kernel/dma-isa.c
+++ b/arch/arm/kernel/dma-isa.c
@@ -18,7 +18,7 @@
18 */ 18 */
19#include <linux/ioport.h> 19#include <linux/ioport.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/pci.h> 21#include <linux/dma-mapping.h>
22 22
23#include <asm/dma.h> 23#include <asm/dma.h>
24#include <asm/io.h> 24#include <asm/io.h>
@@ -65,37 +65,41 @@ static void isa_enable_dma(dmach_t channel, dma_t *dma)
65{ 65{
66 if (dma->invalid) { 66 if (dma->invalid) {
67 unsigned long address, length; 67 unsigned long address, length;
68 unsigned int mode, direction; 68 unsigned int mode;
69 enum dma_data_direction direction;
69 70
70 mode = channel & 3; 71 mode = channel & 3;
71 switch (dma->dma_mode & DMA_MODE_MASK) { 72 switch (dma->dma_mode & DMA_MODE_MASK) {
72 case DMA_MODE_READ: 73 case DMA_MODE_READ:
73 mode |= ISA_DMA_MODE_READ; 74 mode |= ISA_DMA_MODE_READ;
74 direction = PCI_DMA_FROMDEVICE; 75 direction = DMA_FROM_DEVICE;
75 break; 76 break;
76 77
77 case DMA_MODE_WRITE: 78 case DMA_MODE_WRITE:
78 mode |= ISA_DMA_MODE_WRITE; 79 mode |= ISA_DMA_MODE_WRITE;
79 direction = PCI_DMA_TODEVICE; 80 direction = DMA_TO_DEVICE;
80 break; 81 break;
81 82
82 case DMA_MODE_CASCADE: 83 case DMA_MODE_CASCADE:
83 mode |= ISA_DMA_MODE_CASCADE; 84 mode |= ISA_DMA_MODE_CASCADE;
84 direction = PCI_DMA_BIDIRECTIONAL; 85 direction = DMA_BIDIRECTIONAL;
85 break; 86 break;
86 87
87 default: 88 default:
88 direction = PCI_DMA_NONE; 89 direction = DMA_NONE;
89 break; 90 break;
90 } 91 }
91 92
92 if (!dma->using_sg) { 93 if (!dma->sg) {
93 /* 94 /*
94 * Cope with ISA-style drivers which expect cache 95 * Cope with ISA-style drivers which expect cache
95 * coherence. 96 * coherence.
96 */ 97 */
97 dma->buf.dma_address = pci_map_single(NULL, 98 dma->sg = &dma->buf;
98 dma->buf.__address, dma->buf.length, 99 dma->sgcount = 1;
100 dma->buf.length = dma->count;
101 dma->buf.dma_address = dma_map_single(NULL,
102 dma->addr, dma->count,
99 direction); 103 direction);
100 } 104 }
101 105
diff --git a/arch/arm/kernel/dma.c b/arch/arm/kernel/dma.c
index 2b7883884234..5a0f4bc5da95 100644
--- a/arch/arm/kernel/dma.c
+++ b/arch/arm/kernel/dma.c
@@ -12,8 +12,6 @@
12 * DMA facilities. 12 * DMA facilities.
13 */ 13 */
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/slab.h>
16#include <linux/mman.h>
17#include <linux/init.h> 15#include <linux/init.h>
18#include <linux/spinlock.h> 16#include <linux/spinlock.h>
19#include <linux/errno.h> 17#include <linux/errno.h>
@@ -23,8 +21,7 @@
23#include <asm/mach/dma.h> 21#include <asm/mach/dma.h>
24 22
25DEFINE_SPINLOCK(dma_spin_lock); 23DEFINE_SPINLOCK(dma_spin_lock);
26 24EXPORT_SYMBOL(dma_spin_lock);
27#if MAX_DMA_CHANNELS > 0
28 25
29static dma_t dma_chan[MAX_DMA_CHANNELS]; 26static dma_t dma_chan[MAX_DMA_CHANNELS];
30 27
@@ -81,6 +78,7 @@ bad_dma:
81busy: 78busy:
82 return -EBUSY; 79 return -EBUSY;
83} 80}
81EXPORT_SYMBOL(request_dma);
84 82
85/* 83/*
86 * Free DMA channel 84 * Free DMA channel
@@ -112,6 +110,7 @@ void free_dma(dmach_t channel)
112bad_dma: 110bad_dma:
113 printk(KERN_ERR "dma: trying to free DMA%d\n", channel); 111 printk(KERN_ERR "dma: trying to free DMA%d\n", channel);
114} 112}
113EXPORT_SYMBOL(free_dma);
115 114
116/* Set DMA Scatter-Gather list 115/* Set DMA Scatter-Gather list
117 */ 116 */
@@ -125,15 +124,15 @@ void set_dma_sg (dmach_t channel, struct scatterlist *sg, int nr_sg)
125 124
126 dma->sg = sg; 125 dma->sg = sg;
127 dma->sgcount = nr_sg; 126 dma->sgcount = nr_sg;
128 dma->using_sg = 1;
129 dma->invalid = 1; 127 dma->invalid = 1;
130} 128}
129EXPORT_SYMBOL(set_dma_sg);
131 130
132/* Set DMA address 131/* Set DMA address
133 * 132 *
134 * Copy address to the structure, and set the invalid bit 133 * Copy address to the structure, and set the invalid bit
135 */ 134 */
136void set_dma_addr (dmach_t channel, unsigned long physaddr) 135void __set_dma_addr (dmach_t channel, void *addr)
137{ 136{
138 dma_t *dma = dma_chan + channel; 137 dma_t *dma = dma_chan + channel;
139 138
@@ -141,12 +140,11 @@ void set_dma_addr (dmach_t channel, unsigned long physaddr)
141 printk(KERN_ERR "dma%d: altering DMA address while " 140 printk(KERN_ERR "dma%d: altering DMA address while "
142 "DMA active\n", channel); 141 "DMA active\n", channel);
143 142
144 dma->sg = &dma->buf; 143 dma->sg = NULL;
145 dma->sgcount = 1; 144 dma->addr = addr;
146 dma->buf.__address = bus_to_virt(physaddr);
147 dma->using_sg = 0;
148 dma->invalid = 1; 145 dma->invalid = 1;
149} 146}
147EXPORT_SYMBOL(__set_dma_addr);
150 148
151/* Set DMA byte count 149/* Set DMA byte count
152 * 150 *
@@ -160,12 +158,11 @@ void set_dma_count (dmach_t channel, unsigned long count)
160 printk(KERN_ERR "dma%d: altering DMA count while " 158 printk(KERN_ERR "dma%d: altering DMA count while "
161 "DMA active\n", channel); 159 "DMA active\n", channel);
162 160
163 dma->sg = &dma->buf; 161 dma->sg = NULL;
164 dma->sgcount = 1; 162 dma->count = count;
165 dma->buf.length = count;
166 dma->using_sg = 0;
167 dma->invalid = 1; 163 dma->invalid = 1;
168} 164}
165EXPORT_SYMBOL(set_dma_count);
169 166
170/* Set DMA direction mode 167/* Set DMA direction mode
171 */ 168 */
@@ -180,6 +177,7 @@ void set_dma_mode (dmach_t channel, dmamode_t mode)
180 dma->dma_mode = mode; 177 dma->dma_mode = mode;
181 dma->invalid = 1; 178 dma->invalid = 1;
182} 179}
180EXPORT_SYMBOL(set_dma_mode);
183 181
184/* Enable DMA channel 182/* Enable DMA channel
185 */ 183 */
@@ -200,6 +198,7 @@ free_dma:
200 printk(KERN_ERR "dma%d: trying to enable free DMA\n", channel); 198 printk(KERN_ERR "dma%d: trying to enable free DMA\n", channel);
201 BUG(); 199 BUG();
202} 200}
201EXPORT_SYMBOL(enable_dma);
203 202
204/* Disable DMA channel 203/* Disable DMA channel
205 */ 204 */
@@ -220,6 +219,7 @@ free_dma:
220 printk(KERN_ERR "dma%d: trying to disable free DMA\n", channel); 219 printk(KERN_ERR "dma%d: trying to disable free DMA\n", channel);
221 BUG(); 220 BUG();
222} 221}
222EXPORT_SYMBOL(disable_dma);
223 223
224/* 224/*
225 * Is the specified DMA channel active? 225 * Is the specified DMA channel active?
@@ -233,6 +233,7 @@ void set_dma_page(dmach_t channel, char pagenr)
233{ 233{
234 printk(KERN_ERR "dma%d: trying to set_dma_page\n", channel); 234 printk(KERN_ERR "dma%d: trying to set_dma_page\n", channel);
235} 235}
236EXPORT_SYMBOL(set_dma_page);
236 237
237void set_dma_speed(dmach_t channel, int cycle_ns) 238void set_dma_speed(dmach_t channel, int cycle_ns)
238{ 239{
@@ -243,6 +244,7 @@ void set_dma_speed(dmach_t channel, int cycle_ns)
243 ret = dma->d_ops->setspeed(channel, dma, cycle_ns); 244 ret = dma->d_ops->setspeed(channel, dma, cycle_ns);
244 dma->speed = ret; 245 dma->speed = ret;
245} 246}
247EXPORT_SYMBOL(set_dma_speed);
246 248
247int get_dma_residue(dmach_t channel) 249int get_dma_residue(dmach_t channel)
248{ 250{
@@ -254,49 +256,12 @@ int get_dma_residue(dmach_t channel)
254 256
255 return ret; 257 return ret;
256} 258}
259EXPORT_SYMBOL(get_dma_residue);
257 260
258void __init init_dma(void) 261static int __init init_dma(void)
259{ 262{
260 arch_dma_init(dma_chan); 263 arch_dma_init(dma_chan);
261}
262
263#else
264
265int request_dma(dmach_t channel, const char *device_id)
266{
267 return -EINVAL;
268}
269
270int get_dma_residue(dmach_t channel)
271{
272 return 0; 264 return 0;
273} 265}
274 266
275#define GLOBAL_ALIAS(_a,_b) asm (".set " #_a "," #_b "; .globl " #_a) 267core_initcall(init_dma);
276GLOBAL_ALIAS(disable_dma, get_dma_residue);
277GLOBAL_ALIAS(enable_dma, get_dma_residue);
278GLOBAL_ALIAS(free_dma, get_dma_residue);
279GLOBAL_ALIAS(get_dma_list, get_dma_residue);
280GLOBAL_ALIAS(set_dma_mode, get_dma_residue);
281GLOBAL_ALIAS(set_dma_page, get_dma_residue);
282GLOBAL_ALIAS(set_dma_count, get_dma_residue);
283GLOBAL_ALIAS(set_dma_addr, get_dma_residue);
284GLOBAL_ALIAS(set_dma_sg, get_dma_residue);
285GLOBAL_ALIAS(set_dma_speed, get_dma_residue);
286GLOBAL_ALIAS(init_dma, get_dma_residue);
287
288#endif
289
290EXPORT_SYMBOL(request_dma);
291EXPORT_SYMBOL(free_dma);
292EXPORT_SYMBOL(enable_dma);
293EXPORT_SYMBOL(disable_dma);
294EXPORT_SYMBOL(set_dma_addr);
295EXPORT_SYMBOL(set_dma_count);
296EXPORT_SYMBOL(set_dma_mode);
297EXPORT_SYMBOL(set_dma_page);
298EXPORT_SYMBOL(get_dma_residue);
299EXPORT_SYMBOL(set_dma_sg);
300EXPORT_SYMBOL(set_dma_speed);
301
302EXPORT_SYMBOL(dma_spin_lock);
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index 2a8d27e18fa7..a52baedf6262 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -18,8 +18,6 @@
18#include <asm/memory.h> 18#include <asm/memory.h>
19#include <asm/glue.h> 19#include <asm/glue.h>
20#include <asm/vfpmacros.h> 20#include <asm/vfpmacros.h>
21#include <asm/hardware.h> /* should be moved into entry-macro.S */
22#include <asm/arch/irqs.h> /* should be moved into entry-macro.S */
23#include <asm/arch/entry-macro.S> 21#include <asm/arch/entry-macro.S>
24 22
25#include "entry-header.S" 23#include "entry-header.S"
diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
index d7d69fd7039f..1e985f2cd70f 100644
--- a/arch/arm/kernel/head.S
+++ b/arch/arm/kernel/head.S
@@ -33,6 +33,8 @@
33#define MACHINFO_PGOFFIO 12 33#define MACHINFO_PGOFFIO 12
34#define MACHINFO_NAME 16 34#define MACHINFO_NAME 16
35 35
36#define KERNEL_RAM_ADDR (PAGE_OFFSET + TEXT_OFFSET)
37
36/* 38/*
37 * swapper_pg_dir is the virtual address of the initial page table. 39 * swapper_pg_dir is the virtual address of the initial page table.
38 * We place the page tables 16K below KERNEL_RAM_ADDR. Therefore, we must 40 * We place the page tables 16K below KERNEL_RAM_ADDR. Therefore, we must
diff --git a/arch/arm/kernel/irq.c b/arch/arm/kernel/irq.c
index d7099dbbb879..869c466e6258 100644
--- a/arch/arm/kernel/irq.c
+++ b/arch/arm/kernel/irq.c
@@ -1027,7 +1027,6 @@ void __init init_irq_proc(void)
1027void __init init_IRQ(void) 1027void __init init_IRQ(void)
1028{ 1028{
1029 struct irqdesc *desc; 1029 struct irqdesc *desc;
1030 extern void init_dma(void);
1031 int irq; 1030 int irq;
1032 1031
1033#ifdef CONFIG_SMP 1032#ifdef CONFIG_SMP
@@ -1041,7 +1040,6 @@ void __init init_IRQ(void)
1041 } 1040 }
1042 1041
1043 init_arch_irq(); 1042 init_arch_irq();
1044 init_dma();
1045} 1043}
1046 1044
1047static int __init noirqdebug_setup(char *str) 1045static int __init noirqdebug_setup(char *str)
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index 30494aab829a..54a21bdcba5c 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -28,10 +28,9 @@
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/cpu.h> 29#include <linux/cpu.h>
30 30
31#include <asm/system.h>
32#include <asm/io.h>
33#include <asm/leds.h> 31#include <asm/leds.h>
34#include <asm/processor.h> 32#include <asm/processor.h>
33#include <asm/system.h>
35#include <asm/uaccess.h> 34#include <asm/uaccess.h>
36#include <asm/mach/time.h> 35#include <asm/mach/time.h>
37 36
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 85774165e9fd..2cab741ad0f8 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -26,8 +26,6 @@
26 26
27#include <asm/cpu.h> 27#include <asm/cpu.h>
28#include <asm/elf.h> 28#include <asm/elf.h>
29#include <asm/hardware.h>
30#include <asm/io.h>
31#include <asm/procinfo.h> 29#include <asm/procinfo.h>
32#include <asm/setup.h> 30#include <asm/setup.h>
33#include <asm/mach-types.h> 31#include <asm/mach-types.h>
diff --git a/arch/arm/kernel/time.c b/arch/arm/kernel/time.c
index fc4729106a32..d7d932c02866 100644
--- a/arch/arm/kernel/time.c
+++ b/arch/arm/kernel/time.c
@@ -29,9 +29,6 @@
29#include <linux/sysdev.h> 29#include <linux/sysdev.h>
30#include <linux/timer.h> 30#include <linux/timer.h>
31 31
32#include <asm/hardware.h>
33#include <asm/io.h>
34#include <asm/irq.h>
35#include <asm/leds.h> 32#include <asm/leds.h>
36#include <asm/thread_info.h> 33#include <asm/thread_info.h>
37#include <asm/mach/time.h> 34#include <asm/mach/time.h>
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index 45e9ea6cd2a5..c9fe6f5f7ee3 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -23,7 +23,6 @@
23 23
24#include <asm/atomic.h> 24#include <asm/atomic.h>
25#include <asm/cacheflush.h> 25#include <asm/cacheflush.h>
26#include <asm/io.h>
27#include <asm/system.h> 26#include <asm/system.h>
28#include <asm/uaccess.h> 27#include <asm/uaccess.h>
29#include <asm/unistd.h> 28#include <asm/unistd.h>
diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
index 9a47770114d4..2b254e88595c 100644
--- a/arch/arm/kernel/vmlinux.lds.S
+++ b/arch/arm/kernel/vmlinux.lds.S
@@ -17,15 +17,13 @@ jiffies = jiffies_64;
17jiffies = jiffies_64 + 4; 17jiffies = jiffies_64 + 4;
18#endif 18#endif
19 19
20SECTIONS
21{
20#ifdef CONFIG_XIP_KERNEL 22#ifdef CONFIG_XIP_KERNEL
21#define TEXTADDR XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR) 23 . = XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR);
22#else 24#else
23#define TEXTADDR KERNEL_RAM_ADDR 25 . = PAGE_OFFSET + TEXT_OFFSET;
24#endif 26#endif
25
26SECTIONS
27{
28 . = TEXTADDR;
29 .init : { /* Init code and data */ 27 .init : { /* Init code and data */
30 _stext = .; 28 _stext = .;
31 _sinittext = .; 29 _sinittext = .;
@@ -104,7 +102,7 @@ SECTIONS
104 102
105#ifdef CONFIG_XIP_KERNEL 103#ifdef CONFIG_XIP_KERNEL
106 __data_loc = ALIGN(4); /* location in binary */ 104 __data_loc = ALIGN(4); /* location in binary */
107 . = KERNEL_RAM_ADDR; 105 . = PAGE_OFFSET + TEXT_OFFSET;
108#else 106#else
109 . = ALIGN(THREAD_SIZE); 107 . = ALIGN(THREAD_SIZE);
110 __data_loc = .; 108 __data_loc = .;
diff --git a/arch/arm/mach-aaec2000/clock.c b/arch/arm/mach-aaec2000/clock.c
index 0340ddc4824e..1c84c60941e1 100644
--- a/arch/arm/mach-aaec2000/clock.c
+++ b/arch/arm/mach-aaec2000/clock.c
@@ -15,9 +15,9 @@
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/err.h> 16#include <linux/err.h>
17#include <linux/string.h> 17#include <linux/string.h>
18#include <linux/clk.h>
18 19
19#include <asm/semaphore.h> 20#include <asm/semaphore.h>
20#include <asm/hardware/clock.h>
21 21
22#include "clock.h" 22#include "clock.h"
23 23
@@ -58,17 +58,6 @@ void clk_disable(struct clk *clk)
58} 58}
59EXPORT_SYMBOL(clk_disable); 59EXPORT_SYMBOL(clk_disable);
60 60
61int clk_use(struct clk *clk)
62{
63 return 0;
64}
65EXPORT_SYMBOL(clk_use);
66
67void clk_unuse(struct clk *clk)
68{
69}
70EXPORT_SYMBOL(clk_unuse);
71
72unsigned long clk_get_rate(struct clk *clk) 61unsigned long clk_get_rate(struct clk *clk)
73{ 62{
74 return clk->rate; 63 return clk->rate;
diff --git a/arch/arm/mach-aaec2000/core.c b/arch/arm/mach-aaec2000/core.c
index 4e706d9ad368..dce4815cf53c 100644
--- a/arch/arm/mach-aaec2000/core.c
+++ b/arch/arm/mach-aaec2000/core.c
@@ -20,11 +20,11 @@
20#include <linux/interrupt.h> 20#include <linux/interrupt.h>
21#include <linux/timex.h> 21#include <linux/timex.h>
22#include <linux/signal.h> 22#include <linux/signal.h>
23#include <linux/amba/bus.h>
23 24
24#include <asm/hardware.h> 25#include <asm/hardware.h>
25#include <asm/irq.h> 26#include <asm/irq.h>
26#include <asm/sizes.h> 27#include <asm/sizes.h>
27#include <asm/hardware/amba.h>
28 28
29#include <asm/mach/flash.h> 29#include <asm/mach/flash.h>
30#include <asm/mach/irq.h> 30#include <asm/mach/irq.h>
diff --git a/arch/arm/mach-aaec2000/core.h b/arch/arm/mach-aaec2000/core.h
index daefc0ea14a1..b6029a95f19c 100644
--- a/arch/arm/mach-aaec2000/core.h
+++ b/arch/arm/mach-aaec2000/core.h
@@ -9,7 +9,7 @@
9 * 9 *
10 */ 10 */
11 11
12#include <asm/hardware/amba_clcd.h> 12#include <linux/amba/clcd.h>
13 13
14struct sys_timer; 14struct sys_timer;
15 15
diff --git a/arch/arm/mach-clps711x/dma.c b/arch/arm/mach-clps711x/dma.c
deleted file mode 100644
index af5a4de38eac..000000000000
--- a/arch/arm/mach-clps711x/dma.c
+++ /dev/null
@@ -1,27 +0,0 @@
1/*
2 * linux/arch/arm/mach-clps711x/dma.c
3 *
4 * Copyright (C) 2000 Deep Blue Solutions Ltd
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 as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20#include <linux/init.h>
21
22#include <asm/dma.h>
23#include <asm/mach/dma.h>
24
25void __init arch_dma_init(dma_t *dma)
26{
27}
diff --git a/arch/arm/mach-epxa10db/dma.c b/arch/arm/mach-epxa10db/dma.c
deleted file mode 100644
index 0151e9f1c066..000000000000
--- a/arch/arm/mach-epxa10db/dma.c
+++ /dev/null
@@ -1,28 +0,0 @@
1/*
2 * linux/arch/arm/mach-epxa10db/dma.c
3 *
4 * Copyright (C) 1999 ARM Limited
5 * Copyright (C) 2000 Deep Blue Solutions Ltd
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21#include <linux/init.h>
22
23#include <asm/dma.h>
24#include <asm/mach/dma.h>
25
26void __init arch_dma_init(dma_t *dma)
27{
28}
diff --git a/arch/arm/mach-footbridge/dma.c b/arch/arm/mach-footbridge/dma.c
index a6b1396b0951..7a54578b51af 100644
--- a/arch/arm/mach-footbridge/dma.c
+++ b/arch/arm/mach-footbridge/dma.c
@@ -15,6 +15,7 @@
15 15
16#include <asm/dma.h> 16#include <asm/dma.h>
17#include <asm/io.h> 17#include <asm/io.h>
18#include <asm/scatterlist.h>
18 19
19#include <asm/mach/dma.h> 20#include <asm/mach/dma.h>
20#include <asm/hardware/dec21285.h> 21#include <asm/hardware/dec21285.h>
diff --git a/arch/arm/mach-imx/mx1ads.c b/arch/arm/mach-imx/mx1ads.c
index 708e1b3faa14..c9e0cd8ed016 100644
--- a/arch/arm/mach-imx/mx1ads.c
+++ b/arch/arm/mach-imx/mx1ads.c
@@ -29,27 +29,27 @@
29#include "generic.h" 29#include "generic.h"
30#include <asm/serial.h> 30#include <asm/serial.h>
31 31
32static struct resource mx1ads_resources[] = { 32static struct resource cs89x0_resources[] = {
33 [0] = { 33 [0] = {
34 .start = IMX_CS4_VIRT, 34 .start = IMX_CS4_PHYS + 0x300,
35 .end = IMX_CS4_VIRT + 16, 35 .end = IMX_CS4_PHYS + 0x300 + 16,
36 .flags = IORESOURCE_MEM, 36 .flags = IORESOURCE_MEM,
37 }, 37 },
38 [1] = { 38 [1] = {
39 .start = 13, 39 .start = IRQ_GPIOC(17),
40 .end = 13, 40 .end = IRQ_GPIOC(17),
41 .flags = IORESOURCE_IRQ, 41 .flags = IORESOURCE_IRQ,
42 }, 42 },
43}; 43};
44 44
45static struct platform_device mx1ads_device = { 45static struct platform_device cs89x0_device = {
46 .name = "mx1ads", 46 .name = "cirrus-cs89x0",
47 .num_resources = ARRAY_SIZE(mx1ads_resources), 47 .num_resources = ARRAY_SIZE(cs89x0_resources),
48 .resource = mx1ads_resources, 48 .resource = cs89x0_resources,
49}; 49};
50 50
51static struct platform_device *devices[] __initdata = { 51static struct platform_device *devices[] __initdata = {
52 &mx1ads_device, 52 &cs89x0_device,
53}; 53};
54 54
55static void __init 55static void __init
@@ -61,45 +61,10 @@ mx1ads_init(void)
61 platform_add_devices(devices, ARRAY_SIZE(devices)); 61 platform_add_devices(devices, ARRAY_SIZE(devices));
62} 62}
63 63
64static struct map_desc mx1ads_io_desc[] __initdata = {
65 {
66 .virtual = IMX_CS0_VIRT,
67 .pfn = __phys_to_pfn(IMX_CS0_PHYS),
68 .length = IMX_CS0_SIZE,
69 .type = MT_DEVICE
70 }, {
71 .virtual = IMX_CS1_VIRT,
72 .pfn = __phys_to_pfn(IMX_CS1_PHYS),
73 .length = IMX_CS1_SIZE,
74 .type = MT_DEVICE
75 }, {
76 .virtual = IMX_CS2_VIRT,
77 .pfn = __phys_to_pfn(IMX_CS2_PHYS),
78 .length = IMX_CS2_SIZE,
79 .type = MT_DEVICE
80 }, {
81 .virtual = IMX_CS3_VIRT,
82 .pfn = __phys_to_pfn(IMX_CS3_PHYS),
83 .length = IMX_CS3_SIZE,
84 .type = MT_DEVICE
85 }, {
86 .virtual = IMX_CS4_VIRT,
87 .pfn = __phys_to_pfn(IMX_CS4_PHYS),
88 .length = IMX_CS4_SIZE,
89 .type = MT_DEVICE
90 }, {
91 .virtual = IMX_CS5_VIRT,
92 .pfn = __phys_to_pfn(IMX_CS5_PHYS),
93 .length = IMX_CS5_SIZE,
94 .type = MT_DEVICE
95 }
96};
97
98static void __init 64static void __init
99mx1ads_map_io(void) 65mx1ads_map_io(void)
100{ 66{
101 imx_map_io(); 67 imx_map_io();
102 iotable_init(mx1ads_io_desc, ARRAY_SIZE(mx1ads_io_desc));
103} 68}
104 69
105MACHINE_START(MX1ADS, "Motorola MX1ADS") 70MACHINE_START(MX1ADS, "Motorola MX1ADS")
diff --git a/arch/arm/mach-integrator/clock.c b/arch/arm/mach-integrator/clock.c
index 73c360685cad..40684e01e865 100644
--- a/arch/arm/mach-integrator/clock.c
+++ b/arch/arm/mach-integrator/clock.c
@@ -14,9 +14,9 @@
14#include <linux/errno.h> 14#include <linux/errno.h>
15#include <linux/err.h> 15#include <linux/err.h>
16#include <linux/string.h> 16#include <linux/string.h>
17#include <linux/clk.h>
17 18
18#include <asm/semaphore.h> 19#include <asm/semaphore.h>
19#include <asm/hardware/clock.h>
20#include <asm/hardware/icst525.h> 20#include <asm/hardware/icst525.h>
21 21
22#include "clock.h" 22#include "clock.h"
@@ -58,17 +58,6 @@ void clk_disable(struct clk *clk)
58} 58}
59EXPORT_SYMBOL(clk_disable); 59EXPORT_SYMBOL(clk_disable);
60 60
61int clk_use(struct clk *clk)
62{
63 return 0;
64}
65EXPORT_SYMBOL(clk_use);
66
67void clk_unuse(struct clk *clk)
68{
69}
70EXPORT_SYMBOL(clk_unuse);
71
72unsigned long clk_get_rate(struct clk *clk) 61unsigned long clk_get_rate(struct clk *clk)
73{ 62{
74 return clk->rate; 63 return clk->rate;
diff --git a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c
index dacbf504dae2..20071a2767cc 100644
--- a/arch/arm/mach-integrator/core.c
+++ b/arch/arm/mach-integrator/core.c
@@ -15,11 +15,11 @@
15#include <linux/interrupt.h> 15#include <linux/interrupt.h>
16#include <linux/sched.h> 16#include <linux/sched.h>
17#include <linux/smp.h> 17#include <linux/smp.h>
18#include <linux/amba/bus.h>
18 19
19#include <asm/hardware.h> 20#include <asm/hardware.h>
20#include <asm/irq.h> 21#include <asm/irq.h>
21#include <asm/io.h> 22#include <asm/io.h>
22#include <asm/hardware/amba.h>
23#include <asm/hardware/arm_timer.h> 23#include <asm/hardware/arm_timer.h>
24#include <asm/arch/cm.h> 24#include <asm/arch/cm.h>
25#include <asm/system.h> 25#include <asm/system.h>
diff --git a/arch/arm/mach-integrator/dma.c b/arch/arm/mach-integrator/dma.c
deleted file mode 100644
index aae6f23cd72b..000000000000
--- a/arch/arm/mach-integrator/dma.c
+++ /dev/null
@@ -1,35 +0,0 @@
1/*
2 * linux/arch/arm/mach-integrator/dma.c
3 *
4 * Copyright (C) 1999 ARM Limited
5 * Copyright (C) 2000 Deep Blue Solutions Ltd
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21#include <linux/slab.h>
22#include <linux/mman.h>
23#include <linux/init.h>
24
25#include <asm/page.h>
26#include <asm/pgtable.h>
27#include <asm/dma.h>
28#include <asm/io.h>
29#include <asm/hardware.h>
30
31#include <asm/mach/dma.h>
32
33void __init arch_dma_init(dma_t *dma)
34{
35}
diff --git a/arch/arm/mach-integrator/impd1.c b/arch/arm/mach-integrator/impd1.c
index a4bafee77a06..a85d471c5bfa 100644
--- a/arch/arm/mach-integrator/impd1.c
+++ b/arch/arm/mach-integrator/impd1.c
@@ -18,11 +18,11 @@
18#include <linux/device.h> 18#include <linux/device.h>
19#include <linux/errno.h> 19#include <linux/errno.h>
20#include <linux/mm.h> 20#include <linux/mm.h>
21#include <linux/amba/bus.h>
22#include <linux/amba/clcd.h>
21 23
22#include <asm/io.h> 24#include <asm/io.h>
23#include <asm/hardware/icst525.h> 25#include <asm/hardware/icst525.h>
24#include <asm/hardware/amba.h>
25#include <asm/hardware/amba_clcd.h>
26#include <asm/arch/lm.h> 26#include <asm/arch/lm.h>
27#include <asm/arch/impd1.h> 27#include <asm/arch/impd1.h>
28#include <asm/sizes.h> 28#include <asm/sizes.h>
diff --git a/arch/arm/mach-integrator/integrator_ap.c b/arch/arm/mach-integrator/integrator_ap.c
index 4c0f7c65facf..3afedeb56a6e 100644
--- a/arch/arm/mach-integrator/integrator_ap.c
+++ b/arch/arm/mach-integrator/integrator_ap.c
@@ -25,6 +25,8 @@
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/string.h> 26#include <linux/string.h>
27#include <linux/sysdev.h> 27#include <linux/sysdev.h>
28#include <linux/amba/bus.h>
29#include <linux/amba/kmi.h>
28 30
29#include <asm/hardware.h> 31#include <asm/hardware.h>
30#include <asm/io.h> 32#include <asm/io.h>
@@ -32,8 +34,6 @@
32#include <asm/setup.h> 34#include <asm/setup.h>
33#include <asm/param.h> /* HZ */ 35#include <asm/param.h> /* HZ */
34#include <asm/mach-types.h> 36#include <asm/mach-types.h>
35#include <asm/hardware/amba.h>
36#include <asm/hardware/amba_kmi.h>
37 37
38#include <asm/arch/lm.h> 38#include <asm/arch/lm.h>
39 39
diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c
index 93f7ccb22c27..16cf2482a3e9 100644
--- a/arch/arm/mach-integrator/integrator_cp.c
+++ b/arch/arm/mach-integrator/integrator_cp.c
@@ -16,15 +16,15 @@
16#include <linux/slab.h> 16#include <linux/slab.h>
17#include <linux/string.h> 17#include <linux/string.h>
18#include <linux/sysdev.h> 18#include <linux/sysdev.h>
19#include <linux/amba/bus.h>
20#include <linux/amba/kmi.h>
21#include <linux/amba/clcd.h>
19 22
20#include <asm/hardware.h> 23#include <asm/hardware.h>
21#include <asm/io.h> 24#include <asm/io.h>
22#include <asm/irq.h> 25#include <asm/irq.h>
23#include <asm/setup.h> 26#include <asm/setup.h>
24#include <asm/mach-types.h> 27#include <asm/mach-types.h>
25#include <asm/hardware/amba.h>
26#include <asm/hardware/amba_kmi.h>
27#include <asm/hardware/amba_clcd.h>
28#include <asm/hardware/icst525.h> 28#include <asm/hardware/icst525.h>
29 29
30#include <asm/arch/cm.h> 30#include <asm/arch/cm.h>
diff --git a/arch/arm/mach-integrator/time.c b/arch/arm/mach-integrator/time.c
index 1a844ca139e0..9f46aaef8968 100644
--- a/arch/arm/mach-integrator/time.c
+++ b/arch/arm/mach-integrator/time.c
@@ -14,8 +14,8 @@
14#include <linux/interrupt.h> 14#include <linux/interrupt.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/device.h> 16#include <linux/device.h>
17#include <linux/amba/bus.h>
17 18
18#include <asm/hardware/amba.h>
19#include <asm/hardware.h> 19#include <asm/hardware.h>
20#include <asm/io.h> 20#include <asm/io.h>
21#include <asm/uaccess.h> 21#include <asm/uaccess.h>
diff --git a/arch/arm/mach-iop3xx/iop331-setup.c b/arch/arm/mach-iop3xx/iop331-setup.c
index 53f60614498b..e6ea1cba6a17 100644
--- a/arch/arm/mach-iop3xx/iop331-setup.c
+++ b/arch/arm/mach-iop3xx/iop331-setup.c
@@ -18,7 +18,7 @@
18#include <linux/platform_device.h> 18#include <linux/platform_device.h>
19#include <linux/serial.h> 19#include <linux/serial.h>
20#include <linux/tty.h> 20#include <linux/tty.h>
21#include <linux/serial_core.h> 21#include <linux/serial_8250.h>
22 22
23#include <asm/io.h> 23#include <asm/io.h>
24#include <asm/pgtable.h> 24#include <asm/pgtable.h>
@@ -50,32 +50,74 @@ static struct map_desc iop331_std_desc[] __initdata = {
50 } 50 }
51}; 51};
52 52
53static struct uart_port iop331_serial_ports[] = { 53static struct resource iop33x_uart0_resources[] = {
54 { 54 [0] = {
55 .membase = (char*)(IOP331_UART0_VIRT), 55 .start = IOP331_UART0_PHYS,
56 .mapbase = (IOP331_UART0_PHYS), 56 .end = IOP331_UART0_PHYS + 0x3f,
57 .irq = IRQ_IOP331_UART0, 57 .flags = IORESOURCE_MEM,
58 .flags = UPF_SKIP_TEST, 58 },
59 .iotype = UPIO_MEM, 59 [1] = {
60 .regshift = 2, 60 .start = IRQ_IOP331_UART0,
61 .uartclk = IOP331_UART_XTAL, 61 .end = IRQ_IOP331_UART0,
62 .line = 0, 62 .flags = IORESOURCE_IRQ
63 .type = PORT_XSCALE, 63 }
64 .fifosize = 32 64};
65 } , { 65
66 .membase = (char*)(IOP331_UART1_VIRT), 66static struct resource iop33x_uart1_resources[] = {
67 .mapbase = (IOP331_UART1_PHYS), 67 [0] = {
68 .irq = IRQ_IOP331_UART1, 68 .start = IOP331_UART1_PHYS,
69 .flags = UPF_SKIP_TEST, 69 .end = IOP331_UART1_PHYS + 0x3f,
70 .iotype = UPIO_MEM, 70 .flags = IORESOURCE_MEM,
71 .regshift = 2, 71 },
72 .uartclk = IOP331_UART_XTAL, 72 [1] = {
73 .line = 1, 73 .start = IRQ_IOP331_UART1,
74 .type = PORT_XSCALE, 74 .end = IRQ_IOP331_UART1,
75 .fifosize = 32 75 .flags = IORESOURCE_IRQ
76 } 76 }
77}; 77};
78 78
79static struct plat_serial8250_port iop33x_uart0_data[] = {
80 {
81 .membase = (char*)(IOP331_UART0_VIRT),
82 .mapbase = (IOP331_UART0_PHYS),
83 .irq = IRQ_IOP331_UART0,
84 .uartclk = IOP331_UART_XTAL,
85 .regshift = 2,
86 .iotype = UPIO_MEM,
87 .flags = UPF_SKIP_TEST,
88 },
89 { },
90};
91
92static struct plat_serial8250_port iop33x_uart1_data[] = {
93 {
94 .membase = (char*)(IOP331_UART1_VIRT),
95 .mapbase = (IOP331_UART1_PHYS),
96 .irq = IRQ_IOP331_UART1,
97 .uartclk = IOP331_UART_XTAL,
98 .regshift = 2,
99 .iotype = UPIO_MEM,
100 .flags = UPF_SKIP_TEST,
101 },
102 { },
103};
104
105static struct platform_device iop33x_uart0 = {
106 .name = "serial8250",
107 .id = 0,
108 .dev.platform_data = iop33x_uart0_data,
109 .num_resources = 2,
110 .resource = iop33x_uart0_resources,
111};
112
113static struct platform_device iop33x_uart1 = {
114 .name = "serial8250",
115 .id = 1,
116 .dev.platform_data = iop33x_uart1_data,
117 .num_resources = 2,
118 .resource = iop33x_uart1_resources,
119};
120
79static struct resource iop33x_i2c_0_resources[] = { 121static struct resource iop33x_i2c_0_resources[] = {
80 [0] = { 122 [0] = {
81 .start = 0xfffff680, 123 .start = 0xfffff680,
@@ -117,6 +159,8 @@ static struct platform_device iop33x_i2c_1_controller = {
117}; 159};
118 160
119static struct platform_device *iop33x_devices[] __initdata = { 161static struct platform_device *iop33x_devices[] __initdata = {
162 &iop33x_uart0,
163 &iop33x_uart1,
120 &iop33x_i2c_0_controller, 164 &iop33x_i2c_0_controller,
121 &iop33x_i2c_1_controller 165 &iop33x_i2c_1_controller
122}; 166};
@@ -133,8 +177,6 @@ void __init iop33x_init(void)
133void __init iop331_map_io(void) 177void __init iop331_map_io(void)
134{ 178{
135 iotable_init(iop331_std_desc, ARRAY_SIZE(iop331_std_desc)); 179 iotable_init(iop331_std_desc, ARRAY_SIZE(iop331_std_desc));
136 early_serial_setup(&iop331_serial_ports[0]);
137 early_serial_setup(&iop331_serial_ports[1]);
138} 180}
139 181
140#ifdef CONFIG_ARCH_IOP331 182#ifdef CONFIG_ARCH_IOP331
diff --git a/arch/arm/mach-ixp4xx/Kconfig b/arch/arm/mach-ixp4xx/Kconfig
index 385285851cb5..daadc78e271b 100644
--- a/arch/arm/mach-ixp4xx/Kconfig
+++ b/arch/arm/mach-ixp4xx/Kconfig
@@ -71,6 +71,14 @@ config ARCH_PRPMC1100
71 PrPCM1100 Processor Mezanine Module. For more information on 71 PrPCM1100 Processor Mezanine Module. For more information on
72 this platform, see <file:Documentation/arm/IXP4xx>. 72 this platform, see <file:Documentation/arm/IXP4xx>.
73 73
74config MACH_NAS100D
75 bool
76 prompt "NAS100D"
77 help
78 Say 'Y' here if you want your kernel to support Iomega's
79 NAS 100d device. For more information on this platform,
80 see http://www.nslu2-linux.org/wiki/NAS100d/HomePage
81
74# 82#
75# Avila and IXDP share the same source for now. Will change in future 83# Avila and IXDP share the same source for now. Will change in future
76# 84#
diff --git a/arch/arm/mach-ixp4xx/Makefile b/arch/arm/mach-ixp4xx/Makefile
index 7a15629c18d0..0471044fa179 100644
--- a/arch/arm/mach-ixp4xx/Makefile
+++ b/arch/arm/mach-ixp4xx/Makefile
@@ -9,4 +9,5 @@ obj-$(CONFIG_MACH_IXDPG425) += ixdpg425-pci.o coyote-setup.o
9obj-$(CONFIG_ARCH_ADI_COYOTE) += coyote-pci.o coyote-setup.o 9obj-$(CONFIG_ARCH_ADI_COYOTE) += coyote-pci.o coyote-setup.o
10obj-$(CONFIG_MACH_GTWX5715) += gtwx5715-pci.o gtwx5715-setup.o 10obj-$(CONFIG_MACH_GTWX5715) += gtwx5715-pci.o gtwx5715-setup.o
11obj-$(CONFIG_MACH_NSLU2) += nslu2-pci.o nslu2-setup.o nslu2-power.o 11obj-$(CONFIG_MACH_NSLU2) += nslu2-pci.o nslu2-setup.o nslu2-power.o
12obj-$(CONFIG_MACH_NAS100D) += nas100d-pci.o nas100d-setup.o nas100d-power.o
12 13
diff --git a/arch/arm/mach-ixp4xx/common-pci.c b/arch/arm/mach-ixp4xx/common-pci.c
index 9795da270e3a..6e3462ed5306 100644
--- a/arch/arm/mach-ixp4xx/common-pci.c
+++ b/arch/arm/mach-ixp4xx/common-pci.c
@@ -341,6 +341,29 @@ int dma_needs_bounce(struct device *dev, dma_addr_t dma_addr, size_t size)
341 return (dev->bus == &pci_bus_type ) && ((dma_addr + size) >= SZ_64M); 341 return (dev->bus == &pci_bus_type ) && ((dma_addr + size) >= SZ_64M);
342} 342}
343 343
344/*
345 * Only first 64MB of memory can be accessed via PCI.
346 * We use GFP_DMA to allocate safe buffers to do map/unmap.
347 * This is really ugly and we need a better way of specifying
348 * DMA-capable regions of memory.
349 */
350void __init ixp4xx_adjust_zones(int node, unsigned long *zone_size,
351 unsigned long *zhole_size)
352{
353 unsigned int sz = SZ_64M >> PAGE_SHIFT;
354
355 /*
356 * Only adjust if > 64M on current system
357 */
358 if (node || (zone_size[0] <= sz))
359 return;
360
361 zone_size[1] = zone_size[0] - sz;
362 zone_size[0] = sz;
363 zhole_size[1] = zhole_size[0];
364 zhole_size[0] = 0;
365}
366
344void __init ixp4xx_pci_preinit(void) 367void __init ixp4xx_pci_preinit(void)
345{ 368{
346 unsigned long processor_id; 369 unsigned long processor_id;
diff --git a/arch/arm/mach-ixp4xx/common.c b/arch/arm/mach-ixp4xx/common.c
index f3c687cf0071..6b393691d0e8 100644
--- a/arch/arm/mach-ixp4xx/common.c
+++ b/arch/arm/mach-ixp4xx/common.c
@@ -142,6 +142,8 @@ static int ixp4xx_set_irq_type(unsigned int irq, unsigned int type)
142 *int_reg &= ~(IXP4XX_GPIO_STYLE_CLEAR << 142 *int_reg &= ~(IXP4XX_GPIO_STYLE_CLEAR <<
143 (line * IXP4XX_GPIO_STYLE_SIZE)); 143 (line * IXP4XX_GPIO_STYLE_SIZE));
144 144
145 *IXP4XX_GPIO_GPISR = (1 << line);
146
145 /* Set the new style */ 147 /* Set the new style */
146 *int_reg |= (int_style << (line * IXP4XX_GPIO_STYLE_SIZE)); 148 *int_reg |= (int_style << (line * IXP4XX_GPIO_STYLE_SIZE));
147 149
@@ -169,7 +171,7 @@ static void ixp4xx_irq_ack(unsigned int irq)
169 int line = (irq < 32) ? irq2gpio[irq] : -1; 171 int line = (irq < 32) ? irq2gpio[irq] : -1;
170 172
171 if (line >= 0) 173 if (line >= 0)
172 gpio_line_isr_clear(line); 174 *IXP4XX_GPIO_GPISR = (1 << line);
173} 175}
174 176
175/* 177/*
@@ -330,11 +332,27 @@ static struct platform_device *ixp46x_devices[] __initdata = {
330 &ixp46x_i2c_controller 332 &ixp46x_i2c_controller
331}; 333};
332 334
335unsigned long ixp4xx_exp_bus_size;
336
333void __init ixp4xx_sys_init(void) 337void __init ixp4xx_sys_init(void)
334{ 338{
339 ixp4xx_exp_bus_size = SZ_16M;
340
335 if (cpu_is_ixp46x()) { 341 if (cpu_is_ixp46x()) {
342 int region;
343
336 platform_add_devices(ixp46x_devices, 344 platform_add_devices(ixp46x_devices,
337 ARRAY_SIZE(ixp46x_devices)); 345 ARRAY_SIZE(ixp46x_devices));
346
347 for (region = 0; region < 7; region++) {
348 if((*(IXP4XX_EXP_REG(0x4 * region)) & 0x200)) {
349 ixp4xx_exp_bus_size = SZ_32M;
350 break;
351 }
352 }
338 } 353 }
354
355 printk("IXP4xx: Using %uMiB expansion bus window size\n",
356 ixp4xx_exp_bus_size >> 20);
339} 357}
340 358
diff --git a/arch/arm/mach-ixp4xx/coyote-pci.c b/arch/arm/mach-ixp4xx/coyote-pci.c
index 60de8a94cff5..e6b7fcd923fa 100644
--- a/arch/arm/mach-ixp4xx/coyote-pci.c
+++ b/arch/arm/mach-ixp4xx/coyote-pci.c
@@ -33,9 +33,6 @@ void __init coyote_pci_preinit(void)
33 set_irq_type(IRQ_COYOTE_PCI_SLOT0, IRQT_LOW); 33 set_irq_type(IRQ_COYOTE_PCI_SLOT0, IRQT_LOW);
34 set_irq_type(IRQ_COYOTE_PCI_SLOT1, IRQT_LOW); 34 set_irq_type(IRQ_COYOTE_PCI_SLOT1, IRQT_LOW);
35 35
36 gpio_line_isr_clear(COYOTE_PCI_SLOT0_PIN);
37 gpio_line_isr_clear(COYOTE_PCI_SLOT1_PIN);
38
39 ixp4xx_pci_preinit(); 36 ixp4xx_pci_preinit();
40} 37}
41 38
diff --git a/arch/arm/mach-ixp4xx/coyote-setup.c b/arch/arm/mach-ixp4xx/coyote-setup.c
index 050c92768913..679594a73981 100644
--- a/arch/arm/mach-ixp4xx/coyote-setup.c
+++ b/arch/arm/mach-ixp4xx/coyote-setup.c
@@ -14,6 +14,7 @@
14#include <linux/serial.h> 14#include <linux/serial.h>
15#include <linux/tty.h> 15#include <linux/tty.h>
16#include <linux/serial_8250.h> 16#include <linux/serial_8250.h>
17#include <linux/slab.h>
17 18
18#include <asm/types.h> 19#include <asm/types.h>
19#include <asm/setup.h> 20#include <asm/setup.h>
@@ -30,8 +31,6 @@ static struct flash_platform_data coyote_flash_data = {
30}; 31};
31 32
32static struct resource coyote_flash_resource = { 33static struct resource coyote_flash_resource = {
33 .start = COYOTE_FLASH_BASE,
34 .end = COYOTE_FLASH_BASE + COYOTE_FLASH_SIZE - 1,
35 .flags = IORESOURCE_MEM, 34 .flags = IORESOURCE_MEM,
36}; 35};
37 36
@@ -81,6 +80,11 @@ static struct platform_device *coyote_devices[] __initdata = {
81 80
82static void __init coyote_init(void) 81static void __init coyote_init(void)
83{ 82{
83 ixp4xx_sys_init();
84
85 coyote_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
86 coyote_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1;
87
84 *IXP4XX_EXP_CS0 |= IXP4XX_FLASH_WRITABLE; 88 *IXP4XX_EXP_CS0 |= IXP4XX_FLASH_WRITABLE;
85 *IXP4XX_EXP_CS1 = *IXP4XX_EXP_CS0; 89 *IXP4XX_EXP_CS1 = *IXP4XX_EXP_CS0;
86 90
@@ -91,8 +95,6 @@ static void __init coyote_init(void)
91 coyote_uart_data[0].irq = IRQ_IXP4XX_UART1; 95 coyote_uart_data[0].irq = IRQ_IXP4XX_UART1;
92 } 96 }
93 97
94
95 ixp4xx_sys_init();
96 platform_add_devices(coyote_devices, ARRAY_SIZE(coyote_devices)); 98 platform_add_devices(coyote_devices, ARRAY_SIZE(coyote_devices));
97} 99}
98 100
diff --git a/arch/arm/mach-ixp4xx/gtwx5715-setup.c b/arch/arm/mach-ixp4xx/gtwx5715-setup.c
index 29a6d02fa851..038670489970 100644
--- a/arch/arm/mach-ixp4xx/gtwx5715-setup.c
+++ b/arch/arm/mach-ixp4xx/gtwx5715-setup.c
@@ -27,6 +27,7 @@
27#include <linux/serial.h> 27#include <linux/serial.h>
28#include <linux/tty.h> 28#include <linux/tty.h>
29#include <linux/serial_8250.h> 29#include <linux/serial_8250.h>
30#include <linux/slab.h>
30 31
31#include <asm/types.h> 32#include <asm/types.h>
32#include <asm/setup.h> 33#include <asm/setup.h>
@@ -106,11 +107,9 @@ static struct flash_platform_data gtwx5715_flash_data = {
106 .width = 2, 107 .width = 2,
107}; 108};
108 109
109static struct resource gtwx5715_flash_resource = { 110static struct gtw5715_flash_resource = {
110 .start = GTWX5715_FLASH_BASE,
111 .end = GTWX5715_FLASH_BASE + GTWX5715_FLASH_SIZE - 1,
112 .flags = IORESOURCE_MEM, 111 .flags = IORESOURCE_MEM,
113}; 112}
114 113
115static struct platform_device gtwx5715_flash = { 114static struct platform_device gtwx5715_flash = {
116 .name = "IXP4XX-Flash", 115 .name = "IXP4XX-Flash",
@@ -129,6 +128,14 @@ static struct platform_device *gtwx5715_devices[] __initdata = {
129 128
130static void __init gtwx5715_init(void) 129static void __init gtwx5715_init(void)
131{ 130{
131 ixp4xx_sys_init();
132
133 if (!flash_resource)
134 printk(KERN_ERR "Could not allocate flash resource\n");
135
136 gtwx5715_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
137 gtwx5715_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_8M - 1;
138
132 platform_add_devices(gtwx5715_devices, ARRAY_SIZE(gtwx5715_devices)); 139 platform_add_devices(gtwx5715_devices, ARRAY_SIZE(gtwx5715_devices));
133} 140}
134 141
diff --git a/arch/arm/mach-ixp4xx/ixdp425-pci.c b/arch/arm/mach-ixp4xx/ixdp425-pci.c
index f9a1d3e7d692..da415d5d7f37 100644
--- a/arch/arm/mach-ixp4xx/ixdp425-pci.c
+++ b/arch/arm/mach-ixp4xx/ixdp425-pci.c
@@ -32,11 +32,6 @@ void __init ixdp425_pci_preinit(void)
32 set_irq_type(IRQ_IXDP425_PCI_INTC, IRQT_LOW); 32 set_irq_type(IRQ_IXDP425_PCI_INTC, IRQT_LOW);
33 set_irq_type(IRQ_IXDP425_PCI_INTD, IRQT_LOW); 33 set_irq_type(IRQ_IXDP425_PCI_INTD, IRQT_LOW);
34 34
35 gpio_line_isr_clear(IXDP425_PCI_INTA_PIN);
36 gpio_line_isr_clear(IXDP425_PCI_INTB_PIN);
37 gpio_line_isr_clear(IXDP425_PCI_INTC_PIN);
38 gpio_line_isr_clear(IXDP425_PCI_INTD_PIN);
39
40 ixp4xx_pci_preinit(); 35 ixp4xx_pci_preinit();
41} 36}
42 37
diff --git a/arch/arm/mach-ixp4xx/ixdp425-setup.c b/arch/arm/mach-ixp4xx/ixdp425-setup.c
index 3a22d84e1047..c2e105c89c95 100644
--- a/arch/arm/mach-ixp4xx/ixdp425-setup.c
+++ b/arch/arm/mach-ixp4xx/ixdp425-setup.c
@@ -14,6 +14,7 @@
14#include <linux/serial.h> 14#include <linux/serial.h>
15#include <linux/tty.h> 15#include <linux/tty.h>
16#include <linux/serial_8250.h> 16#include <linux/serial_8250.h>
17#include <linux/slab.h>
17 18
18#include <asm/types.h> 19#include <asm/types.h>
19#include <asm/setup.h> 20#include <asm/setup.h>
@@ -30,8 +31,6 @@ static struct flash_platform_data ixdp425_flash_data = {
30}; 31};
31 32
32static struct resource ixdp425_flash_resource = { 33static struct resource ixdp425_flash_resource = {
33 .start = IXDP425_FLASH_BASE,
34 .end = IXDP425_FLASH_BASE + IXDP425_FLASH_SIZE - 1,
35 .flags = IORESOURCE_MEM, 34 .flags = IORESOURCE_MEM,
36}; 35};
37 36
@@ -108,17 +107,13 @@ static struct platform_device *ixdp425_devices[] __initdata = {
108 &ixdp425_uart 107 &ixdp425_uart
109}; 108};
110 109
111
112static void __init ixdp425_init(void) 110static void __init ixdp425_init(void)
113{ 111{
114 ixp4xx_sys_init(); 112 ixp4xx_sys_init();
115 113
116 /* 114 ixdp425_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
117 * IXP465 has 32MB window 115 ixdp425_flash_resource.end =
118 */ 116 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
119 if (machine_is_ixdp465()) {
120 ixdp425_flash_resource.end += IXDP425_FLASH_SIZE;
121 }
122 117
123 platform_add_devices(ixdp425_devices, ARRAY_SIZE(ixdp425_devices)); 118 platform_add_devices(ixdp425_devices, ARRAY_SIZE(ixdp425_devices));
124} 119}
diff --git a/arch/arm/mach-ixp4xx/ixdpg425-pci.c b/arch/arm/mach-ixp4xx/ixdpg425-pci.c
index fe5e7660de1d..526fb6175bc3 100644
--- a/arch/arm/mach-ixp4xx/ixdpg425-pci.c
+++ b/arch/arm/mach-ixp4xx/ixdpg425-pci.c
@@ -32,9 +32,6 @@ void __init ixdpg425_pci_preinit(void)
32 set_irq_type(IRQ_IXP4XX_GPIO6, IRQT_LOW); 32 set_irq_type(IRQ_IXP4XX_GPIO6, IRQT_LOW);
33 set_irq_type(IRQ_IXP4XX_GPIO7, IRQT_LOW); 33 set_irq_type(IRQ_IXP4XX_GPIO7, IRQT_LOW);
34 34
35 gpio_line_isr_clear(6);
36 gpio_line_isr_clear(7);
37
38 ixp4xx_pci_preinit(); 35 ixp4xx_pci_preinit();
39} 36}
40 37
diff --git a/arch/arm/mach-ixp4xx/nas100d-pci.c b/arch/arm/mach-ixp4xx/nas100d-pci.c
new file mode 100644
index 000000000000..26b7c001ff64
--- /dev/null
+++ b/arch/arm/mach-ixp4xx/nas100d-pci.c
@@ -0,0 +1,71 @@
1/*
2 * arch/arm/mach-ixp4xx/nas100d-pci.c
3 *
4 * NAS 100d board-level PCI initialization
5 *
6 * based on ixdp425-pci.c:
7 * Copyright (C) 2002 Intel Corporation.
8 * Copyright (C) 2003-2004 MontaVista Software, Inc.
9 *
10 * Maintainer: http://www.nslu2-linux.org/
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15 *
16 */
17
18#include <linux/config.h>
19#include <linux/pci.h>
20#include <linux/init.h>
21
22#include <asm/mach/pci.h>
23#include <asm/mach-types.h>
24
25void __init nas100d_pci_preinit(void)
26{
27 set_irq_type(IRQ_NAS100D_PCI_INTA, IRQT_LOW);
28 set_irq_type(IRQ_NAS100D_PCI_INTB, IRQT_LOW);
29 set_irq_type(IRQ_NAS100D_PCI_INTC, IRQT_LOW);
30 set_irq_type(IRQ_NAS100D_PCI_INTD, IRQT_LOW);
31 set_irq_type(IRQ_NAS100D_PCI_INTE, IRQT_LOW);
32
33 ixp4xx_pci_preinit();
34}
35
36static int __init nas100d_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
37{
38 static int pci_irq_table[NAS100D_PCI_MAX_DEV][NAS100D_PCI_IRQ_LINES] =
39 {
40 { IRQ_NAS100D_PCI_INTA, -1, -1 },
41 { IRQ_NAS100D_PCI_INTB, -1, -1 },
42 { IRQ_NAS100D_PCI_INTC, IRQ_NAS100D_PCI_INTD, IRQ_NAS100D_PCI_INTE },
43 };
44
45 int irq = -1;
46
47 if (slot >= 1 && slot <= NAS100D_PCI_MAX_DEV &&
48 pin >= 1 && pin <= NAS100D_PCI_IRQ_LINES)
49 irq = pci_irq_table[slot-1][pin-1];
50
51 return irq;
52}
53
54struct hw_pci __initdata nas100d_pci = {
55 .nr_controllers = 1,
56 .preinit = nas100d_pci_preinit,
57 .swizzle = pci_std_swizzle,
58 .setup = ixp4xx_setup,
59 .scan = ixp4xx_scan_bus,
60 .map_irq = nas100d_map_irq,
61};
62
63int __init nas100d_pci_init(void)
64{
65 if (machine_is_nas100d())
66 pci_common_init(&nas100d_pci);
67
68 return 0;
69}
70
71subsys_initcall(nas100d_pci_init);
diff --git a/arch/arm/mach-ixp4xx/nas100d-power.c b/arch/arm/mach-ixp4xx/nas100d-power.c
new file mode 100644
index 000000000000..2bec69bfa715
--- /dev/null
+++ b/arch/arm/mach-ixp4xx/nas100d-power.c
@@ -0,0 +1,67 @@
1/*
2 * arch/arm/mach-ixp4xx/nas100d-power.c
3 *
4 * NAS 100d Power/Reset driver
5 *
6 * Copyright (C) 2005 Tower Technologies
7 *
8 * based on nas100d-io.c
9 * Copyright (C) 2004 Karen Spearel
10 *
11 * Author: Alessandro Zummo <a.zummo@towertech.it>
12 * Maintainers: http://www.nslu2-linux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License version 2 as
16 * published by the Free Software Foundation.
17 *
18 */
19
20#include <linux/module.h>
21#include <linux/reboot.h>
22#include <linux/interrupt.h>
23
24#include <asm/mach-types.h>
25
26extern void ctrl_alt_del(void);
27
28static irqreturn_t nas100d_reset_handler(int irq, void *dev_id, struct pt_regs *regs)
29{
30 /* Signal init to do the ctrlaltdel action, this will bypass init if
31 * it hasn't started and do a kernel_restart.
32 */
33 ctrl_alt_del();
34
35 return IRQ_HANDLED;
36}
37
38static int __init nas100d_power_init(void)
39{
40 if (!(machine_is_nas100d()))
41 return 0;
42
43 set_irq_type(NAS100D_RB_IRQ, IRQT_LOW);
44
45 if (request_irq(NAS100D_RB_IRQ, &nas100d_reset_handler,
46 SA_INTERRUPT, "NAS100D reset button", NULL) < 0) {
47
48 printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
49 NAS100D_RB_IRQ);
50
51 return -EIO;
52 }
53
54 return 0;
55}
56
57static void __exit nas100d_power_exit(void)
58{
59 free_irq(NAS100D_RB_IRQ, NULL);
60}
61
62module_init(nas100d_power_init);
63module_exit(nas100d_power_exit);
64
65MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");
66MODULE_DESCRIPTION("NAS100D Power/Reset driver");
67MODULE_LICENSE("GPL");
diff --git a/arch/arm/mach-ixp4xx/nas100d-setup.c b/arch/arm/mach-ixp4xx/nas100d-setup.c
new file mode 100644
index 000000000000..49998a8bd4e8
--- /dev/null
+++ b/arch/arm/mach-ixp4xx/nas100d-setup.c
@@ -0,0 +1,135 @@
1/*
2 * arch/arm/mach-ixp4xx/nas100d-setup.c
3 *
4 * NAS 100d board-setup
5 *
6 * based ixdp425-setup.c:
7 * Copyright (C) 2003-2004 MontaVista Software, Inc.
8 *
9 * Author: Alessandro Zummo <a.zummo@towertech.it>
10 * Author: Rod Whitby <rod@whitby.id.au>
11 * Maintainers: http://www.nslu2-linux.org/
12 *
13 */
14
15#include <linux/kernel.h>
16#include <linux/serial.h>
17#include <linux/serial_8250.h>
18
19#include <asm/mach-types.h>
20#include <asm/mach/arch.h>
21#include <asm/mach/flash.h>
22
23static struct flash_platform_data nas100d_flash_data = {
24 .map_name = "cfi_probe",
25 .width = 2,
26};
27
28static struct resource nas100d_flash_resource = {
29 .flags = IORESOURCE_MEM,
30};
31
32static struct platform_device nas100d_flash = {
33 .name = "IXP4XX-Flash",
34 .id = 0,
35 .dev.platform_data = &nas100d_flash_data,
36 .num_resources = 1,
37 .resource = &nas100d_flash_resource,
38};
39
40static struct ixp4xx_i2c_pins nas100d_i2c_gpio_pins = {
41 .sda_pin = NAS100D_SDA_PIN,
42 .scl_pin = NAS100D_SCL_PIN,
43};
44
45static struct platform_device nas100d_i2c_controller = {
46 .name = "IXP4XX-I2C",
47 .id = 0,
48 .dev.platform_data = &nas100d_i2c_gpio_pins,
49 .num_resources = 0,
50};
51
52static struct resource nas100d_uart_resources[] = {
53 {
54 .start = IXP4XX_UART1_BASE_PHYS,
55 .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
56 .flags = IORESOURCE_MEM,
57 },
58 {
59 .start = IXP4XX_UART2_BASE_PHYS,
60 .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
61 .flags = IORESOURCE_MEM,
62 }
63};
64
65static struct plat_serial8250_port nas100d_uart_data[] = {
66 {
67 .mapbase = IXP4XX_UART1_BASE_PHYS,
68 .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
69 .irq = IRQ_IXP4XX_UART1,
70 .flags = UPF_BOOT_AUTOCONF,
71 .iotype = UPIO_MEM,
72 .regshift = 2,
73 .uartclk = IXP4XX_UART_XTAL,
74 },
75 {
76 .mapbase = IXP4XX_UART2_BASE_PHYS,
77 .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
78 .irq = IRQ_IXP4XX_UART2,
79 .flags = UPF_BOOT_AUTOCONF,
80 .iotype = UPIO_MEM,
81 .regshift = 2,
82 .uartclk = IXP4XX_UART_XTAL,
83 },
84 { }
85};
86
87static struct platform_device nas100d_uart = {
88 .name = "serial8250",
89 .id = PLAT8250_DEV_PLATFORM,
90 .dev.platform_data = nas100d_uart_data,
91 .num_resources = 2,
92 .resource = nas100d_uart_resources,
93};
94
95static struct platform_device *nas100d_devices[] __initdata = {
96 &nas100d_i2c_controller,
97 &nas100d_flash,
98 &nas100d_uart,
99};
100
101static void nas100d_power_off(void)
102{
103 /* This causes the box to drop the power and go dead. */
104
105 /* enable the pwr cntl gpio */
106 gpio_line_config(NAS100D_PO_GPIO, IXP4XX_GPIO_OUT);
107
108 /* do the deed */
109 gpio_line_set(NAS100D_PO_GPIO, IXP4XX_GPIO_HIGH);
110}
111
112static void __init nas100d_init(void)
113{
114 ixp4xx_sys_init();
115
116 nas100d_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
117 nas100d_flash_resource.end =
118 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
119
120 pm_power_off = nas100d_power_off;
121
122 platform_add_devices(nas100d_devices, ARRAY_SIZE(nas100d_devices));
123}
124
125MACHINE_START(NAS100D, "Iomega NAS 100d")
126 /* Maintainer: www.nslu2-linux.org */
127 .phys_ram = PHYS_OFFSET,
128 .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
129 .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC,
130 .boot_params = 0x00000100,
131 .map_io = ixp4xx_map_io,
132 .init_irq = ixp4xx_init_irq,
133 .timer = &ixp4xx_timer,
134 .init_machine = nas100d_init,
135MACHINE_END
diff --git a/arch/arm/mach-ixp4xx/nslu2-pci.c b/arch/arm/mach-ixp4xx/nslu2-pci.c
index a575f2e0b2c8..ece860444d5b 100644
--- a/arch/arm/mach-ixp4xx/nslu2-pci.c
+++ b/arch/arm/mach-ixp4xx/nslu2-pci.c
@@ -28,14 +28,6 @@ void __init nslu2_pci_preinit(void)
28 set_irq_type(IRQ_NSLU2_PCI_INTB, IRQT_LOW); 28 set_irq_type(IRQ_NSLU2_PCI_INTB, IRQT_LOW);
29 set_irq_type(IRQ_NSLU2_PCI_INTC, IRQT_LOW); 29 set_irq_type(IRQ_NSLU2_PCI_INTC, IRQT_LOW);
30 30
31 gpio_line_isr_clear(NSLU2_PCI_INTA_PIN);
32 gpio_line_isr_clear(NSLU2_PCI_INTB_PIN);
33 gpio_line_isr_clear(NSLU2_PCI_INTC_PIN);
34
35 /* INTD is not configured as GPIO is used
36 * for the power input button.
37 */
38
39 ixp4xx_pci_preinit(); 31 ixp4xx_pci_preinit();
40} 32}
41 33
diff --git a/arch/arm/mach-ixp4xx/nslu2-power.c b/arch/arm/mach-ixp4xx/nslu2-power.c
index 18fbc8c0fb30..b0ad9e901f6e 100644
--- a/arch/arm/mach-ixp4xx/nslu2-power.c
+++ b/arch/arm/mach-ixp4xx/nslu2-power.c
@@ -54,9 +54,6 @@ static int __init nslu2_power_init(void)
54 set_irq_type(NSLU2_RB_IRQ, IRQT_LOW); 54 set_irq_type(NSLU2_RB_IRQ, IRQT_LOW);
55 set_irq_type(NSLU2_PB_IRQ, IRQT_HIGH); 55 set_irq_type(NSLU2_PB_IRQ, IRQT_HIGH);
56 56
57 gpio_line_isr_clear(NSLU2_RB_GPIO);
58 gpio_line_isr_clear(NSLU2_PB_GPIO);
59
60 if (request_irq(NSLU2_RB_IRQ, &nslu2_reset_handler, 57 if (request_irq(NSLU2_RB_IRQ, &nslu2_reset_handler,
61 SA_INTERRUPT, "NSLU2 reset button", NULL) < 0) { 58 SA_INTERRUPT, "NSLU2 reset button", NULL) < 0) {
62 59
diff --git a/arch/arm/mach-omap1/board-palmte.c b/arch/arm/mach-omap1/board-palmte.c
index 540b20d78cca..5c975eb5c34b 100644
--- a/arch/arm/mach-omap1/board-palmte.c
+++ b/arch/arm/mach-omap1/board-palmte.c
@@ -19,6 +19,7 @@
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/notifier.h> 21#include <linux/notifier.h>
22#include <linux/clk.h>
22 23
23#include <asm/hardware.h> 24#include <asm/hardware.h>
24#include <asm/mach-types.h> 25#include <asm/mach-types.h>
@@ -30,7 +31,6 @@
30#include <asm/arch/usb.h> 31#include <asm/arch/usb.h>
31#include <asm/arch/board.h> 32#include <asm/arch/board.h>
32#include <asm/arch/common.h> 33#include <asm/arch/common.h>
33#include <asm/hardware/clock.h>
34 34
35static void __init omap_generic_init_irq(void) 35static void __init omap_generic_init_irq(void)
36{ 36{
diff --git a/arch/arm/mach-omap1/clock.c b/arch/arm/mach-omap1/clock.c
index 4277eee44ed5..9d862f86bba6 100644
--- a/arch/arm/mach-omap1/clock.c
+++ b/arch/arm/mach-omap1/clock.c
@@ -16,9 +16,9 @@
16#include <linux/list.h> 16#include <linux/list.h>
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/err.h> 18#include <linux/err.h>
19#include <linux/clk.h>
19 20
20#include <asm/io.h> 21#include <asm/io.h>
21#include <asm/hardware/clock.h>
22 22
23#include <asm/arch/usb.h> 23#include <asm/arch/usb.h>
24#include <asm/arch/clock.h> 24#include <asm/arch/clock.h>
diff --git a/arch/arm/mach-omap1/serial.c b/arch/arm/mach-omap1/serial.c
index 6810cfb84462..fcfb81d13cfe 100644
--- a/arch/arm/mach-omap1/serial.c
+++ b/arch/arm/mach-omap1/serial.c
@@ -17,10 +17,10 @@
17#include <linux/tty.h> 17#include <linux/tty.h>
18#include <linux/serial_8250.h> 18#include <linux/serial_8250.h>
19#include <linux/serial_reg.h> 19#include <linux/serial_reg.h>
20#include <linux/clk.h>
20 21
21#include <asm/io.h> 22#include <asm/io.h>
22#include <asm/mach-types.h> 23#include <asm/mach-types.h>
23#include <asm/hardware/clock.h>
24 24
25#include <asm/arch/board.h> 25#include <asm/arch/board.h>
26#include <asm/arch/mux.h> 26#include <asm/arch/mux.h>
diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c
index 85818d9f2635..5407b9549150 100644
--- a/arch/arm/mach-omap2/clock.c
+++ b/arch/arm/mach-omap2/clock.c
@@ -22,10 +22,10 @@
22#include <linux/list.h> 22#include <linux/list.h>
23#include <linux/errno.h> 23#include <linux/errno.h>
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/clk.h>
25 26
26#include <asm/io.h> 27#include <asm/io.h>
27 28
28#include <asm/hardware/clock.h>
29#include <asm/arch/clock.h> 29#include <asm/arch/clock.h>
30#include <asm/arch/sram.h> 30#include <asm/arch/sram.h>
31#include <asm/arch/prcm.h> 31#include <asm/arch/prcm.h>
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index f4df04fe1dd8..e1bd46a96e11 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -16,9 +16,9 @@
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/serial_8250.h> 17#include <linux/serial_8250.h>
18#include <linux/serial_reg.h> 18#include <linux/serial_reg.h>
19#include <linux/clk.h>
19 20
20#include <asm/io.h> 21#include <asm/io.h>
21#include <asm/hardware/clock.h>
22 22
23#include <asm/arch/common.h> 23#include <asm/arch/common.h>
24#include <asm/arch/board.h> 24#include <asm/arch/board.h>
diff --git a/arch/arm/mach-omap2/timer-gp.c b/arch/arm/mach-omap2/timer-gp.c
index 9ec11443200f..23d36b1c40fe 100644
--- a/arch/arm/mach-omap2/timer-gp.c
+++ b/arch/arm/mach-omap2/timer-gp.c
@@ -21,10 +21,11 @@
21#include <linux/time.h> 21#include <linux/time.h>
22#include <linux/interrupt.h> 22#include <linux/interrupt.h>
23#include <linux/err.h> 23#include <linux/err.h>
24#include <linux/clk.h>
25
24#include <asm/mach/time.h> 26#include <asm/mach/time.h>
25#include <asm/delay.h> 27#include <asm/delay.h>
26#include <asm/io.h> 28#include <asm/io.h>
27#include <asm/hardware/clock.h>
28 29
29#define OMAP2_GP_TIMER1_BASE 0x48028000 30#define OMAP2_GP_TIMER1_BASE 0x48028000
30#define OMAP2_GP_TIMER2_BASE 0x4802a000 31#define OMAP2_GP_TIMER2_BASE 0x4802a000
diff --git a/arch/arm/mach-pxa/Kconfig b/arch/arm/mach-pxa/Kconfig
index 2a58499c0968..c1d77f5b3823 100644
--- a/arch/arm/mach-pxa/Kconfig
+++ b/arch/arm/mach-pxa/Kconfig
@@ -112,12 +112,14 @@ config IWMMXT
112config PXA_SHARP_C7xx 112config PXA_SHARP_C7xx
113 bool 113 bool
114 select PXA_SSP 114 select PXA_SSP
115 select SHARPSL_PM
115 help 116 help
116 Enable support for all Sharp C7xx models 117 Enable support for all Sharp C7xx models
117 118
118config PXA_SHARP_Cxx00 119config PXA_SHARP_Cxx00
119 bool 120 bool
120 select PXA_SSP 121 select PXA_SSP
122 select SHARPSL_PM
121 help 123 help
122 Enable common support for Sharp Cxx00 models 124 Enable common support for Sharp Cxx00 models
123 125
diff --git a/arch/arm/mach-pxa/corgi_pm.c b/arch/arm/mach-pxa/corgi_pm.c
index 599be14754f9..7a1ab73e9e10 100644
--- a/arch/arm/mach-pxa/corgi_pm.c
+++ b/arch/arm/mach-pxa/corgi_pm.c
@@ -33,19 +33,7 @@ static void corgi_charger_init(void)
33 pxa_gpio_mode(CORGI_GPIO_CHRG_ON | GPIO_OUT); 33 pxa_gpio_mode(CORGI_GPIO_CHRG_ON | GPIO_OUT);
34 pxa_gpio_mode(CORGI_GPIO_CHRG_UKN | GPIO_OUT); 34 pxa_gpio_mode(CORGI_GPIO_CHRG_UKN | GPIO_OUT);
35 pxa_gpio_mode(CORGI_GPIO_KEY_INT | GPIO_IN); 35 pxa_gpio_mode(CORGI_GPIO_KEY_INT | GPIO_IN);
36} 36 sharpsl_pm_pxa_init();
37
38static void corgi_charge_led(int val)
39{
40 if (val == SHARPSL_LED_ERROR) {
41 dev_dbg(sharpsl_pm.dev, "Charge LED Error\n");
42 } else if (val == SHARPSL_LED_ON) {
43 dev_dbg(sharpsl_pm.dev, "Charge LED On\n");
44 GPSR0 = GPIO_bit(CORGI_GPIO_LED_ORANGE);
45 } else {
46 dev_dbg(sharpsl_pm.dev, "Charge LED Off\n");
47 GPCR0 = GPIO_bit(CORGI_GPIO_LED_ORANGE);
48 }
49} 37}
50 38
51static void corgi_measure_temp(int on) 39static void corgi_measure_temp(int on)
@@ -138,15 +126,15 @@ static int corgi_should_wakeup(unsigned int resume_on_alarm)
138 dev_dbg(sharpsl_pm.dev, "GPLR0 = %x,%x\n", GPLR0, PEDR); 126 dev_dbg(sharpsl_pm.dev, "GPLR0 = %x,%x\n", GPLR0, PEDR);
139 127
140 if ((PEDR & GPIO_bit(CORGI_GPIO_AC_IN))) { 128 if ((PEDR & GPIO_bit(CORGI_GPIO_AC_IN))) {
141 if (STATUS_AC_IN()) { 129 if (sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN)) {
142 /* charge on */ 130 /* charge on */
143 dev_dbg(sharpsl_pm.dev, "ac insert\n"); 131 dev_dbg(sharpsl_pm.dev, "ac insert\n");
144 sharpsl_pm.flags |= SHARPSL_DO_OFFLINE_CHRG; 132 sharpsl_pm.flags |= SHARPSL_DO_OFFLINE_CHRG;
145 } else { 133 } else {
146 /* charge off */ 134 /* charge off */
147 dev_dbg(sharpsl_pm.dev, "ac remove\n"); 135 dev_dbg(sharpsl_pm.dev, "ac remove\n");
148 CHARGE_LED_OFF(); 136 sharpsl_pm_led(SHARPSL_LED_OFF);
149 CHARGE_OFF(); 137 sharpsl_pm.machinfo->charge(0);
150 sharpsl_pm.charge_mode = CHRG_OFF; 138 sharpsl_pm.charge_mode = CHRG_OFF;
151 } 139 }
152 } 140 }
@@ -172,23 +160,39 @@ static unsigned long corgi_charger_wakeup(void)
172 return ~GPLR0 & ( GPIO_bit(CORGI_GPIO_AC_IN) | GPIO_bit(CORGI_GPIO_KEY_INT) | GPIO_bit(CORGI_GPIO_WAKEUP) ); 160 return ~GPLR0 & ( GPIO_bit(CORGI_GPIO_AC_IN) | GPIO_bit(CORGI_GPIO_KEY_INT) | GPIO_bit(CORGI_GPIO_WAKEUP) );
173} 161}
174 162
175static int corgi_acin_status(void) 163unsigned long corgipm_read_devdata(int type)
176{ 164{
177 return ((GPLR(CORGI_GPIO_AC_IN) & GPIO_bit(CORGI_GPIO_AC_IN)) != 0); 165 switch(type) {
166 case SHARPSL_STATUS_ACIN:
167 return ((GPLR(CORGI_GPIO_AC_IN) & GPIO_bit(CORGI_GPIO_AC_IN)) != 0);
168 case SHARPSL_STATUS_LOCK:
169 return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batlock);
170 case SHARPSL_STATUS_CHRGFULL:
171 return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batfull);
172 case SHARPSL_STATUS_FATAL:
173 return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_fatal);
174 case SHARPSL_ACIN_VOLT:
175 return sharpsl_pm_pxa_read_max1111(MAX1111_ACIN_VOLT);
176 case SHARPSL_BATT_TEMP:
177 return sharpsl_pm_pxa_read_max1111(MAX1111_BATT_TEMP);
178 case SHARPSL_BATT_VOLT:
179 default:
180 return sharpsl_pm_pxa_read_max1111(MAX1111_BATT_VOLT);
181 }
178} 182}
179 183
180static struct sharpsl_charger_machinfo corgi_pm_machinfo = { 184static struct sharpsl_charger_machinfo corgi_pm_machinfo = {
181 .init = corgi_charger_init, 185 .init = corgi_charger_init,
186 .exit = sharpsl_pm_pxa_remove,
182 .gpio_batlock = CORGI_GPIO_BAT_COVER, 187 .gpio_batlock = CORGI_GPIO_BAT_COVER,
183 .gpio_acin = CORGI_GPIO_AC_IN, 188 .gpio_acin = CORGI_GPIO_AC_IN,
184 .gpio_batfull = CORGI_GPIO_CHRG_FULL, 189 .gpio_batfull = CORGI_GPIO_CHRG_FULL,
185 .status_acin = corgi_acin_status,
186 .discharge = corgi_discharge, 190 .discharge = corgi_discharge,
187 .charge = corgi_charge, 191 .charge = corgi_charge,
188 .chargeled = corgi_charge_led,
189 .measure_temp = corgi_measure_temp, 192 .measure_temp = corgi_measure_temp,
190 .presuspend = corgi_presuspend, 193 .presuspend = corgi_presuspend,
191 .postsuspend = corgi_postsuspend, 194 .postsuspend = corgi_postsuspend,
195 .read_devdata = corgipm_read_devdata,
192 .charger_wakeup = corgi_charger_wakeup, 196 .charger_wakeup = corgi_charger_wakeup,
193 .should_wakeup = corgi_should_wakeup, 197 .should_wakeup = corgi_should_wakeup,
194 .bat_levels = 40, 198 .bat_levels = 40,
diff --git a/arch/arm/mach-pxa/mainstone.c b/arch/arm/mach-pxa/mainstone.c
index 277498ae5b6c..8da9d3efe9a0 100644
--- a/arch/arm/mach-pxa/mainstone.c
+++ b/arch/arm/mach-pxa/mainstone.c
@@ -427,6 +427,12 @@ static void __init mainstone_init(void)
427 printk(KERN_NOTICE "Mainstone configured to boot from %s\n", 427 printk(KERN_NOTICE "Mainstone configured to boot from %s\n",
428 mst_flash_data[0].name); 428 mst_flash_data[0].name);
429 429
430 /* system bus arbiter setting
431 * - Core_Park
432 * - LCD_wt:DMA_wt:CORE_Wt = 2:3:4
433 */
434 ARB_CNTRL = ARB_CORE_PARK | 0x234;
435
430 /* 436 /*
431 * On Mainstone, we route AC97_SYSCLK via GPIO45 to 437 * On Mainstone, we route AC97_SYSCLK via GPIO45 to
432 * the audio daughter card 438 * the audio daughter card
diff --git a/arch/arm/mach-pxa/sharpsl.h b/arch/arm/mach-pxa/sharpsl.h
index b0c40a1d6671..da4769caaf72 100644
--- a/arch/arm/mach-pxa/sharpsl.h
+++ b/arch/arm/mach-pxa/sharpsl.h
@@ -1,7 +1,17 @@
1/* 1/*
2 * SharpSL SSP Driver 2 * Copyright (c) 2004-2005 Richard Purdie
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
3 */ 8 */
4 9
10#include <asm/hardware/sharpsl_pm.h>
11
12/*
13 * SharpSL SSP Driver
14 */
5struct corgissp_machinfo { 15struct corgissp_machinfo {
6 int port; 16 int port;
7 int cs_lcdcon; 17 int cs_lcdcon;
@@ -14,18 +24,18 @@ struct corgissp_machinfo {
14 24
15void corgi_ssp_set_machinfo(struct corgissp_machinfo *machinfo); 25void corgi_ssp_set_machinfo(struct corgissp_machinfo *machinfo);
16 26
27
17/* 28/*
18 * SharpSL Backlight 29 * SharpSL Backlight
19 */ 30 */
20
21void corgi_bl_set_intensity(int intensity); 31void corgi_bl_set_intensity(int intensity);
22void spitz_bl_set_intensity(int intensity); 32void spitz_bl_set_intensity(int intensity);
23void akita_bl_set_intensity(int intensity); 33void akita_bl_set_intensity(int intensity);
24 34
35
25/* 36/*
26 * SharpSL Touchscreen Driver 37 * SharpSL Touchscreen Driver
27 */ 38 */
28
29unsigned long corgi_get_hsync_len(void); 39unsigned long corgi_get_hsync_len(void);
30unsigned long spitz_get_hsync_len(void); 40unsigned long spitz_get_hsync_len(void);
31void corgi_put_hsync(void); 41void corgi_put_hsync(void);
@@ -33,89 +43,22 @@ void spitz_put_hsync(void);
33void corgi_wait_hsync(void); 43void corgi_wait_hsync(void);
34void spitz_wait_hsync(void); 44void spitz_wait_hsync(void);
35 45
46
36/* 47/*
37 * SharpSL Battery/PM Driver 48 * SharpSL Battery/PM Driver
38 */ 49 */
39 50
40struct sharpsl_charger_machinfo { 51#define READ_GPIO_BIT(x) (GPLR(x) & GPIO_bit(x))
41 void (*init)(void);
42 int gpio_acin;
43 int gpio_batfull;
44 int gpio_batlock;
45 int gpio_fatal;
46 int (*status_acin)(void);
47 void (*discharge)(int);
48 void (*discharge1)(int);
49 void (*charge)(int);
50 void (*chargeled)(int);
51 void (*measure_temp)(int);
52 void (*presuspend)(void);
53 void (*postsuspend)(void);
54 unsigned long (*charger_wakeup)(void);
55 int (*should_wakeup)(unsigned int resume_on_alarm);
56 int bat_levels;
57 struct battery_thresh *bat_levels_noac;
58 struct battery_thresh *bat_levels_acin;
59 int status_high_acin;
60 int status_low_acin;
61 int status_high_noac;
62 int status_low_noac;
63};
64
65struct battery_thresh {
66 int voltage;
67 int percentage;
68};
69
70struct battery_stat {
71 int ac_status; /* APM AC Present/Not Present */
72 int mainbat_status; /* APM Main Battery Status */
73 int mainbat_percent; /* Main Battery Percentage Charge */
74 int mainbat_voltage; /* Main Battery Voltage */
75};
76
77struct sharpsl_pm_status {
78 struct device *dev;
79 struct timer_list ac_timer;
80 struct timer_list chrg_full_timer;
81
82 int charge_mode;
83#define CHRG_ERROR (-1)
84#define CHRG_OFF (0)
85#define CHRG_ON (1)
86#define CHRG_DONE (2)
87
88 unsigned int flags;
89#define SHARPSL_SUSPENDED (1 << 0) /* Device is Suspended */
90#define SHARPSL_ALARM_ACTIVE (1 << 1) /* Alarm is for charging event (not user) */
91#define SHARPSL_BL_LIMIT (1 << 2) /* Backlight Intensity Limited */
92#define SHARPSL_APM_QUEUED (1 << 3) /* APM Event Queued */
93#define SHARPSL_DO_OFFLINE_CHRG (1 << 4) /* Trigger the offline charger */
94 52
95 int full_count; 53/* MAX1111 Channel Definitions */
96 unsigned long charge_start_time; 54#define MAX1111_BATT_VOLT 4u
97 struct sharpsl_charger_machinfo *machinfo; 55#define MAX1111_BATT_TEMP 2u
98 struct battery_stat battstat; 56#define MAX1111_ACIN_VOLT 6u
99};
100 57
101extern struct sharpsl_pm_status sharpsl_pm;
102extern struct battery_thresh spitz_battery_levels_acin[]; 58extern struct battery_thresh spitz_battery_levels_acin[];
103extern struct battery_thresh spitz_battery_levels_noac[]; 59extern struct battery_thresh spitz_battery_levels_noac[];
60void sharpsl_pm_pxa_init(void);
61void sharpsl_pm_pxa_remove(void);
62int sharpsl_pm_pxa_read_max1111(int channel);
104 63
105#define READ_GPIO_BIT(x) (GPLR(x) & GPIO_bit(x))
106
107#define SHARPSL_LED_ERROR 2
108#define SHARPSL_LED_ON 1
109#define SHARPSL_LED_OFF 0
110 64
111#define CHARGE_ON() sharpsl_pm.machinfo->charge(1)
112#define CHARGE_OFF() sharpsl_pm.machinfo->charge(0)
113#define CHARGE_LED_ON() sharpsl_pm.machinfo->chargeled(SHARPSL_LED_ON)
114#define CHARGE_LED_OFF() sharpsl_pm.machinfo->chargeled(SHARPSL_LED_OFF)
115#define CHARGE_LED_ERR() sharpsl_pm.machinfo->chargeled(SHARPSL_LED_ERROR)
116#define DISCHARGE_ON() sharpsl_pm.machinfo->discharge(1)
117#define DISCHARGE_OFF() sharpsl_pm.machinfo->discharge(0)
118#define STATUS_AC_IN() sharpsl_pm.machinfo->status_acin()
119#define STATUS_BATT_LOCKED() READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batlock)
120#define STATUS_CHRG_FULL() READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batfull)
121#define STATUS_FATAL() READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_fatal)
diff --git a/arch/arm/mach-pxa/sharpsl_pm.c b/arch/arm/mach-pxa/sharpsl_pm.c
index c10be00fb526..6d402b262d8a 100644
--- a/arch/arm/mach-pxa/sharpsl_pm.c
+++ b/arch/arm/mach-pxa/sharpsl_pm.c
@@ -15,48 +15,20 @@
15#undef DEBUG 15#undef DEBUG
16 16
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/timer.h>
19#include <linux/init.h> 18#include <linux/init.h>
20#include <linux/kernel.h> 19#include <linux/kernel.h>
21#include <linux/apm_bios.h>
22#include <linux/delay.h>
23#include <linux/interrupt.h> 20#include <linux/interrupt.h>
24#include <linux/platform_device.h> 21#include <linux/platform_device.h>
25 22
26#include <asm/hardware.h> 23#include <asm/hardware.h>
27#include <asm/hardware/scoop.h>
28#include <asm/mach-types.h> 24#include <asm/mach-types.h>
29#include <asm/irq.h> 25#include <asm/irq.h>
30#include <asm/apm.h> 26#include <asm/apm.h>
31
32#include <asm/arch/pm.h> 27#include <asm/arch/pm.h>
33#include <asm/arch/pxa-regs.h> 28#include <asm/arch/pxa-regs.h>
34#include <asm/arch/sharpsl.h> 29#include <asm/arch/sharpsl.h>
35#include "sharpsl.h" 30#include "sharpsl.h"
36 31
37/*
38 * Constants
39 */
40#define SHARPSL_CHARGE_ON_TIME_INTERVAL (msecs_to_jiffies(1*60*1000)) /* 1 min */
41#define SHARPSL_CHARGE_FINISH_TIME (msecs_to_jiffies(10*60*1000)) /* 10 min */
42#define SHARPSL_BATCHK_TIME (msecs_to_jiffies(15*1000)) /* 15 sec */
43#define SHARPSL_BATCHK_TIME_SUSPEND (60*10) /* 10 min */
44#define SHARPSL_WAIT_CO_TIME 15 /* 15 sec */
45#define SHARPSL_WAIT_DISCHARGE_ON 100 /* 100 msec */
46#define SHARPSL_CHECK_BATTERY_WAIT_TIME_TEMP 10 /* 10 msec */
47#define SHARPSL_CHECK_BATTERY_WAIT_TIME_VOLT 10 /* 10 msec */
48#define SHARPSL_CHECK_BATTERY_WAIT_TIME_ACIN 10 /* 10 msec */
49#define SHARPSL_CHARGE_WAIT_TIME 15 /* 15 msec */
50#define SHARPSL_CHARGE_CO_CHECK_TIME 5 /* 5 msec */
51#define SHARPSL_CHARGE_RETRY_CNT 1 /* eqv. 10 min */
52
53#define SHARPSL_CHARGE_ON_VOLT 0x99 /* 2.9V */
54#define SHARPSL_CHARGE_ON_TEMP 0xe0 /* 2.9V */
55#define SHARPSL_CHARGE_ON_ACIN_HIGH 0x9b /* 6V */
56#define SHARPSL_CHARGE_ON_ACIN_LOW 0x34 /* 2V */
57#define SHARPSL_FATAL_ACIN_VOLT 182 /* 3.45V */
58#define SHARPSL_FATAL_NOACIN_VOLT 170 /* 3.40V */
59
60struct battery_thresh spitz_battery_levels_acin[] = { 32struct battery_thresh spitz_battery_levels_acin[] = {
61 { 213, 100}, 33 { 213, 100},
62 { 212, 98}, 34 { 212, 98},
@@ -151,763 +123,17 @@ struct battery_thresh spitz_battery_levels_noac[] = {
151#define MAXCTRL_SEL_SH 4 123#define MAXCTRL_SEL_SH 4
152#define MAXCTRL_STR 1u << 7 124#define MAXCTRL_STR 1u << 7
153 125
154/* MAX1111 Channel Definitions */
155#define BATT_AD 4u
156#define BATT_THM 2u
157#define JK_VAD 6u
158
159
160/*
161 * Prototypes
162 */
163static int sharpsl_read_main_battery(void);
164static int sharpsl_off_charge_battery(void);
165static int sharpsl_check_battery_temp(void);
166static int sharpsl_check_battery_voltage(void);
167static int sharpsl_ac_check(void);
168static int sharpsl_fatal_check(void);
169static int sharpsl_average_value(int ad);
170static void sharpsl_average_clear(void);
171static void sharpsl_charge_toggle(void *private_);
172static void sharpsl_battery_thread(void *private_);
173
174
175/*
176 * Variables
177 */
178struct sharpsl_pm_status sharpsl_pm;
179DECLARE_WORK(toggle_charger, sharpsl_charge_toggle, NULL);
180DECLARE_WORK(sharpsl_bat, sharpsl_battery_thread, NULL);
181
182
183static int get_percentage(int voltage)
184{
185 int i = sharpsl_pm.machinfo->bat_levels - 1;
186 struct battery_thresh *thresh;
187
188 if (sharpsl_pm.charge_mode == CHRG_ON)
189 thresh=sharpsl_pm.machinfo->bat_levels_acin;
190 else
191 thresh=sharpsl_pm.machinfo->bat_levels_noac;
192
193 while (i > 0 && (voltage > thresh[i].voltage))
194 i--;
195
196 return thresh[i].percentage;
197}
198
199static int get_apm_status(int voltage)
200{
201 int low_thresh, high_thresh;
202
203 if (sharpsl_pm.charge_mode == CHRG_ON) {
204 high_thresh = sharpsl_pm.machinfo->status_high_acin;
205 low_thresh = sharpsl_pm.machinfo->status_low_acin;
206 } else {
207 high_thresh = sharpsl_pm.machinfo->status_high_noac;
208 low_thresh = sharpsl_pm.machinfo->status_low_noac;
209 }
210
211 if (voltage >= high_thresh)
212 return APM_BATTERY_STATUS_HIGH;
213 if (voltage >= low_thresh)
214 return APM_BATTERY_STATUS_LOW;
215 return APM_BATTERY_STATUS_CRITICAL;
216}
217
218void sharpsl_battery_kick(void)
219{
220 schedule_delayed_work(&sharpsl_bat, msecs_to_jiffies(125));
221}
222EXPORT_SYMBOL(sharpsl_battery_kick);
223
224
225static void sharpsl_battery_thread(void *private_)
226{
227 int voltage, percent, apm_status, i = 0;
228
229 if (!sharpsl_pm.machinfo)
230 return;
231
232 sharpsl_pm.battstat.ac_status = (STATUS_AC_IN() ? APM_AC_ONLINE : APM_AC_OFFLINE);
233
234 /* Corgi cannot confirm when battery fully charged so periodically kick! */
235 if (machine_is_corgi() && (sharpsl_pm.charge_mode == CHRG_ON)
236 && time_after(jiffies, sharpsl_pm.charge_start_time + SHARPSL_CHARGE_ON_TIME_INTERVAL))
237 schedule_work(&toggle_charger);
238
239 while(1) {
240 voltage = sharpsl_read_main_battery();
241 if (voltage > 0) break;
242 if (i++ > 5) {
243 voltage = sharpsl_pm.machinfo->bat_levels_noac[0].voltage;
244 dev_warn(sharpsl_pm.dev, "Warning: Cannot read main battery!\n");
245 break;
246 }
247 }
248
249 voltage = sharpsl_average_value(voltage);
250 apm_status = get_apm_status(voltage);
251 percent = get_percentage(voltage);
252
253 /* At low battery voltages, the voltage has a tendency to start
254 creeping back up so we try to avoid this here */
255 if ((sharpsl_pm.battstat.ac_status == APM_AC_ONLINE) || (apm_status == APM_BATTERY_STATUS_HIGH) || percent <= sharpsl_pm.battstat.mainbat_percent) {
256 sharpsl_pm.battstat.mainbat_voltage = voltage;
257 sharpsl_pm.battstat.mainbat_status = apm_status;
258 sharpsl_pm.battstat.mainbat_percent = percent;
259 }
260
261 dev_dbg(sharpsl_pm.dev, "Battery: voltage: %d, status: %d, percentage: %d, time: %d\n", voltage,
262 sharpsl_pm.battstat.mainbat_status, sharpsl_pm.battstat.mainbat_percent, jiffies);
263
264 /* If battery is low. limit backlight intensity to save power. */
265 if ((sharpsl_pm.battstat.ac_status != APM_AC_ONLINE)
266 && ((sharpsl_pm.battstat.mainbat_status == APM_BATTERY_STATUS_LOW) ||
267 (sharpsl_pm.battstat.mainbat_status == APM_BATTERY_STATUS_CRITICAL))) {
268 if (!(sharpsl_pm.flags & SHARPSL_BL_LIMIT)) {
269 corgibl_limit_intensity(1);
270 sharpsl_pm.flags |= SHARPSL_BL_LIMIT;
271 }
272 } else if (sharpsl_pm.flags & SHARPSL_BL_LIMIT) {
273 corgibl_limit_intensity(0);
274 sharpsl_pm.flags &= ~SHARPSL_BL_LIMIT;
275 }
276
277 /* Suspend if critical battery level */
278 if ((sharpsl_pm.battstat.ac_status != APM_AC_ONLINE)
279 && (sharpsl_pm.battstat.mainbat_status == APM_BATTERY_STATUS_CRITICAL)
280 && !(sharpsl_pm.flags & SHARPSL_APM_QUEUED)) {
281 sharpsl_pm.flags |= SHARPSL_APM_QUEUED;
282 dev_err(sharpsl_pm.dev, "Fatal Off\n");
283 apm_queue_event(APM_CRITICAL_SUSPEND);
284 }
285
286 schedule_delayed_work(&sharpsl_bat, SHARPSL_BATCHK_TIME);
287}
288
289static void sharpsl_charge_on(void)
290{
291 dev_dbg(sharpsl_pm.dev, "Turning Charger On\n");
292
293 sharpsl_pm.full_count = 0;
294 sharpsl_pm.charge_mode = CHRG_ON;
295 schedule_delayed_work(&toggle_charger, msecs_to_jiffies(250));
296 schedule_delayed_work(&sharpsl_bat, msecs_to_jiffies(500));
297}
298
299static void sharpsl_charge_off(void)
300{
301 dev_dbg(sharpsl_pm.dev, "Turning Charger Off\n");
302
303 CHARGE_OFF();
304 CHARGE_LED_OFF();
305 sharpsl_pm.charge_mode = CHRG_OFF;
306
307 schedule_work(&sharpsl_bat);
308}
309
310static void sharpsl_charge_error(void)
311{
312 CHARGE_LED_ERR();
313 CHARGE_OFF();
314 sharpsl_pm.charge_mode = CHRG_ERROR;
315}
316
317static void sharpsl_charge_toggle(void *private_)
318{
319 dev_dbg(sharpsl_pm.dev, "Toogling Charger at time: %lx\n", jiffies);
320
321 if (STATUS_AC_IN() == 0) {
322 sharpsl_charge_off();
323 return;
324 } else if ((sharpsl_check_battery_temp() < 0) || (sharpsl_ac_check() < 0)) {
325 sharpsl_charge_error();
326 return;
327 }
328
329 CHARGE_LED_ON();
330 CHARGE_OFF();
331 mdelay(SHARPSL_CHARGE_WAIT_TIME);
332 CHARGE_ON();
333
334 sharpsl_pm.charge_start_time = jiffies;
335}
336
337static void sharpsl_ac_timer(unsigned long data)
338{
339 int acin = STATUS_AC_IN();
340
341 dev_dbg(sharpsl_pm.dev, "AC Status: %d\n",acin);
342
343 sharpsl_average_clear();
344 if (acin && (sharpsl_pm.charge_mode != CHRG_ON))
345 sharpsl_charge_on();
346 else if (sharpsl_pm.charge_mode == CHRG_ON)
347 sharpsl_charge_off();
348
349 schedule_work(&sharpsl_bat);
350}
351
352
353static irqreturn_t sharpsl_ac_isr(int irq, void *dev_id, struct pt_regs *fp)
354{
355 /* Delay the event slightly to debounce */
356 /* Must be a smaller delay than the chrg_full_isr below */
357 mod_timer(&sharpsl_pm.ac_timer, jiffies + msecs_to_jiffies(250));
358
359 return IRQ_HANDLED;
360}
361
362static void sharpsl_chrg_full_timer(unsigned long data)
363{
364 dev_dbg(sharpsl_pm.dev, "Charge Full at time: %lx\n", jiffies);
365
366 sharpsl_pm.full_count++;
367
368 if (STATUS_AC_IN() == 0) {
369 dev_dbg(sharpsl_pm.dev, "Charge Full: AC removed - stop charging!\n");
370 if (sharpsl_pm.charge_mode == CHRG_ON)
371 sharpsl_charge_off();
372 } else if (sharpsl_pm.full_count < 2) {
373 dev_dbg(sharpsl_pm.dev, "Charge Full: Count too low\n");
374 schedule_work(&toggle_charger);
375 } else if (time_after(jiffies, sharpsl_pm.charge_start_time + SHARPSL_CHARGE_FINISH_TIME)) {
376 dev_dbg(sharpsl_pm.dev, "Charge Full: Interrupt generated too slowly - retry.\n");
377 schedule_work(&toggle_charger);
378 } else {
379 sharpsl_charge_off();
380 sharpsl_pm.charge_mode = CHRG_DONE;
381 dev_dbg(sharpsl_pm.dev, "Charge Full: Charging Finished\n");
382 }
383}
384
385/* Charging Finished Interrupt (Not present on Corgi) */
386/* Can trigger at the same time as an AC staus change so
387 delay until after that has been processed */
388static irqreturn_t sharpsl_chrg_full_isr(int irq, void *dev_id, struct pt_regs *fp)
389{
390 if (sharpsl_pm.flags & SHARPSL_SUSPENDED)
391 return IRQ_HANDLED;
392
393 /* delay until after any ac interrupt */
394 mod_timer(&sharpsl_pm.chrg_full_timer, jiffies + msecs_to_jiffies(500));
395
396 return IRQ_HANDLED;
397}
398
399static irqreturn_t sharpsl_fatal_isr(int irq, void *dev_id, struct pt_regs *fp)
400{
401 int is_fatal = 0;
402
403 if (STATUS_BATT_LOCKED() == 0) {
404 dev_err(sharpsl_pm.dev, "Battery now Unlocked! Suspending.\n");
405 is_fatal = 1;
406 }
407
408 if (sharpsl_pm.machinfo->gpio_fatal && (STATUS_FATAL() == 0)) {
409 dev_err(sharpsl_pm.dev, "Fatal Batt Error! Suspending.\n");
410 is_fatal = 1;
411 }
412
413 if (!(sharpsl_pm.flags & SHARPSL_APM_QUEUED) && is_fatal) {
414 sharpsl_pm.flags |= SHARPSL_APM_QUEUED;
415 apm_queue_event(APM_CRITICAL_SUSPEND);
416 }
417
418 return IRQ_HANDLED;
419}
420
421/*
422 * Maintain an average of the last 10 readings
423 */
424#define SHARPSL_CNV_VALUE_NUM 10
425static int sharpsl_ad_index;
426
427static void sharpsl_average_clear(void)
428{
429 sharpsl_ad_index = 0;
430}
431
432static int sharpsl_average_value(int ad)
433{
434 int i, ad_val = 0;
435 static int sharpsl_ad[SHARPSL_CNV_VALUE_NUM+1];
436
437 if (sharpsl_pm.battstat.mainbat_status != APM_BATTERY_STATUS_HIGH) {
438 sharpsl_ad_index = 0;
439 return ad;
440 }
441
442 sharpsl_ad[sharpsl_ad_index] = ad;
443 sharpsl_ad_index++;
444 if (sharpsl_ad_index >= SHARPSL_CNV_VALUE_NUM) {
445 for (i=0; i < (SHARPSL_CNV_VALUE_NUM-1); i++)
446 sharpsl_ad[i] = sharpsl_ad[i+1];
447 sharpsl_ad_index = SHARPSL_CNV_VALUE_NUM - 1;
448 }
449 for (i=0; i < sharpsl_ad_index; i++)
450 ad_val += sharpsl_ad[i];
451
452 return (ad_val / sharpsl_ad_index);
453}
454
455
456/* 126/*
457 * Read MAX1111 ADC 127 * Read MAX1111 ADC
458 */ 128 */
459static int read_max1111(int channel) 129int sharpsl_pm_pxa_read_max1111(int channel)
460{ 130{
461 return corgi_ssp_max1111_get((channel << MAXCTRL_SEL_SH) | MAXCTRL_PD0 | MAXCTRL_PD1 131 return corgi_ssp_max1111_get((channel << MAXCTRL_SEL_SH) | MAXCTRL_PD0 | MAXCTRL_PD1
462 | MAXCTRL_SGL | MAXCTRL_UNI | MAXCTRL_STR); 132 | MAXCTRL_SGL | MAXCTRL_UNI | MAXCTRL_STR);
463} 133}
464 134
465static int sharpsl_read_main_battery(void) 135void sharpsl_pm_pxa_init(void)
466{
467 return read_max1111(BATT_AD);
468}
469
470static int sharpsl_read_temp(void)
471{ 136{
472 int temp;
473
474 sharpsl_pm.machinfo->measure_temp(1);
475
476 mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_TEMP);
477 temp = read_max1111(BATT_THM);
478
479 sharpsl_pm.machinfo->measure_temp(0);
480
481 return temp;
482}
483
484static int sharpsl_read_acin(void)
485{
486 return read_max1111(JK_VAD);
487}
488
489/*
490 * Take an array of 5 integers, remove the maximum and minimum values
491 * and return the average.
492 */
493static int get_select_val(int *val)
494{
495 int i, j, k, temp, sum = 0;
496
497 /* Find MAX val */
498 temp = val[0];
499 j=0;
500 for (i=1; i<5; i++) {
501 if (temp < val[i]) {
502 temp = val[i];
503 j = i;
504 }
505 }
506
507 /* Find MIN val */
508 temp = val[4];
509 k=4;
510 for (i=3; i>=0; i--) {
511 if (temp > val[i]) {
512 temp = val[i];
513 k = i;
514 }
515 }
516
517 for (i=0; i<5; i++)
518 if (i != j && i != k )
519 sum += val[i];
520
521 dev_dbg(sharpsl_pm.dev, "Average: %d from values: %d, %d, %d, %d, %d\n", sum/3, val[0], val[1], val[2], val[3], val[4]);
522
523 return (sum/3);
524}
525
526static int sharpsl_check_battery_temp(void)
527{
528 int val, i, buff[5];
529
530 /* Check battery temperature */
531 for (i=0; i<5; i++) {
532 mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_TEMP);
533 buff[i] = sharpsl_read_temp();
534 }
535
536 val = get_select_val(buff);
537
538 dev_dbg(sharpsl_pm.dev, "Temperature: %d\n", val);
539 if (val > SHARPSL_CHARGE_ON_TEMP)
540 return -1;
541
542 return 0;
543}
544
545static int sharpsl_check_battery_voltage(void)
546{
547 int val, i, buff[5];
548
549 /* disable charge, enable discharge */
550 CHARGE_OFF();
551 DISCHARGE_ON();
552 mdelay(SHARPSL_WAIT_DISCHARGE_ON);
553
554 if (sharpsl_pm.machinfo->discharge1)
555 sharpsl_pm.machinfo->discharge1(1);
556
557 /* Check battery voltage */
558 for (i=0; i<5; i++) {
559 buff[i] = sharpsl_read_main_battery();
560 mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_VOLT);
561 }
562
563 if (sharpsl_pm.machinfo->discharge1)
564 sharpsl_pm.machinfo->discharge1(0);
565
566 DISCHARGE_OFF();
567
568 val = get_select_val(buff);
569 dev_dbg(sharpsl_pm.dev, "Battery Voltage: %d\n", val);
570
571 if (val < SHARPSL_CHARGE_ON_VOLT)
572 return -1;
573
574 return 0;
575}
576
577static int sharpsl_ac_check(void)
578{
579 int temp, i, buff[5];
580
581 for (i=0; i<5; i++) {
582 buff[i] = sharpsl_read_acin();
583 mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_ACIN);
584 }
585
586 temp = get_select_val(buff);
587 dev_dbg(sharpsl_pm.dev, "AC Voltage: %d\n",temp);
588
589 if ((temp > SHARPSL_CHARGE_ON_ACIN_HIGH) || (temp < SHARPSL_CHARGE_ON_ACIN_LOW)) {
590 dev_err(sharpsl_pm.dev, "Error: AC check failed.\n");
591 return -1;
592 }
593
594 return 0;
595}
596
597#ifdef CONFIG_PM
598static int sharpsl_pm_suspend(struct platform_device *pdev, pm_message_t state)
599{
600 sharpsl_pm.flags |= SHARPSL_SUSPENDED;
601 flush_scheduled_work();
602
603 if (sharpsl_pm.charge_mode == CHRG_ON)
604 sharpsl_pm.flags |= SHARPSL_DO_OFFLINE_CHRG;
605 else
606 sharpsl_pm.flags &= ~SHARPSL_DO_OFFLINE_CHRG;
607
608 return 0;
609}
610
611static int sharpsl_pm_resume(struct platform_device *pdev)
612{
613 /* Clear the reset source indicators as they break the bootloader upon reboot */
614 RCSR = 0x0f;
615 sharpsl_average_clear();
616 sharpsl_pm.flags &= ~SHARPSL_APM_QUEUED;
617 sharpsl_pm.flags &= ~SHARPSL_SUSPENDED;
618
619 return 0;
620}
621
622static void corgi_goto_sleep(unsigned long alarm_time, unsigned int alarm_enable, suspend_state_t state)
623{
624 dev_dbg(sharpsl_pm.dev, "Time is: %08x\n",RCNR);
625
626 dev_dbg(sharpsl_pm.dev, "Offline Charge Activate = %d\n",sharpsl_pm.flags & SHARPSL_DO_OFFLINE_CHRG);
627 /* not charging and AC-IN! */
628
629 if ((sharpsl_pm.flags & SHARPSL_DO_OFFLINE_CHRG) && (STATUS_AC_IN() != 0)) {
630 dev_dbg(sharpsl_pm.dev, "Activating Offline Charger...\n");
631 sharpsl_pm.charge_mode = CHRG_OFF;
632 sharpsl_pm.flags &= ~SHARPSL_DO_OFFLINE_CHRG;
633 sharpsl_off_charge_battery();
634 }
635
636 sharpsl_pm.machinfo->presuspend();
637
638 PEDR = 0xffffffff; /* clear it */
639
640 sharpsl_pm.flags &= ~SHARPSL_ALARM_ACTIVE;
641 if ((sharpsl_pm.charge_mode == CHRG_ON) && ((alarm_enable && ((alarm_time - RCNR) > (SHARPSL_BATCHK_TIME_SUSPEND + 30))) || !alarm_enable)) {
642 RTSR &= RTSR_ALE;
643 RTAR = RCNR + SHARPSL_BATCHK_TIME_SUSPEND;
644 dev_dbg(sharpsl_pm.dev, "Charging alarm at: %08x\n",RTAR);
645 sharpsl_pm.flags |= SHARPSL_ALARM_ACTIVE;
646 } else if (alarm_enable) {
647 RTSR &= RTSR_ALE;
648 RTAR = alarm_time;
649 dev_dbg(sharpsl_pm.dev, "User alarm at: %08x\n",RTAR);
650 } else {
651 dev_dbg(sharpsl_pm.dev, "No alarms set.\n");
652 }
653
654 pxa_pm_enter(state);
655
656 sharpsl_pm.machinfo->postsuspend();
657
658 dev_dbg(sharpsl_pm.dev, "Corgi woken up from suspend: %08x\n",PEDR);
659}
660
661static int corgi_enter_suspend(unsigned long alarm_time, unsigned int alarm_enable, suspend_state_t state)
662{
663 if (!sharpsl_pm.machinfo->should_wakeup(!(sharpsl_pm.flags & SHARPSL_ALARM_ACTIVE) && alarm_enable) )
664 {
665 if (!(sharpsl_pm.flags & SHARPSL_ALARM_ACTIVE)) {
666 dev_dbg(sharpsl_pm.dev, "No user triggered wakeup events and not charging. Strange. Suspend.\n");
667 corgi_goto_sleep(alarm_time, alarm_enable, state);
668 return 1;
669 }
670 if(sharpsl_off_charge_battery()) {
671 dev_dbg(sharpsl_pm.dev, "Charging. Suspend...\n");
672 corgi_goto_sleep(alarm_time, alarm_enable, state);
673 return 1;
674 }
675 dev_dbg(sharpsl_pm.dev, "User triggered wakeup in offline charger.\n");
676 }
677
678 if ((STATUS_BATT_LOCKED() == 0) || (sharpsl_fatal_check() < 0) )
679 {
680 dev_err(sharpsl_pm.dev, "Fatal condition. Suspend.\n");
681 corgi_goto_sleep(alarm_time, alarm_enable, state);
682 return 1;
683 }
684
685 return 0;
686}
687
688static int corgi_pxa_pm_enter(suspend_state_t state)
689{
690 unsigned long alarm_time = RTAR;
691 unsigned int alarm_status = ((RTSR & RTSR_ALE) != 0);
692
693 dev_dbg(sharpsl_pm.dev, "SharpSL suspending for first time.\n");
694
695 corgi_goto_sleep(alarm_time, alarm_status, state);
696
697 while (corgi_enter_suspend(alarm_time,alarm_status,state))
698 {}
699
700 dev_dbg(sharpsl_pm.dev, "SharpSL resuming...\n");
701
702 return 0;
703}
704#endif
705
706
707/*
708 * Check for fatal battery errors
709 * Fatal returns -1
710 */
711static int sharpsl_fatal_check(void)
712{
713 int buff[5], temp, i, acin;
714
715 dev_dbg(sharpsl_pm.dev, "sharpsl_fatal_check entered\n");
716
717 /* Check AC-Adapter */
718 acin = STATUS_AC_IN();
719
720 if (acin && (sharpsl_pm.charge_mode == CHRG_ON)) {
721 CHARGE_OFF();
722 udelay(100);
723 DISCHARGE_ON(); /* enable discharge */
724 mdelay(SHARPSL_WAIT_DISCHARGE_ON);
725 }
726
727 if (sharpsl_pm.machinfo->discharge1)
728 sharpsl_pm.machinfo->discharge1(1);
729
730 /* Check battery : check inserting battery ? */
731 for (i=0; i<5; i++) {
732 buff[i] = sharpsl_read_main_battery();
733 mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_VOLT);
734 }
735
736 if (sharpsl_pm.machinfo->discharge1)
737 sharpsl_pm.machinfo->discharge1(0);
738
739 if (acin && (sharpsl_pm.charge_mode == CHRG_ON)) {
740 udelay(100);
741 CHARGE_ON();
742 DISCHARGE_OFF();
743 }
744
745 temp = get_select_val(buff);
746 dev_dbg(sharpsl_pm.dev, "sharpsl_fatal_check: acin: %d, discharge voltage: %d, no discharge: %d\n", acin, temp, sharpsl_read_main_battery());
747
748 if ((acin && (temp < SHARPSL_FATAL_ACIN_VOLT)) ||
749 (!acin && (temp < SHARPSL_FATAL_NOACIN_VOLT)))
750 return -1;
751 return 0;
752}
753
754static int sharpsl_off_charge_error(void)
755{
756 dev_err(sharpsl_pm.dev, "Offline Charger: Error occured.\n");
757 CHARGE_OFF();
758 CHARGE_LED_ERR();
759 sharpsl_pm.charge_mode = CHRG_ERROR;
760 return 1;
761}
762
763/*
764 * Charging Control while suspended
765 * Return 1 - go straight to sleep
766 * Return 0 - sleep or wakeup depending on other factors
767 */
768static int sharpsl_off_charge_battery(void)
769{
770 int time;
771
772 dev_dbg(sharpsl_pm.dev, "Charge Mode: %d\n", sharpsl_pm.charge_mode);
773
774 if (sharpsl_pm.charge_mode == CHRG_OFF) {
775 dev_dbg(sharpsl_pm.dev, "Offline Charger: Step 1\n");
776
777 /* AC Check */
778 if ((sharpsl_ac_check() < 0) || (sharpsl_check_battery_temp() < 0))
779 return sharpsl_off_charge_error();
780
781 /* Start Charging */
782 CHARGE_LED_ON();
783 CHARGE_OFF();
784 mdelay(SHARPSL_CHARGE_WAIT_TIME);
785 CHARGE_ON();
786
787 sharpsl_pm.charge_mode = CHRG_ON;
788 sharpsl_pm.full_count = 0;
789
790 return 1;
791 } else if (sharpsl_pm.charge_mode != CHRG_ON) {
792 return 1;
793 }
794
795 if (sharpsl_pm.full_count == 0) {
796 int time;
797
798 dev_dbg(sharpsl_pm.dev, "Offline Charger: Step 2\n");
799
800 if ((sharpsl_check_battery_temp() < 0) || (sharpsl_check_battery_voltage() < 0))
801 return sharpsl_off_charge_error();
802
803 CHARGE_OFF();
804 mdelay(SHARPSL_CHARGE_WAIT_TIME);
805 CHARGE_ON();
806 sharpsl_pm.charge_mode = CHRG_ON;
807
808 mdelay(SHARPSL_CHARGE_CO_CHECK_TIME);
809
810 time = RCNR;
811 while(1) {
812 /* Check if any wakeup event had occured */
813 if (sharpsl_pm.machinfo->charger_wakeup() != 0)
814 return 0;
815 /* Check for timeout */
816 if ((RCNR - time) > SHARPSL_WAIT_CO_TIME)
817 return 1;
818 if (STATUS_CHRG_FULL()) {
819 dev_dbg(sharpsl_pm.dev, "Offline Charger: Charge full occured. Retrying to check\n");
820 sharpsl_pm.full_count++;
821 CHARGE_OFF();
822 mdelay(SHARPSL_CHARGE_WAIT_TIME);
823 CHARGE_ON();
824 return 1;
825 }
826 }
827 }
828
829 dev_dbg(sharpsl_pm.dev, "Offline Charger: Step 3\n");
830
831 mdelay(SHARPSL_CHARGE_CO_CHECK_TIME);
832
833 time = RCNR;
834 while(1) {
835 /* Check if any wakeup event had occured */
836 if (sharpsl_pm.machinfo->charger_wakeup() != 0)
837 return 0;
838 /* Check for timeout */
839 if ((RCNR-time) > SHARPSL_WAIT_CO_TIME) {
840 if (sharpsl_pm.full_count > SHARPSL_CHARGE_RETRY_CNT) {
841 dev_dbg(sharpsl_pm.dev, "Offline Charger: Not charged sufficiently. Retrying.\n");
842 sharpsl_pm.full_count = 0;
843 }
844 sharpsl_pm.full_count++;
845 return 1;
846 }
847 if (STATUS_CHRG_FULL()) {
848 dev_dbg(sharpsl_pm.dev, "Offline Charger: Charging complete.\n");
849 CHARGE_LED_OFF();
850 CHARGE_OFF();
851 sharpsl_pm.charge_mode = CHRG_DONE;
852 return 1;
853 }
854 }
855}
856
857
858static ssize_t battery_percentage_show(struct device *dev, struct device_attribute *attr, char *buf)
859{
860 return sprintf(buf, "%d\n",sharpsl_pm.battstat.mainbat_percent);
861}
862
863static ssize_t battery_voltage_show(struct device *dev, struct device_attribute *attr, char *buf)
864{
865 return sprintf(buf, "%d\n",sharpsl_pm.battstat.mainbat_voltage);
866}
867
868static DEVICE_ATTR(battery_percentage, 0444, battery_percentage_show, NULL);
869static DEVICE_ATTR(battery_voltage, 0444, battery_voltage_show, NULL);
870
871extern void (*apm_get_power_status)(struct apm_power_info *);
872
873static void sharpsl_apm_get_power_status(struct apm_power_info *info)
874{
875 info->ac_line_status = sharpsl_pm.battstat.ac_status;
876
877 if (sharpsl_pm.charge_mode == CHRG_ON)
878 info->battery_status = APM_BATTERY_STATUS_CHARGING;
879 else
880 info->battery_status = sharpsl_pm.battstat.mainbat_status;
881
882 info->battery_flag = (1 << info->battery_status);
883 info->battery_life = sharpsl_pm.battstat.mainbat_percent;
884}
885
886static struct pm_ops sharpsl_pm_ops = {
887 .pm_disk_mode = PM_DISK_FIRMWARE,
888 .prepare = pxa_pm_prepare,
889 .enter = corgi_pxa_pm_enter,
890 .finish = pxa_pm_finish,
891};
892
893static int __init sharpsl_pm_probe(struct platform_device *pdev)
894{
895 if (!pdev->dev.platform_data)
896 return -EINVAL;
897
898 sharpsl_pm.dev = &pdev->dev;
899 sharpsl_pm.machinfo = pdev->dev.platform_data;
900 sharpsl_pm.charge_mode = CHRG_OFF;
901 sharpsl_pm.flags = 0;
902
903 sharpsl_pm.machinfo->init();
904
905 init_timer(&sharpsl_pm.ac_timer);
906 sharpsl_pm.ac_timer.function = sharpsl_ac_timer;
907
908 init_timer(&sharpsl_pm.chrg_full_timer);
909 sharpsl_pm.chrg_full_timer.function = sharpsl_chrg_full_timer;
910
911 pxa_gpio_mode(sharpsl_pm.machinfo->gpio_acin | GPIO_IN); 137 pxa_gpio_mode(sharpsl_pm.machinfo->gpio_acin | GPIO_IN);
912 pxa_gpio_mode(sharpsl_pm.machinfo->gpio_batfull | GPIO_IN); 138 pxa_gpio_mode(sharpsl_pm.machinfo->gpio_batfull | GPIO_IN);
913 pxa_gpio_mode(sharpsl_pm.machinfo->gpio_batlock | GPIO_IN); 139 pxa_gpio_mode(sharpsl_pm.machinfo->gpio_batlock | GPIO_IN);
@@ -938,26 +164,10 @@ static int __init sharpsl_pm_probe(struct platform_device *pdev)
938 } 164 }
939 else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull),IRQT_RISING); 165 else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull),IRQT_RISING);
940 } 166 }
941
942 device_create_file(&pdev->dev, &dev_attr_battery_percentage);
943 device_create_file(&pdev->dev, &dev_attr_battery_voltage);
944
945 apm_get_power_status = sharpsl_apm_get_power_status;
946
947 pm_set_ops(&sharpsl_pm_ops);
948
949 mod_timer(&sharpsl_pm.ac_timer, jiffies + msecs_to_jiffies(250));
950
951 return 0;
952} 167}
953 168
954static int sharpsl_pm_remove(struct platform_device *pdev) 169void sharpsl_pm_pxa_remove(void)
955{ 170{
956 pm_set_ops(NULL);
957
958 device_remove_file(&pdev->dev, &dev_attr_battery_percentage);
959 device_remove_file(&pdev->dev, &dev_attr_battery_voltage);
960
961 free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_acin), sharpsl_ac_isr); 171 free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_acin), sharpsl_ac_isr);
962 free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batlock), sharpsl_fatal_isr); 172 free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batlock), sharpsl_fatal_isr);
963 173
@@ -966,32 +176,4 @@ static int sharpsl_pm_remove(struct platform_device *pdev)
966 176
967 if (!machine_is_corgi()) 177 if (!machine_is_corgi())
968 free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull), sharpsl_chrg_full_isr); 178 free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull), sharpsl_chrg_full_isr);
969
970 del_timer_sync(&sharpsl_pm.chrg_full_timer);
971 del_timer_sync(&sharpsl_pm.ac_timer);
972
973 return 0;
974} 179}
975
976static struct platform_driver sharpsl_pm_driver = {
977 .probe = sharpsl_pm_probe,
978 .remove = sharpsl_pm_remove,
979 .suspend = sharpsl_pm_suspend,
980 .resume = sharpsl_pm_resume,
981 .driver = {
982 .name = "sharpsl-pm",
983 },
984};
985
986static int __devinit sharpsl_pm_init(void)
987{
988 return platform_driver_register(&sharpsl_pm_driver);
989}
990
991static void sharpsl_pm_exit(void)
992{
993 platform_driver_unregister(&sharpsl_pm_driver);
994}
995
996late_initcall(sharpsl_pm_init);
997module_exit(sharpsl_pm_exit);
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index 2df1b56615b1..f2007db0cda5 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -36,6 +36,7 @@
36#include <asm/arch/irq.h> 36#include <asm/arch/irq.h>
37#include <asm/arch/irda.h> 37#include <asm/arch/irda.h>
38#include <asm/arch/mmc.h> 38#include <asm/arch/mmc.h>
39#include <asm/arch/ohci.h>
39#include <asm/arch/udc.h> 40#include <asm/arch/udc.h>
40#include <asm/arch/pxafb.h> 41#include <asm/arch/pxafb.h>
41#include <asm/arch/akita.h> 42#include <asm/arch/akita.h>
@@ -126,10 +127,12 @@ static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr)
126 cpr &= ~0x0002; 127 cpr &= ~0x0002;
127 if (device == SPITZ_PWR_SD) 128 if (device == SPITZ_PWR_SD)
128 cpr &= ~0x0004; 129 cpr &= ~0x0004;
129 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
130 if (!(cpr & 0x0002) && !(cpr & 0x0004)) { 130 if (!(cpr & 0x0002) && !(cpr & 0x0004)) {
131 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, 0x0000);
131 mdelay(1); 132 mdelay(1);
132 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER); 133 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER);
134 } else {
135 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
133 } 136 }
134 } 137 }
135} 138}
@@ -335,6 +338,35 @@ static struct pxamci_platform_data spitz_mci_platform_data = {
335 338
336 339
337/* 340/*
341 * USB Host (OHCI)
342 */
343static int spitz_ohci_init(struct device *dev)
344{
345 /* Only Port 2 is connected */
346 pxa_gpio_mode(SPITZ_GPIO_USB_CONNECT | GPIO_IN);
347 pxa_gpio_mode(SPITZ_GPIO_USB_HOST | GPIO_OUT);
348 pxa_gpio_mode(SPITZ_GPIO_USB_DEVICE | GPIO_IN);
349
350 /* Setup USB Port 2 Output Control Register */
351 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
352
353 GPSR(SPITZ_GPIO_USB_HOST) = GPIO_bit(SPITZ_GPIO_USB_HOST);
354
355 UHCHR = (UHCHR) &
356 ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSEP3 | UHCHR_SSE);
357
358 UHCRHDA |= UHCRHDA_NOCP;
359
360 return 0;
361}
362
363static struct pxaohci_platform_data spitz_ohci_platform_data = {
364 .port_mode = PMM_NPS_MODE,
365 .init = spitz_ohci_init,
366};
367
368
369/*
338 * Irda 370 * Irda
339 */ 371 */
340static void spitz_irda_transceiver_mode(struct device *dev, int mode) 372static void spitz_irda_transceiver_mode(struct device *dev, int mode)
@@ -411,6 +443,7 @@ static void __init common_init(void)
411 443
412 platform_add_devices(devices, ARRAY_SIZE(devices)); 444 platform_add_devices(devices, ARRAY_SIZE(devices));
413 pxa_set_mci_info(&spitz_mci_platform_data); 445 pxa_set_mci_info(&spitz_mci_platform_data);
446 pxa_set_ohci_info(&spitz_ohci_platform_data);
414 pxa_set_ficp_info(&spitz_ficp_platform_data); 447 pxa_set_ficp_info(&spitz_ficp_platform_data);
415 set_pxa_fb_parent(&spitzssp_device.dev); 448 set_pxa_fb_parent(&spitzssp_device.dev);
416 set_pxa_fb_info(&spitz_pxafb_info); 449 set_pxa_fb_info(&spitz_pxafb_info);
diff --git a/arch/arm/mach-pxa/spitz_pm.c b/arch/arm/mach-pxa/spitz_pm.c
index 3ce7486daa51..5e5bdc898482 100644
--- a/arch/arm/mach-pxa/spitz_pm.c
+++ b/arch/arm/mach-pxa/spitz_pm.c
@@ -33,19 +33,7 @@ static void spitz_charger_init(void)
33{ 33{
34 pxa_gpio_mode(SPITZ_GPIO_KEY_INT | GPIO_IN); 34 pxa_gpio_mode(SPITZ_GPIO_KEY_INT | GPIO_IN);
35 pxa_gpio_mode(SPITZ_GPIO_SYNC | GPIO_IN); 35 pxa_gpio_mode(SPITZ_GPIO_SYNC | GPIO_IN);
36} 36 sharpsl_pm_pxa_init();
37
38static void spitz_charge_led(int val)
39{
40 if (val == SHARPSL_LED_ERROR) {
41 dev_dbg(sharpsl_pm.dev, "Charge LED Error\n");
42 } else if (val == SHARPSL_LED_ON) {
43 dev_dbg(sharpsl_pm.dev, "Charge LED On\n");
44 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_ORANGE);
45 } else {
46 dev_dbg(sharpsl_pm.dev, "Charge LED Off\n");
47 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_ORANGE);
48 }
49} 37}
50 38
51static void spitz_measure_temp(int on) 39static void spitz_measure_temp(int on)
@@ -92,7 +80,7 @@ static void spitz_discharge1(int on)
92 80
93static void spitz_presuspend(void) 81static void spitz_presuspend(void)
94{ 82{
95 spitz_last_ac_status = STATUS_AC_IN(); 83 spitz_last_ac_status = sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN);
96 84
97 /* GPIO Sleep Register */ 85 /* GPIO Sleep Register */
98 PGSR0 = 0x00144018; 86 PGSR0 = 0x00144018;
@@ -138,7 +126,7 @@ static void spitz_postsuspend(void)
138static int spitz_should_wakeup(unsigned int resume_on_alarm) 126static int spitz_should_wakeup(unsigned int resume_on_alarm)
139{ 127{
140 int is_resume = 0; 128 int is_resume = 0;
141 int acin = STATUS_AC_IN(); 129 int acin = sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN);
142 130
143 if (spitz_last_ac_status != acin) { 131 if (spitz_last_ac_status != acin) {
144 if (acin) { 132 if (acin) {
@@ -148,8 +136,8 @@ static int spitz_should_wakeup(unsigned int resume_on_alarm)
148 } else { 136 } else {
149 /* charge off */ 137 /* charge off */
150 dev_dbg(sharpsl_pm.dev, "AC Removed\n"); 138 dev_dbg(sharpsl_pm.dev, "AC Removed\n");
151 CHARGE_LED_OFF(); 139 sharpsl_pm_led(SHARPSL_LED_OFF);
152 CHARGE_OFF(); 140 sharpsl_pm.machinfo->charge(0);
153 sharpsl_pm.charge_mode = CHRG_OFF; 141 sharpsl_pm.charge_mode = CHRG_OFF;
154 } 142 }
155 spitz_last_ac_status = acin; 143 spitz_last_ac_status = acin;
@@ -175,25 +163,41 @@ static unsigned long spitz_charger_wakeup(void)
175 return (~GPLR0 & GPIO_bit(SPITZ_GPIO_KEY_INT)) | (GPLR0 & GPIO_bit(SPITZ_GPIO_SYNC)); 163 return (~GPLR0 & GPIO_bit(SPITZ_GPIO_KEY_INT)) | (GPLR0 & GPIO_bit(SPITZ_GPIO_SYNC));
176} 164}
177 165
178static int spitz_acin_status(void) 166unsigned long spitzpm_read_devdata(int type)
179{ 167{
180 return (((~GPLR(SPITZ_GPIO_AC_IN)) & GPIO_bit(SPITZ_GPIO_AC_IN)) != 0); 168 switch(type) {
169 case SHARPSL_STATUS_ACIN:
170 return (((~GPLR(SPITZ_GPIO_AC_IN)) & GPIO_bit(SPITZ_GPIO_AC_IN)) != 0);
171 case SHARPSL_STATUS_LOCK:
172 return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batlock);
173 case SHARPSL_STATUS_CHRGFULL:
174 return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batfull);
175 case SHARPSL_STATUS_FATAL:
176 return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_fatal);
177 case SHARPSL_ACIN_VOLT:
178 return sharpsl_pm_pxa_read_max1111(MAX1111_ACIN_VOLT);
179 case SHARPSL_BATT_TEMP:
180 return sharpsl_pm_pxa_read_max1111(MAX1111_BATT_TEMP);
181 case SHARPSL_BATT_VOLT:
182 default:
183 return sharpsl_pm_pxa_read_max1111(MAX1111_BATT_VOLT);
184 }
181} 185}
182 186
183struct sharpsl_charger_machinfo spitz_pm_machinfo = { 187struct sharpsl_charger_machinfo spitz_pm_machinfo = {
184 .init = spitz_charger_init, 188 .init = spitz_charger_init,
189 .exit = sharpsl_pm_pxa_remove,
185 .gpio_batlock = SPITZ_GPIO_BAT_COVER, 190 .gpio_batlock = SPITZ_GPIO_BAT_COVER,
186 .gpio_acin = SPITZ_GPIO_AC_IN, 191 .gpio_acin = SPITZ_GPIO_AC_IN,
187 .gpio_batfull = SPITZ_GPIO_CHRG_FULL, 192 .gpio_batfull = SPITZ_GPIO_CHRG_FULL,
188 .gpio_fatal = SPITZ_GPIO_FATAL_BAT, 193 .gpio_fatal = SPITZ_GPIO_FATAL_BAT,
189 .status_acin = spitz_acin_status,
190 .discharge = spitz_discharge, 194 .discharge = spitz_discharge,
191 .discharge1 = spitz_discharge1, 195 .discharge1 = spitz_discharge1,
192 .charge = spitz_charge, 196 .charge = spitz_charge,
193 .chargeled = spitz_charge_led,
194 .measure_temp = spitz_measure_temp, 197 .measure_temp = spitz_measure_temp,
195 .presuspend = spitz_presuspend, 198 .presuspend = spitz_presuspend,
196 .postsuspend = spitz_postsuspend, 199 .postsuspend = spitz_postsuspend,
200 .read_devdata = spitzpm_read_devdata,
197 .charger_wakeup = spitz_charger_wakeup, 201 .charger_wakeup = spitz_charger_wakeup,
198 .should_wakeup = spitz_should_wakeup, 202 .should_wakeup = spitz_should_wakeup,
199 .bat_levels = 40, 203 .bat_levels = 40,
diff --git a/arch/arm/mach-realview/clock.c b/arch/arm/mach-realview/clock.c
index 002635c97bb6..ec3f7e798623 100644
--- a/arch/arm/mach-realview/clock.c
+++ b/arch/arm/mach-realview/clock.c
@@ -13,9 +13,9 @@
13#include <linux/list.h> 13#include <linux/list.h>
14#include <linux/errno.h> 14#include <linux/errno.h>
15#include <linux/err.h> 15#include <linux/err.h>
16#include <linux/clk.h>
16 17
17#include <asm/semaphore.h> 18#include <asm/semaphore.h>
18#include <asm/hardware/clock.h>
19#include <asm/hardware/icst307.h> 19#include <asm/hardware/icst307.h>
20 20
21#include "clock.h" 21#include "clock.h"
@@ -57,17 +57,6 @@ void clk_disable(struct clk *clk)
57} 57}
58EXPORT_SYMBOL(clk_disable); 58EXPORT_SYMBOL(clk_disable);
59 59
60int clk_use(struct clk *clk)
61{
62 return 0;
63}
64EXPORT_SYMBOL(clk_use);
65
66void clk_unuse(struct clk *clk)
67{
68}
69EXPORT_SYMBOL(clk_unuse);
70
71unsigned long clk_get_rate(struct clk *clk) 60unsigned long clk_get_rate(struct clk *clk)
72{ 61{
73 return clk->rate; 62 return clk->rate;
diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c
index af6580f1ceb8..4a222f59f2cf 100644
--- a/arch/arm/mach-realview/core.c
+++ b/arch/arm/mach-realview/core.c
@@ -24,14 +24,14 @@
24#include <linux/dma-mapping.h> 24#include <linux/dma-mapping.h>
25#include <linux/sysdev.h> 25#include <linux/sysdev.h>
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/amba/bus.h>
28#include <linux/amba/clcd.h>
27 29
28#include <asm/system.h> 30#include <asm/system.h>
29#include <asm/hardware.h> 31#include <asm/hardware.h>
30#include <asm/io.h> 32#include <asm/io.h>
31#include <asm/irq.h> 33#include <asm/irq.h>
32#include <asm/leds.h> 34#include <asm/leds.h>
33#include <asm/hardware/amba.h>
34#include <asm/hardware/amba_clcd.h>
35#include <asm/hardware/arm_timer.h> 35#include <asm/hardware/arm_timer.h>
36#include <asm/hardware/icst307.h> 36#include <asm/hardware/icst307.h>
37 37
diff --git a/arch/arm/mach-realview/core.h b/arch/arm/mach-realview/core.h
index c06e6041df41..93e86d9f439c 100644
--- a/arch/arm/mach-realview/core.h
+++ b/arch/arm/mach-realview/core.h
@@ -22,7 +22,8 @@
22#ifndef __ASM_ARCH_REALVIEW_H 22#ifndef __ASM_ARCH_REALVIEW_H
23#define __ASM_ARCH_REALVIEW_H 23#define __ASM_ARCH_REALVIEW_H
24 24
25#include <asm/hardware/amba.h> 25#include <linux/amba/bus.h>
26
26#include <asm/leds.h> 27#include <asm/leds.h>
27#include <asm/io.h> 28#include <asm/io.h>
28 29
diff --git a/arch/arm/mach-realview/realview_eb.c b/arch/arm/mach-realview/realview_eb.c
index 7dc32503fdf2..112f7592aca9 100644
--- a/arch/arm/mach-realview/realview_eb.c
+++ b/arch/arm/mach-realview/realview_eb.c
@@ -23,6 +23,7 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/sysdev.h> 25#include <linux/sysdev.h>
26#include <linux/amba/bus.h>
26 27
27#include <asm/hardware.h> 28#include <asm/hardware.h>
28#include <asm/io.h> 29#include <asm/io.h>
@@ -30,7 +31,6 @@
30#include <asm/leds.h> 31#include <asm/leds.h>
31#include <asm/mach-types.h> 32#include <asm/mach-types.h>
32#include <asm/hardware/gic.h> 33#include <asm/hardware/gic.h>
33#include <asm/hardware/amba.h>
34#include <asm/hardware/icst307.h> 34#include <asm/hardware/icst307.h>
35 35
36#include <asm/mach/arch.h> 36#include <asm/mach/arch.h>
diff --git a/arch/arm/mach-rpc/dma.c b/arch/arm/mach-rpc/dma.c
index bc0747439fb3..bd86ffba8810 100644
--- a/arch/arm/mach-rpc/dma.c
+++ b/arch/arm/mach-rpc/dma.c
@@ -13,7 +13,7 @@
13#include <linux/mman.h> 13#include <linux/mman.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/interrupt.h> 15#include <linux/interrupt.h>
16#include <linux/pci.h> 16#include <linux/dma-mapping.h>
17 17
18#include <asm/page.h> 18#include <asm/page.h>
19#include <asm/dma.h> 19#include <asm/dma.h>
@@ -148,11 +148,14 @@ static void iomd_enable_dma(dmach_t channel, dma_t *dma)
148 * Cope with ISA-style drivers which expect cache 148 * Cope with ISA-style drivers which expect cache
149 * coherence. 149 * coherence.
150 */ 150 */
151 if (!dma->using_sg) { 151 if (!dma->sg) {
152 dma->buf.dma_address = pci_map_single(NULL, 152 dma->sg = &dma->buf;
153 dma->buf.__address, dma->buf.length, 153 dma->sgcount = 1;
154 dma->buf.length = dma->count;
155 dma->buf.dma_address = dma_map_single(NULL,
156 dma->addr, dma->count,
154 dma->dma_mode == DMA_MODE_READ ? 157 dma->dma_mode == DMA_MODE_READ ?
155 PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE); 158 DMA_FROM_DEVICE : DMA_TO_DEVICE);
156 } 159 }
157 160
158 iomd_writeb(DMA_CR_C, dma_base + CR); 161 iomd_writeb(DMA_CR_C, dma_base + CR);
@@ -239,7 +242,7 @@ static void floppy_enable_dma(dmach_t channel, dma_t *dma)
239 unsigned int fiqhandler_length; 242 unsigned int fiqhandler_length;
240 struct pt_regs regs; 243 struct pt_regs regs;
241 244
242 if (dma->using_sg) 245 if (dma->sg)
243 BUG(); 246 BUG();
244 247
245 if (dma->dma_mode == DMA_MODE_READ) { 248 if (dma->dma_mode == DMA_MODE_READ) {
@@ -252,8 +255,8 @@ static void floppy_enable_dma(dmach_t channel, dma_t *dma)
252 fiqhandler_length = &floppy_fiqout_end - &floppy_fiqout_start; 255 fiqhandler_length = &floppy_fiqout_end - &floppy_fiqout_start;
253 } 256 }
254 257
255 regs.ARM_r9 = dma->buf.length; 258 regs.ARM_r9 = dma->count;
256 regs.ARM_r10 = (unsigned long)dma->buf.__address; 259 regs.ARM_r10 = (unsigned long)dma->addr;
257 regs.ARM_fp = (unsigned long)FLOPPYDMA_BASE; 260 regs.ARM_fp = (unsigned long)FLOPPYDMA_BASE;
258 261
259 if (claim_fiq(&fh)) { 262 if (claim_fiq(&fh)) {
diff --git a/arch/arm/mach-s3c2410/clock.c b/arch/arm/mach-s3c2410/clock.c
index 82e8253b1fa0..5830ae3ddd19 100644
--- a/arch/arm/mach-s3c2410/clock.c
+++ b/arch/arm/mach-s3c2410/clock.c
@@ -34,16 +34,15 @@
34#include <linux/err.h> 34#include <linux/err.h>
35#include <linux/platform_device.h> 35#include <linux/platform_device.h>
36#include <linux/sysdev.h> 36#include <linux/sysdev.h>
37
38#include <linux/interrupt.h> 37#include <linux/interrupt.h>
39#include <linux/ioport.h> 38#include <linux/ioport.h>
39#include <linux/clk.h>
40 40
41#include <asm/hardware.h> 41#include <asm/hardware.h>
42#include <asm/atomic.h> 42#include <asm/atomic.h>
43#include <asm/irq.h> 43#include <asm/irq.h>
44#include <asm/io.h> 44#include <asm/io.h>
45 45
46#include <asm/hardware/clock.h>
47#include <asm/arch/regs-clock.h> 46#include <asm/arch/regs-clock.h>
48 47
49#include "clock.h" 48#include "clock.h"
@@ -151,18 +150,6 @@ void clk_disable(struct clk *clk)
151} 150}
152 151
153 152
154int clk_use(struct clk *clk)
155{
156 atomic_inc(&clk->used);
157 return 0;
158}
159
160
161void clk_unuse(struct clk *clk)
162{
163 atomic_dec(&clk->used);
164}
165
166unsigned long clk_get_rate(struct clk *clk) 153unsigned long clk_get_rate(struct clk *clk)
167{ 154{
168 if (IS_ERR(clk)) 155 if (IS_ERR(clk))
@@ -196,8 +183,6 @@ EXPORT_SYMBOL(clk_get);
196EXPORT_SYMBOL(clk_put); 183EXPORT_SYMBOL(clk_put);
197EXPORT_SYMBOL(clk_enable); 184EXPORT_SYMBOL(clk_enable);
198EXPORT_SYMBOL(clk_disable); 185EXPORT_SYMBOL(clk_disable);
199EXPORT_SYMBOL(clk_use);
200EXPORT_SYMBOL(clk_unuse);
201EXPORT_SYMBOL(clk_get_rate); 186EXPORT_SYMBOL(clk_get_rate);
202EXPORT_SYMBOL(clk_round_rate); 187EXPORT_SYMBOL(clk_round_rate);
203EXPORT_SYMBOL(clk_set_rate); 188EXPORT_SYMBOL(clk_set_rate);
@@ -370,7 +355,6 @@ static struct clk init_clocks[] = {
370int s3c24xx_register_clock(struct clk *clk) 355int s3c24xx_register_clock(struct clk *clk)
371{ 356{
372 clk->owner = THIS_MODULE; 357 clk->owner = THIS_MODULE;
373 atomic_set(&clk->used, 0);
374 358
375 if (clk->enable == NULL) 359 if (clk->enable == NULL)
376 clk->enable = clk_null_enable; 360 clk->enable = clk_null_enable;
diff --git a/arch/arm/mach-s3c2410/clock.h b/arch/arm/mach-s3c2410/clock.h
index 7953b6f397b9..177d5c8decf7 100644
--- a/arch/arm/mach-s3c2410/clock.h
+++ b/arch/arm/mach-s3c2410/clock.h
@@ -16,7 +16,6 @@ struct clk {
16 struct clk *parent; 16 struct clk *parent;
17 const char *name; 17 const char *name;
18 int id; 18 int id;
19 atomic_t used;
20 unsigned long rate; 19 unsigned long rate;
21 unsigned long ctrlbit; 20 unsigned long ctrlbit;
22 int (*enable)(struct clk *, int enable); 21 int (*enable)(struct clk *, int enable);
diff --git a/arch/arm/mach-s3c2410/s3c2440-clock.c b/arch/arm/mach-s3c2410/s3c2440-clock.c
index c67e0979aec3..b557a2be8a01 100644
--- a/arch/arm/mach-s3c2410/s3c2440-clock.c
+++ b/arch/arm/mach-s3c2410/s3c2440-clock.c
@@ -29,16 +29,15 @@
29#include <linux/err.h> 29#include <linux/err.h>
30#include <linux/device.h> 30#include <linux/device.h>
31#include <linux/sysdev.h> 31#include <linux/sysdev.h>
32
33#include <linux/interrupt.h> 32#include <linux/interrupt.h>
34#include <linux/ioport.h> 33#include <linux/ioport.h>
34#include <linux/clk.h>
35 35
36#include <asm/hardware.h> 36#include <asm/hardware.h>
37#include <asm/atomic.h> 37#include <asm/atomic.h>
38#include <asm/irq.h> 38#include <asm/irq.h>
39#include <asm/io.h> 39#include <asm/io.h>
40 40
41#include <asm/hardware/clock.h>
42#include <asm/arch/regs-clock.h> 41#include <asm/arch/regs-clock.h>
43 42
44#include "clock.h" 43#include "clock.h"
diff --git a/arch/arm/mach-s3c2410/s3c2440.c b/arch/arm/mach-s3c2410/s3c2440.c
index 4d63e7133b48..b7fe6d9453fb 100644
--- a/arch/arm/mach-s3c2410/s3c2440.c
+++ b/arch/arm/mach-s3c2410/s3c2440.c
@@ -28,6 +28,7 @@
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/platform_device.h> 29#include <linux/platform_device.h>
30#include <linux/sysdev.h> 30#include <linux/sysdev.h>
31#include <linux/clk.h>
31 32
32#include <asm/mach/arch.h> 33#include <asm/mach/arch.h>
33#include <asm/mach/map.h> 34#include <asm/mach/map.h>
@@ -36,7 +37,6 @@
36#include <asm/hardware.h> 37#include <asm/hardware.h>
37#include <asm/io.h> 38#include <asm/io.h>
38#include <asm/irq.h> 39#include <asm/irq.h>
39#include <asm/hardware/clock.h>
40 40
41#include <asm/arch/regs-clock.h> 41#include <asm/arch/regs-clock.h>
42#include <asm/arch/regs-serial.h> 42#include <asm/arch/regs-serial.h>
diff --git a/arch/arm/mach-s3c2410/time.c b/arch/arm/mach-s3c2410/time.c
index 8a00e3c3cd08..10a2976aefdd 100644
--- a/arch/arm/mach-s3c2410/time.c
+++ b/arch/arm/mach-s3c2410/time.c
@@ -24,6 +24,7 @@
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/err.h> 26#include <linux/err.h>
27#include <linux/clk.h>
27 28
28#include <asm/system.h> 29#include <asm/system.h>
29#include <asm/leds.h> 30#include <asm/leds.h>
@@ -35,7 +36,6 @@
35#include <asm/arch/regs-timer.h> 36#include <asm/arch/regs-timer.h>
36#include <asm/arch/regs-irq.h> 37#include <asm/arch/regs-irq.h>
37#include <asm/mach/time.h> 38#include <asm/mach/time.h>
38#include <asm/hardware/clock.h>
39 39
40#include "clock.h" 40#include "clock.h"
41#include "cpu.h" 41#include "cpu.h"
@@ -191,7 +191,6 @@ static void s3c2410_timer_setup (void)
191 if (IS_ERR(clk)) 191 if (IS_ERR(clk))
192 panic("failed to get clock for system timer"); 192 panic("failed to get clock for system timer");
193 193
194 clk_use(clk);
195 clk_enable(clk); 194 clk_enable(clk);
196 195
197 pclk = clk_get_rate(clk); 196 pclk = clk_get_rate(clk);
diff --git a/arch/arm/mach-sa1100/pm.c b/arch/arm/mach-sa1100/pm.c
index 59c7964cfe11..786c8534231f 100644
--- a/arch/arm/mach-sa1100/pm.c
+++ b/arch/arm/mach-sa1100/pm.c
@@ -135,29 +135,11 @@ unsigned long sleep_phys_sp(void *sp)
135} 135}
136 136
137/* 137/*
138 * Called after processes are frozen, but before we shut down devices.
139 */
140static int sa11x0_pm_prepare(suspend_state_t state)
141{
142 return 0;
143}
144
145/*
146 * Called after devices are re-setup, but before processes are thawed.
147 */
148static int sa11x0_pm_finish(suspend_state_t state)
149{
150 return 0;
151}
152
153/*
154 * Set to PM_DISK_FIRMWARE so we can quickly veto suspend-to-disk. 138 * Set to PM_DISK_FIRMWARE so we can quickly veto suspend-to-disk.
155 */ 139 */
156static struct pm_ops sa11x0_pm_ops = { 140static struct pm_ops sa11x0_pm_ops = {
157 .pm_disk_mode = PM_DISK_FIRMWARE, 141 .pm_disk_mode = PM_DISK_FIRMWARE,
158 .prepare = sa11x0_pm_prepare,
159 .enter = sa11x0_pm_enter, 142 .enter = sa11x0_pm_enter,
160 .finish = sa11x0_pm_finish,
161}; 143};
162 144
163static int __init sa11x0_pm_init(void) 145static int __init sa11x0_pm_init(void)
diff --git a/arch/arm/mach-versatile/clock.c b/arch/arm/mach-versatile/clock.c
index b96a2ea15d41..dcf10014f5cd 100644
--- a/arch/arm/mach-versatile/clock.c
+++ b/arch/arm/mach-versatile/clock.c
@@ -14,9 +14,9 @@
14#include <linux/errno.h> 14#include <linux/errno.h>
15#include <linux/err.h> 15#include <linux/err.h>
16#include <linux/string.h> 16#include <linux/string.h>
17#include <linux/clk.h>
17 18
18#include <asm/semaphore.h> 19#include <asm/semaphore.h>
19#include <asm/hardware/clock.h>
20#include <asm/hardware/icst307.h> 20#include <asm/hardware/icst307.h>
21 21
22#include "clock.h" 22#include "clock.h"
@@ -58,17 +58,6 @@ void clk_disable(struct clk *clk)
58} 58}
59EXPORT_SYMBOL(clk_disable); 59EXPORT_SYMBOL(clk_disable);
60 60
61int clk_use(struct clk *clk)
62{
63 return 0;
64}
65EXPORT_SYMBOL(clk_use);
66
67void clk_unuse(struct clk *clk)
68{
69}
70EXPORT_SYMBOL(clk_unuse);
71
72unsigned long clk_get_rate(struct clk *clk) 61unsigned long clk_get_rate(struct clk *clk)
73{ 62{
74 return clk->rate; 63 return clk->rate;
diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
index a1ca46630dda..90023745b23a 100644
--- a/arch/arm/mach-versatile/core.c
+++ b/arch/arm/mach-versatile/core.c
@@ -25,14 +25,14 @@
25#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <linux/sysdev.h> 26#include <linux/sysdev.h>
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/amba/bus.h>
29#include <linux/amba/clcd.h>
28 30
29#include <asm/system.h> 31#include <asm/system.h>
30#include <asm/hardware.h> 32#include <asm/hardware.h>
31#include <asm/io.h> 33#include <asm/io.h>
32#include <asm/irq.h> 34#include <asm/irq.h>
33#include <asm/leds.h> 35#include <asm/leds.h>
34#include <asm/hardware/amba.h>
35#include <asm/hardware/amba_clcd.h>
36#include <asm/hardware/arm_timer.h> 36#include <asm/hardware/arm_timer.h>
37#include <asm/hardware/icst307.h> 37#include <asm/hardware/icst307.h>
38 38
diff --git a/arch/arm/mach-versatile/core.h b/arch/arm/mach-versatile/core.h
index 588c20669d5d..afcaa858eb1f 100644
--- a/arch/arm/mach-versatile/core.h
+++ b/arch/arm/mach-versatile/core.h
@@ -22,7 +22,7 @@
22#ifndef __ASM_ARCH_VERSATILE_H 22#ifndef __ASM_ARCH_VERSATILE_H
23#define __ASM_ARCH_VERSATILE_H 23#define __ASM_ARCH_VERSATILE_H
24 24
25#include <asm/hardware/amba.h> 25#include <linux/amba/bus.h>
26 26
27extern void __init versatile_init(void); 27extern void __init versatile_init(void);
28extern void __init versatile_init_irq(void); 28extern void __init versatile_init_irq(void);
diff --git a/arch/arm/mach-versatile/versatile_ab.c b/arch/arm/mach-versatile/versatile_ab.c
index 8b0b3bef24ae..e74c8a2fbb95 100644
--- a/arch/arm/mach-versatile/versatile_ab.c
+++ b/arch/arm/mach-versatile/versatile_ab.c
@@ -23,12 +23,12 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/device.h> 24#include <linux/device.h>
25#include <linux/sysdev.h> 25#include <linux/sysdev.h>
26#include <linux/amba/bus.h>
26 27
27#include <asm/hardware.h> 28#include <asm/hardware.h>
28#include <asm/io.h> 29#include <asm/io.h>
29#include <asm/irq.h> 30#include <asm/irq.h>
30#include <asm/mach-types.h> 31#include <asm/mach-types.h>
31#include <asm/hardware/amba.h>
32 32
33#include <asm/mach/arch.h> 33#include <asm/mach/arch.h>
34 34
diff --git a/arch/arm/mach-versatile/versatile_pb.c b/arch/arm/mach-versatile/versatile_pb.c
index 7c3078c38916..22d5ca07f75d 100644
--- a/arch/arm/mach-versatile/versatile_pb.c
+++ b/arch/arm/mach-versatile/versatile_pb.c
@@ -23,12 +23,12 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/device.h> 24#include <linux/device.h>
25#include <linux/sysdev.h> 25#include <linux/sysdev.h>
26#include <linux/amba/bus.h>
26 27
27#include <asm/hardware.h> 28#include <asm/hardware.h>
28#include <asm/io.h> 29#include <asm/io.h>
29#include <asm/irq.h> 30#include <asm/irq.h>
30#include <asm/mach-types.h> 31#include <asm/mach-types.h>
31#include <asm/hardware/amba.h>
32 32
33#include <asm/mach/arch.h> 33#include <asm/mach/arch.h>
34#include <asm/mach/mmc.h> 34#include <asm/mach/mmc.h>
diff --git a/arch/arm/mm/consistent.c b/arch/arm/mm/consistent.c
index dbfe9e891f01..0513ed1b2fcf 100644
--- a/arch/arm/mm/consistent.c
+++ b/arch/arm/mm/consistent.c
@@ -19,7 +19,6 @@
19#include <linux/dma-mapping.h> 19#include <linux/dma-mapping.h>
20 20
21#include <asm/cacheflush.h> 21#include <asm/cacheflush.h>
22#include <asm/io.h>
23#include <asm/tlbflush.h> 22#include <asm/tlbflush.h>
24 23
25#define CONSISTENT_BASE (0xffc00000) 24#define CONSISTENT_BASE (0xffc00000)
diff --git a/arch/arm/mm/discontig.c b/arch/arm/mm/discontig.c
index 0d097bb1bc4d..1e5602189507 100644
--- a/arch/arm/mm/discontig.c
+++ b/arch/arm/mm/discontig.c
@@ -9,10 +9,8 @@
9 * it under the terms of the GNU General Public License version 2 as 9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
11 */ 11 */
12
13#include <linux/module.h> 12#include <linux/module.h>
14#include <linux/mm.h> 13#include <linux/mmzone.h>
15#include <linux/init.h>
16#include <linux/bootmem.h> 14#include <linux/bootmem.h>
17 15
18#if MAX_NUMNODES != 4 && MAX_NUMNODES != 16 16#if MAX_NUMNODES != 4 && MAX_NUMNODES != 16
diff --git a/arch/arm/mm/mm-armv.c b/arch/arm/mm/mm-armv.c
index 9e50127be635..d0245a31d4dd 100644
--- a/arch/arm/mm/mm-armv.c
+++ b/arch/arm/mm/mm-armv.c
@@ -19,7 +19,6 @@
19 19
20#include <asm/pgalloc.h> 20#include <asm/pgalloc.h>
21#include <asm/page.h> 21#include <asm/page.h>
22#include <asm/io.h>
23#include <asm/setup.h> 22#include <asm/setup.h>
24#include <asm/tlbflush.h> 23#include <asm/tlbflush.h>
25 24
diff --git a/arch/arm/plat-omap/clock.c b/arch/arm/plat-omap/clock.c
index 7ce39b986e23..84fd65656fcf 100644
--- a/arch/arm/plat-omap/clock.c
+++ b/arch/arm/plat-omap/clock.c
@@ -19,10 +19,10 @@
19#include <linux/errno.h> 19#include <linux/errno.h>
20#include <linux/err.h> 20#include <linux/err.h>
21#include <linux/string.h> 21#include <linux/string.h>
22#include <linux/clk.h>
22 23
23#include <asm/io.h> 24#include <asm/io.h>
24#include <asm/semaphore.h> 25#include <asm/semaphore.h>
25#include <asm/hardware/clock.h>
26 26
27#include <asm/arch/clock.h> 27#include <asm/arch/clock.h>
28 28
diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c
index ccdb452630cf..adffc5a859ee 100644
--- a/arch/arm/plat-omap/common.c
+++ b/arch/arm/plat-omap/common.c
@@ -18,12 +18,12 @@
18#include <linux/tty.h> 18#include <linux/tty.h>
19#include <linux/serial_8250.h> 19#include <linux/serial_8250.h>
20#include <linux/serial_reg.h> 20#include <linux/serial_reg.h>
21#include <linux/clk.h>
21 22
22#include <asm/hardware.h> 23#include <asm/hardware.h>
23#include <asm/system.h> 24#include <asm/system.h>
24#include <asm/pgtable.h> 25#include <asm/pgtable.h>
25#include <asm/mach/map.h> 26#include <asm/mach/map.h>
26#include <asm/hardware/clock.h>
27#include <asm/io.h> 27#include <asm/io.h>
28#include <asm/setup.h> 28#include <asm/setup.h>
29 29
diff --git a/arch/arm/plat-omap/cpu-omap.c b/arch/arm/plat-omap/cpu-omap.c
index fd894bb00107..98edc9fdd6d1 100644
--- a/arch/arm/plat-omap/cpu-omap.c
+++ b/arch/arm/plat-omap/cpu-omap.c
@@ -19,13 +19,12 @@
19#include <linux/delay.h> 19#include <linux/delay.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/err.h> 21#include <linux/err.h>
22#include <linux/clk.h>
22 23
23#include <asm/hardware.h> 24#include <asm/hardware.h>
24#include <asm/io.h> 25#include <asm/io.h>
25#include <asm/system.h> 26#include <asm/system.h>
26 27
27#include <asm/hardware/clock.h>
28
29/* TODO: Add support for SDRAM timing changes */ 28/* TODO: Add support for SDRAM timing changes */
30 29
31int omap_verify_speed(struct cpufreq_policy *policy) 30int omap_verify_speed(struct cpufreq_policy *policy)
diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c
index 76f721d85137..ca3681a824ac 100644
--- a/arch/arm/plat-omap/gpio.c
+++ b/arch/arm/plat-omap/gpio.c
@@ -19,9 +19,9 @@
19#include <linux/ptrace.h> 19#include <linux/ptrace.h>
20#include <linux/sysdev.h> 20#include <linux/sysdev.h>
21#include <linux/err.h> 21#include <linux/err.h>
22#include <linux/clk.h>
22 23
23#include <asm/hardware.h> 24#include <asm/hardware.h>
24#include <asm/hardware/clock.h>
25#include <asm/irq.h> 25#include <asm/irq.h>
26#include <asm/arch/irqs.h> 26#include <asm/arch/irqs.h>
27#include <asm/arch/gpio.h> 27#include <asm/arch/gpio.h>
diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
index ea9475c86656..be0e0f32a598 100644
--- a/arch/arm/plat-omap/mcbsp.c
+++ b/arch/arm/plat-omap/mcbsp.c
@@ -19,6 +19,7 @@
19#include <linux/completion.h> 19#include <linux/completion.h>
20#include <linux/interrupt.h> 20#include <linux/interrupt.h>
21#include <linux/err.h> 21#include <linux/err.h>
22#include <linux/clk.h>
22 23
23#include <asm/delay.h> 24#include <asm/delay.h>
24#include <asm/io.h> 25#include <asm/io.h>
@@ -30,8 +31,6 @@
30#include <asm/arch/dsp_common.h> 31#include <asm/arch/dsp_common.h>
31#include <asm/arch/mcbsp.h> 32#include <asm/arch/mcbsp.h>
32 33
33#include <asm/hardware/clock.h>
34
35#ifdef CONFIG_MCBSP_DEBUG 34#ifdef CONFIG_MCBSP_DEBUG
36#define DBG(x...) printk(x) 35#define DBG(x...) printk(x)
37#else 36#else
diff --git a/arch/arm/plat-omap/ocpi.c b/arch/arm/plat-omap/ocpi.c
index b86148227480..e40fcc8b43d4 100644
--- a/arch/arm/plat-omap/ocpi.c
+++ b/arch/arm/plat-omap/ocpi.c
@@ -31,9 +31,9 @@
31#include <linux/init.h> 31#include <linux/init.h>
32#include <linux/spinlock.h> 32#include <linux/spinlock.h>
33#include <linux/err.h> 33#include <linux/err.h>
34#include <linux/clk.h>
34 35
35#include <asm/io.h> 36#include <asm/io.h>
36#include <asm/hardware/clock.h>
37#include <asm/hardware.h> 37#include <asm/hardware.h>
38 38
39#define OCPI_BASE 0xfffec320 39#define OCPI_BASE 0xfffec320