Lines Matching +full:mdio +full:- +full:parent +full:- +full:bus
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* Driver for MMIO-Mapped MDIO devices. Some IPs expose internal PHYs or PCS
3 * within the MMIO-mapped area
9 #include <linux/mdio.h>
16 #include <linux/mdio/mdio-regmap.h>
18 #define DRV_NAME "mdio-regmap"
25 static int mdio_regmap_read_c22(struct mii_bus *bus, int addr, int regnum) in mdio_regmap_read_c22() argument
27 struct mdio_regmap_priv *ctx = bus->priv; in mdio_regmap_read_c22()
31 if (ctx->valid_addr != addr) in mdio_regmap_read_c22()
32 return -ENODEV; in mdio_regmap_read_c22()
34 ret = regmap_read(ctx->regmap, regnum, &val); in mdio_regmap_read_c22()
41 static int mdio_regmap_write_c22(struct mii_bus *bus, int addr, int regnum, in mdio_regmap_write_c22() argument
44 struct mdio_regmap_priv *ctx = bus->priv; in mdio_regmap_write_c22()
46 if (ctx->valid_addr != addr) in mdio_regmap_write_c22()
47 return -ENODEV; in mdio_regmap_write_c22()
49 return regmap_write(ctx->regmap, regnum, val); in mdio_regmap_write_c22()
59 if (!config->parent) in devm_mdio_regmap_register()
60 return ERR_PTR(-EINVAL); in devm_mdio_regmap_register()
62 mii = devm_mdiobus_alloc_size(config->parent, sizeof(*mr)); in devm_mdio_regmap_register()
64 return ERR_PTR(-ENOMEM); in devm_mdio_regmap_register()
66 mr = mii->priv; in devm_mdio_regmap_register()
67 mr->regmap = config->regmap; in devm_mdio_regmap_register()
68 mr->valid_addr = config->valid_addr; in devm_mdio_regmap_register()
70 mii->name = DRV_NAME; in devm_mdio_regmap_register()
71 strscpy(mii->id, config->name, MII_BUS_ID_SIZE); in devm_mdio_regmap_register()
72 mii->parent = config->parent; in devm_mdio_regmap_register()
73 mii->read = mdio_regmap_read_c22; in devm_mdio_regmap_register()
74 mii->write = mdio_regmap_write_c22; in devm_mdio_regmap_register()
76 if (config->autoscan) in devm_mdio_regmap_register()
77 mii->phy_mask = ~BIT(config->valid_addr); in devm_mdio_regmap_register()
79 mii->phy_mask = ~0; in devm_mdio_regmap_register()
83 dev_err(config->parent, "Cannot register MDIO bus![%s] (%d)\n", mii->id, rc); in devm_mdio_regmap_register()
91 MODULE_DESCRIPTION("MDIO API over regmap");