mpc8610_hpcd.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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 <sysdev/fsl_pci.h>
  34. #include <sysdev/fsl_soc.h>
  35. void __init
  36. mpc86xx_hpcd_init_irq(void)
  37. {
  38. struct mpic *mpic1;
  39. struct device_node *np;
  40. struct resource res;
  41. /* Determine PIC address. */
  42. np = of_find_node_by_type(NULL, "open-pic");
  43. if (np == NULL)
  44. return;
  45. of_address_to_resource(np, 0, &res);
  46. /* Alloc mpic structure and per isu has 16 INT entries. */
  47. mpic1 = mpic_alloc(np, res.start,
  48. MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
  49. 0, 256, " MPIC ");
  50. BUG_ON(mpic1 == NULL);
  51. mpic_init(mpic1);
  52. }
  53. #ifdef CONFIG_PCI
  54. static void __devinit quirk_uli1575(struct pci_dev *dev)
  55. {
  56. u32 temp32;
  57. /* Disable INTx */
  58. pci_read_config_dword(dev, 0x48, &temp32);
  59. pci_write_config_dword(dev, 0x48, (temp32 | 1<<26));
  60. /* Enable sideband interrupt */
  61. pci_read_config_dword(dev, 0x90, &temp32);
  62. pci_write_config_dword(dev, 0x90, (temp32 | 1<<22));
  63. }
  64. static void __devinit quirk_uli5288(struct pci_dev *dev)
  65. {
  66. unsigned char c;
  67. unsigned short temp;
  68. /* Interrupt Disable, Needed when SATA disabled */
  69. pci_read_config_word(dev, PCI_COMMAND, &temp);
  70. temp |= 1<<10;
  71. pci_write_config_word(dev, PCI_COMMAND, temp);
  72. pci_read_config_byte(dev, 0x83, &c);
  73. c |= 0x80;
  74. pci_write_config_byte(dev, 0x83, c);
  75. pci_write_config_byte(dev, PCI_CLASS_PROG, 0x01);
  76. pci_write_config_byte(dev, PCI_CLASS_DEVICE, 0x06);
  77. pci_read_config_byte(dev, 0x83, &c);
  78. c &= 0x7f;
  79. pci_write_config_byte(dev, 0x83, c);
  80. }
  81. /*
  82. * Since 8259PIC was disabled on the board, the IDE device can not
  83. * use the legacy IRQ, we need to let the IDE device work under
  84. * native mode and use the interrupt line like other PCI devices.
  85. * IRQ14 is a sideband interrupt from IDE device to CPU and we use this
  86. * as the interrupt for IDE device.
  87. */
  88. static void __devinit quirk_uli5229(struct pci_dev *dev)
  89. {
  90. unsigned char c;
  91. pci_read_config_byte(dev, 0x4b, &c);
  92. c |= 0x10;
  93. pci_write_config_byte(dev, 0x4b, c);
  94. }
  95. /*
  96. * SATA interrupt pin bug fix
  97. * There's a chip bug for 5288, The interrupt pin should be 2,
  98. * not the read only value 1, So it use INTB#, not INTA# which
  99. * actually used by the IDE device 5229.
  100. * As of this bug, during the PCI initialization, 5288 read the
  101. * irq of IDE device from the device tree, this function fix this
  102. * bug by re-assigning a correct irq to 5288.
  103. *
  104. */
  105. static void __devinit final_uli5288(struct pci_dev *dev)
  106. {
  107. struct pci_controller *hose = pci_bus_to_host(dev->bus);
  108. struct device_node *hosenode = hose ? hose->arch_data : NULL;
  109. struct of_irq oirq;
  110. int virq, pin = 2;
  111. u32 laddr[3];
  112. if (!hosenode)
  113. return;
  114. laddr[0] = (hose->first_busno << 16) | (PCI_DEVFN(31, 0) << 8);
  115. laddr[1] = laddr[2] = 0;
  116. of_irq_map_raw(hosenode, &pin, 1, laddr, &oirq);
  117. virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
  118. oirq.size);
  119. dev->irq = virq;
  120. }
  121. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x1575, quirk_uli1575);
  122. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x5288, quirk_uli5288);
  123. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x5229, quirk_uli5229);
  124. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AL, 0x5288, final_uli5288);
  125. #endif /* CONFIG_PCI */
  126. static void __init
  127. mpc86xx_hpcd_setup_arch(void)
  128. {
  129. #ifdef CONFIG_PCI
  130. struct device_node *np;
  131. #endif
  132. if (ppc_md.progress)
  133. ppc_md.progress("mpc86xx_hpcd_setup_arch()", 0);
  134. #ifdef CONFIG_PCI
  135. for_each_node_by_type(np, "pci") {
  136. if (of_device_is_compatible(np, "fsl,mpc8610-pci")
  137. || of_device_is_compatible(np, "fsl,mpc8641-pcie")) {
  138. struct resource rsrc;
  139. of_address_to_resource(np, 0, &rsrc);
  140. if ((rsrc.start & 0xfffff) == 0xa000)
  141. fsl_add_bridge(np, 1);
  142. else
  143. fsl_add_bridge(np, 0);
  144. }
  145. }
  146. #endif
  147. printk("MPC86xx HPCD board from Freescale Semiconductor\n");
  148. }
  149. /*
  150. * Called very early, device-tree isn't unflattened
  151. */
  152. static int __init mpc86xx_hpcd_probe(void)
  153. {
  154. unsigned long root = of_get_flat_dt_root();
  155. if (of_flat_dt_is_compatible(root, "fsl,MPC8610HPCD"))
  156. return 1; /* Looks good */
  157. return 0;
  158. }
  159. long __init
  160. mpc86xx_time_init(void)
  161. {
  162. unsigned int temp;
  163. /* Set the time base to zero */
  164. mtspr(SPRN_TBWL, 0);
  165. mtspr(SPRN_TBWU, 0);
  166. temp = mfspr(SPRN_HID0);
  167. temp |= HID0_TBEN;
  168. mtspr(SPRN_HID0, temp);
  169. asm volatile("isync");
  170. return 0;
  171. }
  172. define_machine(mpc86xx_hpcd) {
  173. .name = "MPC86xx HPCD",
  174. .probe = mpc86xx_hpcd_probe,
  175. .setup_arch = mpc86xx_hpcd_setup_arch,
  176. .init_IRQ = mpc86xx_hpcd_init_irq,
  177. .get_irq = mpic_get_irq,
  178. .restart = fsl_rstcr_restart,
  179. .time_init = mpc86xx_time_init,
  180. .calibrate_decr = generic_calibrate_decr,
  181. .progress = udbg_progress,
  182. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  183. };