xes_mpc85xx.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (C) 2009 Extreme Engineering Solutions, Inc.
  4. *
  5. * X-ES board-specific functionality
  6. *
  7. * Based on mpc85xx_ds code from Freescale Semiconductor, Inc.
  8. *
  9. * Author: Nate Case <ncase@xes-inc.com>
  10. */
  11. #include <linux/stddef.h>
  12. #include <linux/kernel.h>
  13. #include <linux/pci.h>
  14. #include <linux/kdev_t.h>
  15. #include <linux/delay.h>
  16. #include <linux/seq_file.h>
  17. #include <linux/interrupt.h>
  18. #include <linux/of.h>
  19. #include <linux/of_address.h>
  20. #include <asm/time.h>
  21. #include <asm/machdep.h>
  22. #include <asm/pci-bridge.h>
  23. #include <mm/mmu_decl.h>
  24. #include <asm/udbg.h>
  25. #include <asm/mpic.h>
  26. #include <sysdev/fsl_soc.h>
  27. #include <sysdev/fsl_pci.h>
  28. #include "smp.h"
  29. #include "mpc85xx.h"
  30. /* A few bit definitions needed for fixups on some boards */
  31. #define MPC85xx_L2CTL_L2E 0x80000000 /* L2 enable */
  32. #define MPC85xx_L2CTL_L2I 0x40000000 /* L2 flash invalidate */
  33. #define MPC85xx_L2CTL_L2SIZ_MASK 0x30000000 /* L2 SRAM size (R/O) */
  34. static void __init xes_mpc85xx_pic_init(void)
  35. {
  36. struct mpic *mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN,
  37. 0, 256, " OpenPIC ");
  38. BUG_ON(mpic == NULL);
  39. mpic_init(mpic);
  40. }
  41. static void __init xes_mpc85xx_configure_l2(void __iomem *l2_base)
  42. {
  43. volatile uint32_t ctl, tmp;
  44. asm volatile("msync; isync");
  45. tmp = in_be32(l2_base);
  46. /*
  47. * xMon may have enabled part of L2 as SRAM, so we need to set it
  48. * up for all cache mode just to be safe.
  49. */
  50. printk(KERN_INFO "xes_mpc85xx: Enabling L2 as cache\n");
  51. ctl = MPC85xx_L2CTL_L2E | MPC85xx_L2CTL_L2I;
  52. if (of_machine_is_compatible("MPC8540") ||
  53. of_machine_is_compatible("MPC8560"))
  54. /*
  55. * Assume L2 SRAM is used fully for cache, so set
  56. * L2BLKSZ (bits 4:5) to match L2SIZ (bits 2:3).
  57. */
  58. ctl |= (tmp & MPC85xx_L2CTL_L2SIZ_MASK) >> 2;
  59. asm volatile("msync; isync");
  60. out_be32(l2_base, ctl);
  61. asm volatile("msync; isync");
  62. }
  63. static void __init xes_mpc85xx_fixups(void)
  64. {
  65. struct device_node *np;
  66. int err;
  67. /*
  68. * Legacy xMon firmware on some X-ES boards does not enable L2
  69. * as cache. We must ensure that they get enabled here.
  70. */
  71. for_each_node_by_name(np, "l2-cache-controller") {
  72. struct resource r[2];
  73. void __iomem *l2_base;
  74. /* Only MPC8548, MPC8540, and MPC8560 boards are affected */
  75. if (!of_device_is_compatible(np,
  76. "fsl,mpc8548-l2-cache-controller") &&
  77. !of_device_is_compatible(np,
  78. "fsl,mpc8540-l2-cache-controller") &&
  79. !of_device_is_compatible(np,
  80. "fsl,mpc8560-l2-cache-controller"))
  81. continue;
  82. err = of_address_to_resource(np, 0, &r[0]);
  83. if (err) {
  84. printk(KERN_WARNING "xes_mpc85xx: Could not get "
  85. "resource for device tree node '%pOF'",
  86. np);
  87. continue;
  88. }
  89. l2_base = ioremap(r[0].start, resource_size(&r[0]));
  90. xes_mpc85xx_configure_l2(l2_base);
  91. }
  92. }
  93. /*
  94. * Setup the architecture
  95. */
  96. static void __init xes_mpc85xx_setup_arch(void)
  97. {
  98. struct device_node *root;
  99. const char *model = "Unknown";
  100. root = of_find_node_by_path("/");
  101. if (root == NULL)
  102. return;
  103. model = of_get_property(root, "model", NULL);
  104. printk(KERN_INFO "X-ES MPC85xx-based single-board computer: %s\n",
  105. model + strlen("xes,"));
  106. xes_mpc85xx_fixups();
  107. mpc85xx_smp_init();
  108. fsl_pci_assign_primary();
  109. }
  110. machine_arch_initcall(xes_mpc8572, mpc85xx_common_publish_devices);
  111. machine_arch_initcall(xes_mpc8548, mpc85xx_common_publish_devices);
  112. machine_arch_initcall(xes_mpc8540, mpc85xx_common_publish_devices);
  113. define_machine(xes_mpc8572) {
  114. .name = "X-ES MPC8572",
  115. .compatible = "xes,MPC8572",
  116. .setup_arch = xes_mpc85xx_setup_arch,
  117. .init_IRQ = xes_mpc85xx_pic_init,
  118. #ifdef CONFIG_PCI
  119. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  120. .pcibios_fixup_phb = fsl_pcibios_fixup_phb,
  121. #endif
  122. .get_irq = mpic_get_irq,
  123. .progress = udbg_progress,
  124. };
  125. define_machine(xes_mpc8548) {
  126. .name = "X-ES MPC8548",
  127. .compatible = "xes,MPC8548",
  128. .setup_arch = xes_mpc85xx_setup_arch,
  129. .init_IRQ = xes_mpc85xx_pic_init,
  130. #ifdef CONFIG_PCI
  131. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  132. .pcibios_fixup_phb = fsl_pcibios_fixup_phb,
  133. #endif
  134. .get_irq = mpic_get_irq,
  135. .progress = udbg_progress,
  136. };
  137. define_machine(xes_mpc8540) {
  138. .name = "X-ES MPC8540",
  139. .compatible = "xes,MPC8540",
  140. .setup_arch = xes_mpc85xx_setup_arch,
  141. .init_IRQ = xes_mpc85xx_pic_init,
  142. #ifdef CONFIG_PCI
  143. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  144. .pcibios_fixup_phb = fsl_pcibios_fixup_phb,
  145. #endif
  146. .get_irq = mpic_get_irq,
  147. .progress = udbg_progress,
  148. };