arch.c 5.1 KB

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