Merge branch '3.2-without-smb2' of git://git.samba.org/sfrench/cifs-2.6
[pandora-kernel.git] / arch / arm / mach-bcmring / arch.c
1 /*****************************************************************************
2 * Copyright 2003 - 2008 Broadcom Corporation.  All rights reserved.
3 *
4 * Unless you and Broadcom execute a separate written software license
5 * agreement governing use of this software, this software is licensed to you
6 * under the terms of the GNU General Public License version 2, available at
7 * http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
8 *
9 * Notwithstanding the above, under no circumstances may you combine this
10 * software in any way with any other Broadcom software provided under a
11 * license other than the GPL, without Broadcom's express prior written
12 * consent.
13 *****************************************************************************/
14
15 #include <linux/kernel.h>
16 #include <linux/platform_device.h>
17 #include <linux/types.h>
18 #include <linux/sched.h>
19 #include <linux/interrupt.h>
20 #include <linux/init.h>
21 #include <linux/errno.h>
22 #include <linux/spinlock.h>
23 #include <linux/module.h>
24
25 #include <linux/proc_fs.h>
26 #include <linux/sysctl.h>
27
28 #include <asm/irq.h>
29 #include <asm/setup.h>
30 #include <asm/mach-types.h>
31 #include <asm/mach/time.h>
32 #include <asm/pmu.h>
33
34 #include <asm/mach/arch.h>
35 #include <mach/dma.h>
36 #include <mach/hardware.h>
37 #include <mach/csp/mm_io.h>
38 #include <mach/csp/chipcHw_def.h>
39 #include <mach/csp/chipcHw_inline.h>
40
41 #include <cfg_global.h>
42
43 #include "core.h"
44
45 HW_DECLARE_SPINLOCK(arch)
46 HW_DECLARE_SPINLOCK(gpio)
47 #if defined(CONFIG_DEBUG_SPINLOCK)
48     EXPORT_SYMBOL(bcmring_gpio_reg_lock);
49 #endif
50
51 /* sysctl */
52 int bcmring_arch_warm_reboot;   /* do a warm reboot on hard reset */
53
54 static struct ctl_table_header *bcmring_sysctl_header;
55
56 static struct ctl_table bcmring_sysctl_warm_reboot[] = {
57         {
58          .procname = "warm",
59          .data = &bcmring_arch_warm_reboot,
60          .maxlen = sizeof(int),
61          .mode = 0644,
62          .proc_handler = proc_dointvec},
63         {}
64 };
65
66 static struct ctl_table bcmring_sysctl_reboot[] = {
67         {
68          .procname = "reboot",
69          .mode = 0555,
70          .child = bcmring_sysctl_warm_reboot},
71         {}
72 };
73
74 static struct resource nand_resource[] = {
75         [0] = {
76                 .start = MM_ADDR_IO_NAND,
77                 .end = MM_ADDR_IO_NAND + 0x1000 - 1,
78                 .flags = IORESOURCE_MEM,
79         },
80 };
81
82 static struct platform_device nand_device = {
83         .name = "bcm-nand",
84         .id = -1,
85         .resource = nand_resource,
86         .num_resources  = ARRAY_SIZE(nand_resource),
87 };
88
89 static struct resource pmu_resource = {
90         .start  = IRQ_PMUIRQ,
91         .end    = IRQ_PMUIRQ,
92         .flags  = IORESOURCE_IRQ,
93 };
94
95 static struct platform_device pmu_device = {
96         .name           = "arm-pmu",
97         .id             = ARM_PMU_DEVICE_CPU,
98         .resource       = &pmu_resource,
99         .num_resources  = 1,
100 };
101
102
103 static struct platform_device *devices[] __initdata = {
104         &nand_device,
105         &pmu_device,
106 };
107
108 /****************************************************************************
109 *
110 *   Called from the customize_machine function in arch/arm/kernel/setup.c
111 *
112 *   The customize_machine function is tagged as an arch_initcall
113 *   (see include/linux/init.h for the order that the various init sections
114 *   are called in.
115 *
116 *****************************************************************************/
117 static void __init bcmring_init_machine(void)
118 {
119
120         bcmring_sysctl_header = register_sysctl_table(bcmring_sysctl_reboot);
121
122         /* Enable spread spectrum */
123         chipcHw_enableSpreadSpectrum();
124
125         platform_add_devices(devices, ARRAY_SIZE(devices));
126
127         bcmring_amba_init();
128
129         dma_init();
130 }
131
132 /****************************************************************************
133 *
134 *   Called from setup_arch (in arch/arm/kernel/setup.c) to fixup any tags
135 *   passed in by the boot loader.
136 *
137 *****************************************************************************/
138
139 static void __init bcmring_fixup(struct tag *t, char **cmdline,
140         struct meminfo *mi) {
141 #ifdef CONFIG_BLK_DEV_INITRD
142         printk(KERN_NOTICE "bcmring_fixup\n");
143         t->hdr.tag = ATAG_CORE;
144         t->hdr.size = tag_size(tag_core);
145         t->u.core.flags = 0;
146         t->u.core.pagesize = PAGE_SIZE;
147         t->u.core.rootdev = 31 << 8 | 0;
148         t = tag_next(t);
149
150         t->hdr.tag = ATAG_MEM;
151         t->hdr.size = tag_size(tag_mem32);
152         t->u.mem.start = CFG_GLOBAL_RAM_BASE;
153         t->u.mem.size = CFG_GLOBAL_RAM_SIZE;
154
155         t = tag_next(t);
156
157         t->hdr.tag = ATAG_NONE;
158         t->hdr.size = 0;
159 #endif
160 }
161
162 /****************************************************************************
163 *
164 *   Machine Description
165 *
166 *****************************************************************************/
167
168 MACHINE_START(BCMRING, "BCMRING")
169         /* Maintainer: Broadcom Corporation */
170         .fixup = bcmring_fixup,
171         .map_io = bcmring_map_io,
172         .init_early = bcmring_init_early,
173         .init_irq = bcmring_init_irq,
174         .timer = &bcmring_timer,
175         .init_machine = bcmring_init_machine
176 MACHINE_END