ehci-marvell.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * (C) Copyright 2009
  3. * Marvell Semiconductor <www.marvell.com>
  4. * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #include <common.h>
  9. #include <asm/io.h>
  10. #include <usb.h>
  11. #include "ehci.h"
  12. #include <asm/arch/cpu.h>
  13. #if defined(CONFIG_KIRKWOOD)
  14. #include <asm/arch/kirkwood.h>
  15. #elif defined(CONFIG_ORION5X)
  16. #include <asm/arch/orion5x.h>
  17. #endif
  18. DECLARE_GLOBAL_DATA_PTR;
  19. #define rdl(off) readl(MVUSB0_BASE + (off))
  20. #define wrl(off, val) writel((val), MVUSB0_BASE + (off))
  21. #define USB_WINDOW_CTRL(i) (0x320 + ((i) << 4))
  22. #define USB_WINDOW_BASE(i) (0x324 + ((i) << 4))
  23. #define USB_TARGET_DRAM 0x0
  24. /*
  25. * USB 2.0 Bridge Address Decoding registers setup
  26. */
  27. static void usb_brg_adrdec_setup(void)
  28. {
  29. int i;
  30. u32 size, base, attrib;
  31. for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
  32. /* Enable DRAM bank */
  33. switch (i) {
  34. case 0:
  35. attrib = MVUSB0_CPU_ATTR_DRAM_CS0;
  36. break;
  37. case 1:
  38. attrib = MVUSB0_CPU_ATTR_DRAM_CS1;
  39. break;
  40. case 2:
  41. attrib = MVUSB0_CPU_ATTR_DRAM_CS2;
  42. break;
  43. case 3:
  44. attrib = MVUSB0_CPU_ATTR_DRAM_CS3;
  45. break;
  46. default:
  47. /* invalide bank, disable access */
  48. attrib = 0;
  49. break;
  50. }
  51. size = gd->bd->bi_dram[i].size;
  52. base = gd->bd->bi_dram[i].start;
  53. if ((size) && (attrib))
  54. wrl(USB_WINDOW_CTRL(i),
  55. MVCPU_WIN_CTRL_DATA(size, USB_TARGET_DRAM,
  56. attrib, MVCPU_WIN_ENABLE));
  57. else
  58. wrl(USB_WINDOW_CTRL(i), MVCPU_WIN_DISABLE);
  59. wrl(USB_WINDOW_BASE(i), base);
  60. }
  61. }
  62. /*
  63. * Create the appropriate control structures to manage
  64. * a new EHCI host controller.
  65. */
  66. int ehci_hcd_init(int index, enum usb_init_type init,
  67. struct ehci_hccr **hccr, struct ehci_hcor **hcor)
  68. {
  69. usb_brg_adrdec_setup();
  70. *hccr = (struct ehci_hccr *)(MVUSB0_BASE + 0x100);
  71. *hcor = (struct ehci_hcor *)((uint32_t) *hccr
  72. + HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase)));
  73. debug("ehci-marvell: init hccr %x and hcor %x hc_length %d\n",
  74. (uint32_t)*hccr, (uint32_t)*hcor,
  75. (uint32_t)HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase)));
  76. return 0;
  77. }
  78. /*
  79. * Destroy the appropriate control structures corresponding
  80. * the the EHCI host controller.
  81. */
  82. int ehci_hcd_stop(int index)
  83. {
  84. return 0;
  85. }