Commit 76a7f8fd authored by Mark Haverkamp's avatar Mark Haverkamp Committed by James Bottomley

[SCSI] aacraid: merge rx and rkt code

Received from Mark Salyzyn:

The only real difference between the rkt and rx platform modules is the
offset of the message registers. This patch recognizes this similarity
and simplifies the driver to reduce it's code footprint and to improve
maintainability by reducing the code duplication.

Visibly, the 'rkt.c' portion of this patch looks more complicated than
it really is. View it as retaining the rkt-only specifics of the
interface.
Signed-off-by: default avatarMark Haverkamp <markh@osdl.org>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 653ba58d
...@@ -494,6 +494,7 @@ struct adapter_ops ...@@ -494,6 +494,7 @@ struct adapter_ops
int (*adapter_sync_cmd)(struct aac_dev *dev, u32 command, u32 p1, u32 p2, u32 p3, u32 p4, u32 p5, u32 p6, u32 *status, u32 *r1, u32 *r2, u32 *r3, u32 *r4); int (*adapter_sync_cmd)(struct aac_dev *dev, u32 command, u32 p1, u32 p2, u32 p3, u32 p4, u32 p5, u32 p6, u32 *status, u32 *r1, u32 *r2, u32 *r3, u32 *r4);
int (*adapter_check_health)(struct aac_dev *dev); int (*adapter_check_health)(struct aac_dev *dev);
int (*adapter_send)(struct fib * fib); int (*adapter_send)(struct fib * fib);
int (*adapter_ioremap)(struct aac_dev * dev, u32 size);
}; };
/* /*
...@@ -682,14 +683,6 @@ struct rx_inbound { ...@@ -682,14 +683,6 @@ struct rx_inbound {
__le32 Mailbox[8]; __le32 Mailbox[8];
}; };
#define InboundMailbox0 IndexRegs.Mailbox[0]
#define InboundMailbox1 IndexRegs.Mailbox[1]
#define InboundMailbox2 IndexRegs.Mailbox[2]
#define InboundMailbox3 IndexRegs.Mailbox[3]
#define InboundMailbox4 IndexRegs.Mailbox[4]
#define InboundMailbox5 IndexRegs.Mailbox[5]
#define InboundMailbox6 IndexRegs.Mailbox[6]
#define INBOUNDDOORBELL_0 0x00000001 #define INBOUNDDOORBELL_0 0x00000001
#define INBOUNDDOORBELL_1 0x00000002 #define INBOUNDDOORBELL_1 0x00000002
#define INBOUNDDOORBELL_2 0x00000004 #define INBOUNDDOORBELL_2 0x00000004
...@@ -1010,6 +1003,8 @@ struct aac_dev ...@@ -1010,6 +1003,8 @@ struct aac_dev
struct rx_registers __iomem *rx; struct rx_registers __iomem *rx;
struct rkt_registers __iomem *rkt; struct rkt_registers __iomem *rkt;
} regs; } regs;
volatile void __iomem *base;
volatile struct rx_inbound __iomem *IndexRegs;
u32 OIMR; /* Mask Register Cache */ u32 OIMR; /* Mask Register Cache */
/* /*
* AIF thread states * AIF thread states
...@@ -1050,6 +1045,9 @@ struct aac_dev ...@@ -1050,6 +1045,9 @@ struct aac_dev
#define aac_adapter_send(fib) \ #define aac_adapter_send(fib) \
((fib)->dev)->a_ops.adapter_send(fib) ((fib)->dev)->a_ops.adapter_send(fib)
#define aac_adapter_ioremap(dev, size) \
(dev)->a_ops.adapter_ioremap(dev, size)
#define FIB_CONTEXT_FLAG_TIMED_OUT (0x00000001) #define FIB_CONTEXT_FLAG_TIMED_OUT (0x00000001)
/* /*
......
...@@ -307,17 +307,12 @@ struct aac_dev *aac_init_adapter(struct aac_dev *dev) ...@@ -307,17 +307,12 @@ struct aac_dev *aac_init_adapter(struct aac_dev *dev)
if (status[1] & AAC_OPT_NEW_COMM) if (status[1] & AAC_OPT_NEW_COMM)
dev->new_comm_interface = dev->a_ops.adapter_send != 0; dev->new_comm_interface = dev->a_ops.adapter_send != 0;
if (dev->new_comm_interface && (status[2] > dev->base_size)) { if (dev->new_comm_interface && (status[2] > dev->base_size)) {
iounmap(dev->regs.sa); aac_adapter_ioremap(dev, 0);
dev->base_size = status[2]; dev->base_size = status[2];
dprintk((KERN_DEBUG "ioremap(%lx,%d)\n", if (aac_adapter_ioremap(dev, status[2])) {
host->base, status[2]));
dev->regs.sa = ioremap(host->base, status[2]);
if (dev->regs.sa == NULL) {
/* remap failed, go back ... */ /* remap failed, go back ... */
dev->new_comm_interface = 0; dev->new_comm_interface = 0;
dev->regs.sa = ioremap(host->base, if (aac_adapter_ioremap(dev, AAC_MIN_FOOTPRINT_SIZE)) {
AAC_MIN_FOOTPRINT_SIZE);
if (dev->regs.sa == NULL) {
printk(KERN_WARNING printk(KERN_WARNING
"aacraid: unable to map adapter.\n"); "aacraid: unable to map adapter.\n");
return NULL; return NULL;
......
...@@ -867,13 +867,6 @@ static int __devinit aac_probe_one(struct pci_dev *pdev, ...@@ -867,13 +867,6 @@ static int __devinit aac_probe_one(struct pci_dev *pdev,
* Map in the registers from the adapter. * Map in the registers from the adapter.
*/ */
aac->base_size = AAC_MIN_FOOTPRINT_SIZE; aac->base_size = AAC_MIN_FOOTPRINT_SIZE;
if ((aac->regs.sa = ioremap(
(unsigned long)aac->scsi_host_ptr->base, AAC_MIN_FOOTPRINT_SIZE))
== NULL) {
printk(KERN_WARNING "%s: unable to map adapter.\n",
AAC_DRIVERNAME);
goto out_free_fibs;
}
if ((*aac_drivers[index].init)(aac)) if ((*aac_drivers[index].init)(aac))
goto out_unmap; goto out_unmap;
...@@ -972,8 +965,7 @@ static int __devinit aac_probe_one(struct pci_dev *pdev, ...@@ -972,8 +965,7 @@ static int __devinit aac_probe_one(struct pci_dev *pdev,
aac_fib_map_free(aac); aac_fib_map_free(aac);
pci_free_consistent(aac->pdev, aac->comm_size, aac->comm_addr, aac->comm_phys); pci_free_consistent(aac->pdev, aac->comm_size, aac->comm_addr, aac->comm_phys);
kfree(aac->queues); kfree(aac->queues);
iounmap(aac->regs.sa); aac_adapter_ioremap(aac, 0);
out_free_fibs:
kfree(aac->fibs); kfree(aac->fibs);
kfree(aac->fsa_dev); kfree(aac->fsa_dev);
out_free_host: out_free_host:
...@@ -1008,7 +1000,7 @@ static void __devexit aac_remove_one(struct pci_dev *pdev) ...@@ -1008,7 +1000,7 @@ static void __devexit aac_remove_one(struct pci_dev *pdev)
kfree(aac->queues); kfree(aac->queues);
free_irq(pdev->irq, aac); free_irq(pdev->irq, aac);
iounmap(aac->regs.sa); aac_adapter_ioremap(aac, 0);
kfree(aac->fibs); kfree(aac->fibs);
kfree(aac->fsa_dev); kfree(aac->fsa_dev);
......
This diff is collapsed.
...@@ -79,7 +79,7 @@ static irqreturn_t aac_rx_intr(int irq, void *dev_id, struct pt_regs *regs) ...@@ -79,7 +79,7 @@ static irqreturn_t aac_rx_intr(int irq, void *dev_id, struct pt_regs *regs)
{ {
bellbits = rx_readl(dev, OutboundDoorbellReg); bellbits = rx_readl(dev, OutboundDoorbellReg);
if (bellbits & DoorBellPrintfReady) { if (bellbits & DoorBellPrintfReady) {
aac_printf(dev, rx_readl (dev, IndexRegs.Mailbox[5])); aac_printf(dev, readl (&dev->IndexRegs->Mailbox[5]));
rx_writel(dev, MUnit.ODR,DoorBellPrintfReady); rx_writel(dev, MUnit.ODR,DoorBellPrintfReady);
rx_writel(dev, InboundDoorbellReg,DoorBellPrintfDone); rx_writel(dev, InboundDoorbellReg,DoorBellPrintfDone);
} }
...@@ -134,14 +134,14 @@ static int rx_sync_cmd(struct aac_dev *dev, u32 command, ...@@ -134,14 +134,14 @@ static int rx_sync_cmd(struct aac_dev *dev, u32 command,
/* /*
* Write the command into Mailbox 0 * Write the command into Mailbox 0
*/ */
rx_writel(dev, InboundMailbox0, command); writel(command, &dev->IndexRegs->Mailbox[0]);
/* /*
* Write the parameters into Mailboxes 1 - 6 * Write the parameters into Mailboxes 1 - 6
*/ */
rx_writel(dev, InboundMailbox1, p1); writel(p1, &dev->IndexRegs->Mailbox[1]);
rx_writel(dev, InboundMailbox2, p2); writel(p2, &dev->IndexRegs->Mailbox[2]);
rx_writel(dev, InboundMailbox3, p3); writel(p3, &dev->IndexRegs->Mailbox[3]);
rx_writel(dev, InboundMailbox4, p4); writel(p4, &dev->IndexRegs->Mailbox[4]);
/* /*
* Clear the synch command doorbell to start on a clean slate. * Clear the synch command doorbell to start on a clean slate.
*/ */
...@@ -199,15 +199,15 @@ static int rx_sync_cmd(struct aac_dev *dev, u32 command, ...@@ -199,15 +199,15 @@ static int rx_sync_cmd(struct aac_dev *dev, u32 command,
* Pull the synch status from Mailbox 0. * Pull the synch status from Mailbox 0.
*/ */
if (status) if (status)
*status = rx_readl(dev, IndexRegs.Mailbox[0]); *status = readl(&dev->IndexRegs->Mailbox[0]);
if (r1) if (r1)
*r1 = rx_readl(dev, IndexRegs.Mailbox[1]); *r1 = readl(&dev->IndexRegs->Mailbox[1]);
if (r2) if (r2)
*r2 = rx_readl(dev, IndexRegs.Mailbox[2]); *r2 = readl(&dev->IndexRegs->Mailbox[2]);
if (r3) if (r3)
*r3 = rx_readl(dev, IndexRegs.Mailbox[3]); *r3 = readl(&dev->IndexRegs->Mailbox[3]);
if (r4) if (r4)
*r4 = rx_readl(dev, IndexRegs.Mailbox[4]); *r4 = readl(&dev->IndexRegs->Mailbox[4]);
/* /*
* Clear the synch command doorbell. * Clear the synch command doorbell.
*/ */
...@@ -261,8 +261,6 @@ static void aac_rx_notify_adapter(struct aac_dev *dev, u32 event) ...@@ -261,8 +261,6 @@ static void aac_rx_notify_adapter(struct aac_dev *dev, u32 event)
rx_writel(dev, MUnit.IDR,INBOUNDDOORBELL_3); rx_writel(dev, MUnit.IDR,INBOUNDDOORBELL_3);
break; break;
case HostShutdown: case HostShutdown:
// rx_sync_cmd(dev, HOST_CRASHING, 0, 0, 0, 0, 0, 0,
// NULL, NULL, NULL, NULL, NULL);
break; break;
case FastIo: case FastIo:
rx_writel(dev, MUnit.IDR,INBOUNDDOORBELL_6); rx_writel(dev, MUnit.IDR,INBOUNDDOORBELL_6);
...@@ -283,7 +281,7 @@ static void aac_rx_notify_adapter(struct aac_dev *dev, u32 event) ...@@ -283,7 +281,7 @@ static void aac_rx_notify_adapter(struct aac_dev *dev, u32 event)
* Start up processing on an i960 based AAC adapter * Start up processing on an i960 based AAC adapter
*/ */
static void aac_rx_start_adapter(struct aac_dev *dev) void aac_rx_start_adapter(struct aac_dev *dev)
{ {
struct aac_init *init; struct aac_init *init;
...@@ -381,7 +379,7 @@ static int aac_rx_send(struct fib * fib) ...@@ -381,7 +379,7 @@ static int aac_rx_send(struct fib * fib)
dprintk((KERN_DEBUG "Index = 0x%x\n", Index)); dprintk((KERN_DEBUG "Index = 0x%x\n", Index));
if (Index == 0xFFFFFFFFL) if (Index == 0xFFFFFFFFL)
return Index; return Index;
device += Index; device = dev->base + Index;
dprintk((KERN_DEBUG "entry = %x %x %u\n", (u32)(addr & 0xffffffff), dprintk((KERN_DEBUG "entry = %x %x %u\n", (u32)(addr & 0xffffffff),
(u32)(addr >> 32), (u32)le16_to_cpu(fib->hw_fib->header.Size))); (u32)(addr >> 32), (u32)le16_to_cpu(fib->hw_fib->header.Size)));
writel((u32)(addr & 0xffffffff), device); writel((u32)(addr & 0xffffffff), device);
...@@ -394,6 +392,24 @@ static int aac_rx_send(struct fib * fib) ...@@ -394,6 +392,24 @@ static int aac_rx_send(struct fib * fib)
return 0; return 0;
} }
/**
* aac_rx_ioremap
* @size: mapping resize request
*
*/
static int aac_rx_ioremap(struct aac_dev * dev, u32 size)
{
if (!size) {
iounmap(dev->regs.rx);
return 0;
}
dev->base = dev->regs.rx = ioremap(dev->scsi_host_ptr->base, size);
if (dev->base == NULL)
return -1;
dev->IndexRegs = &dev->regs.rx->IndexRegs;
return 0;
}
static int aac_rx_restart_adapter(struct aac_dev *dev) static int aac_rx_restart_adapter(struct aac_dev *dev)
{ {
u32 var; u32 var;
...@@ -422,7 +438,7 @@ static int aac_rx_restart_adapter(struct aac_dev *dev) ...@@ -422,7 +438,7 @@ static int aac_rx_restart_adapter(struct aac_dev *dev)
* to the comm region. * to the comm region.
*/ */
int aac_rx_init(struct aac_dev *dev) int _aac_rx_init(struct aac_dev *dev)
{ {
unsigned long start; unsigned long start;
unsigned long status; unsigned long status;
...@@ -432,23 +448,30 @@ int aac_rx_init(struct aac_dev *dev) ...@@ -432,23 +448,30 @@ int aac_rx_init(struct aac_dev *dev)
instance = dev->id; instance = dev->id;
name = dev->name; name = dev->name;
if (aac_adapter_ioremap(dev, dev->base_size)) {
printk(KERN_WARNING "%s: unable to map adapter.\n", name);
goto error_iounmap;
}
/* /*
* Check to see if the board panic'd while booting. * Check to see if the board panic'd while booting.
*/ */
if (rx_readl(dev, MUnit.OMRx[0]) & KERNEL_PANIC) status = rx_readl(dev, MUnit.OMRx[0]);
if (status & KERNEL_PANIC)
if (aac_rx_restart_adapter(dev)) if (aac_rx_restart_adapter(dev))
goto error_iounmap; goto error_iounmap;
/* /*
* Check to see if the board failed any self tests. * Check to see if the board failed any self tests.
*/ */
if (rx_readl(dev, MUnit.OMRx[0]) & SELF_TEST_FAILED) { status = rx_readl(dev, MUnit.OMRx[0]);
if (status & SELF_TEST_FAILED) {
printk(KERN_ERR "%s%d: adapter self-test failed.\n", dev->name, instance); printk(KERN_ERR "%s%d: adapter self-test failed.\n", dev->name, instance);
goto error_iounmap; goto error_iounmap;
} }
/* /*
* Check to see if the monitor panic'd while booting. * Check to see if the monitor panic'd while booting.
*/ */
if (rx_readl(dev, MUnit.OMRx[0]) & MONITOR_PANIC) { if (status & MONITOR_PANIC) {
printk(KERN_ERR "%s%d: adapter monitor panic.\n", dev->name, instance); printk(KERN_ERR "%s%d: adapter monitor panic.\n", dev->name, instance);
goto error_iounmap; goto error_iounmap;
} }
...@@ -456,12 +479,10 @@ int aac_rx_init(struct aac_dev *dev) ...@@ -456,12 +479,10 @@ int aac_rx_init(struct aac_dev *dev)
/* /*
* Wait for the adapter to be up and running. Wait up to 3 minutes * Wait for the adapter to be up and running. Wait up to 3 minutes
*/ */
while ((!(rx_readl(dev, IndexRegs.Mailbox[7]) & KERNEL_UP_AND_RUNNING)) while (!((status = rx_readl(dev, MUnit.OMRx[0])) & KERNEL_UP_AND_RUNNING))
|| (!(rx_readl(dev, MUnit.OMRx[0]) & KERNEL_UP_AND_RUNNING)))
{ {
if(time_after(jiffies, start+startup_timeout*HZ)) if(time_after(jiffies, start+startup_timeout*HZ))
{ {
status = rx_readl(dev, IndexRegs.Mailbox[7]);
printk(KERN_ERR "%s%d: adapter kernel failed to start, init status = %lx.\n", printk(KERN_ERR "%s%d: adapter kernel failed to start, init status = %lx.\n",
dev->name, instance, status); dev->name, instance, status);
goto error_iounmap; goto error_iounmap;
...@@ -496,11 +517,6 @@ int aac_rx_init(struct aac_dev *dev) ...@@ -496,11 +517,6 @@ int aac_rx_init(struct aac_dev *dev)
if (dev->new_comm_interface) if (dev->new_comm_interface)
rx_writeb(dev, MUnit.OIMR, dev->OIMR = 0xf7); rx_writeb(dev, MUnit.OIMR, dev->OIMR = 0xf7);
/*
* Tell the adapter that all is configured, and it can start
* accepting requests
*/
aac_rx_start_adapter(dev);
return 0; return 0;
error_irq: error_irq:
...@@ -511,3 +527,23 @@ error_iounmap: ...@@ -511,3 +527,23 @@ error_iounmap:
return -1; return -1;
} }
int aac_rx_init(struct aac_dev *dev)
{
int retval;
/*
* Fill in the function dispatch table.
*/
dev->a_ops.adapter_ioremap = aac_rx_ioremap;
retval = _aac_rx_init(dev);
if (!retval) {
/*
* Tell the adapter that all is configured, and it can
* start accepting requests
*/
aac_rx_start_adapter(dev);
}
return retval;
}
...@@ -280,6 +280,21 @@ static int aac_sa_check_health(struct aac_dev *dev) ...@@ -280,6 +280,21 @@ static int aac_sa_check_health(struct aac_dev *dev)
return 0; return 0;
} }
/**
* aac_sa_ioremap
* @size: mapping resize request
*
*/
static int aac_sa_ioremap(struct aac_dev * dev, u32 size)
{
if (!size) {
iounmap(dev->regs.sa);
return 0;
}
dev->base = dev->regs.sa = ioremap(dev->scsi_host_ptr->base, size);
return (dev->base == NULL) ? -1 : 0;
}
/** /**
* aac_sa_init - initialize an ARM based AAC card * aac_sa_init - initialize an ARM based AAC card
* @dev: device to configure * @dev: device to configure
...@@ -299,6 +314,11 @@ int aac_sa_init(struct aac_dev *dev) ...@@ -299,6 +314,11 @@ int aac_sa_init(struct aac_dev *dev)
instance = dev->id; instance = dev->id;
name = dev->name; name = dev->name;
if (aac_sa_ioremap(dev, dev->base_size)) {
printk(KERN_WARNING "%s: unable to map adapter.\n", name);
goto error_iounmap;
}
/* /*
* Check to see if the board failed any self tests. * Check to see if the board failed any self tests.
*/ */
...@@ -341,6 +361,7 @@ int aac_sa_init(struct aac_dev *dev) ...@@ -341,6 +361,7 @@ int aac_sa_init(struct aac_dev *dev)
dev->a_ops.adapter_notify = aac_sa_notify_adapter; dev->a_ops.adapter_notify = aac_sa_notify_adapter;
dev->a_ops.adapter_sync_cmd = sa_sync_cmd; dev->a_ops.adapter_sync_cmd = sa_sync_cmd;
dev->a_ops.adapter_check_health = aac_sa_check_health; dev->a_ops.adapter_check_health = aac_sa_check_health;
dev->a_ops.adapter_ioremap = aac_sa_ioremap;
/* /*
* First clear out all interrupts. Then enable the one's that * First clear out all interrupts. Then enable the one's that
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment