qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] xilinx_zynq: Add one variable to avoid overwriting QSPI bus
@ 2012-11-28  9:14 Liming Wang
  2012-11-28 10:08 ` Peter Crosthwaite
  2012-12-04 17:13 ` Peter Maydell
  0 siblings, 2 replies; 3+ messages in thread
From: Liming Wang @ 2012-11-28  9:14 UTC (permalink / raw)
  To: qemu-devel, Peter Crosthwaite
  Cc: Peter Maydell, Peter Crosthwaite, Stefan Hajnoczi

commit 7b482bcf xilinx_zynq: added QSPI controller

Adds one QSPI controller, which has two spi buses, one is for
spi0, and another is for spi1. But when initializing the spi1
bus, "dev" has been overwrited by the ssi_create_slave_no_init() function,
so that qdev_get_child_bus() returns NULL and the last two m25p80 flashes
won't be attached to the spi1 bus, but to main-system-bus.

Here we add one variable to avoid overwriting.

Signed-off-by: Liming Wang <walimisdev@gmail.com>
---
 hw/xilinx_zynq.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/hw/xilinx_zynq.c b/hw/xilinx_zynq.c
index 1f12a3d..49233d8 100644
--- a/hw/xilinx_zynq.c
+++ b/hw/xilinx_zynq.c
@@ -57,6 +57,7 @@ static inline void zynq_init_spi_flashes(uint32_t base_addr, qemu_irq irq,
     DeviceState *dev;
     SysBusDevice *busdev;
     SSIBus *spi;
+    DeviceState *flash_dev;
     int i, j;
     int num_busses =  is_qspi ? NUM_QSPI_BUSSES : 1;
     int num_ss = is_qspi ? NUM_QSPI_FLASHES : NUM_SPI_FLASHES;
@@ -81,11 +82,11 @@ static inline void zynq_init_spi_flashes(uint32_t base_addr, qemu_irq irq,
         spi = (SSIBus *)qdev_get_child_bus(dev, bus_name);
 
         for (j = 0; j < num_ss; ++j) {
-            dev = ssi_create_slave_no_init(spi, "m25p80");
-            qdev_prop_set_string(dev, "partname", "n25q128");
-            qdev_init_nofail(dev);
+            flash_dev = ssi_create_slave_no_init(spi, "m25p80");
+            qdev_prop_set_string(flash_dev, "partname", "n25q128");
+            qdev_init_nofail(flash_dev);
 
-            cs_line = qdev_get_gpio_in(dev, 0);
+            cs_line = qdev_get_gpio_in(flash_dev, 0);
             sysbus_connect_irq(busdev, i * num_ss + j + 1, cs_line);
         }
     }
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] xilinx_zynq: Add one variable to avoid overwriting QSPI bus
  2012-11-28  9:14 [Qemu-devel] [PATCH] xilinx_zynq: Add one variable to avoid overwriting QSPI bus Liming Wang
@ 2012-11-28 10:08 ` Peter Crosthwaite
  2012-12-04 17:13 ` Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Crosthwaite @ 2012-11-28 10:08 UTC (permalink / raw)
  To: Liming Wang; +Cc: Peter Maydell, qemu-devel, Stefan Hajnoczi

On Wed, Nov 28, 2012 at 7:14 PM, Liming Wang <walimisdev@gmail.com> wrote:
> commit 7b482bcf xilinx_zynq: added QSPI controller
>
> Adds one QSPI controller, which has two spi buses, one is for
> spi0, and another is for spi1. But when initializing the spi1
> bus, "dev" has been overwrited by the ssi_create_slave_no_init() function,
> so that qdev_get_child_bus() returns NULL and the last two m25p80 flashes
> won't be attached to the spi1 bus, but to main-system-bus.
>
> Here we add one variable to avoid overwriting.
>
> Signed-off-by: Liming Wang <walimisdev@gmail.com>

Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>

> ---
>  hw/xilinx_zynq.c |    9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/hw/xilinx_zynq.c b/hw/xilinx_zynq.c
> index 1f12a3d..49233d8 100644
> --- a/hw/xilinx_zynq.c
> +++ b/hw/xilinx_zynq.c
> @@ -57,6 +57,7 @@ static inline void zynq_init_spi_flashes(uint32_t base_addr, qemu_irq irq,
>      DeviceState *dev;
>      SysBusDevice *busdev;
>      SSIBus *spi;
> +    DeviceState *flash_dev;
>      int i, j;
>      int num_busses =  is_qspi ? NUM_QSPI_BUSSES : 1;
>      int num_ss = is_qspi ? NUM_QSPI_FLASHES : NUM_SPI_FLASHES;
> @@ -81,11 +82,11 @@ static inline void zynq_init_spi_flashes(uint32_t base_addr, qemu_irq irq,
>          spi = (SSIBus *)qdev_get_child_bus(dev, bus_name);
>
>          for (j = 0; j < num_ss; ++j) {
> -            dev = ssi_create_slave_no_init(spi, "m25p80");
> -            qdev_prop_set_string(dev, "partname", "n25q128");
> -            qdev_init_nofail(dev);
> +            flash_dev = ssi_create_slave_no_init(spi, "m25p80");
> +            qdev_prop_set_string(flash_dev, "partname", "n25q128");
> +            qdev_init_nofail(flash_dev);
>
> -            cs_line = qdev_get_gpio_in(dev, 0);
> +            cs_line = qdev_get_gpio_in(flash_dev, 0);
>              sysbus_connect_irq(busdev, i * num_ss + j + 1, cs_line);
>          }
>      }
> --
> 1.7.9.5
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] xilinx_zynq: Add one variable to avoid overwriting QSPI bus
  2012-11-28  9:14 [Qemu-devel] [PATCH] xilinx_zynq: Add one variable to avoid overwriting QSPI bus Liming Wang
  2012-11-28 10:08 ` Peter Crosthwaite
@ 2012-12-04 17:13 ` Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2012-12-04 17:13 UTC (permalink / raw)
  To: Liming Wang
  Cc: Peter Crosthwaite, Peter Crosthwaite, qemu-devel, Stefan Hajnoczi

On 28 November 2012 09:14, Liming Wang <walimisdev@gmail.com> wrote:
> commit 7b482bcf xilinx_zynq: added QSPI controller
>
> Adds one QSPI controller, which has two spi buses, one is for
> spi0, and another is for spi1. But when initializing the spi1
> bus, "dev" has been overwrited by the ssi_create_slave_no_init() function,
> so that qdev_get_child_bus() returns NULL and the last two m25p80 flashes
> won't be attached to the spi1 bus, but to main-system-bus.
>
> Here we add one variable to avoid overwriting.
>
> Signed-off-by: Liming Wang <walimisdev@gmail.com>

Thanks, applied to arm-devs.next.

-- PMM

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-12-04 17:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-28  9:14 [Qemu-devel] [PATCH] xilinx_zynq: Add one variable to avoid overwriting QSPI bus Liming Wang
2012-11-28 10:08 ` Peter Crosthwaite
2012-12-04 17:13 ` Peter Maydell

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).