Skip to content

Commit 5eb32bd

Browse files
baruchsiachdavem330
authored andcommitted
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>
1 parent 8286274 commit 5eb32bd

3 files changed

Lines changed: 45 additions & 0 deletions

File tree

‎drivers/net/fec.c‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <linux/clk.h>
4242
#include <linux/platform_device.h>
4343
#include <linux/phy.h>
44+
#include <linux/fec.h>
4445

4546
#include <asm/cacheflush.h>
4647

@@ -182,6 +183,7 @@ struct fec_enet_private {
182183
struct phy_device *phy_dev;
183184
int mii_timeout;
184185
uint phy_speed;
186+
phy_interface_t phy_interface;
185187
int index;
186188
int link;
187189
int full_duplex;
@@ -1191,6 +1193,21 @@ fec_restart(struct net_device *dev, int duplex)
11911193
/* Set MII speed */
11921194
writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
11931195

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+
11941211
/* And last, enable the transmit and receive processing */
11951212
writel(2, fep->hwp + FEC_ECNTRL);
11961213
writel(0, fep->hwp + FEC_R_DES_ACTIVE);
@@ -1226,6 +1243,7 @@ static int __devinit
12261243
fec_probe(struct platform_device *pdev)
12271244
{
12281245
struct fec_enet_private *fep;
1246+
struct fec_platform_data *pdata;
12291247
struct net_device *ndev;
12301248
int i, irq, ret = 0;
12311249
struct resource *r;
@@ -1259,6 +1277,10 @@ fec_probe(struct platform_device *pdev)
12591277

12601278
platform_set_drvdata(pdev, ndev);
12611279

1280+
pdata = pdev->dev.platform_data;
1281+
if (pdata)
1282+
fep->phy_interface = pdata->phy;
1283+
12621284
/* This device has up to three irqs on some platforms */
12631285
for (i = 0; i < 3; i++) {
12641286
irq = platform_get_irq(pdev, i);

‎drivers/net/fec.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
#define FEC_R_DES_START 0x180 /* Receive descriptor ring */
4444
#define FEC_X_DES_START 0x184 /* Transmit descriptor ring */
4545
#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 */
4648

4749
#else
4850

‎include/linux/fec.h‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/* include/linux/fec.h
2+
*
3+
* Copyright (c) 2009 Orex Computed Radiography
4+
* Baruch Siach <baruch@tkos.co.il>
5+
*
6+
* Header file for the FEC platform data
7+
*
8+
* This program is free software; you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License version 2 as
10+
* published by the Free Software Foundation.
11+
*/
12+
#ifndef __LINUX_FEC_H__
13+
#define __LINUX_FEC_H__
14+
15+
#include <linux/phy.h>
16+
17+
struct fec_platform_data {
18+
phy_interface_t phy;
19+
};
20+
21+
#endif

0 commit comments

Comments
 (0)