Lines Matching +full:pcie +full:- +full:phy
18 #include <linux/phy/phy.h>
34 * struct cygnus_pcie_phy - Cygnus PCIe PHY device
35 * @core: pointer to the Cygnus PCIe PHY core control
36 * @id: internal ID to identify the Cygnus PCIe PHY
37 * @phy: pointer to the kernel PHY device
42 struct phy *phy; member
46 * struct cygnus_pcie_phy_core - Cygnus PCIe PHY core control
50 * @phys: pointer to Cygnus PHY device
59 static int cygnus_pcie_power_config(struct cygnus_pcie_phy *phy, bool enable) in cygnus_pcie_power_config() argument
61 struct cygnus_pcie_phy_core *core = phy->core; in cygnus_pcie_power_config()
65 mutex_lock(&core->lock); in cygnus_pcie_power_config()
67 switch (phy->id) { in cygnus_pcie_power_config()
77 mutex_unlock(&core->lock); in cygnus_pcie_power_config()
78 dev_err(core->dev, "PCIe PHY %d invalid\n", phy->id); in cygnus_pcie_power_config()
79 return -EINVAL; in cygnus_pcie_power_config()
83 val = readl(core->base + PCIE_CFG_OFFSET); in cygnus_pcie_power_config()
85 writel(val, core->base + PCIE_CFG_OFFSET); in cygnus_pcie_power_config()
87 * Wait 50 ms for the PCIe Serdes to stabilize after the analog in cygnus_pcie_power_config()
92 val = readl(core->base + PCIE_CFG_OFFSET); in cygnus_pcie_power_config()
94 writel(val, core->base + PCIE_CFG_OFFSET); in cygnus_pcie_power_config()
97 mutex_unlock(&core->lock); in cygnus_pcie_power_config()
98 dev_dbg(core->dev, "PCIe PHY %d %s\n", phy->id, in cygnus_pcie_power_config()
103 static int cygnus_pcie_phy_power_on(struct phy *p) in cygnus_pcie_phy_power_on()
105 struct cygnus_pcie_phy *phy = phy_get_drvdata(p); in cygnus_pcie_phy_power_on() local
107 return cygnus_pcie_power_config(phy, true); in cygnus_pcie_phy_power_on()
110 static int cygnus_pcie_phy_power_off(struct phy *p) in cygnus_pcie_phy_power_off()
112 struct cygnus_pcie_phy *phy = phy_get_drvdata(p); in cygnus_pcie_phy_power_off() local
114 return cygnus_pcie_power_config(phy, false); in cygnus_pcie_phy_power_off()
125 struct device *dev = &pdev->dev; in cygnus_pcie_phy_probe()
126 struct device_node *node = dev->of_node, *child; in cygnus_pcie_phy_probe()
134 dev_err(dev, "PHY no child node\n"); in cygnus_pcie_phy_probe()
135 return -ENODEV; in cygnus_pcie_phy_probe()
140 return -ENOMEM; in cygnus_pcie_phy_probe()
142 core->dev = dev; in cygnus_pcie_phy_probe()
145 core->base = devm_ioremap_resource(dev, res); in cygnus_pcie_phy_probe()
146 if (IS_ERR(core->base)) in cygnus_pcie_phy_probe()
147 return PTR_ERR(core->base); in cygnus_pcie_phy_probe()
149 mutex_init(&core->lock); in cygnus_pcie_phy_probe()
158 ret = -EINVAL; in cygnus_pcie_phy_probe()
163 dev_err(dev, "invalid PHY id: %u\n", id); in cygnus_pcie_phy_probe()
164 ret = -EINVAL; in cygnus_pcie_phy_probe()
168 if (core->phys[id].phy) { in cygnus_pcie_phy_probe()
169 dev_err(dev, "duplicated PHY id: %u\n", id); in cygnus_pcie_phy_probe()
170 ret = -EINVAL; in cygnus_pcie_phy_probe()
174 p = &core->phys[id]; in cygnus_pcie_phy_probe()
175 p->phy = devm_phy_create(dev, child, &cygnus_pcie_phy_ops); in cygnus_pcie_phy_probe()
176 if (IS_ERR(p->phy)) { in cygnus_pcie_phy_probe()
177 dev_err(dev, "failed to create PHY\n"); in cygnus_pcie_phy_probe()
178 ret = PTR_ERR(p->phy); in cygnus_pcie_phy_probe()
182 p->core = core; in cygnus_pcie_phy_probe()
183 p->id = id; in cygnus_pcie_phy_probe()
184 phy_set_drvdata(p->phy, p); in cygnus_pcie_phy_probe()
192 dev_err(dev, "failed to register PHY provider\n"); in cygnus_pcie_phy_probe()
196 dev_dbg(dev, "registered %u PCIe PHY(s)\n", cnt); in cygnus_pcie_phy_probe()
205 { .compatible = "brcm,cygnus-pcie-phy" },
212 .name = "cygnus-pcie-phy",
220 MODULE_DESCRIPTION("Broadcom Cygnus PCIe PHY driver");