Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Adaptec AAC series RAID controller driver |
Alan Cox | fa195af | 2008-10-27 15:16:36 +0000 | [diff] [blame] | 3 | * (c) Copyright 2001 Red Hat Inc. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
| 5 | * based on the old aacraid driver that is.. |
| 6 | * Adaptec aacraid device driver for Linux. |
| 7 | * |
Mahesh Rajashekhara | e8b12f0 | 2011-03-17 02:10:32 -0700 | [diff] [blame] | 8 | * Copyright (c) 2000-2010 Adaptec, Inc. |
| 9 | * 2010 PMC-Sierra, Inc. (aacraid@pmc-sierra.com) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2, or (at your option) |
| 14 | * any later version. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; see the file COPYING. If not, write to |
| 23 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
| 24 | * |
| 25 | * Module Name: |
| 26 | * rx.c |
| 27 | * |
| 28 | * Abstract: Hardware miniport for Drawbridge specific hardware functions. |
| 29 | * |
| 30 | */ |
| 31 | |
| 32 | #include <linux/kernel.h> |
| 33 | #include <linux/init.h> |
| 34 | #include <linux/types.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | #include <linux/pci.h> |
| 36 | #include <linux/spinlock.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | #include <linux/blkdev.h> |
| 38 | #include <linux/delay.h> |
| 39 | #include <linux/completion.h> |
| 40 | #include <linux/time.h> |
| 41 | #include <linux/interrupt.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | |
| 43 | #include <scsi/scsi_host.h> |
| 44 | |
| 45 | #include "aacraid.h" |
| 46 | |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 47 | static irqreturn_t aac_rx_intr_producer(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | { |
| 49 | struct aac_dev *dev = dev_id; |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 50 | unsigned long bellbits; |
| 51 | u8 intstat = rx_readb(dev, MUnit.OISR); |
Mark Haverkamp | 8e0c5eb | 2005-10-24 10:52:22 -0700 | [diff] [blame] | 52 | |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 53 | /* |
| 54 | * Read mask and invert because drawbridge is reversed. |
| 55 | * This allows us to only service interrupts that have |
| 56 | * been enabled. |
| 57 | * Check to see if this is our interrupt. If it isn't just return |
| 58 | */ |
Salyzyn, Mark | 912d4e8 | 2007-03-26 09:21:14 -0400 | [diff] [blame] | 59 | if (likely(intstat & ~(dev->OIMR))) { |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 60 | bellbits = rx_readl(dev, OutboundDoorbellReg); |
Salyzyn, Mark | 912d4e8 | 2007-03-26 09:21:14 -0400 | [diff] [blame] | 61 | if (unlikely(bellbits & DoorBellPrintfReady)) { |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 62 | aac_printf(dev, readl (&dev->IndexRegs->Mailbox[5])); |
| 63 | rx_writel(dev, MUnit.ODR,DoorBellPrintfReady); |
| 64 | rx_writel(dev, InboundDoorbellReg,DoorBellPrintfDone); |
| 65 | } |
Salyzyn, Mark | 912d4e8 | 2007-03-26 09:21:14 -0400 | [diff] [blame] | 66 | else if (unlikely(bellbits & DoorBellAdapterNormCmdReady)) { |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 67 | rx_writel(dev, MUnit.ODR, DoorBellAdapterNormCmdReady); |
| 68 | aac_command_normal(&dev->queues->queue[HostNormCmdQueue]); |
| 69 | } |
Salyzyn, Mark | 912d4e8 | 2007-03-26 09:21:14 -0400 | [diff] [blame] | 70 | else if (likely(bellbits & DoorBellAdapterNormRespReady)) { |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 71 | rx_writel(dev, MUnit.ODR,DoorBellAdapterNormRespReady); |
| 72 | aac_response_normal(&dev->queues->queue[HostNormRespQueue]); |
| 73 | } |
Salyzyn, Mark | 912d4e8 | 2007-03-26 09:21:14 -0400 | [diff] [blame] | 74 | else if (unlikely(bellbits & DoorBellAdapterNormCmdNotFull)) { |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 75 | rx_writel(dev, MUnit.ODR, DoorBellAdapterNormCmdNotFull); |
| 76 | } |
Salyzyn, Mark | 912d4e8 | 2007-03-26 09:21:14 -0400 | [diff] [blame] | 77 | else if (unlikely(bellbits & DoorBellAdapterNormRespNotFull)) { |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 78 | rx_writel(dev, MUnit.ODR, DoorBellAdapterNormCmdNotFull); |
| 79 | rx_writel(dev, MUnit.ODR, DoorBellAdapterNormRespNotFull); |
| 80 | } |
| 81 | return IRQ_HANDLED; |
| 82 | } |
| 83 | return IRQ_NONE; |
| 84 | } |
| 85 | |
| 86 | static irqreturn_t aac_rx_intr_message(int irq, void *dev_id) |
| 87 | { |
Mahesh Rajashekhara | e8b12f0 | 2011-03-17 02:10:32 -0700 | [diff] [blame] | 88 | int isAif, isFastResponse, isSpecial; |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 89 | struct aac_dev *dev = dev_id; |
| 90 | u32 Index = rx_readl(dev, MUnit.OutboundQueue); |
Salyzyn, Mark | 912d4e8 | 2007-03-26 09:21:14 -0400 | [diff] [blame] | 91 | if (unlikely(Index == 0xFFFFFFFFL)) |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 92 | Index = rx_readl(dev, MUnit.OutboundQueue); |
Salyzyn, Mark | 912d4e8 | 2007-03-26 09:21:14 -0400 | [diff] [blame] | 93 | if (likely(Index != 0xFFFFFFFFL)) { |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 94 | do { |
Mahesh Rajashekhara | e8b12f0 | 2011-03-17 02:10:32 -0700 | [diff] [blame] | 95 | isAif = isFastResponse = isSpecial = 0; |
| 96 | if (Index & 0x00000002L) { |
| 97 | isAif = 1; |
| 98 | if (Index == 0xFFFFFFFEL) |
| 99 | isSpecial = 1; |
| 100 | Index &= ~0x00000002L; |
| 101 | } else { |
| 102 | if (Index & 0x00000001L) |
| 103 | isFastResponse = 1; |
| 104 | Index >>= 2; |
| 105 | } |
| 106 | if (!isSpecial) { |
| 107 | if (unlikely(aac_intr_normal(dev, |
| 108 | Index, isAif, |
| 109 | isFastResponse, NULL))) { |
| 110 | rx_writel(dev, |
| 111 | MUnit.OutboundQueue, |
| 112 | Index); |
| 113 | rx_writel(dev, |
| 114 | MUnit.ODR, |
| 115 | DoorBellAdapterNormRespReady); |
| 116 | } |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 117 | } |
Mark Haverkamp | 8e0c5eb | 2005-10-24 10:52:22 -0700 | [diff] [blame] | 118 | Index = rx_readl(dev, MUnit.OutboundQueue); |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 119 | } while (Index != 0xFFFFFFFFL); |
| 120 | return IRQ_HANDLED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | } |
| 122 | return IRQ_NONE; |
| 123 | } |
| 124 | |
| 125 | /** |
Mark Haverkamp | bd1aac8 | 2005-08-03 15:39:01 -0700 | [diff] [blame] | 126 | * aac_rx_disable_interrupt - Disable interrupts |
| 127 | * @dev: Adapter |
| 128 | */ |
| 129 | |
| 130 | static void aac_rx_disable_interrupt(struct aac_dev *dev) |
| 131 | { |
| 132 | rx_writeb(dev, MUnit.OIMR, dev->OIMR = 0xff); |
| 133 | } |
| 134 | |
| 135 | /** |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 136 | * aac_rx_enable_interrupt_producer - Enable interrupts |
| 137 | * @dev: Adapter |
| 138 | */ |
| 139 | |
| 140 | static void aac_rx_enable_interrupt_producer(struct aac_dev *dev) |
| 141 | { |
| 142 | rx_writeb(dev, MUnit.OIMR, dev->OIMR = 0xfb); |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * aac_rx_enable_interrupt_message - Enable interrupts |
| 147 | * @dev: Adapter |
| 148 | */ |
| 149 | |
| 150 | static void aac_rx_enable_interrupt_message(struct aac_dev *dev) |
| 151 | { |
| 152 | rx_writeb(dev, MUnit.OIMR, dev->OIMR = 0xf7); |
| 153 | } |
| 154 | |
| 155 | /** |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | * rx_sync_cmd - send a command and wait |
| 157 | * @dev: Adapter |
| 158 | * @command: Command to execute |
| 159 | * @p1: first parameter |
| 160 | * @ret: adapter status |
| 161 | * |
| 162 | * This routine will send a synchronous command to the adapter and wait |
| 163 | * for its completion. |
| 164 | */ |
| 165 | |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 166 | static int rx_sync_cmd(struct aac_dev *dev, u32 command, |
| 167 | u32 p1, u32 p2, u32 p3, u32 p4, u32 p5, u32 p6, |
| 168 | u32 *status, u32 * r1, u32 * r2, u32 * r3, u32 * r4) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | { |
| 170 | unsigned long start; |
| 171 | int ok; |
| 172 | /* |
| 173 | * Write the command into Mailbox 0 |
| 174 | */ |
Mark Haverkamp | 76a7f8f | 2006-09-19 09:00:02 -0700 | [diff] [blame] | 175 | writel(command, &dev->IndexRegs->Mailbox[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | /* |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 177 | * Write the parameters into Mailboxes 1 - 6 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | */ |
Mark Haverkamp | 76a7f8f | 2006-09-19 09:00:02 -0700 | [diff] [blame] | 179 | writel(p1, &dev->IndexRegs->Mailbox[1]); |
| 180 | writel(p2, &dev->IndexRegs->Mailbox[2]); |
| 181 | writel(p3, &dev->IndexRegs->Mailbox[3]); |
| 182 | writel(p4, &dev->IndexRegs->Mailbox[4]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | /* |
| 184 | * Clear the synch command doorbell to start on a clean slate. |
| 185 | */ |
| 186 | rx_writel(dev, OutboundDoorbellReg, OUTBOUNDDOORBELL_0); |
| 187 | /* |
| 188 | * Disable doorbell interrupts |
| 189 | */ |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 190 | rx_writeb(dev, MUnit.OIMR, dev->OIMR = 0xff); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | /* |
| 192 | * Force the completion of the mask register write before issuing |
| 193 | * the interrupt. |
| 194 | */ |
| 195 | rx_readb (dev, MUnit.OIMR); |
| 196 | /* |
| 197 | * Signal that there is a new synch command |
| 198 | */ |
| 199 | rx_writel(dev, InboundDoorbellReg, INBOUNDDOORBELL_0); |
| 200 | |
| 201 | ok = 0; |
| 202 | start = jiffies; |
| 203 | |
| 204 | /* |
| 205 | * Wait up to 30 seconds |
| 206 | */ |
| 207 | while (time_before(jiffies, start+30*HZ)) |
| 208 | { |
| 209 | udelay(5); /* Delay 5 microseconds to let Mon960 get info. */ |
| 210 | /* |
| 211 | * Mon960 will set doorbell0 bit when it has completed the command. |
| 212 | */ |
| 213 | if (rx_readl(dev, OutboundDoorbellReg) & OUTBOUNDDOORBELL_0) { |
| 214 | /* |
| 215 | * Clear the doorbell. |
| 216 | */ |
| 217 | rx_writel(dev, OutboundDoorbellReg, OUTBOUNDDOORBELL_0); |
| 218 | ok = 1; |
| 219 | break; |
| 220 | } |
| 221 | /* |
| 222 | * Yield the processor in case we are slow |
| 223 | */ |
Mark Haverkamp | 1241f35 | 2006-03-27 09:44:23 -0800 | [diff] [blame] | 224 | msleep(1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | } |
Salyzyn, Mark | 912d4e8 | 2007-03-26 09:21:14 -0400 | [diff] [blame] | 226 | if (unlikely(ok != 1)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | /* |
| 228 | * Restore interrupt mask even though we timed out |
| 229 | */ |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 230 | aac_adapter_enable_int(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | return -ETIMEDOUT; |
| 232 | } |
| 233 | /* |
| 234 | * Pull the synch status from Mailbox 0. |
| 235 | */ |
| 236 | if (status) |
Mark Haverkamp | 76a7f8f | 2006-09-19 09:00:02 -0700 | [diff] [blame] | 237 | *status = readl(&dev->IndexRegs->Mailbox[0]); |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 238 | if (r1) |
Mark Haverkamp | 76a7f8f | 2006-09-19 09:00:02 -0700 | [diff] [blame] | 239 | *r1 = readl(&dev->IndexRegs->Mailbox[1]); |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 240 | if (r2) |
Mark Haverkamp | 76a7f8f | 2006-09-19 09:00:02 -0700 | [diff] [blame] | 241 | *r2 = readl(&dev->IndexRegs->Mailbox[2]); |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 242 | if (r3) |
Mark Haverkamp | 76a7f8f | 2006-09-19 09:00:02 -0700 | [diff] [blame] | 243 | *r3 = readl(&dev->IndexRegs->Mailbox[3]); |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 244 | if (r4) |
Mark Haverkamp | 76a7f8f | 2006-09-19 09:00:02 -0700 | [diff] [blame] | 245 | *r4 = readl(&dev->IndexRegs->Mailbox[4]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | /* |
| 247 | * Clear the synch command doorbell. |
| 248 | */ |
| 249 | rx_writel(dev, OutboundDoorbellReg, OUTBOUNDDOORBELL_0); |
| 250 | /* |
| 251 | * Restore interrupt mask |
| 252 | */ |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 253 | aac_adapter_enable_int(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | return 0; |
| 255 | |
| 256 | } |
| 257 | |
| 258 | /** |
| 259 | * aac_rx_interrupt_adapter - interrupt adapter |
| 260 | * @dev: Adapter |
| 261 | * |
| 262 | * Send an interrupt to the i960 and breakpoint it. |
| 263 | */ |
| 264 | |
| 265 | static void aac_rx_interrupt_adapter(struct aac_dev *dev) |
| 266 | { |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 267 | rx_sync_cmd(dev, BREAKPOINT_REQUEST, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | /** |
| 271 | * aac_rx_notify_adapter - send an event to the adapter |
| 272 | * @dev: Adapter |
| 273 | * @event: Event to send |
| 274 | * |
| 275 | * Notify the i960 that something it probably cares about has |
| 276 | * happened. |
| 277 | */ |
| 278 | |
| 279 | static void aac_rx_notify_adapter(struct aac_dev *dev, u32 event) |
| 280 | { |
| 281 | switch (event) { |
| 282 | |
| 283 | case AdapNormCmdQue: |
| 284 | rx_writel(dev, MUnit.IDR,INBOUNDDOORBELL_1); |
| 285 | break; |
| 286 | case HostNormRespNotFull: |
| 287 | rx_writel(dev, MUnit.IDR,INBOUNDDOORBELL_4); |
| 288 | break; |
| 289 | case AdapNormRespQue: |
| 290 | rx_writel(dev, MUnit.IDR,INBOUNDDOORBELL_2); |
| 291 | break; |
| 292 | case HostNormCmdNotFull: |
| 293 | rx_writel(dev, MUnit.IDR,INBOUNDDOORBELL_3); |
| 294 | break; |
| 295 | case HostShutdown: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | break; |
| 297 | case FastIo: |
| 298 | rx_writel(dev, MUnit.IDR,INBOUNDDOORBELL_6); |
| 299 | break; |
| 300 | case AdapPrintfDone: |
| 301 | rx_writel(dev, MUnit.IDR,INBOUNDDOORBELL_5); |
| 302 | break; |
| 303 | default: |
| 304 | BUG(); |
| 305 | break; |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | /** |
| 310 | * aac_rx_start_adapter - activate adapter |
| 311 | * @dev: Adapter |
| 312 | * |
| 313 | * Start up processing on an i960 based AAC adapter |
| 314 | */ |
| 315 | |
Adrian Bunk | 9695a25 | 2007-03-26 21:59:35 -0800 | [diff] [blame] | 316 | static void aac_rx_start_adapter(struct aac_dev *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | struct aac_init *init; |
| 319 | |
| 320 | init = dev->init; |
| 321 | init->HostElapsedSeconds = cpu_to_le32(get_seconds()); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | // We can only use a 32 bit address here |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 323 | rx_sync_cmd(dev, INIT_STRUCT_BASE_ADDRESS, (u32)(ulong)dev->init_pa, |
| 324 | 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | /** |
| 328 | * aac_rx_check_health |
| 329 | * @dev: device to check if healthy |
| 330 | * |
| 331 | * Will attempt to determine if the specified adapter is alive and |
| 332 | * capable of handling requests, returning 0 if alive. |
| 333 | */ |
| 334 | static int aac_rx_check_health(struct aac_dev *dev) |
| 335 | { |
| 336 | u32 status = rx_readl(dev, MUnit.OMRx[0]); |
| 337 | |
| 338 | /* |
| 339 | * Check to see if the board failed any self tests. |
| 340 | */ |
Salyzyn, Mark | 912d4e8 | 2007-03-26 09:21:14 -0400 | [diff] [blame] | 341 | if (unlikely(status & SELF_TEST_FAILED)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | return -1; |
| 343 | /* |
| 344 | * Check to see if the board panic'd. |
| 345 | */ |
Salyzyn, Mark | 912d4e8 | 2007-03-26 09:21:14 -0400 | [diff] [blame] | 346 | if (unlikely(status & KERNEL_PANIC)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | char * buffer; |
| 348 | struct POSTSTATUS { |
Mark Haverkamp | 56b5871 | 2005-04-27 06:05:51 -0700 | [diff] [blame] | 349 | __le32 Post_Command; |
| 350 | __le32 Post_Address; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | } * post; |
| 352 | dma_addr_t paddr, baddr; |
| 353 | int ret; |
| 354 | |
Salyzyn, Mark | 912d4e8 | 2007-03-26 09:21:14 -0400 | [diff] [blame] | 355 | if (likely((status & 0xFF000000L) == 0xBC000000L)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | return (status >> 16) & 0xFF; |
| 357 | buffer = pci_alloc_consistent(dev->pdev, 512, &baddr); |
| 358 | ret = -2; |
Salyzyn, Mark | 912d4e8 | 2007-03-26 09:21:14 -0400 | [diff] [blame] | 359 | if (unlikely(buffer == NULL)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | return ret; |
| 361 | post = pci_alloc_consistent(dev->pdev, |
| 362 | sizeof(struct POSTSTATUS), &paddr); |
Salyzyn, Mark | 912d4e8 | 2007-03-26 09:21:14 -0400 | [diff] [blame] | 363 | if (unlikely(post == NULL)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | pci_free_consistent(dev->pdev, 512, buffer, baddr); |
| 365 | return ret; |
| 366 | } |
| 367 | memset(buffer, 0, 512); |
| 368 | post->Post_Command = cpu_to_le32(COMMAND_POST_RESULTS); |
| 369 | post->Post_Address = cpu_to_le32(baddr); |
| 370 | rx_writel(dev, MUnit.IMRx[0], paddr); |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 371 | rx_sync_cmd(dev, COMMAND_POST_RESULTS, baddr, 0, 0, 0, 0, 0, |
| 372 | NULL, NULL, NULL, NULL, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | pci_free_consistent(dev->pdev, sizeof(struct POSTSTATUS), |
| 374 | post, paddr); |
Salyzyn, Mark | 912d4e8 | 2007-03-26 09:21:14 -0400 | [diff] [blame] | 375 | if (likely((buffer[0] == '0') && ((buffer[1] == 'x') || (buffer[1] == 'X')))) { |
Andy Shevchenko | ecc3099 | 2010-08-10 18:01:27 -0700 | [diff] [blame] | 376 | ret = (hex_to_bin(buffer[2]) << 4) + |
| 377 | hex_to_bin(buffer[3]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | } |
| 379 | pci_free_consistent(dev->pdev, 512, buffer, baddr); |
| 380 | return ret; |
| 381 | } |
| 382 | /* |
| 383 | * Wait for the adapter to be up and running. |
| 384 | */ |
Salyzyn, Mark | 912d4e8 | 2007-03-26 09:21:14 -0400 | [diff] [blame] | 385 | if (unlikely(!(status & KERNEL_UP_AND_RUNNING))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | return -3; |
| 387 | /* |
| 388 | * Everything is OK |
| 389 | */ |
| 390 | return 0; |
| 391 | } |
| 392 | |
| 393 | /** |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 394 | * aac_rx_deliver_producer |
Mark Haverkamp | 8e0c5eb | 2005-10-24 10:52:22 -0700 | [diff] [blame] | 395 | * @fib: fib to issue |
| 396 | * |
| 397 | * Will send a fib, returning 0 if successful. |
| 398 | */ |
Salyzyn, Mark | 2ab01ef | 2007-05-15 09:14:21 -0400 | [diff] [blame] | 399 | int aac_rx_deliver_producer(struct fib * fib) |
Mark Haverkamp | 8e0c5eb | 2005-10-24 10:52:22 -0700 | [diff] [blame] | 400 | { |
Mark Haverkamp | 8e0c5eb | 2005-10-24 10:52:22 -0700 | [diff] [blame] | 401 | struct aac_dev *dev = fib->dev; |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 402 | struct aac_queue *q = &dev->queues->queue[AdapNormCmdQueue]; |
Mark Haverkamp | 8e0c5eb | 2005-10-24 10:52:22 -0700 | [diff] [blame] | 403 | u32 Index; |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 404 | unsigned long nointr = 0; |
Mark Haverkamp | 8e0c5eb | 2005-10-24 10:52:22 -0700 | [diff] [blame] | 405 | |
Mark Haverkamp | a8166a5 | 2007-03-15 10:26:22 -0700 | [diff] [blame] | 406 | aac_queue_get( dev, &Index, AdapNormCmdQueue, fib->hw_fib_va, 1, fib, &nointr); |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 407 | |
Mahesh Rajashekhara | ef61623 | 2015-03-26 10:41:30 -0400 | [diff] [blame] | 408 | atomic_inc(&q->numpending); |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 409 | *(q->headers.producer) = cpu_to_le32(Index + 1); |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 410 | if (!(nointr & aac_config.irq_mod)) |
| 411 | aac_adapter_notify(dev, AdapNormCmdQueue); |
| 412 | |
| 413 | return 0; |
| 414 | } |
| 415 | |
| 416 | /** |
| 417 | * aac_rx_deliver_message |
| 418 | * @fib: fib to issue |
| 419 | * |
| 420 | * Will send a fib, returning 0 if successful. |
| 421 | */ |
| 422 | static int aac_rx_deliver_message(struct fib * fib) |
| 423 | { |
| 424 | struct aac_dev *dev = fib->dev; |
| 425 | struct aac_queue *q = &dev->queues->queue[AdapNormCmdQueue]; |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 426 | u32 Index; |
| 427 | u64 addr; |
| 428 | volatile void __iomem *device; |
| 429 | |
| 430 | unsigned long count = 10000000L; /* 50 seconds */ |
Mahesh Rajashekhara | ef61623 | 2015-03-26 10:41:30 -0400 | [diff] [blame] | 431 | atomic_inc(&q->numpending); |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 432 | for(;;) { |
Mark Haverkamp | 8e0c5eb | 2005-10-24 10:52:22 -0700 | [diff] [blame] | 433 | Index = rx_readl(dev, MUnit.InboundQueue); |
Salyzyn, Mark | 912d4e8 | 2007-03-26 09:21:14 -0400 | [diff] [blame] | 434 | if (unlikely(Index == 0xFFFFFFFFL)) |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 435 | Index = rx_readl(dev, MUnit.InboundQueue); |
Salyzyn, Mark | 912d4e8 | 2007-03-26 09:21:14 -0400 | [diff] [blame] | 436 | if (likely(Index != 0xFFFFFFFFL)) |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 437 | break; |
| 438 | if (--count == 0) { |
Mahesh Rajashekhara | ef61623 | 2015-03-26 10:41:30 -0400 | [diff] [blame] | 439 | atomic_dec(&q->numpending); |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 440 | return -ETIMEDOUT; |
| 441 | } |
| 442 | udelay(5); |
| 443 | } |
Mark Haverkamp | 76a7f8f | 2006-09-19 09:00:02 -0700 | [diff] [blame] | 444 | device = dev->base + Index; |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 445 | addr = fib->hw_fib_pa; |
Mark Haverkamp | 8e0c5eb | 2005-10-24 10:52:22 -0700 | [diff] [blame] | 446 | writel((u32)(addr & 0xffffffff), device); |
| 447 | device += sizeof(u32); |
| 448 | writel((u32)(addr >> 32), device); |
| 449 | device += sizeof(u32); |
Mark Haverkamp | a8166a5 | 2007-03-15 10:26:22 -0700 | [diff] [blame] | 450 | writel(le16_to_cpu(fib->hw_fib_va->header.Size), device); |
Mark Haverkamp | 8e0c5eb | 2005-10-24 10:52:22 -0700 | [diff] [blame] | 451 | rx_writel(dev, MUnit.InboundQueue, Index); |
Mark Haverkamp | 8e0c5eb | 2005-10-24 10:52:22 -0700 | [diff] [blame] | 452 | return 0; |
| 453 | } |
| 454 | |
Mark Haverkamp | 76a7f8f | 2006-09-19 09:00:02 -0700 | [diff] [blame] | 455 | /** |
| 456 | * aac_rx_ioremap |
| 457 | * @size: mapping resize request |
| 458 | * |
| 459 | */ |
| 460 | static int aac_rx_ioremap(struct aac_dev * dev, u32 size) |
| 461 | { |
| 462 | if (!size) { |
| 463 | iounmap(dev->regs.rx); |
| 464 | return 0; |
| 465 | } |
Ben Collins | ff08784 | 2012-06-11 14:05:02 -0400 | [diff] [blame] | 466 | dev->base = dev->regs.rx = ioremap(dev->base_start, size); |
Mark Haverkamp | 76a7f8f | 2006-09-19 09:00:02 -0700 | [diff] [blame] | 467 | if (dev->base == NULL) |
| 468 | return -1; |
| 469 | dev->IndexRegs = &dev->regs.rx->IndexRegs; |
| 470 | return 0; |
| 471 | } |
| 472 | |
Mark Haverkamp | 8418852 | 2007-03-15 10:26:05 -0700 | [diff] [blame] | 473 | static int aac_rx_restart_adapter(struct aac_dev *dev, int bled) |
Mark Haverkamp | 8c23cd7 | 2006-08-08 08:52:14 -0700 | [diff] [blame] | 474 | { |
Mahesh Rajashekhara | 6e40e5f | 2014-01-13 13:50:30 +0530 | [diff] [blame] | 475 | u32 var = 0; |
Mark Haverkamp | 8c23cd7 | 2006-08-08 08:52:14 -0700 | [diff] [blame] | 476 | |
Salyzyn, Mark | 29c9768 | 2007-06-12 09:33:54 -0400 | [diff] [blame] | 477 | if (!(dev->supplement_adapter_info.SupportedOptions2 & |
Salyzyn, Mark | a3940da | 2008-01-08 12:48:25 -0800 | [diff] [blame] | 478 | AAC_OPTION_MU_RESET) || (bled >= 0) || (bled == -2)) { |
Salyzyn, Mark | 29c9768 | 2007-06-12 09:33:54 -0400 | [diff] [blame] | 479 | if (bled) |
| 480 | printk(KERN_ERR "%s%d: adapter kernel panic'd %x.\n", |
| 481 | dev->name, dev->id, bled); |
| 482 | else { |
| 483 | bled = aac_adapter_sync_cmd(dev, IOP_RESET_ALWAYS, |
| 484 | 0, 0, 0, 0, 0, 0, &var, NULL, NULL, NULL, NULL); |
Salyzyn, Mark | 9859c1a | 2007-07-27 10:29:26 -0400 | [diff] [blame] | 485 | if (!bled && (var != 0x00000001) && (var != 0x3803000F)) |
Salyzyn, Mark | 29c9768 | 2007-06-12 09:33:54 -0400 | [diff] [blame] | 486 | bled = -EINVAL; |
| 487 | } |
| 488 | if (bled && (bled != -ETIMEDOUT)) |
| 489 | bled = aac_adapter_sync_cmd(dev, IOP_RESET, |
| 490 | 0, 0, 0, 0, 0, 0, &var, NULL, NULL, NULL, NULL); |
Mark Haverkamp | 8c23cd7 | 2006-08-08 08:52:14 -0700 | [diff] [blame] | 491 | |
Salyzyn, Mark | 29c9768 | 2007-06-12 09:33:54 -0400 | [diff] [blame] | 492 | if (bled && (bled != -ETIMEDOUT)) |
| 493 | return -EINVAL; |
| 494 | } |
Mahesh Rajashekhara | 6e40e5f | 2014-01-13 13:50:30 +0530 | [diff] [blame] | 495 | if (bled && (var == 0x3803000F)) { /* USE_OTHER_METHOD */ |
Mark Haverkamp | 8418852 | 2007-03-15 10:26:05 -0700 | [diff] [blame] | 496 | rx_writel(dev, MUnit.reserved2, 3); |
| 497 | msleep(5000); /* Delay 5 seconds */ |
| 498 | var = 0x00000001; |
| 499 | } |
Mahesh Rajashekhara | 6e40e5f | 2014-01-13 13:50:30 +0530 | [diff] [blame] | 500 | if (bled && (var != 0x00000001)) |
Mark Haverkamp | 8418852 | 2007-03-15 10:26:05 -0700 | [diff] [blame] | 501 | return -EINVAL; |
Mahesh Rajashekhara | 6e40e5f | 2014-01-13 13:50:30 +0530 | [diff] [blame] | 502 | ssleep(5); |
Mark Haverkamp | 8c23cd7 | 2006-08-08 08:52:14 -0700 | [diff] [blame] | 503 | if (rx_readl(dev, MUnit.OMRx[0]) & KERNEL_PANIC) |
Mark Haverkamp | 8418852 | 2007-03-15 10:26:05 -0700 | [diff] [blame] | 504 | return -ENODEV; |
Salyzyn, Mark | 1208bab | 2007-05-22 09:32:29 -0400 | [diff] [blame] | 505 | if (startup_timeout < 300) |
| 506 | startup_timeout = 300; |
Mark Haverkamp | 8c23cd7 | 2006-08-08 08:52:14 -0700 | [diff] [blame] | 507 | return 0; |
| 508 | } |
| 509 | |
Mark Haverkamp | 8e0c5eb | 2005-10-24 10:52:22 -0700 | [diff] [blame] | 510 | /** |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 511 | * aac_rx_select_comm - Select communications method |
| 512 | * @dev: Adapter |
| 513 | * @comm: communications method |
| 514 | */ |
| 515 | |
| 516 | int aac_rx_select_comm(struct aac_dev *dev, int comm) |
| 517 | { |
| 518 | switch (comm) { |
| 519 | case AAC_COMM_PRODUCER: |
| 520 | dev->a_ops.adapter_enable_int = aac_rx_enable_interrupt_producer; |
| 521 | dev->a_ops.adapter_intr = aac_rx_intr_producer; |
| 522 | dev->a_ops.adapter_deliver = aac_rx_deliver_producer; |
| 523 | break; |
| 524 | case AAC_COMM_MESSAGE: |
| 525 | dev->a_ops.adapter_enable_int = aac_rx_enable_interrupt_message; |
| 526 | dev->a_ops.adapter_intr = aac_rx_intr_message; |
| 527 | dev->a_ops.adapter_deliver = aac_rx_deliver_message; |
| 528 | break; |
| 529 | default: |
| 530 | return 1; |
| 531 | } |
| 532 | return 0; |
| 533 | } |
| 534 | |
| 535 | /** |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | * aac_rx_init - initialize an i960 based AAC card |
| 537 | * @dev: device to configure |
| 538 | * |
| 539 | * Allocate and set up resources for the i960 based AAC variants. The |
| 540 | * device_interface in the commregion will be allocated and linked |
| 541 | * to the comm region. |
| 542 | */ |
| 543 | |
Mark Haverkamp | 76a7f8f | 2006-09-19 09:00:02 -0700 | [diff] [blame] | 544 | int _aac_rx_init(struct aac_dev *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | { |
| 546 | unsigned long start; |
| 547 | unsigned long status; |
Salyzyn, Mark | 18a6598 | 2007-03-30 10:30:48 -0400 | [diff] [blame] | 548 | int restart = 0; |
Salyzyn, Mark | 912d4e8 | 2007-03-26 09:21:14 -0400 | [diff] [blame] | 549 | int instance = dev->id; |
| 550 | const char * name = dev->name; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | |
Mark Haverkamp | 76a7f8f | 2006-09-19 09:00:02 -0700 | [diff] [blame] | 552 | if (aac_adapter_ioremap(dev, dev->base_size)) { |
| 553 | printk(KERN_WARNING "%s: unable to map adapter.\n", name); |
| 554 | goto error_iounmap; |
| 555 | } |
| 556 | |
Salyzyn, Mark | 18a6598 | 2007-03-30 10:30:48 -0400 | [diff] [blame] | 557 | /* Failure to reset here is an option ... */ |
Salyzyn, Mark | a5694ec | 2007-04-30 13:22:24 -0400 | [diff] [blame] | 558 | dev->a_ops.adapter_sync_cmd = rx_sync_cmd; |
| 559 | dev->a_ops.adapter_enable_int = aac_rx_disable_interrupt; |
Salyzyn, Mark | 18a6598 | 2007-03-30 10:30:48 -0400 | [diff] [blame] | 560 | dev->OIMR = status = rx_readb (dev, MUnit.OIMR); |
Salyzyn, Mark | 1208bab | 2007-05-22 09:32:29 -0400 | [diff] [blame] | 561 | if ((((status & 0x0c) != 0x0c) || aac_reset_devices || reset_devices) && |
Salyzyn, Mark | 18a6598 | 2007-03-30 10:30:48 -0400 | [diff] [blame] | 562 | !aac_rx_restart_adapter(dev, 0)) |
Salyzyn, Mark | f858317 | 2007-10-30 15:50:49 -0400 | [diff] [blame] | 563 | /* Make sure the Hardware FIFO is empty */ |
| 564 | while ((++restart < 512) && |
| 565 | (rx_readl(dev, MUnit.OutboundQueue) != 0xFFFFFFFFL)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 566 | /* |
Mark Haverkamp | 8e0c5eb | 2005-10-24 10:52:22 -0700 | [diff] [blame] | 567 | * Check to see if the board panic'd while booting. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | */ |
Mark Haverkamp | 76a7f8f | 2006-09-19 09:00:02 -0700 | [diff] [blame] | 569 | status = rx_readl(dev, MUnit.OMRx[0]); |
Mark Haverkamp | 8418852 | 2007-03-15 10:26:05 -0700 | [diff] [blame] | 570 | if (status & KERNEL_PANIC) { |
Salyzyn, Mark | 18a6598 | 2007-03-30 10:30:48 -0400 | [diff] [blame] | 571 | if (aac_rx_restart_adapter(dev, aac_rx_check_health(dev))) |
Mark Haverkamp | 8c23cd7 | 2006-08-08 08:52:14 -0700 | [diff] [blame] | 572 | goto error_iounmap; |
Salyzyn, Mark | 18a6598 | 2007-03-30 10:30:48 -0400 | [diff] [blame] | 573 | ++restart; |
Mark Haverkamp | 8418852 | 2007-03-15 10:26:05 -0700 | [diff] [blame] | 574 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | /* |
| 576 | * Check to see if the board failed any self tests. |
| 577 | */ |
Mark Haverkamp | 76a7f8f | 2006-09-19 09:00:02 -0700 | [diff] [blame] | 578 | status = rx_readl(dev, MUnit.OMRx[0]); |
| 579 | if (status & SELF_TEST_FAILED) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 580 | printk(KERN_ERR "%s%d: adapter self-test failed.\n", dev->name, instance); |
| 581 | goto error_iounmap; |
| 582 | } |
| 583 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | * Check to see if the monitor panic'd while booting. |
| 585 | */ |
Mark Haverkamp | 76a7f8f | 2006-09-19 09:00:02 -0700 | [diff] [blame] | 586 | if (status & MONITOR_PANIC) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | printk(KERN_ERR "%s%d: adapter monitor panic.\n", dev->name, instance); |
| 588 | goto error_iounmap; |
| 589 | } |
| 590 | start = jiffies; |
| 591 | /* |
| 592 | * Wait for the adapter to be up and running. Wait up to 3 minutes |
| 593 | */ |
Mark Haverkamp | 76a7f8f | 2006-09-19 09:00:02 -0700 | [diff] [blame] | 594 | while (!((status = rx_readl(dev, MUnit.OMRx[0])) & KERNEL_UP_AND_RUNNING)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | { |
Salyzyn, Mark | 18a6598 | 2007-03-30 10:30:48 -0400 | [diff] [blame] | 596 | if ((restart && |
| 597 | (status & (KERNEL_PANIC|SELF_TEST_FAILED|MONITOR_PANIC))) || |
| 598 | time_after(jiffies, start+HZ*startup_timeout)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | printk(KERN_ERR "%s%d: adapter kernel failed to start, init status = %lx.\n", |
| 600 | dev->name, instance, status); |
| 601 | goto error_iounmap; |
| 602 | } |
Salyzyn, Mark | 18a6598 | 2007-03-30 10:30:48 -0400 | [diff] [blame] | 603 | if (!restart && |
| 604 | ((status & (KERNEL_PANIC|SELF_TEST_FAILED|MONITOR_PANIC)) || |
| 605 | time_after(jiffies, start + HZ * |
| 606 | ((startup_timeout > 60) |
| 607 | ? (startup_timeout - 60) |
| 608 | : (startup_timeout / 2))))) { |
| 609 | if (likely(!aac_rx_restart_adapter(dev, aac_rx_check_health(dev)))) |
| 610 | start = jiffies; |
| 611 | ++restart; |
| 612 | } |
Mark Haverkamp | 404d9a9 | 2006-05-10 09:12:48 -0700 | [diff] [blame] | 613 | msleep(1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | } |
Salyzyn, Mark | 29c9768 | 2007-06-12 09:33:54 -0400 | [diff] [blame] | 615 | if (restart && aac_commit) |
Salyzyn, Mark | 1208bab | 2007-05-22 09:32:29 -0400 | [diff] [blame] | 616 | aac_commit = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | /* |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 618 | * Fill in the common function dispatch table. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | */ |
| 620 | dev->a_ops.adapter_interrupt = aac_rx_interrupt_adapter; |
Mark Haverkamp | bd1aac8 | 2005-08-03 15:39:01 -0700 | [diff] [blame] | 621 | dev->a_ops.adapter_disable_int = aac_rx_disable_interrupt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 622 | dev->a_ops.adapter_notify = aac_rx_notify_adapter; |
| 623 | dev->a_ops.adapter_sync_cmd = rx_sync_cmd; |
| 624 | dev->a_ops.adapter_check_health = aac_rx_check_health; |
Mark Haverkamp | 8418852 | 2007-03-15 10:26:05 -0700 | [diff] [blame] | 625 | dev->a_ops.adapter_restart = aac_rx_restart_adapter; |
Mahesh Rajashekhara | de665f2 | 2015-08-28 06:38:34 -0400 | [diff] [blame] | 626 | dev->a_ops.adapter_start = aac_rx_start_adapter; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | |
Mark Haverkamp | bd1aac8 | 2005-08-03 15:39:01 -0700 | [diff] [blame] | 628 | /* |
| 629 | * First clear out all interrupts. Then enable the one's that we |
| 630 | * can handle. |
| 631 | */ |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 632 | aac_adapter_comm(dev, AAC_COMM_PRODUCER); |
| 633 | aac_adapter_disable_int(dev); |
Mark Haverkamp | bd1aac8 | 2005-08-03 15:39:01 -0700 | [diff] [blame] | 634 | rx_writel(dev, MUnit.ODR, 0xffffffff); |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 635 | aac_adapter_enable_int(dev); |
Mark Haverkamp | bd1aac8 | 2005-08-03 15:39:01 -0700 | [diff] [blame] | 636 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | if (aac_init_adapter(dev) == NULL) |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 638 | goto error_iounmap; |
| 639 | aac_adapter_comm(dev, dev->comm_interface); |
Mahesh Rajashekhara | 1160461 | 2012-02-08 22:51:04 -0800 | [diff] [blame] | 640 | dev->sync_mode = 0; /* sync. mode not supported */ |
Salyzyn, Mark | 8ef2224 | 2008-02-08 05:48:22 -0800 | [diff] [blame] | 641 | dev->msi = aac_msi && !pci_enable_msi(dev->pdev); |
| 642 | if (request_irq(dev->pdev->irq, dev->a_ops.adapter_intr, |
Michael Opdenacker | 4909cc2 | 2014-03-05 06:09:41 +0100 | [diff] [blame] | 643 | IRQF_SHARED, "aacraid", dev) < 0) { |
Salyzyn, Mark | 8ef2224 | 2008-02-08 05:48:22 -0800 | [diff] [blame] | 644 | if (dev->msi) |
| 645 | pci_disable_msi(dev->pdev); |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 646 | printk(KERN_ERR "%s%d: Interrupt unavailable.\n", |
| 647 | name, instance); |
| 648 | goto error_iounmap; |
| 649 | } |
Ben Collins | ff08784 | 2012-06-11 14:05:02 -0400 | [diff] [blame] | 650 | dev->dbg_base = dev->base_start; |
Mahesh Rajashekhara | e8b12f0 | 2011-03-17 02:10:32 -0700 | [diff] [blame] | 651 | dev->dbg_base_mapped = dev->base; |
| 652 | dev->dbg_size = dev->base_size; |
| 653 | |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 654 | aac_adapter_enable_int(dev); |
| 655 | /* |
| 656 | * Tell the adapter that all is configured, and it can |
| 657 | * start accepting requests |
| 658 | */ |
| 659 | aac_rx_start_adapter(dev); |
Mark Haverkamp | 8e0c5eb | 2005-10-24 10:52:22 -0700 | [diff] [blame] | 660 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 661 | return 0; |
| 662 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | error_iounmap: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 664 | |
| 665 | return -1; |
| 666 | } |
Mark Haverkamp | 76a7f8f | 2006-09-19 09:00:02 -0700 | [diff] [blame] | 667 | |
| 668 | int aac_rx_init(struct aac_dev *dev) |
| 669 | { |
Mark Haverkamp | 76a7f8f | 2006-09-19 09:00:02 -0700 | [diff] [blame] | 670 | /* |
| 671 | * Fill in the function dispatch table. |
| 672 | */ |
| 673 | dev->a_ops.adapter_ioremap = aac_rx_ioremap; |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 674 | dev->a_ops.adapter_comm = aac_rx_select_comm; |
Mark Haverkamp | 76a7f8f | 2006-09-19 09:00:02 -0700 | [diff] [blame] | 675 | |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 676 | return _aac_rx_init(dev); |
Mark Haverkamp | 76a7f8f | 2006-09-19 09:00:02 -0700 | [diff] [blame] | 677 | } |