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