aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/hermes.c
diff options
context:
space:
mode:
authorDavid Kilroy <kilroyd@gmail.com>2008-08-21 18:27:50 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-08-22 19:28:04 -0400
commitfc5a62d8b7052ea588e4f7750cd78b0c4c47015a (patch)
treecf25f5749da81c0a0a13986315486fdaf42e1fe7 /drivers/net/wireless/hermes.c
parent82a06ee518f570eb8fbb6588e75a4a5d838ac901 (diff)
orinoco: Add function to execute Hermes initialisation commands synchronously
The current synchronous execution function doesn't work for certain Hermes commands which clear the MAGIC number from SWSUPPORT0. These commands seem to be related to initialisation or programming, for example HERMES_CMD_INIT. Replicate hermes_docmd_wait for commands which clear the MAGIC number from SWSUPPORT0. This version accepts two extra arguments which are passed straight to the firmware. Functionality copied out of hermes_init. Signed-off-by: David Kilroy <kilroyd@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/hermes.c')
-rw-r--r--drivers/net/wireless/hermes.c94
1 files changed, 57 insertions, 37 deletions
diff --git a/drivers/net/wireless/hermes.c b/drivers/net/wireless/hermes.c
index 240118f33585..bfa375369df3 100644
--- a/drivers/net/wireless/hermes.c
+++ b/drivers/net/wireless/hermes.c
@@ -116,6 +116,61 @@ static int hermes_issue_cmd(hermes_t *hw, u16 cmd, u16 param0,
116 * Function definitions 116 * Function definitions
117 */ 117 */
118 118
119/* For doing cmds that wipe the magic constant in SWSUPPORT0 */
120int hermes_doicmd_wait(hermes_t *hw, u16 cmd,
121 u16 parm0, u16 parm1, u16 parm2,
122 struct hermes_response *resp)
123{
124 int err = 0;
125 int k;
126 u16 status, reg;
127
128 err = hermes_issue_cmd(hw, cmd, parm0, parm1, parm2);
129 if (err)
130 return err;
131
132 reg = hermes_read_regn(hw, EVSTAT);
133 k = CMD_INIT_TIMEOUT;
134 while ((!(reg & HERMES_EV_CMD)) && k) {
135 k--;
136 udelay(10);
137 reg = hermes_read_regn(hw, EVSTAT);
138 }
139
140 hermes_write_regn(hw, SWSUPPORT0, HERMES_MAGIC);
141
142 if (!hermes_present(hw)) {
143 DEBUG(0, "hermes @ 0x%x: Card removed during reset.\n",
144 hw->iobase);
145 err = -ENODEV;
146 goto out;
147 }
148
149 if (!(reg & HERMES_EV_CMD)) {
150 printk(KERN_ERR "hermes @ %p: "
151 "Timeout waiting for card to reset (reg=0x%04x)!\n",
152 hw->iobase, reg);
153 err = -ETIMEDOUT;
154 goto out;
155 }
156
157 status = hermes_read_regn(hw, STATUS);
158 if (resp) {
159 resp->status = status;
160 resp->resp0 = hermes_read_regn(hw, RESP0);
161 resp->resp1 = hermes_read_regn(hw, RESP1);
162 resp->resp2 = hermes_read_regn(hw, RESP2);
163 }
164
165 hermes_write_regn(hw, EVACK, HERMES_EV_CMD);
166
167 if (status & HERMES_STATUS_RESULT)
168 err = -EIO;
169out:
170 return err;
171}
172EXPORT_SYMBOL(hermes_doicmd_wait);
173
119void hermes_struct_init(hermes_t *hw, void __iomem *address, int reg_spacing) 174void hermes_struct_init(hermes_t *hw, void __iomem *address, int reg_spacing)
120{ 175{
121 hw->iobase = address; 176 hw->iobase = address;
@@ -126,7 +181,7 @@ EXPORT_SYMBOL(hermes_struct_init);
126 181
127int hermes_init(hermes_t *hw) 182int hermes_init(hermes_t *hw)
128{ 183{
129 u16 status, reg; 184 u16 reg;
130 int err = 0; 185 int err = 0;
131 int k; 186 int k;
132 187
@@ -164,43 +219,8 @@ int hermes_init(hermes_t *hw)
164 219
165 /* We don't use hermes_docmd_wait here, because the reset wipes 220 /* We don't use hermes_docmd_wait here, because the reset wipes
166 the magic constant in SWSUPPORT0 away, and it gets confused */ 221 the magic constant in SWSUPPORT0 away, and it gets confused */
167 err = hermes_issue_cmd(hw, HERMES_CMD_INIT, 0, 0, 0); 222 err = hermes_doicmd_wait(hw, HERMES_CMD_INIT, 0, 0, 0, NULL);
168 if (err)
169 return err;
170
171 reg = hermes_read_regn(hw, EVSTAT);
172 k = CMD_INIT_TIMEOUT;
173 while ( (! (reg & HERMES_EV_CMD)) && k) {
174 k--;
175 udelay(10);
176 reg = hermes_read_regn(hw, EVSTAT);
177 }
178
179 hermes_write_regn(hw, SWSUPPORT0, HERMES_MAGIC);
180
181 if (! hermes_present(hw)) {
182 DEBUG(0, "hermes @ 0x%x: Card removed during reset.\n",
183 hw->iobase);
184 err = -ENODEV;
185 goto out;
186 }
187
188 if (! (reg & HERMES_EV_CMD)) {
189 printk(KERN_ERR "hermes @ %p: "
190 "Timeout waiting for card to reset (reg=0x%04x)!\n",
191 hw->iobase, reg);
192 err = -ETIMEDOUT;
193 goto out;
194 }
195
196 status = hermes_read_regn(hw, STATUS);
197
198 hermes_write_regn(hw, EVACK, HERMES_EV_CMD);
199 223
200 if (status & HERMES_STATUS_RESULT)
201 err = -EIO;
202
203 out:
204 return err; 224 return err;
205} 225}
206EXPORT_SYMBOL(hermes_init); 226EXPORT_SYMBOL(hermes_init);