Commit | Line | Data |
---|---|---|
80ff0fd3 DD |
1 | /********************************************************************** |
2 | * Author: Cavium Networks | |
3 | * | |
4 | * Contact: support@caviumnetworks.com | |
5 | * This file is part of the OCTEON SDK | |
6 | * | |
7 | * Copyright (c) 2003-2007 Cavium Networks | |
8 | * | |
9 | * This file is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License, Version 2, as | |
11 | * published by the Free Software Foundation. | |
12 | * | |
13 | * This file is distributed in the hope that it will be useful, but | |
14 | * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty | |
15 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or | |
16 | * NONINFRINGEMENT. See the GNU General Public License for more | |
17 | * details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this file; if not, write to the Free Software | |
21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
22 | * or visit http://www.gnu.org/licenses/. | |
23 | * | |
24 | * This file may also be available under a different license from Cavium. | |
25 | * Contact Cavium Networks for more information | |
26 | **********************************************************************/ | |
ec3a2207 | 27 | #include <linux/phy.h> |
80ff0fd3 DD |
28 | #include <linux/kernel.h> |
29 | #include <linux/netdevice.h> | |
7a2eaf93 | 30 | #include <linux/ratelimit.h> |
80ff0fd3 DD |
31 | #include <net/dst.h> |
32 | ||
33 | #include <asm/octeon/octeon.h> | |
34 | ||
35 | #include "ethernet-defines.h" | |
36 | #include "octeon-ethernet.h" | |
37 | #include "ethernet-util.h" | |
ec3a2207 | 38 | #include "ethernet-mdio.h" |
80ff0fd3 | 39 | |
af866496 | 40 | #include <asm/octeon/cvmx-helper.h> |
80ff0fd3 | 41 | |
af866496 | 42 | #include <asm/octeon/cvmx-gmxx-defs.h> |
80ff0fd3 | 43 | |
80ff0fd3 DD |
44 | static void cvm_oct_sgmii_poll(struct net_device *dev) |
45 | { | |
46 | struct octeon_ethernet *priv = netdev_priv(dev); | |
47 | cvmx_helper_link_info_t link_info; | |
48 | ||
49 | link_info = cvmx_helper_link_get(priv->port); | |
50 | if (link_info.u64 == priv->link_info) | |
51 | return; | |
52 | ||
53 | link_info = cvmx_helper_link_autoconf(priv->port); | |
54 | priv->link_info = link_info.u64; | |
55 | ||
56 | /* Tell Linux */ | |
57 | if (link_info.s.link_up) { | |
80ff0fd3 DD |
58 | if (!netif_carrier_ok(dev)) |
59 | netif_carrier_on(dev); | |
2638f713 AK |
60 | } else if (netif_carrier_ok(dev)) { |
61 | netif_carrier_off(dev); | |
80ff0fd3 | 62 | } |
2638f713 | 63 | cvm_oct_note_carrier(priv, link_info); |
80ff0fd3 DD |
64 | } |
65 | ||
ec3a2207 | 66 | int cvm_oct_sgmii_open(struct net_device *dev) |
80ff0fd3 | 67 | { |
9e3ae4f9 | 68 | return cvm_oct_common_open(dev, cvm_oct_sgmii_poll, true); |
ec3a2207 DD |
69 | } |
70 | ||
ec3a2207 DD |
71 | int cvm_oct_sgmii_init(struct net_device *dev) |
72 | { | |
80ff0fd3 | 73 | cvm_oct_common_init(dev); |
80ff0fd3 DD |
74 | |
75 | /* FIXME: Need autoneg logic */ | |
76 | return 0; | |
77 | } |