pci-tx4927.c 2.4 KB

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