aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/legacy
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/legacy')
-rw-r--r--drivers/ide/legacy/ide-cs.c60
1 files changed, 28 insertions, 32 deletions
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c
index 70bb1b8bab09..58690c1ff6ba 100644
--- a/drivers/ide/legacy/ide-cs.c
+++ b/drivers/ide/legacy/ide-cs.c
@@ -87,8 +87,8 @@ typedef struct ide_info_t {
87 int hd; 87 int hd;
88} ide_info_t; 88} ide_info_t;
89 89
90static void ide_release(dev_link_t *); 90static void ide_release(struct pcmcia_device *);
91static void ide_config(dev_link_t *); 91static void ide_config(struct pcmcia_device *);
92 92
93static void ide_detach(struct pcmcia_device *p_dev); 93static void ide_detach(struct pcmcia_device *p_dev);
94 94
@@ -103,10 +103,9 @@ static void ide_detach(struct pcmcia_device *p_dev);
103 103
104======================================================================*/ 104======================================================================*/
105 105
106static int ide_attach(struct pcmcia_device *p_dev) 106static int ide_attach(struct pcmcia_device *link)
107{ 107{
108 ide_info_t *info; 108 ide_info_t *info;
109 dev_link_t *link = dev_to_instance(p_dev);
110 109
111 DEBUG(0, "ide_attach()\n"); 110 DEBUG(0, "ide_attach()\n");
112 111
@@ -115,7 +114,7 @@ static int ide_attach(struct pcmcia_device *p_dev)
115 if (!info) 114 if (!info)
116 return -ENOMEM; 115 return -ENOMEM;
117 116
118 info->p_dev = p_dev; 117 info->p_dev = link;
119 link->priv = info; 118 link->priv = info;
120 119
121 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 120 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
@@ -141,10 +140,8 @@ static int ide_attach(struct pcmcia_device *p_dev)
141 140
142======================================================================*/ 141======================================================================*/
143 142
144static void ide_detach(struct pcmcia_device *p_dev) 143static void ide_detach(struct pcmcia_device *link)
145{ 144{
146 dev_link_t *link = dev_to_instance(p_dev);
147
148 DEBUG(0, "ide_detach(0x%p)\n", link); 145 DEBUG(0, "ide_detach(0x%p)\n", link);
149 146
150 if (link->state & DEV_CONFIG) 147 if (link->state & DEV_CONFIG)
@@ -175,9 +172,8 @@ static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq
175#define CS_CHECK(fn, ret) \ 172#define CS_CHECK(fn, ret) \
176do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 173do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
177 174
178static void ide_config(dev_link_t *link) 175static void ide_config(struct pcmcia_device *link)
179{ 176{
180 client_handle_t handle = link->handle;
181 ide_info_t *info = link->priv; 177 ide_info_t *info = link->priv;
182 tuple_t tuple; 178 tuple_t tuple;
183 struct { 179 struct {
@@ -201,16 +197,16 @@ static void ide_config(dev_link_t *link)
201 tuple.TupleDataMax = 255; 197 tuple.TupleDataMax = 255;
202 tuple.Attributes = 0; 198 tuple.Attributes = 0;
203 tuple.DesiredTuple = CISTPL_CONFIG; 199 tuple.DesiredTuple = CISTPL_CONFIG;
204 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 200 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
205 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 201 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
206 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &stk->parse)); 202 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &stk->parse));
207 link->conf.ConfigBase = stk->parse.config.base; 203 link->conf.ConfigBase = stk->parse.config.base;
208 link->conf.Present = stk->parse.config.rmask[0]; 204 link->conf.Present = stk->parse.config.rmask[0];
209 205
210 tuple.DesiredTuple = CISTPL_MANFID; 206 tuple.DesiredTuple = CISTPL_MANFID;
211 if (!pcmcia_get_first_tuple(handle, &tuple) && 207 if (!pcmcia_get_first_tuple(link, &tuple) &&
212 !pcmcia_get_tuple_data(handle, &tuple) && 208 !pcmcia_get_tuple_data(link, &tuple) &&
213 !pcmcia_parse_tuple(handle, &tuple, &stk->parse)) 209 !pcmcia_parse_tuple(link, &tuple, &stk->parse))
214 is_kme = ((stk->parse.manfid.manf == MANFID_KME) && 210 is_kme = ((stk->parse.manfid.manf == MANFID_KME) &&
215 ((stk->parse.manfid.card == PRODID_KME_KXLC005_A) || 211 ((stk->parse.manfid.card == PRODID_KME_KXLC005_A) ||
216 (stk->parse.manfid.card == PRODID_KME_KXLC005_B))); 212 (stk->parse.manfid.card == PRODID_KME_KXLC005_B)));
@@ -219,15 +215,15 @@ static void ide_config(dev_link_t *link)
219 link->state |= DEV_CONFIG; 215 link->state |= DEV_CONFIG;
220 216
221 /* Not sure if this is right... look up the current Vcc */ 217 /* Not sure if this is right... look up the current Vcc */
222 CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(handle, &stk->conf)); 218 CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &stk->conf));
223 219
224 pass = io_base = ctl_base = 0; 220 pass = io_base = ctl_base = 0;
225 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 221 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
226 tuple.Attributes = 0; 222 tuple.Attributes = 0;
227 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 223 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
228 while (1) { 224 while (1) {
229 if (pcmcia_get_tuple_data(handle, &tuple) != 0) goto next_entry; 225 if (pcmcia_get_tuple_data(link, &tuple) != 0) goto next_entry;
230 if (pcmcia_parse_tuple(handle, &tuple, &stk->parse) != 0) goto next_entry; 226 if (pcmcia_parse_tuple(link, &tuple, &stk->parse) != 0) goto next_entry;
231 227
232 /* Check for matching Vcc, unless we're desperate */ 228 /* Check for matching Vcc, unless we're desperate */
233 if (!pass) { 229 if (!pass) {
@@ -258,14 +254,14 @@ static void ide_config(dev_link_t *link)
258 link->io.NumPorts1 = 8; 254 link->io.NumPorts1 = 8;
259 link->io.BasePort2 = io->win[1].base; 255 link->io.BasePort2 = io->win[1].base;
260 link->io.NumPorts2 = (is_kme) ? 2 : 1; 256 link->io.NumPorts2 = (is_kme) ? 2 : 1;
261 if (pcmcia_request_io(link->handle, &link->io) != 0) 257 if (pcmcia_request_io(link, &link->io) != 0)
262 goto next_entry; 258 goto next_entry;
263 io_base = link->io.BasePort1; 259 io_base = link->io.BasePort1;
264 ctl_base = link->io.BasePort2; 260 ctl_base = link->io.BasePort2;
265 } else if ((io->nwin == 1) && (io->win[0].len >= 16)) { 261 } else if ((io->nwin == 1) && (io->win[0].len >= 16)) {
266 link->io.NumPorts1 = io->win[0].len; 262 link->io.NumPorts1 = io->win[0].len;
267 link->io.NumPorts2 = 0; 263 link->io.NumPorts2 = 0;
268 if (pcmcia_request_io(link->handle, &link->io) != 0) 264 if (pcmcia_request_io(link, &link->io) != 0)
269 goto next_entry; 265 goto next_entry;
270 io_base = link->io.BasePort1; 266 io_base = link->io.BasePort1;
271 ctl_base = link->io.BasePort1 + 0x0e; 267 ctl_base = link->io.BasePort1 + 0x0e;
@@ -278,16 +274,16 @@ static void ide_config(dev_link_t *link)
278 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) 274 if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
279 memcpy(&stk->dflt, cfg, sizeof(stk->dflt)); 275 memcpy(&stk->dflt, cfg, sizeof(stk->dflt));
280 if (pass) { 276 if (pass) {
281 CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple)); 277 CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple));
282 } else if (pcmcia_get_next_tuple(handle, &tuple) != 0) { 278 } else if (pcmcia_get_next_tuple(link, &tuple) != 0) {
283 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 279 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
284 memset(&stk->dflt, 0, sizeof(stk->dflt)); 280 memset(&stk->dflt, 0, sizeof(stk->dflt));
285 pass++; 281 pass++;
286 } 282 }
287 } 283 }
288 284
289 CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq)); 285 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
290 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf)); 286 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
291 287
292 /* disable drive interrupts during IDE probe */ 288 /* disable drive interrupts during IDE probe */
293 outb(0x02, ctl_base); 289 outb(0x02, ctl_base);
@@ -298,12 +294,12 @@ static void ide_config(dev_link_t *link)
298 294
299 /* retry registration in case device is still spinning up */ 295 /* retry registration in case device is still spinning up */
300 for (hd = -1, i = 0; i < 10; i++) { 296 for (hd = -1, i = 0; i < 10; i++) {
301 hd = idecs_register(io_base, ctl_base, link->irq.AssignedIRQ, handle); 297 hd = idecs_register(io_base, ctl_base, link->irq.AssignedIRQ, link);
302 if (hd >= 0) break; 298 if (hd >= 0) break;
303 if (link->io.NumPorts1 == 0x20) { 299 if (link->io.NumPorts1 == 0x20) {
304 outb(0x02, ctl_base + 0x10); 300 outb(0x02, ctl_base + 0x10);
305 hd = idecs_register(io_base + 0x10, ctl_base + 0x10, 301 hd = idecs_register(io_base + 0x10, ctl_base + 0x10,
306 link->irq.AssignedIRQ, handle); 302 link->irq.AssignedIRQ, link);
307 if (hd >= 0) { 303 if (hd >= 0) {
308 io_base += 0x10; 304 io_base += 0x10;
309 ctl_base += 0x10; 305 ctl_base += 0x10;
@@ -338,7 +334,7 @@ err_mem:
338 goto failed; 334 goto failed;
339 335
340cs_failed: 336cs_failed:
341 cs_error(link->handle, last_fn, last_ret); 337 cs_error(link, last_fn, last_ret);
342failed: 338failed:
343 kfree(stk); 339 kfree(stk);
344 ide_release(link); 340 ide_release(link);
@@ -353,7 +349,7 @@ failed:
353 349
354======================================================================*/ 350======================================================================*/
355 351
356void ide_release(dev_link_t *link) 352void ide_release(struct pcmcia_device *link)
357{ 353{
358 ide_info_t *info = link->priv; 354 ide_info_t *info = link->priv;
359 355
@@ -366,7 +362,7 @@ void ide_release(dev_link_t *link)
366 } 362 }
367 info->ndev = 0; 363 info->ndev = 0;
368 364
369 pcmcia_disable_device(link->handle); 365 pcmcia_disable_device(link);
370} /* ide_release */ 366} /* ide_release */
371 367
372 368