prpmc2800.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * Board setup routines for the Motorola PrPMC2800
  3. *
  4. * Author: Dale Farnsworth <dale@farnsworth.org>
  5. *
  6. * 2007 (c) MontaVista, Software, Inc. This file is licensed under
  7. * the terms of the GNU General Public License version 2. This program
  8. * is licensed "as is" without any warranty of any kind, whether express
  9. * or implied.
  10. */
  11. #include <linux/stddef.h>
  12. #include <linux/kernel.h>
  13. #include <linux/delay.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/seq_file.h>
  16. #include <asm/machdep.h>
  17. #include <asm/prom.h>
  18. #include <asm/system.h>
  19. #include <asm/time.h>
  20. #include <asm/kexec.h>
  21. #include <mm/mmu_decl.h>
  22. #include <sysdev/mv64x60.h>
  23. #define MV64x60_MPP_CNTL_0 0x0000
  24. #define MV64x60_MPP_CNTL_2 0x0008
  25. #define MV64x60_GPP_IO_CNTL 0x0000
  26. #define MV64x60_GPP_LEVEL_CNTL 0x0010
  27. #define MV64x60_GPP_VALUE_SET 0x0018
  28. #define PLATFORM_NAME_MAX 32
  29. static char prpmc2800_platform_name[PLATFORM_NAME_MAX];
  30. static void __iomem *mv64x60_mpp_reg_base;
  31. static void __iomem *mv64x60_gpp_reg_base;
  32. static void __init prpmc2800_setup_arch(void)
  33. {
  34. struct device_node *np;
  35. phys_addr_t paddr;
  36. const unsigned int *reg;
  37. const unsigned int *prop;
  38. /*
  39. * ioremap mpp and gpp registers in case they are later
  40. * needed by prpmc2800_reset_board().
  41. */
  42. np = of_find_compatible_node(NULL, NULL, "marvell,mv64x60-mpp");
  43. reg = of_get_property(np, "reg", NULL);
  44. paddr = of_translate_address(np, reg);
  45. of_node_put(np);
  46. mv64x60_mpp_reg_base = ioremap(paddr, reg[1]);
  47. np = of_find_compatible_node(NULL, NULL, "marvell,mv64x60-gpp");
  48. reg = of_get_property(np, "reg", NULL);
  49. paddr = of_translate_address(np, reg);
  50. of_node_put(np);
  51. mv64x60_gpp_reg_base = ioremap(paddr, reg[1]);
  52. np = of_find_node_by_type(NULL, "cpu");
  53. prop = of_get_property(np, "clock-frequency", NULL);
  54. if (prop)
  55. loops_per_jiffy = *prop / HZ;
  56. of_node_put(np);
  57. #ifdef CONFIG_PCI
  58. mv64x60_pci_init();
  59. #endif
  60. printk("Motorola %s\n", prpmc2800_platform_name);
  61. }
  62. static void prpmc2800_reset_board(void)
  63. {
  64. u32 temp;
  65. local_irq_disable();
  66. temp = in_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_0);
  67. temp &= 0xFFFF0FFF;
  68. out_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_0, temp);
  69. temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL);
  70. temp |= 0x00000004;
  71. out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL, temp);
  72. temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL);
  73. temp |= 0x00000004;
  74. out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL, temp);
  75. temp = in_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_2);
  76. temp &= 0xFFFF0FFF;
  77. out_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_2, temp);
  78. temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL);
  79. temp |= 0x00080000;
  80. out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL, temp);
  81. temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL);
  82. temp |= 0x00080000;
  83. out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL, temp);
  84. out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_VALUE_SET, 0x00080004);
  85. }
  86. static void prpmc2800_restart(char *cmd)
  87. {
  88. volatile ulong i = 10000000;
  89. prpmc2800_reset_board();
  90. while (i-- > 0);
  91. panic("restart failed\n");
  92. }
  93. #ifdef CONFIG_NOT_COHERENT_CACHE
  94. #define PPRPM2800_COHERENCY_SETTING "off"
  95. #else
  96. #define PPRPM2800_COHERENCY_SETTING "on"
  97. #endif
  98. void prpmc2800_show_cpuinfo(struct seq_file *m)
  99. {
  100. uint memsize = total_memory;
  101. seq_printf(m, "Vendor\t\t: Motorola\n");
  102. seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
  103. seq_printf(m, "coherency\t: %s\n", PPRPM2800_COHERENCY_SETTING);
  104. }
  105. /*
  106. * Called very early, device-tree isn't unflattened
  107. */
  108. static int __init prpmc2800_probe(void)
  109. {
  110. unsigned long root = of_get_flat_dt_root();
  111. unsigned long len = PLATFORM_NAME_MAX;
  112. void *m;
  113. if (!of_flat_dt_is_compatible(root, "motorola,PrPMC2800"))
  114. return 0;
  115. /* Update ppc_md.name with name from dt */
  116. m = of_get_flat_dt_prop(root, "model", &len);
  117. if (m)
  118. strncpy(prpmc2800_platform_name, m,
  119. min((int)len, PLATFORM_NAME_MAX - 1));
  120. return 1;
  121. }
  122. define_machine(prpmc2800){
  123. .name = prpmc2800_platform_name,
  124. .probe = prpmc2800_probe,
  125. .setup_arch = prpmc2800_setup_arch,
  126. .show_cpuinfo = prpmc2800_show_cpuinfo,
  127. .init_IRQ = mv64x60_init_irq,
  128. .get_irq = mv64x60_get_irq,
  129. .restart = prpmc2800_restart,
  130. .calibrate_decr = generic_calibrate_decr,
  131. #ifdef CONFIG_KEXEC
  132. .machine_kexec = default_machine_kexec,
  133. .machine_kexec_prepare = default_machine_kexec_prepare,
  134. .machine_crash_shutdown = default_machine_crash_shutdown,
  135. #endif
  136. };