blob: 8cd6588a83e3be4c7b81e65af0073b899b3600dd [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Adaptec AAC series RAID controller driver
3 * (c) Copyright 2001 Red Hat Inc. <alan@redhat.com>
4 *
5 * based on the old aacraid driver that is..
6 * Adaptec aacraid device driver for Linux.
7 *
Salyzyn, Markc835e372007-07-26 14:20:02 -04008 * Copyright (c) 2000-2007 Adaptec, Inc. (aacraid@adaptec.com)
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2, or (at your option)
13 * any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; see the file COPYING. If not, write to
22 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 * Module Name:
25 * rkt.c
26 *
27 * Abstract: Hardware miniport for Drawbridge specific hardware functions.
28 *
29 */
30
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#include <linux/blkdev.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
33#include <scsi/scsi_host.h>
34
35#include "aacraid.h"
36
Mark Haverkamp28713322007-01-23 14:59:20 -080037#define AAC_NUM_IO_FIB_RKT (246 - AAC_NUM_MGT_FIB)
38
39/**
40 * aac_rkt_select_comm - Select communications method
41 * @dev: Adapter
42 * @comm: communications method
43 */
44
45static int aac_rkt_select_comm(struct aac_dev *dev, int comm)
46{
47 int retval;
Mark Haverkamp28713322007-01-23 14:59:20 -080048 retval = aac_rx_select_comm(dev, comm);
49 if (comm == AAC_COMM_MESSAGE) {
50 /*
51 * FIB Setup has already been done, but we can minimize the
52 * damage by at least ensuring the OS never issues more
53 * commands than we can handle. The Rocket adapters currently
54 * can only handle 246 commands and 8 AIFs at the same time,
55 * and in fact do notify us accordingly if we negotiate the
56 * FIB size. The problem that causes us to add this check is
57 * to ensure that we do not overdo it with the adapter when a
58 * hard coded FIB override is being utilized. This special
59 * case warrants this half baked, but convenient, check here.
60 */
61 if (dev->scsi_host_ptr->can_queue > AAC_NUM_IO_FIB_RKT) {
62 dev->init->MaxIoCommands =
63 cpu_to_le32(AAC_NUM_IO_FIB_RKT + AAC_NUM_MGT_FIB);
64 dev->scsi_host_ptr->can_queue = AAC_NUM_IO_FIB_RKT;
65 }
66 }
67 return retval;
68}
69
Mark Haverkamp76a7f8f2006-09-19 09:00:02 -070070/**
71 * aac_rkt_ioremap
72 * @size: mapping resize request
73 *
74 */
75static int aac_rkt_ioremap(struct aac_dev * dev, u32 size)
Linus Torvalds1da177e2005-04-16 15:20:36 -070076{
Mark Haverkamp76a7f8f2006-09-19 09:00:02 -070077 if (!size) {
78 iounmap(dev->regs.rkt);
79 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 }
Mark Haverkamp76a7f8f2006-09-19 09:00:02 -070081 dev->base = dev->regs.rkt = ioremap(dev->scsi_host_ptr->base, size);
82 if (dev->base == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 return -1;
Mark Haverkamp76a7f8f2006-09-19 09:00:02 -070084 dev->IndexRegs = &dev->regs.rkt->IndexRegs;
Mark Haverkamp8c23cd72006-08-08 08:52:14 -070085 return 0;
86}
87
Mark Haverkamp8e0c5eb2005-10-24 10:52:22 -070088/**
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 * aac_rkt_init - initialize an i960 based AAC card
90 * @dev: device to configure
91 *
92 * Allocate and set up resources for the i960 based AAC variants. The
93 * device_interface in the commregion will be allocated and linked
94 * to the comm region.
95 */
96
97int aac_rkt_init(struct aac_dev *dev)
98{
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 /*
100 * Fill in the function dispatch table.
101 */
Mark Haverkamp76a7f8f2006-09-19 09:00:02 -0700102 dev->a_ops.adapter_ioremap = aac_rkt_ioremap;
Mark Haverkamp28713322007-01-23 14:59:20 -0800103 dev->a_ops.adapter_comm = aac_rkt_select_comm;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104
Mark Haverkamp28713322007-01-23 14:59:20 -0800105 return _aac_rx_init(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106}