0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef __LINUX_CDNS3_CORE_H
0012 #define __LINUX_CDNS3_CORE_H
0013
0014 #include <linux/usb/otg.h>
0015 #include <linux/usb/role.h>
0016
0017 struct cdns;
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 struct cdns_role_driver {
0030 int (*start)(struct cdns *cdns);
0031 void (*stop)(struct cdns *cdns);
0032 int (*suspend)(struct cdns *cdns, bool do_wakeup);
0033 int (*resume)(struct cdns *cdns, bool hibernated);
0034 const char *name;
0035 #define CDNS_ROLE_STATE_INACTIVE 0
0036 #define CDNS_ROLE_STATE_ACTIVE 1
0037 int state;
0038 };
0039
0040 #define CDNS_XHCI_RESOURCES_NUM 2
0041
0042 struct cdns3_platform_data {
0043 int (*platform_suspend)(struct device *dev,
0044 bool suspend, bool wakeup);
0045 unsigned long quirks;
0046 #define CDNS3_DEFAULT_PM_RUNTIME_ALLOW BIT(0)
0047 };
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083 struct cdns {
0084 struct device *dev;
0085 void __iomem *xhci_regs;
0086 struct resource xhci_res[CDNS_XHCI_RESOURCES_NUM];
0087 struct cdns3_usb_regs __iomem *dev_regs;
0088
0089 struct resource otg_res;
0090 struct cdns3_otg_legacy_regs __iomem *otg_v0_regs;
0091 struct cdns3_otg_regs __iomem *otg_v1_regs;
0092 struct cdnsp_otg_regs __iomem *otg_cdnsp_regs;
0093 struct cdns_otg_common_regs __iomem *otg_regs;
0094 struct cdns_otg_irq_regs __iomem *otg_irq_regs;
0095 #define CDNS3_CONTROLLER_V0 0
0096 #define CDNS3_CONTROLLER_V1 1
0097 #define CDNSP_CONTROLLER_V2 2
0098 u32 version;
0099 bool phyrst_a_enable;
0100
0101 int otg_irq;
0102 int dev_irq;
0103 int wakeup_irq;
0104 struct cdns_role_driver *roles[USB_ROLE_DEVICE + 1];
0105 enum usb_role role;
0106 struct platform_device *host_dev;
0107 void *gadget_dev;
0108 struct phy *usb2_phy;
0109 struct phy *usb3_phy;
0110
0111 struct mutex mutex;
0112 enum usb_dr_mode dr_mode;
0113 struct usb_role_switch *role_sw;
0114 bool in_lpm;
0115 bool wakeup_pending;
0116 struct cdns3_platform_data *pdata;
0117 spinlock_t lock;
0118 struct xhci_plat_priv *xhci_plat_data;
0119
0120 int (*gadget_init)(struct cdns *cdns);
0121 };
0122
0123 int cdns_hw_role_switch(struct cdns *cdns);
0124 int cdns_init(struct cdns *cdns);
0125 int cdns_remove(struct cdns *cdns);
0126
0127 #ifdef CONFIG_PM_SLEEP
0128 int cdns_resume(struct cdns *cdns, u8 set_active);
0129 int cdns_suspend(struct cdns *cdns);
0130 #else
0131 static inline int cdns_resume(struct cdns *cdns, u8 set_active)
0132 { return 0; }
0133 static inline int cdns_suspend(struct cdns *cdns)
0134 { return 0; }
0135 #endif
0136 #endif