~ubuntu-branches/ubuntu/saucy/linux-ti-omap4/saucy-proposed

« back to all changes in this revision

Viewing changes to drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c

  • Committer: Package Import Robot
  • Author(s): Paolo Pisati, Paolo Pisati, Stefan Bader, Upstream Kernel Changes
  • Date: 2012-08-15 17:17:43 UTC
  • Revision ID: package-import@ubuntu.com-20120815171743-h5wnuf51xe7pvdid
Tags: 3.5.0-207.13
[ Paolo Pisati ]

* Start new release

[ Stefan Bader ]

* (config) Enable getabis to use local package copies

[ Upstream Kernel Changes ]

* fixup: gargabe collect iva_seq[0|1] init
* [Config] enable all SND_OMAP_SOC_*s
* fixup: cm2xxx_3xxx.o is needed for omap2_cm_read|write_reg
* fixup: add some snd_soc_dai* helper functions
* fixup: s/snd_soc_dpcm_params/snd_soc_dpcm/g
* fixup: typo, no_host_mode and useless SDP4430 init
* fixup: enable again aess hwmod

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#define MII_BUSY 0x00000001
35
35
#define MII_WRITE 0x00000002
36
36
 
 
37
static int stmmac_mdio_busy_wait(void __iomem *ioaddr, unsigned int mii_addr)
 
38
{
 
39
        unsigned long curr;
 
40
        unsigned long finish = jiffies + 3 * HZ;
 
41
 
 
42
        do {
 
43
                curr = jiffies;
 
44
                if (readl(ioaddr + mii_addr) & MII_BUSY)
 
45
                        cpu_relax();
 
46
                else
 
47
                        return 0;
 
48
        } while (!time_after_eq(curr, finish));
 
49
 
 
50
        return -EBUSY;
 
51
}
 
52
 
37
53
/**
38
54
 * stmmac_mdio_read
39
55
 * @bus: points to the mii_bus structure
54
70
        int data;
55
71
        u16 regValue = (((phyaddr << 11) & (0x0000F800)) |
56
72
                        ((phyreg << 6) & (0x000007C0)));
57
 
        regValue |= MII_BUSY | ((priv->plat->clk_csr & 7) << 2);
58
 
 
59
 
        do {} while (((readl(priv->ioaddr + mii_address)) & MII_BUSY) == 1);
 
73
        regValue |= MII_BUSY | ((priv->clk_csr & 0xF) << 2);
 
74
 
 
75
        if (stmmac_mdio_busy_wait(priv->ioaddr, mii_address))
 
76
                return -EBUSY;
 
77
 
60
78
        writel(regValue, priv->ioaddr + mii_address);
61
 
        do {} while (((readl(priv->ioaddr + mii_address)) & MII_BUSY) == 1);
 
79
 
 
80
        if (stmmac_mdio_busy_wait(priv->ioaddr, mii_address))
 
81
                return -EBUSY;
62
82
 
63
83
        /* Read the data from the MII data register */
64
84
        data = (int)readl(priv->ioaddr + mii_data);
86
106
            (((phyaddr << 11) & (0x0000F800)) | ((phyreg << 6) & (0x000007C0)))
87
107
            | MII_WRITE;
88
108
 
89
 
        value |= MII_BUSY | ((priv->plat->clk_csr & 7) << 2);
90
 
 
 
109
        value |= MII_BUSY | ((priv->clk_csr & 0xF) << 2);
91
110
 
92
111
        /* Wait until any existing MII operation is complete */
93
 
        do {} while (((readl(priv->ioaddr + mii_address)) & MII_BUSY) == 1);
 
112
        if (stmmac_mdio_busy_wait(priv->ioaddr, mii_address))
 
113
                return -EBUSY;
94
114
 
95
115
        /* Set the MII address register to write */
96
116
        writel(phydata, priv->ioaddr + mii_data);
97
117
        writel(value, priv->ioaddr + mii_address);
98
118
 
99
119
        /* Wait until any existing MII operation is complete */
100
 
        do {} while (((readl(priv->ioaddr + mii_address)) & MII_BUSY) == 1);
101
 
 
102
 
        return 0;
 
120
        return stmmac_mdio_busy_wait(priv->ioaddr, mii_address);
103
121
}
104
122
 
105
123
/**