diff options
-rw-r--r-- | arch/powerpc/include/asm/qe.h | 2 | ||||
-rw-r--r-- | drivers/net/ucc_geth.c | 79 | ||||
-rw-r--r-- | drivers/net/ucc_geth.h | 28 |
3 files changed, 107 insertions, 2 deletions
diff --git a/arch/powerpc/include/asm/qe.h b/arch/powerpc/include/asm/qe.h index 2701753d9937..4459d20dc76a 100644 --- a/arch/powerpc/include/asm/qe.h +++ b/arch/powerpc/include/asm/qe.h | |||
@@ -668,6 +668,8 @@ struct ucc_slow_pram { | |||
668 | #define UCC_GETH_UPSMR_RMM 0x00001000 | 668 | #define UCC_GETH_UPSMR_RMM 0x00001000 |
669 | #define UCC_GETH_UPSMR_CAM 0x00000400 | 669 | #define UCC_GETH_UPSMR_CAM 0x00000400 |
670 | #define UCC_GETH_UPSMR_BRO 0x00000200 | 670 | #define UCC_GETH_UPSMR_BRO 0x00000200 |
671 | #define UCC_GETH_UPSMR_SMM 0x00000080 | ||
672 | #define UCC_GETH_UPSMR_SGMM 0x00000020 | ||
671 | 673 | ||
672 | /* UCC Transmit On Demand Register (UTODR) */ | 674 | /* UCC Transmit On Demand Register (UTODR) */ |
673 | #define UCC_SLOW_TOD 0x8000 | 675 | #define UCC_SLOW_TOD 0x8000 |
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c index 0cf22c4f123b..fd6140bd9aae 100644 --- a/drivers/net/ucc_geth.c +++ b/drivers/net/ucc_geth.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2006-2007 Freescale Semicondutor, Inc. All rights reserved. | 2 | * Copyright (C) 2006-2009 Freescale Semicondutor, Inc. All rights reserved. |
3 | * | 3 | * |
4 | * Author: Shlomi Gridish <gridish@freescale.com> | 4 | * Author: Shlomi Gridish <gridish@freescale.com> |
5 | * Li Yang <leoli@freescale.com> | 5 | * Li Yang <leoli@freescale.com> |
@@ -65,6 +65,8 @@ | |||
65 | 65 | ||
66 | static DEFINE_SPINLOCK(ugeth_lock); | 66 | static DEFINE_SPINLOCK(ugeth_lock); |
67 | 67 | ||
68 | static void uec_configure_serdes(struct net_device *dev); | ||
69 | |||
68 | static struct { | 70 | static struct { |
69 | u32 msg_enable; | 71 | u32 msg_enable; |
70 | } debug = { -1 }; | 72 | } debug = { -1 }; |
@@ -1410,6 +1412,9 @@ static int adjust_enet_interface(struct ucc_geth_private *ugeth) | |||
1410 | (ugeth->phy_interface == PHY_INTERFACE_MODE_RTBI)) { | 1412 | (ugeth->phy_interface == PHY_INTERFACE_MODE_RTBI)) { |
1411 | upsmr |= UCC_GETH_UPSMR_TBIM; | 1413 | upsmr |= UCC_GETH_UPSMR_TBIM; |
1412 | } | 1414 | } |
1415 | if ((ugeth->phy_interface == PHY_INTERFACE_MODE_SGMII)) | ||
1416 | upsmr |= UCC_GETH_UPSMR_SGMM; | ||
1417 | |||
1413 | out_be32(&uf_regs->upsmr, upsmr); | 1418 | out_be32(&uf_regs->upsmr, upsmr); |
1414 | 1419 | ||
1415 | /* Disable autonegotiation in tbi mode, because by default it | 1420 | /* Disable autonegotiation in tbi mode, because by default it |
@@ -1554,6 +1559,9 @@ static int init_phy(struct net_device *dev) | |||
1554 | return -ENODEV; | 1559 | return -ENODEV; |
1555 | } | 1560 | } |
1556 | 1561 | ||
1562 | if (priv->phy_interface == PHY_INTERFACE_MODE_SGMII) | ||
1563 | uec_configure_serdes(dev); | ||
1564 | |||
1557 | phydev->supported &= (ADVERTISED_10baseT_Half | | 1565 | phydev->supported &= (ADVERTISED_10baseT_Half | |
1558 | ADVERTISED_10baseT_Full | | 1566 | ADVERTISED_10baseT_Full | |
1559 | ADVERTISED_100baseT_Half | | 1567 | ADVERTISED_100baseT_Half | |
@@ -1569,7 +1577,41 @@ static int init_phy(struct net_device *dev) | |||
1569 | return 0; | 1577 | return 0; |
1570 | } | 1578 | } |
1571 | 1579 | ||
1580 | /* Initialize TBI PHY interface for communicating with the | ||
1581 | * SERDES lynx PHY on the chip. We communicate with this PHY | ||
1582 | * through the MDIO bus on each controller, treating it as a | ||
1583 | * "normal" PHY at the address found in the UTBIPA register. We assume | ||
1584 | * that the UTBIPA register is valid. Either the MDIO bus code will set | ||
1585 | * it to a value that doesn't conflict with other PHYs on the bus, or the | ||
1586 | * value doesn't matter, as there are no other PHYs on the bus. | ||
1587 | */ | ||
1588 | static void uec_configure_serdes(struct net_device *dev) | ||
1589 | { | ||
1590 | struct ucc_geth_private *ugeth = netdev_priv(dev); | ||
1591 | |||
1592 | if (!ugeth->tbiphy) { | ||
1593 | printk(KERN_WARNING "SGMII mode requires that the device " | ||
1594 | "tree specify a tbi-handle\n"); | ||
1595 | return; | ||
1596 | } | ||
1597 | |||
1598 | /* | ||
1599 | * If the link is already up, we must already be ok, and don't need to | ||
1600 | * configure and reset the TBI<->SerDes link. Maybe U-Boot configured | ||
1601 | * everything for us? Resetting it takes the link down and requires | ||
1602 | * several seconds for it to come back. | ||
1603 | */ | ||
1604 | if (phy_read(ugeth->tbiphy, ENET_TBI_MII_SR) & TBISR_LSTATUS) | ||
1605 | return; | ||
1606 | |||
1607 | /* Single clk mode, mii mode off(for serdes communication) */ | ||
1608 | phy_write(ugeth->tbiphy, ENET_TBI_MII_ANA, TBIANA_SETTINGS); | ||
1572 | 1609 | ||
1610 | phy_write(ugeth->tbiphy, ENET_TBI_MII_TBICON, TBICON_CLK_SELECT); | ||
1611 | |||
1612 | phy_write(ugeth->tbiphy, ENET_TBI_MII_CR, TBICR_SETTINGS); | ||
1613 | |||
1614 | } | ||
1573 | 1615 | ||
1574 | static int ugeth_graceful_stop_tx(struct ucc_geth_private *ugeth) | 1616 | static int ugeth_graceful_stop_tx(struct ucc_geth_private *ugeth) |
1575 | { | 1617 | { |
@@ -3523,6 +3565,8 @@ static phy_interface_t to_phy_interface(const char *phy_connection_type) | |||
3523 | return PHY_INTERFACE_MODE_RGMII_RXID; | 3565 | return PHY_INTERFACE_MODE_RGMII_RXID; |
3524 | if (strcasecmp(phy_connection_type, "rtbi") == 0) | 3566 | if (strcasecmp(phy_connection_type, "rtbi") == 0) |
3525 | return PHY_INTERFACE_MODE_RTBI; | 3567 | return PHY_INTERFACE_MODE_RTBI; |
3568 | if (strcasecmp(phy_connection_type, "sgmii") == 0) | ||
3569 | return PHY_INTERFACE_MODE_SGMII; | ||
3526 | 3570 | ||
3527 | return PHY_INTERFACE_MODE_MII; | 3571 | return PHY_INTERFACE_MODE_MII; |
3528 | } | 3572 | } |
@@ -3567,6 +3611,7 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma | |||
3567 | PHY_INTERFACE_MODE_RMII, PHY_INTERFACE_MODE_RGMII, | 3611 | PHY_INTERFACE_MODE_RMII, PHY_INTERFACE_MODE_RGMII, |
3568 | PHY_INTERFACE_MODE_GMII, PHY_INTERFACE_MODE_RGMII, | 3612 | PHY_INTERFACE_MODE_GMII, PHY_INTERFACE_MODE_RGMII, |
3569 | PHY_INTERFACE_MODE_TBI, PHY_INTERFACE_MODE_RTBI, | 3613 | PHY_INTERFACE_MODE_TBI, PHY_INTERFACE_MODE_RTBI, |
3614 | PHY_INTERFACE_MODE_SGMII, | ||
3570 | }; | 3615 | }; |
3571 | 3616 | ||
3572 | ugeth_vdbg("%s: IN", __func__); | 3617 | ugeth_vdbg("%s: IN", __func__); |
@@ -3682,6 +3727,7 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma | |||
3682 | case PHY_INTERFACE_MODE_RGMII_TXID: | 3727 | case PHY_INTERFACE_MODE_RGMII_TXID: |
3683 | case PHY_INTERFACE_MODE_TBI: | 3728 | case PHY_INTERFACE_MODE_TBI: |
3684 | case PHY_INTERFACE_MODE_RTBI: | 3729 | case PHY_INTERFACE_MODE_RTBI: |
3730 | case PHY_INTERFACE_MODE_SGMII: | ||
3685 | max_speed = SPEED_1000; | 3731 | max_speed = SPEED_1000; |
3686 | break; | 3732 | break; |
3687 | default: | 3733 | default: |
@@ -3756,6 +3802,37 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma | |||
3756 | ugeth->ndev = dev; | 3802 | ugeth->ndev = dev; |
3757 | ugeth->node = np; | 3803 | ugeth->node = np; |
3758 | 3804 | ||
3805 | /* Find the TBI PHY. If it's not there, we don't support SGMII */ | ||
3806 | ph = of_get_property(np, "tbi-handle", NULL); | ||
3807 | if (ph) { | ||
3808 | struct device_node *tbi = of_find_node_by_phandle(*ph); | ||
3809 | struct of_device *ofdev; | ||
3810 | struct mii_bus *bus; | ||
3811 | const unsigned int *id; | ||
3812 | |||
3813 | if (!tbi) | ||
3814 | return 0; | ||
3815 | |||
3816 | mdio = of_get_parent(tbi); | ||
3817 | if (!mdio) | ||
3818 | return 0; | ||
3819 | |||
3820 | ofdev = of_find_device_by_node(mdio); | ||
3821 | |||
3822 | of_node_put(mdio); | ||
3823 | |||
3824 | id = of_get_property(tbi, "reg", NULL); | ||
3825 | if (!id) | ||
3826 | return 0; | ||
3827 | of_node_put(tbi); | ||
3828 | |||
3829 | bus = dev_get_drvdata(&ofdev->dev); | ||
3830 | if (!bus) | ||
3831 | return 0; | ||
3832 | |||
3833 | ugeth->tbiphy = bus->phy_map[*id]; | ||
3834 | } | ||
3835 | |||
3759 | return 0; | 3836 | return 0; |
3760 | } | 3837 | } |
3761 | 3838 | ||
diff --git a/drivers/net/ucc_geth.h b/drivers/net/ucc_geth.h index dca628a922ba..deb962bb68ef 100644 --- a/drivers/net/ucc_geth.h +++ b/drivers/net/ucc_geth.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) Freescale Semicondutor, Inc. 2006. All rights reserved. | 2 | * Copyright (C) Freescale Semicondutor, Inc. 2006-2009. All rights reserved. |
3 | * | 3 | * |
4 | * Author: Shlomi Gridish <gridish@freescale.com> | 4 | * Author: Shlomi Gridish <gridish@freescale.com> |
5 | * | 5 | * |
@@ -193,6 +193,31 @@ struct ucc_geth { | |||
193 | #define ENET_TBI_MII_JD 0x10 /* Jitter diagnostics */ | 193 | #define ENET_TBI_MII_JD 0x10 /* Jitter diagnostics */ |
194 | #define ENET_TBI_MII_TBICON 0x11 /* TBI control */ | 194 | #define ENET_TBI_MII_TBICON 0x11 /* TBI control */ |
195 | 195 | ||
196 | /* TBI MDIO register bit fields*/ | ||
197 | #define TBISR_LSTATUS 0x0004 | ||
198 | #define TBICON_CLK_SELECT 0x0020 | ||
199 | #define TBIANA_ASYMMETRIC_PAUSE 0x0100 | ||
200 | #define TBIANA_SYMMETRIC_PAUSE 0x0080 | ||
201 | #define TBIANA_HALF_DUPLEX 0x0040 | ||
202 | #define TBIANA_FULL_DUPLEX 0x0020 | ||
203 | #define TBICR_PHY_RESET 0x8000 | ||
204 | #define TBICR_ANEG_ENABLE 0x1000 | ||
205 | #define TBICR_RESTART_ANEG 0x0200 | ||
206 | #define TBICR_FULL_DUPLEX 0x0100 | ||
207 | #define TBICR_SPEED1_SET 0x0040 | ||
208 | |||
209 | #define TBIANA_SETTINGS ( \ | ||
210 | TBIANA_ASYMMETRIC_PAUSE \ | ||
211 | | TBIANA_SYMMETRIC_PAUSE \ | ||
212 | | TBIANA_FULL_DUPLEX \ | ||
213 | ) | ||
214 | #define TBICR_SETTINGS ( \ | ||
215 | TBICR_PHY_RESET \ | ||
216 | | TBICR_ANEG_ENABLE \ | ||
217 | | TBICR_FULL_DUPLEX \ | ||
218 | | TBICR_SPEED1_SET \ | ||
219 | ) | ||
220 | |||
196 | /* UCC GETH MACCFG1 (MAC Configuration 1 Register) */ | 221 | /* UCC GETH MACCFG1 (MAC Configuration 1 Register) */ |
197 | #define MACCFG1_FLOW_RX 0x00000020 /* Flow Control | 222 | #define MACCFG1_FLOW_RX 0x00000020 /* Flow Control |
198 | Rx */ | 223 | Rx */ |
@@ -1188,6 +1213,7 @@ struct ucc_geth_private { | |||
1188 | 1213 | ||
1189 | struct ugeth_mii_info *mii_info; | 1214 | struct ugeth_mii_info *mii_info; |
1190 | struct phy_device *phydev; | 1215 | struct phy_device *phydev; |
1216 | struct phy_device *tbiphy; | ||
1191 | phy_interface_t phy_interface; | 1217 | phy_interface_t phy_interface; |
1192 | int max_speed; | 1218 | int max_speed; |
1193 | uint32_t msg_enable; | 1219 | uint32_t msg_enable; |