ehci-imx35.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
  3. * Copyright (C) 2010 Freescale Semiconductor, Inc.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License as published by the
  7. * Free Software Foundation; either version 2 of the License, or (at your
  8. * option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  12. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  13. * for more details.
  14. */
  15. #include <linux/platform_device.h>
  16. #include <linux/io.h>
  17. #include <linux/platform_data/usb-ehci-mxc.h>
  18. #include "ehci.h"
  19. #include "hardware.h"
  20. #define USBCTRL_OTGBASE_OFFSET 0x600
  21. #define MX35_OTG_SIC_SHIFT 29
  22. #define MX35_OTG_SIC_MASK (0x3 << MX35_OTG_SIC_SHIFT)
  23. #define MX35_OTG_PM_BIT (1 << 24)
  24. #define MX35_OTG_PP_BIT (1 << 11)
  25. #define MX35_OTG_OCPOL_BIT (1 << 3)
  26. #define MX35_H1_SIC_SHIFT 21
  27. #define MX35_H1_SIC_MASK (0x3 << MX35_H1_SIC_SHIFT)
  28. #define MX35_H1_PP_BIT (1 << 18)
  29. #define MX35_H1_PM_BIT (1 << 16)
  30. #define MX35_H1_IPPUE_UP_BIT (1 << 7)
  31. #define MX35_H1_IPPUE_DOWN_BIT (1 << 6)
  32. #define MX35_H1_TLL_BIT (1 << 5)
  33. #define MX35_H1_USBTE_BIT (1 << 4)
  34. #define MX35_H1_OCPOL_BIT (1 << 2)
  35. int mx35_initialize_usb_hw(int port, unsigned int flags)
  36. {
  37. unsigned int v;
  38. v = readl(MX35_IO_ADDRESS(MX35_USB_BASE_ADDR + USBCTRL_OTGBASE_OFFSET));
  39. switch (port) {
  40. case 0: /* OTG port */
  41. v &= ~(MX35_OTG_SIC_MASK | MX35_OTG_PM_BIT | MX35_OTG_PP_BIT |
  42. MX35_OTG_OCPOL_BIT);
  43. v |= (flags & MXC_EHCI_INTERFACE_MASK) << MX35_OTG_SIC_SHIFT;
  44. if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))
  45. v |= MX35_OTG_PM_BIT;
  46. if (flags & MXC_EHCI_PWR_PIN_ACTIVE_HIGH)
  47. v |= MX35_OTG_PP_BIT;
  48. if (!(flags & MXC_EHCI_OC_PIN_ACTIVE_LOW))
  49. v |= MX35_OTG_OCPOL_BIT;
  50. break;
  51. case 1: /* H1 port */
  52. v &= ~(MX35_H1_SIC_MASK | MX35_H1_PM_BIT | MX35_H1_PP_BIT |
  53. MX35_H1_OCPOL_BIT | MX35_H1_TLL_BIT | MX35_H1_USBTE_BIT |
  54. MX35_H1_IPPUE_DOWN_BIT | MX35_H1_IPPUE_UP_BIT);
  55. v |= (flags & MXC_EHCI_INTERFACE_MASK) << MX35_H1_SIC_SHIFT;
  56. if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))
  57. v |= MX35_H1_PM_BIT;
  58. if (flags & MXC_EHCI_PWR_PIN_ACTIVE_HIGH)
  59. v |= MX35_H1_PP_BIT;
  60. if (!(flags & MXC_EHCI_OC_PIN_ACTIVE_LOW))
  61. v |= MX35_H1_OCPOL_BIT;
  62. if (!(flags & MXC_EHCI_TTL_ENABLED))
  63. v |= MX35_H1_TLL_BIT;
  64. if (flags & MXC_EHCI_INTERNAL_PHY)
  65. v |= MX35_H1_USBTE_BIT;
  66. if (flags & MXC_EHCI_IPPUE_DOWN)
  67. v |= MX35_H1_IPPUE_DOWN_BIT;
  68. if (flags & MXC_EHCI_IPPUE_UP)
  69. v |= MX35_H1_IPPUE_UP_BIT;
  70. break;
  71. default:
  72. return -EINVAL;
  73. }
  74. writel(v, MX35_IO_ADDRESS(MX35_USB_BASE_ADDR + USBCTRL_OTGBASE_OFFSET));
  75. return 0;
  76. }