[mii] Add bit-bashing interface
[ipxe.git] / src / include / ipxe / mii_bit.h
1 #ifndef _IPXE_MII_BIT_H
2 #define _IPXE_MII_BIT_H
3
4 /** @file
5 *
6 * MII bit-bashing interface
7 *
8 */
9
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11
12 #include <ipxe/mii.h>
13 #include <ipxe/bitbash.h>
14
15 #define MII_BIT_START 0xffffffff /**< Start */
16 #define MII_BIT_START_MASK 0x80000000 /**< Start mask */
17
18 #define MII_BIT_CMD_MASK 0x00000008 /**< Command mask */
19 #define MII_BIT_CMD_READ 0x00000006 /**< Command read */
20 #define MII_BIT_CMD_WRITE 0x00000005 /**< Command write */
21 #define MII_BIT_CMD_RW 0x00000001 /**< Command read or write */
22
23 #define MII_BIT_PHY_MASK 0x00000010 /**< PHY mask */
24
25 #define MII_BIT_REG_MASK 0x00000010 /**< Register mask */
26
27 #define MII_BIT_SWITCH 0x00000002 /**< Switch */
28 #define MII_BIT_SWITCH_MASK 0x00000002 /**< Switch mask */
29
30 #define MII_BIT_DATA_MASK 0x00008000 /**< Data mask */
31
32 /** A bit-bashing MII interface */
33 struct mii_bit_basher {
34 /** MII interface */
35 struct mii_interface mdio;
36 /** Bit-bashing interface */
37 struct bit_basher basher;
38 };
39
40 /** Bit indices used for MII bit-bashing interface */
41 enum {
42 /** MII clock */
43 MII_BIT_MDC = 0,
44 /** MII data */
45 MII_BIT_MDIO,
46 /** MII data direction */
47 MII_BIT_DRIVE,
48 };
49
50 /** Delay between MDC transitions */
51 #define MII_BIT_UDELAY 1
52
53 extern void init_mii_bit_basher ( struct mii_bit_basher *miibit );
54
55 #endif /* _IPXE_MII_BIT_H */