prpmc2800.c 4.0 KB

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