pci-tx4927.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * linux/arch/mips/pci/pci-tx4927.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 <linux/interrupt.h>
  19. #include <asm/txx9/generic.h>
  20. #include <asm/txx9/tx4927.h>
  21. int __init tx4927_report_pciclk(void)
  22. {
  23. int pciclk = 0;
  24. printk(KERN_INFO "PCIC --%s PCICLK:",
  25. (__raw_readq(&tx4927_ccfgptr->ccfg) & TX4927_CCFG_PCI66) ?
  26. " PCI66" : "");
  27. if (__raw_readq(&tx4927_ccfgptr->pcfg) & TX4927_PCFG_PCICLKEN_ALL) {
  28. u64 ccfg = __raw_readq(&tx4927_ccfgptr->ccfg);
  29. switch ((unsigned long)ccfg &
  30. TX4927_CCFG_PCIDIVMODE_MASK) {
  31. case TX4927_CCFG_PCIDIVMODE_2_5:
  32. pciclk = txx9_cpu_clock * 2 / 5; break;
  33. case TX4927_CCFG_PCIDIVMODE_3:
  34. pciclk = txx9_cpu_clock / 3; break;
  35. case TX4927_CCFG_PCIDIVMODE_5:
  36. pciclk = txx9_cpu_clock / 5; break;
  37. case TX4927_CCFG_PCIDIVMODE_6:
  38. pciclk = txx9_cpu_clock / 6; break;
  39. }
  40. printk("Internal(%u.%uMHz)",
  41. (pciclk + 50000) / 1000000,
  42. ((pciclk + 50000) / 100000) % 10);
  43. } else {
  44. printk("External");
  45. pciclk = -1;
  46. }
  47. printk("\n");
  48. return pciclk;
  49. }
  50. int __init tx4927_pciclk66_setup(void)
  51. {
  52. int pciclk;
  53. /* Assert M66EN */
  54. tx4927_ccfg_set(TX4927_CCFG_PCI66);
  55. /* Double PCICLK (if possible) */
  56. if (__raw_readq(&tx4927_ccfgptr->pcfg) & TX4927_PCFG_PCICLKEN_ALL) {
  57. unsigned int pcidivmode = 0;
  58. u64 ccfg = __raw_readq(&tx4927_ccfgptr->ccfg);
  59. pcidivmode = (unsigned long)ccfg &
  60. TX4927_CCFG_PCIDIVMODE_MASK;
  61. switch (pcidivmode) {
  62. case TX4927_CCFG_PCIDIVMODE_5:
  63. case TX4927_CCFG_PCIDIVMODE_2_5:
  64. pcidivmode = TX4927_CCFG_PCIDIVMODE_2_5;
  65. pciclk = txx9_cpu_clock * 2 / 5;
  66. break;
  67. case TX4927_CCFG_PCIDIVMODE_6:
  68. case TX4927_CCFG_PCIDIVMODE_3:
  69. default:
  70. pcidivmode = TX4927_CCFG_PCIDIVMODE_3;
  71. pciclk = txx9_cpu_clock / 3;
  72. }
  73. tx4927_ccfg_change(TX4927_CCFG_PCIDIVMODE_MASK,
  74. pcidivmode);
  75. printk(KERN_DEBUG "PCICLK: ccfg:%08lx\n",
  76. (unsigned long)__raw_readq(&tx4927_ccfgptr->ccfg));
  77. } else
  78. pciclk = -1;
  79. return pciclk;
  80. }
  81. void __init tx4927_setup_pcierr_irq(void)
  82. {
  83. if (request_irq(TXX9_IRQ_BASE + TX4927_IR_PCIERR,
  84. tx4927_pcierr_interrupt,
  85. IRQF_DISABLED, "PCI error",
  86. (void *)TX4927_PCIC_REG))
  87. printk(KERN_WARNING "Failed to request irq for PCIERR\n");
  88. }