Received: from eggs.gnu.org ([2001:4830:134:3::10]:53088) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aZ2f1-0000p2-S7 for qemu-devel@nongnu.org; Thu, 25 Feb 2016 15:37:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aZ2ew-0001d3-SZ for qemu-devel@nongnu.org; Thu, 25 Feb 2016 15:37:19 -0500 Received: from zose-mta05.web4all.fr ([185.49.20.50]:49455) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aZ2ew-0001c2-IR for qemu-devel@nongnu.org; Thu, 25 Feb 2016 15:37:14 -0500 References: <7e53a8579626017e62bfa696ca343c310360afa8.1455534309.git.jcd@tribudubois.net> From: Jean-Christophe DUBOIS Message-ID: <56CF65F5.60202@tribudubois.net> Date: Thu, 25 Feb 2016 21:37:09 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2 4/4] i.MX: Add SPI NOR FLASH memory to sabrelite board. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: QEMU Developers , Peter Crosthwaite Le 25/02/2016 15:33, Peter Maydell a =C3=A9crit : > On 15 February 2016 at 11:18, Jean-Christophe Dubois > wrote: >> Signed-off-by: Jean-Christophe Dubois >> --- >> >> Changes since v1: >> * Not present on v1. >> >> hw/arm/sabrelite.c | 9 +++++++++ >> 1 file changed, 9 insertions(+) >> >> diff --git a/hw/arm/sabrelite.c b/hw/arm/sabrelite.c >> index 8db9bbc..237dfa1 100644 >> --- a/hw/arm/sabrelite.c >> +++ b/hw/arm/sabrelite.c >> @@ -70,6 +70,15 @@ static void sabrelite_init(MachineState *machine) >> memory_region_add_subregion(get_system_memory(), FSL_IMX6_MMDC_A= DDR, >> &s->ram); >> >> + { >> + /* Add the sst25vf016b NOR FLASH memory to first SPI */ >> + SSIBus *spi =3D (SSIBus *)qdev_get_child_bus(DEVICE(&s->soc.s= pi[0]), >> + "spi"); > Rather than having the board code looking into the internals > of the SoC struct like this, you should have the SoC create an > spi bus property for itself, and then here you can just have > > spibus =3D (SSIBus *)qdev_get_child_bus(DEVICE(&s->soc), "spi"); I have 5 SPI Controllers so I should do it for each of them. And maybe=20 also for I2C, SDHC and other devices ... There might be a lot of properties a the end ... What would be the rule? Is there a recommended naming scheme? > > See hw/arm/xlnx-ep108.c for an example of this. > The code to create the property in the SoC's realize method is > > object_property_add_alias(OBJECT(s), "spi", > OBJECT(&s->spi[i]), "spi", > &error_abort); > > (where the first "spi" is the name of the bus property to create on the > SoC object, and the second is the name of the bus property on the > internal SPI device object). Example code in hw/arm/xlnx-zynqmp.c. OK, I'll have a look. > >> + DeviceState *flash_dev =3D ssi_create_slave(spi, "sst25vf016b= "); >> + qemu_irq cs_line =3D qdev_get_gpio_in_named(flash_dev, SSI_GP= IO_CS, 0); >> + sysbus_connect_irq(SYS_BUS_DEVICE(&s->soc.spi[0]), 1, cs_line= ); > Again, you want the SoC to provide an outward-facing interface to the > chipselect line so you don't have to have the board code looking > into soc.spi[] itself. OK > >> + } >> + >> sabrelite_binfo.ram_size =3D machine->ram_size; >> sabrelite_binfo.kernel_filename =3D machine->kernel_filename; >> sabrelite_binfo.kernel_cmdline =3D machine->kernel_cmdline; > thanks > -- PMM >