From 77abcb25e92165e2f0b2cd0c24897ce63a0d97b9 Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Wed, 3 Feb 2016 17:44:11 +0100 Subject: [PATCH] inmates: e1000-demo: Hard-wire PHY address All known e1000-compatible cards have their PHYs at address 1. Searching for them does not work reliably, so simply hard-wire the address. Signed-off-by: Jan Kiszka --- inmates/demos/x86/e1000-demo.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/inmates/demos/x86/e1000-demo.c b/inmates/demos/x86/e1000-demo.c index 7273f36..6aaa102 100644 --- a/inmates/demos/x86/e1000-demo.c +++ b/inmates/demos/x86/e1000-demo.c @@ -40,7 +40,7 @@ # define E1000_EERD_DATA_SHIFT 16 #define E1000_REG_MDIC 0x0020 # define E1000_MDIC_REGADD_SHFT 16 -# define E1000_MDIC_PHYADD_SHFT 21 +# define E1000_MDIC_PHYADD (0x1 << 21) # define E1000_MDIC_OP_WRITE (0x1 << 26) # define E1000_MDIC_OP_READ (0x2 << 26) # define E1000_MDIC_READY (0x1 << 28) @@ -72,12 +72,8 @@ #define E1000_REG_RAH 0x5404 # define E1000_RAH_AV (1 << 31) -#define E1000_MAX_PHYADD 7 - #define E1000_PHY_CTRL 0 # define E1000_PHYC_POWER_DOWN (1 << 11) -#define E1000_PHY_PSTATUS 1 -#define E1000_PHY_ID1 2 struct eth_header { u8 dst[6]; @@ -140,7 +136,6 @@ static struct e1000_rxd rx_ring[RX_DESCRIPTORS] __attribute__((aligned(128))); static struct e1000_txd tx_ring[TX_DESCRIPTORS] __attribute__((aligned(128))); static unsigned int rx_idx, tx_idx; static struct eth_header tx_packet; -static unsigned int phyadd; static u16 phy_read(unsigned int reg) { @@ -148,7 +143,7 @@ static u16 phy_read(unsigned int reg) mmio_write32(mmiobar + E1000_REG_MDIC, (reg << E1000_MDIC_REGADD_SHFT) | - (phyadd << E1000_MDIC_PHYADD_SHFT) | E1000_MDIC_OP_READ); + E1000_MDIC_PHYADD | E1000_MDIC_OP_READ); do { val = mmio_read32(mmiobar + E1000_REG_MDIC); cpu_relax(); @@ -161,7 +156,7 @@ static void phy_write(unsigned int reg, u16 val) { mmio_write32(mmiobar + E1000_REG_MDIC, val | (reg << E1000_MDIC_REGADD_SHFT) | - (phyadd << E1000_MDIC_PHYADD_SHFT) | E1000_MDIC_OP_WRITE); + E1000_MDIC_PHYADD | E1000_MDIC_OP_WRITE); while (!(mmio_read32(mmiobar + E1000_REG_MDIC) & E1000_MDIC_READY)) cpu_relax(); } @@ -245,10 +240,6 @@ void inmate_main(void) val |= E1000_CTRL_ASDE | E1000_CTRL_SLU; mmio_write32(mmiobar + E1000_REG_CTRL, val); - for (phyadd = 0; phyadd <= E1000_MAX_PHYADD; phyadd++) - if (phy_read(E1000_PHY_ID1) != 0) - break; - printk("PHY address: %d\n", phyadd); /* power up again in case the previous user turned it off */ phy_write(E1000_PHY_CTRL, phy_read(E1000_PHY_CTRL) & ~E1000_PHYC_POWER_DOWN); -- 2.39.2