prpmc2800.c 3.9 KB

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