Skip to content

Commit

Permalink
net: mvneta: Convert to driver model
Browse files Browse the repository at this point in the history
Update this driver to support driver model. As all MVEBU boards using
this driver are converted with this patch, the non-driver-model code
can be removed completely. This is also the reason why this patch
is quite big and includes a) the driver change and b) the
platform change. As its not git-bisect save otherwise.

With this conversion, some parameters are now extracted from the
DT instread of using the config header defines. The supported
properties right now are:

PHY-mode ("phy-mode") and PHY-address ("reg").

The base addresses for the ethernet controllers can be removed from
the header files as well.

Please note that this patch also removes the E1000 network driver
from some MVEBU config headers. This is necessary, as with DM_ETH
configured and the e1000 driver enabled, the PCI driver also needs
to support DM. But the MVEBU PCI(e) driver still needs to get
ported to DM. When this is done, the E1000 driver can be enabled
again.

Signed-off-by: Stefan Roese <[email protected]>
Cc: Luka Perkov <[email protected]>
Cc: Dirk Eibach <[email protected]>
Cc: Joe Hershberger <[email protected]>
Cc: Simon Glass <[email protected]>
  • Loading branch information
stroese committed Jan 14, 2016
1 parent 202eded commit e3b9c98
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 167 deletions.
1 change: 1 addition & 0 deletions arch/arm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ config ARCH_MVEBU
select OF_CONTROL
select OF_SEPARATE
select DM
select DM_ETH
select DM_SERIAL
select DM_SPI
select DM_SPI_FLASH
Expand Down
24 changes: 0 additions & 24 deletions arch/arm/mach-mvebu/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,30 +326,6 @@ int arch_misc_init(void)
}
#endif /* CONFIG_ARCH_MISC_INIT */

#ifdef CONFIG_MVNETA
int cpu_eth_init(bd_t *bis)
{
u32 enet_base[] = { MVEBU_EGIGA0_BASE, MVEBU_EGIGA1_BASE,
MVEBU_EGIGA2_BASE, MVEBU_EGIGA3_BASE };
u8 phy_addr[] = CONFIG_PHY_ADDR;
int i;

/*
* Only Armada XP supports all 4 ethernet interfaces. A38x has
* slightly different base addresses for its 2-3 interfaces.
*/
if (mvebu_soc_family() != MVEBU_SOC_AXP) {
enet_base[1] = MVEBU_EGIGA2_BASE;
enet_base[2] = MVEBU_EGIGA3_BASE;
}

for (i = 0; i < ARRAY_SIZE(phy_addr); i++)
mvneta_initialize(bis, enet_base[i], i, phy_addr[i]);

return 0;
}
#endif

#ifdef CONFIG_MV_SDHCI
int board_mmc_init(bd_t *bis)
{
Expand Down
4 changes: 0 additions & 4 deletions arch/arm/mach-mvebu/include/mach/soc.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,9 @@
#define MVEBU_CPU_WIN_BASE (MVEBU_REGISTER(0x20000))
#define MVEBU_SDRAM_BASE (MVEBU_REGISTER(0x20180))
#define MVEBU_TIMER_BASE (MVEBU_REGISTER(0x20300))
#define MVEBU_EGIGA2_BASE (MVEBU_REGISTER(0x30000))
#define MVEBU_EGIGA3_BASE (MVEBU_REGISTER(0x34000))
#define MVEBU_REG_PCIE_BASE (MVEBU_REGISTER(0x40000))
#define MVEBU_AXP_USB_BASE (MVEBU_REGISTER(0x50000))
#define MVEBU_USB20_BASE (MVEBU_REGISTER(0x58000))
#define MVEBU_EGIGA0_BASE (MVEBU_REGISTER(0x70000))
#define MVEBU_EGIGA1_BASE (MVEBU_REGISTER(0x74000))
#define MVEBU_AXP_SATA_BASE (MVEBU_REGISTER(0xa0000))
#define MVEBU_SATA0_BASE (MVEBU_REGISTER(0xa8000))
#define MVEBU_NAND_BASE (MVEBU_REGISTER(0xd0000))
Expand Down
32 changes: 12 additions & 20 deletions board/Marvell/db-mv784mp-gp/db-mv784mp-gp.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,40 +87,32 @@ int board_eth_init(bd_t *bis)
return pci_eth_init(bis);
}

#ifdef CONFIG_RESET_PHY_R
/* Configure and enable MV88E1545 PHY */
void reset_phy(void)
int board_phy_config(struct phy_device *phydev)
{
u8 phy_addr[] = CONFIG_PHY_ADDR;
u16 devadr = phy_addr[0];
char *name = "neta0";
u16 reg;

if (miiphy_set_current_dev(name))
return;

/* Enable QSGMII AN */
/* Set page to 4 */
miiphy_write(name, devadr, 0x16, 4);
phy_write(phydev, MDIO_DEVAD_NONE, 0x16, 4);
/* Enable AN */
miiphy_write(name, devadr, 0x0, 0x1140);
phy_write(phydev, MDIO_DEVAD_NONE, 0x0, 0x1140);
/* Set page to 0 */
miiphy_write(name, devadr, 0x16, 0);
phy_write(phydev, MDIO_DEVAD_NONE, 0x16, 0);

/* Phy C_ANEG */
miiphy_read(name, devadr, 0x4, &reg);
reg = phy_read(phydev, MDIO_DEVAD_NONE, 0x4);
reg |= 0x1E0;
miiphy_write(name, devadr, 0x4, reg);
phy_write(phydev, MDIO_DEVAD_NONE, 0x4, reg);

/* Soft-Reset */
miiphy_write(name, devadr, 22, 0x0000);
miiphy_write(name, devadr, 0, 0x9140);
phy_write(phydev, MDIO_DEVAD_NONE, 22, 0x0000);
phy_write(phydev, MDIO_DEVAD_NONE, 0, 0x9140);

/* Power up the phy */
miiphy_read(name, devadr, ETH_PHY_CTRL_REG, &reg);
reg = phy_read(phydev, MDIO_DEVAD_NONE, ETH_PHY_CTRL_REG);
reg &= ~(ETH_PHY_CTRL_POWER_DOWN_MASK);
miiphy_write(name, devadr, ETH_PHY_CTRL_REG, reg);
phy_write(phydev, MDIO_DEVAD_NONE, ETH_PHY_CTRL_REG, reg);

printf("88E1545 Initialized on %s\n", name);
printf("88E1545 Initialized\n");
return 0;
}
#endif /* CONFIG_RESET_PHY_R */
20 changes: 9 additions & 11 deletions board/maxbcm/maxbcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,15 @@ int checkboard(void)
return 0;
}

#ifdef CONFIG_RESET_PHY_R
/* Configure and enable MV88E6185 switch */
void reset_phy(void)
int board_phy_config(struct phy_device *phydev)
{
char *name = "neta0";

if (miiphy_set_current_dev(name))
return;

/* todo: fill this with the real setup / config code */

printf("88E6185 Initialized on %s\n", name);
/*
* todo:
* Fill this with the real setup / config code.
* Please see board/Marvell/db-mv784mp-gp/db-mv784mp-gp.c
* for details.
*/
printf("88E6185 Initialized\n");
return 0;
}
#endif /* CONFIG_RESET_PHY_R */
Loading

0 comments on commit e3b9c98

Please sign in to comment.