aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/aacraid/rx.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/aacraid/rx.c')
-rw-r--r--drivers/scsi/aacraid/rx.c117
1 files changed, 84 insertions, 33 deletions
diff --git a/drivers/scsi/aacraid/rx.c b/drivers/scsi/aacraid/rx.c
index 035018db69b1..a1d214d770eb 100644
--- a/drivers/scsi/aacraid/rx.c
+++ b/drivers/scsi/aacraid/rx.c
@@ -79,7 +79,7 @@ static irqreturn_t aac_rx_intr(int irq, void *dev_id, struct pt_regs *regs)
79 { 79 {
80 bellbits = rx_readl(dev, OutboundDoorbellReg); 80 bellbits = rx_readl(dev, OutboundDoorbellReg);
81 if (bellbits & DoorBellPrintfReady) { 81 if (bellbits & DoorBellPrintfReady) {
82 aac_printf(dev, rx_readl (dev, IndexRegs.Mailbox[5])); 82 aac_printf(dev, readl (&dev->IndexRegs->Mailbox[5]));
83 rx_writel(dev, MUnit.ODR,DoorBellPrintfReady); 83 rx_writel(dev, MUnit.ODR,DoorBellPrintfReady);
84 rx_writel(dev, InboundDoorbellReg,DoorBellPrintfDone); 84 rx_writel(dev, InboundDoorbellReg,DoorBellPrintfDone);
85 } 85 }
@@ -134,14 +134,14 @@ static int rx_sync_cmd(struct aac_dev *dev, u32 command,
134 /* 134 /*
135 * Write the command into Mailbox 0 135 * Write the command into Mailbox 0
136 */ 136 */
137 rx_writel(dev, InboundMailbox0, command); 137 writel(command, &dev->IndexRegs->Mailbox[0]);
138 /* 138 /*
139 * Write the parameters into Mailboxes 1 - 6 139 * Write the parameters into Mailboxes 1 - 6
140 */ 140 */
141 rx_writel(dev, InboundMailbox1, p1); 141 writel(p1, &dev->IndexRegs->Mailbox[1]);
142 rx_writel(dev, InboundMailbox2, p2); 142 writel(p2, &dev->IndexRegs->Mailbox[2]);
143 rx_writel(dev, InboundMailbox3, p3); 143 writel(p3, &dev->IndexRegs->Mailbox[3]);
144 rx_writel(dev, InboundMailbox4, p4); 144 writel(p4, &dev->IndexRegs->Mailbox[4]);
145 /* 145 /*
146 * Clear the synch command doorbell to start on a clean slate. 146 * Clear the synch command doorbell to start on a clean slate.
147 */ 147 */
@@ -199,15 +199,15 @@ static int rx_sync_cmd(struct aac_dev *dev, u32 command,
199 * Pull the synch status from Mailbox 0. 199 * Pull the synch status from Mailbox 0.
200 */ 200 */
201 if (status) 201 if (status)
202 *status = rx_readl(dev, IndexRegs.Mailbox[0]); 202 *status = readl(&dev->IndexRegs->Mailbox[0]);
203 if (r1) 203 if (r1)
204 *r1 = rx_readl(dev, IndexRegs.Mailbox[1]); 204 *r1 = readl(&dev->IndexRegs->Mailbox[1]);
205 if (r2) 205 if (r2)
206 *r2 = rx_readl(dev, IndexRegs.Mailbox[2]); 206 *r2 = readl(&dev->IndexRegs->Mailbox[2]);
207 if (r3) 207 if (r3)
208 *r3 = rx_readl(dev, IndexRegs.Mailbox[3]); 208 *r3 = readl(&dev->IndexRegs->Mailbox[3]);
209 if (r4) 209 if (r4)
210 *r4 = rx_readl(dev, IndexRegs.Mailbox[4]); 210 *r4 = readl(&dev->IndexRegs->Mailbox[4]);
211 /* 211 /*
212 * Clear the synch command doorbell. 212 * Clear the synch command doorbell.
213 */ 213 */
@@ -261,8 +261,6 @@ static void aac_rx_notify_adapter(struct aac_dev *dev, u32 event)
261 rx_writel(dev, MUnit.IDR,INBOUNDDOORBELL_3); 261 rx_writel(dev, MUnit.IDR,INBOUNDDOORBELL_3);
262 break; 262 break;
263 case HostShutdown: 263 case HostShutdown:
264// rx_sync_cmd(dev, HOST_CRASHING, 0, 0, 0, 0, 0, 0,
265// NULL, NULL, NULL, NULL, NULL);
266 break; 264 break;
267 case FastIo: 265 case FastIo:
268 rx_writel(dev, MUnit.IDR,INBOUNDDOORBELL_6); 266 rx_writel(dev, MUnit.IDR,INBOUNDDOORBELL_6);
@@ -283,7 +281,7 @@ static void aac_rx_notify_adapter(struct aac_dev *dev, u32 event)
283 * Start up processing on an i960 based AAC adapter 281 * Start up processing on an i960 based AAC adapter
284 */ 282 */
285 283
286static void aac_rx_start_adapter(struct aac_dev *dev) 284void aac_rx_start_adapter(struct aac_dev *dev)
287{ 285{
288 struct aac_init *init; 286 struct aac_init *init;
289 287
@@ -381,7 +379,7 @@ static int aac_rx_send(struct fib * fib)
381 dprintk((KERN_DEBUG "Index = 0x%x\n", Index)); 379 dprintk((KERN_DEBUG "Index = 0x%x\n", Index));
382 if (Index == 0xFFFFFFFFL) 380 if (Index == 0xFFFFFFFFL)
383 return Index; 381 return Index;
384 device += Index; 382 device = dev->base + Index;
385 dprintk((KERN_DEBUG "entry = %x %x %u\n", (u32)(addr & 0xffffffff), 383 dprintk((KERN_DEBUG "entry = %x %x %u\n", (u32)(addr & 0xffffffff),
386 (u32)(addr >> 32), (u32)le16_to_cpu(fib->hw_fib->header.Size))); 384 (u32)(addr >> 32), (u32)le16_to_cpu(fib->hw_fib->header.Size)));
387 writel((u32)(addr & 0xffffffff), device); 385 writel((u32)(addr & 0xffffffff), device);
@@ -395,6 +393,43 @@ static int aac_rx_send(struct fib * fib)
395} 393}
396 394
397/** 395/**
396 * aac_rx_ioremap
397 * @size: mapping resize request
398 *
399 */
400static int aac_rx_ioremap(struct aac_dev * dev, u32 size)
401{
402 if (!size) {
403 iounmap(dev->regs.rx);
404 return 0;
405 }
406 dev->base = dev->regs.rx = ioremap(dev->scsi_host_ptr->base, size);
407 if (dev->base == NULL)
408 return -1;
409 dev->IndexRegs = &dev->regs.rx->IndexRegs;
410 return 0;
411}
412
413static int aac_rx_restart_adapter(struct aac_dev *dev)
414{
415 u32 var;
416
417 printk(KERN_ERR "%s%d: adapter kernel panic'd.\n",
418 dev->name, dev->id);
419
420 if (aac_rx_check_health(dev) <= 0)
421 return 1;
422 if (rx_sync_cmd(dev, IOP_RESET, 0, 0, 0, 0, 0, 0,
423 &var, NULL, NULL, NULL, NULL))
424 return 1;
425 if (var != 0x00000001)
426 return 1;
427 if (rx_readl(dev, MUnit.OMRx[0]) & KERNEL_PANIC)
428 return 1;
429 return 0;
430}
431
432/**
398 * aac_rx_init - initialize an i960 based AAC card 433 * aac_rx_init - initialize an i960 based AAC card
399 * @dev: device to configure 434 * @dev: device to configure
400 * 435 *
@@ -403,7 +438,7 @@ static int aac_rx_send(struct fib * fib)
403 * to the comm region. 438 * to the comm region.
404 */ 439 */
405 440
406int aac_rx_init(struct aac_dev *dev) 441int _aac_rx_init(struct aac_dev *dev)
407{ 442{
408 unsigned long start; 443 unsigned long start;
409 unsigned long status; 444 unsigned long status;
@@ -413,27 +448,30 @@ int aac_rx_init(struct aac_dev *dev)
413 instance = dev->id; 448 instance = dev->id;
414 name = dev->name; 449 name = dev->name;
415 450
451 if (aac_adapter_ioremap(dev, dev->base_size)) {
452 printk(KERN_WARNING "%s: unable to map adapter.\n", name);
453 goto error_iounmap;
454 }
455
416 /* 456 /*
417 * Check to see if the board panic'd while booting. 457 * Check to see if the board panic'd while booting.
418 */ 458 */
459 status = rx_readl(dev, MUnit.OMRx[0]);
460 if (status & KERNEL_PANIC)
461 if (aac_rx_restart_adapter(dev))
462 goto error_iounmap;
419 /* 463 /*
420 * Check to see if the board failed any self tests. 464 * Check to see if the board failed any self tests.
421 */ 465 */
422 if (rx_readl(dev, MUnit.OMRx[0]) & SELF_TEST_FAILED) { 466 status = rx_readl(dev, MUnit.OMRx[0]);
467 if (status & SELF_TEST_FAILED) {
423 printk(KERN_ERR "%s%d: adapter self-test failed.\n", dev->name, instance); 468 printk(KERN_ERR "%s%d: adapter self-test failed.\n", dev->name, instance);
424 goto error_iounmap; 469 goto error_iounmap;
425 } 470 }
426 /* 471 /*
427 * Check to see if the board panic'd while booting.
428 */
429 if (rx_readl(dev, MUnit.OMRx[0]) & KERNEL_PANIC) {
430 printk(KERN_ERR "%s%d: adapter kernel panic.\n", dev->name, instance);
431 goto error_iounmap;
432 }
433 /*
434 * Check to see if the monitor panic'd while booting. 472 * Check to see if the monitor panic'd while booting.
435 */ 473 */
436 if (rx_readl(dev, MUnit.OMRx[0]) & MONITOR_PANIC) { 474 if (status & MONITOR_PANIC) {
437 printk(KERN_ERR "%s%d: adapter monitor panic.\n", dev->name, instance); 475 printk(KERN_ERR "%s%d: adapter monitor panic.\n", dev->name, instance);
438 goto error_iounmap; 476 goto error_iounmap;
439 } 477 }
@@ -441,12 +479,10 @@ int aac_rx_init(struct aac_dev *dev)
441 /* 479 /*
442 * Wait for the adapter to be up and running. Wait up to 3 minutes 480 * Wait for the adapter to be up and running. Wait up to 3 minutes
443 */ 481 */
444 while ((!(rx_readl(dev, IndexRegs.Mailbox[7]) & KERNEL_UP_AND_RUNNING)) 482 while (!((status = rx_readl(dev, MUnit.OMRx[0])) & KERNEL_UP_AND_RUNNING))
445 || (!(rx_readl(dev, MUnit.OMRx[0]) & KERNEL_UP_AND_RUNNING)))
446 { 483 {
447 if(time_after(jiffies, start+startup_timeout*HZ)) 484 if(time_after(jiffies, start+startup_timeout*HZ))
448 { 485 {
449 status = rx_readl(dev, IndexRegs.Mailbox[7]);
450 printk(KERN_ERR "%s%d: adapter kernel failed to start, init status = %lx.\n", 486 printk(KERN_ERR "%s%d: adapter kernel failed to start, init status = %lx.\n",
451 dev->name, instance, status); 487 dev->name, instance, status);
452 goto error_iounmap; 488 goto error_iounmap;
@@ -481,11 +517,6 @@ int aac_rx_init(struct aac_dev *dev)
481 if (dev->new_comm_interface) 517 if (dev->new_comm_interface)
482 rx_writeb(dev, MUnit.OIMR, dev->OIMR = 0xf7); 518 rx_writeb(dev, MUnit.OIMR, dev->OIMR = 0xf7);
483 519
484 /*
485 * Tell the adapter that all is configured, and it can start
486 * accepting requests
487 */
488 aac_rx_start_adapter(dev);
489 return 0; 520 return 0;
490 521
491error_irq: 522error_irq:
@@ -496,3 +527,23 @@ error_iounmap:
496 527
497 return -1; 528 return -1;
498} 529}
530
531int aac_rx_init(struct aac_dev *dev)
532{
533 int retval;
534
535 /*
536 * Fill in the function dispatch table.
537 */
538 dev->a_ops.adapter_ioremap = aac_rx_ioremap;
539
540 retval = _aac_rx_init(dev);
541 if (!retval) {
542 /*
543 * Tell the adapter that all is configured, and it can
544 * start accepting requests
545 */
546 aac_rx_start_adapter(dev);
547 }
548 return retval;
549}