* [Qemu-devel] [PATCH 1/4] hw/arm/exynos4: Remove unuseful debug code
2019-05-20 21:43 [Qemu-devel] [PATCH 0/4] arm: exynos4: Add dma support for smdkc210 Philippe Mathieu-Daudé
@ 2019-05-20 21:43 ` Philippe Mathieu-Daudé
2019-05-20 21:47 ` Alistair Francis
2019-05-20 21:43 ` [Qemu-devel] [PATCH 2/4] hw/arm/exynos4: Use the IEC binary prefix definitions Philippe Mathieu-Daudé
` (3 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-20 21:43 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Igor Mitsyanko, Alistair Francis, qemu-arm,
Philippe Mathieu-Daudé,
Guenter Roeck
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/arm/exynos4_boards.c | 24 ------------------------
1 file changed, 24 deletions(-)
diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c
index ea8100f65a8..f0c24b7992e 100644
--- a/hw/arm/exynos4_boards.c
+++ b/hw/arm/exynos4_boards.c
@@ -35,20 +35,6 @@
#include "hw/net/lan9118.h"
#include "hw/boards.h"
-#undef DEBUG
-
-//#define DEBUG
-
-#ifdef DEBUG
- #undef PRINT_DEBUG
- #define PRINT_DEBUG(fmt, args...) \
- do { \
- fprintf(stderr, " [%s:%d] "fmt, __func__, __LINE__, ##args); \
- } while (0)
-#else
- #define PRINT_DEBUG(fmt, args...) do {} while (0)
-#endif
-
#define SMDK_LAN9118_BASE_ADDR 0x05000000
typedef enum Exynos4BoardType {
@@ -140,16 +126,6 @@ exynos4_boards_init_common(MachineState *machine,
exynos4_board_binfo.gic_cpu_if_addr =
EXYNOS4210_SMP_PRIVATE_BASE_ADDR + 0x100;
- PRINT_DEBUG("\n ram_size: %luMiB [0x%08lx]\n"
- " kernel_filename: %s\n"
- " kernel_cmdline: %s\n"
- " initrd_filename: %s\n",
- exynos4_board_ram_size[board_type] / 1048576,
- exynos4_board_ram_size[board_type],
- machine->kernel_filename,
- machine->kernel_cmdline,
- machine->initrd_filename);
-
exynos4_boards_init_ram(s, get_system_memory(),
exynos4_board_ram_size[board_type]);
--
2.20.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH 1/4] hw/arm/exynos4: Remove unuseful debug code
2019-05-20 21:43 ` [Qemu-devel] [PATCH 1/4] hw/arm/exynos4: Remove unuseful debug code Philippe Mathieu-Daudé
@ 2019-05-20 21:47 ` Alistair Francis
0 siblings, 0 replies; 9+ messages in thread
From: Alistair Francis @ 2019-05-20 21:47 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Peter Maydell, Igor Mitsyanko, Alistair Francis,
qemu-devel@nongnu.org Developers, qemu-arm, Guenter Roeck
On Mon, May 20, 2019 at 2:45 PM Philippe Mathieu-Daudé
<philmd@redhat.com> wrote:
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Alistair
> ---
> hw/arm/exynos4_boards.c | 24 ------------------------
> 1 file changed, 24 deletions(-)
>
> diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c
> index ea8100f65a8..f0c24b7992e 100644
> --- a/hw/arm/exynos4_boards.c
> +++ b/hw/arm/exynos4_boards.c
> @@ -35,20 +35,6 @@
> #include "hw/net/lan9118.h"
> #include "hw/boards.h"
>
> -#undef DEBUG
> -
> -//#define DEBUG
> -
> -#ifdef DEBUG
> - #undef PRINT_DEBUG
> - #define PRINT_DEBUG(fmt, args...) \
> - do { \
> - fprintf(stderr, " [%s:%d] "fmt, __func__, __LINE__, ##args); \
> - } while (0)
> -#else
> - #define PRINT_DEBUG(fmt, args...) do {} while (0)
> -#endif
> -
> #define SMDK_LAN9118_BASE_ADDR 0x05000000
>
> typedef enum Exynos4BoardType {
> @@ -140,16 +126,6 @@ exynos4_boards_init_common(MachineState *machine,
> exynos4_board_binfo.gic_cpu_if_addr =
> EXYNOS4210_SMP_PRIVATE_BASE_ADDR + 0x100;
>
> - PRINT_DEBUG("\n ram_size: %luMiB [0x%08lx]\n"
> - " kernel_filename: %s\n"
> - " kernel_cmdline: %s\n"
> - " initrd_filename: %s\n",
> - exynos4_board_ram_size[board_type] / 1048576,
> - exynos4_board_ram_size[board_type],
> - machine->kernel_filename,
> - machine->kernel_cmdline,
> - machine->initrd_filename);
> -
> exynos4_boards_init_ram(s, get_system_memory(),
> exynos4_board_ram_size[board_type]);
>
> --
> 2.20.1
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH 2/4] hw/arm/exynos4: Use the IEC binary prefix definitions
2019-05-20 21:43 [Qemu-devel] [PATCH 0/4] arm: exynos4: Add dma support for smdkc210 Philippe Mathieu-Daudé
2019-05-20 21:43 ` [Qemu-devel] [PATCH 1/4] hw/arm/exynos4: Remove unuseful debug code Philippe Mathieu-Daudé
@ 2019-05-20 21:43 ` Philippe Mathieu-Daudé
2019-05-20 21:48 ` Alistair Francis
2019-05-20 21:43 ` [Qemu-devel] [PATCH 3/4] hw/arm/exynos4210: Add DMA support for the Exynos4210 Philippe Mathieu-Daudé
` (2 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-20 21:43 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Igor Mitsyanko, Alistair Francis, qemu-arm,
Philippe Mathieu-Daudé,
Guenter Roeck
It eases code review, unit is explicit.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/arm/exynos4_boards.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c
index f0c24b7992e..f824eef0d36 100644
--- a/hw/arm/exynos4_boards.c
+++ b/hw/arm/exynos4_boards.c
@@ -22,6 +22,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/units.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
#include "qemu-common.h"
@@ -60,8 +61,8 @@ static int exynos4_board_smp_bootreg_addr[EXYNOS4_NUM_OF_BOARDS] = {
};
static unsigned long exynos4_board_ram_size[EXYNOS4_NUM_OF_BOARDS] = {
- [EXYNOS4_BOARD_NURI] = 0x40000000,
- [EXYNOS4_BOARD_SMDKC210] = 0x40000000,
+ [EXYNOS4_BOARD_NURI] = 1 * GiB,
+ [EXYNOS4_BOARD_SMDKC210] = 1 * GiB,
};
static struct arm_boot_info exynos4_board_binfo = {
--
2.20.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH 2/4] hw/arm/exynos4: Use the IEC binary prefix definitions
2019-05-20 21:43 ` [Qemu-devel] [PATCH 2/4] hw/arm/exynos4: Use the IEC binary prefix definitions Philippe Mathieu-Daudé
@ 2019-05-20 21:48 ` Alistair Francis
0 siblings, 0 replies; 9+ messages in thread
From: Alistair Francis @ 2019-05-20 21:48 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Peter Maydell, Igor Mitsyanko, Alistair Francis,
qemu-devel@nongnu.org Developers, qemu-arm, Guenter Roeck
On Mon, May 20, 2019 at 2:48 PM Philippe Mathieu-Daudé
<philmd@redhat.com> wrote:
>
> It eases code review, unit is explicit.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Alistair
> ---
> hw/arm/exynos4_boards.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c
> index f0c24b7992e..f824eef0d36 100644
> --- a/hw/arm/exynos4_boards.c
> +++ b/hw/arm/exynos4_boards.c
> @@ -22,6 +22,7 @@
> */
>
> #include "qemu/osdep.h"
> +#include "qemu/units.h"
> #include "qapi/error.h"
> #include "qemu/error-report.h"
> #include "qemu-common.h"
> @@ -60,8 +61,8 @@ static int exynos4_board_smp_bootreg_addr[EXYNOS4_NUM_OF_BOARDS] = {
> };
>
> static unsigned long exynos4_board_ram_size[EXYNOS4_NUM_OF_BOARDS] = {
> - [EXYNOS4_BOARD_NURI] = 0x40000000,
> - [EXYNOS4_BOARD_SMDKC210] = 0x40000000,
> + [EXYNOS4_BOARD_NURI] = 1 * GiB,
> + [EXYNOS4_BOARD_SMDKC210] = 1 * GiB,
> };
>
> static struct arm_boot_info exynos4_board_binfo = {
> --
> 2.20.1
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH 3/4] hw/arm/exynos4210: Add DMA support for the Exynos4210
2019-05-20 21:43 [Qemu-devel] [PATCH 0/4] arm: exynos4: Add dma support for smdkc210 Philippe Mathieu-Daudé
2019-05-20 21:43 ` [Qemu-devel] [PATCH 1/4] hw/arm/exynos4: Remove unuseful debug code Philippe Mathieu-Daudé
2019-05-20 21:43 ` [Qemu-devel] [PATCH 2/4] hw/arm/exynos4: Use the IEC binary prefix definitions Philippe Mathieu-Daudé
@ 2019-05-20 21:43 ` Philippe Mathieu-Daudé
2019-05-20 21:43 ` [Qemu-devel] [PATCH 4/4] hw/arm/exynos4210: QOM'ify the Exynos4210 SoC Philippe Mathieu-Daudé
2019-05-23 12:57 ` [Qemu-devel] [PATCH 0/4] arm: exynos4: Add dma support for smdkc210 Peter Maydell
4 siblings, 0 replies; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-20 21:43 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Igor Mitsyanko, Alistair Francis, qemu-arm,
Alistair Francis, Philippe Mathieu-Daudé,
Guenter Roeck
From: Guenter Roeck <linux@roeck-us.net>
QEMU already supports pl330. Instantiate it for Exynos4210.
Relevant part of Linux arch/arm/boot/dts/exynos4.dtsi:
/ {
soc: soc {
amba {
pdma0: pdma@12680000 {
compatible = "arm,pl330", "arm,primecell";
reg = <0x12680000 0x1000>;
interrupts = <GIC_SPI 35 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clock CLK_PDMA0>;
clock-names = "apb_pclk";
#dma-cells = <1>;
#dma-channels = <8>;
#dma-requests = <32>;
};
pdma1: pdma@12690000 {
compatible = "arm,pl330", "arm,primecell";
reg = <0x12690000 0x1000>;
interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clock CLK_PDMA1>;
clock-names = "apb_pclk";
#dma-cells = <1>;
#dma-channels = <8>;
#dma-requests = <32>;
};
mdma1: mdma@12850000 {
compatible = "arm,pl330", "arm,primecell";
reg = <0x12850000 0x1000>;
interrupts = <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clock CLK_MDMA>;
clock-names = "apb_pclk";
#dma-cells = <1>;
#dma-channels = <8>;
#dma-requests = <1>;
};
};
};
};
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
[PMD: Do not set default qdev properties, create the controllers in the SoC
rather than the board (Peter Maydell), add dtsi in commit message]
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
---
No SoC datasheet available, Guenter got it working using the
"look into the Linux kernel code and then play with parameters
until it magically starts working" method.
---
hw/arm/exynos4210.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
index af82e955421..19009b76e7c 100644
--- a/hw/arm/exynos4210.c
+++ b/hw/arm/exynos4210.c
@@ -96,6 +96,11 @@
/* EHCI */
#define EXYNOS4210_EHCI_BASE_ADDR 0x12580000
+/* DMA */
+#define EXYNOS4210_PL330_BASE0_ADDR 0x12680000
+#define EXYNOS4210_PL330_BASE1_ADDR 0x12690000
+#define EXYNOS4210_PL330_BASE2_ADDR 0x12850000
+
static uint8_t chipid_and_omr[] = { 0x11, 0x02, 0x21, 0x43,
0x09, 0x00, 0x00, 0x00 };
@@ -160,6 +165,19 @@ static uint64_t exynos4210_calc_affinity(int cpu)
return (0x9 << ARM_AFF1_SHIFT) | cpu;
}
+static void pl330_create(uint32_t base, qemu_irq irq, int nreq)
+{
+ SysBusDevice *busdev;
+ DeviceState *dev;
+
+ dev = qdev_create(NULL, "pl330");
+ qdev_prop_set_uint8(dev, "num_periph_req", nreq);
+ qdev_init_nofail(dev);
+ busdev = SYS_BUS_DEVICE(dev);
+ sysbus_mmio_map(busdev, 0, base);
+ sysbus_connect_irq(busdev, 0, irq);
+}
+
Exynos4210State *exynos4210_init(MemoryRegion *system_mem)
{
Exynos4210State *s = g_new0(Exynos4210State, 1);
@@ -410,5 +428,13 @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem)
sysbus_create_simple(TYPE_EXYNOS4210_EHCI, EXYNOS4210_EHCI_BASE_ADDR,
s->irq_table[exynos4210_get_irq(28, 3)]);
+ /*** DMA controllers ***/
+ pl330_create(EXYNOS4210_PL330_BASE0_ADDR,
+ qemu_irq_invert(s->irq_table[exynos4210_get_irq(35, 1)]), 32);
+ pl330_create(EXYNOS4210_PL330_BASE1_ADDR,
+ qemu_irq_invert(s->irq_table[exynos4210_get_irq(36, 1)]), 32);
+ pl330_create(EXYNOS4210_PL330_BASE2_ADDR,
+ qemu_irq_invert(s->irq_table[exynos4210_get_irq(34, 1)]), 1);
+
return s;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH 4/4] hw/arm/exynos4210: QOM'ify the Exynos4210 SoC
2019-05-20 21:43 [Qemu-devel] [PATCH 0/4] arm: exynos4: Add dma support for smdkc210 Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2019-05-20 21:43 ` [Qemu-devel] [PATCH 3/4] hw/arm/exynos4210: Add DMA support for the Exynos4210 Philippe Mathieu-Daudé
@ 2019-05-20 21:43 ` Philippe Mathieu-Daudé
2019-05-22 22:46 ` Alistair Francis
2019-05-23 12:57 ` [Qemu-devel] [PATCH 0/4] arm: exynos4: Add dma support for smdkc210 Peter Maydell
4 siblings, 1 reply; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-20 21:43 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Igor Mitsyanko, Alistair Francis, qemu-arm,
Philippe Mathieu-Daudé,
Guenter Roeck
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/arm/exynos4210.c | 26 +++++++++++++++++++++++---
hw/arm/exynos4_boards.c | 9 ++++++---
include/hw/arm/exynos4210.h | 9 +++++++--
3 files changed, 36 insertions(+), 8 deletions(-)
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
index 19009b76e7c..0b09129eff8 100644
--- a/hw/arm/exynos4210.c
+++ b/hw/arm/exynos4210.c
@@ -178,9 +178,10 @@ static void pl330_create(uint32_t base, qemu_irq irq, int nreq)
sysbus_connect_irq(busdev, 0, irq);
}
-Exynos4210State *exynos4210_init(MemoryRegion *system_mem)
+static void exynos4210_realize(DeviceState *socdev, Error **errp)
{
- Exynos4210State *s = g_new0(Exynos4210State, 1);
+ Exynos4210State *s = EXYNOS4210_SOC(socdev);
+ MemoryRegion *system_mem = get_system_memory();
qemu_irq gate_irq[EXYNOS4210_NCPUS][EXYNOS4210_IRQ_GATE_NINPUTS];
SysBusDevice *busdev;
DeviceState *dev;
@@ -435,6 +436,25 @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem)
qemu_irq_invert(s->irq_table[exynos4210_get_irq(36, 1)]), 32);
pl330_create(EXYNOS4210_PL330_BASE2_ADDR,
qemu_irq_invert(s->irq_table[exynos4210_get_irq(34, 1)]), 1);
+}
+
+static void exynos4210_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
- return s;
+ dc->realize = exynos4210_realize;
}
+
+static const TypeInfo exynos4210_info = {
+ .name = TYPE_EXYNOS4210_SOC,
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .instance_size = sizeof(Exynos4210State),
+ .class_init = exynos4210_class_init,
+};
+
+static void exynos4210_register_types(void)
+{
+ type_register_static(&exynos4210_info);
+}
+
+type_init(exynos4210_register_types)
diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c
index f824eef0d36..700e90d6671 100644
--- a/hw/arm/exynos4_boards.c
+++ b/hw/arm/exynos4_boards.c
@@ -45,7 +45,7 @@ typedef enum Exynos4BoardType {
} Exynos4BoardType;
typedef struct Exynos4BoardState {
- Exynos4210State *soc;
+ Exynos4210State soc;
MemoryRegion dram0_mem;
MemoryRegion dram1_mem;
} Exynos4BoardState;
@@ -130,7 +130,10 @@ exynos4_boards_init_common(MachineState *machine,
exynos4_boards_init_ram(s, get_system_memory(),
exynos4_board_ram_size[board_type]);
- s->soc = exynos4210_init(get_system_memory());
+ object_initialize(&s->soc, sizeof(s->soc), TYPE_EXYNOS4210_SOC);
+ qdev_set_parent_bus(DEVICE(&s->soc), sysbus_get_default());
+ object_property_set_bool(OBJECT(&s->soc), true, "realized",
+ &error_fatal);
return s;
}
@@ -148,7 +151,7 @@ static void smdkc210_init(MachineState *machine)
EXYNOS4_BOARD_SMDKC210);
lan9215_init(SMDK_LAN9118_BASE_ADDR,
- qemu_irq_invert(s->soc->irq_table[exynos4210_get_irq(37, 1)]));
+ qemu_irq_invert(s->soc.irq_table[exynos4210_get_irq(37, 1)]));
arm_load_kernel(ARM_CPU(first_cpu), &exynos4_board_binfo);
}
diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h
index 098a69ec73d..27c684e851d 100644
--- a/include/hw/arm/exynos4210.h
+++ b/include/hw/arm/exynos4210.h
@@ -85,6 +85,9 @@ typedef struct Exynos4210Irq {
} Exynos4210Irq;
typedef struct Exynos4210State {
+ /*< private >*/
+ SysBusDevice parent_obj;
+ /*< public >*/
ARMCPU *cpu[EXYNOS4210_NCPUS];
Exynos4210Irq irqs;
qemu_irq *irq_table;
@@ -98,11 +101,13 @@ typedef struct Exynos4210State {
I2CBus *i2c_if[EXYNOS4210_I2C_NUMBER];
} Exynos4210State;
+#define TYPE_EXYNOS4210_SOC "exynos4210"
+#define EXYNOS4210_SOC(obj) \
+ OBJECT_CHECK(Exynos4210State, obj, TYPE_EXYNOS4210_SOC)
+
void exynos4210_write_secondary(ARMCPU *cpu,
const struct arm_boot_info *info);
-Exynos4210State *exynos4210_init(MemoryRegion *system_mem);
-
/* Initialize exynos4210 IRQ subsystem stub */
qemu_irq *exynos4210_init_irq(Exynos4210Irq *env);
--
2.20.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH 4/4] hw/arm/exynos4210: QOM'ify the Exynos4210 SoC
2019-05-20 21:43 ` [Qemu-devel] [PATCH 4/4] hw/arm/exynos4210: QOM'ify the Exynos4210 SoC Philippe Mathieu-Daudé
@ 2019-05-22 22:46 ` Alistair Francis
0 siblings, 0 replies; 9+ messages in thread
From: Alistair Francis @ 2019-05-22 22:46 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Peter Maydell, Igor Mitsyanko, Alistair Francis,
qemu-devel@nongnu.org Developers, qemu-arm, Guenter Roeck
On Mon, May 20, 2019 at 2:47 PM Philippe Mathieu-Daudé
<philmd@redhat.com> wrote:
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Alistair
> ---
> hw/arm/exynos4210.c | 26 +++++++++++++++++++++++---
> hw/arm/exynos4_boards.c | 9 ++++++---
> include/hw/arm/exynos4210.h | 9 +++++++--
> 3 files changed, 36 insertions(+), 8 deletions(-)
>
> diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
> index 19009b76e7c..0b09129eff8 100644
> --- a/hw/arm/exynos4210.c
> +++ b/hw/arm/exynos4210.c
> @@ -178,9 +178,10 @@ static void pl330_create(uint32_t base, qemu_irq irq, int nreq)
> sysbus_connect_irq(busdev, 0, irq);
> }
>
> -Exynos4210State *exynos4210_init(MemoryRegion *system_mem)
> +static void exynos4210_realize(DeviceState *socdev, Error **errp)
> {
> - Exynos4210State *s = g_new0(Exynos4210State, 1);
> + Exynos4210State *s = EXYNOS4210_SOC(socdev);
> + MemoryRegion *system_mem = get_system_memory();
> qemu_irq gate_irq[EXYNOS4210_NCPUS][EXYNOS4210_IRQ_GATE_NINPUTS];
> SysBusDevice *busdev;
> DeviceState *dev;
> @@ -435,6 +436,25 @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem)
> qemu_irq_invert(s->irq_table[exynos4210_get_irq(36, 1)]), 32);
> pl330_create(EXYNOS4210_PL330_BASE2_ADDR,
> qemu_irq_invert(s->irq_table[exynos4210_get_irq(34, 1)]), 1);
> +}
> +
> +static void exynos4210_class_init(ObjectClass *klass, void *data)
> +{
> + DeviceClass *dc = DEVICE_CLASS(klass);
>
> - return s;
> + dc->realize = exynos4210_realize;
> }
> +
> +static const TypeInfo exynos4210_info = {
> + .name = TYPE_EXYNOS4210_SOC,
> + .parent = TYPE_SYS_BUS_DEVICE,
> + .instance_size = sizeof(Exynos4210State),
> + .class_init = exynos4210_class_init,
> +};
> +
> +static void exynos4210_register_types(void)
> +{
> + type_register_static(&exynos4210_info);
> +}
> +
> +type_init(exynos4210_register_types)
> diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c
> index f824eef0d36..700e90d6671 100644
> --- a/hw/arm/exynos4_boards.c
> +++ b/hw/arm/exynos4_boards.c
> @@ -45,7 +45,7 @@ typedef enum Exynos4BoardType {
> } Exynos4BoardType;
>
> typedef struct Exynos4BoardState {
> - Exynos4210State *soc;
> + Exynos4210State soc;
> MemoryRegion dram0_mem;
> MemoryRegion dram1_mem;
> } Exynos4BoardState;
> @@ -130,7 +130,10 @@ exynos4_boards_init_common(MachineState *machine,
> exynos4_boards_init_ram(s, get_system_memory(),
> exynos4_board_ram_size[board_type]);
>
> - s->soc = exynos4210_init(get_system_memory());
> + object_initialize(&s->soc, sizeof(s->soc), TYPE_EXYNOS4210_SOC);
> + qdev_set_parent_bus(DEVICE(&s->soc), sysbus_get_default());
> + object_property_set_bool(OBJECT(&s->soc), true, "realized",
> + &error_fatal);
>
> return s;
> }
> @@ -148,7 +151,7 @@ static void smdkc210_init(MachineState *machine)
> EXYNOS4_BOARD_SMDKC210);
>
> lan9215_init(SMDK_LAN9118_BASE_ADDR,
> - qemu_irq_invert(s->soc->irq_table[exynos4210_get_irq(37, 1)]));
> + qemu_irq_invert(s->soc.irq_table[exynos4210_get_irq(37, 1)]));
> arm_load_kernel(ARM_CPU(first_cpu), &exynos4_board_binfo);
> }
>
> diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h
> index 098a69ec73d..27c684e851d 100644
> --- a/include/hw/arm/exynos4210.h
> +++ b/include/hw/arm/exynos4210.h
> @@ -85,6 +85,9 @@ typedef struct Exynos4210Irq {
> } Exynos4210Irq;
>
> typedef struct Exynos4210State {
> + /*< private >*/
> + SysBusDevice parent_obj;
> + /*< public >*/
> ARMCPU *cpu[EXYNOS4210_NCPUS];
> Exynos4210Irq irqs;
> qemu_irq *irq_table;
> @@ -98,11 +101,13 @@ typedef struct Exynos4210State {
> I2CBus *i2c_if[EXYNOS4210_I2C_NUMBER];
> } Exynos4210State;
>
> +#define TYPE_EXYNOS4210_SOC "exynos4210"
> +#define EXYNOS4210_SOC(obj) \
> + OBJECT_CHECK(Exynos4210State, obj, TYPE_EXYNOS4210_SOC)
> +
> void exynos4210_write_secondary(ARMCPU *cpu,
> const struct arm_boot_info *info);
>
> -Exynos4210State *exynos4210_init(MemoryRegion *system_mem);
> -
> /* Initialize exynos4210 IRQ subsystem stub */
> qemu_irq *exynos4210_init_irq(Exynos4210Irq *env);
>
> --
> 2.20.1
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH 0/4] arm: exynos4: Add dma support for smdkc210
2019-05-20 21:43 [Qemu-devel] [PATCH 0/4] arm: exynos4: Add dma support for smdkc210 Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2019-05-20 21:43 ` [Qemu-devel] [PATCH 4/4] hw/arm/exynos4210: QOM'ify the Exynos4210 SoC Philippe Mathieu-Daudé
@ 2019-05-23 12:57 ` Peter Maydell
4 siblings, 0 replies; 9+ messages in thread
From: Peter Maydell @ 2019-05-23 12:57 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Igor Mitsyanko, Alistair Francis, qemu-arm, QEMU Developers,
Guenter Roeck
On Mon, 20 May 2019 at 22:43, Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
>
> Another intent to salvage previous work from Guenter Roeck:
> https://lists.gnu.org/archive/html/qemu-devel/2018-10/msg06302.html
>
> Since v3: https://lists.gnu.org/archive/html/qemu-devel/2018-10/msg06674.html
> - rebased
> - QOM'ify the SoC code
>
> Since v2: https://lists.gnu.org/archive/html/qemu-devel/2018-10/msg06459.html
> - rename init -> create
> - create controllers in SoC rather than the board (Peter Maydell)
> - add Linux dtsi in commit message
>
> Since v1: https://lists.gnu.org/archive/html/qemu-devel/2018-10/msg06335.html
> - Do not factor out pl330_init, which resulted in buggy v1, see:
> https://lists.gnu.org/archive/html/qemu-devel/2018-10/msg06448.html
>
> Guenter Roeck (1):
> hw/arm/exynos4210: Add DMA support for the Exynos4210
>
> Philippe Mathieu-Daudé (3):
> hw/arm/exynos4: Remove unuseful debug code
> hw/arm/exynos4: Use the IEC binary prefix definitions
> hw/arm/exynos4210: QOM'ify the Exynos4210 SoC
Applied to target-arm.next, thanks.
-- PMM
^ permalink raw reply [flat|nested] 9+ messages in thread