Lines Matching +full:input +full:- +full:mode

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Driver for PowerPC 4xx on-chip ethernet controller, RGMII bridge support.
57 static inline u32 rgmii_mode_mask(int mode, int input) in rgmii_mode_mask() argument
59 switch (mode) { in rgmii_mode_mask()
64 return RGMII_FER_RGMII(input); in rgmii_mode_mask()
66 return RGMII_FER_TBI(input); in rgmii_mode_mask()
68 return RGMII_FER_GMII(input); in rgmii_mode_mask()
70 return RGMII_FER_MII(input); in rgmii_mode_mask()
72 return RGMII_FER_RTBI(input); in rgmii_mode_mask()
78 int rgmii_attach(struct platform_device *ofdev, int input, int mode) in rgmii_attach() argument
81 struct rgmii_regs __iomem *p = dev->base; in rgmii_attach()
83 RGMII_DBG(dev, "attach(%d)" NL, input); in rgmii_attach()
86 if (input < 0 || !rgmii_valid_mode(mode)) { in rgmii_attach()
88 ofdev->dev.of_node); in rgmii_attach()
89 return -ENODEV; in rgmii_attach()
92 mutex_lock(&dev->lock); in rgmii_attach()
94 /* Enable this input */ in rgmii_attach()
95 out_be32(&p->fer, in_be32(&p->fer) | rgmii_mode_mask(mode, input)); in rgmii_attach()
97 printk(KERN_NOTICE "%pOF: input %d in %s mode\n", in rgmii_attach()
98 ofdev->dev.of_node, input, phy_modes(mode)); in rgmii_attach()
100 ++dev->users; in rgmii_attach()
102 mutex_unlock(&dev->lock); in rgmii_attach()
107 void rgmii_set_speed(struct platform_device *ofdev, int input, int speed) in rgmii_set_speed() argument
110 struct rgmii_regs __iomem *p = dev->base; in rgmii_set_speed()
113 mutex_lock(&dev->lock); in rgmii_set_speed()
115 ssr = in_be32(&p->ssr) & ~RGMII_SSR_MASK(input); in rgmii_set_speed()
117 RGMII_DBG(dev, "speed(%d, %d)" NL, input, speed); in rgmii_set_speed()
120 ssr |= RGMII_SSR_1000(input); in rgmii_set_speed()
122 ssr |= RGMII_SSR_100(input); in rgmii_set_speed()
124 ssr |= RGMII_SSR_10(input); in rgmii_set_speed()
126 out_be32(&p->ssr, ssr); in rgmii_set_speed()
128 mutex_unlock(&dev->lock); in rgmii_set_speed()
131 void rgmii_get_mdio(struct platform_device *ofdev, int input) in rgmii_get_mdio() argument
134 struct rgmii_regs __iomem *p = dev->base; in rgmii_get_mdio()
137 RGMII_DBG2(dev, "get_mdio(%d)" NL, input); in rgmii_get_mdio()
139 if (!(dev->flags & EMAC_RGMII_FLAG_HAS_MDIO)) in rgmii_get_mdio()
142 mutex_lock(&dev->lock); in rgmii_get_mdio()
144 fer = in_be32(&p->fer); in rgmii_get_mdio()
145 fer |= 0x00080000u >> input; in rgmii_get_mdio()
146 out_be32(&p->fer, fer); in rgmii_get_mdio()
147 (void)in_be32(&p->fer); in rgmii_get_mdio()
152 void rgmii_put_mdio(struct platform_device *ofdev, int input) in rgmii_put_mdio() argument
155 struct rgmii_regs __iomem *p = dev->base; in rgmii_put_mdio()
158 RGMII_DBG2(dev, "put_mdio(%d)" NL, input); in rgmii_put_mdio()
160 if (!(dev->flags & EMAC_RGMII_FLAG_HAS_MDIO)) in rgmii_put_mdio()
163 fer = in_be32(&p->fer); in rgmii_put_mdio()
164 fer &= ~(0x00080000u >> input); in rgmii_put_mdio()
165 out_be32(&p->fer, fer); in rgmii_put_mdio()
166 (void)in_be32(&p->fer); in rgmii_put_mdio()
170 mutex_unlock(&dev->lock); in rgmii_put_mdio()
173 void rgmii_detach(struct platform_device *ofdev, int input) in rgmii_detach() argument
178 BUG_ON(!dev || dev->users == 0); in rgmii_detach()
179 p = dev->base; in rgmii_detach()
181 mutex_lock(&dev->lock); in rgmii_detach()
183 RGMII_DBG(dev, "detach(%d)" NL, input); in rgmii_detach()
185 /* Disable this input */ in rgmii_detach()
186 out_be32(&p->fer, in_be32(&p->fer) & ~RGMII_FER_MASK(input)); in rgmii_detach()
188 --dev->users; in rgmii_detach()
190 mutex_unlock(&dev->lock); in rgmii_detach()
205 hdr->version = 0; in rgmii_dump_regs()
206 hdr->index = 0; /* for now, are there chips with more than one in rgmii_dump_regs()
210 memcpy_fromio(regs, dev->base, sizeof(struct rgmii_regs)); in rgmii_dump_regs()
217 struct device_node *np = ofdev->dev.of_node; in rgmii_probe()
222 rc = -ENOMEM; in rgmii_probe()
227 mutex_init(&dev->lock); in rgmii_probe()
228 dev->ofdev = ofdev; in rgmii_probe()
230 rc = -ENXIO; in rgmii_probe()
236 rc = -ENOMEM; in rgmii_probe()
237 dev->base = (struct rgmii_regs __iomem *)ioremap(regs.start, in rgmii_probe()
239 if (dev->base == NULL) { in rgmii_probe()
245 if (of_get_property(ofdev->dev.of_node, "has-mdio", NULL)) in rgmii_probe()
246 dev->flags |= EMAC_RGMII_FLAG_HAS_MDIO; in rgmii_probe()
249 if (of_device_is_compatible(ofdev->dev.of_node, "ibm,rgmii-axon")) in rgmii_probe()
250 dev->flags |= EMAC_RGMII_FLAG_HAS_MDIO; in rgmii_probe()
253 in_be32(&dev->base->fer), in_be32(&dev->base->ssr)); in rgmii_probe()
256 out_be32(&dev->base->fer, 0); in rgmii_probe()
260 ofdev->dev.of_node, in rgmii_probe()
261 (dev->flags & EMAC_RGMII_FLAG_HAS_MDIO) ? "" : "out"); in rgmii_probe()
278 WARN_ON(dev->users != 0); in rgmii_remove()
280 iounmap(dev->base); in rgmii_remove()
292 .type = "emac-rgmii",
299 .name = "emac-rgmii",