c2k.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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/system.h>
  25. #include <asm/time.h>
  26. #include <mm/mmu_decl.h>
  27. #include <sysdev/mv64x60.h>
  28. #define MV64x60_MPP_CNTL_0 0x0000
  29. #define MV64x60_MPP_CNTL_2 0x0008
  30. #define MV64x60_GPP_IO_CNTL 0x0000
  31. #define MV64x60_GPP_LEVEL_CNTL 0x0010
  32. #define MV64x60_GPP_VALUE_SET 0x0018
  33. static void __iomem *mv64x60_mpp_reg_base;
  34. static void __iomem *mv64x60_gpp_reg_base;
  35. static void __init c2k_setup_arch(void)
  36. {
  37. struct device_node *np;
  38. phys_addr_t paddr;
  39. const unsigned int *reg;
  40. /*
  41. * ioremap mpp and gpp registers in case they are later
  42. * needed by c2k_reset_board().
  43. */
  44. np = of_find_compatible_node(NULL, NULL, "marvell,mv64360-mpp");
  45. reg = of_get_property(np, "reg", NULL);
  46. paddr = of_translate_address(np, reg);
  47. of_node_put(np);
  48. mv64x60_mpp_reg_base = ioremap(paddr, reg[1]);
  49. np = of_find_compatible_node(NULL, NULL, "marvell,mv64360-gpp");
  50. reg = of_get_property(np, "reg", NULL);
  51. paddr = of_translate_address(np, reg);
  52. of_node_put(np);
  53. mv64x60_gpp_reg_base = ioremap(paddr, reg[1]);
  54. #ifdef CONFIG_PCI
  55. mv64x60_pci_init();
  56. #endif
  57. }
  58. static void c2k_reset_board(void)
  59. {
  60. u32 temp;
  61. local_irq_disable();
  62. temp = in_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_0);
  63. temp &= 0xFFFF0FFF;
  64. out_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_0, temp);
  65. temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL);
  66. temp |= 0x00000004;
  67. out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL, temp);
  68. temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL);
  69. temp |= 0x00000004;
  70. out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL, temp);
  71. temp = in_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_2);
  72. temp &= 0xFFFF0FFF;
  73. out_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_2, temp);
  74. temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL);
  75. temp |= 0x00080000;
  76. out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL, temp);
  77. temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL);
  78. temp |= 0x00080000;
  79. out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL, temp);
  80. out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_VALUE_SET, 0x00080004);
  81. }
  82. static void c2k_restart(char *cmd)
  83. {
  84. c2k_reset_board();
  85. msleep(100);
  86. panic("restart failed\n");
  87. }
  88. #ifdef CONFIG_NOT_COHERENT_CACHE
  89. #define COHERENCY_SETTING "off"
  90. #else
  91. #define COHERENCY_SETTING "on"
  92. #endif
  93. void c2k_show_cpuinfo(struct seq_file *m)
  94. {
  95. seq_printf(m, "Vendor\t\t: GEFanuc\n");
  96. seq_printf(m, "coherency\t: %s\n", COHERENCY_SETTING);
  97. }
  98. /*
  99. * Called very early, device-tree isn't unflattened
  100. */
  101. static int __init c2k_probe(void)
  102. {
  103. unsigned long root = of_get_flat_dt_root();
  104. if (!of_flat_dt_is_compatible(root, "GEFanuc,C2K"))
  105. return 0;
  106. printk(KERN_INFO "Detected a GEFanuc C2K board\n");
  107. _set_L2CR(0);
  108. _set_L2CR(L2CR_L2E | L2CR_L2PE | L2CR_L2I);
  109. return 1;
  110. }
  111. define_machine(c2k) {
  112. .name = "C2K",
  113. .probe = c2k_probe,
  114. .setup_arch = c2k_setup_arch,
  115. .init_early = mv64x60_init_early,
  116. .show_cpuinfo = c2k_show_cpuinfo,
  117. .init_IRQ = mv64x60_init_irq,
  118. .get_irq = mv64x60_get_irq,
  119. .restart = c2k_restart,
  120. .calibrate_decr = generic_calibrate_decr,
  121. };