usb.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * (C) Copyright 2006
  3. * Markus Klotzbuecher, DENX Software Engineering <mk@denx.de>
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT)
  25. # if defined(CONFIG_CPU_MONAHANS) || defined(CONFIG_CPU_PXA27X)
  26. #include <asm/arch/pxa-regs.h>
  27. #include <asm/io.h>
  28. #include <usb.h>
  29. int usb_cpu_init(void)
  30. {
  31. #if defined(CONFIG_CPU_MONAHANS)
  32. /* Enable USB host clock. */
  33. writel(readl(CKENA) | CKENA_2_USBHOST | CKENA_20_UDC, CKENA);
  34. udelay(100);
  35. #endif
  36. #if defined(CONFIG_CPU_PXA27X)
  37. /* Enable USB host clock. */
  38. writel(readl(CKEN) | CKEN10_USBHOST, CKEN);
  39. #endif
  40. #if defined(CONFIG_CPU_MONAHANS)
  41. /* Configure Port 2 for Host (USB Client Registers) */
  42. writel(0x3000c, UP2OCR);
  43. #endif
  44. writel(readl(UHCHR) | UHCHR_FHR, UHCHR);
  45. mdelay(11);
  46. writel(readl(UHCHR) & ~UHCHR_FHR, UHCHR);
  47. writel(readl(UHCHR) | UHCHR_FSBIR, UHCHR);
  48. while (readl(UHCHR) & UHCHR_FSBIR)
  49. udelay(1);
  50. #if defined(CONFIG_CPU_MONAHANS) || defined(CONFIG_PXA27X)
  51. writel(readl(UHCHR) & ~UHCHR_SSEP0, UHCHR);
  52. #endif
  53. #if defined(CONFIG_CPU_PXA27X)
  54. writel(readl(UHCHR) & ~UHCHR_SSEP2, UHCHR);
  55. #endif
  56. writel(readl(UHCHR) & ~(UHCHR_SSEP1 | UHCHR_SSE), UHCHR);
  57. return 0;
  58. }
  59. int usb_cpu_stop(void)
  60. {
  61. writel(readl(UHCHR) | UHCHR_FHR, UHCHR);
  62. udelay(11);
  63. writel(readl(UHCHR) & ~UHCHR_FHR, UHCHR);
  64. writel(readl(UHCCOMS) | UHCCOMS_HCR, UHCCOMS);
  65. udelay(10);
  66. #if defined(CONFIG_CPU_MONAHANS) || defined(CONFIG_PXA27X)
  67. writel(readl(UHCHR) | UHCHR_SSEP0, UHCHR);
  68. #endif
  69. #if defined(CONFIG_CPU_PXA27X)
  70. writel(readl(UHCHR) | UHCHR_SSEP2, UHCHR);
  71. #endif
  72. writel(readl(UHCHR) | UHCHR_SSEP1 | UHCHR_SSE, UHCHR);
  73. #if defined(CONFIG_CPU_MONAHANS)
  74. /* Disable USB host clock. */
  75. writel(readl(CKENA) & ~(CKENA_2_USBHOST | CKENA_20_UDC), CKENA);
  76. udelay(100);
  77. #endif
  78. #if defined(CONFIG_CPU_PXA27X)
  79. /* Disable USB host clock. */
  80. writel(readl(CKEN) & ~CKEN10_USBHOST, CKEN);
  81. #endif
  82. return 0;
  83. }
  84. int usb_cpu_init_fail(void)
  85. {
  86. return usb_cpu_stop();
  87. }
  88. # endif /* defined(CONFIG_CPU_MONAHANS) || defined(CONFIG_CPU_PXA27X) */
  89. #endif /* defined(CONFIG_USB_OHCI) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT) */