c2k.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * Board setup routines for the GEFanuc C2K board
  3. *
  4. * Author: Remi Machet <rmachet@slac.stanford.edu>
  5. *
  6. * Originated from prpmc2800.c
  7. *
  8. * 2008 (c) Stanford University
  9. * 2007 (c) MontaVista, Software, Inc.
  10. *
  11. * This program is free software; you can redistribute it and/or modify it
  12. * under the terms of the GNU General Public License version 2 as published
  13. * by the Free Software Foundation.
  14. */
  15. #include <linux/stddef.h>
  16. #include <linux/kernel.h>
  17. #include <linux/delay.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/seq_file.h>
  20. #include <linux/time.h>
  21. #include <linux/of.h>
  22. #include <asm/machdep.h>
  23. #include <asm/prom.h>
  24. #include <asm/time.h>
  25. #include <mm/mmu_decl.h>
  26. #include <sysdev/mv64x60.h>
  27. #define MV64x60_MPP_CNTL_0 0x0000
  28. #define MV64x60_MPP_CNTL_2 0x0008
  29. #define MV64x60_GPP_IO_CNTL 0x0000
  30. #define MV64x60_GPP_LEVEL_CNTL 0x0010
  31. #define MV64x60_GPP_VALUE_SET 0x0018
  32. static void __iomem *mv64x60_mpp_reg_base;
  33. static void __iomem *mv64x60_gpp_reg_base;
  34. static void __init c2k_setup_arch(void)
  35. {
  36. struct device_node *np;
  37. phys_addr_t paddr;
  38. const unsigned int *reg;
  39. /*
  40. * ioremap mpp and gpp registers in case they are later
  41. * needed by c2k_reset_board().
  42. */
  43. np = of_find_compatible_node(NULL, NULL, "marvell,mv64360-mpp");
  44. reg = of_get_property(np, "reg", NULL);
  45. paddr = of_translate_address(np, reg);
  46. of_node_put(np);
  47. mv64x60_mpp_reg_base = ioremap(paddr, reg[1]);
  48. np = of_find_compatible_node(NULL, NULL, "marvell,mv64360-gpp");
  49. reg = of_get_property(np, "reg", NULL);
  50. paddr = of_translate_address(np, reg);
  51. of_node_put(np);
  52. mv64x60_gpp_reg_base = ioremap(paddr, reg[1]);
  53. #ifdef CONFIG_PCI
  54. mv64x60_pci_init();
  55. #endif
  56. }
  57. static void c2k_reset_board(void)
  58. {
  59. u32 temp;
  60. local_irq_disable();
  61. temp = in_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_0);
  62. temp &= 0xFFFF0FFF;
  63. out_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_0, temp);
  64. temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL);
  65. temp |= 0x00000004;
  66. out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL, temp);
  67. temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL);
  68. temp |= 0x00000004;
  69. out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL, temp);
  70. temp = in_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_2);
  71. temp &= 0xFFFF0FFF;
  72. out_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_2, temp);
  73. temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL);
  74. temp |= 0x00080000;
  75. out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL, temp);
  76. temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL);
  77. temp |= 0x00080000;
  78. out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL, temp);
  79. out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_VALUE_SET, 0x00080004);
  80. }
  81. static void __noreturn c2k_restart(char *cmd)
  82. {
  83. c2k_reset_board();
  84. msleep(100);
  85. panic("restart failed\n");
  86. }
  87. #ifdef CONFIG_NOT_COHERENT_CACHE
  88. #define COHERENCY_SETTING "off"
  89. #else
  90. #define COHERENCY_SETTING "on"
  91. #endif
  92. void c2k_show_cpuinfo(struct seq_file *m)
  93. {
  94. seq_printf(m, "Vendor\t\t: GEFanuc\n");
  95. seq_printf(m, "coherency\t: %s\n", COHERENCY_SETTING);
  96. }
  97. /*
  98. * Called very early, device-tree isn't unflattened
  99. */
  100. static int __init c2k_probe(void)
  101. {
  102. if (!of_machine_is_compatible("GEFanuc,C2K"))
  103. return 0;
  104. printk(KERN_INFO "Detected a GEFanuc C2K board\n");
  105. _set_L2CR(0);
  106. _set_L2CR(L2CR_L2E | L2CR_L2PE | L2CR_L2I);
  107. mv64x60_init_early();
  108. return 1;
  109. }
  110. define_machine(c2k) {
  111. .name = "C2K",
  112. .probe = c2k_probe,
  113. .setup_arch = c2k_setup_arch,
  114. .show_cpuinfo = c2k_show_cpuinfo,
  115. .init_IRQ = mv64x60_init_irq,
  116. .get_irq = mv64x60_get_irq,
  117. .restart = c2k_restart,
  118. .calibrate_decr = generic_calibrate_decr,
  119. };