pccard.c (61788) | pccard.c (64850) |
---|---|
1/* $NetBSD: pcmcia.c,v 1.13 1998/12/24 04:51:59 marc Exp $ */ | 1/* $NetBSD: pcmcia.c,v 1.13 1998/12/24 04:51:59 marc Exp $ */ |
2/* $FreeBSD: head/sys/dev/pccard/pccard.c 61788 2000-06-18 05:28:59Z imp $ */ | 2/* $FreeBSD: head/sys/dev/pccard/pccard.c 64850 2000-08-19 19:22:04Z 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 --- 77 unchanged lines hidden (view full) --- 88 bus_space_write_1(pf->pf_ccrt, pf->pf_ccrh, 89 pf->pf_ccr_offset + ccr, val); 90 } 91} 92 93static int 94pccard_attach_card(device_t dev) 95{ | 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 --- 77 unchanged lines hidden (view full) --- 88 bus_space_write_1(pf->pf_ccrt, pf->pf_ccrh, 89 pf->pf_ccr_offset + ccr, val); 90 } 91} 92 93static int 94pccard_attach_card(device_t dev) 95{ |
96 struct pccard_softc *sc = (struct pccard_softc *) 97 device_get_softc(dev); | 96 struct pccard_softc *sc = PCCARD_SOFTC(dev); |
98 struct pccard_function *pf; 99 device_t child; 100 int attached; 101 102 DEVPRINTF((dev, "pccard_card_attach\n")); 103 /* 104 * this is here so that when socket_enable calls gettype, trt happens 105 */ 106 STAILQ_INIT(&sc->card.pf_head); 107 108 DEVPRINTF((dev, "chip_socket_enable\n")); 109 POWER_ENABLE_SOCKET(device_get_parent(dev), dev); 110 111 DEVPRINTF((dev, "read_cis\n")); 112 pccard_read_cis(sc); 113 | 97 struct pccard_function *pf; 98 device_t child; 99 int attached; 100 101 DEVPRINTF((dev, "pccard_card_attach\n")); 102 /* 103 * this is here so that when socket_enable calls gettype, trt happens 104 */ 105 STAILQ_INIT(&sc->card.pf_head); 106 107 DEVPRINTF((dev, "chip_socket_enable\n")); 108 POWER_ENABLE_SOCKET(device_get_parent(dev), dev); 109 110 DEVPRINTF((dev, "read_cis\n")); 111 pccard_read_cis(sc); 112 |
114 DEVPRINTF((dev, "chip_socket_disable\n")); 115 POWER_DISABLE_SOCKET(device_get_parent(dev), dev); 116 | |
117 DEVPRINTF((dev, "check_cis_quirks\n")); 118 pccard_check_cis_quirks(dev); 119 120 /* 121 * bail now if the card has no functions, or if there was an error in 122 * the cis. 123 */ 124 --- 7 unchanged lines hidden (view full) --- 132 133 attached = 0; 134 135 DEVPRINTF((dev, "functions scanning\n")); 136 STAILQ_FOREACH(pf, &sc->card.pf_head, pf_list) { 137 if (STAILQ_EMPTY(&pf->cfe_head)) 138 continue; 139 | 113 DEVPRINTF((dev, "check_cis_quirks\n")); 114 pccard_check_cis_quirks(dev); 115 116 /* 117 * bail now if the card has no functions, or if there was an error in 118 * the cis. 119 */ 120 --- 7 unchanged lines hidden (view full) --- 128 129 attached = 0; 130 131 DEVPRINTF((dev, "functions scanning\n")); 132 STAILQ_FOREACH(pf, &sc->card.pf_head, pf_list) { 133 if (STAILQ_EMPTY(&pf->cfe_head)) 134 continue; 135 |
140 printf ("pf %x sc %x\n", pf, sc); | 136 printf ("pf %p sc %p\n", pf, sc); |
141 pf->sc = sc; 142 pf->cfe = NULL; 143 pf->ih_fct = NULL; 144 pf->ih_arg = NULL; 145 } 146 | 137 pf->sc = sc; 138 pf->cfe = NULL; 139 pf->ih_fct = NULL; 140 pf->ih_arg = NULL; 141 } 142 |
143 DEVPRINTF((dev, "chip_socket_disable\n")); 144 POWER_DISABLE_SOCKET(device_get_parent(dev), dev); 145 |
|
147 STAILQ_FOREACH(pf, &sc->card.pf_head, pf_list) { 148 if (STAILQ_EMPTY(&pf->cfe_head)) 149 continue; 150 /* XXX */ 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 156 * departure from the current NetBSD model. 157 * 158 * This could get really ugly for multifunction cards. But 159 * it might also just fall out of the FreeBSD resource model. 160 * 161 */ 162 device_printf(dev, "Starting to attach....\n"); 163 child = device_add_child(dev, NULL, -1); 164 pccard_function_init(pf, STAILQ_FIRST(&pf->cfe_head)); 165 pccard_function_enable(pf); | 146 STAILQ_FOREACH(pf, &sc->card.pf_head, pf_list) { 147 if (STAILQ_EMPTY(&pf->cfe_head)) 148 continue; 149 /* XXX */ 150 /* 151 * In NetBSD, the drivers are responsible for activating 152 * each function of a card. I think that in FreeBSD we 153 * want to activate them enough for the usual bus_*_resource 154 * routines will do the right thing. This many mean a 155 * departure from the current NetBSD model. 156 * 157 * This could get really ugly for multifunction cards. But 158 * it might also just fall out of the FreeBSD resource model. 159 * 160 */ 161 device_printf(dev, "Starting to attach....\n"); 162 child = device_add_child(dev, NULL, -1); 163 pccard_function_init(pf, STAILQ_FIRST(&pf->cfe_head)); 164 pccard_function_enable(pf); |
166 device_printf(dev, "pf %x pf->sc %x\n", pf, pf->sc); | 165 device_printf(dev, "pf %p pf->sc %p\n", pf, pf->sc); |
167 if (device_probe_and_attach(child) == 0) { 168 attached++; 169 170 DEVPRINTF((sc->dev, "function %d CCR at %d " 171 "offset %x: %x %x %x %x, %x %x %x %x, %x\n", 172 pf->number, pf->pf_ccr_window, pf->pf_ccr_offset, 173 pccard_ccr_read(pf, 0x00), 174 pccard_ccr_read(pf, 0x02), pccard_ccr_read(pf, 0x04), 175 pccard_ccr_read(pf, 0x06), pccard_ccr_read(pf, 0x0A), 176 pccard_ccr_read(pf, 0x0C), pccard_ccr_read(pf, 0x0E), 177 pccard_ccr_read(pf, 0x10), pccard_ccr_read(pf, 0x12))); 178 } 179 } 180 return 0; 181} 182 183static int 184pccard_detach_card(device_t dev, int flags) 185{ | 166 if (device_probe_and_attach(child) == 0) { 167 attached++; 168 169 DEVPRINTF((sc->dev, "function %d CCR at %d " 170 "offset %x: %x %x %x %x, %x %x %x %x, %x\n", 171 pf->number, pf->pf_ccr_window, pf->pf_ccr_offset, 172 pccard_ccr_read(pf, 0x00), 173 pccard_ccr_read(pf, 0x02), pccard_ccr_read(pf, 0x04), 174 pccard_ccr_read(pf, 0x06), pccard_ccr_read(pf, 0x0A), 175 pccard_ccr_read(pf, 0x0C), pccard_ccr_read(pf, 0x0E), 176 pccard_ccr_read(pf, 0x10), pccard_ccr_read(pf, 0x12))); 177 } 178 } 179 return 0; 180} 181 182static int 183pccard_detach_card(device_t dev, int flags) 184{ |
186 struct pccard_softc *sc = (struct pccard_softc *) 187 device_get_softc(dev); | 185 struct pccard_softc *sc = PCCARD_SOFTC(dev); |
188 struct pccard_function *pf; 189 190 /* 191 * We are running on either the PCCARD socket's event thread 192 * or in user context detaching a device by user request. 193 */ 194 STAILQ_FOREACH(pf, &sc->card.pf_head, pf_list) { 195 if (STAILQ_FIRST(&pf->cfe_head) == NULL) 196 continue; 197 198 pccard_function_disable(pf); 199 device_delete_child(device_get_parent(dev), dev); 200 } 201 return 0; 202} 203 204static int 205pccard_card_gettype(device_t dev, int *type) 206{ | 186 struct pccard_function *pf; 187 188 /* 189 * We are running on either the PCCARD socket's event thread 190 * or in user context detaching a device by user request. 191 */ 192 STAILQ_FOREACH(pf, &sc->card.pf_head, pf_list) { 193 if (STAILQ_FIRST(&pf->cfe_head) == NULL) 194 continue; 195 196 pccard_function_disable(pf); 197 device_delete_child(device_get_parent(dev), dev); 198 } 199 return 0; 200} 201 202static int 203pccard_card_gettype(device_t dev, int *type) 204{ |
207 struct pccard_softc *sc = (struct pccard_softc *) 208 device_get_softc(dev); | 205 struct pccard_softc *sc = PCCARD_SOFTC(dev); |
209 struct pccard_function *pf; 210 211 /* 212 * set the iftype to memory if this card has no functions (not yet 213 * probed), or only one function, and that is not initialized yet or 214 * that is memory. 215 */ 216 pf = STAILQ_FIRST(&sc->card.pf_head); --- 293 unchanged lines hidden (view full) --- 510{ 511 device_set_desc(dev, "PC Card bus -- newconfig version"); 512 return pccard_add_children(dev, device_get_unit(dev)); 513} 514 515static int 516pccard_attach(device_t dev) 517{ | 206 struct pccard_function *pf; 207 208 /* 209 * set the iftype to memory if this card has no functions (not yet 210 * probed), or only one function, and that is not initialized yet or 211 * that is memory. 212 */ 213 pf = STAILQ_FIRST(&sc->card.pf_head); --- 293 unchanged lines hidden (view full) --- 507{ 508 device_set_desc(dev, "PC Card bus -- newconfig version"); 509 return pccard_add_children(dev, device_get_unit(dev)); 510} 511 512static int 513pccard_attach(device_t dev) 514{ |
518 struct pccard_softc *sc; | 515 struct pccard_softc *sc = PCCARD_SOFTC(dev); |
519 | 516 |
520 sc = (struct pccard_softc *) device_get_softc(dev); | |
521 sc->dev = dev; 522 sc->sc_enabled_count = 0; | 517 sc->dev = dev; 518 sc->sc_enabled_count = 0; |
519 DEVPRINTF((dev, "pccard_attach %p\n", dev)); |
|
523 return bus_generic_attach(dev); 524} 525 526static void 527pccard_print_resources(struct resource_list *rl, const char *name, int type, 528 int count, const char *format) 529{ 530 struct resource_list_entry *rle; --- 148 unchanged lines hidden (view full) --- 679 DEVMETHOD(card_detach_card, pccard_detach_card), 680 681 { 0, 0 } 682}; 683 684static driver_t pccard_driver = { 685 "pccard", 686 pccard_methods, | 520 return bus_generic_attach(dev); 521} 522 523static void 524pccard_print_resources(struct resource_list *rl, const char *name, int type, 525 int count, const char *format) 526{ 527 struct resource_list_entry *rle; --- 148 unchanged lines hidden (view full) --- 676 DEVMETHOD(card_detach_card, pccard_detach_card), 677 678 { 0, 0 } 679}; 680 681static driver_t pccard_driver = { 682 "pccard", 683 pccard_methods, |
687 1, /* no softc */ | 684 sizeof(struct pccard_softc) |
688}; 689 690devclass_t pccard_devclass; 691 692DRIVER_MODULE(pccard, pcic, pccard_driver, pccard_devclass, 0, 0); 693DRIVER_MODULE(pccard, pc98pcic, pccard_driver, pccard_devclass, 0, 0); 694DRIVER_MODULE(pccard, pccbb, pccard_driver, pccard_devclass, 0, 0); 695DRIVER_MODULE(pccard, tcic, pccard_driver, pccard_devclass, 0, 0); | 685}; 686 687devclass_t pccard_devclass; 688 689DRIVER_MODULE(pccard, pcic, pccard_driver, pccard_devclass, 0, 0); 690DRIVER_MODULE(pccard, pc98pcic, pccard_driver, pccard_devclass, 0, 0); 691DRIVER_MODULE(pccard, pccbb, pccard_driver, pccard_devclass, 0, 0); 692DRIVER_MODULE(pccard, tcic, pccard_driver, pccard_devclass, 0, 0); |