Lines Matching +full:sdio +full:- +full:attached
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2015-2016 Landon Fuller <landon@landonf.org>
105 BHND_CDESC(BCM, SDIOH, OTHER, "SDIO Host Controller"),
115 BHND_CDESC(BCM, ARM7S, CPU, "ARM7TDMI-S CPU"),
118 BHND_CDESC(BCM, SSNPHY, WLAN_PHY, "802.11n Single-Stream PHY"),
119 BHND_CDESC(BCM, SDIOD, OTHER, "SDIO Device Core"),
120 BHND_CDESC(BCM, ARMCM3, CPU, "ARM Cortex-M3 CPU"),
144 BHND_CDESC(BCM, NS_SDIO, OTHER, "SDIO 3.0 Host Controller"),
176 * Device table entries for core-specific CLKCTL quirk lookup.
203 * @param vendor A JEP106 Manufacturer ID, including the non-standard ARM 4-bit
280 * Return a human-readable name for a BHND core.
282 * @param vendor The core designer's JEDEC-106 Manufacturer ID.
293 return desc->desc; in bhnd_find_core_name()
299 * @param vendor The core designer's JEDEC-106 Manufacturer ID.
310 return desc->class; in bhnd_find_core_class()
314 * Return a human-readable name for a BHND core.
321 return bhnd_find_core_name(ci->vendor, ci->device); in bhnd_core_name()
332 return bhnd_find_core_class(ci->vendor, ci->device); in bhnd_core_class()
344 * failure. No more than @p size-1 characters be written, with the @p size'th
352 /* All hex formatted IDs are within the range of 0x4000-0x9C3F (40000-1) */ in bhnd_format_chip_id()
360 * Return a core info record populated from a bhnd-attached @p dev.
380 * @param bus The bhnd-compatible bus to be searched.
382 * @param unit The core unit number; specify -1 to return the first match
396 if (unit == -1) in bhnd_bus_find_child()
405 * @param bus The bhnd-compatible bus to be searched.
446 * @param bus The bhnd-compatible bus to be queried.
453 * @retval non-zero if an error occurs, a regular unix error code will
487 * Perform in-place sorting of an array of bhnd device instances.
533 return (-1); in compare_ascending_probe_order()
554 * @param bus The bhnd-compatible bus for which all children should be probed
555 * and attached.
583 * to which the bhndb bridge is attached.
590 * should be attached.
593 * @retval NULL if @p dev is not attached via a bhndb bus.
594 * @retval NULL if no parent device is attached via @p bus_class.
619 /* Search for a parent attached to the expected bus class */ in bhnd_find_bridge_root()
661 * @retval non-NULL if a matching core is found.
686 BHND_MATCH_CORE_VENDOR(core->vendor), in bhnd_core_get_match_desc()
687 BHND_MATCH_CORE_ID(core->device), in bhnd_core_get_match_desc()
688 BHND_MATCH_CORE_REV(HWREV_EQ(core->hwrev)), in bhnd_core_get_match_desc()
690 BHND_MATCH_CORE_IDX(core->core_idx), in bhnd_core_get_match_desc()
691 BHND_MATCH_CORE_UNIT(core->unit) in bhnd_core_get_match_desc()
728 if (desc->m.match.core_vendor && desc->core_vendor != core->vendor) in bhnd_core_matches()
731 if (desc->m.match.core_id && desc->core_id != core->device) in bhnd_core_matches()
734 if (desc->m.match.core_unit && desc->core_unit != core->unit) in bhnd_core_matches()
737 if (desc->m.match.core_rev && in bhnd_core_matches()
738 !bhnd_hwrev_matches(core->hwrev, &desc->core_rev)) in bhnd_core_matches()
741 if (desc->m.match.core_idx && desc->core_idx != core->core_idx) in bhnd_core_matches()
744 if (desc->m.match.core_class && in bhnd_core_matches()
745 desc->core_class != bhnd_core_class(core)) in bhnd_core_matches()
764 if (desc->m.match.chip_id && chip->chip_id != desc->chip_id) in bhnd_chip_matches()
767 if (desc->m.match.chip_pkg && chip->chip_pkg != desc->chip_pkg) in bhnd_chip_matches()
770 if (desc->m.match.chip_rev && in bhnd_chip_matches()
771 !bhnd_hwrev_matches(chip->chip_rev, &desc->chip_rev)) in bhnd_chip_matches()
774 if (desc->m.match.chip_type && chip->chip_type != desc->chip_type) in bhnd_chip_matches()
793 if (desc->m.match.board_srom_rev && in bhnd_board_matches()
794 !bhnd_hwrev_matches(board->board_srom_rev, &desc->board_srom_rev)) in bhnd_board_matches()
797 if (desc->m.match.board_vendor && in bhnd_board_matches()
798 board->board_vendor != desc->board_vendor) in bhnd_board_matches()
801 if (desc->m.match.board_type && board->board_type != desc->board_type) in bhnd_board_matches()
804 if (desc->m.match.board_devid && in bhnd_board_matches()
805 board->board_devid != desc->board_devid) in bhnd_board_matches()
808 if (desc->m.match.board_rev && in bhnd_board_matches()
809 !bhnd_hwrev_matches(board->board_rev, &desc->board_rev)) in bhnd_board_matches()
827 if (desc->start != BHND_HWREV_INVALID && in bhnd_hwrev_matches()
828 desc->start > hwrev) in bhnd_hwrev_matches()
831 if (desc->end != BHND_HWREV_INVALID && in bhnd_hwrev_matches()
832 desc->end < hwrev) in bhnd_hwrev_matches()
863 /* Only applicable to bhnd-attached cores */ in bhnd_device_matches()
867 "attributes against non-core device\n"); in bhnd_device_matches()
910 * @retval non-NULL the first matching device, if any.
930 if (!bhnd_device_matches(dev, &entry->core)) in bhnd_device_lookup()
934 dflags = entry->device_flags; in bhnd_device_lookup()
982 qtable = dent->quirks_table; in bhnd_device_quirks()
989 if (bhnd_device_matches(dev, &qent->desc)) in bhnd_device_quirks()
990 quirks |= qent->quirks; in bhnd_device_quirks()
1005 * @retval non-zero if allocation of any non-RF_OPTIONAL resource fails,
1014 for (u_int i = 0; rs[i].type != -1; i++) in bhnd_alloc_resources()
1017 for (u_int i = 0; rs[i].type != -1; i++) { in bhnd_alloc_resources()
1043 for (u_int i = 0; rs[i].type != -1; i++) { in bhnd_release_resources()
1053 * Allocate and return a new per-core PMU clock control/status (clkctl)
1067 * microseconds; this upper bound will be used to busy-wait
1070 * @retval non-NULL success
1084 clkctl->cc_dev = dev; in bhnd_alloc_core_clkctl()
1085 clkctl->cc_pmu_dev = pmu_dev; in bhnd_alloc_core_clkctl()
1086 clkctl->cc_res = r; in bhnd_alloc_core_clkctl()
1087 clkctl->cc_res_offset = offset; in bhnd_alloc_core_clkctl()
1088 clkctl->cc_max_latency = max_latency; in bhnd_alloc_core_clkctl()
1089 clkctl->cc_quirks = bhnd_device_quirks(dev, bhnd_clkctl_devices, in bhnd_alloc_core_clkctl()
1111 * Wait for the per-core clock status to be equal to @p value after
1114 * @param clkctl Per-core clkctl state to be queryied.
1130 /* Bitswapped HTAVAIL/ALPAVAIL work-around */ in bhnd_core_clkctl_wait()
1131 if (clkctl->cc_quirks & BHND_CLKCTL_QUIRK_CCS0) { in bhnd_core_clkctl_wait()
1151 for (u_int i = 0; i < clkctl->cc_max_latency; i += 10) { in bhnd_core_clkctl_wait()
1152 clkst = bhnd_bus_read_4(clkctl->cc_res, clkctl->cc_res_offset); in bhnd_core_clkctl_wait()
1159 device_printf(clkctl->cc_dev, "clkst wait timeout (value=%#x, " in bhnd_core_clkctl_wait()
1166 * Read an NVRAM variable's NUL-terminated string value.
1171 * success, the NUL-terminated string value will be
1182 * @retval ENOMEM If @p buf is non-NULL and a buffer of @p len is too
1187 * @retval non-zero If reading @p name otherwise fails, a regular unix
1223 * @retval non-zero If reading @p name otherwise fails, a regular unix
1253 * Read an NVRAM variable's unsigned 8-bit integer value.
1266 * @retval non-zero If reading @p name otherwise fails, a regular unix
1276 * Read an NVRAM variable's unsigned 16-bit integer value.
1290 * @retval non-zero If reading @p name otherwise fails, a regular unix
1300 * Read an NVRAM variable's unsigned 32-bit integer value.
1314 * @retval non-zero If reading @p name otherwise fails, a regular unix
1340 * @retval non-zero If reading @p name otherwise fails, a regular unix
1370 * Read an NVRAM variable's signed 8-bit integer value.
1383 * @retval non-zero If reading @p name otherwise fails, a regular unix
1393 * Read an NVRAM variable's signed 16-bit integer value.
1407 * @retval non-zero If reading @p name otherwise fails, a regular unix
1417 * Read an NVRAM variable's signed 32-bit integer value.
1431 * @retval non-zero If reading @p name otherwise fails, a regular unix
1462 * @retval non-zero If reading @p name otherwise fails, a regular unix
1490 * @retval non-zero if an error occurs initializing the service registry,
1497 STAILQ_INIT(&bsr->entries); in bhnd_service_registry_init()
1498 mtx_init(&bsr->lock, "bhnd_service_registry lock", NULL, MTX_DEF); in bhnd_service_registry_init()
1519 mtx_lock(&bsr->lock); in bhnd_service_registry_fini()
1520 STAILQ_FOREACH_SAFE(entry, &bsr->entries, link, enext) { in bhnd_service_registry_fini()
1521 if (entry->refs > 0) in bhnd_service_registry_fini()
1524 STAILQ_REMOVE(&bsr->entries, entry, bhnd_service_entry, link); in bhnd_service_registry_fini()
1528 if (!STAILQ_EMPTY(&bsr->entries)) { in bhnd_service_registry_fini()
1529 mtx_unlock(&bsr->lock); in bhnd_service_registry_fini()
1532 mtx_unlock(&bsr->lock); in bhnd_service_registry_fini()
1534 mtx_destroy(&bsr->lock); in bhnd_service_registry_fini()
1549 * @retval non-zero if registering @p provider otherwise fails, a regular
1561 mtx_lock(&bsr->lock); in bhnd_service_registry_add()
1564 STAILQ_FOREACH(entry, &bsr->entries, link) { in bhnd_service_registry_add()
1565 if (entry->service == service) { in bhnd_service_registry_add()
1566 mtx_unlock(&bsr->lock); in bhnd_service_registry_add()
1574 mtx_unlock(&bsr->lock); in bhnd_service_registry_add()
1578 entry->provider = provider; in bhnd_service_registry_add()
1579 entry->service = service; in bhnd_service_registry_add()
1580 entry->flags = flags; in bhnd_service_registry_add()
1581 refcount_init(&entry->refs, 0); in bhnd_service_registry_add()
1583 STAILQ_INSERT_HEAD(&bsr->entries, entry, link); in bhnd_service_registry_add()
1585 mtx_unlock(&bsr->lock); in bhnd_service_registry_add()
1597 KASSERT(entry->refs == 0, ("provider has active references")); in bhnd_service_registry_free_entry()
1621 mtx_lock(&bsr->lock); in bhnd_service_registry_remove()
1624 ((_e)->provider == provider && \ in bhnd_service_registry_remove()
1625 (service == BHND_SERVICE_ANY || (_e)->service == service)) in bhnd_service_registry_remove()
1629 STAILQ_FOREACH(entry, &bsr->entries, link) { in bhnd_service_registry_remove()
1630 /* Skip non-matching entries */ in bhnd_service_registry_remove()
1635 if (entry->refs > 0) { in bhnd_service_registry_remove()
1636 mtx_unlock(&bsr->lock); in bhnd_service_registry_remove()
1642 STAILQ_FOREACH_SAFE(entry, &bsr->entries, link, enext) { in bhnd_service_registry_remove()
1643 /* Skip non-matching entries */ in bhnd_service_registry_remove()
1648 STAILQ_REMOVE(&bsr->entries, entry, bhnd_service_entry, link); in bhnd_service_registry_remove()
1655 mtx_unlock(&bsr->lock); in bhnd_service_registry_remove()
1678 mtx_lock(&bsr->lock); in bhnd_service_registry_retain()
1679 STAILQ_FOREACH(entry, &bsr->entries, link) { in bhnd_service_registry_retain()
1680 if (entry->service != service) in bhnd_service_registry_retain()
1685 refcount_acquire(&entry->refs); in bhnd_service_registry_retain()
1687 mtx_unlock(&bsr->lock); in bhnd_service_registry_retain()
1688 return (entry->provider); in bhnd_service_registry_retain()
1690 mtx_unlock(&bsr->lock); in bhnd_service_registry_retain()
1725 mtx_lock(&bsr->lock); in bhnd_service_registry_release()
1726 STAILQ_FOREACH(entry, &bsr->entries, link) { in bhnd_service_registry_release()
1729 if (entry->provider != provider) in bhnd_service_registry_release()
1732 if (entry->service != service) in bhnd_service_registry_release()
1735 if (refcount_release(&entry->refs) && in bhnd_service_registry_release()
1736 (entry->flags & BHND_SPF_INHERITED)) in bhnd_service_registry_release()
1741 STAILQ_REMOVE(&bsr->entries, entry, bhnd_service_entry, in bhnd_service_registry_release()
1749 mtx_unlock(&bsr->lock); in bhnd_service_registry_release()
1758 * Using the bhnd(4) bus-level core information and a custom core name,
1761 * @param dev A bhnd-bus attached device.
1762 * @param dev_name The core's name (e.g. "SDIO Device Core").
1775 * Using the bhnd(4) bus-level core information, populate @p dev's device
1778 * @param dev A bhnd-bus attached device.
1790 * @param dev A bhnd-bus attached device.
1800 switch (chip_id->chip_type) { in bhnd_set_default_bus_desc()
1818 chip_id->chip_id); in bhnd_set_default_bus_desc()
2137 OPT_BHND_GV(info->board_vendor, BOARDVENDOR, 0); in bhnd_bus_generic_read_board_info()
2138 OPT_BHND_GV(info->board_type, BOARDTYPE, 0); /* srom >= 2 */ in bhnd_bus_generic_read_board_info()
2139 OPT_BHND_GV(info->board_devid, DEVID, 0); /* srom >= 8 */ in bhnd_bus_generic_read_board_info()
2140 REQ_BHND_GV(info->board_rev, BOARDREV); in bhnd_bus_generic_read_board_info()
2141 OPT_BHND_GV(info->board_srom_rev,SROMREV, 0); /* missing in in bhnd_bus_generic_read_board_info()
2144 REQ_BHND_GV(info->board_flags, BOARDFLAGS); in bhnd_bus_generic_read_board_info()
2145 OPT_BHND_GV(info->board_flags2, BOARDFLAGS2, 0); /* srom >= 4 */ in bhnd_bus_generic_read_board_info()
2146 OPT_BHND_GV(info->board_flags3, BOARDFLAGS3, 0); /* srom >= 11 */ in bhnd_bus_generic_read_board_info()
2172 /* Look for a directly-attached NVRAM child */ in bhnd_bus_generic_get_nvram_var()
2214 br->direct = false; in bhnd_bus_generic_alloc_resource()
2215 br->res = res; in bhnd_bus_generic_alloc_resource()
2246 if ((error = BUS_RELEASE_RESOURCE(dev, child, r->res))) in bhnd_bus_generic_release_resource()
2261 * direct use of the bhnd(4) resource APIs on devices that may not be attached
2285 error = bus_activate_resource(child, type, rid, r->res); in bhnd_bus_generic_activate_resource()
2287 r->direct = true; in bhnd_bus_generic_activate_resource()