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.
8 * Authors: Peter Chen <peter.chen@nxp.com>
9 * Pawel Laszczak <pawell@cadence.com>
11 #include <linux/compiler.h>
12 #include <linux/types.h>
13 #include <linux/usb/otg.h>
14 #include <generic-phy.h>
16 #ifndef __LINUX_CDNS3_CORE_H
17 #define __LINUX_CDNS3_CORE_H
28 * struct cdns3_role_driver - host/gadget role driver
29 * @start: start this role
30 * @stop: stop this role
31 * @suspend: suspend callback for this role
32 * @resume: resume callback for this role
33 * @irq: irq handler for this role
34 * @name: role name string (host/gadget)
35 * @state: current state
37 struct cdns3_role_driver {
38 int (*start)(struct cdns3 *cdns);
39 void (*stop)(struct cdns3 *cdns);
40 int (*suspend)(struct cdns3 *cdns, bool do_wakeup);
41 int (*resume)(struct cdns3 *cdns, bool hibernated);
43 #define CDNS3_ROLE_STATE_INACTIVE 0
44 #define CDNS3_ROLE_STATE_ACTIVE 1
48 #define CDNS3_XHCI_RESOURCES_NUM 2
50 * struct cdns3 - Representation of Cadence USB3 DRD controller.
51 * @dev: pointer to Cadence device struct
52 * @xhci_regs: pointer to base of xhci registers
53 * @dev_regs: pointer to base of dev registers
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 * @roles: array of supported roles for this controller
61 * @host_dev: the child host device pointer for cdns3 core
62 * @gadget_dev: the child gadget device pointer for cdns3 core
63 * @usb2_phy: pointer to USB2 PHY
64 * @usb3_phy: pointer to USB3 PHY
65 * @mutex: the mutex for concurrent code at driver
66 * @dr_mode: supported mode of operation it can be only Host, only Device
67 * or OTG mode that allow to switch between Device and Host mode.
68 * This field based on firmware setting, kernel configuration
69 * and hardware configuration.
70 * @role_sw: pointer to role switch object.
71 * @role_override: set 1 if role rely on SW.
75 void __iomem *xhci_regs;
76 struct cdns3_usb_regs __iomem *dev_regs;
78 struct cdns3_otg_legacy_regs *otg_v0_regs;
79 struct cdns3_otg_regs *otg_v1_regs;
80 struct cdns3_otg_common_regs *otg_regs;
81 #define CDNS3_CONTROLLER_V0 0
82 #define CDNS3_CONTROLLER_V1 1
87 struct cdns3_role_driver *roles[USB_ROLE_DEVICE + 1];
89 struct cdns3_device *gadget_dev;
92 /* mutext used in workqueue*/
94 enum usb_dr_mode dr_mode;
98 int cdns3_hw_role_switch(struct cdns3 *cdns);
101 * cdns3_bind - generic bind function
102 * @parent - pointer to parent udevice of which cdns3 USB controller
105 * return 0 on success, negative errno otherwise
107 int cdns3_bind(struct udevice *dev);
108 #endif /* __LINUX_CDNS3_CORE_H */