summaryrefslogtreecommitdiff
path: root/sys/dev/pci/aic7870.c
blob: 17f8e551eeaa753a6a19f03850d4fc2ed905d51f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
 * Product specific probe and attach routines for:
 *      294X and aic7870 motherboard SCSI controllers
 *
 * Copyright (c) 1995 Justin T. Gibbs
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice immediately at the beginning of the file, without modification,
 *    this list of conditions, and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Absolutely no warranty of function or purpose is made by the author
 *    Justin T. Gibbs.
 * 4. Modifications may be freely made to this file if the above conditions
 *    are met.
 *
 *	$Id: aic7870.c,v 1.1 1995/10/18 08:52:39 deraadt Exp $
 */

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/malloc.h>
#include <sys/kernel.h>
#include <sys/device.h>

#include <scsi/scsi_all.h>
#include <scsi/scsiconf.h>

#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <dev/ic/aic7xxxvar.h>


#define PCI_BASEADR0	PCI_MAP_REG_START
#define PCI_DEVICE_ID_ADAPTEC_2940	0x71789004ul
#define PCI_DEVICE_ID_ADAPTEC_AIC7870	0x70789004ul


static int aic7870_probe();
static void aic7870_attach();

struct cfdriver ahccd = {
        NULL, "ahc", aic7870_probe, aic7870_attach, DV_DULL, 
        sizeof(struct ahc_softc)
}; 

int ahcintr __P((void *));
      

int
aic7870_probe(parent, match, aux)
        struct device *parent;
        void *match, *aux; 
{       
        struct pci_attach_args *pa = aux;

	if (pa->pa_id != PCI_DEVICE_ID_ADAPTEC_2940 &&
	    pa->pa_id != PCI_DEVICE_ID_ADAPTEC_AIC7870)
		return (0);

	return (1);
}

void    
aic7870_attach(parent, self, aux)
        struct device *parent, *self;
        void *aux;
{       
        struct pci_attach_args *pa = aux;
        struct ahc_softc *ahc = (void *)self;
	int iobase; 

        switch (pa->pa_id) {
        case PCI_DEVICE_ID_ADAPTEC_2940:
		ahc->type = AHC_294;
                break;
        case PCI_DEVICE_ID_ADAPTEC_AIC7870:
		ahc->type = AHC_AIC7870;
                break;
        }

	if (pci_map_io(pa->pa_tag, PCI_BASEADR0, &iobase))
		return;

	/*
	 * Make the offsets the same as for EISA
	 */
	iobase -= 0xc00ul; 

	if (ahcprobe(ahc, iobase) == 0)
		return;

	ahcattach(ahc);

	ahc->sc_ih = pci_map_int(pa->pa_tag, PCI_IPL_BIO, ahcintr, ahc);
}