]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-linux/u-boot.git/commitdiff
keystone2: remove has_mdio environment variable
authorVitaly Andrianov <vitalya@ti.com>
Thu, 3 Apr 2014 17:12:54 +0000 (13:12 -0400)
committerVitaly Andrianov <vitalya@ti.com>
Thu, 3 Apr 2014 17:12:54 +0000 (13:12 -0400)
There was a bug of using has_mdio environment variable. If that variable
set to "1" the keystone network drivers always uses mdio to configure a
port even if a particular port dosn't have a phy connected. Also depending
on the variable it incorrectly overrided sgmii_link_type.

This patch removes the has_mdio environment variable. Depending on
sgmii_link_type the keytone2_eth_open sets the local sys_has_mdio for the
currently opening port.

Signed-off-by: Vitaly Andrianov <vitalya@ti.com>
arch/arm/include/asm/arch-keystone/emac_defs.h
board/ti/k2hk_evm/board.c
board/ti/k2hk_evm/post.c
drivers/net/keystone_net.c

index 4fc0e6135cab40787fdccef54ceb064d43f2d3e1..12546946d937bd566216df84ac70b1837eb288b5 100644 (file)
@@ -373,6 +373,4 @@ typedef struct
        struct  eth_device *dev;
 } eth_priv_t;
 
-void keystone2_emac_set_has_mdio(int has_mdio);
-
 #endif  /* _EMAC_DEFS_H_ */
index 03d17ce53188b7cb699890dff684cbf6275150c4..86a3617ae1273ee5006d733f2f99d1233ee611a7 100644 (file)
@@ -159,29 +159,13 @@ int board_eth_init(bd_t *bis)
 {
        int     j;
        int     res;
-       int     has_mdio = 0; /* doesn't have mdio by default */
        int     link_type_name[32];
 
-       res = get_eth_env_param("has_mdio");
-       if (res >= 0)
-               has_mdio = res;
-
-       keystone2_emac_set_has_mdio(has_mdio);
-
        for (j = 0; j < get_num_eth_ports(); j++) {
                sprintf(link_type_name, "sgmii%d_link_type", j);
                res = get_eth_env_param(link_type_name);
-               if (res < 0) {
-                       /* setting default type */
-                       if (has_mdio == 1)
-                               eth_priv_cfg[j].sgmii_link_type =
-                                       SGMII_LINK_MAC_PHY;
-                       else
-                               eth_priv_cfg[j].sgmii_link_type =
-                                       SGMII_LINK_MAC_PHY_FORCED;
-               } else {
+               if (res >= 0)
                        eth_priv_cfg[j].sgmii_link_type = res;
-               }
 
                keystone2_emac_initialize(&eth_priv_cfg[j]);
        }
index 6dae2e11effba26ff9069aac404569b20df05324..134af34ab3abf322cb05d6611f5865b96e5b9b6a 100644 (file)
@@ -282,14 +282,15 @@ int post_emac_test(void)
        int port;
        int ret = 0;
 
-       if (0 == keystone2_emag_get_has_mdio()) {
-               printf("Board doesn't have MDIO - EMAC test skipped\n");
-               return 0;
-       }
-
        for (port = 0; port < get_num_eth_ports(); port++) {
                printf("POST EMAC TEST for port %d ... ", port);
                eth_priv = get_eth_priv_ptr(port);
+
+               if (eth_priv->sgmii_link_type != SGMII_LINK_MAC_PHY) {
+                       printf("Port doesn't have mdio - test skipped\n");
+                       continue;
+               }
+
                if (eth_priv == NULL) {
                        printf("ERROR: cannot get eth_priv\n");
                        ret = 1;
index 5128b47fe98c3de6d76923b2c0fca9b1c462b2eb..3a2064457bc92f55fbe14cbc3aa5cbf9acdfbf5c 100644 (file)
@@ -550,6 +550,9 @@ static int keystone2_eth_open(struct eth_device *dev, bd_t *bis)
 
        net_rx_buffs.rx_flow    = eth_priv->rx_flow;
 
+       sys_has_mdio =
+               (eth_priv->sgmii_link_type == SGMII_LINK_MAC_PHY) ? 1 : 0;
+
        psc_enable_module(KS2_LPSC_PA);
        psc_enable_module(KS2_LPSC_CPGMAC);
 
@@ -583,7 +586,6 @@ static int keystone2_eth_open(struct eth_device *dev, bd_t *bis)
         * If present this is usually defined to a series of register writes
         */
        hwConfigStreamingSwitch();
-
        if (sys_has_mdio) {
                /* Init MDIO & get link state */
                clkdiv = (EMAC_MDIO_BUS_FREQ / EMAC_MDIO_CLOCK_FREQ) - 1;
@@ -699,16 +701,6 @@ static int keystone2_eth_rcv_packet(struct eth_device *dev)
        return (pkt_size);
 }
 
-inline void keystone2_emac_set_has_mdio(int has_mdio)
-{
-       sys_has_mdio = has_mdio;
-}
-
-inline int keystone2_emag_get_has_mdio(void)
-{
-       return sys_has_mdio;
-}
-
 inline void keystone2_emac_set_loopback_test(int val)
 {
        loopback_test = val;
@@ -742,7 +734,8 @@ int keystone2_emac_initialize(eth_priv_t *eth_priv)
        eth_priv->dev           = dev;
        eth_register(dev);
 
-       if (sys_has_mdio && !phy_registered) {
+       if ((eth_priv->sgmii_link_type == SGMII_LINK_MAC_PHY) &&
+           !phy_registered) {
                phy_registered = 1;
 #ifdef CONFIG_ETH_PHY_MARVEL_88E1111
                sprintf(phy.name, "88E1111");