summaryrefslogtreecommitdiffstats
path: root/sys/i4b/layer1/i4b_isic_pcmcia.c
blob: 466ad56a9b34c103b33561f2fff22ad87548806e (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/*
 *   Copyright (c) 1998 Matthias Apitz. All rights reserved.
 *
 *   Copyright (c) 1998, 1999 Hellmuth Michaelis. 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, 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. Neither the name of the author nor the names of any co-contributors
 *      may be used to endorse or promote products derived from this software
 *      without specific prior written permission.
 *   4. Altered versions must be plainly marked as such, and must not be
 *      misrepresented as being the original software and/or documentation.
 *   
 *   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 *   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 *   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 *   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 *   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 *   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 *   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 *   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 *   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 *   SUCH DAMAGE.
 *
 *---------------------------------------------------------------------------
 *
 *	i4b_isic_pcmcia.c - i4b FreeBSD PCMCIA support
 *	----------------------------------------------
 *
 * $FreeBSD$
 *
 *      last edit-date: [Mon Apr 26 10:52:57 1999]
 *
 *---------------------------------------------------------------------------*/

#ifdef __FreeBSD__
#include "isic.h"
#include "opt_i4b.h"
#include "card.h"
#undef NCARD
#define NCARD 0

#if (NISIC > 0) && (NCARD > 0)
 
#include "apm.h"
#include <sys/types.h>
#include <sys/select.h>
#include <sys/param.h>
#include <i386/isa/isa_device.h>

#if defined(__FreeBSD__) && __FreeBSD__ >= 3
#include <sys/ioccom.h>
#else
#include <sys/ioctl.h>
#endif

#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/mbuf.h>
#include <sys/socket.h>
#include <net/if.h>
#include <machine/clock.h>
#include <i386/isa/isa_device.h>

#include <pccard/cardinfo.h>
#include <pccard/driver.h>
#include <pccard/slot.h>

#include <machine/i4b_debug.h>
#include <machine/i4b_ioctl.h>
#include <machine/i4b_trace.h>

#include <i4b/layer1/i4b_l1.h>
#include <i4b/layer1/i4b_isac.h>
#include <i4b/layer1/i4b_hscx.h>

#include <i4b/include/i4b_l1l2.h>
#include <i4b/include/i4b_mbuf.h>
#include <i4b/include/i4b_global.h>

#ifdef __FreeBSD__

#if !(defined(__FreeBSD_version)) || (defined(__FreeBSD_version) && __FreeBSD_version >= 300006)
void isicintr ( int unit );
#else
extern void isicintr(int unit);
#endif

#endif
 
extern int isicattach(struct isa_device *dev);

/*  
 * PC-Card (PCMCIA) specific code.
 */
static int  isic_pccard_init    __P((struct pccard_devinfo *));
static void isic_unload         __P((struct pccard_devinfo *));
static int  isic_card_intr      __P((struct pccard_devinfo *));
    
#if defined(__FreeBSD__) && __FreeBSD__ < 3
static struct pccard_device isic_info = {
    "isic",
    isic_pccard_init,
    isic_unload,
    isic_card_intr,
    0,                      /* Attributes - presently unused */
    &net_imask
};      
  
DATA_SET(pccarddrv_set, isic_info);
#else
PCCARD_MODULE(isic, isic_pccard_init, isic_unload, isic_card_intr, 0,net_imask);
#endif


/*
 * Initialize the device - called from Slot manager.
 */

static int opened = 0;			/* our cards status */

static int isic_pccard_init(devi)
struct pccard_devinfo *devi;
{   
#ifdef AVM_A1_PCMCIA
    	struct isa_device *is = &devi->isahd;

	if ((1 << is->id_unit) & opened)
		return(EBUSY);

	opened |= 1 << is->id_unit;
	printf("isic%d: PCMCIA init, irqmask = 0x%x (%d), iobase = 0x%x\n",
                is->id_unit, is->id_irq, devi->slt->irq, is->id_iobase);

	/* 
	 * look if there is really an AVM PCMCIA Fritz!Card and
	 * setup the card specific stuff
	 */
	isic_probe_avma1_pcmcia(is);

	/* ap:
	 * XXX what's to do with the return value?
	 */

	/*
	 * try to attach the PCMCIA card as a normal A1 card
	 */

	isic_realattach(is, 0);

#endif
	return(0);
}

static void isic_unload(devi)
struct pccard_devinfo *devi;
{   
    	struct isa_device *is = &devi->isahd;
	printf("isic%d: unloaded\n", is->id_unit);
	opened &= ~(1 << is->id_unit);
}

/*
 * card_intr - Shared interrupt called from
 * front end of PC-Card handler.
 */
static int isic_card_intr(devi)
struct pccard_devinfo *devi;
{   
	isicintr(devi->isahd.id_unit);
	return(1);
}   

#endif /* (NISIC > 0) && (NCARD > 0) */
#endif /* __FreeBSD__ */
OpenPOWER on IntegriCloud