prpmc2800.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. /*
  38. * ioremap mpp and gpp registers in case they are later
  39. * needed by prpmc2800_reset_board().
  40. */
  41. np = of_find_compatible_node(NULL, NULL, "marvell,mv64x60-mpp");
  42. reg = of_get_property(np, "reg", NULL);
  43. paddr = of_translate_address(np, reg);
  44. of_node_put(np);
  45. mv64x60_mpp_reg_base = ioremap(paddr, reg[1]);
  46. np = of_find_compatible_node(NULL, NULL, "marvell,mv64x60-gpp");
  47. reg = of_get_property(np, "reg", NULL);
  48. paddr = of_translate_address(np, reg);
  49. of_node_put(np);
  50. mv64x60_gpp_reg_base = ioremap(paddr, reg[1]);
  51. #ifdef CONFIG_PCI
  52. mv64x60_pci_init();
  53. #endif
  54. printk("Motorola %s\n", prpmc2800_platform_name);
  55. }
  56. static void prpmc2800_reset_board(void)
  57. {
  58. u32 temp;
  59. local_irq_disable();
  60. temp = in_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_0);
  61. temp &= 0xFFFF0FFF;
  62. out_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_0, temp);
  63. temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL);
  64. temp |= 0x00000004;
  65. out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL, temp);
  66. temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL);
  67. temp |= 0x00000004;
  68. out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL, temp);
  69. temp = in_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_2);
  70. temp &= 0xFFFF0FFF;
  71. out_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_2, temp);
  72. temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL);
  73. temp |= 0x00080000;
  74. out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL, temp);
  75. temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL);
  76. temp |= 0x00080000;
  77. out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL, temp);
  78. out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_VALUE_SET, 0x00080004);
  79. }
  80. static void prpmc2800_restart(char *cmd)
  81. {
  82. volatile ulong i = 10000000;
  83. prpmc2800_reset_board();
  84. while (i-- > 0);
  85. panic("restart failed\n");
  86. }
  87. #ifdef CONFIG_NOT_COHERENT_CACHE
  88. #define PPRPM2800_COHERENCY_SETTING "off"
  89. #else
  90. #define PPRPM2800_COHERENCY_SETTING "on"
  91. #endif
  92. void prpmc2800_show_cpuinfo(struct seq_file *m)
  93. {
  94. uint memsize = total_memory;
  95. seq_printf(m, "Vendor\t\t: Motorola\n");
  96. seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
  97. seq_printf(m, "coherency\t: %s\n", PPRPM2800_COHERENCY_SETTING);
  98. }
  99. /*
  100. * Called very early, device-tree isn't unflattened
  101. */
  102. static int __init prpmc2800_probe(void)
  103. {
  104. unsigned long root = of_get_flat_dt_root();
  105. unsigned long len = PLATFORM_NAME_MAX;
  106. void *m;
  107. if (!of_flat_dt_is_compatible(root, "motorola,PrPMC2800"))
  108. return 0;
  109. /* Update ppc_md.name with name from dt */
  110. m = of_get_flat_dt_prop(root, "model", &len);
  111. if (m)
  112. strncpy(prpmc2800_platform_name, m,
  113. min((int)len, PLATFORM_NAME_MAX - 1));
  114. return 1;
  115. }
  116. define_machine(prpmc2800){
  117. .name = prpmc2800_platform_name,
  118. .probe = prpmc2800_probe,
  119. .setup_arch = prpmc2800_setup_arch,
  120. .init_early = mv64x60_init_early,
  121. .show_cpuinfo = prpmc2800_show_cpuinfo,
  122. .init_IRQ = mv64x60_init_irq,
  123. .get_irq = mv64x60_get_irq,
  124. .restart = prpmc2800_restart,
  125. .calibrate_decr = generic_calibrate_decr,
  126. #ifdef CONFIG_KEXEC
  127. .machine_kexec = default_machine_kexec,
  128. .machine_kexec_prepare = default_machine_kexec_prepare,
  129. .machine_crash_shutdown = default_machine_crash_shutdown,
  130. #endif
  131. };