Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  *  Adaptec AAC series RAID controller driver
0004  *  (c) Copyright 2001 Red Hat Inc.
0005  *
0006  * based on the old aacraid driver that is..
0007  * Adaptec aacraid device driver for Linux.
0008  *
0009  * Copyright (c) 2000-2010 Adaptec, Inc.
0010  *               2010-2015 PMC-Sierra, Inc. (aacraid@pmc-sierra.com)
0011  *       2016-2017 Microsemi Corp. (aacraid@microsemi.com)
0012  *
0013  * Module Name:
0014  *  rkt.c
0015  *
0016  * Abstract: Hardware miniport for Drawbridge specific hardware functions.
0017  */
0018 
0019 #include <linux/blkdev.h>
0020 
0021 #include <scsi/scsi_host.h>
0022 
0023 #include "aacraid.h"
0024 
0025 #define AAC_NUM_IO_FIB_RKT      (246 - AAC_NUM_MGT_FIB)
0026 
0027 /**
0028  *  aac_rkt_select_comm -   Select communications method
0029  *  @dev: Adapter
0030  *  @comm: communications method
0031  */
0032 
0033 static int aac_rkt_select_comm(struct aac_dev *dev, int comm)
0034 {
0035     int retval;
0036     retval = aac_rx_select_comm(dev, comm);
0037     if (comm == AAC_COMM_MESSAGE) {
0038         /*
0039          * FIB Setup has already been done, but we can minimize the
0040          * damage by at least ensuring the OS never issues more
0041          * commands than we can handle. The Rocket adapters currently
0042          * can only handle 246 commands and 8 AIFs at the same time,
0043          * and in fact do notify us accordingly if we negotiate the
0044          * FIB size. The problem that causes us to add this check is
0045          * to ensure that we do not overdo it with the adapter when a
0046          * hard coded FIB override is being utilized. This special
0047          * case warrants this half baked, but convenient, check here.
0048          */
0049         if (dev->scsi_host_ptr->can_queue > AAC_NUM_IO_FIB_RKT) {
0050             dev->init->r7.max_io_commands =
0051                 cpu_to_le32(AAC_NUM_IO_FIB_RKT + AAC_NUM_MGT_FIB);
0052             dev->scsi_host_ptr->can_queue = AAC_NUM_IO_FIB_RKT;
0053         }
0054     }
0055     return retval;
0056 }
0057 
0058 /**
0059  *  aac_rkt_ioremap
0060  *  @dev: device to ioremap
0061  *  @size: mapping resize request
0062  *
0063  */
0064 static int aac_rkt_ioremap(struct aac_dev * dev, u32 size)
0065 {
0066     if (!size) {
0067         iounmap(dev->regs.rkt);
0068         return 0;
0069     }
0070     dev->base = dev->regs.rkt = ioremap(dev->base_start, size);
0071     if (dev->base == NULL)
0072         return -1;
0073     dev->IndexRegs = &dev->regs.rkt->IndexRegs;
0074     return 0;
0075 }
0076 
0077 /**
0078  *  aac_rkt_init    -   initialize an i960 based AAC card
0079  *  @dev: device to configure
0080  *
0081  *  Allocate and set up resources for the i960 based AAC variants. The
0082  *  device_interface in the commregion will be allocated and linked
0083  *  to the comm region.
0084  */
0085 
0086 int aac_rkt_init(struct aac_dev *dev)
0087 {
0088     /*
0089      *  Fill in the function dispatch table.
0090      */
0091     dev->a_ops.adapter_ioremap = aac_rkt_ioremap;
0092     dev->a_ops.adapter_comm = aac_rkt_select_comm;
0093 
0094     return _aac_rx_init(dev);
0095 }