Merge branch 'multiplatform/platform-data' into next/multiplatform
[platform/kernel/linux-arm64.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
33 #include <asm/mach/arch.h>
34 #include <mach/dma.h>
35 #include <mach/hardware.h>
36 #include <mach/csp/mm_io.h>
37 #include <mach/csp/chipcHw_def.h>
38 #include <mach/csp/chipcHw_inline.h>
39
40 #include <mach/cfg_global.h>
41
42 #include "core.h"
43
44 HW_DECLARE_SPINLOCK(arch)
45 HW_DECLARE_SPINLOCK(gpio)
46 #if defined(CONFIG_DEBUG_SPINLOCK)
47     EXPORT_SYMBOL(bcmring_gpio_reg_lock);
48 #endif
49
50 /* sysctl */
51 static int bcmring_arch_warm_reboot;    /* do a warm reboot on hard reset */
52
53 static void bcmring_restart(char mode, const char *cmd)
54 {
55         printk("arch_reset:%c %x\n", mode, bcmring_arch_warm_reboot);
56
57         if (mode == 'h') {
58                 /* Reboot configured in proc entry */
59                 if (bcmring_arch_warm_reboot) {
60                         printk("warm reset\n");
61                         /* Issue Warm reset (do not reset ethernet switch, keep alive) */
62                         chipcHw_reset(chipcHw_REG_SOFT_RESET_CHIP_WARM);
63                 } else {
64                         /* Force reset of everything */
65                         printk("force reset\n");
66                         chipcHw_reset(chipcHw_REG_SOFT_RESET_CHIP_SOFT);
67                 }
68         } else {
69                 /* Force reset of everything */
70                 printk("force reset\n");
71                 chipcHw_reset(chipcHw_REG_SOFT_RESET_CHIP_SOFT);
72         }
73 }
74
75 static struct ctl_table_header *bcmring_sysctl_header;
76
77 static struct ctl_table bcmring_sysctl_warm_reboot[] = {
78         {
79          .procname = "warm",
80          .data = &bcmring_arch_warm_reboot,
81          .maxlen = sizeof(int),
82          .mode = 0644,
83          .proc_handler = proc_dointvec},
84         {}
85 };
86
87 static struct ctl_table bcmring_sysctl_reboot[] = {
88         {
89          .procname = "reboot",
90          .mode = 0555,
91          .child = bcmring_sysctl_warm_reboot},
92         {}
93 };
94
95 static struct resource nand_resource[] = {
96         [0] = {
97                 .start = MM_ADDR_IO_NAND,
98                 .end = MM_ADDR_IO_NAND + 0x1000 - 1,
99                 .flags = IORESOURCE_MEM,
100         },
101 };
102
103 static struct platform_device nand_device = {
104         .name = "bcm-nand",
105         .id = -1,
106         .resource = nand_resource,
107         .num_resources  = ARRAY_SIZE(nand_resource),
108 };
109
110 static struct resource pmu_resource = {
111         .start  = IRQ_PMUIRQ,
112         .end    = IRQ_PMUIRQ,
113         .flags  = IORESOURCE_IRQ,
114 };
115
116 static struct platform_device pmu_device = {
117         .name           = "arm-pmu",
118         .id             = -1,
119         .resource       = &pmu_resource,
120         .num_resources  = 1,
121 };
122
123
124 static struct platform_device *devices[] __initdata = {
125         &nand_device,
126         &pmu_device,
127 };
128
129 /****************************************************************************
130 *
131 *   Called from the customize_machine function in arch/arm/kernel/setup.c
132 *
133 *   The customize_machine function is tagged as an arch_initcall
134 *   (see include/linux/init.h for the order that the various init sections
135 *   are called in.
136 *
137 *****************************************************************************/
138 static void __init bcmring_init_machine(void)
139 {
140
141         bcmring_sysctl_header = register_sysctl_table(bcmring_sysctl_reboot);
142
143         /* Enable spread spectrum */
144         chipcHw_enableSpreadSpectrum();
145
146         platform_add_devices(devices, ARRAY_SIZE(devices));
147
148         bcmring_amba_init();
149
150         dma_init();
151 }
152
153 /****************************************************************************
154 *
155 *   Called from setup_arch (in arch/arm/kernel/setup.c) to fixup any tags
156 *   passed in by the boot loader.
157 *
158 *****************************************************************************/
159
160 static void __init bcmring_fixup(struct tag *t, char **cmdline,
161         struct meminfo *mi) {
162 #ifdef CONFIG_BLK_DEV_INITRD
163         printk(KERN_NOTICE "bcmring_fixup\n");
164         t->hdr.tag = ATAG_CORE;
165         t->hdr.size = tag_size(tag_core);
166         t->u.core.flags = 0;
167         t->u.core.pagesize = PAGE_SIZE;
168         t->u.core.rootdev = 31 << 8 | 0;
169         t = tag_next(t);
170
171         t->hdr.tag = ATAG_MEM;
172         t->hdr.size = tag_size(tag_mem32);
173         t->u.mem.start = CFG_GLOBAL_RAM_BASE;
174         t->u.mem.size = CFG_GLOBAL_RAM_SIZE;
175
176         t = tag_next(t);
177
178         t->hdr.tag = ATAG_NONE;
179         t->hdr.size = 0;
180 #endif
181 }
182
183 /****************************************************************************
184 *
185 *   Machine Description
186 *
187 *****************************************************************************/
188
189 MACHINE_START(BCMRING, "BCMRING")
190         /* Maintainer: Broadcom Corporation */
191         .fixup = bcmring_fixup,
192         .map_io = bcmring_map_io,
193         .init_early = bcmring_init_early,
194         .init_irq = bcmring_init_irq,
195         .timer = &bcmring_timer,
196         .init_machine = bcmring_init_machine,
197         .restart = bcmring_restart,
198 MACHINE_END