usb.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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_PXA27X)
  26. #include <asm/arch/pxa-regs.h>
  27. #include <usb.h>
  28. int usb_cpu_init(void)
  29. {
  30. #if defined(CONFIG_CPU_MONAHANS)
  31. /* Enable USB host clock. */
  32. CKENA |= (CKENA_2_USBHOST | CKENA_20_UDC);
  33. udelay(100);
  34. #endif
  35. #if defined(CONFIG_PXA27X)
  36. /* Enable USB host clock. */
  37. CKEN |= CKEN10_USBHOST;
  38. #endif
  39. #if defined(CONFIG_CPU_MONAHANS)
  40. /* Configure Port 2 for Host (USB Client Registers) */
  41. UP2OCR = 0x3000c;
  42. #endif
  43. UHCHR |= UHCHR_FHR;
  44. wait_ms(11);
  45. UHCHR &= ~UHCHR_FHR;
  46. UHCHR |= UHCHR_FSBIR;
  47. while (UHCHR & UHCHR_FSBIR)
  48. udelay(1);
  49. #if defined(CONFIG_CPU_MONAHANS)
  50. UHCHR &= ~UHCHR_SSEP0;
  51. #endif
  52. #if defined(CONFIG_PXA27X)
  53. UHCHR &= ~UHCHR_SSEP2;
  54. #endif
  55. UHCHR &= ~UHCHR_SSEP1;
  56. UHCHR &= ~UHCHR_SSE;
  57. return 0;
  58. }
  59. int usb_cpu_stop(void)
  60. {
  61. UHCHR |= UHCHR_FHR;
  62. udelay(11);
  63. UHCHR &= ~UHCHR_FHR;
  64. UHCCOMS |= 1;
  65. udelay(10);
  66. #if defined(CONFIG_CPU_MONAHANS)
  67. UHCHR |= UHCHR_SSEP0;
  68. #endif
  69. #if defined(CONFIG_PXA27X)
  70. UHCHR |= UHCHR_SSEP2;
  71. #endif
  72. UHCHR |= UHCHR_SSEP1;
  73. UHCHR |= UHCHR_SSE;
  74. return 0;
  75. }
  76. int usb_cpu_init_fail(void)
  77. {
  78. UHCHR |= UHCHR_FHR;
  79. udelay(11);
  80. UHCHR &= ~UHCHR_FHR;
  81. UHCCOMS |= 1;
  82. udelay(10);
  83. #if defined(CONFIG_CPU_MONAHANS)
  84. UHCHR |= UHCHR_SSEP0;
  85. #endif
  86. #if defined(CONFIG_PXA27X)
  87. UHCHR |= UHCHR_SSEP2;
  88. #endif
  89. UHCHR |= UHCHR_SSEP1;
  90. UHCHR |= UHCHR_SSE;
  91. return 0;
  92. }
  93. # endif /* defined(CONFIG_CPU_MONAHANS) || defined(CONFIG_PXA27X) */
  94. #endif /* defined(CONFIG_USB_OHCI) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT) */