FreeBSD/sys/dev/bhnd/cores/chipc/chipc.c
/**
 * Determine the NVRAM data source for this device.
 * 
 * The SPROM, OTP, and flash capability flags must be fully populated in
 * @p caps.
 *
 * @param sc chipc driver state.
 * @param caps capability flags to be used to derive NVRAM configuration.
 */
Determine the NVRAM data source for this device.

The SPROM, OTP, and flash capability flags must be fully populated in
@p caps.

@param sc chipc driver state.
@param caps capability flags to be used to derive NVRAM configuration.
Determine the NVRAM data source for this device . The SPROM OTP and flash capability flags must be fully populated in @p caps . @param sc chipc driver state . @param caps capability flags to be used to derive NVRAM configuration .
static bhnd_nvram_src
chipc_find_nvram_src(struct chipc_softc *sc, struct chipc_caps *caps)
{
	uint32_t		 otp_st, srom_ctrl;
	if (!CHIPC_QUIRK(sc, SUPPORTS_SPROM))
		return (BHND_NVRAM_SRC_UNKNOWN);
	if (caps->sprom) {
		srom_ctrl = bhnd_bus_read_4(sc->core, CHIPC_SPROM_CTRL);
		if (srom_ctrl & CHIPC_SRC_PRESENT)
			return (BHND_NVRAM_SRC_SPROM);
	}
	if (CHIPC_QUIRK(sc, SUPPORTS_OTP) && caps->otp_size > 0) {
		if (!CHIPC_QUIRK(sc, OTP_HND)) {
			device_printf(sc->dev,
			    "NVRAM unavailable: unsupported OTP controller.\n");
			return (BHND_NVRAM_SRC_UNKNOWN);
		}
		otp_st = bhnd_bus_read_4(sc->core, CHIPC_OTPST);
		if (otp_st & CHIPC_OTPS_GUP_HW)
			return (BHND_NVRAM_SRC_OTP);
	}
	if (caps->flash_type != CHIPC_FLASH_NONE)
		return (BHND_NVRAM_SRC_FLASH);
	return (BHND_NVRAM_SRC_UNKNOWN);
}
static bhnd_nvram_src chipc_find_nvram_src ( struct chipc_softc * sc , struct chipc_caps * caps ) { uint32_t otp_st , srom_ctrl ; if ( ! CHIPC_QUIRK ( sc , SUPPORTS_SPROM ) ) return ( BHND_NVRAM_SRC_UNKNOWN ) ; if ( caps -> sprom ) { srom_ctrl = bhnd_bus_read_4 ( sc -> core , CHIPC_SPROM_CTRL ) ; if ( srom_ctrl & CHIPC_SRC_PRESENT ) return ( BHND_NVRAM_SRC_SPROM ) ; } if ( CHIPC_QUIRK ( sc , SUPPORTS_OTP ) && caps -> otp_size > 0 ) { if ( ! CHIPC_QUIRK ( sc , OTP_HND ) ) { device_printf ( sc -> dev , " \n " ) ; return ( BHND_NVRAM_SRC_UNKNOWN ) ; } otp_st = bhnd_bus_read_4 ( sc -> core , CHIPC_OTPST ) ; if ( otp_st & CHIPC_OTPS_GUP_HW ) return ( BHND_NVRAM_SRC_OTP ) ; } if ( caps -> flash_type != CHIPC_FLASH_NONE ) return ( BHND_NVRAM_SRC_FLASH ) ; return ( BHND_NVRAM_SRC_UNKNOWN ) ; }
Determine the NVRAM data source for this device.
Determine the NVRAM data source for this device .
/* Very early devices vend SPROM/OTP/CIS (if at all) via the
	 * host bridge interface instead of ChipCommon. */ /*
	 * Later chipset revisions standardized the SPROM capability flags and
	 * register interfaces.
	 * 
	 * We check for hardware presence in order of precedence. For example,
	 * SPROM is is always used in preference to internal OTP if found.
	 */ /* Check for programmed OTP H/W subregion (contains SROM data) */ /* TODO: need access to HND-OTP device */ /* Check for flash */ /* No NVRAM hardware capability declared */