pci-tx4938.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * linux/arch/mips/pci/pci-tx4938.c
  3. *
  4. * Based on linux/arch/mips/txx9/rbtx4938/setup.c,
  5. * and RBTX49xx patch from CELF patch archive.
  6. *
  7. * Copyright 2001, 2003-2005 MontaVista Software Inc.
  8. * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
  9. * (C) Copyright TOSHIBA CORPORATION 2000-2001, 2004-2007
  10. *
  11. * This file is subject to the terms and conditions of the GNU General Public
  12. * License. See the file "COPYING" in the main directory of this archive
  13. * for more details.
  14. */
  15. #include <linux/init.h>
  16. #include <linux/pci.h>
  17. #include <linux/kernel.h>
  18. #include <asm/txx9/generic.h>
  19. #include <asm/txx9/tx4938.h>
  20. int __init tx4938_report_pciclk(void)
  21. {
  22. int pciclk = 0;
  23. printk(KERN_INFO "PCIC --%s PCICLK:",
  24. (__raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_PCI66) ?
  25. " PCI66" : "");
  26. if (__raw_readq(&tx4938_ccfgptr->pcfg) & TX4938_PCFG_PCICLKEN_ALL) {
  27. u64 ccfg = __raw_readq(&tx4938_ccfgptr->ccfg);
  28. switch ((unsigned long)ccfg &
  29. TX4938_CCFG_PCIDIVMODE_MASK) {
  30. case TX4938_CCFG_PCIDIVMODE_4:
  31. pciclk = txx9_cpu_clock / 4; break;
  32. case TX4938_CCFG_PCIDIVMODE_4_5:
  33. pciclk = txx9_cpu_clock * 2 / 9; break;
  34. case TX4938_CCFG_PCIDIVMODE_5:
  35. pciclk = txx9_cpu_clock / 5; break;
  36. case TX4938_CCFG_PCIDIVMODE_5_5:
  37. pciclk = txx9_cpu_clock * 2 / 11; break;
  38. case TX4938_CCFG_PCIDIVMODE_8:
  39. pciclk = txx9_cpu_clock / 8; break;
  40. case TX4938_CCFG_PCIDIVMODE_9:
  41. pciclk = txx9_cpu_clock / 9; break;
  42. case TX4938_CCFG_PCIDIVMODE_10:
  43. pciclk = txx9_cpu_clock / 10; break;
  44. case TX4938_CCFG_PCIDIVMODE_11:
  45. pciclk = txx9_cpu_clock / 11; break;
  46. }
  47. printk("Internal(%u.%uMHz)",
  48. (pciclk + 50000) / 1000000,
  49. ((pciclk + 50000) / 100000) % 10);
  50. } else {
  51. printk("External");
  52. pciclk = -1;
  53. }
  54. printk("\n");
  55. return pciclk;
  56. }
  57. void __init tx4938_report_pci1clk(void)
  58. {
  59. __u64 ccfg = __raw_readq(&tx4938_ccfgptr->ccfg);
  60. unsigned int pciclk =
  61. txx9_gbus_clock / ((ccfg & TX4938_CCFG_PCI1DMD) ? 4 : 2);
  62. printk(KERN_INFO "PCIC1 -- %sPCICLK:%u.%uMHz\n",
  63. (ccfg & TX4938_CCFG_PCI1_66) ? "PCI66 " : "",
  64. (pciclk + 50000) / 1000000,
  65. ((pciclk + 50000) / 100000) % 10);
  66. }
  67. int __init tx4938_pciclk66_setup(void)
  68. {
  69. int pciclk;
  70. /* Assert M66EN */
  71. tx4938_ccfg_set(TX4938_CCFG_PCI66);
  72. /* Double PCICLK (if possible) */
  73. if (__raw_readq(&tx4938_ccfgptr->pcfg) & TX4938_PCFG_PCICLKEN_ALL) {
  74. unsigned int pcidivmode = 0;
  75. u64 ccfg = __raw_readq(&tx4938_ccfgptr->ccfg);
  76. pcidivmode = (unsigned long)ccfg &
  77. TX4938_CCFG_PCIDIVMODE_MASK;
  78. switch (pcidivmode) {
  79. case TX4938_CCFG_PCIDIVMODE_8:
  80. case TX4938_CCFG_PCIDIVMODE_4:
  81. pcidivmode = TX4938_CCFG_PCIDIVMODE_4;
  82. pciclk = txx9_cpu_clock / 4;
  83. break;
  84. case TX4938_CCFG_PCIDIVMODE_9:
  85. case TX4938_CCFG_PCIDIVMODE_4_5:
  86. pcidivmode = TX4938_CCFG_PCIDIVMODE_4_5;
  87. pciclk = txx9_cpu_clock * 2 / 9;
  88. break;
  89. case TX4938_CCFG_PCIDIVMODE_10:
  90. case TX4938_CCFG_PCIDIVMODE_5:
  91. pcidivmode = TX4938_CCFG_PCIDIVMODE_5;
  92. pciclk = txx9_cpu_clock / 5;
  93. break;
  94. case TX4938_CCFG_PCIDIVMODE_11:
  95. case TX4938_CCFG_PCIDIVMODE_5_5:
  96. default:
  97. pcidivmode = TX4938_CCFG_PCIDIVMODE_5_5;
  98. pciclk = txx9_cpu_clock * 2 / 11;
  99. break;
  100. }
  101. tx4938_ccfg_change(TX4938_CCFG_PCIDIVMODE_MASK,
  102. pcidivmode);
  103. printk(KERN_DEBUG "PCICLK: ccfg:%08lx\n",
  104. (unsigned long)__raw_readq(&tx4938_ccfgptr->ccfg));
  105. } else
  106. pciclk = -1;
  107. return pciclk;
  108. }
  109. int tx4938_pcic1_map_irq(const struct pci_dev *dev, u8 slot)
  110. {
  111. if (get_tx4927_pcicptr(dev->bus->sysdata) == tx4938_pcic1ptr) {
  112. switch (slot) {
  113. case TX4927_PCIC_IDSEL_AD_TO_SLOT(31):
  114. if (__raw_readq(&tx4938_ccfgptr->pcfg) &
  115. TX4938_PCFG_ETH0_SEL)
  116. return TXX9_IRQ_BASE + TX4938_IR_ETH0;
  117. break;
  118. case TX4927_PCIC_IDSEL_AD_TO_SLOT(30):
  119. if (__raw_readq(&tx4938_ccfgptr->pcfg) &
  120. TX4938_PCFG_ETH1_SEL)
  121. return TXX9_IRQ_BASE + TX4938_IR_ETH1;
  122. break;
  123. }
  124. return 0;
  125. }
  126. return -1;
  127. }