Deleted Added
full compact
ncr53c500_pccard.c (194023) ncr53c500_pccard.c (240172)
1/* $NecBSD: ncr53c500_pisa.c,v 1.28 1998/11/26 01:59:11 honda Exp $ */
2/* $NetBSD$ */
3
4/*-
5 * [Ported for FreeBSD]
6 * Copyright (c) 2000
7 * Noriaki Mitsunaga, Mitsuru Iwasaki and Takanori Watanabe.
8 * All rights reserved.

--- 23 unchanged lines hidden (view full) ---

32 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39#include <sys/cdefs.h>
1/* $NecBSD: ncr53c500_pisa.c,v 1.28 1998/11/26 01:59:11 honda Exp $ */
2/* $NetBSD$ */
3
4/*-
5 * [Ported for FreeBSD]
6 * Copyright (c) 2000
7 * Noriaki Mitsunaga, Mitsuru Iwasaki and Takanori Watanabe.
8 * All rights reserved.

--- 23 unchanged lines hidden (view full) ---

32 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39#include <sys/cdefs.h>
40__FBSDID("$FreeBSD: head/sys/dev/ncv/ncr53c500_pccard.c 194023 2009-06-11 17:14:28Z avg $");
40__FBSDID("$FreeBSD: head/sys/dev/ncv/ncr53c500_pccard.c 240172 2012-09-06 18:53:33Z jhb $");
41
42#include <sys/param.h>
43#include <sys/errno.h>
44#include <sys/kernel.h>
45#include <sys/malloc.h>
41
42#include <sys/param.h>
43#include <sys/errno.h>
44#include <sys/kernel.h>
45#include <sys/malloc.h>
46#include <sys/module.h>
46#include <sys/systm.h>
47
48#include <machine/bus.h>
49#include <machine/resource.h>
50#include <sys/rman.h>
51#include <compat/netbsd/dvcfg.h>
52
47#include <sys/systm.h>
48
49#include <machine/bus.h>
50#include <machine/resource.h>
51#include <sys/rman.h>
52#include <compat/netbsd/dvcfg.h>
53
53#include <sys/device_port.h>
54#include <sys/bus.h>
54
55#include <dev/pccard/pccardvar.h>
56
57#include <cam/scsi/scsi_low.h>
58#include <cam/scsi/scsi_low_pisa.h>
59
60#include <dev/ncv/ncr53c500reg.h>
61#include <dev/ncv/ncr53c500hw.h>
62#include <dev/ncv/ncr53c500var.h>
63
64#define KME_KXLC004_01 0x100
65#define OFFSET_KME_KXLC004_01 0x10
66
67
68#include "pccarddevs.h"
69
55
56#include <dev/pccard/pccardvar.h>
57
58#include <cam/scsi/scsi_low.h>
59#include <cam/scsi/scsi_low_pisa.h>
60
61#include <dev/ncv/ncr53c500reg.h>
62#include <dev/ncv/ncr53c500hw.h>
63#include <dev/ncv/ncr53c500var.h>
64
65#define KME_KXLC004_01 0x100
66#define OFFSET_KME_KXLC004_01 0x10
67
68
69#include "pccarddevs.h"
70
70static int ncvprobe(DEVPORT_PDEVICE devi);
71static int ncvattach(DEVPORT_PDEVICE devi);
71static int ncvprobe(device_t devi);
72static int ncvattach(device_t devi);
72
73
73static void ncv_card_unload(DEVPORT_PDEVICE);
74static void ncv_card_unload(device_t);
74
75static const struct ncv_product {
76 struct pccard_product prod;
77 int flags;
78} ncv_products[] = {
79 { PCMCIA_CARD(EPSON, SC200), 0},
80 { PCMCIA_CARD(PANASONIC, KXLC002), 0xb4d00000 },
81 { PCMCIA_CARD(PANASONIC, KXLC003), 0xb4d00000 }, /* untested */

--- 15 unchanged lines hidden (view full) ---

