Lines Matching +full:pcie +full:- +full:phy +full:- +full:0
1 // SPDX-License-Identifier: GPL-2.0-only
8 #include <linux/phy/phy.h>
11 #define PCIE_CFG_OFFSET 0x00
16 CYGNUS_PHY_PCIE0 = 0,
24 * struct cygnus_pcie_phy - Cygnus PCIe PHY device
25 * @core: pointer to the Cygnus PCIe PHY core control
26 * @id: internal ID to identify the Cygnus PCIe PHY
27 * @phy: pointer to the kernel PHY device
32 struct phy *phy; member
36 * struct cygnus_pcie_phy_core - Cygnus PCIe PHY core control
40 * @phys: pointer to Cygnus PHY device
49 static int cygnus_pcie_power_config(struct cygnus_pcie_phy *phy, bool enable) in cygnus_pcie_power_config() argument
51 struct cygnus_pcie_phy_core *core = phy->core; in cygnus_pcie_power_config()
55 mutex_lock(&core->lock); in cygnus_pcie_power_config()
57 switch (phy->id) { in cygnus_pcie_power_config()
67 mutex_unlock(&core->lock); in cygnus_pcie_power_config()
68 dev_err(core->dev, "PCIe PHY %d invalid\n", phy->id); in cygnus_pcie_power_config()
69 return -EINVAL; in cygnus_pcie_power_config()
73 val = readl(core->base + PCIE_CFG_OFFSET); in cygnus_pcie_power_config()
75 writel(val, core->base + PCIE_CFG_OFFSET); in cygnus_pcie_power_config()
77 * Wait 50 ms for the PCIe Serdes to stabilize after the analog in cygnus_pcie_power_config()
82 val = readl(core->base + PCIE_CFG_OFFSET); in cygnus_pcie_power_config()
84 writel(val, core->base + PCIE_CFG_OFFSET); in cygnus_pcie_power_config()
87 mutex_unlock(&core->lock); in cygnus_pcie_power_config()
88 dev_dbg(core->dev, "PCIe PHY %d %s\n", phy->id, in cygnus_pcie_power_config()
90 return 0; in cygnus_pcie_power_config()
93 static int cygnus_pcie_phy_power_on(struct phy *p) in cygnus_pcie_phy_power_on()
95 struct cygnus_pcie_phy *phy = phy_get_drvdata(p); in cygnus_pcie_phy_power_on() local
97 return cygnus_pcie_power_config(phy, true); in cygnus_pcie_phy_power_on()
100 static int cygnus_pcie_phy_power_off(struct phy *p) in cygnus_pcie_phy_power_off()
102 struct cygnus_pcie_phy *phy = phy_get_drvdata(p); in cygnus_pcie_phy_power_off() local
104 return cygnus_pcie_power_config(phy, false); in cygnus_pcie_phy_power_off()
115 struct device *dev = &pdev->dev; in cygnus_pcie_phy_probe()
116 struct device_node *node = dev->of_node; in cygnus_pcie_phy_probe()
119 unsigned cnt = 0; in cygnus_pcie_phy_probe()
121 if (of_get_child_count(node) == 0) { in cygnus_pcie_phy_probe()
122 dev_err(dev, "PHY no child node\n"); in cygnus_pcie_phy_probe()
123 return -ENODEV; in cygnus_pcie_phy_probe()
128 return -ENOMEM; in cygnus_pcie_phy_probe()
130 core->dev = dev; in cygnus_pcie_phy_probe()
132 core->base = devm_platform_ioremap_resource(pdev, 0); in cygnus_pcie_phy_probe()
133 if (IS_ERR(core->base)) in cygnus_pcie_phy_probe()
134 return PTR_ERR(core->base); in cygnus_pcie_phy_probe()
136 mutex_init(&core->lock); in cygnus_pcie_phy_probe()
145 return -EINVAL; in cygnus_pcie_phy_probe()
149 dev_err(dev, "invalid PHY id: %u\n", id); in cygnus_pcie_phy_probe()
150 return -EINVAL; in cygnus_pcie_phy_probe()
153 if (core->phys[id].phy) { in cygnus_pcie_phy_probe()
154 dev_err(dev, "duplicated PHY id: %u\n", id); in cygnus_pcie_phy_probe()
155 return -EINVAL; in cygnus_pcie_phy_probe()
158 p = &core->phys[id]; in cygnus_pcie_phy_probe()
159 p->phy = devm_phy_create(dev, child, &cygnus_pcie_phy_ops); in cygnus_pcie_phy_probe()
160 if (IS_ERR(p->phy)) { in cygnus_pcie_phy_probe()
161 dev_err(dev, "failed to create PHY\n"); in cygnus_pcie_phy_probe()
162 return PTR_ERR(p->phy); in cygnus_pcie_phy_probe()
165 p->core = core; in cygnus_pcie_phy_probe()
166 p->id = id; in cygnus_pcie_phy_probe()
167 phy_set_drvdata(p->phy, p); in cygnus_pcie_phy_probe()
175 dev_err(dev, "failed to register PHY provider\n"); in cygnus_pcie_phy_probe()
179 dev_dbg(dev, "registered %u PCIe PHY(s)\n", cnt); in cygnus_pcie_phy_probe()
181 return 0; in cygnus_pcie_phy_probe()
185 { .compatible = "brcm,cygnus-pcie-phy" },
192 .name = "cygnus-pcie-phy",
200 MODULE_DESCRIPTION("Broadcom Cygnus PCIe PHY driver");