mpc8610_hpcd.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /*
  2. * MPC8610 HPCD board specific routines
  3. *
  4. * Initial author: Xianghua Xiao <x.xiao@freescale.com>
  5. * Recode: Jason Jin <jason.jin@freescale.com>
  6. *
  7. * Rewrite the interrupt routing. remove the 8259PIC support,
  8. * All the integrated device in ULI use sideband interrupt.
  9. *
  10. * Copyright 2007 Freescale Semiconductor Inc.
  11. *
  12. * This program is free software; you can redistribute it and/or modify it
  13. * under the terms of the GNU General Public License as published by the
  14. * Free Software Foundation; either version 2 of the License, or (at your
  15. * option) any later version.
  16. */
  17. #include <linux/stddef.h>
  18. #include <linux/kernel.h>
  19. #include <linux/pci.h>
  20. #include <linux/kdev_t.h>
  21. #include <linux/delay.h>
  22. #include <linux/seq_file.h>
  23. #include <linux/of.h>
  24. #include <asm/system.h>
  25. #include <asm/time.h>
  26. #include <asm/machdep.h>
  27. #include <asm/pci-bridge.h>
  28. #include <asm/mpc86xx.h>
  29. #include <asm/prom.h>
  30. #include <mm/mmu_decl.h>
  31. #include <asm/udbg.h>
  32. #include <asm/mpic.h>
  33. #include <linux/of_platform.h>
  34. #include <sysdev/fsl_pci.h>
  35. #include <sysdev/fsl_soc.h>
  36. static struct of_device_id __initdata mpc8610_ids[] = {
  37. { .compatible = "fsl,mpc8610-immr", },
  38. {}
  39. };
  40. static int __init mpc8610_declare_of_platform_devices(void)
  41. {
  42. /* Without this call, the SSI device driver won't get probed. */
  43. of_platform_bus_probe(NULL, mpc8610_ids, NULL);
  44. return 0;
  45. }
  46. machine_device_initcall(mpc86xx_hpcd, mpc8610_declare_of_platform_devices);
  47. static void __init
  48. mpc86xx_hpcd_init_irq(void)
  49. {
  50. struct mpic *mpic1;
  51. struct device_node *np;
  52. struct resource res;
  53. /* Determine PIC address. */
  54. np = of_find_node_by_type(NULL, "open-pic");
  55. if (np == NULL)
  56. return;
  57. of_address_to_resource(np, 0, &res);
  58. /* Alloc mpic structure and per isu has 16 INT entries. */
  59. mpic1 = mpic_alloc(np, res.start,
  60. MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
  61. 0, 256, " MPIC ");
  62. BUG_ON(mpic1 == NULL);
  63. mpic_init(mpic1);
  64. }
  65. #ifdef CONFIG_PCI
  66. static void __devinit quirk_uli1575(struct pci_dev *dev)
  67. {
  68. u32 temp32;
  69. /* Disable INTx */
  70. pci_read_config_dword(dev, 0x48, &temp32);
  71. pci_write_config_dword(dev, 0x48, (temp32 | 1<<26));
  72. /* Enable sideband interrupt */
  73. pci_read_config_dword(dev, 0x90, &temp32);
  74. pci_write_config_dword(dev, 0x90, (temp32 | 1<<22));
  75. }
  76. static void __devinit quirk_uli5288(struct pci_dev *dev)
  77. {
  78. unsigned char c;
  79. unsigned short temp;
  80. /* Interrupt Disable, Needed when SATA disabled */
  81. pci_read_config_word(dev, PCI_COMMAND, &temp);
  82. temp |= 1<<10;
  83. pci_write_config_word(dev, PCI_COMMAND, temp);
  84. pci_read_config_byte(dev, 0x83, &c);
  85. c |= 0x80;
  86. pci_write_config_byte(dev, 0x83, c);
  87. pci_write_config_byte(dev, PCI_CLASS_PROG, 0x01);
  88. pci_write_config_byte(dev, PCI_CLASS_DEVICE, 0x06);
  89. pci_read_config_byte(dev, 0x83, &c);
  90. c &= 0x7f;
  91. pci_write_config_byte(dev, 0x83, c);
  92. }
  93. /*
  94. * Since 8259PIC was disabled on the board, the IDE device can not
  95. * use the legacy IRQ, we need to let the IDE device work under
  96. * native mode and use the interrupt line like other PCI devices.
  97. * IRQ14 is a sideband interrupt from IDE device to CPU and we use this
  98. * as the interrupt for IDE device.
  99. */
  100. static void __devinit quirk_uli5229(struct pci_dev *dev)
  101. {
  102. unsigned char c;
  103. pci_read_config_byte(dev, 0x4b, &c);
  104. c |= 0x10;
  105. pci_write_config_byte(dev, 0x4b, c);
  106. }
  107. /*
  108. * SATA interrupt pin bug fix
  109. * There's a chip bug for 5288, The interrupt pin should be 2,
  110. * not the read only value 1, So it use INTB#, not INTA# which
  111. * actually used by the IDE device 5229.
  112. * As of this bug, during the PCI initialization, 5288 read the
  113. * irq of IDE device from the device tree, this function fix this
  114. * bug by re-assigning a correct irq to 5288.
  115. *
  116. */
  117. static void __devinit final_uli5288(struct pci_dev *dev)
  118. {
  119. struct pci_controller *hose = pci_bus_to_host(dev->bus);
  120. struct device_node *hosenode = hose ? hose->dn : NULL;
  121. struct of_irq oirq;
  122. int virq, pin = 2;
  123. u32 laddr[3];
  124. if (!hosenode)
  125. return;
  126. laddr[0] = (hose->first_busno << 16) | (PCI_DEVFN(31, 0) << 8);
  127. laddr[1] = laddr[2] = 0;
  128. of_irq_map_raw(hosenode, &pin, 1, laddr, &oirq);
  129. virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
  130. oirq.size);
  131. dev->irq = virq;
  132. }
  133. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x1575, quirk_uli1575);
  134. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x5288, quirk_uli5288);
  135. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x5229, quirk_uli5229);
  136. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AL, 0x5288, final_uli5288);
  137. #endif /* CONFIG_PCI */
  138. static void __init
  139. mpc86xx_hpcd_setup_arch(void)
  140. {
  141. #ifdef CONFIG_PCI
  142. struct device_node *np;
  143. #endif
  144. if (ppc_md.progress)
  145. ppc_md.progress("mpc86xx_hpcd_setup_arch()", 0);
  146. #ifdef CONFIG_PCI
  147. for_each_node_by_type(np, "pci") {
  148. if (of_device_is_compatible(np, "fsl,mpc8610-pci")
  149. || of_device_is_compatible(np, "fsl,mpc8641-pcie")) {
  150. struct resource rsrc;
  151. of_address_to_resource(np, 0, &rsrc);
  152. if ((rsrc.start & 0xfffff) == 0xa000)
  153. fsl_add_bridge(np, 1);
  154. else
  155. fsl_add_bridge(np, 0);
  156. }
  157. }
  158. #endif
  159. printk("MPC86xx HPCD board from Freescale Semiconductor\n");
  160. }
  161. /*
  162. * Called very early, device-tree isn't unflattened
  163. */
  164. static int __init mpc86xx_hpcd_probe(void)
  165. {
  166. unsigned long root = of_get_flat_dt_root();
  167. if (of_flat_dt_is_compatible(root, "fsl,MPC8610HPCD"))
  168. return 1; /* Looks good */
  169. return 0;
  170. }
  171. static long __init
  172. mpc86xx_time_init(void)
  173. {
  174. unsigned int temp;
  175. /* Set the time base to zero */
  176. mtspr(SPRN_TBWL, 0);
  177. mtspr(SPRN_TBWU, 0);
  178. temp = mfspr(SPRN_HID0);
  179. temp |= HID0_TBEN;
  180. mtspr(SPRN_HID0, temp);
  181. asm volatile("isync");
  182. return 0;
  183. }
  184. define_machine(mpc86xx_hpcd) {
  185. .name = "MPC86xx HPCD",
  186. .probe = mpc86xx_hpcd_probe,
  187. .setup_arch = mpc86xx_hpcd_setup_arch,
  188. .init_IRQ = mpc86xx_hpcd_init_irq,
  189. .get_irq = mpic_get_irq,
  190. .restart = fsl_rstcr_restart,
  191. .time_init = mpc86xx_time_init,
  192. .calibrate_decr = generic_calibrate_decr,
  193. .progress = udbg_progress,
  194. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  195. };