1/* $NetBSD: pcmcia.c,v 1.23 2000/07/28 19:17:02 drochner Exp $ */ |
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 |
58#define PRVERBOSE(arg) printf arg 59#define DEVPRVERBOSE(arg) device_printf 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 |
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 |
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); |
177 if (pccard_function_enable(pf) == 0 && 178 device_probe_and_attach(child) == 0) { |
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 */ |
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 |
378 if (pf->cfe == NULL) { 379 DEVPRVERBOSE((dev, "No config entry could be allocated.\n")); 380 return ENOMEM; 381 } |
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{ |
668 device_set_desc(dev, "16-bit PCCard bus"); |
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 |
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), |
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 --- |