tqm85xx.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. * Based on MPC8560 ADS and arch/ppc tqm85xx ports
  3. *
  4. * Maintained by Kumar Gala (see MAINTAINERS for contact information)
  5. *
  6. * Copyright 2008 Freescale Semiconductor Inc.
  7. *
  8. * Copyright (c) 2005-2006 DENX Software Engineering
  9. * Stefan Roese <sr@denx.de>
  10. *
  11. * Based on original work by
  12. * Kumar Gala <kumar.gala@freescale.com>
  13. * Copyright 2004 Freescale Semiconductor Inc.
  14. *
  15. * This program is free software; you can redistribute it and/or modify it
  16. * under the terms of the GNU General Public License as published by the
  17. * Free Software Foundation; either version 2 of the License, or (at your
  18. * option) any later version.
  19. */
  20. #include <linux/stddef.h>
  21. #include <linux/kernel.h>
  22. #include <linux/pci.h>
  23. #include <linux/kdev_t.h>
  24. #include <linux/delay.h>
  25. #include <linux/seq_file.h>
  26. #include <linux/of_platform.h>
  27. #include <asm/system.h>
  28. #include <asm/time.h>
  29. #include <asm/machdep.h>
  30. #include <asm/pci-bridge.h>
  31. #include <asm/mpic.h>
  32. #include <asm/prom.h>
  33. #include <mm/mmu_decl.h>
  34. #include <asm/udbg.h>
  35. #include <sysdev/fsl_soc.h>
  36. #include <sysdev/fsl_pci.h>
  37. #include "mpc85xx.h"
  38. #ifdef CONFIG_CPM2
  39. #include <asm/cpm2.h>
  40. #endif /* CONFIG_CPM2 */
  41. static void __init tqm85xx_pic_init(void)
  42. {
  43. struct mpic *mpic;
  44. struct resource r;
  45. struct device_node *np;
  46. np = of_find_node_by_type(NULL, "open-pic");
  47. if (!np) {
  48. printk(KERN_ERR "Could not find open-pic node\n");
  49. return;
  50. }
  51. if (of_address_to_resource(np, 0, &r)) {
  52. printk(KERN_ERR "Could not map mpic register space\n");
  53. of_node_put(np);
  54. return;
  55. }
  56. mpic = mpic_alloc(np, r.start,
  57. MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
  58. 0, 256, " OpenPIC ");
  59. BUG_ON(mpic == NULL);
  60. of_node_put(np);
  61. mpic_init(mpic);
  62. mpc85xx_cpm2_pic_init();
  63. }
  64. /*
  65. * Setup the architecture
  66. */
  67. static void __init tqm85xx_setup_arch(void)
  68. {
  69. #ifdef CONFIG_PCI
  70. struct device_node *np;
  71. #endif
  72. if (ppc_md.progress)
  73. ppc_md.progress("tqm85xx_setup_arch()", 0);
  74. #ifdef CONFIG_CPM2
  75. cpm2_reset();
  76. #endif
  77. #ifdef CONFIG_PCI
  78. for_each_node_by_type(np, "pci") {
  79. if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
  80. of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
  81. struct resource rsrc;
  82. if (!of_address_to_resource(np, 0, &rsrc)) {
  83. if ((rsrc.start & 0xfffff) == 0x8000)
  84. fsl_add_bridge(np, 1);
  85. else
  86. fsl_add_bridge(np, 0);
  87. }
  88. }
  89. }
  90. #endif
  91. }
  92. static void tqm85xx_show_cpuinfo(struct seq_file *m)
  93. {
  94. uint pvid, svid, phid1;
  95. pvid = mfspr(SPRN_PVR);
  96. svid = mfspr(SPRN_SVR);
  97. seq_printf(m, "Vendor\t\t: TQ Components\n");
  98. seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
  99. seq_printf(m, "SVR\t\t: 0x%x\n", svid);
  100. /* Display cpu Pll setting */
  101. phid1 = mfspr(SPRN_HID1);
  102. seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
  103. }
  104. static void __init tqm85xx_ti1520_fixup(struct pci_dev *pdev)
  105. {
  106. unsigned int val;
  107. /* Do not do the fixup on other platforms! */
  108. if (!machine_is(tqm85xx))
  109. return;
  110. dev_info(&pdev->dev, "Using TI 1520 fixup on TQM85xx\n");
  111. /*
  112. * Enable P2CCLK bit in system control register
  113. * to enable CLOCK output to power chip
  114. */
  115. pci_read_config_dword(pdev, 0x80, &val);
  116. pci_write_config_dword(pdev, 0x80, val | (1 << 27));
  117. }
  118. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1520,
  119. tqm85xx_ti1520_fixup);
  120. static struct of_device_id __initdata of_bus_ids[] = {
  121. { .compatible = "simple-bus", },
  122. { .compatible = "gianfar", },
  123. {},
  124. };
  125. static int __init declare_of_platform_devices(void)
  126. {
  127. of_platform_bus_probe(NULL, of_bus_ids, NULL);
  128. return 0;
  129. }
  130. machine_device_initcall(tqm85xx, declare_of_platform_devices);
  131. static const char *board[] __initdata = {
  132. "tqc,tqm8540",
  133. "tqc,tqm8541",
  134. "tqc,tqm8548",
  135. "tqc,tqm8555",
  136. "tqc,tqm8560",
  137. NULL
  138. };
  139. /*
  140. * Called very early, device-tree isn't unflattened
  141. */
  142. static int __init tqm85xx_probe(void)
  143. {
  144. return of_flat_dt_match(of_get_flat_dt_root(), board);
  145. }
  146. define_machine(tqm85xx) {
  147. .name = "TQM85xx",
  148. .probe = tqm85xx_probe,
  149. .setup_arch = tqm85xx_setup_arch,
  150. .init_IRQ = tqm85xx_pic_init,
  151. .show_cpuinfo = tqm85xx_show_cpuinfo,
  152. .get_irq = mpic_get_irq,
  153. .restart = fsl_rstcr_restart,
  154. .calibrate_decr = generic_calibrate_decr,
  155. .progress = udbg_progress,
  156. };