aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Ermakov <vooon341@gmail.com>2012-03-17 09:10:50 -0400
committerDavid S. Miller <davem@davemloft.net>2012-03-19 18:02:05 -0400
commitba568335b089e0a27829e3a6117a7e1bf957ad07 (patch)
tree460d6569c4ad623ec8f1aee8d0fcb571b3ac1b4d
parentdc72d99dabb870ca5bd6d9fff674be853bb4a88d (diff)
fs_enet: Add MPC5125 FEC support and PHY interface selection
Add compatible string for MPC5125 FEC. The FEC on MPC5125 additionally supports RMII PHY interface. Configure controller/PHY interface type according to the optional phy-connection-type property in the ethernet node. This property should be either "rmii" or "mii". Signed-off-by: Vladimir Ermakov <vooon341@gmail.com> Signed-off-by: Anatolij Gustschin <agust@denx.de> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/freescale/fs_enet/fec.h6
-rw-r--r--drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c20
-rw-r--r--drivers/net/ethernet/freescale/fs_enet/mac-fec.c9
3 files changed, 28 insertions, 7 deletions
diff --git a/drivers/net/ethernet/freescale/fs_enet/fec.h b/drivers/net/ethernet/freescale/fs_enet/fec.h
index e980527e2b99..b9fe5bde432a 100644
--- a/drivers/net/ethernet/freescale/fs_enet/fec.h
+++ b/drivers/net/ethernet/freescale/fs_enet/fec.h
@@ -23,6 +23,10 @@
23#define FEC_ECNTRL_ETHER_EN 0x00000002 23#define FEC_ECNTRL_ETHER_EN 0x00000002
24#define FEC_ECNTRL_RESET 0x00000001 24#define FEC_ECNTRL_RESET 0x00000001
25 25
26/* RMII mode enabled only when MII_MODE bit is set too. */
27#define FEC_RCNTRL_RMII_MODE (0x00000100 | \
28 FEC_RCNTRL_MII_MODE | FEC_RCNTRL_FCE)
29#define FEC_RCNTRL_FCE 0x00000020
26#define FEC_RCNTRL_BC_REJ 0x00000010 30#define FEC_RCNTRL_BC_REJ 0x00000010
27#define FEC_RCNTRL_PROM 0x00000008 31#define FEC_RCNTRL_PROM 0x00000008
28#define FEC_RCNTRL_MII_MODE 0x00000004 32#define FEC_RCNTRL_MII_MODE 0x00000004
@@ -33,8 +37,6 @@
33#define FEC_TCNTRL_HBC 0x00000002 37#define FEC_TCNTRL_HBC 0x00000002
34#define FEC_TCNTRL_GTS 0x00000001 38#define FEC_TCNTRL_GTS 0x00000001
35 39
36
37
38/* 40/*
39 * Delay to wait for FEC reset command to complete (in us) 41 * Delay to wait for FEC reset command to complete (in us)
40 */ 42 */
diff --git a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
index 999638a7c851..e4e6cd2c5f82 100644
--- a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
+++ b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
@@ -790,16 +790,20 @@ static int fs_init_phy(struct net_device *dev)
790{ 790{
791 struct fs_enet_private *fep = netdev_priv(dev); 791 struct fs_enet_private *fep = netdev_priv(dev);
792 struct phy_device *phydev; 792 struct phy_device *phydev;
793 phy_interface_t iface;
793 794
794 fep->oldlink = 0; 795 fep->oldlink = 0;
795 fep->oldspeed = 0; 796 fep->oldspeed = 0;
796 fep->oldduplex = -1; 797 fep->oldduplex = -1;
797 798
799 iface = fep->fpi->use_rmii ?
800 PHY_INTERFACE_MODE_RMII : PHY_INTERFACE_MODE_MII;
801
798 phydev = of_phy_connect(dev, fep->fpi->phy_node, &fs_adjust_link, 0, 802 phydev = of_phy_connect(dev, fep->fpi->phy_node, &fs_adjust_link, 0,
799 PHY_INTERFACE_MODE_MII); 803 iface);
800 if (!phydev) { 804 if (!phydev) {
801 phydev = of_phy_connect_fixed_link(dev, &fs_adjust_link, 805 phydev = of_phy_connect_fixed_link(dev, &fs_adjust_link,
802 PHY_INTERFACE_MODE_MII); 806 iface);
803 } 807 }
804 if (!phydev) { 808 if (!phydev) {
805 dev_err(&dev->dev, "Could not attach to PHY\n"); 809 dev_err(&dev->dev, "Could not attach to PHY\n");
@@ -1007,6 +1011,7 @@ static int __devinit fs_enet_probe(struct platform_device *ofdev)
1007 struct fs_platform_info *fpi; 1011 struct fs_platform_info *fpi;
1008 const u32 *data; 1012 const u32 *data;
1009 const u8 *mac_addr; 1013 const u8 *mac_addr;
1014 const char *phy_connection_type;
1010 int privsize, len, ret = -ENODEV; 1015 int privsize, len, ret = -ENODEV;
1011 1016
1012 match = of_match_device(fs_enet_match, &ofdev->dev); 1017 match = of_match_device(fs_enet_match, &ofdev->dev);
@@ -1035,6 +1040,13 @@ static int __devinit fs_enet_probe(struct platform_device *ofdev)
1035 NULL))) 1040 NULL)))
1036 goto out_free_fpi; 1041 goto out_free_fpi;
1037 1042
1043 if (of_device_is_compatible(ofdev->dev.of_node, "fsl,mpc5125-fec")) {
1044 phy_connection_type = of_get_property(ofdev->dev.of_node,
1045 "phy-connection-type", NULL);
1046 if (phy_connection_type && !strcmp("rmii", phy_connection_type))
1047 fpi->use_rmii = 1;
1048 }
1049
1038 privsize = sizeof(*fep) + 1050 privsize = sizeof(*fep) +
1039 sizeof(struct sk_buff **) * 1051 sizeof(struct sk_buff **) *
1040 (fpi->rx_ring + fpi->tx_ring); 1052 (fpi->rx_ring + fpi->tx_ring);
@@ -1150,6 +1162,10 @@ static struct of_device_id fs_enet_match[] = {
1150 .compatible = "fsl,mpc5121-fec", 1162 .compatible = "fsl,mpc5121-fec",
1151 .data = (void *)&fs_fec_ops, 1163 .data = (void *)&fs_fec_ops,
1152 }, 1164 },
1165 {
1166 .compatible = "fsl,mpc5125-fec",
1167 .data = (void *)&fs_fec_ops,
1168 },
1153#else 1169#else
1154 { 1170 {
1155 .compatible = "fsl,pq1-fec-enet", 1171 .compatible = "fsl,pq1-fec-enet",
diff --git a/drivers/net/ethernet/freescale/fs_enet/mac-fec.c b/drivers/net/ethernet/freescale/fs_enet/mac-fec.c
index b9fbc83d64a7..9ae6cdbcac2e 100644
--- a/drivers/net/ethernet/freescale/fs_enet/mac-fec.c
+++ b/drivers/net/ethernet/freescale/fs_enet/mac-fec.c
@@ -322,10 +322,11 @@ static void restart(struct net_device *dev)
322 FW(fecp, r_cntrl, FEC_RCNTRL_MII_MODE); /* MII enable */ 322 FW(fecp, r_cntrl, FEC_RCNTRL_MII_MODE); /* MII enable */
323#else 323#else
324 /* 324 /*
325 * Only set MII mode - do not touch maximum frame length 325 * Only set MII/RMII mode - do not touch maximum frame length
326 * configured before. 326 * configured before.
327 */ 327 */
328 FS(fecp, r_cntrl, FEC_RCNTRL_MII_MODE); 328 FS(fecp, r_cntrl, fpi->use_rmii ?
329 FEC_RCNTRL_RMII_MODE : FEC_RCNTRL_MII_MODE);
329#endif 330#endif
330 /* 331 /*
331 * adjust to duplex mode 332 * adjust to duplex mode
@@ -381,7 +382,9 @@ static void stop(struct net_device *dev)
381 382
382 /* shut down FEC1? that's where the mii bus is */ 383 /* shut down FEC1? that's where the mii bus is */
383 if (fpi->has_phy) { 384 if (fpi->has_phy) {
384 FS(fecp, r_cntrl, FEC_RCNTRL_MII_MODE); /* MII enable */ 385 FS(fecp, r_cntrl, fpi->use_rmii ?
386 FEC_RCNTRL_RMII_MODE :
387 FEC_RCNTRL_MII_MODE); /* MII/RMII enable */
385 FS(fecp, ecntrl, FEC_ECNTRL_PINMUX | FEC_ECNTRL_ETHER_EN); 388 FS(fecp, ecntrl, FEC_ECNTRL_PINMUX | FEC_ECNTRL_ETHER_EN);
386 FW(fecp, ievent, FEC_ENET_MII); 389 FW(fecp, ievent, FEC_ENET_MII);
387 FW(fecp, mii_speed, feci->mii_speed); 390 FW(fecp, mii_speed, feci->mii_speed);