Message ID | 1447680189-2128-4-git-send-email-shannon.zhao@linaro.org |
---|---|
State | New |
Headers | show |
On Mon, 16 Nov 2015 21:23:04 +0800 shannon.zhao@linaro.org wrote: > From: Shannon Zhao <shannon.zhao@linaro.org> > > Add power button device in ACPI DSDT table. > > Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org> > Reviewed-by: Wei Huang <wei@redhat.com> > Tested-by: Wei Huang <wei@redhat.com> > --- > hw/arm/virt-acpi-build.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c > index bf6b934..b25c90b 100644 > --- a/hw/arm/virt-acpi-build.c > +++ b/hw/arm/virt-acpi-build.c > @@ -340,6 +340,18 @@ static void acpi_dsdt_add_gpio(Aml *scope, const MemMapEntry *gpio_memmap, > aml_append(scope, dev); > } > > +static void acpi_dsdt_add_power_button(Aml *scope) > +{ > + Aml *dev = aml_device("PWRB"); > + aml_append(dev, aml_name_decl("_HID", aml_string("PNP0C0C"))); > + aml_append(dev, aml_name_decl("_ADR", aml_int(0))); > + aml_append(dev, aml_name_decl("_UID", aml_int(0))); > + Aml *method = aml_method("_STA", 0); > + aml_append(method, aml_return(aml_int(0x0F))); > + aml_append(dev, method); since _STA always returns 0xF you can just drop it altogether, as _STA == 0xF is implied if it's not present. > + aml_append(scope, dev); > +} > + > /* RSDP */ > static GArray * > build_rsdp(GArray *rsdp_table, GArray *linker, unsigned rsdt) > @@ -558,6 +570,7 @@ build_dsdt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info) > guest_info->use_highmem); > acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO], > (irqmap[VIRT_GPIO] + ARM_SPI_BASE)); > + acpi_dsdt_add_power_button(scope); > > aml_append(dsdt, scope); >
Hi Igor, On 2015/12/1 19:41, Igor Mammedov wrote: > On Mon, 16 Nov 2015 21:23:04 +0800 > shannon.zhao@linaro.org wrote: > >> > From: Shannon Zhao <shannon.zhao@linaro.org> >> > >> > Add power button device in ACPI DSDT table. >> > >> > Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com> >> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org> >> > Reviewed-by: Wei Huang <wei@redhat.com> >> > Tested-by: Wei Huang <wei@redhat.com> >> > --- >> > hw/arm/virt-acpi-build.c | 13 +++++++++++++ >> > 1 file changed, 13 insertions(+) >> > >> > diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c >> > index bf6b934..b25c90b 100644 >> > --- a/hw/arm/virt-acpi-build.c >> > +++ b/hw/arm/virt-acpi-build.c >> > @@ -340,6 +340,18 @@ static void acpi_dsdt_add_gpio(Aml *scope, const MemMapEntry *gpio_memmap, >> > aml_append(scope, dev); >> > } >> > >> > +static void acpi_dsdt_add_power_button(Aml *scope) >> > +{ >> > + Aml *dev = aml_device("PWRB"); >> > + aml_append(dev, aml_name_decl("_HID", aml_string("PNP0C0C"))); >> > + aml_append(dev, aml_name_decl("_ADR", aml_int(0))); >> > + aml_append(dev, aml_name_decl("_UID", aml_int(0))); >> > + Aml *method = aml_method("_STA", 0); >> > + aml_append(method, aml_return(aml_int(0x0F))); >> > + aml_append(dev, method); > since _STA always returns 0xF you can just drop it altogether, > as _STA == 0xF is implied if it's not present. > Yes, but I think adding this is harmless and make the return value explicit. Thanks,
On Tue, 1 Dec 2015 20:43:36 +0800 Shannon Zhao <zhaoshenglong@huawei.com> wrote: > Hi Igor, > > On 2015/12/1 19:41, Igor Mammedov wrote: > > On Mon, 16 Nov 2015 21:23:04 +0800 > > shannon.zhao@linaro.org wrote: > > > >> > From: Shannon Zhao <shannon.zhao@linaro.org> > >> > > >> > Add power button device in ACPI DSDT table. > >> > > >> > Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com> > >> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org> > >> > Reviewed-by: Wei Huang <wei@redhat.com> > >> > Tested-by: Wei Huang <wei@redhat.com> > >> > --- > >> > hw/arm/virt-acpi-build.c | 13 +++++++++++++ > >> > 1 file changed, 13 insertions(+) > >> > > >> > diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c > >> > index bf6b934..b25c90b 100644 > >> > --- a/hw/arm/virt-acpi-build.c > >> > +++ b/hw/arm/virt-acpi-build.c > >> > @@ -340,6 +340,18 @@ static void acpi_dsdt_add_gpio(Aml *scope, const MemMapEntry *gpio_memmap, > >> > aml_append(scope, dev); > >> > } > >> > > >> > +static void acpi_dsdt_add_power_button(Aml *scope) > >> > +{ > >> > + Aml *dev = aml_device("PWRB"); > >> > + aml_append(dev, aml_name_decl("_HID", aml_string("PNP0C0C"))); > >> > + aml_append(dev, aml_name_decl("_ADR", aml_int(0))); > >> > + aml_append(dev, aml_name_decl("_UID", aml_int(0))); > >> > + Aml *method = aml_method("_STA", 0); > >> > + aml_append(method, aml_return(aml_int(0x0F))); > >> > + aml_append(dev, method); > > since _STA always returns 0xF you can just drop it altogether, > > as _STA == 0xF is implied if it's not present. > > > > Yes, but I think adding this is harmless and make the return value explicit. It's useless and consumes several bytes, it's better to drop it unless you have to have it. > Thanks,
Hi Igor, On 2015/12/1 21:05, Igor Mammedov wrote: >>>>> +static void acpi_dsdt_add_power_button(Aml *scope) >>>>> > >> > +{ >>>>> > >> > + Aml *dev = aml_device("PWRB"); >>>>> > >> > + aml_append(dev, aml_name_decl("_HID", aml_string("PNP0C0C"))); >>>>> > >> > + aml_append(dev, aml_name_decl("_ADR", aml_int(0))); >>>>> > >> > + aml_append(dev, aml_name_decl("_UID", aml_int(0))); >>>>> > >> > + Aml *method = aml_method("_STA", 0); >>>>> > >> > + aml_append(method, aml_return(aml_int(0x0F))); >>>>> > >> > + aml_append(dev, method); >>> > > since _STA always returns 0xF you can just drop it altogether, >>> > > as _STA == 0xF is implied if it's not present. >>> > > >> > >> > Yes, but I think adding this is harmless and make the return value explicit. > It's useless and consumes several bytes, it's better to drop it unless you have to have it. > Sure, will drop it. :) BTW, could you have a look at other ACPI patches in this series? Thanks in advance!
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index bf6b934..b25c90b 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -340,6 +340,18 @@ static void acpi_dsdt_add_gpio(Aml *scope, const MemMapEntry *gpio_memmap, aml_append(scope, dev); } +static void acpi_dsdt_add_power_button(Aml *scope) +{ + Aml *dev = aml_device("PWRB"); + aml_append(dev, aml_name_decl("_HID", aml_string("PNP0C0C"))); + aml_append(dev, aml_name_decl("_ADR", aml_int(0))); + aml_append(dev, aml_name_decl("_UID", aml_int(0))); + Aml *method = aml_method("_STA", 0); + aml_append(method, aml_return(aml_int(0x0F))); + aml_append(dev, method); + aml_append(scope, dev); +} + /* RSDP */ static GArray * build_rsdp(GArray *rsdp_table, GArray *linker, unsigned rsdt) @@ -558,6 +570,7 @@ build_dsdt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info) guest_info->use_highmem); acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO], (irqmap[VIRT_GPIO] + ARM_SPI_BASE)); + acpi_dsdt_add_power_button(scope); aml_append(dsdt, scope);