hw/arm: Add SD bus QOM alias on the machine/soc
Subsystems (3)
cover hw/arm: Add SD bus QOM alias on the machine/soc
Easy fix for LP#1895895 suggested by Peter.
As TYPE_ASPEED_SDHCI creates SDHCI inside a controller (not a SoC/machine) we don't bother modifying it yet.
Philippe Mathieu-Daudé (4):
hw/arm/fsl-imx: Add SD bus QOM alias on the SoC hw/arm/exynos4210: Add SD bus QOM alias on the SoC hw/arm/xlnx-versal: Add SD bus QOM alias on the SoC hw/arm/xilinx_zynq: Add SD bus QOM alias on the machine
hw/arm/exynos4210.c | 5 +++++ hw/arm/fsl-imx25.c | 6 ++++++ hw/arm/fsl-imx6.c | 6 ++++++ hw/arm/xilinx_zynq.c | 6 ++++++ hw/arm/xlnx-versal.c | 5 +++++ 5 files changed, 28 insertions(+)
Signature · 1 line
2.26.2
PATCH 1/4 hw/arm/fsl-imx: Add SD bus QOM alias on the SoC
To be able to select a particular SD bus from the command line, add a QOM alias on the SoC (using an unique name).
--- hw/arm/fsl-imx25.c | 6 ++++++ hw/arm/fsl-imx6.c | 6 ++++++ 2 files changed, 12 insertions(+)
hw/arm/fsl-imx25.c +6 -0
@@ -239,6 +239,7 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp) { FSL_IMX25_ESDHC1_ADDR, FSL_IMX25_ESDHC1_IRQ }, { FSL_IMX25_ESDHC2_ADDR, FSL_IMX25_ESDHC2_IRQ }, }; + g_autofree char *bus_name = NULL;object_property_set_uint (OBJECT (&s->esdhc[i]),"sd-spec-version" ,2 , &error_abort);
@@ -253,6 +254,11 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->esdhc[i]),0 ,qdev_get_gpio_in (DEVICE (&s->avic), esdhc_table[i].irq)); + +/* Alias controller SD bus to the SoC itself */ + bus_name =g_strdup_printf ("sd-bus%d" , i); +object_property_add_alias (OBJECT (s), bus_name, +OBJECT (&s->esdhc[i]),"sd-bus" ); }/* USB */
hw/arm/fsl-imx6.c +6 -0
@@ -314,6 +314,7 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) { FSL_IMX6_uSDHC3_ADDR, FSL_IMX6_uSDHC3_IRQ }, { FSL_IMX6_uSDHC4_ADDR, FSL_IMX6_uSDHC4_IRQ }, }; + g_autofree char *bus_name = NULL;/* UHS-I SDIO3.0 SDR104 1.8V ADMA */ object_property_set_uint(OBJECT(&s->esdhc[i]), "sd-spec-version", 3,
@@ -329,6 +330,11 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->esdhc[i]),0 ,qdev_get_gpio_in (DEVICE (&s->a9mpcore), esdhc_table[i].irq)); + +/* Alias controller SD bus to the SoC itself */ + bus_name =g_strdup_printf ("sd-bus%d" , i); +object_property_add_alias (OBJECT (s), bus_name, +OBJECT (&s->esdhc[i]),"sd-bus" ); }/* USB */
Signature · 1 line
2.26.2
Re: [PATCH-for-5.2? 1/4] hw/arm/fsl-imx: Add SD bus QOM alias on the SoC
Quoted 8 lines · Philippe Mathieu-Daudé
To be able to select a particular SD bus from the command line, add a QOM alias on the SoC (using an unique name).
Reported-by David Aghaian <[email protected]>Suggested-by Peter Maydell <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 57 lines
--- hw/arm/fsl-imx25.c | 6 ++++++ hw/arm/fsl-imx6.c | 6 ++++++ 2 files changed, 12 insertions(+)hw/arm/fsl-imx25.c +6
-0@@ -239,6 +239,7 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp) { FSL_IMX25_ESDHC1_ADDR, FSL_IMX25_ESDHC1_IRQ }, { FSL_IMX25_ESDHC2_ADDR, FSL_IMX25_ESDHC2_IRQ }, }; + g_autofree char *bus_name = NULL;object_property_set_uint (OBJECT (&s->esdhc[i]),"sd-spec-version" ,2 , &error_abort);@@ -253,6 +254,11 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->esdhc[i]),0 ,qdev_get_gpio_in (DEVICE (&s->avic), esdhc_table[i].irq)); + +/* Alias controller SD bus to the SoC itself */ + bus_name =g_strdup_printf ("sd-bus%d" , i); +object_property_add_alias (OBJECT (s), bus_name, +OBJECT (&s->esdhc[i]),"sd-bus" ); }/* USB */ hw/arm/fsl-imx6.c +6
-1@@ -314,6 +314,7 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) { FSL_IMX6_uSDHC3_ADDR, FSL_IMX6_uSDHC3_IRQ }, { FSL_IMX6_uSDHC4_ADDR, FSL_IMX6_uSDHC4_IRQ }, }; + g_autofree char *bus_name = NULL;/* UHS-I SDIO3.0 SDR104 1.8V ADMA */ object_property_set_uint(OBJECT(&s->esdhc[i]), "sd-spec-version", 3,@@ -329,6 +330,11 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->esdhc[i]),0 ,qdev_get_gpio_in (DEVICE (&s->a9mpcore), esdhc_table[i].irq)); + +/* Alias controller SD bus to the SoC itself */ + bus_name =g_strdup_printf ("sd-bus%d" , i); +object_property_add_alias (OBJECT (s), bus_name, +OBJECT (&s->esdhc[i]),"sd-bus" ); }/* USB */ --2.26.2
PATCH 2/4 hw/arm/exynos4210: Add SD bus QOM alias on the SoC
In reply to Philippe Mathieu-DaudéTo be able to select a particular SD bus from the command line, add a QOM alias on the SoC (using an unique name).
--- hw/arm/exynos4210.c | 5 +++++ 1 file changed, 5 insertions(+)
hw/arm/exynos4210.c +5 -0
@@ -408,6 +408,7 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)/*** SD/MMC host controllers ***/ for (n =0 ; n <EXYNOS4210_SDHCI_NUMBER ; n++) { + g_autofree char *bus_name = NULL;DeviceState *carddev;BlockBackend *blk;DriveInfo *di;
@@ -432,6 +433,10 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)sysbus_mmio_map (busdev,0 ,EXYNOS4210_SDHCI_ADDR (n));sysbus_connect_irq (busdev,0 , s->irq_table[exynos4210_get_irq (29 , n)]); +/* Alias controller SD bus to the SoC itself */ + bus_name =g_strdup_printf ("sd-bus%d" , n); +object_property_add_alias (OBJECT (s), bus_name,OBJECT (dev),"sd-bus" ); + di =drive_get (IF_SD ,0 , n); blk = di ?blk_by_legacy_dinfo (di) :NULL ; carddev =qdev_new (TYPE_SD_CARD );
Signature · 1 line
2.26.2
Re: [PATCH-for-5.2? 2/4] hw/arm/exynos4210: Add SD bus QOM alias on the SoC
Quoted 6 lines · Philippe Mathieu-Daudé
To be able to select a particular SD bus from the command line, add a QOM alias on the SoC (using an unique name).
Suggested-by Peter Maydell <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 31 lines
--- hw/arm/exynos4210.c | 5 +++++ 1 file changed, 5 insertions(+)hw/arm/exynos4210.c +5
-1@@ -408,6 +408,7 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)/*** SD/MMC host controllers ***/ for (n =0 ; n <EXYNOS4210_SDHCI_NUMBER ; n++) { + g_autofree char *bus_name = NULL;DeviceState *carddev;BlockBackend *blk;DriveInfo *di;@@ -432,6 +433,10 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)sysbus_mmio_map (busdev,0 ,EXYNOS4210_SDHCI_ADDR (n));sysbus_connect_irq (busdev,0 , s->irq_table[exynos4210_get_irq (29 , n)]); +/* Alias controller SD bus to the SoC itself */ + bus_name =g_strdup_printf ("sd-bus%d" , n); +object_property_add_alias (OBJECT (s), bus_name,OBJECT (dev),"sd-bus" ); + di =drive_get (IF_SD ,0 , n); blk = di ?blk_by_legacy_dinfo (di) :NULL ; carddev =qdev_new (TYPE_SD_CARD ); --2.26.2
PATCH 3/4 hw/arm/xlnx-versal: Add SD bus QOM alias on the SoC
In reply to Philippe Mathieu-DaudéTo be able to select a particular SD bus from the command line, add a QOM alias on the SoC (using an unique name).
--- hw/arm/xlnx-versal.c | 5 +++++ 1 file changed, 5 insertions(+)
hw/arm/xlnx-versal.c +5 -0
@@ -210,6 +210,7 @@ static void versal_create_sds(Versal *s, qemu_irq *pic)int i;for (i =0 ; i <ARRAY_SIZE (s->pmc.iou.sd); i++) { + g_autofree char *bus_name = NULL;DeviceState *dev;MemoryRegion *mr;
@@ -224,6 +225,10 @@ static void versal_create_sds(Versal *s, qemu_irq *pic)object_property_set_uint (OBJECT (dev),"uhs" ,UHS_I , &error_fatal);sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal); +/* Alias controller SD bus to the SoC itself */ + bus_name =g_strdup_printf ("sd-bus%d" , i); +object_property_add_alias (OBJECT (s), bus_name,OBJECT (dev),"sd-bus" ); + mr =sysbus_mmio_get_region (SYS_BUS_DEVICE (dev),0 );memory_region_add_subregion (&s->mr_ps,MM_PMC_SD0 + i *MM_PMC_SD0_SIZE , mr);
Signature · 1 line
2.26.2
Re: [PATCH-for-5.2? 3/4] hw/arm/xlnx-versal: Add SD bus QOM alias on the SoC
Quoted 6 lines · Philippe Mathieu-Daudé
To be able to select a particular SD bus from the command line, add a QOM alias on the SoC (using an unique name).
Suggested-by Peter Maydell <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 31 lines
--- hw/arm/xlnx-versal.c | 5 +++++ 1 file changed, 5 insertions(+)hw/arm/xlnx-versal.c +5
-1@@ -210,6 +210,7 @@ static void versal_create_sds(Versal *s, qemu_irq *pic)int i;for (i =0 ; i <ARRAY_SIZE (s->pmc.iou.sd); i++) { + g_autofree char *bus_name = NULL;DeviceState *dev;MemoryRegion *mr;@@ -224,6 +225,10 @@ static void versal_create_sds(Versal *s, qemu_irq *pic)object_property_set_uint (OBJECT (dev),"uhs" ,UHS_I , &error_fatal);sysbus_realize (SYS_BUS_DEVICE (dev), &error_fatal); +/* Alias controller SD bus to the SoC itself */ + bus_name =g_strdup_printf ("sd-bus%d" , i); +object_property_add_alias (OBJECT (s), bus_name,OBJECT (dev),"sd-bus" ); + mr =sysbus_mmio_get_region (SYS_BUS_DEVICE (dev),0 );memory_region_add_subregion (&s->mr_ps,MM_PMC_SD0 + i *MM_PMC_SD0_SIZE , mr); --2.26.2
PATCH 4/4 hw/arm/xilinx_zynq: Add SD bus QOM alias on the machine
In reply to Philippe Mathieu-DaudéTo be able to select a particular SD bus from the command line, add a QOM alias on the machine (using an unique name).
--- hw/arm/xilinx_zynq.c | 6 ++++++ 1 file changed, 6 insertions(+)
hw/arm/xilinx_zynq.c +6 -0
@@ -286,6 +286,7 @@ static void zynq_init(MachineState *machine)DriveInfo *di;BlockBackend *blk;DeviceState *carddev; + g_autofree char *bus_name = NULL;/* Compatible with: * - SD Host Controller Specification Version 2.0 Part A2
@@ -299,6 +300,11 @@ static void zynq_init(MachineState *machine)sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 , hci_addr);sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , pic[hci_irq -IRQ_OFFSET ]); +/* Alias controller SD bus to the machine itself */ + bus_name =g_strdup_printf ("sd-bus%d" , n); +object_property_add_alias (OBJECT (machine), bus_name, +OBJECT (dev),"sd-bus" ); + di =drive_get_next (IF_SD ); blk = di ?blk_by_legacy_dinfo (di) :NULL ; carddev =qdev_new (TYPE_SD_CARD );
Signature · 1 line
2.26.2
Re: [PATCH-for-5.2? 4/4] hw/arm/xilinx_zynq: Add SD bus QOM alias on the machine
Quoted 6 lines · Philippe Mathieu-Daudé
To be able to select a particular SD bus from the command line, add a QOM alias on the machine (using an unique name).
Suggested-by Peter Maydell <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 32 lines
--- hw/arm/xilinx_zynq.c | 6 ++++++ 1 file changed, 6 insertions(+)hw/arm/xilinx_zynq.c +6
-1@@ -286,6 +286,7 @@ static void zynq_init(MachineState *machine)DriveInfo *di;BlockBackend *blk;DeviceState *carddev; + g_autofree char *bus_name = NULL;/* Compatible with: * - SD Host Controller Specification Version 2.0 Part A2 @@ -299,6 +300,11 @@ static void zynq_init(MachineState *machine)sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 , hci_addr);sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 , pic[hci_irq -IRQ_OFFSET ]); +/* Alias controller SD bus to the machine itself */ + bus_name =g_strdup_printf ("sd-bus%d" , n); +object_property_add_alias (OBJECT (machine), bus_name, +OBJECT (dev),"sd-bus" ); + di =drive_get_next (IF_SD ); blk = di ?blk_by_legacy_dinfo (di) :NULL ; carddev =qdev_new (TYPE_SD_CARD ); --2.26.2
Quoted 5 lines · Philippe Mathieu-Daudé
Easy fix for LP#1895895 suggested by Peter.
As
TYPE_ASPEED_SDHCIcreates SDHCI inside a controller (not a SoC/machine) we don't bother modifying it yet.
So how on the command line do you specify plugging the SD card into one of the new aliases?
I tried (with the sabrelite machine):
-drive file=/tmp/sdcard.img,format=raw,id=mysdcard -device sd-card,drive=mysdcard,bus=sd-bus0
but QEMU gives the error:
qemu-system-arm: -device sd-card,drive=mysdcard,bus=sd-bus0: Bus 'sd-bus0' not found
Maybe my idea about the aliases turns out to be wrong ? :-(
thanks
-- PMM
Quoted 11 lines
Easy fix for LP#1895895 suggested by Peter.
As
TYPE_ASPEED_SDHCIcreates SDHCI inside a controller (not a SoC/machine) we don't bother modifying it yet.Philippe Mathieu-Daudé (4):
hw/arm/fsl-imx: Add SD bus QOM alias on the SoC hw/arm/exynos4210: Add SD bus QOM alias on the SoC hw/arm/xlnx-versal: Add SD bus QOM alias on the SoC hw/arm/xilinx_zynq: Add SD bus QOM alias on the machine
Quoted 6 lines
hw/arm/exynos4210.c | 5 +++++ hw/arm/fsl-imx25.c | 6 ++++++ hw/arm/fsl-imx6.c | 6 ++++++ hw/arm/xilinx_zynq.c | 6 ++++++ hw/arm/xlnx-versal.c | 5 +++++ 5 files changed, 28 insertions(+)
Ping