staging: et131x: Remove redundant phy code
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / staging / et131x / et1310_pm.c
blobb20d5d627ef4da221074e7239cffde6d5abfcf1f
1 /*
2 * Agere Systems Inc.
3 * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
5 * Copyright © 2005 Agere Systems Inc.
6 * All rights reserved.
7 * http://www.agere.com
9 *------------------------------------------------------------------------------
11 * et1310_pm.c - All power management related code (not completely implemented)
13 *------------------------------------------------------------------------------
15 * SOFTWARE LICENSE
17 * This software is provided subject to the following terms and conditions,
18 * which you should read carefully before using the software. Using this
19 * software indicates your acceptance of these terms and conditions. If you do
20 * not agree with these terms and conditions, do not use the software.
22 * Copyright © 2005 Agere Systems Inc.
23 * All rights reserved.
25 * Redistribution and use in source or binary forms, with or without
26 * modifications, are permitted provided that the following conditions are met:
28 * . Redistributions of source code must retain the above copyright notice, this
29 * list of conditions and the following Disclaimer as comments in the code as
30 * well as in the documentation and/or other materials provided with the
31 * distribution.
33 * . Redistributions in binary form must reproduce the above copyright notice,
34 * this list of conditions and the following Disclaimer in the documentation
35 * and/or other materials provided with the distribution.
37 * . Neither the name of Agere Systems Inc. nor the names of the contributors
38 * may be used to endorse or promote products derived from this software
39 * without specific prior written permission.
41 * Disclaimer
43 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
44 * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
45 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
46 * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
47 * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY
48 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
49 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
50 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
51 * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT
52 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
53 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
54 * DAMAGE.
58 #include "et131x_version.h"
59 #include "et131x_defs.h"
61 #include <linux/init.h>
62 #include <linux/module.h>
63 #include <linux/types.h>
64 #include <linux/kernel.h>
66 #include <linux/sched.h>
67 #include <linux/ptrace.h>
68 #include <linux/ctype.h>
69 #include <linux/string.h>
70 #include <linux/timer.h>
71 #include <linux/interrupt.h>
72 #include <linux/in.h>
73 #include <linux/delay.h>
74 #include <linux/io.h>
75 #include <linux/bitops.h>
76 #include <asm/system.h>
78 #include <linux/netdevice.h>
79 #include <linux/etherdevice.h>
80 #include <linux/skbuff.h>
81 #include <linux/if_arp.h>
82 #include <linux/ioport.h>
84 #include "et1310_phy.h"
85 #include "et1310_rx.h"
86 #include "et131x_adapter.h"
87 #include "et131x.h"
89 /**
90 * et1310_enable_phy_coma - called when network cable is unplugged
91 * @adapter: pointer to our adapter structure
93 * driver receive an phy status change interrupt while in D0 and check that
94 * phy_status is down.
96 * -- gate off JAGCore;
97 * -- set gigE PHY in Coma mode
98 * -- wake on phy_interrupt; Perform software reset JAGCore,
99 * re-initialize jagcore and gigE PHY
101 * Add D0-ASPM-PhyLinkDown Support:
102 * -- while in D0, when there is a phy_interrupt indicating phy link
103 * down status, call the MPSetPhyComa routine to enter this active
104 * state power saving mode
105 * -- while in D0-ASPM-PhyLinkDown mode, when there is a phy_interrupt
106 * indicating linkup status, call the MPDisablePhyComa routine to
107 * restore JAGCore and gigE PHY
109 void et1310_enable_phy_coma(struct et131x_adapter *adapter)
111 unsigned long flags;
112 u32 pmcsr;
114 pmcsr = readl(&adapter->regs->global.pm_csr);
116 /* Save the GbE PHY speed and duplex modes. Need to restore this
117 * when cable is plugged back in
120 * TODO - when PM is re-enabled, check if we need to
121 * perform a similar task as this -
122 * adapter->pdown_speed = adapter->ai_force_speed;
123 * adapter->pdown_duplex = adapter->ai_force_duplex;
126 /* Stop sending packets. */
127 spin_lock_irqsave(&adapter->send_hw_lock, flags);
128 adapter->flags |= fMP_ADAPTER_LOWER_POWER;
129 spin_unlock_irqrestore(&adapter->send_hw_lock, flags);
131 /* Wait for outstanding Receive packets */
133 /* Gate off JAGCore 3 clock domains */
134 pmcsr &= ~ET_PMCSR_INIT;
135 writel(pmcsr, &adapter->regs->global.pm_csr);
137 /* Program gigE PHY in to Coma mode */
138 pmcsr |= ET_PM_PHY_SW_COMA;
139 writel(pmcsr, &adapter->regs->global.pm_csr);
143 * et1310_disable_phy_coma - Disable the Phy Coma Mode
144 * @adapter: pointer to our adapter structure
146 void et1310_disable_phy_coma(struct et131x_adapter *adapter)
148 u32 pmcsr;
150 pmcsr = readl(&adapter->regs->global.pm_csr);
152 /* Disable phy_sw_coma register and re-enable JAGCore clocks */
153 pmcsr |= ET_PMCSR_INIT;
154 pmcsr &= ~ET_PM_PHY_SW_COMA;
155 writel(pmcsr, &adapter->regs->global.pm_csr);
157 /* Restore the GbE PHY speed and duplex modes;
158 * Reset JAGCore; re-configure and initialize JAGCore and gigE PHY
160 /* TODO - when PM is re-enabled, check if we need to
161 * perform a similar task as this -
162 * adapter->ai_force_speed = adapter->pdown_speed;
163 * adapter->ai_force_duplex = adapter->pdown_duplex;
166 /* Re-initialize the send structures */
167 et131x_init_send(adapter);
169 /* Reset the RFD list and re-start RU */
170 et131x_reset_recv(adapter);
172 /* Bring the device back to the state it was during init prior to
173 * autonegotiation being complete. This way, when we get the auto-neg
174 * complete interrupt, we can complete init by calling ConfigMacREGS2.
176 et131x_soft_reset(adapter);
178 /* setup et1310 as per the documentation ?? */
179 et131x_adapter_setup(adapter);
181 /* Allow Tx to restart */
182 adapter->flags &= ~fMP_ADAPTER_LOWER_POWER;
184 /* Need to re-enable Rx. */
185 et131x_rx_dma_enable(adapter);