Lines Matching +full:chip +full:- +full:relative
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
76 int mapped_rid; /**< resource ID of current mapping, or -1 */
80 * Fetch the device enumeration parser class from all bhnd(4)-compatible drivers
85 * bhnd(4)-compatible drivers.
89 * If the chipset supports standard chip
92 * @param[out] cid On success, the probed chip identifier.
94 * @retval non-NULL on success, the best available EROM class.
164 * @param cid The device's chip identifier.
166 * @retval non-NULL success
181 printf("error initializing %s parser at %#jx: %d\n", cls->name, in bhnd_erom_alloc()
182 (uintmax_t)cid->enum_addr, error); in bhnd_erom_alloc()
194 * This may be used to initialize a caller-allocated erom instance state
203 * @param cid The device's chip identifier.
209 * @retval non-zero if an error occurs initializing the EROM parser,
221 if (kcls->size > esize) in bhnd_erom_init_static()
257 * Read the chip identification registers mapped by @p eio, popuating @p cid
262 * @param[out] cid On success, the parsed chip identification.
282 /* Read chip identifier */ in bhnd_erom_read_chipid()
285 /* Extract the basic chip info */ in bhnd_erom_read_chipid()
286 cid->chip_id = CHIPC_GET_BITS(idreg, CHIPC_ID_CHIP); in bhnd_erom_read_chipid()
287 cid->chip_pkg = CHIPC_GET_BITS(idreg, CHIPC_ID_PKG); in bhnd_erom_read_chipid()
288 cid->chip_rev = CHIPC_GET_BITS(idreg, CHIPC_ID_REV); in bhnd_erom_read_chipid()
289 cid->chip_type = CHIPC_GET_BITS(idreg, CHIPC_ID_BUS); in bhnd_erom_read_chipid()
290 cid->ncores = CHIPC_GET_BITS(idreg, CHIPC_ID_NUMCORE); in bhnd_erom_read_chipid()
293 if (BHND_CHIPTYPE_HAS_EROM(cid->chip_type)) { in bhnd_erom_read_chipid()
294 cid->enum_addr = bhnd_erom_io_read(eio, CHIPC_EROMPTR, 4); in bhnd_erom_read_chipid()
296 cid->enum_addr = cc_addr; in bhnd_erom_read_chipid()
301 cid->chip_caps = 0x0; in bhnd_erom_read_chipid()
304 cid->chip_caps |= BHND_CAP_BP64; in bhnd_erom_read_chipid()
307 cid->chip_caps |= BHND_CAP_PMU; in bhnd_erom_read_chipid()
321 * @retval non-zero if mapping @p addr otherwise fails, a regular
327 return (eio->map(eio, addr, size)); in bhnd_erom_io_map()
344 return (eio->tell(eio, addr, size)); in bhnd_erom_io_tell()
349 * relative to @p eio's current mapping.
358 return (eio->read(eio, offset, width)); in bhnd_erom_io_read()
367 if (eio->fini != NULL) in bhnd_erom_io_fini()
368 return (eio->fini(eio)); in bhnd_erom_io_fini()
385 iores->eio.map = bhnd_erom_iores_map; in bhnd_erom_iores_new()
386 iores->eio.tell = bhnd_erom_iores_tell; in bhnd_erom_iores_new()
387 iores->eio.read = bhnd_erom_iores_read; in bhnd_erom_iores_new()
388 iores->eio.fini = bhnd_erom_iores_fini; in bhnd_erom_iores_new()
390 iores->owner = dev; in bhnd_erom_iores_new()
391 iores->owner_rid = rid; in bhnd_erom_iores_new()
392 iores->mapped = NULL; in bhnd_erom_iores_new()
393 iores->mapped_rid = -1; in bhnd_erom_iores_new()
395 return (&iores->eio); in bhnd_erom_iores_new()
410 if (BHND_ADDR_MAX - size < addr) in bhnd_erom_iores_map()
414 if (iores->mapped) { in bhnd_erom_iores_map()
416 if (rman_get_start(iores->mapped->res) == addr && in bhnd_erom_iores_map()
417 rman_get_size(iores->mapped->res) == size) in bhnd_erom_iores_map()
423 bhnd_release_resource(iores->owner, SYS_RES_MEMORY, in bhnd_erom_iores_map()
424 iores->mapped_rid, iores->mapped); in bhnd_erom_iores_map()
425 iores->mapped = NULL; in bhnd_erom_iores_map()
426 iores->mapped_rid = -1; in bhnd_erom_iores_map()
430 iores->mapped_rid = iores->owner_rid; in bhnd_erom_iores_map()
431 iores->mapped = bhnd_alloc_resource(iores->owner, SYS_RES_MEMORY, in bhnd_erom_iores_map()
432 &iores->mapped_rid, addr, addr+size-1, size, in bhnd_erom_iores_map()
434 if (iores->mapped == NULL) { in bhnd_erom_iores_map()
435 iores->mapped_rid = -1; in bhnd_erom_iores_map()
448 if (iores->mapped == NULL) in bhnd_erom_iores_tell()
451 *addr = rman_get_start(iores->mapped->res); in bhnd_erom_iores_tell()
452 *size = rman_get_size(iores->mapped->res); in bhnd_erom_iores_tell()
462 if (iores->mapped == NULL) in bhnd_erom_iores_read()
467 return (bhnd_bus_read_1(iores->mapped, offset)); in bhnd_erom_iores_read()
469 return (bhnd_bus_read_2(iores->mapped, offset)); in bhnd_erom_iores_read()
471 return (bhnd_bus_read_4(iores->mapped, offset)); in bhnd_erom_iores_read()
483 if (iores->mapped) { in bhnd_erom_iores_fini()
484 bhnd_release_resource(iores->owner, SYS_RES_MEMORY, in bhnd_erom_iores_fini()
485 iores->mapped_rid, iores->mapped); in bhnd_erom_iores_fini()
486 iores->mapped = NULL; in bhnd_erom_iores_fini()
487 iores->mapped_rid = -1; in bhnd_erom_iores_fini()
504 * @retval non-zero if initializing @p iobus otherwise fails, a regular
511 iobus->eio.map = bhnd_erom_iobus_map; in bhnd_erom_iobus_init()
512 iobus->eio.tell = bhnd_erom_iobus_tell; in bhnd_erom_iobus_init()
513 iobus->eio.read = bhnd_erom_iobus_read; in bhnd_erom_iobus_init()
514 iobus->eio.fini = NULL; in bhnd_erom_iobus_init()
516 iobus->addr = addr; in bhnd_erom_iobus_init()
517 iobus->size = size; in bhnd_erom_iobus_init()
518 iobus->bst = bst; in bhnd_erom_iobus_init()
519 iobus->bsh = bsh; in bhnd_erom_iobus_init()
520 iobus->mapped = false; in bhnd_erom_iobus_init()
536 if (BHND_ADDR_MAX - size < addr) in bhnd_erom_iobus_map()
540 if (addr < iobus->addr || size > iobus->size) in bhnd_erom_iobus_map()
543 if (iobus->size - (addr - iobus->addr) < size) in bhnd_erom_iobus_map()
547 if ((addr - iobus->addr) > BUS_SPACE_MAXSIZE) in bhnd_erom_iobus_map()
553 iobus->offset = addr - iobus->addr; in bhnd_erom_iobus_map()
554 iobus->limit = size; in bhnd_erom_iobus_map()
555 iobus->mapped = true; in bhnd_erom_iobus_map()
566 if (!iobus->mapped) in bhnd_erom_iobus_tell()
569 *addr = iobus->addr + iobus->offset; in bhnd_erom_iobus_tell()
570 *size = iobus->limit; in bhnd_erom_iobus_tell()
580 if (!iobus->mapped) in bhnd_erom_iobus_read()
583 if (iobus->limit < width || iobus->limit - width < offset) in bhnd_erom_iobus_read()
588 return (bus_space_read_1(iobus->bst, iobus->bsh, in bhnd_erom_iobus_read()
589 iobus->offset + offset)); in bhnd_erom_iobus_read()
591 return (bus_space_read_2(iobus->bst, iobus->bsh, in bhnd_erom_iobus_read()
592 iobus->offset + offset)); in bhnd_erom_iobus_read()
594 return (bus_space_read_4(iobus->bst, iobus->bsh, in bhnd_erom_iobus_read()
595 iobus->offset + offset)); in bhnd_erom_iobus_read()