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