Ido Shayevitz | cdeef4c | 2012-05-29 13:17:41 +0200 | [diff] [blame] | 1 | /** |
| 2 | * dwc3_otg.h - DesignWare USB3 DRD Controller OTG |
| 3 | * |
Vijayavardhan Vennapusa | 4514588 | 2013-01-03 14:11:58 +0530 | [diff] [blame] | 4 | * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
Ido Shayevitz | cdeef4c | 2012-05-29 13:17:41 +0200 | [diff] [blame] | 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 | |
| 16 | #ifndef __LINUX_USB_DWC3_OTG_H |
| 17 | #define __LINUX_USB_DWC3_OTG_H |
| 18 | |
| 19 | #include <linux/workqueue.h> |
Vijayavardhan Vennapusa | 42eeea3 | 2012-10-22 17:56:11 +0530 | [diff] [blame] | 20 | #include <linux/power_supply.h> |
Ido Shayevitz | cdeef4c | 2012-05-29 13:17:41 +0200 | [diff] [blame] | 21 | |
| 22 | #include <linux/usb/otg.h> |
Vijayavardhan Vennapusa | 4514588 | 2013-01-03 14:11:58 +0530 | [diff] [blame] | 23 | #include "power.h" |
Ido Shayevitz | cdeef4c | 2012-05-29 13:17:41 +0200 | [diff] [blame] | 24 | |
Vijayavardhan Vennapusa | 42eeea3 | 2012-10-22 17:56:11 +0530 | [diff] [blame] | 25 | #define DWC3_IDEV_CHG_MAX 1500 |
| 26 | |
Manu Gautam | 8c64281 | 2012-06-07 10:35:10 +0530 | [diff] [blame] | 27 | struct dwc3_charger; |
| 28 | |
Ido Shayevitz | cdeef4c | 2012-05-29 13:17:41 +0200 | [diff] [blame] | 29 | /** |
| 30 | * struct dwc3_otg: OTG driver data. Shared by HCD and DCD. |
| 31 | * @otg: USB OTG Transceiver structure. |
| 32 | * @irq: IRQ number assigned for HSUSB controller. |
| 33 | * @regs: ioremapped register base address. |
| 34 | * @sm_work: OTG state machine work. |
Manu Gautam | 8c64281 | 2012-06-07 10:35:10 +0530 | [diff] [blame] | 35 | * @charger: DWC3 external charger detector |
| 36 | * @inputs: OTG state machine inputs |
Ido Shayevitz | cdeef4c | 2012-05-29 13:17:41 +0200 | [diff] [blame] | 37 | */ |
| 38 | struct dwc3_otg { |
Manu Gautam | f1fceddf | 2012-10-12 14:02:50 +0530 | [diff] [blame] | 39 | struct usb_otg otg; |
| 40 | int irq; |
| 41 | struct dwc3 *dwc; |
| 42 | void __iomem *regs; |
| 43 | struct regulator *vbus_otg; |
Manu Gautam | b506727 | 2012-07-02 09:53:41 +0530 | [diff] [blame] | 44 | struct work_struct sm_work; |
| 45 | struct dwc3_charger *charger; |
| 46 | struct dwc3_ext_xceiv *ext_xceiv; |
Manu Gautam | 8c64281 | 2012-06-07 10:35:10 +0530 | [diff] [blame] | 47 | #define ID 0 |
| 48 | #define B_SESS_VLD 1 |
| 49 | unsigned long inputs; |
Vijayavardhan Vennapusa | 42eeea3 | 2012-10-22 17:56:11 +0530 | [diff] [blame] | 50 | struct power_supply *psy; |
| 51 | struct completion dwc3_xcvr_vbus_init; |
Vijayavardhan Vennapusa | 4514588 | 2013-01-03 14:11:58 +0530 | [diff] [blame] | 52 | int host_bus_suspend; |
Ido Shayevitz | cdeef4c | 2012-05-29 13:17:41 +0200 | [diff] [blame] | 53 | }; |
Manu Gautam | 8c64281 | 2012-06-07 10:35:10 +0530 | [diff] [blame] | 54 | |
| 55 | /** |
| 56 | * USB charger types |
| 57 | * |
| 58 | * DWC3_INVALID_CHARGER Invalid USB charger. |
| 59 | * DWC3_SDP_CHARGER Standard downstream port. Refers to a downstream port |
| 60 | * on USB compliant host/hub. |
| 61 | * DWC3_DCP_CHARGER Dedicated charger port (AC charger/ Wall charger). |
| 62 | * DWC3_CDP_CHARGER Charging downstream port. Enumeration can happen and |
| 63 | * IDEV_CHG_MAX can be drawn irrespective of USB state. |
Manu Gautam | a1e331d | 2013-02-07 14:55:05 +0530 | [diff] [blame] | 64 | * DWC3_PROPRIETARY_CHARGER A proprietary charger pull DP and DM to specific |
| 65 | * voltages between 2.0-3.3v for identification. |
Manu Gautam | 8c64281 | 2012-06-07 10:35:10 +0530 | [diff] [blame] | 66 | */ |
| 67 | enum dwc3_chg_type { |
| 68 | DWC3_INVALID_CHARGER = 0, |
| 69 | DWC3_SDP_CHARGER, |
| 70 | DWC3_DCP_CHARGER, |
| 71 | DWC3_CDP_CHARGER, |
Manu Gautam | a1e331d | 2013-02-07 14:55:05 +0530 | [diff] [blame] | 72 | DWC3_PROPRIETARY_CHARGER, |
Manu Gautam | 8c64281 | 2012-06-07 10:35:10 +0530 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | struct dwc3_charger { |
| 76 | enum dwc3_chg_type chg_type; |
Vijayavardhan Vennapusa | 42eeea3 | 2012-10-22 17:56:11 +0530 | [diff] [blame] | 77 | unsigned max_power; |
Manu Gautam | 6c0ff03 | 2012-11-02 14:55:35 +0530 | [diff] [blame] | 78 | bool charging_disabled; |
Manu Gautam | 8c64281 | 2012-06-07 10:35:10 +0530 | [diff] [blame] | 79 | |
| 80 | /* start/stop charger detection, provided by external charger module */ |
| 81 | void (*start_detection)(struct dwc3_charger *charger, bool start); |
| 82 | |
| 83 | /* to notify OTG about charger detection completion, provided by OTG */ |
| 84 | void (*notify_detection_complete)(struct usb_otg *otg, |
| 85 | struct dwc3_charger *charger); |
| 86 | }; |
| 87 | |
| 88 | /* for external charger driver */ |
| 89 | extern int dwc3_set_charger(struct usb_otg *otg, struct dwc3_charger *charger); |
| 90 | |
Manu Gautam | b506727 | 2012-07-02 09:53:41 +0530 | [diff] [blame] | 91 | enum dwc3_ext_events { |
| 92 | DWC3_EVENT_NONE = 0, /* no change event */ |
| 93 | DWC3_EVENT_PHY_RESUME, /* PHY has come out of LPM */ |
| 94 | DWC3_EVENT_XCEIV_STATE, /* XCEIV state (id/bsv) has changed */ |
| 95 | }; |
| 96 | |
| 97 | enum dwc3_id_state { |
| 98 | DWC3_ID_GROUND = 0, |
| 99 | DWC3_ID_FLOAT, |
| 100 | }; |
| 101 | |
| 102 | /* external transceiver that can perform connect/disconnect monitoring in LPM */ |
| 103 | struct dwc3_ext_xceiv { |
| 104 | enum dwc3_id_state id; |
| 105 | bool bsv; |
Vijayavardhan Vennapusa | d2993b8 | 2012-10-22 13:08:21 +0530 | [diff] [blame] | 106 | bool otg_capability; |
Manu Gautam | b506727 | 2012-07-02 09:53:41 +0530 | [diff] [blame] | 107 | |
| 108 | /* to notify OTG about LPM exit event, provided by OTG */ |
| 109 | void (*notify_ext_events)(struct usb_otg *otg, |
| 110 | enum dwc3_ext_events ext_event); |
Vijayavardhan Vennapusa | b743456 | 2012-12-12 16:48:49 +0530 | [diff] [blame] | 111 | /* for block reset USB core */ |
| 112 | void (*ext_block_reset)(void); |
Manu Gautam | b506727 | 2012-07-02 09:53:41 +0530 | [diff] [blame] | 113 | }; |
| 114 | |
| 115 | /* for external transceiver driver */ |
| 116 | extern int dwc3_set_ext_xceiv(struct usb_otg *otg, |
| 117 | struct dwc3_ext_xceiv *ext_xceiv); |
| 118 | |
Ido Shayevitz | cdeef4c | 2012-05-29 13:17:41 +0200 | [diff] [blame] | 119 | #endif /* __LINUX_USB_DWC3_OTG_H */ |