14 #include <linux/module.h>
15 #include <linux/kernel.h>
25 #define DRIVER_NAME "mxs_phy"
27 #define HW_USBPHY_PWD 0x00
28 #define HW_USBPHY_CTRL 0x30
29 #define HW_USBPHY_CTRL_SET 0x34
30 #define HW_USBPHY_CTRL_CLR 0x38
32 #define BM_USBPHY_CTRL_SFTRST BIT(31)
33 #define BM_USBPHY_CTRL_CLKGATE BIT(30)
34 #define BM_USBPHY_CTRL_ENUTMILEVEL3 BIT(15)
35 #define BM_USBPHY_CTRL_ENUTMILEVEL2 BIT(14)
36 #define BM_USBPHY_CTRL_ENHOSTDISCONDETECT BIT(1)
42 #define MXY_PHY_ENHOSTDISCONDETECT_DELAY 250
50 #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
71 clk_prepare_enable(mxs_phy->
clk);
72 mxs_phy_hw_init(mxs_phy);
78 static void mxs_phy_shutdown(
struct usb_phy *
phy)
85 clk_disable_unprepare(mxs_phy->
clk);
88 static void mxs_phy_enhostdiscondetect_delay(
struct work_struct *
ws)
94 dev_dbg(mxs_phy->
phy.dev,
"Setting ENHOSTDISCONDETECT\n");
103 dev_dbg(phy->
dev,
"Connect on port %d\n", port);
105 mxs_phy_hw_init(mxs_phy);
111 dev_dbg(phy->
dev,
"Delaying setting ENHOSTDISCONDETECT\n");
113 mxs_phy_enhostdiscondetect_delay);
120 static int mxs_phy_on_disconnect(
struct usb_phy *phy,
int port)
122 dev_dbg(phy->
dev,
"Disconnect on port %d\n", port);
125 dev_dbg(phy->
dev,
"Clearing ENHOSTDISCONDETECT\n");
137 struct mxs_phy *mxs_phy;
141 dev_err(&pdev->
dev,
"can't get device resources\n");
152 "can't get the clock, err=%ld", PTR_ERR(clk));
158 dev_err(&pdev->
dev,
"Failed to allocate USB PHY structure!\n");
162 mxs_phy->
phy.io_priv = base;
163 mxs_phy->
phy.dev = &pdev->
dev;
165 mxs_phy->
phy.init = mxs_phy_init;
166 mxs_phy->
phy.shutdown = mxs_phy_shutdown;
167 mxs_phy->
phy.notify_connect = mxs_phy_on_connect;
168 mxs_phy->
phy.notify_disconnect = mxs_phy_on_disconnect;
174 platform_set_drvdata(pdev, &mxs_phy->
phy);
181 platform_set_drvdata(pdev,
NULL);
187 { .compatible =
"fsl,imx23-usbphy", },
193 .probe = mxs_phy_probe,
198 .of_match_table = mxs_phy_dt_ids,
202 static int __init mxs_phy_module_init(
void)
208 static void __exit mxs_phy_module_exit(
void)