/* Read an off-chip register in a PHY through the MDC/MDIO port */ static int bfin_mdiobus_read(struct mii_bus *bus, int phy_addr, int regnum) { bfin_mdio_poll(); /* read mode */ bfin_write_EMAC_STAADD(SET_PHYAD((u16) phy_addr) | SET_REGAD((u16) regnum) | STABUSY); bfin_mdio_poll(); return (int) bfin_read_EMAC_STADAT(); }
static void bfin_mac_enable(void) { u32 opmode; pr_debug("%s: %s\n", DRV_NAME, __func__); bfin_write_DMA1_NEXT_DESC_PTR(&(rx_list_head->desc_a)); bfin_write_DMA1_CONFIG(rx_list_head->desc_a.config); bfin_mdio_poll(); opmode = bfin_read_EMAC_OPMODE(); if (opmode & FDMODE) opmode |= PSF; else opmode |= DRO | DC | PSF; opmode |= RE; #if defined(CONFIG_BFIN_MAC_RMII) opmode |= RMII; #if (defined(CONFIG_BF537) || defined(CONFIG_BF536)) && CONFIG_BF_REV_0_2 opmode |= TE; #endif #endif bfin_write_EMAC_OPMODE(opmode); }
/* Write an off-chip register in a PHY through the MDC/MDIO port */ static int bfin_mdiobus_write(struct mii_bus *bus, int phy_addr, int regnum, u16 value) { bfin_mdio_poll(); bfin_write_EMAC_STADAT((u32) value); /* write mode */ bfin_write_EMAC_STAADD(SET_PHYAD((u16) phy_addr) | SET_REGAD((u16) regnum) | STAOP | STABUSY); bfin_mdio_poll(); return 0; }
static int bfin_mac_enable(void) { int ret; u32 opmode; pr_debug("%s: %s\n", DRV_NAME, __func__); /* Set RX DMA */ bfin_write_DMA1_NEXT_DESC_PTR(&(rx_list_head->desc_a)); bfin_write_DMA1_CONFIG(rx_list_head->desc_a.config); /* Wait MII done */ ret = bfin_mdio_poll(); if (ret) return ret; /* We enable only RX here */ /* ASTP : Enable Automatic Pad Stripping PR : Promiscuous Mode for test PSF : Receive frames with total length less than 64 bytes. FDMODE : Full Duplex Mode LB : Internal Loopback for test RE : Receiver Enable */ opmode = bfin_read_EMAC_OPMODE(); if (opmode & FDMODE) opmode |= PSF; else opmode |= DRO | DC | PSF; opmode |= RE; #if defined(CONFIG_BFIN_MAC_RMII) opmode |= RMII; /* For Now only 100MBit are supported */ #if (defined(CONFIG_BF537) || defined(CONFIG_BF536)) && CONFIG_BF_REV_0_2 opmode |= TE; #endif #endif /* Turn on the EMAC rx */ bfin_write_EMAC_OPMODE(opmode); return 0; }