[PATCH v3 34/35] dm: acpi: Enhance acpi_get_name()
Simon Glass
sjg at chromium.org
Tue Jul 7 21:12:34 CEST 2020
Hi Bin,
On Sun, 28 Jun 2020 at 23:39, Bin Meng <bmeng.cn at gmail.com> wrote:
>
> Hi Simon,
>
> On Sun, Jun 14, 2020 at 10:55 AM Simon Glass <sjg at chromium.org> wrote:
> >
> > 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 at chromium.org>
> > Reviewed-by: Wolfgang Wallner <wolfgang.wallner at br-automation.com>
> > ---
> >
> > Changes in v3:
> > - Fix 'of' typo
> >
> > Changes in v1:
> > - Use acpi,ddn instead of acpi,desc
> > - Rename to acpi_device_infer_name()
> > - Update newly created sandbox tests
> >
> > arch/sandbox/dts/test.dts | 1 +
> > doc/device-tree-bindings/device.txt | 13 ++++
> > drivers/core/acpi.c | 13 +++-
> > drivers/i2c/sandbox_i2c.c | 10 ---
> > drivers/spi/sandbox_spi.c | 10 ---
> > include/acpi/acpi_device.h | 15 ++++
> > lib/acpi/acpi_device.c | 106 ++++++++++++++++++++++++++++
> > test/dm/acpi.c | 42 ++++++++++-
> > test/dm/acpigen.c | 4 +-
> > 9 files changed, 189 insertions(+), 25 deletions(-)
[..]
> > diff --git a/lib/acpi/acpi_device.c b/lib/acpi/acpi_device.c
> > index 912369498a..c6560e37bc 100644
> > --- a/lib/acpi/acpi_device.c
> > +++ b/lib/acpi/acpi_device.c
> > @@ -10,6 +10,8 @@
> > #include <dm.h>
> > #include <irq.h>
> > #include <log.h>
> > +#include <usb.h>
> > +#include <acpi/acpigen.h>
> > #include <acpi/acpi_device.h>
> > #include <acpi/acpigen.h>
> > #include <asm-generic/gpio.h>
> > @@ -711,3 +713,107 @@ int acpi_device_write_spi_dev(struct acpi_ctx *ctx, const struct udevice *dev)
> > return 0;
> > }
> > #endif /* CONFIG_SPI */
> > +
> > +static const char *acpi_name_from_id(enum uclass_id id)
> > +{
> > + switch (id) {
> > + case UCLASS_USB_HUB:
> > + /* Root Hub */
> > + return "RHUB";
> > + /* DSDT: acpi/northbridge.asl */
> > + case UCLASS_NORTHBRIDGE:
> > + return "MCHC";
> > + /* DSDT: acpi/lpc.asl */
> > + case UCLASS_LPC:
> > + return "LPCB";
> > + /* DSDT: acpi/xhci.asl */
> > + case UCLASS_USB:
> > + return "XHCI";
>
> What about USB 2.0 controllers?
Not supported. Will add a comment. This is only an attempt to guess at
the right name. You can always put it in the device tree.
>
> > + case UCLASS_PWM:
> > + return "PWM";
> > + default:
> > + return NULL;
> > + }
> > +}
>
> The above mapping seems to only work with x86 PCI devices? What about
> other architectures? The API name is too generic if this is only for
> 86,
Yes but as mentioned earlier, I am not implementing this for other
architectures, just creating and API and code that can be modified as
other archs are supported.
I'll add a comment.
Regards,
SImon
More information about the U-Boot
mailing list