arch.c 5.1 KB

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