On 2 March 2016 at 05:27, Jean-Christophe Dubois <j...@tribudubois.net> wrote:
> The sabrelite supports one SPI FLASH memory on SPI1
>
> Signed-off-by: Jean-Christophe Dubois <j...@tribudubois.net>
> ---
>
> +
> +    {
> +        /* Add the sst25vf016b NOR FLASH memory to first SPI */
> +        Object *spi_dev;
> +
> +        spi_dev = object_resolve_path_component(OBJECT(&s->soc), "spi1");
> +        if (spi_dev) {
> +            SSIBus *spi_bus;
> +
> +            spi_bus = (SSIBus *)qdev_get_child_bus(DEVICE(spi_dev), "spi");

This looks odd. You should just be able to do
 spi_bus = (SSIBus *)qdev_get_child_bus(DEVICE(&s->soc), "spi1");
without using object_resolve_path_component() to try to find an
SPI device object, because your SoC device should have alias properties
which provide access to its SPI subcomponents' SPI buses.
See hw/arm/xlnx-ep108.c for an example of the board code for this and
hw/arm/xlnx-zynqmp.c for the SoC code which calls
object_property_add_alias() to set up the aliases.

> +            if (spi_bus) {
> +                DeviceState *flash_dev;
> +
> +                flash_dev = ssi_create_slave(spi_bus, "sst25vf016b");
> +                if (flash_dev) {
> +                    qemu_irq cs_line = qdev_get_gpio_in_named(flash_dev,
> +                                                              SSI_GPIO_CS, 
> 0);
> +                    sysbus_connect_irq(SYS_BUS_DEVICE(spi_dev), 1, cs_line);
> +                }
> +            }
> +        }
> +    }

thanks
-- PMM

Reply via email to