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