dwc3_otg.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /**
  2. * dwc3_otg.h - DesignWare USB3 DRD Controller OTG
  3. *
  4. * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 and
  8. * only version 2 as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #ifndef __LINUX_USB_DWC3_OTG_H
  16. #define __LINUX_USB_DWC3_OTG_H
  17. #include <linux/workqueue.h>
  18. #include <linux/power_supply.h>
  19. #include <linux/usb/otg.h>
  20. #include "power.h"
  21. #define DWC3_IDEV_CHG_MAX 1500
  22. struct dwc3_charger;
  23. /**
  24. * struct dwc3_otg: OTG driver data. Shared by HCD and DCD.
  25. * @otg: USB OTG Transceiver structure.
  26. * @irq: IRQ number assigned for HSUSB controller.
  27. * @regs: ioremapped register base address.
  28. * @sm_work: OTG state machine work.
  29. * @charger: DWC3 external charger detector
  30. * @inputs: OTG state machine inputs
  31. */
  32. struct dwc3_otg {
  33. struct usb_otg otg;
  34. int irq;
  35. struct dwc3 *dwc;
  36. void __iomem *regs;
  37. struct regulator *vbus_otg;
  38. struct delayed_work sm_work;
  39. struct dwc3_charger *charger;
  40. struct dwc3_ext_xceiv *ext_xceiv;
  41. #define ID 0
  42. #define B_SESS_VLD 1
  43. unsigned long inputs;
  44. struct power_supply *psy;
  45. struct completion dwc3_xcvr_vbus_init;
  46. int host_bus_suspend;
  47. int charger_retry_count;
  48. int vbus_retry_count;
  49. };
  50. /**
  51. * USB charger types
  52. *
  53. * DWC3_INVALID_CHARGER Invalid USB charger.
  54. * DWC3_SDP_CHARGER Standard downstream port. Refers to a downstream port
  55. * on USB compliant host/hub.
  56. * DWC3_DCP_CHARGER Dedicated charger port (AC charger/ Wall charger).
  57. * DWC3_CDP_CHARGER Charging downstream port. Enumeration can happen and
  58. * IDEV_CHG_MAX can be drawn irrespective of USB state.
  59. * DWC3_PROPRIETARY_CHARGER A proprietary charger pull DP and DM to specific
  60. * voltages between 2.0-3.3v for identification.
  61. * DWC3_FLOATED_CHARGER Non standard charger whose data lines are floating.
  62. */
  63. enum dwc3_chg_type {
  64. DWC3_INVALID_CHARGER = 0,
  65. DWC3_SDP_CHARGER,
  66. DWC3_DCP_CHARGER,
  67. DWC3_CDP_CHARGER,
  68. DWC3_PROPRIETARY_CHARGER,
  69. DWC3_FLOATED_CHARGER,
  70. };
  71. struct dwc3_charger {
  72. enum dwc3_chg_type chg_type;
  73. unsigned max_power;
  74. bool charging_disabled;
  75. bool skip_chg_detect;
  76. /* start/stop charger detection, provided by external charger module */
  77. void (*start_detection)(struct dwc3_charger *charger, bool start);
  78. /* to notify OTG about charger detection completion, provided by OTG */
  79. void (*notify_detection_complete)(struct usb_otg *otg,
  80. struct dwc3_charger *charger);
  81. };
  82. /* for external charger driver */
  83. extern int dwc3_set_charger(struct usb_otg *otg, struct dwc3_charger *charger);
  84. enum dwc3_ext_events {
  85. DWC3_EVENT_NONE = 0, /* no change event */
  86. DWC3_EVENT_PHY_RESUME, /* PHY has come out of LPM */
  87. DWC3_EVENT_XCEIV_STATE, /* XCEIV state (id/bsv) has changed */
  88. };
  89. enum dwc3_id_state {
  90. DWC3_ID_GROUND = 0,
  91. DWC3_ID_FLOAT,
  92. };
  93. /* external transceiver that can perform connect/disconnect monitoring in LPM */
  94. struct dwc3_ext_xceiv {
  95. enum dwc3_id_state id;
  96. bool bsv;
  97. bool otg_capability;
  98. /* to notify OTG about LPM exit event, provided by OTG */
  99. void (*notify_ext_events)(struct usb_otg *otg,
  100. enum dwc3_ext_events ext_event);
  101. /* for block reset USB core */
  102. void (*ext_block_reset)(struct dwc3_ext_xceiv *ext_xceiv,
  103. bool core_reset);
  104. };
  105. /* for external transceiver driver */
  106. extern int dwc3_set_ext_xceiv(struct usb_otg *otg,
  107. struct dwc3_ext_xceiv *ext_xceiv);
  108. #endif /* __LINUX_USB_DWC3_OTG_H */