97
98static void
99ncv_pccard_intr(void * arg)
100{
101 ncvintr(arg);
102}
103
104static void
75
76static const struct ncv_product {
77 struct pccard_product prod;
78 int flags;
79} ncv_products[] = {
80 { PCMCIA_CARD(EPSON, SC200), 0},
81 { PCMCIA_CARD(PANASONIC, KXLC002), 0xb4d00000 },
82 { PCMCIA_CARD(PANASONIC, KXLC003), 0xb4d00000 }, /* untested */

--- 15 unchanged lines hidden (view full) ---

98
99static void
100ncv_pccard_intr(void * arg)
101{
102 ncvintr(arg);
103}
104
105static void
105ncv_release_resource(DEVPORT_PDEVICE dev)
106ncv_release_resource(device_t dev)
106{
107 struct ncv_softc *sc = device_get_softc(dev);
108
109 if (sc->ncv_intrhand) {
110 bus_teardown_intr(dev, sc->irq_res, sc->ncv_intrhand);
111 }
112
113 if (sc->port_res) {

--- 13 unchanged lines hidden (view full) ---

127
128 if (sc->mem_res) {
129 bus_release_resource(dev, SYS_RES_MEMORY,
130 sc->mem_rid, sc->mem_res);
131 }
132}
133
134static int
107{
108 struct ncv_softc *sc = device_get_softc(dev);
109
110 if (sc->ncv_intrhand) {
111 bus_teardown_intr(dev, sc->irq_res, sc->ncv_intrhand);
112 }
113
114 if (sc->port_res) {

--- 13 unchanged lines hidden (view full) ---

128
129 if (sc->mem_res) {
130 bus_release_resource(dev, SYS_RES_MEMORY,
131 sc->mem_rid, sc->mem_res);
132 }
133}
134
135static int
135ncv_alloc_resource(DEVPORT_PDEVICE dev)
136ncv_alloc_resource(device_t dev)
136{
137 struct ncv_softc *sc = device_get_softc(dev);
137{
138 struct ncv_softc *sc = device_get_softc(dev);
138 u_int32_t flags = DEVPORT_PDEVFLAGS(dev);
139 u_int32_t flags = device_get_flags(dev);
139 u_long ioaddr, iosize, maddr, msize;
140 int error;
141 bus_addr_t offset = 0;
142
143 if(flags & KME_KXLC004_01)
144 offset = OFFSET_KME_KXLC004_01;
145
146 error = bus_get_resource(dev, SYS_RES_IOPORT, 0, &ioaddr, &iosize);

--- 138 unchanged lines hidden (view full) ---

285};
286
287static devclass_t ncv_devclass;
288
289MODULE_DEPEND(ncv, scsi_low, 1, 1, 1);
290DRIVER_MODULE(ncv, pccard, ncv_pccard_driver, ncv_devclass, 0, 0);
291
292static void
140 u_long ioaddr, iosize, maddr, msize;
141 int error;
142 bus_addr_t offset = 0;
143
144 if(flags & KME_KXLC004_01)
145 offset = OFFSET_KME_KXLC004_01;
146
147 error = bus_get_resource(dev, SYS_RES_IOPORT, 0, &ioaddr, &iosize);

--- 138 unchanged lines hidden (view full) ---

286};
287
288static devclass_t ncv_devclass;
289
290MODULE_DEPEND(ncv, scsi_low, 1, 1, 1);
291DRIVER_MODULE(ncv, pccard, ncv_pccard_driver, ncv_devclass, 0, 0);
292
293static void
293ncv_card_unload(DEVPORT_PDEVICE devi)
294ncv_card_unload(device_t devi)
294{
295{
295 struct ncv_softc *sc = DEVPORT_PDEVGET_SOFTC(devi);
296 struct ncv_softc *sc = device_get_softc(devi);
296 intrmask_t s;
297
298 s = splcam();
299 scsi_low_deactivate((struct scsi_low_softc *)sc);
300 scsi_low_dettach(&sc->sc_sclow);
301 splx(s);
302}
303
304static int
297 intrmask_t s;
298
299 s = splcam();
300 scsi_low_deactivate((struct scsi_low_softc *)sc);
301 scsi_low_dettach(&sc->sc_sclow);
302 splx(s);
303}
304
305static int
305ncvprobe(DEVPORT_PDEVICE devi)
306ncvprobe(device_t devi)
306{
307 int rv;
308 struct ncv_softc *sc = device_get_softc(devi);
307{
308 int rv;
309 struct ncv_softc *sc = device_get_softc(devi);
309 u_int32_t flags = DEVPORT_PDEVFLAGS(devi);
310 u_int32_t flags = device_get_flags(devi);
310
311 rv = ncvprobesubr(rman_get_bustag(sc->port_res),
312 rman_get_bushandle(sc->port_res),
313 flags, NCV_HOSTID);
314
315 return rv;
316}
317
318static int
311
312 rv = ncvprobesubr(rman_get_bustag(sc->port_res),
313 rman_get_bushandle(sc->port_res),
314 flags, NCV_HOSTID);
315
316 return rv;
317}
318
319static int
319ncvattach(DEVPORT_PDEVICE devi)
320ncvattach(device_t devi)
320{
321 struct ncv_softc *sc;
322 struct scsi_low_softc *slp;
321{
322 struct ncv_softc *sc;
323 struct scsi_low_softc *slp;
323 u_int32_t flags = DEVPORT_PDEVFLAGS(devi);
324 u_int32_t flags = device_get_flags(devi);
324 intrmask_t s;
325 char dvname[16]; /* SCSI_LOW_DVNAME_LEN */
326
327 strcpy(dvname, "ncv");
328
325 intrmask_t s;
326 char dvname[16]; /* SCSI_LOW_DVNAME_LEN */
327
328 strcpy(dvname, "ncv");
329
329 sc = DEVPORT_PDEVALLOC_SOFTC(devi);
330 sc = device_get_softc(devi);
330 if (sc == NULL) {
331 return(0);
332 }
333
334 slp = &sc->sc_sclow;
335 slp->sl_dev = devi;
336 sc->sc_iot = rman_get_bustag(sc->port_res);
337 sc->sc_ioh = rman_get_bushandle(sc->port_res);
338
339 slp->sl_hostid = NCV_HOSTID;
340 slp->sl_cfgflags = flags;
341
342 s = splcam();
343 ncvattachsubr(sc);
344 splx(s);
345
346 return(NCVIOSZ);
347}
331 if (sc == NULL) {
332 return(0);
333 }
334
335 slp = &sc->sc_sclow;
336 slp->sl_dev = devi;
337 sc->sc_iot = rman_get_bustag(sc->port_res);
338 sc->sc_ioh = rman_get_bushandle(sc->port_res);
339
340 slp->sl_hostid = NCV_HOSTID;
341 slp->sl_cfgflags = flags;
342
343 s = splcam();
344 ncvattachsubr(sc);
345 splx(s);
346
347 return(NCVIOSZ);
348}