xref: /openbmc/linux/drivers/scsi/aacraid/nark.c (revision df2634f43f5106947f3735a0b61a6527a4b278cd)
1 /*
2  *	Adaptec AAC series RAID controller driver
3  *
4  * based on the old aacraid driver that is..
5  * Adaptec aacraid device driver for Linux.
6  *
7  * Copyright (c) 2006-2007 Adaptec, Inc. (aacraid@adaptec.com)
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2, or (at your option)
12  * any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; see the file COPYING.  If not, write to
21  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22  *
23  * Module Name:
24  *  nark.c
25  *
26  * Abstract: Hardware Device Interface for NEMER/ARK
27  *
28  */
29 
30 #include <linux/pci.h>
31 #include <linux/blkdev.h>
32 
33 #include <scsi/scsi_host.h>
34 
35 #include "aacraid.h"
36 
37 /**
38  *	aac_nark_ioremap
39  *	@size: mapping resize request
40  *
41  */
42 static int aac_nark_ioremap(struct aac_dev * dev, u32 size)
43 {
44 	if (!size) {
45 		iounmap(dev->regs.rx);
46 		dev->regs.rx = NULL;
47 		iounmap(dev->base);
48 		dev->base = NULL;
49 		return 0;
50 	}
51 	dev->scsi_host_ptr->base = pci_resource_start(dev->pdev, 2);
52 	dev->regs.rx = ioremap((u64)pci_resource_start(dev->pdev, 0) |
53 	  ((u64)pci_resource_start(dev->pdev, 1) << 32),
54 	  sizeof(struct rx_registers) - sizeof(struct rx_inbound));
55 	dev->base = NULL;
56 	if (dev->regs.rx == NULL)
57 		return -1;
58 	dev->base = ioremap(dev->scsi_host_ptr->base, size);
59 	if (dev->base == NULL) {
60 		iounmap(dev->regs.rx);
61 		dev->regs.rx = NULL;
62 		return -1;
63 	}
64 	dev->IndexRegs = &((struct rx_registers __iomem *)dev->base)->IndexRegs;
65 	return 0;
66 }
67 
68 /**
69  *	aac_nark_init	-	initialize an NEMER/ARK Split Bar card
70  *	@dev: device to configure
71  *
72  */
73 
74 int aac_nark_init(struct aac_dev * dev)
75 {
76 	/*
77 	 *	Fill in the function dispatch table.
78 	 */
79 	dev->a_ops.adapter_ioremap = aac_nark_ioremap;
80 	dev->a_ops.adapter_comm = aac_rx_select_comm;
81 
82 	return _aac_rx_init(dev);
83 }
84