Received: from eggs.gnu.org ([2001:4830:134:3::10]:33733) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3BQQ-0004gW-Of for qemu-devel@nongnu.org; Sun, 29 Nov 2015 18:30:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a3BQP-0000LX-FL for qemu-devel@nongnu.org; Sun, 29 Nov 2015 18:30:34 -0500 References: <67ac22f6fca1dcbafb69d5bd318b1157c8d5d923.1448602470.git.crosthwaite.peter@gmail.com> From: Jean-Christophe DUBOIS Message-ID: <565B8A90.3060505@tribudubois.net> Date: Mon, 30 Nov 2015 00:30:24 +0100 MIME-Version: 1.0 In-Reply-To: <67ac22f6fca1dcbafb69d5bd318b1157c8d5d923.1448602470.git.crosthwaite.peter@gmail.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v1 2/2] arm: fsl-imx25: Add SD support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Crosthwaite , qemu-devel@nongnu.org Cc: saipava@xilinx.com, qemu-block@nongnu.org, Peter Crosthwaite Hello Peter, Le 28/11/2015 21:50, Peter Crosthwaite a =E9crit : > Add the two SD card controllers as the generic sysbus SDHCI device. > Tested as sucessfully working with Linux 4.2. using the SD card for the > root file system. I guess the SDHCI device present in Qemu is (surprisingly) close enough=20 to the i.MX version so that it works with a "generic" guest driver not=20 using all device features which is nice. But I am afraid the Freescale version is not 100% compatible. To me it=20 looks like some registers are different or not supported in i.MX25. I guess we could "fix it" later when we meet some different guest driver. JC > > Signed-off-by: Peter Crosthwaite > --- > > hw/arm/fsl-imx25.c | 26 ++++++++++++++++++++++++++ > include/hw/arm/fsl-imx25.h | 9 +++++++++ > 2 files changed, 35 insertions(+) > > diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c > index e1cadac..9ccbd03 100644 > --- a/hw/arm/fsl-imx25.c > +++ b/hw/arm/fsl-imx25.c > @@ -68,6 +68,11 @@ static void fsl_imx25_init(Object *obj) > object_initialize(&s->gpio[i], sizeof(s->gpio[i]), TYPE_IMX_G= PIO); > qdev_set_parent_bus(DEVICE(&s->gpio[i]), sysbus_get_default()= ); > } > + > + for (i =3D 0; i < FSL_IMX25_NUM_ESDHCS; i++) { > + object_initialize(&s->esdhc[i], sizeof(s->esdhc[i]), TYPE_SYSB= US_SDHCI); > + qdev_set_parent_bus(DEVICE(&s->esdhc[i]), sysbus_get_default()= ); > + } > } > =20 > static void fsl_imx25_realize(DeviceState *dev, Error **errp) > @@ -243,6 +248,27 @@ static void fsl_imx25_realize(DeviceState *dev, Er= ror **errp) > gpio_table[i].irq)); > } > =20 > + /* Initialize all eSDHCs */ > + for (i =3D 0; i < FSL_IMX25_NUM_ESDHCS; i++) { > + static const struct { > + hwaddr addr; > + unsigned int irq; > + } esdhc_table[FSL_IMX25_NUM_ESDHCS] =3D { > + { FSL_IMX25_ESDHC1_ADDR, FSL_IMX25_ESDHC1_IRQ }, > + { FSL_IMX25_ESDHC2_ADDR, FSL_IMX25_ESDHC2_IRQ } > + }; > + > + object_property_set_bool(OBJECT(&s->esdhc[i]), true, "realized= ", &err); > + if (err) { > + error_propagate(errp, err); > + return; > + } > + sysbus_mmio_map(SYS_BUS_DEVICE(&s->esdhc[i]), 0, esdhc_table[i= ].addr); > + sysbus_connect_irq(SYS_BUS_DEVICE(&s->esdhc[i]), 0, > + qdev_get_gpio_in(DEVICE(&s->avic), > + esdhc_table[i].irq)); > + } > + > /* initialize 2 x 16 KB ROM */ > memory_region_init_rom_device(&s->rom[0], NULL, NULL, NULL, > "imx25.rom0", FSL_IMX25_ROM0_SIZE, = &err); > diff --git a/include/hw/arm/fsl-imx25.h b/include/hw/arm/fsl-imx25.h > index 73f50c6..ade4d42 100644 > --- a/include/hw/arm/fsl-imx25.h > +++ b/include/hw/arm/fsl-imx25.h > @@ -26,6 +26,7 @@ > #include "hw/net/imx_fec.h" > #include "hw/i2c/imx_i2c.h" > #include "hw/gpio/imx_gpio.h" > +#include "hw/sd/sdhci.h" > #include "exec/memory.h" > =20 > #define TYPE_FSL_IMX25 "fsl,imx25" > @@ -36,6 +37,7 @@ > #define FSL_IMX25_NUM_EPITS 2 > #define FSL_IMX25_NUM_I2CS 3 > #define FSL_IMX25_NUM_GPIOS 4 > +#define FSL_IMX25_NUM_ESDHCS 2 > =20 > typedef struct FslIMX25State { > /*< private >*/ > @@ -51,6 +53,7 @@ typedef struct FslIMX25State { > IMXFECState fec; > IMXI2CState i2c[FSL_IMX25_NUM_I2CS]; > IMXGPIOState gpio[FSL_IMX25_NUM_GPIOS]; > + SDHCIState esdhc[2]; > MemoryRegion rom[2]; > MemoryRegion iram; > MemoryRegion iram_alias; > @@ -211,6 +214,10 @@ typedef struct FslIMX25State { > #define FSL_IMX25_GPIO4_SIZE 0x4000 > #define FSL_IMX25_GPIO3_ADDR 0x53FA4000 > #define FSL_IMX25_GPIO3_SIZE 0x4000 > +#define FSL_IMX25_ESDHC1_ADDR 0x53FB4000 > +#define FSL_IMX25_ESDHC1_SIZE 0x4000 > +#define FSL_IMX25_ESDHC2_ADDR 0x53FBB000 > +#define FSL_IMX25_ESDHC2_SIZE 0x4000 > #define FSL_IMX25_GPIO1_ADDR 0x53FCC000 > #define FSL_IMX25_GPIO1_SIZE 0x4000 > #define FSL_IMX25_GPIO2_ADDR 0x53FD0000 > @@ -245,5 +252,7 @@ typedef struct FslIMX25State { > #define FSL_IMX25_GPIO2_IRQ 51 > #define FSL_IMX25_GPIO3_IRQ 16 > #define FSL_IMX25_GPIO4_IRQ 23 > +#define FSL_IMX25_ESDHC1_IRQ 9 > +#define FSL_IMX25_ESDHC2_IRQ 8 > =20 > #endif /* FSL_IMX25_H */