* [PATCH 0/2] hw/arm: fsl-imx25: Connect eSDHC and USB controllers
@ 2020-03-10 21:51 Guenter Roeck
2020-03-10 21:51 ` [PATCH 1/2] hw/arm: fsl-imx25: Wire up eSDHC controllers Guenter Roeck
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Guenter Roeck @ 2020-03-10 21:51 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-arm, qemu-devel, Guenter Roeck, Jean-Christophe Dubois
The following two patches wire up eSDHC and USB controllers for fsl-imx25.
With these patches in place, the imx25-pdk emulation can boot from SD cards
and from USB.
----------------------------------------------------------------
Guenter Roeck (2):
hw/arm: fsl-imx25: Wire up eSDHC controllers
hw/arm/fsl-imx25: Wire up USB controllers
hw/arm/fsl-imx25.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++
hw/arm/imx25_pdk.c | 16 +++++++++++++
include/hw/arm/fsl-imx25.h | 18 +++++++++++++++
3 files changed, 90 insertions(+)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] hw/arm: fsl-imx25: Wire up eSDHC controllers
2020-03-10 21:51 [PATCH 0/2] hw/arm: fsl-imx25: Connect eSDHC and USB controllers Guenter Roeck
@ 2020-03-10 21:51 ` Guenter Roeck
2020-03-10 21:51 ` [PATCH 2/2] hw/arm/fsl-imx25: Wire up USB controllers Guenter Roeck
2020-03-12 13:41 ` [PATCH 0/2] hw/arm: fsl-imx25: Connect eSDHC and " Peter Maydell
2 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2020-03-10 21:51 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-arm, qemu-devel, Guenter Roeck, Jean-Christophe Dubois
Wire up eSDHC controllers in fsl-imx25. For imx25-pdk, connect drives
provided on the command line to available eSDHC controllers.
This patch enables booting the imx25-pdk emulation from SD card.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
hw/arm/fsl-imx25.c | 32 ++++++++++++++++++++++++++++++++
hw/arm/imx25_pdk.c | 16 ++++++++++++++++
include/hw/arm/fsl-imx25.h | 9 +++++++++
3 files changed, 57 insertions(+)
diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c
index da3471b395..f977c42426 100644
--- a/hw/arm/fsl-imx25.c
+++ b/hw/arm/fsl-imx25.c
@@ -31,6 +31,8 @@
#include "hw/qdev-properties.h"
#include "chardev/char.h"
+#define IMX25_ESDHC_CAPABILITIES 0x07e20000
+
static void fsl_imx25_init(Object *obj)
{
FslIMX25State *s = FSL_IMX25(obj);
@@ -74,6 +76,11 @@ static void fsl_imx25_init(Object *obj)
sysbus_init_child_obj(obj, "gpio[*]", &s->gpio[i], sizeof(s->gpio[i]),
TYPE_IMX_GPIO);
}
+
+ for (i = 0; i < FSL_IMX25_NUM_ESDHCS; i++) {
+ sysbus_init_child_obj(obj, "sdhc[*]", &s->esdhc[i], sizeof(s->esdhc[i]),
+ TYPE_IMX_USDHC);
+ }
}
static void fsl_imx25_realize(DeviceState *dev, Error **errp)
@@ -246,6 +253,31 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
gpio_table[i].irq));
}
+ /* Initialize all SDHC */
+ for (i = 0; i < FSL_IMX25_NUM_ESDHCS; i++) {
+ static const struct {
+ hwaddr addr;
+ unsigned int irq;
+ } esdhc_table[FSL_IMX25_NUM_ESDHCS] = {
+ { FSL_IMX25_ESDHC1_ADDR, FSL_IMX25_ESDHC1_IRQ },
+ { FSL_IMX25_ESDHC2_ADDR, FSL_IMX25_ESDHC2_IRQ },
+ };
+
+ object_property_set_uint(OBJECT(&s->esdhc[i]), 2, "sd-spec-version",
+ &err);
+ object_property_set_uint(OBJECT(&s->esdhc[i]), IMX25_ESDHC_CAPABILITIES,
+ "capareg", &err);
+ 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(&s->rom[0], NULL,
"imx25.rom0", FSL_IMX25_ROM0_SIZE, &err);
diff --git a/hw/arm/imx25_pdk.c b/hw/arm/imx25_pdk.c
index 26713d9a7e..b3ca82bafa 100644
--- a/hw/arm/imx25_pdk.c
+++ b/hw/arm/imx25_pdk.c
@@ -26,6 +26,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "cpu.h"
+#include "hw/qdev-properties.h"
#include "hw/arm/fsl-imx25.h"
#include "hw/boards.h"
#include "qemu/error-report.h"
@@ -120,6 +121,21 @@ static void imx25_pdk_init(MachineState *machine)
imx25_pdk_binfo.board_id = 1771,
imx25_pdk_binfo.nb_cpus = 1;
+ for (i = 0; i < FSL_IMX25_NUM_ESDHCS; i++) {
+ BusState *bus;
+ DeviceState *carddev;
+ DriveInfo *di;
+ BlockBackend *blk;
+
+ di = drive_get_next(IF_SD);
+ blk = di ? blk_by_legacy_dinfo(di) : NULL;
+ bus = qdev_get_child_bus(DEVICE(&s->soc.esdhc[i]), "sd-bus");
+ carddev = qdev_create(bus, TYPE_SD_CARD);
+ qdev_prop_set_drive(carddev, "drive", blk, &error_fatal);
+ object_property_set_bool(OBJECT(carddev), true,
+ "realized", &error_fatal);
+ }
+
/*
* We test explicitly for qtest here as it is not done (yet?) in
* arm_load_kernel(). Without this the "make check" command would
diff --git a/include/hw/arm/fsl-imx25.h b/include/hw/arm/fsl-imx25.h
index 1c86bb55fb..4e2d4868cd 100644
--- a/include/hw/arm/fsl-imx25.h
+++ b/include/hw/arm/fsl-imx25.h
@@ -27,6 +27,7 @@
#include "hw/misc/imx_rngc.h"
#include "hw/i2c/imx_i2c.h"
#include "hw/gpio/imx_gpio.h"
+#include "hw/sd/sdhci.h"
#include "exec/memory.h"
#include "target/arm/cpu.h"
@@ -38,6 +39,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
typedef struct FslIMX25State {
/*< private >*/
@@ -54,6 +56,7 @@ typedef struct FslIMX25State {
IMXRNGCState rngc;
IMXI2CState i2c[FSL_IMX25_NUM_I2CS];
IMXGPIOState gpio[FSL_IMX25_NUM_GPIOS];
+ SDHCIState esdhc[FSL_IMX25_NUM_ESDHCS];
MemoryRegion rom[2];
MemoryRegion iram;
MemoryRegion iram_alias;
@@ -215,6 +218,10 @@ typedef struct FslIMX25State {
#define FSL_IMX25_GPIO3_SIZE 0x4000
#define FSL_IMX25_RNGC_ADDR 0x53FB0000
#define FSL_IMX25_RNGC_SIZE 0x4000
+#define FSL_IMX25_ESDHC1_ADDR 0x53FB4000
+#define FSL_IMX25_ESDHC1_SIZE 0x4000
+#define FSL_IMX25_ESDHC2_ADDR 0x53FB8000
+#define FSL_IMX25_ESDHC2_SIZE 0x4000
#define FSL_IMX25_GPIO1_ADDR 0x53FCC000
#define FSL_IMX25_GPIO1_SIZE 0x4000
#define FSL_IMX25_GPIO2_ADDR 0x53FD0000
@@ -250,5 +257,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
#endif /* FSL_IMX25_H */
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] hw/arm/fsl-imx25: Wire up USB controllers
2020-03-10 21:51 [PATCH 0/2] hw/arm: fsl-imx25: Connect eSDHC and USB controllers Guenter Roeck
2020-03-10 21:51 ` [PATCH 1/2] hw/arm: fsl-imx25: Wire up eSDHC controllers Guenter Roeck
@ 2020-03-10 21:51 ` Guenter Roeck
2020-03-12 13:41 ` [PATCH 0/2] hw/arm: fsl-imx25: Connect eSDHC and " Peter Maydell
2 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2020-03-10 21:51 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-arm, qemu-devel, Guenter Roeck, Jean-Christophe Dubois
i.MX25 supports two USB controllers. Let's wire them up.
With this patch, imx25-pdk can boot from both USB ports.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
hw/arm/fsl-imx25.c | 24 ++++++++++++++++++++++++
include/hw/arm/fsl-imx25.h | 9 +++++++++
2 files changed, 33 insertions(+)
diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c
index f977c42426..a3f829f436 100644
--- a/hw/arm/fsl-imx25.c
+++ b/hw/arm/fsl-imx25.c
@@ -81,6 +81,12 @@ static void fsl_imx25_init(Object *obj)
sysbus_init_child_obj(obj, "sdhc[*]", &s->esdhc[i], sizeof(s->esdhc[i]),
TYPE_IMX_USDHC);
}
+
+ for (i = 0; i < FSL_IMX25_NUM_USBS; i++) {
+ sysbus_init_child_obj(obj, "usb[*]", &s->usb[i], sizeof(s->usb[i]),
+ TYPE_CHIPIDEA);
+ }
+
}
static void fsl_imx25_realize(DeviceState *dev, Error **errp)
@@ -278,6 +284,24 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
esdhc_table[i].irq));
}
+ /* USB */
+ for (i = 0; i < FSL_IMX25_NUM_USBS; i++) {
+ static const struct {
+ hwaddr addr;
+ unsigned int irq;
+ } usb_table[FSL_IMX25_NUM_USBS] = {
+ { FSL_IMX25_USB1_ADDR, FSL_IMX25_USB1_IRQ },
+ { FSL_IMX25_USB2_ADDR, FSL_IMX25_USB2_IRQ },
+ };
+
+ object_property_set_bool(OBJECT(&s->usb[i]), true, "realized",
+ &error_abort);
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->usb[i]), 0, usb_table[i].addr);
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->usb[i]), 0,
+ qdev_get_gpio_in(DEVICE(&s->avic),
+ usb_table[i].irq));
+ }
+
/* initialize 2 x 16 KB ROM */
memory_region_init_rom(&s->rom[0], 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 4e2d4868cd..5e196bbf05 100644
--- a/include/hw/arm/fsl-imx25.h
+++ b/include/hw/arm/fsl-imx25.h
@@ -28,6 +28,7 @@
#include "hw/i2c/imx_i2c.h"
#include "hw/gpio/imx_gpio.h"
#include "hw/sd/sdhci.h"
+#include "hw/usb/chipidea.h"
#include "exec/memory.h"
#include "target/arm/cpu.h"
@@ -40,6 +41,7 @@
#define FSL_IMX25_NUM_I2CS 3
#define FSL_IMX25_NUM_GPIOS 4
#define FSL_IMX25_NUM_ESDHCS 2
+#define FSL_IMX25_NUM_USBS 2
typedef struct FslIMX25State {
/*< private >*/
@@ -57,6 +59,7 @@ typedef struct FslIMX25State {
IMXI2CState i2c[FSL_IMX25_NUM_I2CS];
IMXGPIOState gpio[FSL_IMX25_NUM_GPIOS];
SDHCIState esdhc[FSL_IMX25_NUM_ESDHCS];
+ ChipideaState usb[FSL_IMX25_NUM_USBS];
MemoryRegion rom[2];
MemoryRegion iram;
MemoryRegion iram_alias;
@@ -226,6 +229,10 @@ typedef struct FslIMX25State {
#define FSL_IMX25_GPIO1_SIZE 0x4000
#define FSL_IMX25_GPIO2_ADDR 0x53FD0000
#define FSL_IMX25_GPIO2_SIZE 0x4000
+#define FSL_IMX25_USB1_ADDR 0x53FF4000
+#define FSL_IMX25_USB1_SIZE 0x0200
+#define FSL_IMX25_USB2_ADDR 0x53FF4400
+#define FSL_IMX25_USB2_SIZE 0x0200
#define FSL_IMX25_AVIC_ADDR 0x68000000
#define FSL_IMX25_AVIC_SIZE 0x4000
#define FSL_IMX25_IRAM_ADDR 0x78000000
@@ -259,5 +266,7 @@ typedef struct FslIMX25State {
#define FSL_IMX25_GPIO4_IRQ 23
#define FSL_IMX25_ESDHC1_IRQ 9
#define FSL_IMX25_ESDHC2_IRQ 8
+#define FSL_IMX25_USB1_IRQ 37
+#define FSL_IMX25_USB2_IRQ 35
#endif /* FSL_IMX25_H */
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] hw/arm: fsl-imx25: Connect eSDHC and USB controllers
2020-03-10 21:51 [PATCH 0/2] hw/arm: fsl-imx25: Connect eSDHC and USB controllers Guenter Roeck
2020-03-10 21:51 ` [PATCH 1/2] hw/arm: fsl-imx25: Wire up eSDHC controllers Guenter Roeck
2020-03-10 21:51 ` [PATCH 2/2] hw/arm/fsl-imx25: Wire up USB controllers Guenter Roeck
@ 2020-03-12 13:41 ` Peter Maydell
2 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2020-03-12 13:41 UTC (permalink / raw)
To: Guenter Roeck; +Cc: qemu-arm, QEMU Developers, Jean-Christophe Dubois
On Tue, 10 Mar 2020 at 21:51, Guenter Roeck <linux@roeck-us.net> wrote:
>
> The following two patches wire up eSDHC and USB controllers for fsl-imx25.
> With these patches in place, the imx25-pdk emulation can boot from SD cards
> and from USB.
>
> ----------------------------------------------------------------
> Guenter Roeck (2):
> hw/arm: fsl-imx25: Wire up eSDHC controllers
> hw/arm/fsl-imx25: Wire up USB controllers
Applied to target-arm.next, thanks.
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-03-12 13:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-10 21:51 [PATCH 0/2] hw/arm: fsl-imx25: Connect eSDHC and USB controllers Guenter Roeck
2020-03-10 21:51 ` [PATCH 1/2] hw/arm: fsl-imx25: Wire up eSDHC controllers Guenter Roeck
2020-03-10 21:51 ` [PATCH 2/2] hw/arm/fsl-imx25: Wire up USB controllers Guenter Roeck
2020-03-12 13:41 ` [PATCH 0/2] hw/arm: fsl-imx25: Connect eSDHC and " Peter Maydell
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.