Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/bhnd/bhnd.h
Show First 20 Lines • Show All 411 Lines • ▼ Show 20 Lines | |||||
* @param dev A bhnd bus child device. | * @param dev A bhnd bus child device. | ||||
*/ | */ | ||||
static inline const struct bhnd_chipid * | static inline const struct bhnd_chipid * | ||||
bhnd_get_chipid(device_t dev) { | bhnd_get_chipid(device_t dev) { | ||||
return (BHND_BUS_GET_CHIPID(device_get_parent(dev), dev)); | return (BHND_BUS_GET_CHIPID(device_get_parent(dev), dev)); | ||||
}; | }; | ||||
/** | /** | ||||
* If supported by the chipset, return the clock source for the given clock. | |||||
* | |||||
* This function is only supported on early PWRCTL-equipped chipsets | |||||
* that expose clock management via their host bridge interface. Currently, | |||||
* this includes PCI (not PCIe) devices, with ChipCommon core revisions 0-9. | |||||
* | |||||
* @param dev A bhnd bus child device. | |||||
* @param clock The clock for which a clock source will be returned. | |||||
* | |||||
* @retval bhnd_clksrc The clock source for @p clock. | |||||
* @retval BHND_CLKSRC_UNKNOWN If @p clock is unsupported, or its | |||||
* clock source is not known to the bus. | |||||
*/ | |||||
static inline bhnd_clksrc | |||||
bhnd_pwrctl_get_clksrc(device_t dev, bhnd_clock clock) | |||||
{ | |||||
return (BHND_BUS_PWRCTL_GET_CLKSRC(device_get_parent(dev), dev, clock)); | |||||
} | |||||
/** | |||||
* If supported by the chipset, gate @p clock | |||||
* | |||||
* This function is only supported on early PWRCTL-equipped chipsets | |||||
* that expose clock management via their host bridge interface. Currently, | |||||
* this includes PCI (not PCIe) devices, with ChipCommon core revisions 0-9. | |||||
* | |||||
* @param dev A bhnd bus child device. | |||||
* @param clock The clock to be disabled. | |||||
* | |||||
* @retval 0 success | |||||
* @retval ENODEV If bus-level clock source management is not supported. | |||||
* @retval ENXIO If bus-level management of @p clock is not supported. | |||||
*/ | |||||
static inline int | |||||
bhnd_pwrctl_gate_clock(device_t dev, bhnd_clock clock) | |||||
{ | |||||
return (BHND_BUS_PWRCTL_GATE_CLOCK(device_get_parent(dev), dev, clock)); | |||||
} | |||||
/** | |||||
* If supported by the chipset, ungate @p clock | |||||
* | |||||
* This function is only supported on early PWRCTL-equipped chipsets | |||||
* that expose clock management via their host bridge interface. Currently, | |||||
* this includes PCI (not PCIe) devices, with ChipCommon core revisions 0-9. | |||||
* | |||||
* @param dev A bhnd bus child device. | |||||
* @param clock The clock to be enabled. | |||||
* | |||||
* @retval 0 success | |||||
* @retval ENODEV If bus-level clock source management is not supported. | |||||
* @retval ENXIO If bus-level management of @p clock is not supported. | |||||
*/ | |||||
static inline int | |||||
bhnd_pwrctl_ungate_clock(device_t dev, bhnd_clock clock) | |||||
{ | |||||
return (BHND_BUS_PWRCTL_UNGATE_CLOCK(device_get_parent(dev), dev, | |||||
clock)); | |||||
} | |||||
/** | |||||
* Return the BHND attachment type of the parent bhnd bus. | * Return the BHND attachment type of the parent bhnd bus. | ||||
* | * | ||||
* @param dev A bhnd bus child device. | * @param dev A bhnd bus child device. | ||||
* | * | ||||
* @retval BHND_ATTACH_ADAPTER if the bus is resident on a bridged adapter, | * @retval BHND_ATTACH_ADAPTER if the bus is resident on a bridged adapter, | ||||
* such as a WiFi chipset. | * such as a WiFi chipset. | ||||
* @retval BHND_ATTACH_NATIVE if the bus provides hardware services (clock, | * @retval BHND_ATTACH_NATIVE if the bus provides hardware services (clock, | ||||
* CPU, etc) to a directly attached native host. | * CPU, etc) to a directly attached native host. | ||||
Show All 18 Lines | |||||
* @retval ENODEV No valid NVRAM source could be found. | * @retval ENODEV No valid NVRAM source could be found. | ||||
* @retval non-zero If reading @p name otherwise fails, a regular unix | * @retval non-zero If reading @p name otherwise fails, a regular unix | ||||
* error code will be returned. | * error code will be returned. | ||||
*/ | */ | ||||
static inline int | static inline int | ||||
bhnd_read_board_info(device_t dev, struct bhnd_board_info *info) | bhnd_read_board_info(device_t dev, struct bhnd_board_info *info) | ||||
{ | { | ||||
return (BHND_BUS_READ_BOARD_INFO(device_get_parent(dev), dev, info)); | return (BHND_BUS_READ_BOARD_INFO(device_get_parent(dev), dev, info)); | ||||
} | |||||
/** | |||||
* Allocate and enable per-core PMU request handling for @p child. | |||||
* | |||||
* The region containing the core's PMU register block (if any) must be | |||||
* allocated via bus_alloc_resource(9) (or bhnd_alloc_resource) before | |||||
* calling bhnd_alloc_pmu(), and must not be released until after | |||||
* calling bhnd_release_pmu(). | |||||
* | |||||
* @param dev The parent of @p child. | |||||
* @param child The requesting bhnd device. | |||||
* | |||||
* @retval 0 success | |||||
* @retval non-zero If allocating PMU request state otherwise fails, a | |||||
* regular unix error code will be returned. | |||||
*/ | |||||
static inline int | |||||
bhnd_alloc_pmu(device_t dev) | |||||
{ | |||||
return (BHND_BUS_ALLOC_PMU(device_get_parent(dev), dev)); | |||||
} | |||||
/** | |||||
* Release any per-core PMU resources allocated for @p child. Any outstanding | |||||
* PMU requests are are discarded. | |||||
* | |||||
* @param dev The parent of @p child. | |||||
* @param child The requesting bhnd device. | |||||
* | |||||
* @retval 0 success | |||||
* @retval non-zero If releasing PMU request state otherwise fails, a | |||||
* regular unix error code will be returned, and | |||||
* the core state will be left unmodified. | |||||
*/ | |||||
static inline int | |||||
bhnd_release_pmu(device_t dev) | |||||
{ | |||||
return (BHND_BUS_RELEASE_PMU(device_get_parent(dev), dev)); | |||||
} | |||||
/** | |||||
* Request that @p clock (or faster) be routed to @p dev. | |||||
* | |||||
* A driver must ask the bhnd bus to allocate clock request state | |||||
* via bhnd_alloc_pmu() before it can request clock resources. | |||||
* | |||||
* Request multiplexing is managed by the bus. | |||||
* | |||||
* @param dev The bhnd(4) device to which @p clock should be routed. | |||||
* @param clock The requested clock source. | |||||
* | |||||
* @retval 0 success | |||||
* @retval ENODEV If an unsupported clock was requested. | |||||
* @retval ENXIO If the PMU has not been initialized or is otherwise unvailable. | |||||
*/ | |||||
static inline int | |||||
bhnd_request_clock(device_t dev, bhnd_clock clock) | |||||
{ | |||||
return (BHND_BUS_REQUEST_CLOCK(device_get_parent(dev), dev, clock)); | |||||
} | |||||
/** | |||||
* Request that @p clocks be powered on behalf of @p dev. | |||||
* | |||||
* This will power any clock sources (e.g. XTAL, PLL, etc) required for | |||||
* @p clocks and wait until they are ready, discarding any previous | |||||
* requests by @p dev. | |||||
* | |||||
* Request multiplexing is managed by the bus. | |||||
* | |||||
* A driver must ask the bhnd bus to allocate clock request state | |||||
* via bhnd_alloc_pmu() before it can request clock resources. | |||||
* | |||||
* @param dev The requesting bhnd(4) device. | |||||
* @param clocks The clock(s) to be enabled. | |||||
* | |||||
* @retval 0 success | |||||
* @retval ENODEV If an unsupported clock was requested. | |||||
* @retval ENXIO If the PMU has not been initialized or is otherwise unvailable. | |||||
*/ | |||||
static inline int | |||||
bhnd_enable_clocks(device_t dev, uint32_t clocks) | |||||
{ | |||||
return (BHND_BUS_ENABLE_CLOCKS(device_get_parent(dev), dev, clocks)); | |||||
} | |||||
/** | |||||
* Power up an external PMU-managed resource assigned to @p dev. | |||||
* | |||||
* A driver must ask the bhnd bus to allocate PMU request state | |||||
* via bhnd_alloc_pmu() before it can request PMU resources. | |||||
* | |||||
* @param dev The requesting bhnd(4) device. | |||||
* @param rsrc The core-specific external resource identifier. | |||||
* | |||||
* @retval 0 success | |||||
* @retval ENODEV If the PMU does not support @p rsrc. | |||||
* @retval ENXIO If the PMU has not been initialized or is otherwise unvailable. | |||||
*/ | |||||
static inline int | |||||
bhnd_request_ext_rsrc(device_t dev, u_int rsrc) | |||||
{ | |||||
return (BHND_BUS_REQUEST_EXT_RSRC(device_get_parent(dev), dev, rsrc)); | |||||
} | |||||
/** | |||||
* Power down an external PMU-managed resource assigned to @p dev. | |||||
* | |||||
* A driver must ask the bhnd bus to allocate PMU request state | |||||
* via bhnd_alloc_pmu() before it can request PMU resources. | |||||
* | |||||
* @param dev The requesting bhnd(4) device. | |||||
* @param rsrc The core-specific external resource identifier. | |||||
* | |||||
* @retval 0 success | |||||
* @retval ENODEV If the PMU does not support @p rsrc. | |||||
* @retval ENXIO If the PMU has not been initialized or is otherwise unvailable. | |||||
*/ | |||||
static inline int | |||||
bhnd_release_ext_rsrc(device_t dev, u_int rsrc) | |||||
{ | |||||
return (BHND_BUS_RELEASE_EXT_RSRC(device_get_parent(dev), dev, rsrc)); | |||||
} | |||||
/** | |||||
* Read @p width bytes at @p offset from the bus-specific agent/config | |||||
* space of @p dev. | |||||
* | |||||
* @param dev The bhnd device for which @p offset should be read. | |||||
* @param offset The offset to be read. | |||||
* @param width The size of the access. Must be 1, 2 or 4 bytes. | |||||
* | |||||
* The exact behavior of this method is bus-specific. In the case of | |||||
* bcma(4), this method provides access to the first agent port of @p child. | |||||
* | |||||
* @note Device drivers should only use this API for functionality | |||||
* that is not available via another bhnd(4) function. | |||||
*/ | |||||
static inline uint32_t | |||||
bhnd_read_config(device_t dev, bus_size_t offset, u_int width) | |||||
{ | |||||
return (BHND_BUS_READ_CONFIG(device_get_parent(dev), dev, offset, | |||||
width)); | |||||
} | |||||
/** | |||||
* Read @p width bytes at @p offset from the bus-specific agent/config | |||||
* space of @p dev. | |||||
* | |||||
* @param dev The bhnd device for which @p offset should be read. | |||||
* @param offset The offset to be written. | |||||
* @param width The size of the access. Must be 1, 2 or 4 bytes. | |||||
* | |||||
* The exact behavior of this method is bus-specific. In the case of | |||||
* bcma(4), this method provides access to the first agent port of @p child. | |||||
* | |||||
* @note Device drivers should only use this API for functionality | |||||
* that is not available via another bhnd(4) function. | |||||
*/ | |||||
static inline void | |||||
bhnd_write_config(device_t dev, bus_size_t offset, uint32_t val, u_int width) | |||||
{ | |||||
BHND_BUS_WRITE_CONFIG(device_get_parent(dev), dev, offset, val, width); | |||||
} | } | ||||
/** | /** | ||||
* Read an NVRAM variable, coerced to the requested @p type. | * Read an NVRAM variable, coerced to the requested @p type. | ||||
* | * | ||||
* @param dev A bhnd bus child device. | * @param dev A bhnd bus child device. | ||||
* @param name The NVRAM variable name. | * @param name The NVRAM variable name. | ||||
* @param[out] buf A buffer large enough to hold @p len bytes. On | * @param[out] buf A buffer large enough to hold @p len bytes. On | ||||
▲ Show 20 Lines • Show All 504 Lines • Show Last 20 Lines |