Update the miiphybb documentation to match current implementation. The static struct bb_miiphy_bus bb_miiphy_buses[] array is removed. The example is updated to match current Renesas RAVB driver, which is one of the miiphybb users.
Reviewed-by: Paul Barker <paul.barker...@bp.renesas.com> Signed-off-by: Marek Vasut <marek.vasut+rene...@mailbox.org> --- Cc: Jim Liu <jim.t90...@gmail.com> Cc: Joe Hershberger <joe.hershber...@ni.com> Cc: Mario Six <mario....@gdsys.cc> Cc: Michael Chang <zhang971090...@gmail.com> Cc: Nobuhiro Iwamatsu <iwama...@nigauri.org> Cc: Parvathi Bhogaraju <pbhogar...@microsoft.com> Cc: Paul Barker <paul.barker...@bp.renesas.com> Cc: Ramon Fried <rfried....@gmail.com> Cc: Tom Rini <tr...@konsulko.com> Cc: u-boot@lists.denx.de --- V2: - Fix language bugs - Add RB from Paul --- doc/README.bitbangMII | 66 ++++++++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 19 deletions(-) diff --git a/doc/README.bitbangMII b/doc/README.bitbangMII index 05ab20376f3..78b4ef880cb 100644 --- a/doc/README.bitbangMII +++ b/doc/README.bitbangMII @@ -1,39 +1,67 @@ -This patch rewrites the miiphybb ( Bit-banged MII bus driver ) in order to -support an arbitrary number of mii buses. This feature is useful when your -board uses different mii buses for different phys and all (or a part) of these -buses are implemented via bit-banging mode. +The miiphybb ( Bit-banged MII bus driver ) supports an arbitrary number of +MII buses. This feature is useful when a driver uses different MII buses for +different PHYs and all (or a part) of these buses are implemented via +bit-banging mode. The driver requires that the following macros should be defined into the board configuration file: CONFIG_BITBANGMII - Enable the miiphybb driver -The board code needs to fill the bb_miiphy_buses[] array with a record for -each required bus and declare the bb_miiphy_buses_num variable with the -number of mii buses. The record (struct bb_miiphy_bus) has the following +The driver code needs to allocate a regular MDIO device using mdio_alloc() +and assign .read and .write accessors which wrap bb_miiphy_read() and +bb_miiphy_write() functions respectively. The bb_miiphy_read() and +bb_miiphy_write() functions take a pointer to a callback structure, +struct bb_miiphy_bus_ops. The struct bb_miiphy_bus_ops has the following fields/callbacks (see miiphy.h for details): -char name[] - The symbolic name that must be equal to the MII bus - registered name -int (*init)() - Initialization function called at startup time (just - before the Ethernet initialization) int (*mdio_active)() - Activate the MDIO pin as output int (*mdio_tristate)() - Activate the MDIO pin as input/tristate pin int (*set_mdio)() - Write the MDIO pin int (*get_mdio)() - Read the MDIO pin int (*set_mdc)() - Write the MDC pin int (*delay)() - Delay function -void *priv - Private data used by board specific code -The board code will look like: +The driver code will look like: -struct bb_miiphy_bus bb_miiphy_buses[] = { - { .name = "miibus#1", .init = b1_init, .mdio_active = b1_mdio_active, ... }, - { .name = "miibus#2", .init = b2_init, .mdio_active = b2_mdio_active, ... }, - ... +static const struct bb_miiphy_bus_ops ravb_bb_miiphy_bus_ops = { + .mdio_active = ravb_bb_mdio_active, + .mdio_tristate = ravb_bb_mdio_tristate, + .set_mdio = ravb_bb_set_mdio, + .get_mdio = ravb_bb_get_mdio, + .set_mdc = ravb_bb_set_mdc, + .delay = ravb_bb_delay, }; -int bb_miiphy_buses_num = sizeof(bb_miiphy_buses) / - sizeof(bb_miiphy_buses[0]); + +static int ravb_bb_miiphy_read(struct mii_dev *miidev, int addr, + int devad, int reg) +{ + return bb_miiphy_read(miidev, &ravb_bb_miiphy_bus_ops, + addr, devad, reg); +} + +static int ravb_bb_miiphy_write(struct mii_dev *miidev, int addr, + int devad, int reg, u16 value) +{ + return bb_miiphy_write(miidev, &ravb_bb_miiphy_bus_ops, + addr, devad, reg, value); +} + +static int ravb_probe(struct udevice *dev) +{ + struct mii_dev *mdiodev; +... + mdiodev = mdio_alloc(); + if (!mdiodev) + return -ENOMEM; + + mdiodev->read = ravb_bb_miiphy_read; + mdiodev->write = ravb_bb_miiphy_write; + mdiodev->priv = eth; + snprintf(mdiodev->name, sizeof(mdiodev->name), dev->name); + + ret = mdio_register(mdiodev); +... 2009 Industrie Dial Face S.p.A. Luigi 'Comio' Mantellini <luigi.mantell...@idf-hit.com> -- 2.47.2