Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/bhnd/bhnd.c
Show First 20 Lines • Show All 355 Lines • ▼ Show 20 Lines | bhnd_finish_attach(struct bhnd_softc *sc) | ||||
} | } | ||||
ccaps = BHND_CHIPC_GET_CAPS(sc->chipc_dev); | ccaps = BHND_CHIPC_GET_CAPS(sc->chipc_dev); | ||||
/* Look for NVRAM device */ | /* Look for NVRAM device */ | ||||
if (ccaps->nvram_src != BHND_NVRAM_SRC_UNKNOWN) { | if (ccaps->nvram_src != BHND_NVRAM_SRC_UNKNOWN) { | ||||
if ((sc->nvram_dev = bhnd_find_nvram(sc)) == NULL) { | if ((sc->nvram_dev = bhnd_find_nvram(sc)) == NULL) { | ||||
device_printf(sc->dev, | device_printf(sc->dev, | ||||
"warning: %s NVRAM device not found\n", | "warning: NVRAM %s device not found\n", | ||||
bhnd_nvram_src_name(ccaps->nvram_src)); | bhnd_nvram_src_name(ccaps->nvram_src)); | ||||
} | } | ||||
} | } | ||||
/* Look for a PMU */ | /* Look for a PMU */ | ||||
if (ccaps->pmu) { | if (ccaps->pmu) { | ||||
if ((sc->pmu_dev = bhnd_find_pmu(sc)) == NULL) { | if ((sc->pmu_dev = bhnd_find_pmu(sc)) == NULL) { | ||||
device_printf(sc->dev, | device_printf(sc->dev, | ||||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | bhnd_find_platform_dev(struct bhnd_softc *sc, const char *classname) | ||||
/* Look for the first matching ChipCommon child */ | /* Look for the first matching ChipCommon child */ | ||||
if ((chipc = bhnd_find_chipc(sc)) == NULL) { | if ((chipc = bhnd_find_chipc(sc)) == NULL) { | ||||
device_printf(sc->dev, | device_printf(sc->dev, | ||||
"chipc unavailable; cannot locate %s\n", classname); | "chipc unavailable; cannot locate %s\n", classname); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
child = device_find_child(chipc, classname, -1); | child = device_find_child(chipc, classname, -1); | ||||
if (child != NULL) | |||||
goto found; | |||||
/* Look for a parent-attached device (e.g. nexus0 -> bhnd_nvram) */ | |||||
child = device_find_child(device_get_parent(sc->dev), classname, -1); | |||||
if (child == NULL) | if (child == NULL) | ||||
return (NULL); | return (NULL); | ||||
found: | found: | ||||
if (device_get_state(child) < DS_ATTACHING) | if (device_get_state(child) < DS_ATTACHING) | ||||
return (NULL); | return (NULL); | ||||
return (child); | return (child); | ||||
▲ Show 20 Lines • Show All 176 Lines • ▼ Show 20 Lines | |||||
* | * | ||||
* This implementation searches @p dev for a usable NVRAM child device. | * This implementation searches @p dev for a usable NVRAM child device. | ||||
* | * | ||||
* If no usable child device is found on @p dev, the request is delegated to | * If no usable child device is found on @p dev, the request is delegated to | ||||
* the BHND_BUS_GET_NVRAM_VAR() method on the parent of @p dev. | * the BHND_BUS_GET_NVRAM_VAR() method on the parent of @p dev. | ||||
*/ | */ | ||||
int | int | ||||
bhnd_generic_get_nvram_var(device_t dev, device_t child, const char *name, | bhnd_generic_get_nvram_var(device_t dev, device_t child, const char *name, | ||||
void *buf, size_t *size) | void *buf, size_t *size, bhnd_nvram_type type) | ||||
{ | { | ||||
struct bhnd_softc *sc; | struct bhnd_softc *sc; | ||||
device_t nvram, parent; | device_t nvram, parent; | ||||
sc = device_get_softc(dev); | sc = device_get_softc(dev); | ||||
/* If a NVRAM device is available, consult it first */ | /* If a NVRAM device is available, consult it first */ | ||||
if ((nvram = bhnd_find_nvram(sc)) != NULL) | if ((nvram = bhnd_find_nvram(sc)) != NULL) | ||||
return BHND_NVRAM_GETVAR(nvram, name, buf, size); | return BHND_NVRAM_GETVAR(nvram, name, buf, size, type); | ||||
/* Otherwise, try to delegate to parent */ | /* Otherwise, try to delegate to parent */ | ||||
if ((parent = device_get_parent(dev)) == NULL) | if ((parent = device_get_parent(dev)) == NULL) | ||||
return (ENODEV); | return (ENODEV); | ||||
return (BHND_BUS_GET_NVRAM_VAR(device_get_parent(dev), child, | return (BHND_BUS_GET_NVRAM_VAR(device_get_parent(dev), child, | ||||
name, buf, size)); | name, buf, size, type)); | ||||
} | } | ||||
/** | /** | ||||
* Default bhnd(4) bus driver implementation of BUS_PRINT_CHILD(). | * Default bhnd(4) bus driver implementation of BUS_PRINT_CHILD(). | ||||
* | * | ||||
* This implementation requests the device's struct resource_list via | * This implementation requests the device's struct resource_list via | ||||
* BUS_GET_RESOURCE_LIST. | * BUS_GET_RESOURCE_LIST. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 384 Lines • Show Last 20 Lines |