blob: 0a2fa48a56ff1feaba84578edadf6a40fbdb8701 [file] [log] [blame]
Luigi 'Comio' Mantellini466827e2009-10-10 12:42:20 +02001This patch rewrites the miiphybb ( Bit-banged MII bus driver ) in order to
2support an arbitrary number of mii buses. This feature is useful when your
3board uses different mii buses for different phys and all (or a part) of these
4buses are implemented via bit-banging mode.
5
6The driver requires that the following macros should be defined into the board
7configuration file:
8
Wolfgang Denkd61fbcc2009-10-28 00:49:47 +01009CONFIG_BITBANGMII - Enable the miiphybb driver
Luigi 'Comio' Mantellini466827e2009-10-10 12:42:20 +020010CONFIG_BITBANGMII_MULTI - Enable the multi bus support
11
12If the CONFIG_BITBANGMII_MULTI is not defined, the board's config file needs
13to define at least the following macros:
14
15MII_INIT - Generic code to enable the MII bus (optional)
16MDIO_DECLARE - Declaration needed to access to the MDIO pin (optional)
17MDIO_ACTIVE - Activate the MDIO pin as out pin
18MDIO_TRISTATE - Activate the MDIO pin as input/tristate pin
19MDIO_READ - Read the MDIO pin
20MDIO(v) - Write v on the MDIO pin
21MDC_DECLARE - Declaration needed to access to the MDC pin (optional)
Wolfgang Denkd61fbcc2009-10-28 00:49:47 +010022MDC(v) - Write v on the MDC pin
Luigi 'Comio' Mantellini466827e2009-10-10 12:42:20 +020023
24The previous macros make the driver compatible with the previous version
25(that didn't support the multi-bus).
26
27When the CONFIG_BITBANGMII_MULTI is also defined, the board code needs to fill
28the bb_miiphy_buses[] array with a record for each required bus and declare
29the bb_miiphy_buses_num variable with the number of mii buses.
30The record (struct bb_miiphy_bus) has the following fields/callbacks (see
31miiphy.h for details):
32
Wolfgang Denkd61fbcc2009-10-28 00:49:47 +010033char name[] - The symbolic name that must be equal to the MII bus
34 registered name
35int (*init)() - Initialization function called at startup time (just
36 before the Ethernet initialization)
Luigi 'Comio' Mantellini466827e2009-10-10 12:42:20 +020037int (*mdio_active)() - Activate the MDIO pin as output
38int (*mdio_tristate)() - Activate the MDIO pin as input/tristate pin
39int (*set_mdio)() - Write the MDIO pin
40int (*get_mdio)() - Read the MDIO pin
41int (*set_mdc)() - Write the MDC pin
Wolfgang Denkd61fbcc2009-10-28 00:49:47 +010042int (*delay)() - Delay function
43void *priv - Private data used by board specific code
Luigi 'Comio' Mantellini466827e2009-10-10 12:42:20 +020044
45The board code will look like:
46
47struct bb_miiphy_bus bb_miiphy_buses[] = {
48 { .name = "miibus#1", .init = b1_init, .mdio_active = b1_mdio_active, ... },
49 { .name = "miibus#2", .init = b2_init, .mdio_active = b2_mdio_active, ... },
50 ...
51};
52int bb_miiphy_buses_num = sizeof(bb_miiphy_buses) /
Wolfgang Denkd61fbcc2009-10-28 00:49:47 +010053 sizeof(bb_miiphy_buses[0]);
Luigi 'Comio' Mantellini466827e2009-10-10 12:42:20 +020054
552009 Industrie Dial Face S.p.A.
56 Luigi 'Comio' Mantellini <luigi.mantellini@idf-hit.com>