Lines Matching +full:data +full:- +full:bus
1 // SPDX-License-Identifier: GPL-2.0-or-later
15 #define DRV_NAME "mdio-aspeed"
48 static int aspeed_mdio_op(struct mii_bus *bus, u8 st, u8 op, u8 phyad, u8 regad, in aspeed_mdio_op() argument
49 u16 data) in aspeed_mdio_op() argument
51 struct aspeed_mdio *ctx = bus->priv; in aspeed_mdio_op()
54 dev_dbg(&bus->dev, "%s: st: %u op: %u, phyad: %u, regad: %u, data: %u\n", in aspeed_mdio_op()
55 __func__, st, op, phyad, regad, data); in aspeed_mdio_op()
62 | FIELD_PREP(ASPEED_MDIO_DATA_MIIRDATA, data); in aspeed_mdio_op()
64 iowrite32(ctrl, ctx->base + ASPEED_MDIO_CTRL); in aspeed_mdio_op()
66 return readl_poll_timeout(ctx->base + ASPEED_MDIO_CTRL, ctrl, in aspeed_mdio_op()
72 static int aspeed_mdio_get_data(struct mii_bus *bus) in aspeed_mdio_get_data() argument
74 struct aspeed_mdio *ctx = bus->priv; in aspeed_mdio_get_data()
75 u32 data; in aspeed_mdio_get_data() local
78 rc = readl_poll_timeout(ctx->base + ASPEED_MDIO_DATA, data, in aspeed_mdio_get_data()
79 data & ASPEED_MDIO_DATA_IDLE, in aspeed_mdio_get_data()
85 return FIELD_GET(ASPEED_MDIO_DATA_MIIRDATA, data); in aspeed_mdio_get_data()
88 static int aspeed_mdio_read_c22(struct mii_bus *bus, int addr, int regnum) in aspeed_mdio_read_c22() argument
92 rc = aspeed_mdio_op(bus, ASPEED_MDIO_CTRL_ST_C22, MDIO_C22_OP_READ, in aspeed_mdio_read_c22()
97 return aspeed_mdio_get_data(bus); in aspeed_mdio_read_c22()
100 static int aspeed_mdio_write_c22(struct mii_bus *bus, int addr, int regnum, in aspeed_mdio_write_c22() argument
103 return aspeed_mdio_op(bus, ASPEED_MDIO_CTRL_ST_C22, MDIO_C22_OP_WRITE, in aspeed_mdio_write_c22()
107 static int aspeed_mdio_read_c45(struct mii_bus *bus, int addr, int devad, in aspeed_mdio_read_c45() argument
112 rc = aspeed_mdio_op(bus, ASPEED_MDIO_CTRL_ST_C45, MDIO_C45_OP_ADDR, in aspeed_mdio_read_c45()
117 rc = aspeed_mdio_op(bus, ASPEED_MDIO_CTRL_ST_C45, MDIO_C45_OP_READ, in aspeed_mdio_read_c45()
122 return aspeed_mdio_get_data(bus); in aspeed_mdio_read_c45()
125 static int aspeed_mdio_write_c45(struct mii_bus *bus, int addr, int devad, in aspeed_mdio_write_c45() argument
130 rc = aspeed_mdio_op(bus, ASPEED_MDIO_CTRL_ST_C45, MDIO_C45_OP_ADDR, in aspeed_mdio_write_c45()
135 return aspeed_mdio_op(bus, ASPEED_MDIO_CTRL_ST_C45, MDIO_C45_OP_WRITE, in aspeed_mdio_write_c45()
142 struct mii_bus *bus; in aspeed_mdio_probe() local
145 bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(*ctx)); in aspeed_mdio_probe()
146 if (!bus) in aspeed_mdio_probe()
147 return -ENOMEM; in aspeed_mdio_probe()
149 ctx = bus->priv; in aspeed_mdio_probe()
150 ctx->base = devm_platform_ioremap_resource(pdev, 0); in aspeed_mdio_probe()
151 if (IS_ERR(ctx->base)) in aspeed_mdio_probe()
152 return PTR_ERR(ctx->base); in aspeed_mdio_probe()
154 ctx->reset = devm_reset_control_get_optional_shared(&pdev->dev, NULL); in aspeed_mdio_probe()
155 if (IS_ERR(ctx->reset)) in aspeed_mdio_probe()
156 return PTR_ERR(ctx->reset); in aspeed_mdio_probe()
158 reset_control_deassert(ctx->reset); in aspeed_mdio_probe()
160 bus->name = DRV_NAME; in aspeed_mdio_probe()
161 snprintf(bus->id, MII_BUS_ID_SIZE, "%s%d", pdev->name, pdev->id); in aspeed_mdio_probe()
162 bus->parent = &pdev->dev; in aspeed_mdio_probe()
163 bus->read = aspeed_mdio_read_c22; in aspeed_mdio_probe()
164 bus->write = aspeed_mdio_write_c22; in aspeed_mdio_probe()
165 bus->read_c45 = aspeed_mdio_read_c45; in aspeed_mdio_probe()
166 bus->write_c45 = aspeed_mdio_write_c45; in aspeed_mdio_probe()
168 rc = of_mdiobus_register(bus, pdev->dev.of_node); in aspeed_mdio_probe()
170 dev_err(&pdev->dev, "Cannot register MDIO bus!\n"); in aspeed_mdio_probe()
171 reset_control_assert(ctx->reset); in aspeed_mdio_probe()
175 platform_set_drvdata(pdev, bus); in aspeed_mdio_probe()
182 struct mii_bus *bus = (struct mii_bus *)platform_get_drvdata(pdev); in aspeed_mdio_remove() local
183 struct aspeed_mdio *ctx = bus->priv; in aspeed_mdio_remove()
185 reset_control_assert(ctx->reset); in aspeed_mdio_remove()
186 mdiobus_unregister(bus); in aspeed_mdio_remove()
190 { .compatible = "aspeed,ast2600-mdio", },
208 MODULE_DESCRIPTION("ASPEED MDIO bus controller");