qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Wei Huang <wei@redhat.com>
To: Shannon Zhao <zhaoshenglong@huawei.com>,
	qemu-devel@nongnu.org, peter.maydell@linaro.org,
	pbonzini@redhat.com, christoffer.dall@linaro.org,
	a.spyridakis@virtualopensystems.com, claudio.fontana@huawei.com,
	imammedo@redhat.com, hanjun.guo@linaro.org, mst@redhat.com,
	lersek@redhat.com
Cc: wanghaibin.wang@huawei.com, hangaohuai@huawei.com,
	peter.huangpeng@huawei.com
Subject: Re: [Qemu-devel] [RFC PATCH 1/7] hw/arm/virt: Add a GPIO controller
Date: Wed, 18 Feb 2015 11:52:38 -0600	[thread overview]
Message-ID: <54E4D166.9090205@redhat.com> (raw)
In-Reply-To: <1424167806-8372-2-git-send-email-zhaoshenglong@huawei.com>



On 02/17/2015 04:10 AM, Shannon Zhao wrote:
> Add a GPIO controller in machine virt, in order to support cpu hotplug.
> Here we use pl061.
> 
> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
> ---
>  hw/arm/virt.c |   28 ++++++++++++++++++++++++++++
>  1 files changed, 28 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 8a00574..43c0260 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -75,6 +75,7 @@ enum {
>      VIRT_MMIO,
>      VIRT_RTC,
>      VIRT_FW_CFG,
> +    VIRT_GPIO,
>  };
>  
>  typedef struct MemMapEntry {
> @@ -133,6 +134,7 @@ static const MemMapEntry a15memmap[] = {
>      [VIRT_UART] =       { 0x09000000, 0x00001000 },
>      [VIRT_RTC] =        { 0x09010000, 0x00001000 },
>      [VIRT_FW_CFG] =     { 0x09020000, 0x0000000a },
> +    [VIRT_GPIO] =       { 0x09500000, 0x00001000 },
Base address can start with 0x09030000 to save some space?

>      [VIRT_MMIO] =       { 0x0a000000, 0x00000200 },
>      /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */
>      /* 0x10000000 .. 0x40000000 reserved for PCI */
> @@ -142,6 +144,7 @@ static const MemMapEntry a15memmap[] = {
>  static const int a15irqmap[] = {
>      [VIRT_UART] = 1,
>      [VIRT_RTC] = 2,
> +    [VIRT_GPIO] = 3,
>      [VIRT_MMIO] = 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */
>  };
>  
> @@ -465,6 +468,29 @@ 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";
> +
> +    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);
Maybe also add clocks related properties (see below)? They might be
optional, assuming that you already tested your patches.

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;
> @@ -680,6 +706,8 @@ static void machvirt_init(MachineState *machine)
>  
>      create_rtc(vbi, pic);
>  
> +    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.
> 

  reply	other threads:[~2015-02-18 17:52 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-17 10:09 [Qemu-devel] [RFC PATCH 0/7] hw/arm/virt: Add cpu-add way cpu hotplug support Shannon Zhao
2015-02-17 10:10 ` [Qemu-devel] [RFC PATCH 1/7] hw/arm/virt: Add a GPIO controller Shannon Zhao
2015-02-18 17:52   ` Wei Huang [this message]
2015-02-26  7:43     ` Shannon Zhao
2015-02-17 10:10 ` [Qemu-devel] [RFC PATCH 2/7] hw/arm/virt-acpi-build: Add GPIO controller in ACPI DSDT table Shannon Zhao
2015-02-17 10:10 ` [Qemu-devel] [RFC PATCH 3/7] hw/acpi/virt-hotplug: Add a hotplug device for machine virt Shannon Zhao
2015-02-17 10:10 ` [Qemu-devel] [RFC PATCH 4/7] topology: Move topology.h to an arch-independent location Shannon Zhao
2015-02-17 10:10 ` [Qemu-devel] [RFC PATCH 5/7] target-arm/cpu: Add apic_id property for ARMCPU Shannon Zhao
2015-02-18 17:45   ` Andreas Färber
2015-02-18 19:51     ` Igor Mammedov
2015-02-18 19:57       ` Andreas Färber
2015-02-19  8:22       ` Hanjun Guo
2015-02-17 10:10 ` [Qemu-devel] [RFC PATCH 6/7] hw/arm/virt: Add cpu hotplug support Shannon Zhao
2015-02-17 10:10 ` [Qemu-devel] [RFC PATCH 7/7] hw/arm/virt-acpi-build: Add cpu hotplug support in ACPI Shannon Zhao
2015-02-18 17:19 ` [Qemu-devel] [RFC PATCH 0/7] hw/arm/virt: Add cpu-add way cpu hotplug support Wei Huang
2015-02-18 17:22   ` Wei Huang
2015-02-26  7:32   ` Shannon Zhao
2015-02-28  4:46     ` Wei Huang

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=54E4D166.9090205@redhat.com \
    --to=wei@redhat.com \
    --cc=a.spyridakis@virtualopensystems.com \
    --cc=christoffer.dall@linaro.org \
    --cc=claudio.fontana@huawei.com \
    --cc=hangaohuai@huawei.com \
    --cc=hanjun.guo@linaro.org \
    --cc=imammedo@redhat.com \
    --cc=lersek@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=wanghaibin.wang@huawei.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).