celleb_scc_uhc.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * SCC (Super Companion Chip) UHC setup
  3. *
  4. * (C) Copyright 2006-2007 TOSHIBA CORPORATION
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. */
  20. #include <linux/kernel.h>
  21. #include <linux/pci.h>
  22. #include <asm/delay.h>
  23. #include <asm/io.h>
  24. #include <asm/machdep.h>
  25. #include "celleb_scc.h"
  26. #define UHC_RESET_WAIT_MAX 10000
  27. static inline int uhc_clkctrl_ready(u32 val)
  28. {
  29. const u32 mask = SCC_UHC_USBCEN | SCC_UHC_USBCEN;
  30. return((val & mask) == mask);
  31. }
  32. /*
  33. * UHC(usb host controller) enable function.
  34. * affect to both of OHCI and EHCI core module.
  35. */
  36. static void enable_scc_uhc(struct pci_dev *dev)
  37. {
  38. void __iomem *uhc_base;
  39. u32 __iomem *uhc_clkctrl;
  40. u32 __iomem *uhc_ecmode;
  41. u32 val = 0;
  42. int i;
  43. if (!machine_is(celleb_beat) &&
  44. !machine_is(celleb_native))
  45. return;
  46. uhc_base = ioremap(pci_resource_start(dev, 0),
  47. pci_resource_len(dev, 0));
  48. if (!uhc_base) {
  49. printk(KERN_ERR "failed to map UHC register base.\n");
  50. return;
  51. }
  52. uhc_clkctrl = uhc_base + SCC_UHC_CKRCTRL;
  53. uhc_ecmode = uhc_base + SCC_UHC_ECMODE;
  54. /* setup for normal mode */
  55. val |= SCC_UHC_F48MCKLEN;
  56. out_be32(uhc_clkctrl, val);
  57. val |= SCC_UHC_PHY_SUSPEND_SEL;
  58. out_be32(uhc_clkctrl, val);
  59. udelay(10);
  60. val |= SCC_UHC_PHYEN;
  61. out_be32(uhc_clkctrl, val);
  62. udelay(50);
  63. /* disable reset */
  64. val |= SCC_UHC_HCLKEN;
  65. out_be32(uhc_clkctrl, val);
  66. val |= (SCC_UHC_USBCEN | SCC_UHC_USBEN);
  67. out_be32(uhc_clkctrl, val);
  68. i = 0;
  69. while (!uhc_clkctrl_ready(in_be32(uhc_clkctrl))) {
  70. udelay(10);
  71. if (i++ > UHC_RESET_WAIT_MAX) {
  72. printk(KERN_ERR "Failed to disable UHC reset %x\n",
  73. in_be32(uhc_clkctrl));
  74. break;
  75. }
  76. }
  77. /* Endian Conversion Mode for Master ALL area */
  78. out_be32(uhc_ecmode, SCC_UHC_ECMODE_BY_BYTE);
  79. iounmap(uhc_base);
  80. }
  81. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TOSHIBA_2,
  82. PCI_DEVICE_ID_TOSHIBA_SCC_USB, enable_scc_uhc);