ehci-fsl.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * (C) Copyright 2008, Excito Elektronik i Sk=E5ne AB
  3. *
  4. * Author: Tor Krill tor@excito.com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation; either version 2 of
  9. * the License, or (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
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  19. * MA 02111-1307 USA
  20. */
  21. #include <common.h>
  22. #include <pci.h>
  23. #include <usb.h>
  24. #include <mpc83xx.h>
  25. #include <asm/io.h>
  26. #include <asm/bitops.h>
  27. #include "ehci.h"
  28. #include "ehci-fsl.h"
  29. #include "ehci-core.h"
  30. /*
  31. * Create the appropriate control structures to manage
  32. * a new EHCI host controller.
  33. *
  34. * Excerpts from linux ehci fsl driver.
  35. */
  36. int ehci_hcd_init(void)
  37. {
  38. volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
  39. uint32_t addr, temp;
  40. addr = (uint32_t)&(im->usb[0]);
  41. hccr = (struct ehci_hccr *)(addr + FSL_SKIP_PCI);
  42. hcor = (struct ehci_hcor *)((uint32_t) hccr +
  43. HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
  44. /* Configure clock */
  45. clrsetbits_be32(&(im->clk.sccr), MPC83XX_SCCR_USB_MASK,
  46. MPC83XX_SCCR_USB_DRCM_11);
  47. /* Confgure interface. */
  48. temp = in_be32((void *)(addr + FSL_SOC_USB_CTRL));
  49. out_be32((void *)(addr + FSL_SOC_USB_CTRL), temp
  50. | REFSEL_16MHZ | UTMI_PHY_EN);
  51. /* Wait for clock to stabilize */
  52. do {
  53. temp = in_be32((void *)(addr + FSL_SOC_USB_CTRL));
  54. udelay(1000);
  55. } while (!(temp & PHY_CLK_VALID));
  56. /* Set to Host mode */
  57. temp = in_le32((void *)(addr + FSL_SOC_USB_USBMODE));
  58. out_le32((void *)(addr + FSL_SOC_USB_USBMODE), temp | CM_HOST);
  59. out_be32((void *)(addr + FSL_SOC_USB_SNOOP1), SNOOP_SIZE_2GB);
  60. out_be32((void *)(addr + FSL_SOC_USB_SNOOP2),
  61. 0x80000000 | SNOOP_SIZE_2GB);
  62. /* Init phy */
  63. /* TODO: handle different phys? */
  64. out_le32(&(hcor->or_portsc[0]), PORT_PTS_UTMI);
  65. /* Enable interface. */
  66. temp = in_be32((void *)(addr + FSL_SOC_USB_CTRL));
  67. out_be32((void *)(addr + FSL_SOC_USB_CTRL), temp | USB_EN);
  68. out_be32((void *)(addr + FSL_SOC_USB_PRICTRL), 0x0000000c);
  69. out_be32((void *)(addr + FSL_SOC_USB_AGECNTTHRSH), 0x00000040);
  70. out_be32((void *)(addr + FSL_SOC_USB_SICTRL), 0x00000001);
  71. /* Enable interface. */
  72. temp = in_be32((void *)(addr + FSL_SOC_USB_CTRL));
  73. out_be32((void *)(addr + FSL_SOC_USB_CTRL), temp | USB_EN);
  74. temp = in_le32((void *)(addr + FSL_SOC_USB_USBMODE));
  75. return 0;
  76. }
  77. /*
  78. * Destroy the appropriate control structures corresponding
  79. * the the EHCI host controller.
  80. */
  81. int ehci_hcd_stop(void)
  82. {
  83. return 0;
  84. }