ehci-imx27.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 MX27_OTG_SIC_SHIFT 29
  22. #define MX27_OTG_SIC_MASK (0x3 << MX27_OTG_SIC_SHIFT)
  23. #define MX27_OTG_PM_BIT (1 << 24)
  24. #define MX27_H2_SIC_SHIFT 21
  25. #define MX27_H2_SIC_MASK (0x3 << MX27_H2_SIC_SHIFT)
  26. #define MX27_H2_PM_BIT (1 << 16)
  27. #define MX27_H2_DT_BIT (1 << 5)
  28. #define MX27_H1_SIC_SHIFT 13
  29. #define MX27_H1_SIC_MASK (0x3 << MX27_H1_SIC_SHIFT)
  30. #define MX27_H1_PM_BIT (1 << 8)
  31. #define MX27_H1_DT_BIT (1 << 4)
  32. int mx27_initialize_usb_hw(int port, unsigned int flags)
  33. {
  34. unsigned int v;
  35. v = readl(MX27_IO_ADDRESS(MX27_USB_BASE_ADDR + USBCTRL_OTGBASE_OFFSET));
  36. switch (port) {
  37. case 0: /* OTG port */
  38. v &= ~(MX27_OTG_SIC_MASK | MX27_OTG_PM_BIT);
  39. v |= (flags & MXC_EHCI_INTERFACE_MASK) << MX27_OTG_SIC_SHIFT;
  40. if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))
  41. v |= MX27_OTG_PM_BIT;
  42. break;
  43. case 1: /* H1 port */
  44. v &= ~(MX27_H1_SIC_MASK | MX27_H1_PM_BIT | MX27_H1_DT_BIT);
  45. v |= (flags & MXC_EHCI_INTERFACE_MASK) << MX27_H1_SIC_SHIFT;
  46. if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))
  47. v |= MX27_H1_PM_BIT;
  48. if (!(flags & MXC_EHCI_TTL_ENABLED))
  49. v |= MX27_H1_DT_BIT;
  50. break;
  51. case 2: /* H2 port */
  52. v &= ~(MX27_H2_SIC_MASK | MX27_H2_PM_BIT | MX27_H2_DT_BIT);
  53. v |= (flags & MXC_EHCI_INTERFACE_MASK) << MX27_H2_SIC_SHIFT;
  54. if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))
  55. v |= MX27_H2_PM_BIT;
  56. if (!(flags & MXC_EHCI_TTL_ENABLED))
  57. v |= MX27_H2_DT_BIT;
  58. break;
  59. default:
  60. return -EINVAL;
  61. }
  62. writel(v, MX27_IO_ADDRESS(MX27_USB_BASE_ADDR + USBCTRL_OTGBASE_OFFSET));
  63. return 0;
  64. }