ehci.c 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the
  6. * Free Software Foundation; either version 2 of the License, or (at your
  7. * option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  11. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. * for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software Foundation,
  16. * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18. #include <linux/platform_device.h>
  19. #include <linux/io.h>
  20. #include <mach/hardware.h>
  21. #include <mach/mxc_ehci.h>
  22. #define USBCTRL_OTGBASE_OFFSET 0x600
  23. #define MX31_OTG_SIC_SHIFT 29
  24. #define MX31_OTG_SIC_MASK (0xf << MX31_OTG_SIC_SHIFT)
  25. #define MX31_OTG_PM_BIT (1 << 24)
  26. #define MX31_H2_SIC_SHIFT 21
  27. #define MX31_H2_SIC_MASK (0xf << MX31_H2_SIC_SHIFT)
  28. #define MX31_H2_PM_BIT (1 << 16)
  29. #define MX31_H2_DT_BIT (1 << 5)
  30. #define MX31_H1_SIC_SHIFT 13
  31. #define MX31_H1_SIC_MASK (0xf << MX31_H1_SIC_SHIFT)
  32. #define MX31_H1_PM_BIT (1 << 8)
  33. #define MX31_H1_DT_BIT (1 << 4)
  34. int mxc_set_usbcontrol(int port, unsigned int flags)
  35. {
  36. unsigned int v;
  37. if (cpu_is_mx31()) {
  38. v = readl(IO_ADDRESS(MX31_OTG_BASE_ADDR +
  39. USBCTRL_OTGBASE_OFFSET));
  40. switch (port) {
  41. case 0: /* OTG port */
  42. v &= ~(MX31_OTG_SIC_MASK | MX31_OTG_PM_BIT);
  43. v |= (flags & MXC_EHCI_INTERFACE_MASK)
  44. << MX31_OTG_SIC_SHIFT;
  45. if (flags & MXC_EHCI_POWER_PINS_ENABLED)
  46. v |= MX31_OTG_PM_BIT;
  47. break;
  48. case 1: /* H1 port */
  49. v &= ~(MX31_H1_SIC_MASK | MX31_H1_PM_BIT);
  50. v |= (flags & MXC_EHCI_INTERFACE_MASK)
  51. << MX31_H1_SIC_SHIFT;
  52. if (flags & MXC_EHCI_POWER_PINS_ENABLED)
  53. v |= MX31_H1_PM_BIT;
  54. if (!(flags & MXC_EHCI_TTL_ENABLED))
  55. v |= MX31_H1_DT_BIT;
  56. break;
  57. case 2: /* H2 port */
  58. v &= ~(MX31_H2_SIC_MASK | MX31_H2_PM_BIT);
  59. v |= (flags & MXC_EHCI_INTERFACE_MASK)
  60. << MX31_H2_SIC_SHIFT;
  61. if (!(flags & MXC_EHCI_POWER_PINS_ENABLED))
  62. v |= MX31_H2_PM_BIT;
  63. if (!(flags & MXC_EHCI_TTL_ENABLED))
  64. v |= MX31_H2_DT_BIT;
  65. break;
  66. }
  67. writel(v, IO_ADDRESS(MX31_OTG_BASE_ADDR +
  68. USBCTRL_OTGBASE_OFFSET));
  69. return 0;
  70. }
  71. printk(KERN_WARNING
  72. "%s() unable to setup USBCONTROL for this CPU\n", __func__);
  73. return -EINVAL;
  74. }
  75. EXPORT_SYMBOL(mxc_set_usbcontrol);