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 | * rkt.c |
| 27 | * |
| 28 | * Abstract: Hardware miniport for Drawbridge specific hardware functions. |
| 29 | * |
| 30 | */ |
| 31 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include <linux/blkdev.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | |
| 34 | #include <scsi/scsi_host.h> |
| 35 | |
| 36 | #include "aacraid.h" |
| 37 | |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 38 | #define AAC_NUM_IO_FIB_RKT (246 - AAC_NUM_MGT_FIB) |
| 39 | |
| 40 | /** |
| 41 | * aac_rkt_select_comm - Select communications method |
| 42 | * @dev: Adapter |
| 43 | * @comm: communications method |
| 44 | */ |
| 45 | |
| 46 | static int aac_rkt_select_comm(struct aac_dev *dev, int comm) |
| 47 | { |
| 48 | int retval; |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 49 | retval = aac_rx_select_comm(dev, comm); |
| 50 | if (comm == AAC_COMM_MESSAGE) { |
| 51 | /* |
| 52 | * FIB Setup has already been done, but we can minimize the |
| 53 | * damage by at least ensuring the OS never issues more |
| 54 | * commands than we can handle. The Rocket adapters currently |
| 55 | * can only handle 246 commands and 8 AIFs at the same time, |
| 56 | * and in fact do notify us accordingly if we negotiate the |
| 57 | * FIB size. The problem that causes us to add this check is |
| 58 | * to ensure that we do not overdo it with the adapter when a |
| 59 | * hard coded FIB override is being utilized. This special |
| 60 | * case warrants this half baked, but convenient, check here. |
| 61 | */ |
| 62 | if (dev->scsi_host_ptr->can_queue > AAC_NUM_IO_FIB_RKT) { |
| 63 | dev->init->MaxIoCommands = |
| 64 | cpu_to_le32(AAC_NUM_IO_FIB_RKT + AAC_NUM_MGT_FIB); |
| 65 | dev->scsi_host_ptr->can_queue = AAC_NUM_IO_FIB_RKT; |
| 66 | } |
| 67 | } |
| 68 | return retval; |
| 69 | } |
| 70 | |
Mark Haverkamp | 76a7f8f | 2006-09-19 09:00:02 -0700 | [diff] [blame] | 71 | /** |
| 72 | * aac_rkt_ioremap |
| 73 | * @size: mapping resize request |
| 74 | * |
| 75 | */ |
| 76 | static int aac_rkt_ioremap(struct aac_dev * dev, u32 size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | { |
Mark Haverkamp | 76a7f8f | 2006-09-19 09:00:02 -0700 | [diff] [blame] | 78 | if (!size) { |
| 79 | iounmap(dev->regs.rkt); |
| 80 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | } |
Mark Haverkamp | 76a7f8f | 2006-09-19 09:00:02 -0700 | [diff] [blame] | 82 | dev->base = dev->regs.rkt = ioremap(dev->scsi_host_ptr->base, size); |
| 83 | if (dev->base == NULL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | return -1; |
Mark Haverkamp | 76a7f8f | 2006-09-19 09:00:02 -0700 | [diff] [blame] | 85 | dev->IndexRegs = &dev->regs.rkt->IndexRegs; |
Mark Haverkamp | 8c23cd7 | 2006-08-08 08:52:14 -0700 | [diff] [blame] | 86 | return 0; |
| 87 | } |
| 88 | |
Mark Haverkamp | 8e0c5eb | 2005-10-24 10:52:22 -0700 | [diff] [blame] | 89 | /** |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | * aac_rkt_init - initialize an i960 based AAC card |
| 91 | * @dev: device to configure |
| 92 | * |
| 93 | * Allocate and set up resources for the i960 based AAC variants. The |
| 94 | * device_interface in the commregion will be allocated and linked |
| 95 | * to the comm region. |
| 96 | */ |
| 97 | |
| 98 | int aac_rkt_init(struct aac_dev *dev) |
| 99 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | /* |
| 101 | * Fill in the function dispatch table. |
| 102 | */ |
Mark Haverkamp | 76a7f8f | 2006-09-19 09:00:02 -0700 | [diff] [blame] | 103 | dev->a_ops.adapter_ioremap = aac_rkt_ioremap; |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 104 | dev->a_ops.adapter_comm = aac_rkt_select_comm; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | |
Mark Haverkamp | 2871332 | 2007-01-23 14:59:20 -0800 | [diff] [blame] | 106 | return _aac_rx_init(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | } |