patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / arch / arm / mach-integrator / core.c
1 /*
2  *  linux/arch/arm/mach-integrator/core.c
3  *
4  *  Copyright (C) 2000-2003 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 version 2, as
8  * published by the Free Software Foundation.
9  */
10 #include <linux/types.h>
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/device.h>
14 #include <linux/spinlock.h>
15
16 #include <asm/hardware.h>
17 #include <asm/irq.h>
18 #include <asm/io.h>
19 #include <asm/hardware/amba.h>
20 #include <asm/arch/cm.h>
21
22 static struct amba_device rtc_device = {
23         .dev            = {
24                 .bus_id = "mb:15",
25         },
26         .res            = {
27                 .start  = INTEGRATOR_RTC_BASE,
28                 .end    = INTEGRATOR_RTC_BASE + SZ_4K - 1,
29                 .flags  = IORESOURCE_MEM,
30         },
31         .irq            = { IRQ_RTCINT, NO_IRQ },
32         .periphid       = 0x00041030,
33 };
34
35 static struct amba_device uart0_device = {
36         .dev            = {
37                 .bus_id = "mb:16",
38         },
39         .res            = {
40                 .start  = INTEGRATOR_UART0_BASE,
41                 .end    = INTEGRATOR_UART0_BASE + SZ_4K - 1,
42                 .flags  = IORESOURCE_MEM,
43         },
44         .irq            = { IRQ_UARTINT0, NO_IRQ },
45         .periphid       = 0x0041010,
46 };
47
48 static struct amba_device uart1_device = {
49         .dev            = {
50                 .bus_id = "mb:17",
51         },
52         .res            = {
53                 .start  = INTEGRATOR_UART1_BASE,
54                 .end    = INTEGRATOR_UART1_BASE + SZ_4K - 1,
55                 .flags  = IORESOURCE_MEM,
56         },
57         .irq            = { IRQ_UARTINT1, NO_IRQ },
58         .periphid       = 0x0041010,
59 };
60
61 static struct amba_device kmi0_device = {
62         .dev            = {
63                 .bus_id = "mb:18",
64         },
65         .res            = {
66                 .start  = KMI0_BASE,
67                 .end    = KMI0_BASE + SZ_4K - 1,
68                 .flags  = IORESOURCE_MEM,
69         },
70         .irq            = { IRQ_KMIINT0, NO_IRQ },
71         .periphid       = 0x00041050,
72 };
73
74 static struct amba_device kmi1_device = {
75         .dev            = {
76                 .bus_id = "mb:19",
77         },
78         .res            = {
79                 .start  = KMI1_BASE,
80                 .end    = KMI1_BASE + SZ_4K - 1,
81                 .flags  = IORESOURCE_MEM,
82         },
83         .irq            = { IRQ_KMIINT1, NO_IRQ },
84         .periphid       = 0x00041050,
85 };
86
87 static struct amba_device *amba_devs[] __initdata = {
88         &rtc_device,
89         &uart0_device,
90         &uart1_device,
91         &kmi0_device,
92         &kmi1_device,
93 };
94
95 static int __init integrator_init(void)
96 {
97         int i;
98
99         for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
100                 struct amba_device *d = amba_devs[i];
101                 amba_device_register(d, &iomem_resource);
102         }
103
104         return 0;
105 }
106
107 arch_initcall(integrator_init);
108
109 #define CM_CTRL IO_ADDRESS(INTEGRATOR_HDR_BASE) + INTEGRATOR_HDR_CTRL_OFFSET
110
111 static spinlock_t cm_lock = SPIN_LOCK_UNLOCKED;
112
113 /**
114  * cm_control - update the CM_CTRL register.
115  * @mask: bits to change
116  * @set: bits to set
117  */
118 void cm_control(u32 mask, u32 set)
119 {
120         unsigned long flags;
121         u32 val;
122
123         spin_lock_irqsave(&cm_lock, flags);
124         val = readl(CM_CTRL) & ~mask;
125         writel(val | set, CM_CTRL);
126         spin_unlock_irqrestore(&cm_lock, flags);
127 }
128
129 EXPORT_SYMBOL(cm_control);