omap_usb.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * omap_usb.h -- omap usb2 phy header file
  3. *
  4. * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * Author: Kishon Vijay Abraham I <kishon@ti.com>
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. */
  18. #ifndef __DRIVERS_OMAP_USB2_H
  19. #define __DRIVERS_OMAP_USB2_H
  20. #include <linux/io.h>
  21. #include <linux/usb/otg.h>
  22. struct usb_dpll_params {
  23. u16 m;
  24. u8 n;
  25. u8 freq:3;
  26. u8 sd;
  27. u32 mf;
  28. };
  29. enum omap_usb_phy_type {
  30. TYPE_USB2, /* USB2_PHY, power down in CONTROL_DEV_CONF */
  31. TYPE_DRA7USB2, /* USB2 PHY, power and power_aux e.g. DRA7 */
  32. TYPE_AM437USB2, /* USB2 PHY, power e.g. AM437x */
  33. };
  34. struct omap_usb {
  35. struct usb_phy phy;
  36. struct phy_companion *comparator;
  37. void __iomem *pll_ctrl_base;
  38. void __iomem *phy_base;
  39. struct device *dev;
  40. struct device *control_dev;
  41. struct clk *wkupclk;
  42. struct clk *optclk;
  43. u8 flags;
  44. enum omap_usb_phy_type type;
  45. struct regmap *syscon_phy_power; /* ctrl. reg. acces */
  46. unsigned int power_reg; /* power reg. index within syscon */
  47. u32 mask;
  48. u32 power_on;
  49. u32 power_off;
  50. };
  51. struct usb_phy_data {
  52. const char *label;
  53. u8 flags;
  54. u32 mask;
  55. u32 power_on;
  56. u32 power_off;
  57. };
  58. /* Driver Flags */
  59. #define OMAP_USB2_HAS_START_SRP (1 << 0)
  60. #define OMAP_USB2_HAS_SET_VBUS (1 << 1)
  61. #define OMAP_USB2_CALIBRATE_FALSE_DISCONNECT (1 << 2)
  62. #define OMAP_DEV_PHY_PD BIT(0)
  63. #define OMAP_USB2_PHY_PD BIT(28)
  64. #define AM437X_USB2_PHY_PD BIT(0)
  65. #define AM437X_USB2_OTG_PD BIT(1)
  66. #define AM437X_USB2_OTGVDET_EN BIT(19)
  67. #define AM437X_USB2_OTGSESSEND_EN BIT(20)
  68. #define phy_to_omapusb(x) container_of((x), struct omap_usb, phy)
  69. #if defined(CONFIG_OMAP_USB2) || defined(CONFIG_OMAP_USB2_MODULE)
  70. extern int omap_usb2_set_comparator(struct phy_companion *comparator);
  71. #else
  72. static inline int omap_usb2_set_comparator(struct phy_companion *comparator)
  73. {
  74. return -ENODEV;
  75. }
  76. #endif
  77. static inline u32 omap_usb_readl(void __iomem *addr, unsigned offset)
  78. {
  79. return __raw_readl(addr + offset);
  80. }
  81. static inline void omap_usb_writel(void __iomem *addr, unsigned offset,
  82. u32 data)
  83. {
  84. __raw_writel(data, addr + offset);
  85. }
  86. #endif /* __DRIVERS_OMAP_USB_H */