Lines Matching +full:gmii +full:- +full:to +full:- +full:rgmii

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * drivers/net/ethernet/ibm/emac/rgmii.c
5 * Driver for PowerPC 4xx on-chip ethernet controller, RGMII bridge support.
30 // XXX FIXME: Axon seems to support a subset of the RGMII, we
31 // thus need to take that into account and possibly change some
32 // of the bit settings below that don't seem to quite match the
49 /* RGMII bridge supports only GMII/TBI and RGMII/RTBI PHYs */
83 struct rgmii_regs __iomem *p = dev->base; in rgmii_attach()
87 /* Check if we need to attach to a RGMII */ in rgmii_attach()
90 ofdev->dev.of_node); in rgmii_attach()
91 return -ENODEV; in rgmii_attach()
94 mutex_lock(&dev->lock); in rgmii_attach()
97 out_be32(&p->fer, in_be32(&p->fer) | rgmii_mode_mask(mode, input)); in rgmii_attach()
100 ofdev->dev.of_node, input, phy_modes(mode)); in rgmii_attach()
102 ++dev->users; in rgmii_attach()
104 mutex_unlock(&dev->lock); in rgmii_attach()
112 struct rgmii_regs __iomem *p = dev->base; in rgmii_set_speed()
115 mutex_lock(&dev->lock); in rgmii_set_speed()
117 ssr = in_be32(&p->ssr) & ~RGMII_SSR_MASK(input); in rgmii_set_speed()
128 out_be32(&p->ssr, ssr); in rgmii_set_speed()
130 mutex_unlock(&dev->lock); in rgmii_set_speed()
136 struct rgmii_regs __iomem *p = dev->base; in rgmii_get_mdio()
141 if (!(dev->flags & EMAC_RGMII_FLAG_HAS_MDIO)) in rgmii_get_mdio()
144 mutex_lock(&dev->lock); in rgmii_get_mdio()
146 fer = in_be32(&p->fer); in rgmii_get_mdio()
148 out_be32(&p->fer, fer); in rgmii_get_mdio()
149 (void)in_be32(&p->fer); in rgmii_get_mdio()
157 struct rgmii_regs __iomem *p = dev->base; in rgmii_put_mdio()
162 if (!(dev->flags & EMAC_RGMII_FLAG_HAS_MDIO)) in rgmii_put_mdio()
165 fer = in_be32(&p->fer); in rgmii_put_mdio()
167 out_be32(&p->fer, fer); in rgmii_put_mdio()
168 (void)in_be32(&p->fer); in rgmii_put_mdio()
172 mutex_unlock(&dev->lock); in rgmii_put_mdio()
180 BUG_ON(!dev || dev->users == 0); in rgmii_detach()
181 p = dev->base; in rgmii_detach()
183 mutex_lock(&dev->lock); in rgmii_detach()
188 out_be32(&p->fer, in_be32(&p->fer) & ~RGMII_FER_MASK(input)); in rgmii_detach()
190 --dev->users; in rgmii_detach()
192 mutex_unlock(&dev->lock); in rgmii_detach()
207 hdr->version = 0; in rgmii_dump_regs()
208 hdr->index = 0; /* for now, are there chips with more than one in rgmii_dump_regs()
209 * rgmii ? if yes, then we'll add a cell_index in rgmii_dump_regs()
212 memcpy_fromio(regs, dev->base, sizeof(struct rgmii_regs)); in rgmii_dump_regs()
219 struct device_node *np = ofdev->dev.of_node; in rgmii_probe()
224 rc = -ENOMEM; in rgmii_probe()
229 mutex_init(&dev->lock); in rgmii_probe()
230 dev->ofdev = ofdev; in rgmii_probe()
232 rc = -ENXIO; in rgmii_probe()
238 rc = -ENOMEM; in rgmii_probe()
239 dev->base = (struct rgmii_regs __iomem *)ioremap(regs.start, in rgmii_probe()
241 if (dev->base == NULL) { in rgmii_probe()
246 /* Check for RGMII flags */ in rgmii_probe()
247 if (of_property_read_bool(ofdev->dev.of_node, "has-mdio")) in rgmii_probe()
248 dev->flags |= EMAC_RGMII_FLAG_HAS_MDIO; in rgmii_probe()
251 if (of_device_is_compatible(ofdev->dev.of_node, "ibm,rgmii-axon")) in rgmii_probe()
252 dev->flags |= EMAC_RGMII_FLAG_HAS_MDIO; in rgmii_probe()
255 in_be32(&dev->base->fer), in_be32(&dev->base->ssr)); in rgmii_probe()
258 out_be32(&dev->base->fer, 0); in rgmii_probe()
261 "RGMII %pOF initialized with%s MDIO support\n", in rgmii_probe()
262 ofdev->dev.of_node, in rgmii_probe()
263 (dev->flags & EMAC_RGMII_FLAG_HAS_MDIO) ? "" : "out"); in rgmii_probe()
280 WARN_ON(dev->users != 0); in rgmii_remove()
282 iounmap(dev->base); in rgmii_remove()
289 .compatible = "ibm,rgmii",
292 .type = "emac-rgmii",
299 .name = "emac-rgmii",