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>

authored by Baruch Siach and committed by David S. Miller 5eb32bd0 82862742

+45
+22
drivers/net/fec.c
··· 41 #include <linux/clk.h> 42 #include <linux/platform_device.h> 43 #include <linux/phy.h> 44 45 #include <asm/cacheflush.h> 46 ··· 183 struct phy_device *phy_dev; 184 int mii_timeout; 185 uint phy_speed; 186 int index; 187 int link; 188 int full_duplex; ··· 1193 /* Set MII speed */ 1194 writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED); 1195 1196 /* And last, enable the transmit and receive processing */ 1197 writel(2, fep->hwp + FEC_ECNTRL); 1198 writel(0, fep->hwp + FEC_R_DES_ACTIVE); ··· 1243 fec_probe(struct platform_device *pdev) 1244 { 1245 struct fec_enet_private *fep; 1246 struct net_device *ndev; 1247 int i, irq, ret = 0; 1248 struct resource *r; ··· 1276 } 1277 1278 platform_set_drvdata(pdev, ndev); 1279 1280 /* This device has up to three irqs on some platforms */ 1281 for (i = 0; i < 3; i++) {
··· 41 #include <linux/clk.h> 42 #include <linux/platform_device.h> 43 #include <linux/phy.h> 44 + #include <linux/fec.h> 45 46 #include <asm/cacheflush.h> 47 ··· 182 struct phy_device *phy_dev; 183 int mii_timeout; 184 uint phy_speed; 185 + phy_interface_t phy_interface; 186 int index; 187 int link; 188 int full_duplex; ··· 1191 /* Set MII speed */ 1192 writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED); 1193 1194 + #ifdef FEC_MIIGSK_ENR 1195 + if (fep->phy_interface == PHY_INTERFACE_MODE_RMII) { 1196 + /* disable the gasket and wait */ 1197 + writel(0, fep->hwp + FEC_MIIGSK_ENR); 1198 + while (readl(fep->hwp + FEC_MIIGSK_ENR) & 4) 1199 + udelay(1); 1200 + 1201 + /* configure the gasket: RMII, 50 MHz, no loopback, no echo */ 1202 + writel(1, fep->hwp + FEC_MIIGSK_CFGR); 1203 + 1204 + /* re-enable the gasket */ 1205 + writel(2, fep->hwp + FEC_MIIGSK_ENR); 1206 + } 1207 + #endif 1208 + 1209 /* And last, enable the transmit and receive processing */ 1210 writel(2, fep->hwp + FEC_ECNTRL); 1211 writel(0, fep->hwp + FEC_R_DES_ACTIVE); ··· 1226 fec_probe(struct platform_device *pdev) 1227 { 1228 struct fec_enet_private *fep; 1229 + struct fec_platform_data *pdata; 1230 struct net_device *ndev; 1231 int i, irq, ret = 0; 1232 struct resource *r; ··· 1258 } 1259 1260 platform_set_drvdata(pdev, ndev); 1261 + 1262 + pdata = pdev->dev.platform_data; 1263 + if (pdata) 1264 + fep->phy_interface = pdata->phy; 1265 1266 /* This device has up to three irqs on some platforms */ 1267 for (i = 0; i < 3; i++) {
+2
drivers/net/fec.h
··· 43 #define FEC_R_DES_START 0x180 /* Receive descriptor ring */ 44 #define FEC_X_DES_START 0x184 /* Transmit descriptor ring */ 45 #define FEC_R_BUFF_SIZE 0x188 /* Maximum receive buff size */ 46 47 #else 48
··· 43 #define FEC_R_DES_START 0x180 /* Receive descriptor ring */ 44 #define FEC_X_DES_START 0x184 /* Transmit descriptor ring */ 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 */ 48 49 #else 50
+21
include/linux/fec.h
···
··· 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