Lines Matching +full:4 +full:- +full:lane
1 // SPDX-License-Identifier: GPL-2.0
47 struct a38x_comphy_lane lane[MAX_A38X_COMPHY]; member
52 { 4, 5, 0 },
53 { 0, 4, 0 },
54 { 0, 0, 4 },
59 static void a38x_set_conf(struct a38x_comphy_lane *lane, bool enable) in a38x_set_conf() argument
61 struct a38x_comphy *priv = lane->priv; in a38x_set_conf()
64 if (priv->conf) { in a38x_set_conf()
65 conf = readl_relaxed(priv->conf); in a38x_set_conf()
67 conf |= BIT(lane->port); in a38x_set_conf()
69 conf &= ~BIT(lane->port); in a38x_set_conf()
70 writel(conf, priv->conf); in a38x_set_conf()
74 static void a38x_comphy_set_reg(struct a38x_comphy_lane *lane, in a38x_comphy_set_reg() argument
79 val = readl_relaxed(lane->base + offset) & ~mask; in a38x_comphy_set_reg()
80 writel(val | value, lane->base + offset); in a38x_comphy_set_reg()
83 static void a38x_comphy_set_speed(struct a38x_comphy_lane *lane, in a38x_comphy_set_speed() argument
86 a38x_comphy_set_reg(lane, COMPHY_CFG1, in a38x_comphy_set_speed()
92 static int a38x_comphy_poll(struct a38x_comphy_lane *lane, in a38x_comphy_poll() argument
98 ret = readl_relaxed_poll_timeout_atomic(lane->base + offset, val, in a38x_comphy_poll()
103 dev_err(lane->priv->dev, in a38x_comphy_poll()
104 "comphy%u: timed out waiting for status\n", lane->n); in a38x_comphy_poll()
115 struct a38x_comphy_lane *lane = phy_get_drvdata(phy); in a38x_comphy_set_mode() local
120 return -EINVAL; in a38x_comphy_set_mode()
133 return -EINVAL; in a38x_comphy_set_mode()
136 a38x_set_conf(lane, false); in a38x_comphy_set_mode()
138 a38x_comphy_set_speed(lane, gen, gen); in a38x_comphy_set_mode()
140 ret = a38x_comphy_poll(lane, COMPHY_STAT1, in a38x_comphy_set_mode()
147 a38x_set_conf(lane, true); in a38x_comphy_set_mode()
160 struct a38x_comphy_lane *lane; in a38x_comphy_xlate() local
164 if (WARN_ON(args->args[0] >= MAX_A38X_PORTS)) in a38x_comphy_xlate()
165 return ERR_PTR(-EINVAL); in a38x_comphy_xlate()
171 lane = phy_get_drvdata(phy); in a38x_comphy_xlate()
172 if (lane->port >= 0) in a38x_comphy_xlate()
173 return ERR_PTR(-EBUSY); in a38x_comphy_xlate()
175 lane->port = args->args[0]; in a38x_comphy_xlate()
177 val = readl_relaxed(lane->priv->base + COMPHY_SELECTOR); in a38x_comphy_xlate()
178 val = (val >> (4 * lane->n)) & 0xf; in a38x_comphy_xlate()
180 if (!gbe_mux[lane->n][lane->port] || in a38x_comphy_xlate()
181 val != gbe_mux[lane->n][lane->port]) { in a38x_comphy_xlate()
182 dev_warn(lane->priv->dev, in a38x_comphy_xlate()
183 "comphy%u: not configured for GBE\n", lane->n); in a38x_comphy_xlate()
184 phy = ERR_PTR(-EINVAL); in a38x_comphy_xlate()
198 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in a38x_comphy_probe()
200 return -ENOMEM; in a38x_comphy_probe()
206 priv->dev = &pdev->dev; in a38x_comphy_probe()
207 priv->base = base; in a38x_comphy_probe()
212 priv->conf = devm_ioremap_resource(&pdev->dev, res); in a38x_comphy_probe()
213 if (IS_ERR(priv->conf)) in a38x_comphy_probe()
214 return PTR_ERR(priv->conf); in a38x_comphy_probe()
217 for_each_available_child_of_node(pdev->dev.of_node, child) { in a38x_comphy_probe()
224 dev_err(&pdev->dev, "missing 'reg' property (%d)\n", in a38x_comphy_probe()
229 if (val >= MAX_A38X_COMPHY || priv->lane[val].base) { in a38x_comphy_probe()
230 dev_err(&pdev->dev, "invalid 'reg' property\n"); in a38x_comphy_probe()
234 phy = devm_phy_create(&pdev->dev, child, &a38x_comphy_ops); in a38x_comphy_probe()
240 priv->lane[val].base = base + 0x28 * val; in a38x_comphy_probe()
241 priv->lane[val].priv = priv; in a38x_comphy_probe()
242 priv->lane[val].n = val; in a38x_comphy_probe()
243 priv->lane[val].port = -1; in a38x_comphy_probe()
244 phy_set_drvdata(phy, &priv->lane[val]); in a38x_comphy_probe()
247 dev_set_drvdata(&pdev->dev, priv); in a38x_comphy_probe()
249 provider = devm_of_phy_provider_register(&pdev->dev, a38x_comphy_xlate); in a38x_comphy_probe()
255 { .compatible = "marvell,armada-380-comphy" },
263 .name = "armada-38x-comphy",