ehci-marvell.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * (C) Copyright 2009
  3. * Marvell Semiconductor <www.marvell.com>
  4. * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  22. * MA 02110-1301 USA
  23. */
  24. #include <common.h>
  25. #include <asm/io.h>
  26. #include <usb.h>
  27. #include "ehci.h"
  28. #include <asm/arch/cpu.h>
  29. #if defined(CONFIG_KIRKWOOD)
  30. #include <asm/arch/kirkwood.h>
  31. #elif defined(CONFIG_ORION5X)
  32. #include <asm/arch/orion5x.h>
  33. #endif
  34. DECLARE_GLOBAL_DATA_PTR;
  35. #define rdl(off) readl(MVUSB0_BASE + (off))
  36. #define wrl(off, val) writel((val), MVUSB0_BASE + (off))
  37. #define USB_WINDOW_CTRL(i) (0x320 + ((i) << 4))
  38. #define USB_WINDOW_BASE(i) (0x324 + ((i) << 4))
  39. #define USB_TARGET_DRAM 0x0
  40. /*
  41. * USB 2.0 Bridge Address Decoding registers setup
  42. */
  43. static void usb_brg_adrdec_setup(void)
  44. {
  45. int i;
  46. u32 size, base, attrib;
  47. for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
  48. /* Enable DRAM bank */
  49. switch (i) {
  50. case 0:
  51. attrib = MVUSB0_CPU_ATTR_DRAM_CS0;
  52. break;
  53. case 1:
  54. attrib = MVUSB0_CPU_ATTR_DRAM_CS1;
  55. break;
  56. case 2:
  57. attrib = MVUSB0_CPU_ATTR_DRAM_CS2;
  58. break;
  59. case 3:
  60. attrib = MVUSB0_CPU_ATTR_DRAM_CS3;
  61. break;
  62. default:
  63. /* invalide bank, disable access */
  64. attrib = 0;
  65. break;
  66. }
  67. size = gd->bd->bi_dram[i].size;
  68. base = gd->bd->bi_dram[i].start;
  69. if ((size) && (attrib))
  70. wrl(USB_WINDOW_CTRL(i),
  71. MVCPU_WIN_CTRL_DATA(size, USB_TARGET_DRAM,
  72. attrib, MVCPU_WIN_ENABLE));
  73. else
  74. wrl(USB_WINDOW_CTRL(i), MVCPU_WIN_DISABLE);
  75. wrl(USB_WINDOW_BASE(i), base);
  76. }
  77. }
  78. /*
  79. * Create the appropriate control structures to manage
  80. * a new EHCI host controller.
  81. */
  82. int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor)
  83. {
  84. usb_brg_adrdec_setup();
  85. *hccr = (struct ehci_hccr *)(MVUSB0_BASE + 0x100);
  86. *hcor = (struct ehci_hcor *)((uint32_t) *hccr
  87. + HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase)));
  88. debug("ehci-marvell: init hccr %x and hcor %x hc_length %d\n",
  89. (uint32_t)*hccr, (uint32_t)*hcor,
  90. (uint32_t)HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase)));
  91. return 0;
  92. }
  93. /*
  94. * Destroy the appropriate control structures corresponding
  95. * the the EHCI host controller.
  96. */
  97. int ehci_hcd_stop(int index)
  98. {
  99. return 0;
  100. }