Lines Matching +full:touch +full:- +full:timeout +full:- +full:ms

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2000-2001 Jonathan Chen All rights reserved.
5 * Copyright (c) 2002-2004 M. Warner Losh <imp@FreeBSD.org>
30 /*-
65 * http://www-s.ti.com/cgi-bin/sc/generic2.cgi?family=PCI+CARDBUS+CONTROLLERS
137 "Starting ioport for 16-bit cards");
142 "Starting ioport for 32-bit cards");
178 SLIST_FOREACH(rle, &sc->rl, link) { in cbb_remove_res()
179 if (rle->res == res) { in cbb_remove_res()
180 SLIST_REMOVE(&sc->rl, rle, cbb_reslist, link); in cbb_remove_res()
192 SLIST_FOREACH(rle, &sc->rl, link) in cbb_find_res()
193 if (SYS_RES_MEMORY == rle->type && rid == rle->rid) in cbb_find_res()
194 return (rle->res); in cbb_find_res()
211 rle->res = res; in cbb_insert_res()
212 rle->type = type; in cbb_insert_res()
213 rle->rid = rid; in cbb_insert_res()
214 SLIST_INSERT_HEAD(&sc->rl, rle, link); in cbb_insert_res()
222 while ((rle = SLIST_FIRST(&sc->rl)) != NULL) { in cbb_destroy_res()
223 device_printf(sc->dev, "Danger Will Robinson: Resource " in cbb_destroy_res()
225 "(rid=%x, type=%d, addr=%jx)\n", rle->rid, rle->type, in cbb_destroy_res()
226 rman_get_start(rle->res)); in cbb_destroy_res()
227 SLIST_REMOVE_HEAD(&sc->rl, link); in cbb_destroy_res()
249 reg = (exca_getb(&sc->exca, EXCA_INTR) & ~EXCA_INTR_IRQ_MASK) | in cbb_disable_func_intr()
251 exca_putb(&sc->exca, EXCA_INTR, reg); in cbb_disable_func_intr()
267 reg = (exca_getb(&sc->exca, EXCA_INTR) & ~EXCA_INTR_IRQ_MASK) | in cbb_enable_func_intr()
269 PCI_MASK_CONFIG(sc->dev, CBBR_BRIDGECTRL, in cbb_enable_func_intr()
271 exca_putb(&sc->exca, EXCA_INTR, reg); in cbb_enable_func_intr()
309 } while (tries-- > 0); in cbb_detach()
317 /* reset 16-bit pcmcia bus */ in cbb_detach()
318 exca_clrb(&sc->exca, EXCA_INTR, EXCA_INTR_RESET); in cbb_detach()
334 bus_teardown_intr(brdev, sc->irq_res, sc->intrhand); in cbb_detach()
335 mtx_lock(&sc->mtx); in cbb_detach()
336 sc->flags |= CBB_KTHREAD_DONE; in cbb_detach()
337 while (sc->flags & CBB_KTHREAD_RUNNING) { in cbb_detach()
338 DEVPRINTF((sc->dev, "Waiting for thread to die\n")); in cbb_detach()
339 wakeup(&sc->intrhand); in cbb_detach()
340 msleep(sc->event_thread, &sc->mtx, PWAIT, "cbbun", 0); in cbb_detach()
342 mtx_unlock(&sc->mtx); in cbb_detach()
344 bus_release_resource(brdev, SYS_RES_IRQ, 0, sc->irq_res); in cbb_detach()
346 sc->base_res); in cbb_detach()
347 mtx_destroy(&sc->mtx); in cbb_detach()
366 ih->filt = filt; in cbb_setup_intr()
367 ih->intr = intr; in cbb_setup_intr()
368 ih->arg = arg; in cbb_setup_intr()
369 ih->sc = sc; in cbb_setup_intr()
376 &ih->cookie); in cbb_setup_intr()
382 sc->cardok = 1; in cbb_setup_intr()
396 ih->cookie); in cbb_teardown_intr()
428 wakeup(&sc->intrhand); in cbb_driver_added()
437 if (child != sc->cbdev && child != sc->exca.pccarddev) in cbb_child_detached()
457 * should add a lock that's shared on a per-slot basis so that only in cbb_event_thread()
460 pause("cbbstart", hz * device_get_unit(sc->dev) * 2); in cbb_event_thread()
461 mtx_lock(&sc->mtx); in cbb_event_thread()
462 sc->flags |= CBB_KTHREAD_RUNNING; in cbb_event_thread()
463 while ((sc->flags & CBB_KTHREAD_DONE) == 0) { in cbb_event_thread()
464 mtx_unlock(&sc->mtx); in cbb_event_thread()
479 DEVPRINTF((sc->dev, in cbb_event_thread()
483 device_printf(sc->dev, in cbb_event_thread()
495 if (sc->sc_root_token) { in cbb_event_thread()
496 root_mount_rel(sc->sc_root_token); in cbb_event_thread()
497 sc->sc_root_token = NULL; in cbb_event_thread()
501 * Wait until it has been 250ms since the last time we in cbb_event_thread()
504 * ISR, we signal sc->cv from the detach path after we've in cbb_event_thread()
506 * 250ms sleep here. in cbb_event_thread()
514 mtx_lock(&sc->mtx); in cbb_event_thread()
516 msleep(&sc->intrhand, &sc->mtx, 0, "-", 0); in cbb_event_thread()
519 (sc->flags & CBB_KTHREAD_DONE) == 0) in cbb_event_thread()
520 err = msleep(&sc->intrhand, &sc->mtx, 0, "-", hz / 5); in cbb_event_thread()
522 DEVPRINTF((sc->dev, "Thread terminating\n")); in cbb_event_thread()
523 sc->flags &= ~CBB_KTHREAD_RUNNING; in cbb_event_thread()
524 mtx_unlock(&sc->mtx); in cbb_event_thread()
540 DEVPRINTF((sc->dev, "card inserted: event=0x%08x, state=%08x\n", in cbb_insert()
544 if (device_is_attached(sc->exca.pccarddev)) { in cbb_insert()
545 sc->flags |= CBB_16BIT_CARD; in cbb_insert()
546 exca_insert(&sc->exca); in cbb_insert()
548 device_printf(sc->dev, in cbb_insert()
549 "16-bit card inserted, but no pccard bus.\n"); in cbb_insert()
552 if (device_is_attached(sc->cbdev)) { in cbb_insert()
553 sc->flags &= ~CBB_16BIT_CARD; in cbb_insert()
554 CARD_ATTACH_CARD(sc->cbdev); in cbb_insert()
556 device_printf(sc->dev, in cbb_insert()
564 device_printf(sc->dev, "Unsupported card type detected\n"); in cbb_insert()
571 sc->cardok = 0; in cbb_removal()
572 if (sc->flags & CBB_16BIT_CARD) { in cbb_removal()
573 exca_removal(&sc->exca); in cbb_removal()
575 if (device_is_attached(sc->cbdev)) in cbb_removal()
576 CARD_DETACH_CARD(sc->cbdev); in cbb_removal()
589 struct cbb_softc *sc = ih->sc; in cbb_func_filt()
594 if (!sc->cardok) in cbb_func_filt()
597 sc->cardok = 0; in cbb_func_filt()
601 return ((*ih->filt)(ih->arg)); in cbb_func_filt()
608 struct cbb_softc *sc = ih->sc; in cbb_func_intr()
623 if (ih->filt == NULL) { in cbb_func_intr()
624 if (!sc->cardok) in cbb_func_intr()
627 sc->cardok = 0; in cbb_func_intr()
632 ih->intr(ih->arg); in cbb_func_intr()
694 reg = exca_getb(&sc->exca, EXCA_INTR); in cbb_o2micro_power_hack()
695 exca_putb(&sc->exca, EXCA_INTR, (reg & 0xf0) | 1); in cbb_o2micro_power_hack()
707 exca_putb(&sc->exca, EXCA_INTR, reg); in cbb_o2micro_power_hack2()
752 DEVPRINTF((sc->dev, "cbb_power: %dV\n", volts)); in cbb_power()
753 if (volts != 0 && sc->chipset == CB_O2MICRO) in cbb_power()
761 * bit generally only affects 16-bit cards. Some bridges allow one to in cbb_power()
762 * set another bit to have it also affect 32-bit cards. Since 32-bit in cbb_power()
767 * EXCA CSC register for 16-bit cards, and disable the CD bit? in cbb_power()
777 mtx_lock(&sc->mtx); in cbb_power()
778 cnt = sc->powerintr; in cbb_power()
780 * We have a shortish timeout of 500ms here. Some bridges do in cbb_power()
781 * not generate a POWER_CYCLE event for 16-bit cards. In in cbb_power()
789 cnt == sc->powerintr && sane-- > 0) in cbb_power()
790 msleep(&sc->powerintr, &sc->mtx, 0, "-", hz / 20); in cbb_power()
791 mtx_unlock(&sc->mtx); in cbb_power()
794 * Relax for 100ms. Some bridges appear to assert this signal in cbb_power()
799 * "off" since we don't touch the card after we turn it off. in cbb_power()
805 * act together, so delay for an additional 100ms. Also as in cbb_power()
809 if (sc->chipset == CB_TOPIC95) in cbb_power()
812 device_printf(sc->dev, "power timeout, doom?\n"); in cbb_power()
831 if (on && sc->chipset != CB_TOPIC95) { in cbb_power()
833 device_printf(sc->dev, "Power not on?\n"); in cbb_power()
836 device_printf(sc->dev, "Bad Vcc requested\n"); in cbb_power()
851 if (sc->chipset == CB_TOPIC97) { in cbb_power()
852 reg_ctrl = pci_read_config(sc->dev, TOPIC_REG_CTRL, 4); in cbb_power()
858 pci_write_config(sc->dev, TOPIC_REG_CTRL, reg_ctrl, 4); in cbb_power()
862 if (volts != 0 && sc->chipset == CB_O2MICRO) in cbb_power()
890 * and what Windows does (and what Microsoft prefers). The MS paper
907 exca_clrb(&sc->exca, EXCA_PWRCTL, EXCA_PWRCTL_OE); in cbb_do_power()
943 * Asserting reset for 20ms is necessary for most bridges. For some in cbb_cardbus_reset_power()
944 * reason, the Ricoh RF5C47x bridges need it asserted for 400ms. The in cbb_cardbus_reset_power()
947 delay = sc->chipset == CB_RF5C47X ? 400 : 20; in cbb_cardbus_reset_power()
957 * followed. In PCI spec v2.2 Table 4-6, Trhfa (Reset High to first in cbb_cardbus_reset_power()
976 0xfffffffful && --count >= 0); in cbb_cardbus_reset_power()
978 device_printf(brdev, "Warning: Bus reset timeout\n"); in cbb_cardbus_reset_power()
983 * multi-function cards, but have nonsense for some of the in cbb_cardbus_reset_power()
1031 pause("cbbErr1", hz / 10); /* wait 100ms */ in cbb_cardbus_power_enable_socket()
1033 } while (err != 0 && count-- > 0); in cbb_cardbus_power_enable_socket()
1112 SLIST_FOREACH(rle, &sc->rl, link) { in cbb_cardbus_auto_open()
1113 if (rle->type != type) in cbb_cardbus_auto_open()
1115 if (rle->res == NULL) in cbb_cardbus_auto_open()
1117 if (!(rman_get_flags(rle->res) & RF_ACTIVE)) in cbb_cardbus_auto_open()
1119 if (rman_get_flags(rle->res) & RF_PREFETCHABLE) in cbb_cardbus_auto_open()
1123 if (rman_get_start(rle->res) < starts[i]) in cbb_cardbus_auto_open()
1124 starts[i] = rman_get_start(rle->res); in cbb_cardbus_auto_open()
1125 if (rman_get_end(rle->res) > ends[i]) in cbb_cardbus_auto_open()
1126 ends[i] = rman_get_end(rle->res); in cbb_cardbus_auto_open()
1131 starts[i] &= ~(align - 1); in cbb_cardbus_auto_open()
1132 ends[i] = roundup2(ends[i], align) - 1; in cbb_cardbus_auto_open()
1137 device_printf(sc->dev, "Overlapping ranges" in cbb_cardbus_auto_open()
1138 " for prefetch and non-prefetch memory\n"); in cbb_cardbus_auto_open()
1143 device_printf(sc->dev, "Overlapping ranges" in cbb_cardbus_auto_open()
1144 " for prefetch and non-prefetch memory\n"); in cbb_cardbus_auto_open()
1151 cbb_cardbus_mem_open(sc->dev, 0, starts[0], ends[0]); in cbb_cardbus_auto_open()
1152 cbb_cardbus_mem_open(sc->dev, 1, starts[1], ends[1]); in cbb_cardbus_auto_open()
1153 reg = pci_read_config(sc->dev, CBBR_BRIDGECTRL, 2); in cbb_cardbus_auto_open()
1158 pci_write_config(sc->dev, CBBR_BRIDGECTRL, reg, 2); in cbb_cardbus_auto_open()
1160 device_printf(sc->dev, "Opening memory:\n"); in cbb_cardbus_auto_open()
1162 device_printf(sc->dev, "Normal: %#x-%#x\n", in cbb_cardbus_auto_open()
1165 device_printf(sc->dev, "Prefetch: %#x-%#x\n", in cbb_cardbus_auto_open()
1169 cbb_cardbus_io_open(sc->dev, 0, starts[0], ends[0]); in cbb_cardbus_auto_open()
1170 cbb_cardbus_io_open(sc->dev, 1, starts[1], ends[1]); in cbb_cardbus_auto_open()
1172 device_printf(sc->dev, "Opening I/O: %#x-%#x\n", in cbb_cardbus_auto_open()
1216 tmp = rman_get_start(sc->irq_res); in cbb_cardbus_alloc_resource()
1218 device_printf(child, "requested interrupt %jd-%jd," in cbb_cardbus_alloc_resource()
1298 exca_reset(&sc->exca, child); in cbb_pcic_power_enable_socket()
1310 /* Turn off the card's interrupt and leave it in reset, wait 10ms */ in cbb_pcic_power_disable_socket()
1311 exca_putb(&sc->exca, EXCA_INTR, 0); in cbb_pcic_power_disable_socket()
1316 exca_putb(&sc->exca, EXCA_PWRCTL, 0); in cbb_pcic_power_disable_socket()
1318 /* wait 300ms until power fails (Tpf). */ in cbb_pcic_power_disable_socket()
1322 exca_putb(&sc->exca, EXCA_INTR, EXCA_INTR_ENABLE); in cbb_pcic_power_disable_socket()
1335 if (sc->flags & CBB_16BIT_CARD) in cbb_power_enable_socket()
1344 if (sc->flags & CBB_16BIT_CARD) in cbb_power_disable_socket()
1356 error = exca_activate_resource(&sc->exca, child, res); in cbb_pcic_activate_resource()
1367 return (exca_deactivate_resource(&sc->exca, child, res)); in cbb_pcic_deactivate_resource()
1400 tmp = rman_get_start(sc->irq_res); in cbb_pcic_alloc_resource()
1402 device_printf(child, "requested interrupt %jd-%jd," in cbb_pcic_alloc_resource()
1408 start = end = rman_get_start(sc->irq_res); in cbb_pcic_alloc_resource()
1462 return (exca_mem_set_flags(&sc->exca, res, flags)); in cbb_pcic_set_res_flags()
1478 return (exca_mem_set_offset(&sc->exca, res, cardaddr, deltap)); in cbb_pcic_set_memory_offset()
1490 if (sc->flags & CBB_16BIT_CARD) in cbb_activate_resource()
1501 if (sc->flags & CBB_16BIT_CARD) in cbb_deactivate_resource()
1513 if (sc->flags & CBB_16BIT_CARD) in cbb_alloc_resource()
1526 if (sc->flags & CBB_16BIT_CARD) in cbb_release_resource()
1539 *result = sc->domain; in cbb_read_ivar()
1542 *result = sc->bus.sec; in cbb_read_ivar()
1573 return (CBB_CARD_PRESENT(sockstate) && sc->cardok); in cbb_child_present()