xref: /OK3568_Linux_fs/u-boot/doc/README.bitbangMII (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunThis patch rewrites the miiphybb ( Bit-banged MII bus driver ) in order to
2*4882a593Smuzhiyunsupport an arbitrary number of mii buses. This feature is useful when your
3*4882a593Smuzhiyunboard uses different mii buses for different phys and all (or a part) of these
4*4882a593Smuzhiyunbuses are implemented via bit-banging mode.
5*4882a593Smuzhiyun
6*4882a593SmuzhiyunThe driver requires that the following macros should be defined into the board
7*4882a593Smuzhiyunconfiguration file:
8*4882a593Smuzhiyun
9*4882a593SmuzhiyunCONFIG_BITBANGMII	- Enable the miiphybb driver
10*4882a593SmuzhiyunCONFIG_BITBANGMII_MULTI - Enable the multi bus support
11*4882a593Smuzhiyun
12*4882a593SmuzhiyunIf the CONFIG_BITBANGMII_MULTI is not defined, the board's config file needs
13*4882a593Smuzhiyunto define at least the following macros:
14*4882a593Smuzhiyun
15*4882a593SmuzhiyunMII_INIT      - Generic code to enable the MII bus (optional)
16*4882a593SmuzhiyunMDIO_DECLARE  - Declaration needed to access to the MDIO pin (optional)
17*4882a593SmuzhiyunMDIO_ACTIVE   - Activate the MDIO pin as out pin
18*4882a593SmuzhiyunMDIO_TRISTATE - Activate the MDIO pin as input/tristate pin
19*4882a593SmuzhiyunMDIO_READ     - Read the MDIO pin
20*4882a593SmuzhiyunMDIO(v)       - Write v on the MDIO pin
21*4882a593SmuzhiyunMDC_DECLARE   - Declaration needed to access to the MDC pin (optional)
22*4882a593SmuzhiyunMDC(v)	      - Write v on the MDC pin
23*4882a593Smuzhiyun
24*4882a593SmuzhiyunThe previous macros make the driver compatible with the previous version
25*4882a593Smuzhiyun(that didn't support the multi-bus).
26*4882a593Smuzhiyun
27*4882a593SmuzhiyunWhen the CONFIG_BITBANGMII_MULTI is also defined, the board code needs to fill
28*4882a593Smuzhiyunthe bb_miiphy_buses[] array with a record for each required bus and declare
29*4882a593Smuzhiyunthe bb_miiphy_buses_num variable with the number of mii buses.
30*4882a593SmuzhiyunThe record (struct bb_miiphy_bus) has the following fields/callbacks (see
31*4882a593Smuzhiyunmiiphy.h for details):
32*4882a593Smuzhiyun
33*4882a593Smuzhiyunchar name[]	       - The symbolic name that must be equal to the MII bus
34*4882a593Smuzhiyun			 registered name
35*4882a593Smuzhiyunint (*init)()	       - Initialization function called at startup time (just
36*4882a593Smuzhiyun			 before the Ethernet initialization)
37*4882a593Smuzhiyunint (*mdio_active)()   - Activate the MDIO pin as output
38*4882a593Smuzhiyunint (*mdio_tristate)() - Activate the MDIO pin as input/tristate pin
39*4882a593Smuzhiyunint (*set_mdio)()      - Write the MDIO pin
40*4882a593Smuzhiyunint (*get_mdio)()      - Read the MDIO pin
41*4882a593Smuzhiyunint (*set_mdc)()       - Write the MDC pin
42*4882a593Smuzhiyunint (*delay)()	       - Delay function
43*4882a593Smuzhiyunvoid *priv	       - Private data used by board specific code
44*4882a593Smuzhiyun
45*4882a593SmuzhiyunThe board code will look like:
46*4882a593Smuzhiyun
47*4882a593Smuzhiyunstruct bb_miiphy_bus bb_miiphy_buses[] = {
48*4882a593Smuzhiyun { .name = "miibus#1", .init = b1_init, .mdio_active = b1_mdio_active, ... },
49*4882a593Smuzhiyun { .name = "miibus#2", .init = b2_init, .mdio_active = b2_mdio_active, ... },
50*4882a593Smuzhiyun ...
51*4882a593Smuzhiyun};
52*4882a593Smuzhiyunint bb_miiphy_buses_num = sizeof(bb_miiphy_buses) /
53*4882a593Smuzhiyun			  sizeof(bb_miiphy_buses[0]);
54*4882a593Smuzhiyun
55*4882a593Smuzhiyun2009 Industrie Dial Face S.p.A.
56*4882a593Smuzhiyun     Luigi 'Comio' Mantellini <luigi.mantellini@idf-hit.com>
57