aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/hermes.c94
-rw-r--r--drivers/net/wireless/hermes.h3
2 files changed, 60 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);
diff --git a/drivers/net/wireless/hermes.h b/drivers/net/wireless/hermes.h
index 8e3f0e3edb58..287f5363fda2 100644
--- a/drivers/net/wireless/hermes.h
+++ b/drivers/net/wireless/hermes.h
@@ -353,6 +353,9 @@ void hermes_struct_init(hermes_t *hw, void __iomem *address, int reg_spacing);
353int hermes_init(hermes_t *hw); 353int hermes_init(hermes_t *hw);
354int hermes_docmd_wait(hermes_t *hw, u16 cmd, u16 parm0, 354int hermes_docmd_wait(hermes_t *hw, u16 cmd, u16 parm0,
355 struct hermes_response *resp); 355 struct hermes_response *resp);
356int hermes_doicmd_wait(hermes_t *hw, u16 cmd,
357 u16 parm0, u16 parm1, u16 parm2,
358 struct hermes_response *resp);
356int hermes_allocate(hermes_t *hw, u16 size, u16 *fid); 359int hermes_allocate(hermes_t *hw, u16 size, u16 *fid);
357 360
358int hermes_bap_pread(hermes_t *hw, int bap, void *buf, int len, 361int hermes_bap_pread(hermes_t *hw, int bap, void *buf, int len,