Linux 6.10-rc7
[linux-2.6-block.git] / drivers / scsi / aacraid / rkt.c
CommitLineData
c82ee6d3 1// SPDX-License-Identifier: GPL-2.0-or-later
1da177e4
LT
2/*
3 * Adaptec AAC series RAID controller driver
fa195afe 4 * (c) Copyright 2001 Red Hat Inc.
1da177e4
LT
5 *
6 * based on the old aacraid driver that is..
7 * Adaptec aacraid device driver for Linux.
8 *
e8b12f0f 9 * Copyright (c) 2000-2010 Adaptec, Inc.
f4babba0
RAR
10 * 2010-2015 PMC-Sierra, Inc. (aacraid@pmc-sierra.com)
11 * 2016-2017 Microsemi Corp. (aacraid@microsemi.com)
1da177e4 12 *
1da177e4
LT
13 * Module Name:
14 * rkt.c
15 *
16 * Abstract: Hardware miniport for Drawbridge specific hardware functions.
1da177e4
LT
17 */
18
1da177e4 19#include <linux/blkdev.h>
1da177e4
LT
20
21#include <scsi/scsi_host.h>
22
23#include "aacraid.h"
24
28713324
MH
25#define AAC_NUM_IO_FIB_RKT (246 - AAC_NUM_MGT_FIB)
26
27/**
28 * aac_rkt_select_comm - Select communications method
29 * @dev: Adapter
30 * @comm: communications method
31 */
32
33static int aac_rkt_select_comm(struct aac_dev *dev, int comm)
34{
35 int retval;
28713324
MH
36 retval = aac_rx_select_comm(dev, comm);
37 if (comm == AAC_COMM_MESSAGE) {
38 /*
39 * FIB Setup has already been done, but we can minimize the
40 * damage by at least ensuring the OS never issues more
41 * commands than we can handle. The Rocket adapters currently
42 * can only handle 246 commands and 8 AIFs at the same time,
43 * and in fact do notify us accordingly if we negotiate the
44 * FIB size. The problem that causes us to add this check is
45 * to ensure that we do not overdo it with the adapter when a
46 * hard coded FIB override is being utilized. This special
47 * case warrants this half baked, but convenient, check here.
48 */
49 if (dev->scsi_host_ptr->can_queue > AAC_NUM_IO_FIB_RKT) {
d1ef4da8 50 dev->init->r7.max_io_commands =
28713324
MH
51 cpu_to_le32(AAC_NUM_IO_FIB_RKT + AAC_NUM_MGT_FIB);
52 dev->scsi_host_ptr->can_queue = AAC_NUM_IO_FIB_RKT;
53 }
54 }
55 return retval;
56}
57
1da177e4 58/**
76a7f8fd 59 * aac_rkt_ioremap
3c4538f8 60 * @dev: device to ioremap
76a7f8fd 61 * @size: mapping resize request
1da177e4 62 *
1da177e4 63 */
76a7f8fd 64static int aac_rkt_ioremap(struct aac_dev * dev, u32 size)
1da177e4 65{
76a7f8fd
MH
66 if (!size) {
67 iounmap(dev->regs.rkt);
68 return 0;
1da177e4 69 }
ff08784b 70 dev->base = dev->regs.rkt = ioremap(dev->base_start, size);
76a7f8fd 71 if (dev->base == NULL)
1da177e4 72 return -1;
76a7f8fd 73 dev->IndexRegs = &dev->regs.rkt->IndexRegs;
8c23cd74
MH
74 return 0;
75}
76
1da177e4
LT
77/**
78 * aac_rkt_init - initialize an i960 based AAC card
79 * @dev: device to configure
80 *
3c4538f8
LJ
81 * Allocate and set up resources for the i960 based AAC variants. The
82 * device_interface in the commregion will be allocated and linked
1da177e4
LT
83 * to the comm region.
84 */
85
86int aac_rkt_init(struct aac_dev *dev)
87{
1da177e4
LT
88 /*
89 * Fill in the function dispatch table.
90 */
76a7f8fd 91 dev->a_ops.adapter_ioremap = aac_rkt_ioremap;
28713324 92 dev->a_ops.adapter_comm = aac_rkt_select_comm;
bd1aac80 93
28713324 94 return _aac_rx_init(dev);
1da177e4 95}