]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - drivers/net/phy/teranetics.c
Merge branch 'master' of git://git.denx.de/u-boot-mips
[karo-tx-uboot.git] / drivers / net / phy / teranetics.c
1 /*
2  * Teranetics PHY drivers
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of
7  * the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
17  * MA 02111-1307 USA
18  *
19  * Copyright 2010-2011 Freescale Semiconductor, Inc.
20  * author Andy Fleming
21  *
22  */
23 #include <config.h>
24 #include <phy.h>
25
26 #ifndef CONFIG_PHYLIB_10G
27 #error The Teranetics PHY needs 10G support
28 #endif
29
30 int tn2020_config(struct phy_device *phydev)
31 {
32         if (phydev->port == PORT_FIBRE) {
33                 unsigned short restart_an = (MDIO_AN_CTRL1_RESTART |
34                                                 MDIO_AN_CTRL1_ENABLE |
35                                                 MDIO_AN_CTRL1_XNP);
36
37                 phy_write(phydev, 30, 93, 2);
38                 phy_write(phydev, MDIO_MMD_AN, MDIO_CTRL1, restart_an);
39         }
40
41         return 0;
42 }
43
44 int tn2020_startup(struct phy_device *phydev)
45 {
46         if (phydev->port != PORT_FIBRE)
47                 return gen10g_startup(phydev);
48
49         /*
50          * The TN2020 only pretends to support fiber.
51          * It works, but it doesn't look like it works,
52          * so the link status reports no link.
53          */
54         phydev->link = 1;
55
56         /* For now just lie and say it's 10G all the time */
57         phydev->speed = SPEED_10000;
58         phydev->duplex = DUPLEX_FULL;
59
60         return 0;
61 }
62
63 struct phy_driver tn2020_driver = {
64         .name = "Teranetics TN2020",
65         .uid = 0x00a19410,
66         .mask = 0xfffffff0,
67         .features = PHY_10G_FEATURES,
68         .mmds = (MDIO_DEVS_PMAPMD | MDIO_DEVS_PCS |
69                         MDIO_DEVS_PHYXS | MDIO_DEVS_AN |
70                         MDIO_DEVS_VEND1 | MDIO_DEVS_VEND2),
71         .config = &tn2020_config,
72         .startup = &tn2020_startup,
73         .shutdown = &gen10g_shutdown,
74 };
75
76 int phy_teranetics_init(void)
77 {
78         phy_register(&tn2020_driver);
79
80         return 0;
81 }