1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Cadence USBSS DRD Header File.
5 * Copyright (C) 2017-2018 NXP
6 * Copyright (C) 2018-2019 Cadence.
11 #include <linux/usb/otg.h>
12 #include <linux/usb/role.h>
14 #ifndef __LINUX_CDNS3_CORE_H
15 #define __LINUX_CDNS3_CORE_H
20 * struct cdns3_role_driver - host/gadget role driver
21 * @start: start this role
22 * @stop: stop this role
23 * @suspend: suspend callback for this role
24 * @resume: resume callback for this role
25 * @irq: irq handler for this role
26 * @name: role name string (host/gadget)
27 * @state: current state
29 struct cdns3_role_driver {
30 int (*start)(struct cdns3 *cdns);
31 void (*stop)(struct cdns3 *cdns);
32 int (*suspend)(struct cdns3 *cdns, bool do_wakeup);
33 int (*resume)(struct cdns3 *cdns, bool hibernated);
35 #define CDNS3_ROLE_STATE_INACTIVE 0
36 #define CDNS3_ROLE_STATE_ACTIVE 1
40 #define CDNS3_XHCI_RESOURCES_NUM 2
42 struct cdns3_platform_data {
43 int (*platform_suspend)(struct device *dev,
44 bool suspend, bool wakeup);
48 * struct cdns3 - Representation of Cadence USB3 DRD controller.
49 * @dev: pointer to Cadence device struct
50 * @xhci_regs: pointer to base of xhci registers
51 * @xhci_res: the resource for xhci
52 * @dev_regs: pointer to base of dev registers
53 * @otg_res: the resource for otg
54 * @otg_v0_regs: pointer to base of v0 otg registers
55 * @otg_v1_regs: pointer to base of v1 otg registers
56 * @otg_regs: pointer to base of otg registers
57 * @otg_irq: irq number for otg controller
58 * @dev_irq: irq number for device controller
59 * @wakeup_irq: irq number for wakeup event, it is optional
60 * @roles: array of supported roles for this controller
62 * @host_dev: the child host device pointer for cdns3 core
63 * @gadget_dev: the child gadget device pointer for cdns3 core
64 * @usb2_phy: pointer to USB2 PHY
65 * @usb3_phy: pointer to USB3 PHY
66 * @mutex: the mutex for concurrent code at driver
67 * @dr_mode: supported mode of operation it can be only Host, only Device
68 * or OTG mode that allow to switch between Device and Host mode.
69 * This field based on firmware setting, kernel configuration
70 * and hardware configuration.
71 * @role_sw: pointer to role switch object.
72 * @in_lpm: indicate the controller is in low power mode
73 * @wakeup_pending: wakeup interrupt pending
74 * @pdata: platform data from glue layer
75 * @lock: spinlock structure
79 void __iomem *xhci_regs;
80 struct resource xhci_res[CDNS3_XHCI_RESOURCES_NUM];
81 struct cdns3_usb_regs __iomem *dev_regs;
83 struct resource otg_res;
84 struct cdns3_otg_legacy_regs *otg_v0_regs;
85 struct cdns3_otg_regs *otg_v1_regs;
86 struct cdns3_otg_common_regs *otg_regs;
87 #define CDNS3_CONTROLLER_V0 0
88 #define CDNS3_CONTROLLER_V1 1
95 struct cdns3_role_driver *roles[USB_ROLE_DEVICE + 1];
97 struct platform_device *host_dev;
98 struct cdns3_device *gadget_dev;
100 struct phy *usb3_phy;
101 /* mutext used in workqueue*/
103 enum usb_dr_mode dr_mode;
104 struct usb_role_switch *role_sw;
107 struct cdns3_platform_data *pdata;
111 int cdns3_hw_role_switch(struct cdns3 *cdns);
113 #endif /* __LINUX_CDNS3_CORE_H */