]>
Commit | Line | Data |
---|---|---|
cfb739b4 GKH |
1 | /* |
2 | * Agere Systems Inc. | |
3 | * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs | |
4 | * | |
64f93036 | 5 | * Copyright © 2005 Agere Systems Inc. |
cfb739b4 GKH |
6 | * All rights reserved. |
7 | * http://www.agere.com | |
8 | * | |
9 | *------------------------------------------------------------------------------ | |
10 | * | |
11 | * et1310_pm.c - All power management related code (not completely implemented) | |
12 | * | |
13 | *------------------------------------------------------------------------------ | |
14 | * | |
15 | * SOFTWARE LICENSE | |
16 | * | |
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. | |
21 | * | |
64f93036 | 22 | * Copyright © 2005 Agere Systems Inc. |
cfb739b4 GKH |
23 | * All rights reserved. |
24 | * | |
25 | * Redistribution and use in source or binary forms, with or without | |
26 | * modifications, are permitted provided that the following conditions are met: | |
27 | * | |
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. | |
32 | * | |
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. | |
36 | * | |
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. | |
40 | * | |
41 | * Disclaimer | |
42 | * | |
64f93036 | 43 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
cfb739b4 GKH |
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. | |
55 | * | |
56 | */ | |
57 | ||
58 | #include "et131x_version.h" | |
cfb739b4 GKH |
59 | #include "et131x_defs.h" |
60 | ||
61 | #include <linux/init.h> | |
62 | #include <linux/module.h> | |
63 | #include <linux/types.h> | |
64 | #include <linux/kernel.h> | |
65 | ||
66 | #include <linux/sched.h> | |
67 | #include <linux/ptrace.h> | |
68 | #include <linux/slab.h> | |
69 | #include <linux/ctype.h> | |
70 | #include <linux/string.h> | |
71 | #include <linux/timer.h> | |
72 | #include <linux/interrupt.h> | |
73 | #include <linux/in.h> | |
74 | #include <linux/delay.h> | |
64f93036 AC |
75 | #include <linux/io.h> |
76 | #include <linux/bitops.h> | |
cfb739b4 | 77 | #include <asm/system.h> |
cfb739b4 GKH |
78 | |
79 | #include <linux/netdevice.h> | |
80 | #include <linux/etherdevice.h> | |
81 | #include <linux/skbuff.h> | |
82 | #include <linux/if_arp.h> | |
83 | #include <linux/ioport.h> | |
84 | ||
85 | #include "et1310_phy.h" | |
cfb739b4 | 86 | #include "et1310_rx.h" |
cfb739b4 | 87 | #include "et131x_adapter.h" |
69ea5fcb | 88 | #include "et131x.h" |
cfb739b4 | 89 | |
cfb739b4 GKH |
90 | /** |
91 | * EnablePhyComa - called when network cable is unplugged | |
25ad00bb | 92 | * @etdev: pointer to our adapter structure |
cfb739b4 GKH |
93 | * |
94 | * driver receive an phy status change interrupt while in D0 and check that | |
95 | * phy_status is down. | |
96 | * | |
97 | * -- gate off JAGCore; | |
98 | * -- set gigE PHY in Coma mode | |
99 | * -- wake on phy_interrupt; Perform software reset JAGCore, | |
100 | * re-initialize jagcore and gigE PHY | |
101 | * | |
102 | * Add D0-ASPM-PhyLinkDown Support: | |
103 | * -- while in D0, when there is a phy_interrupt indicating phy link | |
104 | * down status, call the MPSetPhyComa routine to enter this active | |
105 | * state power saving mode | |
106 | * -- while in D0-ASPM-PhyLinkDown mode, when there is a phy_interrupt | |
107 | * indicating linkup status, call the MPDisablePhyComa routine to | |
108 | * restore JAGCore and gigE PHY | |
109 | */ | |
25ad00bb | 110 | void EnablePhyComa(struct et131x_adapter *etdev) |
cfb739b4 | 111 | { |
37628606 | 112 | unsigned long flags; |
f2c98d27 | 113 | u32 GlobalPmCSR; |
cfb739b4 | 114 | |
f2c98d27 | 115 | GlobalPmCSR = readl(&etdev->regs->global.pm_csr); |
cfb739b4 GKH |
116 | |
117 | /* Save the GbE PHY speed and duplex modes. Need to restore this | |
118 | * when cable is plugged back in | |
119 | */ | |
25ad00bb AC |
120 | etdev->PoMgmt.PowerDownSpeed = etdev->AiForceSpeed; |
121 | etdev->PoMgmt.PowerDownDuplex = etdev->AiForceDpx; | |
cfb739b4 GKH |
122 | |
123 | /* Stop sending packets. */ | |
37628606 | 124 | spin_lock_irqsave(&etdev->SendHWLock, flags); |
f6b35d66 | 125 | etdev->Flags |= fMP_ADAPTER_LOWER_POWER; |
37628606 | 126 | spin_unlock_irqrestore(&etdev->SendHWLock, flags); |
cfb739b4 GKH |
127 | |
128 | /* Wait for outstanding Receive packets */ | |
cfb739b4 GKH |
129 | |
130 | /* Gate off JAGCore 3 clock domains */ | |
f2c98d27 AC |
131 | GlobalPmCSR &= ~ET_PMCSR_INIT; |
132 | writel(GlobalPmCSR, &etdev->regs->global.pm_csr); | |
cfb739b4 GKH |
133 | |
134 | /* Program gigE PHY in to Coma mode */ | |
f2c98d27 AC |
135 | GlobalPmCSR |= ET_PM_PHY_SW_COMA; |
136 | writel(GlobalPmCSR, &etdev->regs->global.pm_csr); | |
cfb739b4 GKH |
137 | } |
138 | ||
139 | /** | |
140 | * DisablePhyComa - Disable the Phy Coma Mode | |
25ad00bb | 141 | * @etdev: pointer to our adapter structure |
cfb739b4 | 142 | */ |
25ad00bb | 143 | void DisablePhyComa(struct et131x_adapter *etdev) |
cfb739b4 | 144 | { |
f2c98d27 | 145 | u32 GlobalPmCSR; |
cfb739b4 | 146 | |
f2c98d27 | 147 | GlobalPmCSR = readl(&etdev->regs->global.pm_csr); |
cfb739b4 GKH |
148 | |
149 | /* Disable phy_sw_coma register and re-enable JAGCore clocks */ | |
f2c98d27 AC |
150 | GlobalPmCSR |= ET_PMCSR_INIT; |
151 | GlobalPmCSR &= ~ET_PM_PHY_SW_COMA; | |
152 | writel(GlobalPmCSR, &etdev->regs->global.pm_csr); | |
cfb739b4 GKH |
153 | |
154 | /* Restore the GbE PHY speed and duplex modes; | |
155 | * Reset JAGCore; re-configure and initialize JAGCore and gigE PHY | |
156 | */ | |
25ad00bb AC |
157 | etdev->AiForceSpeed = etdev->PoMgmt.PowerDownSpeed; |
158 | etdev->AiForceDpx = etdev->PoMgmt.PowerDownDuplex; | |
cfb739b4 GKH |
159 | |
160 | /* Re-initialize the send structures */ | |
25ad00bb | 161 | et131x_init_send(etdev); |
cfb739b4 GKH |
162 | |
163 | /* Reset the RFD list and re-start RU */ | |
25ad00bb | 164 | et131x_reset_recv(etdev); |
cfb739b4 GKH |
165 | |
166 | /* Bring the device back to the state it was during init prior to | |
64f93036 AC |
167 | * autonegotiation being complete. This way, when we get the auto-neg |
168 | * complete interrupt, we can complete init by calling ConfigMacREGS2. | |
169 | */ | |
25ad00bb | 170 | et131x_soft_reset(etdev); |
cfb739b4 GKH |
171 | |
172 | /* setup et1310 as per the documentation ?? */ | |
25ad00bb | 173 | et131x_adapter_setup(etdev); |
cfb739b4 GKH |
174 | |
175 | /* Allow Tx to restart */ | |
f6b35d66 | 176 | etdev->Flags &= ~fMP_ADAPTER_LOWER_POWER; |
cfb739b4 GKH |
177 | |
178 | /* Need to re-enable Rx. */ | |
25ad00bb | 179 | et131x_rx_dma_enable(etdev); |
cfb739b4 GKH |
180 | } |
181 |