This patch is useful for OMAP-L137 based boards which may have RMII enabled.

EMAC on OMAP-L137 supports RMII and on enabling this the RMIISPEED MASK has to
be set/cleared for 100/10 Mbps operation respectively. A member has been added
to the EMAC platform data to indicate the type of interface.

Signed-off-by: Chaithrika U S <[email protected]>
---
 arch/arm/mach-davinci/include/mach/emac.h |    1 +
 drivers/net/davinci_emac.c                |   10 +++++++++-
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-davinci/include/mach/emac.h 
b/arch/arm/mach-davinci/include/mach/emac.h
index 65eba9d..14303ef 100644
--- a/arch/arm/mach-davinci/include/mach/emac.h
+++ b/arch/arm/mach-davinci/include/mach/emac.h
@@ -20,6 +20,7 @@ struct emac_platform_data {
        u32 ctrl_ram_size;
        u32 phy_mask;
        u32 mdio_max_freq;
+       u8 rmii_en;
 };
 
 void davinci_init_emac(struct emac_platform_data *pdata);
diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c
index 829c6e2..7b46826 100644
--- a/drivers/net/davinci_emac.c
+++ b/drivers/net/davinci_emac.c
@@ -191,6 +191,7 @@ static const char emac_version_string[] = "TI DaVinci EMAC 
Linux v6.0";
 #define EMAC_MACCONTROL_GIGABITEN      (0x80)
 #define EMAC_MACCONTROL_GIGABITEN_SHIFT (7)
 #define EMAC_MACCONTROL_FULLDUPLEXEN   (0x1)
+#define EMAC_MACCONTROL_RMIISPEED_MASK BIT(15)
 
 /* GIGABIT MODE related bits */
 #define EMAC_DM646X_MACCONTORL_GMIIEN  (0x01 << 5)
@@ -490,6 +491,7 @@ struct emac_priv {
        u32 duplex; /* Link duplex: 1=Unknown, 2=Half, 3=Full */
        u32 rx_buf_size;
        u32 isr_count;
+       u8 rmii_en;
        struct net_device_stats net_dev_stats;
        u32 mac_hash1;
        u32 mac_hash2;
@@ -773,6 +775,11 @@ static void emac_update_phystatus(struct emac_priv *priv)
                /* Clear the GIG bit and GIGFORCE bit */
                mac_control &= ~(EMAC_DM646X_MACCONTORL_GIGFORCE |
                                        EMAC_DM646X_MACCONTORL_GIG);
+
+               if (priv->rmii_en && (priv->speed == SPEED_100))
+                       mac_control |= EMAC_MACCONTROL_RMIISPEED_MASK;
+               else
+                       mac_control &= ~EMAC_MACCONTROL_RMIISPEED_MASK;
        }
 
        /* Update mac_control if changed */
@@ -2653,9 +2660,10 @@ static int __devinit davinci_emac_probe(struct 
platform_device *pdev)
                return -ENODEV;
        }
 
-       /* MAC addr and PHY mask from platform_data */
+       /* MAC addr and PHY mask , RMII enable info from platform_data */
        memcpy(priv->mac_addr, pdata->mac_addr, 6);
        priv->phy_mask = pdata->phy_mask;
+       priv->rmii_en = pdata->rmii_en;
 
        /* Get EMAC platform data */
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-- 
1.5.6

_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to