All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Huang <wei@redhat.com>
To: Shannon Zhao <shannon.zhao@linaro.org>,
	qemu-devel@nongnu.org, peter.maydell@linaro.org, mst@redhat.com,
	imammedo@redhat.com
Cc: peter.huangpeng@huawei.com, zhaoshenglong@huawei.com
Subject: Re: [Qemu-devel] [PATCH v2 1/8] hw/arm/virt: Add a GPIO controller
Date: Tue, 10 Nov 2015 16:42:13 -0600	[thread overview]
Message-ID: <564272C5.9080107@redhat.com> (raw)
In-Reply-To: <1446128855-26637-2-git-send-email-shannon.zhao@linaro.org>



On 10/29/2015 09:27 AM, Shannon Zhao wrote:
> ACPI 5.0 supports GPIO-signaled ACPI Events. This can be used for
> powerdown, hotplug evnets. Add a GPIO controller in machine virt,
> to support powerdown, maybe can be used for cpu hotplug. And
> here we use pl061.
> 
> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  hw/arm/virt.c         | 30 ++++++++++++++++++++++++++++++
>  include/hw/arm/virt.h |  1 +
>  2 files changed, 31 insertions(+)
> 
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 77d9267..5c505a4 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -120,6 +120,7 @@ static const MemMapEntry a15memmap[] = {
>      [VIRT_UART] =               { 0x09000000, 0x00001000 },
>      [VIRT_RTC] =                { 0x09010000, 0x00001000 },
>      [VIRT_FW_CFG] =             { 0x09020000, 0x00000018 },
> +    [VIRT_GPIO] =               { 0x09030000, 0x00001000 },
>      [VIRT_MMIO] =               { 0x0a000000, 0x00000200 },
>      /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */
>      [VIRT_PLATFORM_BUS] =       { 0x0c000000, 0x02000000 },
> @@ -135,6 +136,7 @@ static const int a15irqmap[] = {
>      [VIRT_UART] = 1,
>      [VIRT_RTC] = 2,
>      [VIRT_PCIE] = 3, /* ... to 6 */
> +    [VIRT_GPIO] = 7,
>      [VIRT_MMIO] = 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */
>      [VIRT_GIC_V2M] = 48, /* ...to 48 + NUM_GICV2M_SPIS - 1 */
>      [VIRT_PLATFORM_BUS] = 112, /* ...to 112 + PLATFORM_BUS_NUM_IRQS -1 */
> @@ -538,6 +540,32 @@ static void create_rtc(const VirtBoardInfo *vbi, qemu_irq *pic)
>      g_free(nodename);
>  }
>  
> +static void create_gpio(const VirtBoardInfo *vbi, qemu_irq *pic)
> +{
> +    char *nodename;
> +    hwaddr base = vbi->memmap[VIRT_GPIO].base;
> +    hwaddr size = vbi->memmap[VIRT_GPIO].size;
> +    int irq = vbi->irqmap[VIRT_GPIO];
> +    const char compat[] = "arm,pl061\0arm,primecell";

The compat list has a small enhancement compared with v1. This is
consistent with PL061 binding document. Other parts look good to me.

Reviewed-by: Wei Huang <wei@redhat.com>

> +
> +    sysbus_create_simple("pl061", base, pic[irq]);
> +
> +    nodename = g_strdup_printf("/pl061@%" PRIx64, base);
> +    qemu_fdt_add_subnode(vbi->fdt, nodename);
> +    qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, "reg",
> +                                 2, base, 2, size);
> +    qemu_fdt_setprop(vbi->fdt, nodename, "compatible", compat, sizeof(compat));
> +    qemu_fdt_setprop_cell(vbi->fdt, nodename, "#gpio-cells", 2);
> +    qemu_fdt_setprop(vbi->fdt, nodename, "gpio-controller", NULL, 0);
> +    qemu_fdt_setprop_cells(vbi->fdt, nodename, "interrupts",
> +                           GIC_FDT_IRQ_TYPE_SPI, irq,
> +                           GIC_FDT_IRQ_FLAGS_LEVEL_HI);
> +    qemu_fdt_setprop_cell(vbi->fdt, nodename, "clocks", vbi->clock_phandle);
> +    qemu_fdt_setprop_string(vbi->fdt, nodename, "clock-names", "apb_pclk");
> +
> +    g_free(nodename);
> +}
> +
>  static void create_virtio_devices(const VirtBoardInfo *vbi, qemu_irq *pic)
>  {
>      int i;
> @@ -1041,6 +1069,8 @@ static void machvirt_init(MachineState *machine)
>  
>      create_pcie(vbi, pic, vms->highmem);
>  
> +    create_gpio(vbi, pic);
> +
>      /* Create mmio transports, so the user can create virtio backends
>       * (which will be automatically plugged in to the transports). If
>       * no backend is created the transport will just sit harmlessly idle.
> diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
> index f464586..925faa7 100644
> --- a/include/hw/arm/virt.h
> +++ b/include/hw/arm/virt.h
> @@ -59,6 +59,7 @@ enum {
>      VIRT_PCIE_ECAM,
>      VIRT_PLATFORM_BUS,
>      VIRT_PCIE_MMIO_HIGH,
> +    VIRT_GPIO,
>  };
>  
>  typedef struct MemMapEntry {
> 

  reply	other threads:[~2015-11-10 22:42 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-29 14:27 [Qemu-devel] [PATCH v2 0/8] Add system_powerdown support on ARM for ACPI and DT Shannon Zhao
2015-10-29 14:27 ` [Qemu-devel] [PATCH v2 1/8] hw/arm/virt: Add a GPIO controller Shannon Zhao
2015-11-10 22:42   ` Wei Huang [this message]
2015-10-29 14:27 ` [Qemu-devel] [PATCH v2 2/8] hw/arm/virt-acpi-build: Add GPIO controller in ACPI DSDT table Shannon Zhao
2015-10-29 14:27 ` [Qemu-devel] [PATCH v2 3/8] hw/arm/virt-acpi-build: Add power button device " Shannon Zhao
2015-11-11  5:09   ` Wei Huang
2015-10-29 14:27 ` [Qemu-devel] [PATCH v2 4/8] hw/acpi/aml-build: Add GPIO Connection Descriptor Shannon Zhao
2015-10-29 14:27 ` [Qemu-devel] [PATCH v2 5/8] hw/acpi/aml-build: Add a wrapper for GPIO Interrupt Connection Shannon Zhao
2015-10-29 14:27 ` [Qemu-devel] [PATCH v2 6/8] hw/arm/virt-acpi-build: Add _E03 for Power Button Shannon Zhao
2015-10-29 14:27 ` [Qemu-devel] [PATCH v2 7/8] hw/arm/virt: Add QEMU powerdown notifier and hook it to GPIO Pin 3 Shannon Zhao
2015-11-11  6:57   ` Wei Huang
2015-11-11  8:52     ` Peter Maydell
2015-10-29 14:27 ` [Qemu-devel] [PATCH v2 8/8] hw/arm/virt: Add gpio-keys node for Poweroff using DT Shannon Zhao
2015-10-29 18:17 ` [Qemu-devel] [PATCH v2 0/8] Add system_powerdown support on ARM for ACPI and DT Wei Huang
2015-10-30  1:09   ` Shannon Zhao
2015-11-10 17:38 ` Wei Huang
2015-11-10 20:56   ` Wei Huang
2015-11-11  1:29     ` Shannon Zhao
2015-11-11  8:36       ` Peter Maydell
2015-11-11  8:53         ` Shannon Zhao
2015-11-27 17:18 ` Peter Maydell
2015-12-02 12:15   ` Igor Mammedov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=564272C5.9080107@redhat.com \
    --to=wei@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=mst@redhat.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=shannon.zhao@linaro.org \
    --cc=zhaoshenglong@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.