xref: /openbmc/linux/drivers/scsi/aacraid/nark.c (revision 0a907292)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  *	Adaptec AAC series RAID controller driver
4  *
5  * based on the old aacraid driver that is..
6  * Adaptec aacraid device driver for Linux.
7  *
8  * Copyright (c) 2000-2010 Adaptec, Inc.
9  *               2010-2015 PMC-Sierra, Inc. (aacraid@pmc-sierra.com)
10  *		 2016-2017 Microsemi Corp. (aacraid@microsemi.com)
11  *
12  * Module Name:
13  *  nark.c
14  *
15  * Abstract: Hardware Device Interface for NEMER/ARK
16  */
17 
18 #include <linux/pci.h>
19 #include <linux/blkdev.h>
20 
21 #include <scsi/scsi_host.h>
22 
23 #include "aacraid.h"
24 
25 /**
26  *	aac_nark_ioremap
27  *	@dev: device to ioremap
28  *	@size: mapping resize request
29  *
30  */
31 static int aac_nark_ioremap(struct aac_dev * dev, u32 size)
32 {
33 	if (!size) {
34 		iounmap(dev->regs.rx);
35 		dev->regs.rx = NULL;
36 		iounmap(dev->base);
37 		dev->base = NULL;
38 		return 0;
39 	}
40 	dev->base_start = pci_resource_start(dev->pdev, 2);
41 	dev->regs.rx = ioremap((u64)pci_resource_start(dev->pdev, 0) |
42 	  ((u64)pci_resource_start(dev->pdev, 1) << 32),
43 	  sizeof(struct rx_registers) - sizeof(struct rx_inbound));
44 	dev->base = NULL;
45 	if (dev->regs.rx == NULL)
46 		return -1;
47 	dev->base = ioremap(dev->base_start, size);
48 	if (dev->base == NULL) {
49 		iounmap(dev->regs.rx);
50 		dev->regs.rx = NULL;
51 		return -1;
52 	}
53 	dev->IndexRegs = &((struct rx_registers __iomem *)dev->base)->IndexRegs;
54 	return 0;
55 }
56 
57 /**
58  *	aac_nark_init	-	initialize an NEMER/ARK Split Bar card
59  *	@dev: device to configure
60  *
61  */
62 
63 int aac_nark_init(struct aac_dev * dev)
64 {
65 	/*
66 	 *	Fill in the function dispatch table.
67 	 */
68 	dev->a_ops.adapter_ioremap = aac_nark_ioremap;
69 	dev->a_ops.adapter_comm = aac_rx_select_comm;
70 
71 	return _aac_rx_init(dev);
72 }
73