| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
#ifndef __LINUX_CDNS3_CORE_H |
| 12 |
#define __LINUX_CDNS3_CORE_H |
| 13 |
|
| 14 |
#include <linux/usb/otg.h> |
| 15 |
#include <linux/usb/role.h> |
| 16 |
|
| 17 |
struct cdns; |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
struct cdns_role_driver { |
| 30 |
int (*start)(struct cdns *cdns); |
| 31 |
void (*stop)(struct cdns *cdns); |
| 32 |
int (*suspend)(struct cdns *cdns, bool do_wakeup); |
| 33 |
int (*resume)(struct cdns *cdns, bool lost_power); |
| 34 |
const char *name; |
| 35 |
#define CDNS_ROLE_STATE_INACTIVE 0 |
| 36 |
#define CDNS_ROLE_STATE_ACTIVE 1 |
| 37 |
int state; |
| 38 |
}; |
| 39 |
|
| 40 |
#define CDNS_XHCI_RESOURCES_NUM 2 |
| 41 |
|
| 42 |
struct cdns3_platform_data { |
| 43 |
int (*platform_suspend)(struct device *dev, |
| 44 |
bool suspend, bool wakeup); |
| 45 |
unsigned long quirks; |
| 46 |
#define CDNS3_DEFAULT_PM_RUNTIME_ALLOW BIT(0) |
| 47 |
#define CDNS3_DRD_SUSPEND_RESIDENCY_ENABLE BIT(1) |
| 48 |
}; |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
struct cdns { |
| 87 |
struct device *dev; |
| 88 |
void __iomem *xhci_regs; |
| 89 |
struct resource xhci_res[CDNS_XHCI_RESOURCES_NUM]; |
| 90 |
struct cdns3_usb_regs __iomem *dev_regs; |
| 91 |
|
| 92 |
struct resource otg_res; |
| 93 |
struct cdns3_otg_legacy_regs __iomem *otg_v0_regs; |
| 94 |
struct cdns3_otg_regs __iomem *otg_v1_regs; |
| 95 |
struct cdnsp_otg_regs __iomem *otg_cdnsp_regs; |
| 96 |
struct cdns_otg_common_regs __iomem *otg_regs; |
| 97 |
struct cdns_otg_irq_regs __iomem *otg_irq_regs; |
| 98 |
#define CDNS3_CONTROLLER_V0 0 |
| 99 |
#define CDNS3_CONTROLLER_V1 1 |
| 100 |
#define CDNSP_CONTROLLER_V2 2 |
| 101 |
u32 version; |
| 102 |
bool phyrst_a_enable; |
| 103 |
|
| 104 |
int otg_irq; |
| 105 |
int dev_irq; |
| 106 |
int wakeup_irq; |
| 107 |
struct cdns_role_driver *roles[USB_ROLE_DEVICE + 1]; |
| 108 |
enum usb_role role; |
| 109 |
struct platform_device *host_dev; |
| 110 |
void *gadget_dev; |
| 111 |
struct phy *usb2_phy; |
| 112 |
struct phy *usb3_phy; |
| 113 |
|
| 114 |
struct mutex mutex; |
| 115 |
enum usb_dr_mode dr_mode; |
| 116 |
struct usb_role_switch *role_sw; |
| 117 |
bool in_lpm; |
| 118 |
bool wakeup_pending; |
| 119 |
struct cdns3_platform_data *pdata; |
| 120 |
spinlock_t lock; |
| 121 |
struct xhci_plat_priv *xhci_plat_data; |
| 122 |
u32 override_apb_timeout; |
| 123 |
|
| 124 |
int (*gadget_init)(struct cdns *cdns); |
| 125 |
}; |
| 126 |
|
| 127 |
int cdns_hw_role_switch(struct cdns *cdns); |
| 128 |
int cdns_init(struct cdns *cdns); |
| 129 |
int cdns_remove(struct cdns *cdns); |
| 130 |
|
| 131 |
#ifdef CONFIG_PM_SLEEP |
| 132 |
int cdns_resume(struct cdns *cdns); |
| 133 |
int cdns_suspend(struct cdns *cdns); |
| 134 |
void cdns_set_active(struct cdns *cdns, u8 set_active); |
| 135 |
#else |
| 136 |
static inline int cdns_resume(struct cdns *cdns) |
| 137 |
{ return 0; } |
| 138 |
static inline void cdns_set_active(struct cdns *cdns, u8 set_active) { } |
| 139 |
static inline int cdns_suspend(struct cdns *cdns) |
| 140 |
{ return 0; } |
| 141 |
#endif |
| 142 |
#endif |