Lines Matching +full:phy +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0+
3 * StarFive JH7110 USB 2.0 PHY driver
14 #include <linux/phy/phy.h>
23 struct phy *phy; member
27 enum phy_mode mode; member
30 static void usb2_set_ls_keepalive(struct jh7110_usb2_phy *phy, bool set) in usb2_set_ls_keepalive() argument
34 /* Host mode enable the LS speed keep-alive signal */ in usb2_set_ls_keepalive()
35 val = readl(phy->regs + USB_LS_KEEPALIVE_OFF); in usb2_set_ls_keepalive()
41 writel(val, phy->regs + USB_LS_KEEPALIVE_OFF); in usb2_set_ls_keepalive()
44 static int usb2_phy_set_mode(struct phy *_phy, in usb2_phy_set_mode()
45 enum phy_mode mode, int submode) in usb2_phy_set_mode() argument
47 struct jh7110_usb2_phy *phy = phy_get_drvdata(_phy); in usb2_phy_set_mode() local
49 switch (mode) { in usb2_phy_set_mode()
55 return -EINVAL; in usb2_phy_set_mode()
58 if (mode != phy->mode) { in usb2_phy_set_mode()
59 dev_dbg(&_phy->dev, "Changing phy to %d\n", mode); in usb2_phy_set_mode()
60 phy->mode = mode; in usb2_phy_set_mode()
61 usb2_set_ls_keepalive(phy, (mode != PHY_MODE_USB_DEVICE)); in usb2_phy_set_mode()
67 static int jh7110_usb2_phy_init(struct phy *_phy) in jh7110_usb2_phy_init()
69 struct jh7110_usb2_phy *phy = phy_get_drvdata(_phy); in jh7110_usb2_phy_init() local
72 ret = clk_set_rate(phy->usb_125m_clk, USB_125M_CLK_RATE); in jh7110_usb2_phy_init()
76 ret = clk_prepare_enable(phy->app_125m); in jh7110_usb2_phy_init()
83 static int jh7110_usb2_phy_exit(struct phy *_phy) in jh7110_usb2_phy_exit()
85 struct jh7110_usb2_phy *phy = phy_get_drvdata(_phy); in jh7110_usb2_phy_exit() local
87 clk_disable_unprepare(phy->app_125m); in jh7110_usb2_phy_exit()
101 struct jh7110_usb2_phy *phy; in jh7110_usb_phy_probe() local
102 struct device *dev = &pdev->dev; in jh7110_usb_phy_probe()
105 phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL); in jh7110_usb_phy_probe()
106 if (!phy) in jh7110_usb_phy_probe()
107 return -ENOMEM; in jh7110_usb_phy_probe()
109 phy->usb_125m_clk = devm_clk_get(dev, "125m"); in jh7110_usb_phy_probe()
110 if (IS_ERR(phy->usb_125m_clk)) in jh7110_usb_phy_probe()
111 return dev_err_probe(dev, PTR_ERR(phy->usb_125m_clk), in jh7110_usb_phy_probe()
114 phy->app_125m = devm_clk_get(dev, "app_125m"); in jh7110_usb_phy_probe()
115 if (IS_ERR(phy->app_125m)) in jh7110_usb_phy_probe()
116 return dev_err_probe(dev, PTR_ERR(phy->app_125m), in jh7110_usb_phy_probe()
119 phy->regs = devm_platform_ioremap_resource(pdev, 0); in jh7110_usb_phy_probe()
120 if (IS_ERR(phy->regs)) in jh7110_usb_phy_probe()
121 return dev_err_probe(dev, PTR_ERR(phy->regs), in jh7110_usb_phy_probe()
122 "Failed to map phy base\n"); in jh7110_usb_phy_probe()
124 phy->phy = devm_phy_create(dev, NULL, &jh7110_usb2_phy_ops); in jh7110_usb_phy_probe()
125 if (IS_ERR(phy->phy)) in jh7110_usb_phy_probe()
126 return dev_err_probe(dev, PTR_ERR(phy->phy), in jh7110_usb_phy_probe()
127 "Failed to create phy\n"); in jh7110_usb_phy_probe()
129 phy_set_drvdata(phy->phy, phy); in jh7110_usb_phy_probe()
136 { .compatible = "starfive,jh7110-usb-phy" },
145 .name = "jh7110-usb-phy",
150 MODULE_DESCRIPTION("StarFive JH7110 USB 2.0 PHY driver");