blob: 5f2cede4d47762339cf1004470053897e6ef2ce8 [file] [log] [blame]
Thomas Gleixnerc82ee6d2019-05-19 15:51:48 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * Adaptec AAC series RAID controller driver
Alan Coxfa195af2008-10-27 15:16:36 +00004 * (c) Copyright 2001 Red Hat Inc.
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 *
6 * based on the old aacraid driver that is..
7 * Adaptec aacraid device driver for Linux.
8 *
Mahesh Rajashekharae8b12f02011-03-17 02:10:32 -07009 * Copyright (c) 2000-2010 Adaptec, Inc.
Raghava Aditya Renukuntaf4babba2017-02-02 15:53:36 -080010 * 2010-2015 PMC-Sierra, Inc. (aacraid@pmc-sierra.com)
11 * 2016-2017 Microsemi Corp. (aacraid@microsemi.com)
Linus Torvalds1da177e2005-04-16 15:20:36 -070012 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 * Module Name:
14 * rkt.c
15 *
16 * Abstract: Hardware miniport for Drawbridge specific hardware functions.
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 */
18
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <linux/blkdev.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
21#include <scsi/scsi_host.h>
22
23#include "aacraid.h"
24
Mark Haverkamp28713322007-01-23 14:59:20 -080025#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;
Mark Haverkamp28713322007-01-23 14:59:20 -080036 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) {
Raghava Aditya Renukuntad1ef4da2017-02-02 15:53:17 -080050 dev->init->r7.max_io_commands =
Mark Haverkamp28713322007-01-23 14:59:20 -080051 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
Mark Haverkamp76a7f8f2006-09-19 09:00:02 -070058/**
59 * aac_rkt_ioremap
60 * @size: mapping resize request
61 *
62 */
63static int aac_rkt_ioremap(struct aac_dev * dev, u32 size)
Linus Torvalds1da177e2005-04-16 15:20:36 -070064{
Mark Haverkamp76a7f8f2006-09-19 09:00:02 -070065 if (!size) {
66 iounmap(dev->regs.rkt);
67 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 }
Ben Collinsff087842012-06-11 14:05:02 -040069 dev->base = dev->regs.rkt = ioremap(dev->base_start, size);
Mark Haverkamp76a7f8f2006-09-19 09:00:02 -070070 if (dev->base == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 return -1;
Mark Haverkamp76a7f8f2006-09-19 09:00:02 -070072 dev->IndexRegs = &dev->regs.rkt->IndexRegs;
Mark Haverkamp8c23cd72006-08-08 08:52:14 -070073 return 0;
74}
75
Mark Haverkamp8e0c5eb2005-10-24 10:52:22 -070076/**
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 * aac_rkt_init - initialize an i960 based AAC card
78 * @dev: device to configure
79 *
80 * Allocate and set up resources for the i960 based AAC variants. The
81 * device_interface in the commregion will be allocated and linked
82 * to the comm region.
83 */
84
85int aac_rkt_init(struct aac_dev *dev)
86{
Linus Torvalds1da177e2005-04-16 15:20:36 -070087 /*
88 * Fill in the function dispatch table.
89 */
Mark Haverkamp76a7f8f2006-09-19 09:00:02 -070090 dev->a_ops.adapter_ioremap = aac_rkt_ioremap;
Mark Haverkamp28713322007-01-23 14:59:20 -080091 dev->a_ops.adapter_comm = aac_rkt_select_comm;
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
Mark Haverkamp28713322007-01-23 14:59:20 -080093 return _aac_rx_init(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070094}