Deleted Added
full compact
pccard.c (67269) pccard.c (67333)
1/* $NetBSD: pcmcia.c,v 1.23 2000/07/28 19:17:02 drochner Exp $ */
1/* $NetBSD: pcmcia.c,v 1.23 2000/07/28 19:17:02 drochner Exp $ */
2/* $FreeBSD: head/sys/dev/pccard/pccard.c 67269 2000-10-18 02:21:00Z imp $ */
2/* $FreeBSD: head/sys/dev/pccard/pccard.c 67333 2000-10-19 22:36:41Z imp $ */
3
4/*
5 * Copyright (c) 1997 Marc Horowitz. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright

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

50#include "card_if.h"
51
52#define PCCARDDEBUG
53
54#ifdef PCCARDDEBUG
55int pccard_debug = 1;
56#define DPRINTF(arg) if (pccard_debug) printf arg
57#define DEVPRINTF(arg) if (pccard_debug) device_printf arg
3
4/*
5 * Copyright (c) 1997 Marc Horowitz. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright

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

50#include "card_if.h"
51
52#define PCCARDDEBUG
53
54#ifdef PCCARDDEBUG
55int pccard_debug = 1;
56#define DPRINTF(arg) if (pccard_debug) printf arg
57#define DEVPRINTF(arg) if (pccard_debug) device_printf arg
58#define PRVERBOSE(arg) printf arg
59#define DEVPRVERBOSE(arg) device_printf arg
58#else
59#define DPRINTF(arg)
60#define DEVPRINTF(arg)
60#else
61#define DPRINTF(arg)
62#define DEVPRINTF(arg)
63#define PRVERBOSE(arg) if (bootverbose) printf arg
64#define DEVPRVERBOSE(arg) if (bootverbose) device_printf arg
61#endif
62
63#ifdef PCCARDVERBOSE
64int pccard_verbose = 1;
65#else
66int pccard_verbose = 0;
67#endif
68

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

136 pf->sc = sc;
137 pf->cfe = NULL;
138 pf->dev = NULL;
139 }
140#if 0
141 DEVPRINTF((dev, "chip_socket_disable\n"));
142 POWER_DISABLE_SOCKET(device_get_parent(dev), dev);
143#endif
65#endif
66
67#ifdef PCCARDVERBOSE
68int pccard_verbose = 1;
69#else
70int pccard_verbose = 0;
71#endif
72

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

140 pf->sc = sc;
141 pf->cfe = NULL;
142 pf->dev = NULL;
143 }
144#if 0
145 DEVPRINTF((dev, "chip_socket_disable\n"));
146 POWER_DISABLE_SOCKET(device_get_parent(dev), dev);
147#endif
144
145 STAILQ_FOREACH(pf, &sc->card.pf_head, pf_list) {
146 if (STAILQ_EMPTY(&pf->cfe_head))
147 continue;
148 /*
149 * In NetBSD, the drivers are responsible for activating
150 * each function of a card. I think that in FreeBSD we
151 * want to activate them enough for the usual bus_*_resource
152 * routines will do the right thing. This many mean a

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

166 * XXX We might want to move the next two lines into
167 * XXX the pccard interface layer. For the moment, this
168 * XXX is OK, but some drivers want to pick the config
169 * XXX entry to use as well as some address tweaks (mostly
170 * XXX due to bugs in decode logic that makes some
171 * XXX addresses illegal or broken).
172 */
173 pccard_function_init(pf);
148 STAILQ_FOREACH(pf, &sc->card.pf_head, pf_list) {
149 if (STAILQ_EMPTY(&pf->cfe_head))
150 continue;
151 /*
152 * In NetBSD, the drivers are responsible for activating
153 * each function of a card. I think that in FreeBSD we
154 * want to activate them enough for the usual bus_*_resource
155 * routines will do the right thing. This many mean a

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

169 * XXX We might want to move the next two lines into
170 * XXX the pccard interface layer. For the moment, this
171 * XXX is OK, but some drivers want to pick the config
172 * XXX entry to use as well as some address tweaks (mostly
173 * XXX due to bugs in decode logic that makes some
174 * XXX addresses illegal or broken).
175 */
176 pccard_function_init(pf);
174 pccard_function_enable(pf);
175 if (device_probe_and_attach(child) == 0) {
177 if (pccard_function_enable(pf) == 0 &&
178 device_probe_and_attach(child) == 0) {
176 attached++;
177
178 DEVPRINTF((sc->dev, "function %d CCR at %d "
179 "offset %x: %x %x %x %x, %x %x %x %x, %x\n",
180 pf->number, pf->pf_ccr_window, pf->pf_ccr_offset,
181 pccard_ccr_read(pf, 0x00),
182 pccard_ccr_read(pf, 0x02), pccard_ccr_read(pf, 0x04),
183 pccard_ccr_read(pf, 0x06), pccard_ccr_read(pf, 0x0A),

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

339 resource_list_add(rl, SYS_RES_IRQ, cfe->irqrid,
340 rman_get_start(r), rman_get_end(r), 1);
341 }
342 /* XXX Don't know how to deal with maxtwins */
343 /* If we get to here, we've allocated all we need */
344 pf->cfe = cfe;
345 break;
346 not_this_one:;
179 attached++;
180
181 DEVPRINTF((sc->dev, "function %d CCR at %d "
182 "offset %x: %x %x %x %x, %x %x %x %x, %x\n",
183 pf->number, pf->pf_ccr_window, pf->pf_ccr_offset,
184 pccard_ccr_read(pf, 0x00),
185 pccard_ccr_read(pf, 0x02), pccard_ccr_read(pf, 0x04),
186 pccard_ccr_read(pf, 0x06), pccard_ccr_read(pf, 0x0A),

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

342 resource_list_add(rl, SYS_RES_IRQ, cfe->irqrid,
343 rman_get_start(r), rman_get_end(r), 1);
344 }
345 /* XXX Don't know how to deal with maxtwins */
346 /* If we get to here, we've allocated all we need */
347 pf->cfe = cfe;
348 break;
349 not_this_one:;
350 /*
351 * Release resources that we partially allocated
352 * from this config entry.
353 */
347 for (i = 0; i < cfe->num_iospace; i++) {
348 resource_list_delete(rl, SYS_RES_IOPORT, i);
349 if (cfe->iores[i])
350 bus_release_resource(bus, SYS_RES_IOPORT,
351 cfe->iorid[i], cfe->iores[i]);
352 cfe->iores[i] = NULL;
353 }
354 if (cfe->irqmask && cfe->irqres) {

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

363/* Enable a PCCARD function */
364int
365pccard_function_enable(struct pccard_function *pf)
366{
367 struct pccard_function *tmp;
368 int reg;
369 device_t dev = pf->sc->dev;
370
354 for (i = 0; i < cfe->num_iospace; i++) {
355 resource_list_delete(rl, SYS_RES_IOPORT, i);
356 if (cfe->iores[i])
357 bus_release_resource(bus, SYS_RES_IOPORT,
358 cfe->iorid[i], cfe->iores[i]);
359 cfe->iores[i] = NULL;
360 }
361 if (cfe->irqmask && cfe->irqres) {

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

370/* Enable a PCCARD function */
371int
372pccard_function_enable(struct pccard_function *pf)
373{
374 struct pccard_function *tmp;
375 int reg;
376 device_t dev = pf->sc->dev;
377
371 if (pf->cfe == NULL)
372 panic("pccard_function_enable: function not initialized");
378 if (pf->cfe == NULL) {
379 DEVPRVERBOSE((dev, "No config entry could be allocated.\n"));
380 return ENOMEM;
381 }
373
374 /*
375 * Increase the reference count on the socket, enabling power, if
376 * necessary.
377 */
378 if (pf->sc->sc_enabled_count++ == 0)
379 POWER_ENABLE_SOCKET(device_get_parent(dev), dev);
380 DEVPRINTF((dev, "++enabled_count = %d\n", pf->sc->sc_enabled_count));

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

651{
652 /* Call parent to scan for any current children */
653 return 0;
654}
655
656static int
657pccard_probe(device_t dev)
658{
382
383 /*
384 * Increase the reference count on the socket, enabling power, if
385 * necessary.
386 */
387 if (pf->sc->sc_enabled_count++ == 0)
388 POWER_ENABLE_SOCKET(device_get_parent(dev), dev);
389 DEVPRINTF((dev, "++enabled_count = %d\n", pf->sc->sc_enabled_count));

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

660{
661 /* Call parent to scan for any current children */
662 return 0;
663}
664
665static int
666pccard_probe(device_t dev)
667{
659 device_set_desc(dev, "PC Card bus -- newconfig version");
668 device_set_desc(dev, "16-bit PCCard bus");
660 return pccard_add_children(dev, device_get_unit(dev));
661}
662
663static int
664pccard_attach(device_t dev)
665{
666 struct pccard_softc *sc = PCCARD_SOFTC(dev);
667

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

904static int
905pccard_deactivate_resource(device_t dev, device_t child, int type, int rid,
906 struct resource *r)
907{
908 /* XXX need to write to the COR to deactivate this for mf cards */
909 return (bus_generic_deactivate_resource(dev, child, type, rid, r));
910}
911
669 return pccard_add_children(dev, device_get_unit(dev));
670}
671
672static int
673pccard_attach(device_t dev)
674{
675 struct pccard_softc *sc = PCCARD_SOFTC(dev);
676

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

913static int
914pccard_deactivate_resource(device_t dev, device_t child, int type, int rid,
915 struct resource *r)
916{
917 /* XXX need to write to the COR to deactivate this for mf cards */
918 return (bus_generic_deactivate_resource(dev, child, type, rid, r));
919}
920
921static void
922pccard_child_detached(device_t parent, device_t dev)
923{
924 struct pccard_ivar *ivar = PCCARD_IVAR(dev);
925
926 if (parent == device_get_parent(dev))
927 free(ivar, M_DEVBUF);
928}
929
912static device_method_t pccard_methods[] = {
913 /* Device interface */
914 DEVMETHOD(device_probe, pccard_probe),
915 DEVMETHOD(device_attach, pccard_attach),
916 DEVMETHOD(device_detach, bus_generic_detach),
917 DEVMETHOD(device_shutdown, bus_generic_shutdown),
918 DEVMETHOD(device_suspend, bus_generic_suspend),
919 DEVMETHOD(device_resume, bus_generic_resume),
920
921 /* Bus interface */
922 DEVMETHOD(bus_print_child, pccard_print_child),
923 DEVMETHOD(bus_driver_added, pccard_driver_added),
930static device_method_t pccard_methods[] = {
931 /* Device interface */
932 DEVMETHOD(device_probe, pccard_probe),
933 DEVMETHOD(device_attach, pccard_attach),
934 DEVMETHOD(device_detach, bus_generic_detach),
935 DEVMETHOD(device_shutdown, bus_generic_shutdown),
936 DEVMETHOD(device_suspend, bus_generic_suspend),
937 DEVMETHOD(device_resume, bus_generic_resume),
938
939 /* Bus interface */
940 DEVMETHOD(bus_print_child, pccard_print_child),
941 DEVMETHOD(bus_driver_added, pccard_driver_added),
942 DEVMETHOD(bus_child_detached, pccard_child_detached),
924 DEVMETHOD(bus_alloc_resource, pccard_alloc_resource),
925 DEVMETHOD(bus_release_resource, pccard_release_resource),
926 DEVMETHOD(bus_activate_resource, pccard_activate_resource),
927 DEVMETHOD(bus_deactivate_resource, pccard_deactivate_resource),
928 DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
929 DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
930 DEVMETHOD(bus_set_resource, pccard_set_resource),
931 DEVMETHOD(bus_get_resource, pccard_get_resource),

--- 27 unchanged lines hidden ---
943 DEVMETHOD(bus_alloc_resource, pccard_alloc_resource),
944 DEVMETHOD(bus_release_resource, pccard_release_resource),
945 DEVMETHOD(bus_activate_resource, pccard_activate_resource),
946 DEVMETHOD(bus_deactivate_resource, pccard_deactivate_resource),
947 DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
948 DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
949 DEVMETHOD(bus_set_resource, pccard_set_resource),
950 DEVMETHOD(bus_get_resource, pccard_get_resource),

--- 27 unchanged lines hidden ---