Commit a8487489 authored by Boris BREZILLON's avatar Boris BREZILLON Committed by David S. Miller

net: macb: remove #if defined(CONFIG_ARCH_AT91) sections

With multi platform support those sections could lead to unexpected
behavior if both ARCH_AT91 and another ARM SoC using the MACB IP are
selected.
Add two new capabilities to encode the default MII mode and the presence
of a CLKEN bit in USRIO register.
Then define the appropriate config for IPs embedded in at91 SoCs.
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
Reviewed-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9c348d45
...@@ -2131,6 +2131,10 @@ static const struct net_device_ops macb_netdev_ops = { ...@@ -2131,6 +2131,10 @@ static const struct net_device_ops macb_netdev_ops = {
}; };
#if defined(CONFIG_OF) #if defined(CONFIG_OF)
static struct macb_config at91sam9260_config = {
.caps = MACB_CAPS_USRIO_HAS_CLKEN | MACB_CAPS_USRIO_DEFAULT_IS_MII,
};
static struct macb_config pc302gem_config = { static struct macb_config pc302gem_config = {
.caps = MACB_CAPS_SG_DISABLED | MACB_CAPS_GIGABIT_MODE_AVAILABLE, .caps = MACB_CAPS_SG_DISABLED | MACB_CAPS_GIGABIT_MODE_AVAILABLE,
.dma_burst_length = 16, .dma_burst_length = 16,
...@@ -2148,7 +2152,7 @@ static struct macb_config sama5d4_config = { ...@@ -2148,7 +2152,7 @@ static struct macb_config sama5d4_config = {
static const struct of_device_id macb_dt_ids[] = { static const struct of_device_id macb_dt_ids[] = {
{ .compatible = "cdns,at32ap7000-macb" }, { .compatible = "cdns,at32ap7000-macb" },
{ .compatible = "cdns,at91sam9260-macb" }, { .compatible = "cdns,at91sam9260-macb", .data = &at91sam9260_config },
{ .compatible = "cdns,macb" }, { .compatible = "cdns,macb" },
{ .compatible = "cdns,pc302-gem", .data = &pc302gem_config }, { .compatible = "cdns,pc302-gem", .data = &pc302gem_config },
{ .compatible = "cdns,gem", .data = &pc302gem_config }, { .compatible = "cdns,gem", .data = &pc302gem_config },
...@@ -2408,21 +2412,19 @@ static int macb_probe(struct platform_device *pdev) ...@@ -2408,21 +2412,19 @@ static int macb_probe(struct platform_device *pdev)
bp->phy_interface = err; bp->phy_interface = err;
} }
config = 0;
if (bp->phy_interface == PHY_INTERFACE_MODE_RGMII) if (bp->phy_interface == PHY_INTERFACE_MODE_RGMII)
macb_or_gem_writel(bp, USRIO, GEM_BIT(RGMII)); config = GEM_BIT(RGMII);
else if (bp->phy_interface == PHY_INTERFACE_MODE_RMII) else if (bp->phy_interface == PHY_INTERFACE_MODE_RMII &&
#if defined(CONFIG_ARCH_AT91) (bp->caps & MACB_CAPS_USRIO_DEFAULT_IS_MII))
macb_or_gem_writel(bp, USRIO, (MACB_BIT(RMII) | config = MACB_BIT(RMII);
MACB_BIT(CLKEN))); else if (!(bp->caps & MACB_CAPS_USRIO_DEFAULT_IS_MII))
#else config = MACB_BIT(MII);
macb_or_gem_writel(bp, USRIO, 0);
#endif if (bp->caps & MACB_CAPS_USRIO_HAS_CLKEN)
else config |= MACB_BIT(CLKEN);
#if defined(CONFIG_ARCH_AT91)
macb_or_gem_writel(bp, USRIO, MACB_BIT(CLKEN)); macb_or_gem_writel(bp, USRIO, config);
#else
macb_or_gem_writel(bp, USRIO, MACB_BIT(MII));
#endif
err = register_netdev(dev); err = register_netdev(dev);
if (err) { if (err) {
......
...@@ -391,6 +391,8 @@ ...@@ -391,6 +391,8 @@
/* Capability mask bits */ /* Capability mask bits */
#define MACB_CAPS_ISR_CLEAR_ON_WRITE 0x00000001 #define MACB_CAPS_ISR_CLEAR_ON_WRITE 0x00000001
#define MACB_CAPS_USRIO_HAS_CLKEN 0x00000002
#define MACB_CAPS_USRIO_DEFAULT_IS_MII 0x00000004
#define MACB_CAPS_FIFO_MODE 0x10000000 #define MACB_CAPS_FIFO_MODE 0x10000000
#define MACB_CAPS_GIGABIT_MODE_AVAILABLE 0x20000000 #define MACB_CAPS_GIGABIT_MODE_AVAILABLE 0x20000000
#define MACB_CAPS_SG_DISABLED 0x40000000 #define MACB_CAPS_SG_DISABLED 0x40000000
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment