Lines Matching +full:gpio +full:- +full:ctrl

1 // SPDX-License-Identifier: GPL-2.0-only
20 #include <linux/mdio-bitbang.h>
28 struct mdiobb_ctrl ctrl; member
35 /* FIXME: If any other users of GPIO crop up, then these will have to
38 * bind the ports to a GPIO driver, and have this be a client of it.
55 static inline void mdio_dir(struct mdiobb_ctrl *ctrl, int dir) in mdio_dir() argument
57 struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl); in mdio_dir()
60 bb_set(bitbang->dir, bitbang->mdio_msk); in mdio_dir()
62 bb_clr(bitbang->dir, bitbang->mdio_msk); in mdio_dir()
65 in_be32(bitbang->dir); in mdio_dir()
68 static inline int mdio_read(struct mdiobb_ctrl *ctrl) in mdio_read() argument
70 struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl); in mdio_read()
71 return bb_read(bitbang->dat, bitbang->mdio_msk); in mdio_read()
74 static inline void mdio(struct mdiobb_ctrl *ctrl, int what) in mdio() argument
76 struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl); in mdio()
79 bb_set(bitbang->dat, bitbang->mdio_msk); in mdio()
81 bb_clr(bitbang->dat, bitbang->mdio_msk); in mdio()
84 in_be32(bitbang->dat); in mdio()
87 static inline void mdc(struct mdiobb_ctrl *ctrl, int what) in mdc() argument
89 struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl); in mdc()
92 bb_set(bitbang->dat, bitbang->mdc_msk); in mdc()
94 bb_clr(bitbang->dat, bitbang->mdc_msk); in mdc()
97 in_be32(bitbang->dat); in mdc()
113 struct bb_info *bitbang = bus->priv; in fs_mii_bitbang_init()
120 return -ENODEV; in fs_mii_bitbang_init()
126 snprintf(bus->id, MII_BUS_ID_SIZE, "%x", res.start); in fs_mii_bitbang_init()
128 data = of_get_property(np, "fsl,mdio-pin", &len); in fs_mii_bitbang_init()
130 return -ENODEV; in fs_mii_bitbang_init()
133 data = of_get_property(np, "fsl,mdc-pin", &len); in fs_mii_bitbang_init()
135 return -ENODEV; in fs_mii_bitbang_init()
138 bitbang->dir = ioremap(res.start, resource_size(&res)); in fs_mii_bitbang_init()
139 if (!bitbang->dir) in fs_mii_bitbang_init()
140 return -ENOMEM; in fs_mii_bitbang_init()
142 bitbang->dat = bitbang->dir + 4; in fs_mii_bitbang_init()
143 bitbang->mdio_msk = 1 << (31 - mdio_pin); in fs_mii_bitbang_init()
144 bitbang->mdc_msk = 1 << (31 - mdc_pin); in fs_mii_bitbang_init()
153 int ret = -ENOMEM; in fs_enet_mdio_probe()
159 bitbang->ctrl.ops = &bb_ops; in fs_enet_mdio_probe()
161 new_bus = alloc_mdio_bitbang(&bitbang->ctrl); in fs_enet_mdio_probe()
165 new_bus->name = "CPM2 Bitbanged MII", in fs_enet_mdio_probe()
167 ret = fs_mii_bitbang_init(new_bus, ofdev->dev.of_node); in fs_enet_mdio_probe()
171 new_bus->phy_mask = ~0; in fs_enet_mdio_probe()
173 new_bus->parent = &ofdev->dev; in fs_enet_mdio_probe()
176 ret = of_mdiobus_register(new_bus, ofdev->dev.of_node); in fs_enet_mdio_probe()
183 iounmap(bitbang->dir); in fs_enet_mdio_probe()
195 struct bb_info *bitbang = bus->priv; in fs_enet_mdio_remove()
199 iounmap(bitbang->dir); in fs_enet_mdio_remove()
205 .compatible = "fsl,cpm2-mdio-bitbang",
213 .name = "fsl-bb-mdio",