FreeBSD/sys/dev/bhnd/bhndb/bhndb.c
/**
 * Read the ChipCommon identification data for this device.
 * 
 * @param sc bhndb device state.
 * @param cfg The hardware configuration to use when mapping the ChipCommon
 * registers.
 * @param[out] result the chip identification data.
 * 
 * @retval 0 success
 * @retval non-zero if the ChipCommon identification data could not be read.
 */
Read the ChipCommon identification data for this device.

@param sc bhndb device state.
@param cfg The hardware configuration to use when mapping the ChipCommon
registers.
@param[out] result the chip identification data.

@retval 0 success
@retval non-zero if the ChipCommon identification data could not be read.
Read the ChipCommon identification data for this device . @param sc bhndb device state . @param cfg The hardware configuration to use when mapping the ChipCommon registers . @param [ out ] result the chip identification data . @retval 0 success @retval non - zero if the ChipCommon identification data could not be read .
static int
bhndb_read_chipid(struct bhndb_softc *sc, const struct bhndb_hwcfg *cfg,
    struct bhnd_chipid *result)
{
	const struct bhnd_chipid	*parent_cid;
	const struct bhndb_regwin	*cc_win;
	struct resource_spec		 rs;
	int				 error;
	parent_cid = BHNDB_BUS_GET_CHIPID(sc->parent_dev, sc->dev);
	if (parent_cid != NULL) {
		*result = *parent_cid;
		return (0);
	}
	cc_win = bhndb_regwin_find_best(cfg->register_windows,
	    BHND_DEVCLASS_CC, 0, BHND_PORT_DEVICE, 0, 0, CHIPC_CHIPID_SIZE);
	if (cc_win == NULL) {
		device_printf(sc->dev, "no chipcommon register window\n");
		return (0);
	}
	if (cc_win->win_type == BHNDB_REGWIN_T_DYN) {
		error = BHNDB_SET_WINDOW_ADDR(sc->dev, cc_win,
		    BHND_DEFAULT_CHIPC_ADDR);
		if (error) {
			device_printf(sc->dev, "failed to set chipcommon "
			    "register window\n");
			return (error);
		}
	}
	rs.type = cc_win->res.type;
	rs.rid = cc_win->res.rid;
	rs.flags = RF_ACTIVE;
	return (bhnd_read_chipid(sc->parent_dev, &rs, cc_win->win_offset,
	    result));
}
static int bhndb_read_chipid ( struct bhndb_softc * sc , const struct bhndb_hwcfg * cfg , struct bhnd_chipid * result ) { const struct bhnd_chipid * parent_cid ; const struct bhndb_regwin * cc_win ; struct resource_spec rs ; int error ; parent_cid = BHNDB_BUS_GET_CHIPID ( sc -> parent_dev , sc -> dev ) ; if ( parent_cid != NULL ) { * result = * parent_cid ; return ( 0 ) ; } cc_win = bhndb_regwin_find_best ( cfg -> register_windows , BHND_DEVCLASS_CC , 0 , BHND_PORT_DEVICE , 0 , 0 , CHIPC_CHIPID_SIZE ) ; if ( cc_win == NULL ) { device_printf ( sc -> dev , " \n " ) ; return ( 0 ) ; } if ( cc_win -> win_type == BHNDB_REGWIN_T_DYN ) { error = BHNDB_SET_WINDOW_ADDR ( sc -> dev , cc_win , BHND_DEFAULT_CHIPC_ADDR ) ; if ( error ) { device_printf ( sc -> dev , " " " \n " ) ; return ( error ) ; } } rs . type = cc_win -> res . type ; rs . rid = cc_win -> res . rid ; rs . flags = RF_ACTIVE ; return ( bhnd_read_chipid ( sc -> parent_dev , & rs , cc_win -> win_offset , result ) ) ; }
Read the ChipCommon identification data for this device.
Read the ChipCommon identification data for this device .
/* Let our parent device override the discovery process */ /* Find a register window we can use to map the first CHIPC_CHIPID_SIZE
	 * of ChipCommon registers. */ /* We can assume a device without a static ChipCommon window uses the
	 * default ChipCommon address. */ /* Let the default bhnd implemenation alloc/release the resource and
	 * perform the read */