pccbb.c (82375) | pccbb.c (82378) |
---|---|
1/* 2 * Copyright (c) 2000,2001 Jonathan Chen. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * | 1/* 2 * Copyright (c) 2000,2001 Jonathan Chen. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * |
28 * $FreeBSD: head/sys/dev/pccbb/pccbb.c 82375 2001-08-26 23:55:34Z jon $ | 28 * $FreeBSD: head/sys/dev/pccbb/pccbb.c 82378 2001-08-27 00:09:42Z jon $ |
29 */ 30 31/* 32 * Driver for PCI to Cardbus Bridge chips 33 * 34 * References: 35 * TI Datasheets: 36 * http://www-s.ti.com/cgi-bin/sc/generic2.cgi?family=PCI+CARDBUS+CONTROLLERS --- 42 unchanged lines hidden (view full) --- 79#if defined CBB_DEBUG 80#define DPRINTF(x) printf x 81#define DEVPRINTF(x) device_printf x 82#else 83#define DPRINTF(x) 84#define DEVPRINTF(x) 85#endif 86 | 29 */ 30 31/* 32 * Driver for PCI to Cardbus Bridge chips 33 * 34 * References: 35 * TI Datasheets: 36 * http://www-s.ti.com/cgi-bin/sc/generic2.cgi?family=PCI+CARDBUS+CONTROLLERS --- 42 unchanged lines hidden (view full) --- 79#if defined CBB_DEBUG 80#define DPRINTF(x) printf x 81#define DEVPRINTF(x) device_printf x 82#else 83#define DPRINTF(x) 84#define DEVPRINTF(x) 85#endif 86 |
87#define PCI_MASK_CONFIG(DEV,REG,MASK,SIZE) \ | 87#define PCI_MASK_CONFIG(DEV,REG,MASK,SIZE) \ |
88 pci_write_config(DEV, REG, pci_read_config(DEV, REG, SIZE) MASK, SIZE) 89#define PCI_MASK2_CONFIG(DEV,REG,MASK1,MASK2,SIZE) \ 90 pci_write_config(DEV, REG, ( \ 91 pci_read_config(DEV, REG, SIZE) MASK1) MASK2, SIZE) 92 93/* 94 * XXX all the pcic code really doesn't belong here and needs to be 95 * XXX migrated to its own file, shared with the 16-bit code --- 94 unchanged lines hidden (view full) --- 190 CB_UNKNOWN, 0}, 191}; 192 193static int cb_chipset(u_int32_t pci_id, const char **namep, int *flagp); 194static int pccbb_probe(device_t brdev); 195static void pccbb_chipinit(struct pccbb_softc *sc); 196static int pccbb_attach(device_t brdev); 197static int pccbb_detach(device_t brdev); | 88 pci_write_config(DEV, REG, pci_read_config(DEV, REG, SIZE) MASK, SIZE) 89#define PCI_MASK2_CONFIG(DEV,REG,MASK1,MASK2,SIZE) \ 90 pci_write_config(DEV, REG, ( \ 91 pci_read_config(DEV, REG, SIZE) MASK1) MASK2, SIZE) 92 93/* 94 * XXX all the pcic code really doesn't belong here and needs to be 95 * XXX migrated to its own file, shared with the 16-bit code --- 94 unchanged lines hidden (view full) --- 190 CB_UNKNOWN, 0}, 191}; 192 193static int cb_chipset(u_int32_t pci_id, const char **namep, int *flagp); 194static int pccbb_probe(device_t brdev); 195static void pccbb_chipinit(struct pccbb_softc *sc); 196static int pccbb_attach(device_t brdev); 197static int pccbb_detach(device_t brdev); |
198static int pccbb_shutdown(device_t brdev); |
|
198static void pccbb_driver_added(device_t brdev, driver_t *driver); 199static void pccbb_child_detached(device_t brdev, device_t child); | 199static void pccbb_driver_added(device_t brdev, driver_t *driver); 200static void pccbb_child_detached(device_t brdev, device_t child); |
201static int pccbb_card_reprobe(device_t brdev, device_t busdev); |
|
200static void pccbb_event_thread(void *arg); | 202static void pccbb_event_thread(void *arg); |
201static void pccbb_create_event_thread (struct pccbb_softc *sc); | 203static void pccbb_create_event_thread(struct pccbb_softc *sc); |
202static void pccbb_start_threads(void *arg); 203static void pccbb_insert(struct pccbb_softc *sc); 204static void pccbb_removal(struct pccbb_softc *sc); 205static void pccbb_intr(void *arg); 206static int pccbb_detect_voltage(device_t brdev); 207static int pccbb_power(device_t brdev, int volts); 208static void pccbb_cardbus_reset(device_t brdev); 209static int pccbb_cardbus_power_enable_socket(device_t brdev, 210 device_t child); 211static void pccbb_cardbus_power_disable_socket(device_t brdev, 212 device_t child); 213static int pccbb_cardbus_io_open(device_t brdev, int win, u_int32_t start, 214 u_int32_t end); 215static int pccbb_cardbus_mem_open(device_t brdev, int win, 216 u_int32_t start, u_int32_t end); 217static void pccbb_cardbus_auto_open(struct pccbb_softc *sc, int type); 218static int pccbb_cardbus_activate_resource(device_t brdev, device_t child, | 204static void pccbb_start_threads(void *arg); 205static void pccbb_insert(struct pccbb_softc *sc); 206static void pccbb_removal(struct pccbb_softc *sc); 207static void pccbb_intr(void *arg); 208static int pccbb_detect_voltage(device_t brdev); 209static int pccbb_power(device_t brdev, int volts); 210static void pccbb_cardbus_reset(device_t brdev); 211static int pccbb_cardbus_power_enable_socket(device_t brdev, 212 device_t child); 213static void pccbb_cardbus_power_disable_socket(device_t brdev, 214 device_t child); 215static int pccbb_cardbus_io_open(device_t brdev, int win, u_int32_t start, 216 u_int32_t end); 217static int pccbb_cardbus_mem_open(device_t brdev, int win, 218 u_int32_t start, u_int32_t end); 219static void pccbb_cardbus_auto_open(struct pccbb_softc *sc, int type); 220static int pccbb_cardbus_activate_resource(device_t brdev, device_t child, |
219 int type, int rid, struct resource *r); | 221 int type, int rid, struct resource *res); |
220static int pccbb_cardbus_deactivate_resource(device_t brdev, | 222static int pccbb_cardbus_deactivate_resource(device_t brdev, |
221 device_t child, int type, int rid, struct resource *r); 222static struct resource * pccbb_cardbus_alloc_resource(device_t brdev, | 223 device_t child, int type, int rid, struct resource *res); 224static struct resource *pccbb_cardbus_alloc_resource(device_t brdev, |
223 device_t child, int type, int *rid, u_long start, 224 u_long end, u_long count, u_int flags); 225static int pccbb_cardbus_release_resource(device_t brdev, device_t child, | 225 device_t child, int type, int *rid, u_long start, 226 u_long end, u_long count, u_int flags); 227static int pccbb_cardbus_release_resource(device_t brdev, device_t child, |
226 int type, int rid, struct resource *r); | 228 int type, int rid, struct resource *res); |
227static int pccbb_pcic_power_enable_socket(device_t brdev, device_t child); 228static void pccbb_pcic_power_disable_socket(device_t brdev, device_t child); 229static void pccbb_pcic_wait_ready(struct pccbb_softc *sc); 230static void pccbb_pcic_do_mem_map(struct pccbb_softc *sc, int win); 231static int pccbb_pcic_mem_map(struct pccbb_softc *sc, int kind, | 229static int pccbb_pcic_power_enable_socket(device_t brdev, device_t child); 230static void pccbb_pcic_power_disable_socket(device_t brdev, device_t child); 231static void pccbb_pcic_wait_ready(struct pccbb_softc *sc); 232static void pccbb_pcic_do_mem_map(struct pccbb_softc *sc, int win); 233static int pccbb_pcic_mem_map(struct pccbb_softc *sc, int kind, |
232 struct resource *r, bus_addr_t card_addr, int *win); | 234 struct resource *res); |
233static void pccbb_pcic_mem_unmap(struct pccbb_softc *sc, int window); | 235static void pccbb_pcic_mem_unmap(struct pccbb_softc *sc, int window); |
236static int pccbb_pcic_mem_findmap(struct pccbb_softc *sc, 237 struct resource *res); |
|
234static void pccbb_pcic_do_io_map(struct pccbb_softc *sc, int win); 235static int pccbb_pcic_io_map(struct pccbb_softc *sc, int width, | 238static void pccbb_pcic_do_io_map(struct pccbb_softc *sc, int win); 239static int pccbb_pcic_io_map(struct pccbb_softc *sc, int width, |
236 struct resource *r, bus_addr_t card_addr, int *win); | 240 struct resource *r); |
237static void pccbb_pcic_io_unmap(struct pccbb_softc *sc, int window); | 241static void pccbb_pcic_io_unmap(struct pccbb_softc *sc, int window); |
242static int pccbb_pcic_io_findmap(struct pccbb_softc *sc, 243 struct resource *res); |
|
238static int pccbb_pcic_activate_resource(device_t brdev, device_t child, | 244static int pccbb_pcic_activate_resource(device_t brdev, device_t child, |
239 int type, int rid, struct resource *r); | 245 int type, int rid, struct resource *res); |
240static int pccbb_pcic_deactivate_resource(device_t brdev, device_t child, | 246static int pccbb_pcic_deactivate_resource(device_t brdev, device_t child, |
241 int type, int rid, struct resource *r); 242static struct resource * pccbb_pcic_alloc_resource(device_t brdev, | 247 int type, int rid, struct resource *res); 248static struct resource *pccbb_pcic_alloc_resource(device_t brdev, |
243 device_t child, int type, int *rid, u_long start, 244 u_long end, u_long count, u_int flags); 245static int pccbb_pcic_release_resource(device_t brdev, device_t child, 246 int type, int rid, struct resource *res); 247static int pccbb_pcic_set_res_flags(device_t brdev, device_t child, 248 int type, int rid, u_int32_t flags); 249static int pccbb_pcic_set_memory_offset(device_t brdev, device_t child, 250 int rid, u_int32_t cardaddr, u_int32_t *deltap); 251static int pccbb_power_enable_socket(device_t brdev, device_t child); 252static void pccbb_power_disable_socket(device_t brdev, device_t child); 253static int pccbb_activate_resource(device_t brdev, device_t child, 254 int type, int rid, struct resource *r); 255static int pccbb_deactivate_resource(device_t brdev, device_t child, 256 int type, int rid, struct resource *r); | 249 device_t child, int type, int *rid, u_long start, 250 u_long end, u_long count, u_int flags); 251static int pccbb_pcic_release_resource(device_t brdev, device_t child, 252 int type, int rid, struct resource *res); 253static int pccbb_pcic_set_res_flags(device_t brdev, device_t child, 254 int type, int rid, u_int32_t flags); 255static int pccbb_pcic_set_memory_offset(device_t brdev, device_t child, 256 int rid, u_int32_t cardaddr, u_int32_t *deltap); 257static int pccbb_power_enable_socket(device_t brdev, device_t child); 258static void pccbb_power_disable_socket(device_t brdev, device_t child); 259static int pccbb_activate_resource(device_t brdev, device_t child, 260 int type, int rid, struct resource *r); 261static int pccbb_deactivate_resource(device_t brdev, device_t child, 262 int type, int rid, struct resource *r); |
257static struct resource * pccbb_alloc_resource(device_t brdev, 258 device_t child, int type, int *rid, u_long start, 259 u_long end, u_long count, u_int flags); | 263static struct resource *pccbb_alloc_resource(device_t brdev, device_t child, 264 int type, int *rid, u_long start, u_long end, u_long count, 265 u_int flags); |
260static int pccbb_release_resource(device_t brdev, device_t child, 261 int type, int rid, struct resource *r); 262static int pccbb_read_ivar(device_t brdev, device_t child, int which, 263 uintptr_t *result); 264static int pccbb_write_ivar(device_t brdev, device_t child, int which, 265 uintptr_t value); 266static int pccbb_maxslots(device_t brdev); | 266static int pccbb_release_resource(device_t brdev, device_t child, 267 int type, int rid, struct resource *r); 268static int pccbb_read_ivar(device_t brdev, device_t child, int which, 269 uintptr_t *result); 270static int pccbb_write_ivar(device_t brdev, device_t child, int which, 271 uintptr_t value); 272static int pccbb_maxslots(device_t brdev); |
267static u_int32_t pccbb_read_config(device_t brdev, int b, int s, int f, | 273static u_int32_t pccbb_read_config(device_t brdev, int b, int s, int f, |
268 int reg, int width); 269static void pccbb_write_config(device_t brdev, int b, int s, int f, 270 int reg, u_int32_t val, int width); 271 272/************************************************************************/ 273/* Probe/Attach */ 274/************************************************************************/ 275 --- 143 unchanged lines hidden (view full) --- 419 sockbase = pci_read_config(brdev, rid, 4); 420 if (sockbase < 0x100000 || sockbase >= 0xfffffff0) { 421 pci_write_config(brdev, rid, 0xffffffff, 4); 422 sockbase = pci_read_config(brdev, rid, 4); 423 sockbase = (sockbase & 0xfffffff0) & 424 -(sockbase & 0xfffffff0); 425 sc->sc_base_res = bus_generic_alloc_resource( 426 device_get_parent(brdev), brdev, SYS_RES_MEMORY, | 274 int reg, int width); 275static void pccbb_write_config(device_t brdev, int b, int s, int f, 276 int reg, u_int32_t val, int width); 277 278/************************************************************************/ 279/* Probe/Attach */ 280/************************************************************************/ 281 --- 143 unchanged lines hidden (view full) --- 425 sockbase = pci_read_config(brdev, rid, 4); 426 if (sockbase < 0x100000 || sockbase >= 0xfffffff0) { 427 pci_write_config(brdev, rid, 0xffffffff, 4); 428 sockbase = pci_read_config(brdev, rid, 4); 429 sockbase = (sockbase & 0xfffffff0) & 430 -(sockbase & 0xfffffff0); 431 sc->sc_base_res = bus_generic_alloc_resource( 432 device_get_parent(brdev), brdev, SYS_RES_MEMORY, |
427 &rid, CARDBUS_SYS_RES_MEMORY_START, 428 CARDBUS_SYS_RES_MEMORY_END, sockbase, | 433 &rid, 0, ~0, sockbase, |
429 RF_ACTIVE|rman_make_alignment_flags(sockbase)); 430 if (!sc->sc_base_res){ 431 device_printf(brdev, 432 "Could not grab register memory\n"); 433 mtx_destroy(&sc->sc_mtx); 434 return ENOMEM; 435 } 436 pci_write_config(brdev, PCCBBR_SOCKBASE, --- 120 unchanged lines hidden (view full) --- 557 558 bus_release_resource(brdev, SYS_RES_IRQ, 0, sc->sc_irq_res); 559 bus_release_resource(brdev, SYS_RES_MEMORY, PCCBBR_SOCKBASE, 560 sc->sc_base_res); 561 mtx_destroy(&sc->sc_mtx); 562 return 0; 563} 564 | 434 RF_ACTIVE|rman_make_alignment_flags(sockbase)); 435 if (!sc->sc_base_res){ 436 device_printf(brdev, 437 "Could not grab register memory\n"); 438 mtx_destroy(&sc->sc_mtx); 439 return ENOMEM; 440 } 441 pci_write_config(brdev, PCCBBR_SOCKBASE, --- 120 unchanged lines hidden (view full) --- 562 563 bus_release_resource(brdev, SYS_RES_IRQ, 0, sc->sc_irq_res); 564 bus_release_resource(brdev, SYS_RES_MEMORY, PCCBBR_SOCKBASE, 565 sc->sc_base_res); 566 mtx_destroy(&sc->sc_mtx); 567 return 0; 568} 569 |
570static int 571pccbb_shutdown(device_t brdev) 572{ 573 struct pccbb_softc *sc = (struct pccbb_softc *)device_get_softc(brdev); 574 /* properly reset everything at shutdown */ 575 576 PCI_MASK_CONFIG(brdev, PCCBBR_BRIDGECTRL, |PCCBBM_BRIDGECTRL_RESET, 2); 577 PCIC_MASK(sc, PCIC_INTR, & ~PCIC_INTR_RESET); 578 579 sc->sc_socketreg->socket_mask = 0; 580 581 pccbb_power(brdev, CARD_VCC_0V | CARD_VPP_0V); 582 583 PCIC_WRITE(sc, PCIC_ADDRWIN_ENABLE, 0); 584 pci_write_config(brdev, PCCBBR_MEMBASE0, 0, 4); 585 pci_write_config(brdev, PCCBBR_MEMLIMIT0, 0, 4); 586 pci_write_config(brdev, PCCBBR_MEMBASE1, 0, 4); 587 pci_write_config(brdev, PCCBBR_MEMLIMIT1, 0, 4); 588 pci_write_config(brdev, PCCBBR_IOBASE0, 0, 4); 589 pci_write_config(brdev, PCCBBR_IOLIMIT0, 0, 4); 590 pci_write_config(brdev, PCCBBR_IOBASE1, 0, 4); 591 pci_write_config(brdev, PCCBBR_IOLIMIT1, 0, 4); 592 pci_write_config(brdev, PCIR_COMMAND, 0, 2); 593 return 0; 594} 595 |
|
565static void 566pccbb_driver_added(device_t brdev, driver_t *driver) 567{ 568 struct pccbb_softc *sc = device_get_softc(brdev); 569 device_t *devlist; 570 int tmp; 571 int numdevs; | 596static void 597pccbb_driver_added(device_t brdev, driver_t *driver) 598{ 599 struct pccbb_softc *sc = device_get_softc(brdev); 600 device_t *devlist; 601 int tmp; 602 int numdevs; |
603 int wake; 604 u_int32_t sockstate; |
|
572 573 DEVICE_IDENTIFY(driver, brdev); 574 device_get_children(brdev, &devlist, &numdevs); | 605 606 DEVICE_IDENTIFY(driver, brdev); 607 device_get_children(brdev, &devlist, &numdevs); |
608 wake = 0; 609 sockstate = sc->sc_socketreg->socket_state; |
|
575 for (tmp = 0; tmp < numdevs; tmp++) { 576 if (device_get_state(devlist[tmp]) == DS_NOTPRESENT && 577 device_probe_and_attach(devlist[tmp]) == 0) { 578 if (devlist[tmp] == NULL) 579 /* NOTHING */; 580 else if (strcmp(driver->name, "cardbus") == 0) { 581 sc->sc_cbdev = devlist[tmp]; | 610 for (tmp = 0; tmp < numdevs; tmp++) { 611 if (device_get_state(devlist[tmp]) == DS_NOTPRESENT && 612 device_probe_and_attach(devlist[tmp]) == 0) { 613 if (devlist[tmp] == NULL) 614 /* NOTHING */; 615 else if (strcmp(driver->name, "cardbus") == 0) { 616 sc->sc_cbdev = devlist[tmp]; |
582 if ((sc->sc_socketreg->socket_state 583 & PCCBB_SOCKET_STAT_CD) == 0) { 584 mtx_lock(&sc->sc_mtx); 585 wakeup(sc); 586 mtx_unlock(&sc->sc_mtx); 587 } | 617 if (((sockstate & PCCBB_SOCKET_STAT_CD) == 0) && 618 (sockstate & PCCBB_SOCKET_STAT_CB)) 619 wake++; |
588 } else if (strcmp(driver->name, "pccard") == 0) { 589 sc->sc_pccarddev = devlist[tmp]; | 620 } else if (strcmp(driver->name, "pccard") == 0) { 621 sc->sc_pccarddev = devlist[tmp]; |
590 if ((sc->sc_socketreg->socket_state 591 & PCCBB_SOCKET_STAT_CD) == 0) { 592 mtx_lock(&sc->sc_mtx); 593 wakeup(sc); 594 mtx_unlock(&sc->sc_mtx); 595 } | 622 if (((sockstate & PCCBB_SOCKET_STAT_CD) == 0) && 623 (sockstate & PCCBB_SOCKET_STAT_16BIT)) 624 wake++; |
596 } else 597 device_printf(brdev, 598 "Unsupported child bus: %s\n", 599 driver->name); 600 } 601 } 602 free(devlist, M_TEMP); | 625 } else 626 device_printf(brdev, 627 "Unsupported child bus: %s\n", 628 driver->name); 629 } 630 } 631 free(devlist, M_TEMP); |
632 633 if (wake > 0) { 634 if ((sc->sc_socketreg->socket_state & PCCBB_SOCKET_STAT_CD) == 635 0) { 636 mtx_lock(&sc->sc_mtx); 637 wakeup(sc); 638 mtx_unlock(&sc->sc_mtx); 639 } 640 } |
|
603} 604 605static void 606pccbb_child_detached(device_t brdev, device_t child) 607{ 608 struct pccbb_softc *sc = device_get_softc(brdev); 609 if (child == sc->sc_cbdev) 610 sc->sc_cbdev = NULL; 611 else if (child == sc->sc_pccarddev) 612 sc->sc_pccarddev = NULL; 613 else 614 device_printf(brdev, "Unknown child detached: %s %p/%p\n", 615 device_get_nameunit(child), sc->sc_cbdev, sc->sc_pccarddev); 616} 617 | 641} 642 643static void 644pccbb_child_detached(device_t brdev, device_t child) 645{ 646 struct pccbb_softc *sc = device_get_softc(brdev); 647 if (child == sc->sc_cbdev) 648 sc->sc_cbdev = NULL; 649 else if (child == sc->sc_pccarddev) 650 sc->sc_pccarddev = NULL; 651 else 652 device_printf(brdev, "Unknown child detached: %s %p/%p\n", 653 device_get_nameunit(child), sc->sc_cbdev, sc->sc_pccarddev); 654} 655 |
656static int 657pccbb_card_reprobe(device_t brdev, device_t busdev) { 658 struct pccbb_softc *sc = device_get_softc(brdev); 659 int wake = 0; 660 u_int32_t sockstate; 661 662 sockstate = sc->sc_socketreg->socket_state; 663 664 if ((sockstate & PCCBB_SOCKET_STAT_CD) == 0) { 665 if (busdev == sc->sc_cbdev && 666 (sockstate & PCCBB_SOCKET_STAT_CB)) 667 wake++; 668 else if (busdev == sc->sc_pccarddev && 669 (sockstate & PCCBB_SOCKET_STAT_16BIT)) 670 wake++; 671 672 if (wake > 0) { 673 mtx_lock(&sc->sc_mtx); 674 wakeup(sc); 675 mtx_unlock(&sc->sc_mtx); 676 return 0; 677 } 678 return EBUSY; 679 } 680 return ENOENT; 681} 682 |
|
618/************************************************************************/ 619/* Kthreads */ 620/************************************************************************/ 621 622static void 623pccbb_event_thread(void *arg) 624{ 625 struct pccbb_softc *sc = arg; --- 26 unchanged lines hidden (view full) --- 652 } 653 mtx_unlock(&sc->sc_mtx); 654 sc->sc_flags &= ~PCCBB_KTHREAD_RUNNING; 655 wakeup(sc); 656 kthread_exit(0); 657} 658 659static void | 683/************************************************************************/ 684/* Kthreads */ 685/************************************************************************/ 686 687static void 688pccbb_event_thread(void *arg) 689{ 690 struct pccbb_softc *sc = arg; --- 26 unchanged lines hidden (view full) --- 717 } 718 mtx_unlock(&sc->sc_mtx); 719 sc->sc_flags &= ~PCCBB_KTHREAD_RUNNING; 720 wakeup(sc); 721 kthread_exit(0); 722} 723 724static void |
660pccbb_create_event_thread (struct pccbb_softc *sc) | 725pccbb_create_event_thread(struct pccbb_softc *sc) |
661{ 662 if (kthread_create(pccbb_event_thread, sc, &sc->event_thread, 663 0, "%s%d", device_get_name(sc->sc_dev), 664 device_get_unit(sc->sc_dev))) { 665 device_printf (sc->sc_dev, "unable to create event thread.\n"); 666 panic ("pccbb_create_event_thread"); 667 } 668} --- 42 unchanged lines hidden (view full) --- 711 } else { 712 device_printf (sc->sc_dev, "Unsupported card type detected\n"); 713 } 714} 715 716static void 717pccbb_removal(struct pccbb_softc *sc) 718{ | 726{ 727 if (kthread_create(pccbb_event_thread, sc, &sc->event_thread, 728 0, "%s%d", device_get_name(sc->sc_dev), 729 device_get_unit(sc->sc_dev))) { 730 device_printf (sc->sc_dev, "unable to create event thread.\n"); 731 panic ("pccbb_create_event_thread"); 732 } 733} --- 42 unchanged lines hidden (view full) --- 776 } else { 777 device_printf (sc->sc_dev, "Unsupported card type detected\n"); 778 } 779} 780 781static void 782pccbb_removal(struct pccbb_softc *sc) 783{ |
719 u_int32_t sockstate; | |
720 struct pccbb_reslist *rle; 721 | 784 struct pccbb_reslist *rle; 785 |
722 sockstate = sc->sc_socketreg->socket_state; 723 724 if (sockstate & PCCBB_16BIT_CARD && sc->sc_pccarddev != NULL) | 786 if (sc->sc_flags & PCCBB_16BIT_CARD && sc->sc_pccarddev != NULL) |
725 CARD_DETACH_CARD(sc->sc_pccarddev, DETACH_FORCE); | 787 CARD_DETACH_CARD(sc->sc_pccarddev, DETACH_FORCE); |
726 else if ((!(sockstate & PCCBB_16BIT_CARD)) && sc->sc_cbdev != NULL) | 788 else if ((!(sc->sc_flags & PCCBB_16BIT_CARD)) && sc->sc_cbdev != NULL) |
727 CARD_DETACH_CARD(sc->sc_cbdev, DETACH_FORCE); 728 | 789 CARD_DETACH_CARD(sc->sc_cbdev, DETACH_FORCE); 790 |
729 while (NULL != (rle = SLIST_FIRST(&sc->rl))) { | 791 while ((rle = SLIST_FIRST(&sc->rl)) != NULL) { |
730 device_printf(sc->sc_dev, "Danger Will Robinson: Resource " 731 "left allocated! This is a bug... " | 792 device_printf(sc->sc_dev, "Danger Will Robinson: Resource " 793 "left allocated! This is a bug... " |
732 "(rid=%x, type=%d, addr=%x)\n", rle->rid, rle->type, 733 rle->start); 734 SLIST_REMOVE_HEAD(&sc->rl, entries); | 794 "(rid=%x, type=%d, addr=%lx)\n", rle->rid, rle->type, 795 rman_get_start(rle->res)); 796 SLIST_REMOVE_HEAD(&sc->rl, link); 797 free(rle, M_DEVBUF); |
735 } 736} 737 738/************************************************************************/ 739/* Interrupt Handler */ 740/************************************************************************/ 741 742static void --- 279 unchanged lines hidden (view full) --- 1022 1023static void 1024pccbb_cardbus_auto_open(struct pccbb_softc *sc, int type) 1025{ 1026 u_int32_t starts[2]; 1027 u_int32_t ends[2]; 1028 struct pccbb_reslist *rle; 1029 int align; | 798 } 799} 800 801/************************************************************************/ 802/* Interrupt Handler */ 803/************************************************************************/ 804 805static void --- 279 unchanged lines hidden (view full) --- 1085 1086static void 1087pccbb_cardbus_auto_open(struct pccbb_softc *sc, int type) 1088{ 1089 u_int32_t starts[2]; 1090 u_int32_t ends[2]; 1091 struct pccbb_reslist *rle; 1092 int align; |
1093 int prefetchable[2]; |
|
1030 1031 starts[0] = starts[1] = 0xffffffff; 1032 ends[0] = ends[1] = 0; 1033 | 1094 1095 starts[0] = starts[1] = 0xffffffff; 1096 ends[0] = ends[1] = 0; 1097 |
1034 SLIST_FOREACH(rle, &sc->rl, entries) { | 1098 if (type == SYS_RES_MEMORY) 1099 align = PCCBB_MEMALIGN; 1100 else if (type == SYS_RES_IOPORT) 1101 align = PCCBB_IOALIGN; 1102 else 1103 align = 1; 1104 1105 SLIST_FOREACH(rle, &sc->rl, link) { |
1035 if (rle->type != type) 1036 ; | 1106 if (rle->type != type) 1107 ; |
1037 else if (starts[0] == 0xffffffff) { 1038 starts[0] = rle->start; 1039 ends[0] = rle->end; 1040 rle->win = 0; 1041 } else if (rle->end > ends[0] && 1042 rle->start - ends[0] < PCCBB_AUTO_OPEN_SMALLHOLE) { 1043 ends[0] = rle->end; 1044 rle->win = 0; 1045 } else if (rle->start < starts[0] && 1046 starts[0] - rle->end < PCCBB_AUTO_OPEN_SMALLHOLE) { 1047 starts[0] = rle->start; 1048 rle->win = 0; | 1108 else if (rle->res == NULL) { 1109 device_printf(sc->sc_dev, "WARNING: Resource not reserved? " 1110 "(type=%d, addr=%lx)\n", 1111 rle->type, rman_get_start(rle->res)); 1112 } else if (!(rman_get_flags(rle->res) & RF_ACTIVE)) { 1113 } else if (starts[0] == 0xffffffff) { 1114 starts[0] = rman_get_start(rle->res); 1115 ends[0] = rman_get_end(rle->res); 1116 prefetchable[0] = 1117 rman_get_flags(rle->res) & RF_PREFETCHABLE; 1118 } else if (rman_get_end(rle->res) > ends[0] && 1119 rman_get_start(rle->res) - ends[0] < 1120 PCCBB_AUTO_OPEN_SMALLHOLE && prefetchable[0] == 1121 (rman_get_flags(rle->res) & RF_PREFETCHABLE)) { 1122 ends[0] = rman_get_end(rle->res); 1123 } else if (rman_get_start(rle->res) < starts[0] && 1124 starts[0] - rman_get_end(rle->res) < 1125 PCCBB_AUTO_OPEN_SMALLHOLE && prefetchable[0] == 1126 (rman_get_flags(rle->res) & RF_PREFETCHABLE)) { 1127 starts[0] = rman_get_start(rle->res); |
1049 } else if (starts[1] == 0xffffffff) { | 1128 } else if (starts[1] == 0xffffffff) { |
1050 starts[1] = rle->start; 1051 ends[1] = rle->end; 1052 rle->win = 1; 1053 } else if (rle->end > ends[1] && 1054 rle->start - ends[1] < PCCBB_AUTO_OPEN_SMALLHOLE) { 1055 ends[1] = rle->end; 1056 rle->win = 1; 1057 } else if (rle->start < starts[1] && 1058 starts[1] - rle->end < PCCBB_AUTO_OPEN_SMALLHOLE) { 1059 starts[1] = rle->start; 1060 rle->win = 1; | 1129 starts[1] = rman_get_start(rle->res); 1130 ends[1] = rman_get_end(rle->res); 1131 prefetchable[1] = 1132 rman_get_flags(rle->res) & RF_PREFETCHABLE; 1133 } else if (rman_get_end(rle->res) > ends[1] && 1134 rman_get_start(rle->res) - ends[1] < 1135 PCCBB_AUTO_OPEN_SMALLHOLE && prefetchable[1] == 1136 (rman_get_flags(rle->res) & RF_PREFETCHABLE)) { 1137 ends[1] = rman_get_end(rle->res); 1138 } else if (rman_get_start(rle->res) < starts[1] && 1139 starts[1] - rman_get_end(rle->res) < 1140 PCCBB_AUTO_OPEN_SMALLHOLE && prefetchable[1] == 1141 (rman_get_flags(rle->res) & RF_PREFETCHABLE)) { 1142 starts[1] = rman_get_start(rle->res); |
1061 } else { 1062 u_int32_t diffs[2]; | 1143 } else { 1144 u_int32_t diffs[2]; |
1145 int win; |
|
1063 1064 diffs[0] = diffs[1] = 0xffffffff; | 1146 1147 diffs[0] = diffs[1] = 0xffffffff; |
1065 if (rle->start > ends[0]) 1066 diffs[0] = rle->start - ends[0]; 1067 else if (rle->end < starts[0]) 1068 diffs[0] = starts[0] - rle->end; 1069 if (rle->start > ends[1]) 1070 diffs[1] = rle->start - ends[1]; 1071 else if (rle->end < starts[1]) 1072 diffs[1] = starts[1] - rle->end; | 1148 if (rman_get_start(rle->res) > ends[0]) 1149 diffs[0] = rman_get_start(rle->res) - ends[0]; 1150 else if (rman_get_end(rle->res) < starts[0]) 1151 diffs[0] = starts[0] - rman_get_end(rle->res); 1152 if (rman_get_start(rle->res) > ends[1]) 1153 diffs[1] = rman_get_start(rle->res) - ends[1]; 1154 else if (rman_get_end(rle->res) < starts[1]) 1155 diffs[1] = starts[1] - rman_get_end(rle->res); |
1073 | 1156 |
1074 rle->win = (diffs[0] <= diffs[1])?0:1; 1075 if (rle->start > ends[rle->win]) 1076 ends[rle->win] = rle->end; 1077 else if (rle->end < starts[rle->win]) 1078 starts[rle->win] = rle->start; | 1157 win = (diffs[0] <= diffs[1])?0:1; 1158 if (rman_get_start(rle->res) > ends[win]) 1159 ends[win] = rman_get_end(rle->res); 1160 else if (rman_get_end(rle->res) < starts[win]) 1161 starts[win] = rman_get_start(rle->res); 1162 if (!(rman_get_flags(rle->res) & RF_PREFETCHABLE)) 1163 prefetchable[win] = 0; |
1079 } | 1164 } |
1165 1166 if (starts[0] != 0xffffffff) 1167 starts[0] -= starts[0] % align; 1168 if (starts[1] != 0xffffffff) 1169 starts[1] -= starts[1] % align; 1170 if (ends[0] % align != 0) 1171 ends[0] += align - ends[0]%align - 1; 1172 if (ends[1] % align != 0) 1173 ends[1] += align - ends[1]%align - 1; |
|
1080 } | 1174 } |
1081 if (type == SYS_RES_MEMORY) 1082 align = PCCBB_MEMALIGN; 1083 else if (type == SYS_RES_IOPORT) 1084 align = PCCBB_IOALIGN; 1085 else 1086 align = 1; | |
1087 | 1175 |
1088 if (starts[0] != 0xffffffff) 1089 starts[0] -= starts[0] % align; 1090 if (starts[1] != 0xffffffff) 1091 starts[1] -= starts[1] % align; 1092 if (ends[0] % align != 0) 1093 ends[0] += align - ends[0]%align - 1; 1094 if (ends[1] % align != 0) 1095 ends[1] += align - ends[1]%align - 1; 1096 | |
1097 if (type == SYS_RES_MEMORY) { | 1176 if (type == SYS_RES_MEMORY) { |
1177 u_int32_t reg; 1178 |
|
1098 pccbb_cardbus_mem_open(sc->sc_dev, 0, starts[0], ends[0]); 1099 pccbb_cardbus_mem_open(sc->sc_dev, 1, starts[1], ends[1]); | 1179 pccbb_cardbus_mem_open(sc->sc_dev, 0, starts[0], ends[0]); 1180 pccbb_cardbus_mem_open(sc->sc_dev, 1, starts[1], ends[1]); |
1181 reg = pci_read_config(sc->sc_dev, PCCBBR_BRIDGECTRL, 2); 1182 reg &= ~(PCCBBM_BRIDGECTRL_PREFETCH_0| 1183 PCCBBM_BRIDGECTRL_PREFETCH_1); 1184 reg |= (prefetchable[0]?PCCBBM_BRIDGECTRL_PREFETCH_0:0)| 1185 (prefetchable[1]?PCCBBM_BRIDGECTRL_PREFETCH_1:0); 1186 pci_write_config(sc->sc_dev, PCCBBR_BRIDGECTRL, reg, 2); |
|
1100 } else if (type == SYS_RES_IOPORT) { 1101 pccbb_cardbus_io_open(sc->sc_dev, 0, starts[0], ends[0]); 1102 pccbb_cardbus_io_open(sc->sc_dev, 1, starts[1], ends[1]); 1103 } 1104} 1105 1106static int 1107pccbb_cardbus_activate_resource(device_t brdev, device_t child, int type, | 1187 } else if (type == SYS_RES_IOPORT) { 1188 pccbb_cardbus_io_open(sc->sc_dev, 0, starts[0], ends[0]); 1189 pccbb_cardbus_io_open(sc->sc_dev, 1, starts[1], ends[1]); 1190 } 1191} 1192 1193static int 1194pccbb_cardbus_activate_resource(device_t brdev, device_t child, int type, |
1108 int rid, struct resource *r) | 1195 int rid, struct resource *res) |
1109{ | 1196{ |
1110 struct pccbb_softc *sc = device_get_softc(brdev); 1111 struct pccbb_reslist *rle; | 1197 int ret; |
1112 | 1198 |
1113 if (type == SYS_RES_MEMORY || type == SYS_RES_IOPORT) { 1114 SLIST_FOREACH(rle, &sc->rl, entries) { 1115 if (type == rle->type && rid == rle->rid && 1116 child == rle->odev) 1117 return bus_generic_activate_resource( 1118 brdev, child, type, rid, r); 1119 } 1120 rle = malloc(sizeof(struct pccbb_reslist), M_DEVBUF, M_WAITOK); 1121 rle->type = type; 1122 rle->rid = rid; 1123 rle->start = rman_get_start(r); 1124 rle->end = rman_get_end(r); 1125 rle->odev = child; 1126 rle->win = -1; 1127 SLIST_INSERT_HEAD(&sc->rl, rle, entries); 1128 1129 pccbb_cardbus_auto_open(sc, type); 1130 } 1131 return bus_generic_activate_resource(brdev, child, type, rid, r); | 1199 ret = BUS_ACTIVATE_RESOURCE(device_get_parent(brdev), child, 1200 type, rid, res); 1201 if (ret != 0) return ret; 1202 pccbb_cardbus_auto_open(device_get_softc(brdev), type); 1203 return 0; |
1132} 1133 1134static int 1135pccbb_cardbus_deactivate_resource(device_t brdev, device_t child, int type, | 1204} 1205 1206static int 1207pccbb_cardbus_deactivate_resource(device_t brdev, device_t child, int type, |
1136 int rid, struct resource *r) | 1208 int rid, struct resource *res) |
1137{ | 1209{ |
1138 struct pccbb_softc *sc = device_get_softc(brdev); 1139 struct pccbb_reslist *rle; | 1210 int ret; |
1140 | 1211 |
1141 SLIST_FOREACH(rle, &sc->rl, entries) { 1142 if (type == rle->type && rid == rle->rid && 1143 child == rle->odev) { 1144 SLIST_REMOVE(&sc->rl, rle, pccbb_reslist, entries); 1145 if (type == SYS_RES_IOPORT || 1146 type == SYS_RES_MEMORY) 1147 pccbb_cardbus_auto_open(sc, type); 1148 free(rle, M_DEVBUF); 1149 break; 1150 } 1151 } 1152 return bus_generic_deactivate_resource(brdev, child, type, rid, r); | 1212 ret = BUS_DEACTIVATE_RESOURCE(device_get_parent(brdev), child, 1213 type, rid, res); 1214 if (ret != 0) return ret; 1215 pccbb_cardbus_auto_open(device_get_softc(brdev), type); 1216 return 0; |
1153} 1154 1155static struct resource * 1156pccbb_cardbus_alloc_resource(device_t brdev, device_t child, int type, int *rid, 1157 u_long start, u_long end, u_long count, u_int flags) 1158{ | 1217} 1218 1219static struct resource * 1220pccbb_cardbus_alloc_resource(device_t brdev, device_t child, int type, int *rid, 1221 u_long start, u_long end, u_long count, u_int flags) 1222{ |
1159 if (type == SYS_RES_IRQ) { 1160 struct pccbb_softc *sc = device_get_softc(brdev); 1161 if (start == 0) { 1162 start = end = rman_get_start(sc->sc_irq_res); | 1223 struct pccbb_softc *sc = device_get_softc(brdev); 1224 struct pccbb_reslist *rle; 1225 int tmp; 1226 struct resource *res; 1227 1228 switch (type) { 1229 case SYS_RES_IRQ: 1230 tmp = rman_get_start(sc->sc_irq_res); 1231 if (start > tmp || end < tmp || count != 1) { 1232 device_printf(child, "requested interrupt %ld-%ld," 1233 "count = %ld not supported by pccbb\n", 1234 start, end, count); 1235 return NULL; |
1163 } | 1236 } |
1164 return bus_generic_alloc_resource(brdev, child, type, rid, 1165 start, end, count, flags); 1166 } else { 1167 if (type == SYS_RES_MEMORY && start == 0 && end == ~0) { 1168 start = CARDBUS_SYS_RES_MEMORY_START; 1169 end = CARDBUS_SYS_RES_MEMORY_END; 1170 } else if (type == SYS_RES_IOPORT && start == 0 && end == ~0) { 1171 start = CARDBUS_SYS_RES_IOPORT_START; 1172 end = CARDBUS_SYS_RES_IOPORT_END; 1173 } 1174 return bus_generic_alloc_resource(brdev, child, type, rid, 1175 start, end, count, flags); | 1237 start = end = tmp; 1238 break; 1239 case SYS_RES_IOPORT: 1240 if (start <= 0x1000) 1241 start = 0x1000; 1242 if (end < start) 1243 end = start; 1244 break; 1245 case SYS_RES_MEMORY: 1246 if (start <= 0x44000000) 1247 start = 0x44000000; 1248 if (end < start) 1249 end = start; 1250 break; |
1176 } | 1251 } |
1252 1253 res = BUS_ALLOC_RESOURCE(device_get_parent(brdev), child, type, rid, 1254 start, end, count, flags & ~RF_ACTIVE); 1255 if (res == NULL) { 1256 printf("pccbb alloc res fail\n"); 1257 return NULL; 1258 } 1259 1260 /* 1261 * Need to record allocated resource so we can iterate through 1262 * it later. 1263 */ 1264 rle = malloc(sizeof(struct pccbb_reslist), M_DEVBUF, M_NOWAIT); 1265 if (!res) 1266 panic("pccbb_cardbus_alloc_resource: can't record entry!"); 1267 rle->res = res; 1268 rle->type = type; 1269 rle->rid = *rid; 1270 rle->cardaddr = 0; 1271 SLIST_INSERT_HEAD(&sc->rl, rle, link); 1272 1273 if (flags & RF_ACTIVE) 1274 if (bus_activate_resource(child, type, *rid, res) != 0) { 1275 bus_release_resource(child, type, *rid, res); 1276 return NULL; 1277 } 1278 1279 return res; |
|
1177} 1178 1179static int 1180pccbb_cardbus_release_resource(device_t brdev, device_t child, int type, | 1280} 1281 1282static int 1283pccbb_cardbus_release_resource(device_t brdev, device_t child, int type, |
1181 int rid, struct resource *r) | 1284 int rid, struct resource *res) |
1182{ | 1285{ |
1183 return bus_generic_release_resource(brdev, child, type, rid, r); | 1286 struct pccbb_softc *sc = device_get_softc(brdev); 1287 struct pccbb_reslist *rle; 1288 1289 if (rman_get_flags(res) & RF_ACTIVE) { 1290 int error; 1291 error = bus_deactivate_resource(child, type, rid, res); 1292 if (error != 0) 1293 return error; 1294 } 1295 1296 SLIST_FOREACH(rle, &sc->rl, link) { 1297 if (rle->res == res) { 1298 SLIST_REMOVE(&sc->rl, rle, pccbb_reslist, link); 1299 free(rle, M_DEVBUF); 1300 break; 1301 } 1302 } 1303 1304 return BUS_RELEASE_RESOURCE(device_get_parent(brdev), child, 1305 type, rid, res); |
1184} 1185 1186/************************************************************************/ 1187/* PC Card Power Functions */ 1188/************************************************************************/ 1189 1190static int 1191pccbb_pcic_power_enable_socket(device_t brdev, device_t child) --- 67 unchanged lines hidden (view full) --- 1259 1260 DPRINTF(("pccbb_pcic_socket_disable\n")); 1261 1262 /* reset signal asserting... */ 1263 PCIC_MASK(sc, PCIC_INTR, & ~PCIC_INTR_RESET); 1264 DELAY(2*1000); 1265 1266 /* power down the socket */ | 1306} 1307 1308/************************************************************************/ 1309/* PC Card Power Functions */ 1310/************************************************************************/ 1311 1312static int 1313pccbb_pcic_power_enable_socket(device_t brdev, device_t child) --- 67 unchanged lines hidden (view full) --- 1381 1382 DPRINTF(("pccbb_pcic_socket_disable\n")); 1383 1384 /* reset signal asserting... */ 1385 PCIC_MASK(sc, PCIC_INTR, & ~PCIC_INTR_RESET); 1386 DELAY(2*1000); 1387 1388 /* power down the socket */ |
1267 PCIC_MASK(sc, PCIC_PWRCTL, &~PCIC_PWRCTL_OE); | |
1268 pccbb_power(brdev, CARD_VCC_0V | CARD_VPP_0V); | 1389 pccbb_power(brdev, CARD_VCC_0V | CARD_VPP_0V); |
1390 PCIC_MASK(sc, PCIC_PWRCTL, &~PCIC_PWRCTL_OE); |
|
1269 1270 /* wait 300ms until power fails (Tpf). */ 1271 DELAY(300 * 1000); 1272} 1273 1274/************************************************************************/ 1275/* PC Card Resource Functions */ 1276/************************************************************************/ --- 92 unchanged lines hidden (view full) --- 1369 win, r1, r2, r3, r4, r5, r6, r7, 1370 sc->mem[win].addr, sc->mem[win].size, sc->mem[win].realsize, 1371 sc->mem[win].offset)); 1372 } 1373#endif 1374} 1375 1376static int | 1391 1392 /* wait 300ms until power fails (Tpf). */ 1393 DELAY(300 * 1000); 1394} 1395 1396/************************************************************************/ 1397/* PC Card Resource Functions */ 1398/************************************************************************/ --- 92 unchanged lines hidden (view full) --- 1491 win, r1, r2, r3, r4, r5, r6, r7, 1492 sc->mem[win].addr, sc->mem[win].size, sc->mem[win].realsize, 1493 sc->mem[win].offset)); 1494 } 1495#endif 1496} 1497 1498static int |
1377pccbb_pcic_mem_map(struct pccbb_softc *sc, int kind, 1378 struct resource *r, bus_addr_t card_addr, int *win) | 1499pccbb_pcic_mem_map(struct pccbb_softc *sc, int kind, struct resource *res) |
1379{ | 1500{ |
1380 int i; | 1501 int win; 1502 struct pccbb_reslist *rle; 1503 bus_addr_t card_addr; |
1381 | 1504 |
1382 *win = -1; 1383 for (i = 0; i < PCIC_MEM_WINS; i++) { 1384 if ((sc->memalloc & (1 << i)) == 0) { 1385 *win = i; 1386 sc->memalloc |= (1 << i); | 1505 for (win = 0; win < PCIC_MEM_WINS; win++) { 1506 if ((sc->memalloc & (1 << win)) == 0) { 1507 sc->memalloc |= (1 << win); |
1387 break; 1388 } 1389 } | 1508 break; 1509 } 1510 } |
1390 if (*win == -1) | 1511 if (win >= PCIC_MEM_WINS) |
1391 return (1); 1392 | 1512 return (1); 1513 |
1393 card_addr = card_addr - card_addr % PCIC_MEM_PAGESIZE; 1394 sc->mem[*win].memt = rman_get_bustag(r); 1395 sc->mem[*win].memh = rman_get_bushandle(r); 1396 sc->mem[*win].addr = rman_get_start(r); 1397 sc->mem[*win].size = rman_get_end(r) - sc->mem[*win].addr + 1; 1398 sc->mem[*win].realsize = sc->mem[*win].size + PCIC_MEM_PAGESIZE - 1; 1399 sc->mem[*win].realsize = sc->mem[*win].realsize - 1400 (sc->mem[*win].realsize % PCIC_MEM_PAGESIZE); 1401 sc->mem[*win].offset = ((long)card_addr) - 1402 ((long)(sc->mem[*win].addr)); 1403 sc->mem[*win].kind = kind; | 1514 SLIST_FOREACH(rle, &sc->rl, link) { 1515 if (rle->res == res) 1516 break; 1517 } 1518 if (!rle) { 1519 device_printf(sc->sc_dev, 1520 "pcic_map_mem: Memory resource not found\n"); 1521 return ENXIO; 1522 } 1523 card_addr = rle->cardaddr - rle->cardaddr % PCIC_MEM_PAGESIZE; 1524 sc->mem[win].memt = rman_get_bustag(res); 1525 sc->mem[win].memh = rman_get_bushandle(res); 1526 sc->mem[win].addr = rman_get_start(res); 1527 sc->mem[win].size = rman_get_end(res) - sc->mem[win].addr + 1; 1528 sc->mem[win].realsize = sc->mem[win].size + PCIC_MEM_PAGESIZE - 1; 1529 sc->mem[win].realsize = sc->mem[win].realsize - 1530 (sc->mem[win].realsize % PCIC_MEM_PAGESIZE); 1531 sc->mem[win].offset = ((long)card_addr) - 1532 ((long)(sc->mem[win].addr)); 1533 sc->mem[win].kind = kind; |
1404 1405 DPRINTF(("pccbb_pcic_mem_map window %d bus %x+%x+%lx card addr %x\n", | 1534 1535 DPRINTF(("pccbb_pcic_mem_map window %d bus %x+%x+%lx card addr %x\n", |
1406 *win, sc->mem[*win].addr, sc->mem[*win].size, 1407 sc->mem[*win].offset, card_addr)); | 1536 win, sc->mem[win].addr, sc->mem[win].size, 1537 sc->mem[win].offset, card_addr)); |
1408 | 1538 |
1409 pccbb_pcic_do_mem_map(sc, *win); | 1539 pccbb_pcic_do_mem_map(sc, win); |
1410 1411 return (0); 1412} 1413 1414static void 1415pccbb_pcic_mem_unmap(struct pccbb_softc *sc, int window) 1416{ 1417 if (window >= PCIC_MEM_WINS) 1418 panic("pccbb_pcic_mem_unmap: window out of range"); 1419 1420 PCIC_MASK(sc, PCIC_ADDRWIN_ENABLE, & ~mem_map_index[window].memenable); 1421 sc->memalloc &= ~(1 << window); 1422} 1423 | 1540 1541 return (0); 1542} 1543 1544static void 1545pccbb_pcic_mem_unmap(struct pccbb_softc *sc, int window) 1546{ 1547 if (window >= PCIC_MEM_WINS) 1548 panic("pccbb_pcic_mem_unmap: window out of range"); 1549 1550 PCIC_MASK(sc, PCIC_ADDRWIN_ENABLE, & ~mem_map_index[window].memenable); 1551 sc->memalloc &= ~(1 << window); 1552} 1553 |
1554static int 1555pccbb_pcic_mem_findmap(struct pccbb_softc *sc, struct resource *res) 1556{ 1557 int win; 1558 1559 for (win = 0; win < PCIC_MEM_WINS; win++) { 1560 if (sc->mem[win].memt == rman_get_bustag(res) && 1561 sc->mem[win].addr == rman_get_start(res) && 1562 sc->mem[win].size == rman_get_size(res)) 1563 return win; 1564 } 1565 device_printf(sc->sc_dev, "Memory map not found!\n"); 1566 return -1; 1567} 1568 |
|
1424#define PCIC_IOINFO(NUM) { \ 1425 PCIC_IOADDR ## NUM ## _START_LSB, \ 1426 PCIC_IOADDR ## NUM ## _START_MSB, \ 1427 PCIC_IOADDR ## NUM ## _STOP_LSB, \ 1428 PCIC_IOADDR ## NUM ## _STOP_MSB, \ 1429 PCIC_ADDRWIN_ENABLE_IO ## NUM ##, \ 1430 PCIC_IOCTL_IO ## NUM ## _WAITSTATE \ 1431 | PCIC_IOCTL_IO ## NUM ## _ZEROWAIT \ --- 49 unchanged lines hidden (view full) --- 1481 DPRINTF(("pccbb_pcic_do_io_map window %d: %02x%02x %02x%02x " 1482 "(%08x+%08x)\n", win, r1, r2, r3, r4, 1483 sc->io[win].addr, sc->io[win].size)); 1484 } 1485#endif 1486} 1487 1488static int | 1569#define PCIC_IOINFO(NUM) { \ 1570 PCIC_IOADDR ## NUM ## _START_LSB, \ 1571 PCIC_IOADDR ## NUM ## _START_MSB, \ 1572 PCIC_IOADDR ## NUM ## _STOP_LSB, \ 1573 PCIC_IOADDR ## NUM ## _STOP_MSB, \ 1574 PCIC_ADDRWIN_ENABLE_IO ## NUM ##, \ 1575 PCIC_IOCTL_IO ## NUM ## _WAITSTATE \ 1576 | PCIC_IOCTL_IO ## NUM ## _ZEROWAIT \ --- 49 unchanged lines hidden (view full) --- 1626 DPRINTF(("pccbb_pcic_do_io_map window %d: %02x%02x %02x%02x " 1627 "(%08x+%08x)\n", win, r1, r2, r3, r4, 1628 sc->io[win].addr, sc->io[win].size)); 1629 } 1630#endif 1631} 1632 1633static int |
1489pccbb_pcic_io_map(struct pccbb_softc *sc, int width, 1490 struct resource *r, bus_addr_t card_addr, int *win) | 1634pccbb_pcic_io_map(struct pccbb_softc *sc, int width, struct resource *r) |
1491{ | 1635{ |
1492 int i; | 1636 int win; |
1493#ifdef CBB_DEBUG 1494 static char *width_names[] = { "auto", "io8", "io16"}; 1495#endif 1496 | 1637#ifdef CBB_DEBUG 1638 static char *width_names[] = { "auto", "io8", "io16"}; 1639#endif 1640 |
1497 *win = -1; 1498 for (i=0; i < PCIC_IO_WINS; i++) { 1499 if ((sc->ioalloc & (1 << i)) == 0) { 1500 *win = i; 1501 sc->ioalloc |= (1 << i); | 1641 for (win=0; win < PCIC_IO_WINS; win++) { 1642 if ((sc->ioalloc & (1 << win)) == 0) { 1643 sc->ioalloc |= (1 << win); |
1502 break; 1503 } 1504 } | 1644 break; 1645 } 1646 } |
1505 if (*win == -1) | 1647 if (win >= PCIC_IO_WINS) |
1506 return (1); 1507 | 1648 return (1); 1649 |
1508 sc->io[*win].iot = rman_get_bustag(r); 1509 sc->io[*win].ioh = rman_get_bushandle(r); 1510 sc->io[*win].addr = rman_get_start(r); 1511 sc->io[*win].size = rman_get_end(r) - sc->io[*win].addr + 1; 1512 sc->io[*win].flags = 0; 1513 sc->io[*win].width = width; | 1650 sc->io[win].iot = rman_get_bustag(r); 1651 sc->io[win].ioh = rman_get_bushandle(r); 1652 sc->io[win].addr = rman_get_start(r); 1653 sc->io[win].size = rman_get_end(r) - sc->io[win].addr + 1; 1654 sc->io[win].flags = 0; 1655 sc->io[win].width = width; |
1514 1515 DPRINTF(("pccbb_pcic_io_map window %d %s port %x+%x\n", | 1656 1657 DPRINTF(("pccbb_pcic_io_map window %d %s port %x+%x\n", |
1516 *win, width_names[width], sc->io[*win].addr, 1517 sc->io[*win].size)); | 1658 win, width_names[width], sc->io[win].addr, 1659 sc->io[win].size)); |
1518 | 1660 |
1519 pccbb_pcic_do_io_map(sc, *win); | 1661 pccbb_pcic_do_io_map(sc, win); |
1520 1521 return (0); 1522} 1523 1524static void 1525pccbb_pcic_io_unmap(struct pccbb_softc *sc, int window) 1526{ 1527 if (window >= PCIC_IO_WINS) --- 7 unchanged lines hidden (view full) --- 1535 sc->io[window].ioh = 0; 1536 sc->io[window].addr = 0; 1537 sc->io[window].size = 0; 1538 sc->io[window].flags = 0; 1539 sc->io[window].width = 0; 1540} 1541 1542static int | 1662 1663 return (0); 1664} 1665 1666static void 1667pccbb_pcic_io_unmap(struct pccbb_softc *sc, int window) 1668{ 1669 if (window >= PCIC_IO_WINS) --- 7 unchanged lines hidden (view full) --- 1677 sc->io[window].ioh = 0; 1678 sc->io[window].addr = 0; 1679 sc->io[window].size = 0; 1680 sc->io[window].flags = 0; 1681 sc->io[window].width = 0; 1682} 1683 1684static int |
1543pccbb_pcic_activate_resource(device_t brdev, device_t child, int type, int rid, 1544 struct resource *r) | 1685pccbb_pcic_io_findmap(struct pccbb_softc *sc, struct resource *res) |
1545{ | 1686{ |
1546 int err; | |
1547 int win; | 1687 int win; |
1548 struct pccbb_reslist *rle; 1549 struct pccbb_softc *sc = device_get_softc(brdev); | |
1550 | 1688 |
1551 if (rman_get_flags(r) & RF_ACTIVE) 1552 return 0; | 1689 for (win = 0; win < PCIC_IO_WINS; win++) { 1690 if (sc->io[win].iot == rman_get_bustag(res) && 1691 sc->io[win].addr == rman_get_start(res) && 1692 sc->io[win].size == rman_get_size(res)) 1693 return win; 1694 } 1695 device_printf(sc->sc_dev, "IO map not found!\n"); 1696 return -1; 1697} |
1553 | 1698 |
1554 switch (type) { 1555 case SYS_RES_IOPORT: 1556 err = pccbb_pcic_io_map(sc, 0, r, 0, &win); | 1699static int 1700pccbb_pcic_activate_resource(device_t brdev, device_t child, int type, int rid, 1701 struct resource *res) 1702{ 1703 int err; 1704 struct pccbb_softc *sc = device_get_softc(brdev); 1705 if (!(rman_get_flags(res) & RF_ACTIVE)) { /* not already activated */ 1706 switch (type) { 1707 case SYS_RES_IOPORT: 1708 err = pccbb_pcic_io_map(sc, 0, res); 1709 break; 1710 case SYS_RES_MEMORY: 1711 err = pccbb_pcic_mem_map(sc, 0, res); 1712 break; 1713 default: 1714 err = 0; 1715 break; 1716 } |
1557 if (err) 1558 return err; | 1717 if (err) 1718 return err; |
1559 break; 1560 case SYS_RES_MEMORY: 1561 err = pccbb_pcic_mem_map(sc, 0, r, 0, &win); 1562 if (err) 1563 return err; 1564 break; 1565 default: 1566 break; | 1719 |
1567 } | 1720 } |
1568 SLIST_FOREACH(rle, &sc->rl, entries) { 1569 if (type == rle->type && rid == rle->rid && 1570 child == rle->odev) { 1571 rle->win = win; 1572 break; 1573 } 1574 } 1575 err = bus_generic_activate_resource(brdev, child, type, rid, r); 1576 return (err); | 1721 return BUS_ACTIVATE_RESOURCE(device_get_parent(brdev), child, 1722 type, rid, res); |
1577} 1578 1579static int 1580pccbb_pcic_deactivate_resource(device_t brdev, device_t child, int type, | 1723} 1724 1725static int 1726pccbb_pcic_deactivate_resource(device_t brdev, device_t child, int type, |
1581 int rid, struct resource *r) | 1727 int rid, struct resource *res) |
1582{ 1583 struct pccbb_softc *sc = device_get_softc(brdev); 1584 int win; | 1728{ 1729 struct pccbb_softc *sc = device_get_softc(brdev); 1730 int win; |
1585 struct pccbb_reslist *rle; 1586 win = -1; 1587 SLIST_FOREACH(rle, &sc->rl, entries) { 1588 if (type == rle->type && rid == rle->rid && 1589 child == rle->odev) { 1590 win = rle->win; | 1731 1732 if (rman_get_flags(res) & RF_ACTIVE) { /* if activated */ 1733 switch (type) { 1734 case SYS_RES_IOPORT: 1735 win = pccbb_pcic_io_findmap(sc, res); 1736 if (win >= 0) 1737 pccbb_pcic_io_unmap(sc, win); 1738 else 1739 return ENOENT; |
1591 break; | 1740 break; |
1741 case SYS_RES_MEMORY: 1742 win = pccbb_pcic_mem_findmap(sc, res); 1743 if (win >= 0) 1744 pccbb_pcic_mem_unmap(sc, win); 1745 else 1746 return ENOENT; 1747 break; |
|
1592 } 1593 } | 1748 } 1749 } |
1594 if (win == -1) { 1595 panic("pccbb_pcic: deactivating bogus resoure"); 1596 return 1; 1597 } 1598 1599 switch (type) { 1600 case SYS_RES_IOPORT: 1601 pccbb_pcic_io_unmap(sc, win); 1602 break; 1603 case SYS_RES_MEMORY: 1604 pccbb_pcic_mem_unmap(sc, win); 1605 break; 1606 default: 1607 break; 1608 } 1609 return bus_generic_deactivate_resource(brdev, child, type, rid, r); | 1750 return BUS_DEACTIVATE_RESOURCE(device_get_parent(brdev), child, 1751 type, rid, res); |
1610} 1611 1612static struct resource * 1613pccbb_pcic_alloc_resource(device_t brdev, device_t child, int type, int *rid, 1614 u_long start, u_long end, u_long count, u_int flags) 1615{ | 1752} 1753 1754static struct resource * 1755pccbb_pcic_alloc_resource(device_t brdev, device_t child, int type, int *rid, 1756 u_long start, u_long end, u_long count, u_int flags) 1757{ |
1616 struct resource *r = NULL; | 1758 struct resource *res = NULL; |
1617 struct pccbb_softc *sc = device_get_softc(brdev); 1618 struct pccbb_reslist *rle; | 1759 struct pccbb_softc *sc = device_get_softc(brdev); 1760 struct pccbb_reslist *rle; |
1761 int tmp; |
|
1619 1620 if ((sc->sc_flags & PCCBB_PCIC_MEM_32) == 0) { 1621 /* XXX: how do we do this? */ 1622 panic("PCCBB bridge cannot handle non MEM_32 bridges\n"); 1623 } 1624 1625 switch (type) { 1626 case SYS_RES_MEMORY: | 1762 1763 if ((sc->sc_flags & PCCBB_PCIC_MEM_32) == 0) { 1764 /* XXX: how do we do this? */ 1765 panic("PCCBB bridge cannot handle non MEM_32 bridges\n"); 1766 } 1767 1768 switch (type) { 1769 case SYS_RES_MEMORY: |
1627 /* Nearly default */ 1628 if (start == 0 && end == ~0 && count != 1) { 1629 start = CARDBUS_SYS_RES_MEMORY_START; /* XXX -- should be tweakable*/ 1630 end = CARDBUS_SYS_RES_MEMORY_END; 1631 } | 1770 if (start < 0x10000000) 1771 start = 0x10000000; /* XXX tweakable? */ 1772 if (end < start) 1773 end = start; |
1632 flags = (flags & ~RF_ALIGNMENT_MASK) | 1633 rman_make_alignment_flags(PCCBB_MEMALIGN); 1634 break; 1635 case SYS_RES_IOPORT: 1636 if (start < 0x100) 1637 start = 0x100; /* XXX tweakable? */ 1638 if (end < start) 1639 end = start; 1640 break; 1641 case SYS_RES_IRQ: | 1774 flags = (flags & ~RF_ALIGNMENT_MASK) | 1775 rman_make_alignment_flags(PCCBB_MEMALIGN); 1776 break; 1777 case SYS_RES_IOPORT: 1778 if (start < 0x100) 1779 start = 0x100; /* XXX tweakable? */ 1780 if (end < start) 1781 end = start; 1782 break; 1783 case SYS_RES_IRQ: |
1784 tmp = rman_get_start(sc->sc_irq_res); 1785 if (start > tmp || end < tmp || count != 1) { 1786 device_printf(child, "requested interrupt %ld-%ld," 1787 "count = %ld not supported by pccbb\n", 1788 start, end, count); 1789 return NULL; 1790 } |
|
1642 flags |= RF_SHAREABLE; 1643 start = end = rman_get_start(sc->sc_irq_res); 1644 break; 1645 } | 1791 flags |= RF_SHAREABLE; 1792 start = end = rman_get_start(sc->sc_irq_res); 1793 break; 1794 } |
1646 r = bus_generic_alloc_resource(brdev, child, type, rid, start, end, 1647 count, flags & ~RF_ACTIVE); 1648 if (r == NULL) | 1795 res = BUS_ALLOC_RESOURCE(device_get_parent(brdev), child, type, rid, 1796 start, end, count, flags & ~RF_ACTIVE); 1797 if (res == NULL) |
1649 return NULL; 1650 | 1798 return NULL; 1799 |
1651 rle = malloc(sizeof(struct pccbb_reslist), M_DEVBUF, M_WAITOK); | 1800 rle = malloc(sizeof(struct pccbb_reslist), M_DEVBUF, M_NOWAIT); 1801 if (!rle) 1802 panic("pccbb_pcic_alloc_resource: can't record entry!"); 1803 rle->res = res; |
1652 rle->type = type; 1653 rle->rid = *rid; | 1804 rle->type = type; 1805 rle->rid = *rid; |
1654 rle->start = rman_get_start(r); 1655 rle->end = rman_get_end(r); 1656 rle->odev = child; 1657 rle->win = -1; 1658 SLIST_INSERT_HEAD(&sc->rl, rle, entries); | 1806 rle->cardaddr = 0; 1807 SLIST_INSERT_HEAD(&sc->rl, rle, link); |
1659 1660 if (flags & RF_ACTIVE) { | 1808 1809 if (flags & RF_ACTIVE) { |
1661 if (bus_activate_resource(child, type, *rid, r) != 0) { 1662 BUS_RELEASE_RESOURCE(brdev, child, type, *rid, r); | 1810 if (bus_activate_resource(child, type, *rid, res) != 0) { 1811 bus_release_resource(child, type, *rid, res); |
1663 return NULL; 1664 } 1665 } 1666 | 1812 return NULL; 1813 } 1814 } 1815 |
1667 return r; | 1816 return res; |
1668} 1669 1670static int 1671pccbb_pcic_release_resource(device_t brdev, device_t child, int type, 1672 int rid, struct resource *res) 1673{ 1674 struct pccbb_softc *sc = device_get_softc(brdev); 1675 struct pccbb_reslist *rle; | 1817} 1818 1819static int 1820pccbb_pcic_release_resource(device_t brdev, device_t child, int type, 1821 int rid, struct resource *res) 1822{ 1823 struct pccbb_softc *sc = device_get_softc(brdev); 1824 struct pccbb_reslist *rle; |
1676 int count = 0; | |
1677 1678 if (rman_get_flags(res) & RF_ACTIVE) { 1679 int error; 1680 error = bus_deactivate_resource(child, type, rid, res); 1681 if (error != 0) 1682 return error; 1683 } 1684 | 1825 1826 if (rman_get_flags(res) & RF_ACTIVE) { 1827 int error; 1828 error = bus_deactivate_resource(child, type, rid, res); 1829 if (error != 0) 1830 return error; 1831 } 1832 |
1685 SLIST_FOREACH(rle, &sc->rl, entries) { 1686 if (type == rle->type && rid == rle->rid && 1687 child == rle->odev) { 1688 SLIST_REMOVE(&sc->rl, rle, pccbb_reslist, entries); | 1833 SLIST_FOREACH(rle, &sc->rl, link) { 1834 if (rle->res == res) { 1835 SLIST_REMOVE(&sc->rl, rle, pccbb_reslist, link); |
1689 free(rle, M_DEVBUF); | 1836 free(rle, M_DEVBUF); |
1690 count++; | |
1691 break; 1692 } 1693 } | 1837 break; 1838 } 1839 } |
1694 if (count == 0) { 1695 panic("pccbb_pcic: releasing bogus resource"); 1696 } | |
1697 | 1840 |
1698 return bus_generic_release_resource(brdev, child, type, rid, res); | 1841 return BUS_RELEASE_RESOURCE(device_get_parent(brdev), child, 1842 type, rid, res); |
1699} 1700 1701/************************************************************************/ 1702/* PC Card methods */ 1703/************************************************************************/ 1704 1705static int 1706pccbb_pcic_set_res_flags(device_t brdev, device_t child, int type, int rid, 1707 u_int32_t flags) 1708{ 1709 struct pccbb_softc *sc = device_get_softc(brdev); | 1843} 1844 1845/************************************************************************/ 1846/* PC Card methods */ 1847/************************************************************************/ 1848 1849static int 1850pccbb_pcic_set_res_flags(device_t brdev, device_t child, int type, int rid, 1851 u_int32_t flags) 1852{ 1853 struct pccbb_softc *sc = device_get_softc(brdev); |
1854 struct resource *res; 1855 struct pccbb_reslist *rle; 1856 int win; |
|
1710 | 1857 |
1858 res = NULL; |
|
1711 if (type != SYS_RES_MEMORY) 1712 return (EINVAL); | 1859 if (type != SYS_RES_MEMORY) 1860 return (EINVAL); |
1713 sc->mem[rid].kind = flags; 1714 pccbb_pcic_do_mem_map(sc, rid); | 1861 SLIST_FOREACH(rle, &sc->rl, link) { 1862 if (SYS_RES_MEMORY == rle->type && rid == rle->rid && 1863 child == rle->res->r_dev) { 1864 res = rle->res; 1865 break; 1866 } 1867 } 1868 1869 if (res == NULL) { 1870 device_printf(brdev, 1871 "set_res_flags: specified rid not found\n"); 1872 return ENOENT; 1873 } 1874 win = pccbb_pcic_mem_findmap(sc, res); 1875 if (win < 0) { 1876 device_printf(brdev, 1877 "set_res_flags: specified resource not active\n"); 1878 return ENOENT; 1879 } 1880 1881 sc->mem[win].kind = flags; 1882 pccbb_pcic_do_mem_map(sc, win); |
1715 return 0; 1716} 1717 1718static int 1719pccbb_pcic_set_memory_offset(device_t brdev, device_t child, int rid, 1720 u_int32_t cardaddr, u_int32_t *deltap) 1721{ 1722 struct pccbb_softc *sc = device_get_softc(brdev); 1723 int win; 1724 struct pccbb_reslist *rle; | 1883 return 0; 1884} 1885 1886static int 1887pccbb_pcic_set_memory_offset(device_t brdev, device_t child, int rid, 1888 u_int32_t cardaddr, u_int32_t *deltap) 1889{ 1890 struct pccbb_softc *sc = device_get_softc(brdev); 1891 int win; 1892 struct pccbb_reslist *rle; |
1893 struct resource *res; |
|
1725 u_int32_t delta; 1726 1727 win = -1; 1728 | 1894 u_int32_t delta; 1895 1896 win = -1; 1897 |
1729 SLIST_FOREACH(rle, &sc->rl, entries) { | 1898 res = NULL; 1899 SLIST_FOREACH(rle, &sc->rl, link) { |
1730 if (SYS_RES_MEMORY == rle->type && rid == rle->rid && | 1900 if (SYS_RES_MEMORY == rle->type && rid == rle->rid && |
1731 child == rle->odev) { 1732 win = rle->win; | 1901 child == rle->res->r_dev) { 1902 res = rle->res; 1903 rle->cardaddr = cardaddr; |
1733 break; 1734 } 1735 } | 1904 break; 1905 } 1906 } |
1736 if (win == -1) { 1737 panic("pccbb_pcic: setting memory offset of bogus resource"); 1738 return 1; | 1907 1908 if (res == NULL) { 1909 device_printf(brdev, 1910 "set_memory_offset: specified rid not found\n"); 1911 return ENOENT; |
1739 } | 1912 } |
1913 win = pccbb_pcic_mem_findmap(sc, res); 1914 if (win < 0) { 1915 device_printf(brdev, 1916 "set_memory_offset: specified resource not active\n"); 1917 return ENOENT; 1918 } |
|
1740 1741 delta = cardaddr % PCIC_MEM_PAGESIZE; 1742 if (deltap) 1743 *deltap = delta; 1744 cardaddr -= delta; 1745 sc->mem[win].realsize = sc->mem[win].size + delta + 1746 PCIC_MEM_PAGESIZE - 1; 1747 sc->mem[win].realsize = sc->mem[win].realsize - --- 145 unchanged lines hidden (view full) --- 1893 b, s, f, reg, val, width); 1894} 1895 1896static device_method_t pccbb_methods[] = { 1897 /* Device interface */ 1898 DEVMETHOD(device_probe, pccbb_probe), 1899 DEVMETHOD(device_attach, pccbb_attach), 1900 DEVMETHOD(device_detach, pccbb_detach), | 1919 1920 delta = cardaddr % PCIC_MEM_PAGESIZE; 1921 if (deltap) 1922 *deltap = delta; 1923 cardaddr -= delta; 1924 sc->mem[win].realsize = sc->mem[win].size + delta + 1925 PCIC_MEM_PAGESIZE - 1; 1926 sc->mem[win].realsize = sc->mem[win].realsize - --- 145 unchanged lines hidden (view full) --- 2072 b, s, f, reg, val, width); 2073} 2074 2075static device_method_t pccbb_methods[] = { 2076 /* Device interface */ 2077 DEVMETHOD(device_probe, pccbb_probe), 2078 DEVMETHOD(device_attach, pccbb_attach), 2079 DEVMETHOD(device_detach, pccbb_detach), |
2080 DEVMETHOD(device_shutdown, pccbb_shutdown), |
|
1901 DEVMETHOD(device_suspend, bus_generic_suspend), 1902 DEVMETHOD(device_resume, bus_generic_resume), 1903 1904 /* bus methods */ 1905 DEVMETHOD(bus_print_child, bus_generic_print_child), 1906 DEVMETHOD(bus_read_ivar, pccbb_read_ivar), 1907 DEVMETHOD(bus_write_ivar, pccbb_write_ivar), 1908 DEVMETHOD(bus_alloc_resource, pccbb_alloc_resource), 1909 DEVMETHOD(bus_release_resource, pccbb_release_resource), 1910 DEVMETHOD(bus_activate_resource, pccbb_activate_resource), 1911 DEVMETHOD(bus_deactivate_resource, pccbb_deactivate_resource), 1912 DEVMETHOD(bus_driver_added, pccbb_driver_added), 1913 DEVMETHOD(bus_child_detached, pccbb_child_detached), 1914 DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), 1915 DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), 1916 | 2081 DEVMETHOD(device_suspend, bus_generic_suspend), 2082 DEVMETHOD(device_resume, bus_generic_resume), 2083 2084 /* bus methods */ 2085 DEVMETHOD(bus_print_child, bus_generic_print_child), 2086 DEVMETHOD(bus_read_ivar, pccbb_read_ivar), 2087 DEVMETHOD(bus_write_ivar, pccbb_write_ivar), 2088 DEVMETHOD(bus_alloc_resource, pccbb_alloc_resource), 2089 DEVMETHOD(bus_release_resource, pccbb_release_resource), 2090 DEVMETHOD(bus_activate_resource, pccbb_activate_resource), 2091 DEVMETHOD(bus_deactivate_resource, pccbb_deactivate_resource), 2092 DEVMETHOD(bus_driver_added, pccbb_driver_added), 2093 DEVMETHOD(bus_child_detached, pccbb_child_detached), 2094 DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), 2095 DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), 2096 |
1917 /* 16-bit card interface */ | 2097 /* 16-bit card interface */ |
1918 DEVMETHOD(card_set_res_flags, pccbb_pcic_set_res_flags), 1919 DEVMETHOD(card_set_memory_offset, pccbb_pcic_set_memory_offset), | 2098 DEVMETHOD(card_set_res_flags, pccbb_pcic_set_res_flags), 2099 DEVMETHOD(card_set_memory_offset, pccbb_pcic_set_memory_offset), |
2100 DEVMETHOD(card_reprobe_card, pccbb_card_reprobe), |
|
1920 | 2101 |
1921 /* power interface */ | 2102 /* power interface */ |
1922 DEVMETHOD(power_enable_socket, pccbb_power_enable_socket), 1923 DEVMETHOD(power_disable_socket, pccbb_power_disable_socket), 1924 | 2103 DEVMETHOD(power_enable_socket, pccbb_power_enable_socket), 2104 DEVMETHOD(power_disable_socket, pccbb_power_disable_socket), 2105 |
1925 /* pcib compatibility interface */ | 2106 /* pcib compatibility interface */ |
1926 DEVMETHOD(pcib_maxslots, pccbb_maxslots), 1927 DEVMETHOD(pcib_read_config, pccbb_read_config), 1928 DEVMETHOD(pcib_write_config, pccbb_write_config), 1929 {0,0} 1930}; 1931 1932static driver_t pccbb_driver = { 1933 "pccbb", 1934 pccbb_methods, 1935 sizeof(struct pccbb_softc) 1936}; 1937 1938static devclass_t pccbb_devclass; 1939 1940DRIVER_MODULE(pccbb, pci, pccbb_driver, pccbb_devclass, 0, 0); 1941 1942SYSINIT(pccbb, SI_SUB_KTHREAD_IDLE, SI_ORDER_ANY, pccbb_start_threads, 0); | 2107 DEVMETHOD(pcib_maxslots, pccbb_maxslots), 2108 DEVMETHOD(pcib_read_config, pccbb_read_config), 2109 DEVMETHOD(pcib_write_config, pccbb_write_config), 2110 {0,0} 2111}; 2112 2113static driver_t pccbb_driver = { 2114 "pccbb", 2115 pccbb_methods, 2116 sizeof(struct pccbb_softc) 2117}; 2118 2119static devclass_t pccbb_devclass; 2120 2121DRIVER_MODULE(pccbb, pci, pccbb_driver, pccbb_devclass, 0, 0); 2122 2123SYSINIT(pccbb, SI_SUB_KTHREAD_IDLE, SI_ORDER_ANY, pccbb_start_threads, 0); |