diff options
author | Baruch Siach <baruch@tkos.co.il> | 2010-05-24 03:36:13 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-05-24 03:36:13 -0400 |
commit | 5eb32bd059379530fc3809a7fcf183feca75f601 (patch) | |
tree | 66b1cc6d4cbd57287efbb63eb23bca341fe94e8b /drivers | |
parent | 8286274284e15b11b0f531b6ceeef21fbe00a8dd (diff) |
fec: add support for PHY interface platform data
The i.MX25 PDK uses RMII to communicate with its PHY. This patch adds
the ability to configure RMII, based on platform data.
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Acked-by: Greg Ungerer <gerg@uclinux.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/fec.c | 22 | ||||
-rw-r--r-- | drivers/net/fec.h | 2 |
2 files changed, 24 insertions, 0 deletions
diff --git a/drivers/net/fec.c b/drivers/net/fec.c index 42d9ac9ba39..326465ffbb2 100644 --- a/drivers/net/fec.c +++ b/drivers/net/fec.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <linux/clk.h> | 41 | #include <linux/clk.h> |
42 | #include <linux/platform_device.h> | 42 | #include <linux/platform_device.h> |
43 | #include <linux/phy.h> | 43 | #include <linux/phy.h> |
44 | #include <linux/fec.h> | ||
44 | 45 | ||
45 | #include <asm/cacheflush.h> | 46 | #include <asm/cacheflush.h> |
46 | 47 | ||
@@ -182,6 +183,7 @@ struct fec_enet_private { | |||
182 | struct phy_device *phy_dev; | 183 | struct phy_device *phy_dev; |
183 | int mii_timeout; | 184 | int mii_timeout; |
184 | uint phy_speed; | 185 | uint phy_speed; |
186 | phy_interface_t phy_interface; | ||
185 | int index; | 187 | int index; |
186 | int link; | 188 | int link; |
187 | int full_duplex; | 189 | int full_duplex; |
@@ -1191,6 +1193,21 @@ fec_restart(struct net_device *dev, int duplex) | |||
1191 | /* Set MII speed */ | 1193 | /* Set MII speed */ |
1192 | writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED); | 1194 | writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED); |
1193 | 1195 | ||
1196 | #ifdef FEC_MIIGSK_ENR | ||
1197 | if (fep->phy_interface == PHY_INTERFACE_MODE_RMII) { | ||
1198 | /* disable the gasket and wait */ | ||
1199 | writel(0, fep->hwp + FEC_MIIGSK_ENR); | ||
1200 | while (readl(fep->hwp + FEC_MIIGSK_ENR) & 4) | ||
1201 | udelay(1); | ||
1202 | |||
1203 | /* configure the gasket: RMII, 50 MHz, no loopback, no echo */ | ||
1204 | writel(1, fep->hwp + FEC_MIIGSK_CFGR); | ||
1205 | |||
1206 | /* re-enable the gasket */ | ||
1207 | writel(2, fep->hwp + FEC_MIIGSK_ENR); | ||
1208 | } | ||
1209 | #endif | ||
1210 | |||
1194 | /* And last, enable the transmit and receive processing */ | 1211 | /* And last, enable the transmit and receive processing */ |
1195 | writel(2, fep->hwp + FEC_ECNTRL); | 1212 | writel(2, fep->hwp + FEC_ECNTRL); |
1196 | writel(0, fep->hwp + FEC_R_DES_ACTIVE); | 1213 | writel(0, fep->hwp + FEC_R_DES_ACTIVE); |
@@ -1226,6 +1243,7 @@ static int __devinit | |||
1226 | fec_probe(struct platform_device *pdev) | 1243 | fec_probe(struct platform_device *pdev) |
1227 | { | 1244 | { |
1228 | struct fec_enet_private *fep; | 1245 | struct fec_enet_private *fep; |
1246 | struct fec_platform_data *pdata; | ||
1229 | struct net_device *ndev; | 1247 | struct net_device *ndev; |
1230 | int i, irq, ret = 0; | 1248 | int i, irq, ret = 0; |
1231 | struct resource *r; | 1249 | struct resource *r; |
@@ -1259,6 +1277,10 @@ fec_probe(struct platform_device *pdev) | |||
1259 | 1277 | ||
1260 | platform_set_drvdata(pdev, ndev); | 1278 | platform_set_drvdata(pdev, ndev); |
1261 | 1279 | ||
1280 | pdata = pdev->dev.platform_data; | ||
1281 | if (pdata) | ||
1282 | fep->phy_interface = pdata->phy; | ||
1283 | |||
1262 | /* This device has up to three irqs on some platforms */ | 1284 | /* This device has up to three irqs on some platforms */ |
1263 | for (i = 0; i < 3; i++) { | 1285 | for (i = 0; i < 3; i++) { |
1264 | irq = platform_get_irq(pdev, i); | 1286 | irq = platform_get_irq(pdev, i); |
diff --git a/drivers/net/fec.h b/drivers/net/fec.h index cc47f3f057c..2c48b25668d 100644 --- a/drivers/net/fec.h +++ b/drivers/net/fec.h | |||
@@ -43,6 +43,8 @@ | |||
43 | #define FEC_R_DES_START 0x180 /* Receive descriptor ring */ | 43 | #define FEC_R_DES_START 0x180 /* Receive descriptor ring */ |
44 | #define FEC_X_DES_START 0x184 /* Transmit descriptor ring */ | 44 | #define FEC_X_DES_START 0x184 /* Transmit descriptor ring */ |
45 | #define FEC_R_BUFF_SIZE 0x188 /* Maximum receive buff size */ | 45 | #define FEC_R_BUFF_SIZE 0x188 /* Maximum receive buff size */ |
46 | #define FEC_MIIGSK_CFGR 0x300 /* MIIGSK Configuration reg */ | ||
47 | #define FEC_MIIGSK_ENR 0x308 /* MIIGSK Enable reg */ | ||
46 | 48 | ||
47 | #else | 49 | #else |
48 | 50 | ||