Ido Shayevitz | cdeef4c | 2012-05-29 13:17:41 +0200 | [diff] [blame] | 1 | /** |
| 2 | * dwc3_otg.h - DesignWare USB3 DRD Controller OTG |
| 3 | * |
Duy Truong | e833aca | 2013-02-12 13:35:08 -0800 | [diff] [blame^] | 4 | * Copyright (c) 2012, 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> |
| 20 | |
| 21 | #include <linux/usb/otg.h> |
| 22 | |
Manu Gautam | 8c64281 | 2012-06-07 10:35:10 +0530 | [diff] [blame] | 23 | struct dwc3_charger; |
| 24 | |
Ido Shayevitz | cdeef4c | 2012-05-29 13:17:41 +0200 | [diff] [blame] | 25 | /** |
| 26 | * struct dwc3_otg: OTG driver data. Shared by HCD and DCD. |
| 27 | * @otg: USB OTG Transceiver structure. |
| 28 | * @irq: IRQ number assigned for HSUSB controller. |
| 29 | * @regs: ioremapped register base address. |
| 30 | * @sm_work: OTG state machine work. |
Manu Gautam | 8c64281 | 2012-06-07 10:35:10 +0530 | [diff] [blame] | 31 | * @charger: DWC3 external charger detector |
| 32 | * @inputs: OTG state machine inputs |
Ido Shayevitz | cdeef4c | 2012-05-29 13:17:41 +0200 | [diff] [blame] | 33 | */ |
| 34 | struct dwc3_otg { |
| 35 | struct usb_otg otg; |
| 36 | int irq; |
| 37 | void __iomem *regs; |
Manu Gautam | b506727 | 2012-07-02 09:53:41 +0530 | [diff] [blame] | 38 | struct work_struct sm_work; |
| 39 | struct dwc3_charger *charger; |
| 40 | struct dwc3_ext_xceiv *ext_xceiv; |
Manu Gautam | 8c64281 | 2012-06-07 10:35:10 +0530 | [diff] [blame] | 41 | #define ID 0 |
| 42 | #define B_SESS_VLD 1 |
| 43 | unsigned long inputs; |
Ido Shayevitz | cdeef4c | 2012-05-29 13:17:41 +0200 | [diff] [blame] | 44 | }; |
Manu Gautam | 8c64281 | 2012-06-07 10:35:10 +0530 | [diff] [blame] | 45 | |
| 46 | /** |
| 47 | * USB charger types |
| 48 | * |
| 49 | * DWC3_INVALID_CHARGER Invalid USB charger. |
| 50 | * DWC3_SDP_CHARGER Standard downstream port. Refers to a downstream port |
| 51 | * on USB compliant host/hub. |
| 52 | * DWC3_DCP_CHARGER Dedicated charger port (AC charger/ Wall charger). |
| 53 | * DWC3_CDP_CHARGER Charging downstream port. Enumeration can happen and |
| 54 | * IDEV_CHG_MAX can be drawn irrespective of USB state. |
| 55 | */ |
| 56 | enum dwc3_chg_type { |
| 57 | DWC3_INVALID_CHARGER = 0, |
| 58 | DWC3_SDP_CHARGER, |
| 59 | DWC3_DCP_CHARGER, |
| 60 | DWC3_CDP_CHARGER, |
| 61 | }; |
| 62 | |
| 63 | struct dwc3_charger { |
| 64 | enum dwc3_chg_type chg_type; |
| 65 | |
| 66 | /* start/stop charger detection, provided by external charger module */ |
| 67 | void (*start_detection)(struct dwc3_charger *charger, bool start); |
| 68 | |
| 69 | /* to notify OTG about charger detection completion, provided by OTG */ |
| 70 | void (*notify_detection_complete)(struct usb_otg *otg, |
| 71 | struct dwc3_charger *charger); |
| 72 | }; |
| 73 | |
| 74 | /* for external charger driver */ |
| 75 | extern int dwc3_set_charger(struct usb_otg *otg, struct dwc3_charger *charger); |
| 76 | |
Manu Gautam | b506727 | 2012-07-02 09:53:41 +0530 | [diff] [blame] | 77 | enum dwc3_ext_events { |
| 78 | DWC3_EVENT_NONE = 0, /* no change event */ |
| 79 | DWC3_EVENT_PHY_RESUME, /* PHY has come out of LPM */ |
| 80 | DWC3_EVENT_XCEIV_STATE, /* XCEIV state (id/bsv) has changed */ |
| 81 | }; |
| 82 | |
| 83 | enum dwc3_id_state { |
| 84 | DWC3_ID_GROUND = 0, |
| 85 | DWC3_ID_FLOAT, |
| 86 | }; |
| 87 | |
| 88 | /* external transceiver that can perform connect/disconnect monitoring in LPM */ |
| 89 | struct dwc3_ext_xceiv { |
| 90 | enum dwc3_id_state id; |
| 91 | bool bsv; |
| 92 | |
| 93 | /* to notify OTG about LPM exit event, provided by OTG */ |
| 94 | void (*notify_ext_events)(struct usb_otg *otg, |
| 95 | enum dwc3_ext_events ext_event); |
| 96 | }; |
| 97 | |
| 98 | /* for external transceiver driver */ |
| 99 | extern int dwc3_set_ext_xceiv(struct usb_otg *otg, |
| 100 | struct dwc3_ext_xceiv *ext_xceiv); |
| 101 | |
Ido Shayevitz | cdeef4c | 2012-05-29 13:17:41 +0200 | [diff] [blame] | 102 | #endif /* __LINUX_USB_DWC3_OTG_H */ |