[U-Boot] DP83849 phy driver support

Ravi Shekhar Ravi.Shekhar at Lntemsys.com
Mon Feb 14 07:36:18 CET 2011


Hi,

I am trying to write support for the DP83849 phy driver in the u-boot. My 
development environment is based on MPC8313E powerpc controller.

I have add following in the tsec.c driver

struct phy_info phy_info_dp83849 = {
        0x20005ca,
        "NatSemi DP83849",
        4,
        (struct phy_cmd[]){     /* config */
                        /* Reset and configure the PHY */
                        {MIIM_CR, MIIM_CR_RST, NULL/*mii_cr_init*/},
                        {MIIM_DP83849_ANAR, 0x000001e1, NULL},
                        {MIIM_CR, miim_read, mii_cr_init},
                        {MIIM_DP83849_PSR, miim_read, 
&mii_parse_dp83849_psr},
                        },
        (struct phy_cmd[]){     /* startup */
                        /* Status is read once to clear old link state */
                        {MIIM_STATUS, miim_read, NULL},
                        /* Auto-negotiate */
                        {MIIM_DP83849_MICR, 0x0002, NULL},
                        {MIIM_DP83849_MISR, 0x003c, NULL},
                        /* Read the link and auto-neg status */
                        {MIIM_DP83849_PSR, 
miim_read,&mii_parse_dp83849_psr},
                        {miim_end,}
                        },
        (struct phy_cmd[]){     /* shutdown - disable interrupts */
                        {MIIM_DP83849_MICR, 0x0000, NULL},
                        {MIIM_DP83849_MISR, 0x0000, NULL},
                        {miim_end,}
                           },
};


uint mii_parse_dp83849_psr(uint mii_reg, struct tsec_private *priv)
{
        uint mii_status = read_phy_reg(priv, MIIM_STATUS);
        printf("mii_status is 0x%4x\n", mii_status);
        if (!(mii_status & MIIM_STATUS_AN_DONE))
        {
                puts("auto-negotiation not complete\n");
                int i = 0;

                /* in case of timeout ->link is cleared */
                priv->link = 1;
                puts("Waiting for PHY realtime link");
                while (!(mii_status & MIIM_STATUS_AN_DONE))
                {
                        /* Timeout reached ? */
                        if (i > PHY_AUTONEGOTIATE_TIMEOUT)
                        {
                                puts(" TIMEOUT !\n");
                                priv->link = 0;
                                break;
                        }

                        if ((i++ % 1000) == 0) {
                                putc('.');
                        }
                        udelay(1000);   /* 1 ms */
                        mii_reg = read_phy_reg(priv, MIIM_DP83849_PSR);
                }
                puts(" done\n");
                udelay(500000); /* another 500 ms (results in faster 
booting) */
        }
        else
        {
                puts("auto-negotiation completed, testing link now...");
                mii_status = read_phy_reg(priv, MIIM_STATUS);
                printf("\nmii_status is 0x%4x\n", mii_status);
                if (mii_status & MIIM_STATUS_LINK)
                {
                        puts("Valid link is established\n");
                        priv->link = 1;
                }
                else
                {
                        priv->link = 0;
                        puts("Link not established\n");
                }
        }
        if(priv->link)
        {
                printf("\nbmsr is : 0x%4x\n", mii_status);
                printf("\npsr is: 0x%4x\n", mii_reg);
                if(mii_reg & MIIM_DP83849_SPD_MASK)
                        priv->speed = 10;
                else
                        priv->speed = 100;

                if (mii_reg & MIIM_DP83849_DPX_MASK)
                        priv->duplexity = 1;
                else
                        priv->duplexity = 0;
        }

        return 0;
}


When I boot up the board. the Link, Speed and ACK LED glows bot when I try 
to ping it does not responds. I tried debugging and figure out that the 
Interrupts are not being acknowledged. The register dump is as follows:

mii read 0 0x0
1000
mii read 0 0x1
786D
mii read 0 0x2
2000
mii read 0 0x3
5CA2
mii read 0 0x4
01E1
mii read 0 0x5
45E1
mii read 0 0x6
0005
mii read 0 0x7
2801
mii read 0 0x8
0000
mii read 0 0x9
0000
mii read 0 0x10
0695
mii read 0 0x11
0002
mii read 0 0x12
2C3C
mii read 0 0x13
0000
mii read 0 0x14
0000
mii read 0 0x15
0000
mii read 0 0x16
0100
mii read 0 0x17
0001
mii read 0 0x18
0000
mii read 0 0x19
8020
mii read 0 0x1a
0804
mii read 0 0x1b
0000
mii read 0 0x1c
0000
mii read 0 0x1d
6011


Please, help me in understanding where I am wrong and why the interrupts 
are not getting ackgd.

Thanks and Regards,

Ravi Shekhar Singh
Software Engineer
ravi.shekhar at lntemsys.com 
Mobile:- 9620793761 


More information about the U-Boot mailing list