dm: acpi: Enhance acpi_get_name()
For many device types it is possible to figure out the name just by looking at its uclass or parent. Add a function to handle this, since it allows us to cover the vast majority of cases automatically. However it is sometimes impossible to figure out an ACPI name for a device just by looking at its uclass. For example a touch device may have a vendor-specific name. Add a new "acpi,name" property to allow a custom name to be created. With this new feature we can drop the get_name() methods in the sandbox I2C and SPI drivers. They were only added for testing purposes. Update the tests to use the new values. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
This commit is contained in:
@@ -384,4 +384,22 @@ int acpi_device_add_power_res(struct acpi_ctx *ctx, u32 tx_state_val,
|
||||
const struct gpio_desc *stop_gpio,
|
||||
uint stop_delay_ms, uint stop_off_delay_ms);
|
||||
|
||||
/**
|
||||
* acpi_device_infer_name() - Infer the name from its uclass or parent
|
||||
*
|
||||
* Many ACPI devices have a standard name that can be inferred from the uclass
|
||||
* they are in, or the uclass of their parent. These rules are implemented in
|
||||
* this function. It attempts to produce a name for a device based on these
|
||||
* rules.
|
||||
*
|
||||
* NOTE: This currently supports only x86 devices. Feel free to enhance it for
|
||||
* other architectures as needed.
|
||||
*
|
||||
* @dev: Device to check
|
||||
* @out_name: Place to put the name (must hold ACPI_NAME_MAX bytes)
|
||||
* @return 0 if a name was found, -ENOENT if not found, -ENXIO if the device
|
||||
* sequence number could not be determined
|
||||
*/
|
||||
int acpi_device_infer_name(const struct udevice *dev, char *out_name);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user