qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Jeffery <andrew@aj.id.au>
To: "Cédric Le Goater" <clg@kaod.org>,
	"Peter Maydell" <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, qemu-arm@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v3 03/10] aspeed-soc: provide a framework to add new SoCs
Date: Wed, 03 Aug 2016 09:16:48 +0930	[thread overview]
Message-ID: <1470181608.4428.36.camel@aj.id.au> (raw)
In-Reply-To: <1470158147-16378-4-git-send-email-clg@kaod.org>

[-- Attachment #1: Type: text/plain, Size: 7252 bytes --]

On Tue, 2016-08-02 at 19:15 +0200, Cédric Le Goater wrote:
> Let's define an object class for each Aspeed SoC we support. A
> AspeedSoCInfo struct gathers the SoC specifications which can later
> be
> used by an instance of the class or by a board using the SoC.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>

Reviewed-by: Andrew Jeffery <andrew@aj.id.au>

> ---
>  hw/arm/aspeed_soc.c         | 27 ++++++++++++++++++++++++---
>  hw/arm/palmetto-bmc.c       | 12 ++++++++----
>  include/hw/arm/aspeed_soc.h | 17 ++++++++++++++++-
>  3 files changed, 48 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
> index 1bec478fef68..ec6ec3546908 100644
> --- a/hw/arm/aspeed_soc.c
> +++ b/hw/arm/aspeed_soc.c
> @@ -37,6 +37,13 @@
>  static const int uart_irqs[] = { 9, 32, 33, 34, 10 };
>  static const int timer_irqs[] = { 16, 17, 18, 35, 36, 37, 38, 39, };
>  
> +#define AST2400_SDRAM_BASE       0x40000000
> +
> +static const AspeedSoCInfo aspeed_socs[] = {
> +    { "ast2400-a0", "arm926", AST2400_A0_SILICON_REV,
> AST2400_SDRAM_BASE },
> +    { "ast2400",    "arm926", AST2400_A0_SILICON_REV,
> AST2400_SDRAM_BASE },
> +};
> +
>  /*
>   * IO handlers: simply catch any reads/writes to IO addresses that
> aren't
>   * handled by a device mapping.
> @@ -65,8 +72,9 @@ static const MemoryRegionOps aspeed_soc_io_ops = {
>  static void aspeed_soc_init(Object *obj)
>  {
>      AspeedSoCState *s = ASPEED_SOC(obj);
> +    AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
>  
> -    s->cpu = cpu_arm_init("arm926");
> +    s->cpu = cpu_arm_init(sc->info->cpu_model);
>  
>      object_initialize(&s->vic, sizeof(s->vic), TYPE_ASPEED_VIC);
>      object_property_add_child(obj, "vic", OBJECT(&s->vic), NULL);
> @@ -84,7 +92,7 @@ static void aspeed_soc_init(Object *obj)
>      object_property_add_child(obj, "scu", OBJECT(&s->scu), NULL);
>      qdev_set_parent_bus(DEVICE(&s->scu), sysbus_get_default());
>      qdev_prop_set_uint32(DEVICE(&s->scu), "silicon-rev",
> -                         AST2400_A0_SILICON_REV);
> +                         sc->info->silicon_rev);
>      object_property_add_alias(obj, "hw-strap1", OBJECT(&s->scu),
>                                "hw-strap1", &error_abort);
>      object_property_add_alias(obj, "hw-strap2", OBJECT(&s->scu),
> @@ -102,7 +110,7 @@ static void aspeed_soc_init(Object *obj)
>      object_property_add_child(obj, "sdmc", OBJECT(&s->sdmc), NULL);
>      qdev_set_parent_bus(DEVICE(&s->sdmc), sysbus_get_default());
>      qdev_prop_set_uint32(DEVICE(&s->sdmc), "silicon-rev",
> -                         AST2400_A0_SILICON_REV);
> +                         sc->info->silicon_rev);
>  }
>  
>  static void aspeed_soc_realize(DeviceState *dev, Error **errp)
> @@ -202,7 +210,9 @@ static void aspeed_soc_realize(DeviceState *dev,
> Error **errp)
>  static void aspeed_soc_class_init(ObjectClass *oc, void *data)
>  {
>      DeviceClass *dc = DEVICE_CLASS(oc);
> +    AspeedSoCClass *sc = ASPEED_SOC_CLASS(oc);
>  
> +    sc->info = (AspeedSoCInfo *) data;
>      dc->realize = aspeed_soc_realize;
>  
>      /*
> @@ -222,7 +232,18 @@ static const TypeInfo aspeed_soc_type_info = {
>  
>  static void aspeed_soc_register_types(void)
>  {
> +    int i;
> +
>      type_register_static(&aspeed_soc_type_info);
> +    for (i = 0; i < ARRAY_SIZE(aspeed_socs); ++i) {
> +        TypeInfo ti = {
> +            .name       = aspeed_socs[i].name,
> +            .parent     = TYPE_ASPEED_SOC,
> +            .class_init = aspeed_soc_class_init,
> +            .class_data = (void *) &aspeed_socs[i],
> +        };
> +        type_register(&ti);
> +    }
>  }
>  
>  type_init(aspeed_soc_register_types)
> diff --git a/hw/arm/palmetto-bmc.c b/hw/arm/palmetto-bmc.c
> index 4d11905cfb18..531c266d9449 100644
> --- a/hw/arm/palmetto-bmc.c
> +++ b/hw/arm/palmetto-bmc.c
> @@ -22,8 +22,6 @@
>  #include "sysemu/blockdev.h"
>  
>  static struct arm_boot_info palmetto_bmc_binfo = {
> -    .loader_start = AST2400_SDRAM_BASE,
> -    .board_id = 0,
>      .nb_cpus = 1,
>  };
>  
> @@ -61,14 +59,17 @@ static void
> palmetto_bmc_init_flashes(AspeedSMCState *s, const char *flashtype,
>  static void palmetto_bmc_init(MachineState *machine)
>  {
>      PalmettoBMCState *bmc;
> +    AspeedSoCClass *sc;
>  
>      bmc = g_new0(PalmettoBMCState, 1);
> -    object_initialize(&bmc->soc, (sizeof(bmc->soc)),
> TYPE_ASPEED_SOC);
> +    object_initialize(&bmc->soc, (sizeof(bmc->soc)), "ast2400-a0");
>      object_property_add_child(OBJECT(machine), "soc", OBJECT(&bmc-
> >soc),
>                                &error_abort);
>  
> +    sc = ASPEED_SOC_GET_CLASS(&bmc->soc);
> +
>      memory_region_allocate_system_memory(&bmc->ram, NULL, "ram",
> ram_size);
> -    memory_region_add_subregion(get_system_memory(),
> AST2400_SDRAM_BASE,
> +    memory_region_add_subregion(get_system_memory(), sc->info-
> >sdram_base,
>                                  &bmc->ram);
>      object_property_add_const_link(OBJECT(&bmc->soc), "ram",
> OBJECT(&bmc->ram),
>                                     &error_abort);
> @@ -84,6 +85,9 @@ static void palmetto_bmc_init(MachineState
> *machine)
>      palmetto_bmc_binfo.initrd_filename = machine->initrd_filename;
>      palmetto_bmc_binfo.kernel_cmdline = machine->kernel_cmdline;
>      palmetto_bmc_binfo.ram_size = ram_size;
> +    palmetto_bmc_binfo.board_id = sc->info->silicon_rev;
> +    palmetto_bmc_binfo.loader_start = sc->info->sdram_base;
> +
>      arm_load_kernel(ARM_CPU(first_cpu), &palmetto_bmc_binfo);
>  }
>  
> diff --git a/include/hw/arm/aspeed_soc.h
> b/include/hw/arm/aspeed_soc.h
> index bf63ae90cabe..0146a2a54a0e 100644
> --- a/include/hw/arm/aspeed_soc.h
> +++ b/include/hw/arm/aspeed_soc.h
> @@ -39,6 +39,21 @@ typedef struct AspeedSoCState {
>  #define TYPE_ASPEED_SOC "aspeed-soc"
>  #define ASPEED_SOC(obj) OBJECT_CHECK(AspeedSoCState, (obj),
> TYPE_ASPEED_SOC)
>  
> -#define AST2400_SDRAM_BASE       0x40000000
> +typedef struct AspeedSoCInfo {
> +    const char *name;
> +    const char *cpu_model;
> +    uint32_t silicon_rev;
> +    hwaddr sdram_base;
> +} AspeedSoCInfo;
> +
> +typedef struct AspeedSoCClass {
> +    DeviceState parent_class;
> +    AspeedSoCInfo *info;
> +} AspeedSoCClass;
> +
> +#define
> ASPEED_SOC_CLASS(klass)                                         \
> +    OBJECT_CLASS_CHECK(AspeedSoCClass, (klass), TYPE_ASPEED_SOC)
> +#define ASPEED_SOC_GET_CLASS(obj)                               \
> +    OBJECT_GET_CLASS(AspeedSoCClass, (obj), TYPE_ASPEED_SOC)
>  
>  #endif /* ASPEED_SOC_H */

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2016-08-02 23:47 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-02 17:15 [Qemu-devel] [PATCH v3 00/10] arm: add ast2500 support Cédric Le Goater
2016-08-02 17:15 ` [Qemu-devel] [PATCH v3 01/10] ast2400: rename the Aspeed SoC files to aspeed_soc Cédric Le Goater
2016-08-02 23:35   ` Andrew Jeffery
2016-08-11 10:22   ` Peter Maydell
2016-08-11 10:27     ` Cédric Le Goater
2016-08-02 17:15 ` [Qemu-devel] [PATCH v3 02/10] ast2400: replace ast2400 with aspeed_soc Cédric Le Goater
2016-08-02 23:44   ` Andrew Jeffery
2016-08-11 10:23   ` Peter Maydell
2016-08-02 17:15 ` [Qemu-devel] [PATCH v3 03/10] aspeed-soc: provide a framework to add new SoCs Cédric Le Goater
2016-08-02 23:46   ` Andrew Jeffery [this message]
2016-08-11 10:14   ` Peter Maydell
2016-08-12  8:33     ` Cédric Le Goater
2016-08-12  9:21       ` Peter Maydell
2016-08-22  9:07         ` Cédric Le Goater
2016-08-02 17:15 ` [Qemu-devel] [PATCH v3 04/10] palmetto-bmc: rename the Aspeed board file to aspeed.c Cédric Le Goater
2016-08-02 23:47   ` Andrew Jeffery
2016-08-11 10:24   ` Peter Maydell
2016-08-02 17:15 ` [Qemu-devel] [PATCH v3 05/10] palmetto-bmc: replace palmetto_bmc with aspeed Cédric Le Goater
2016-08-02 23:56   ` Andrew Jeffery
2016-08-11 10:23   ` Peter Maydell
2016-08-02 17:15 ` [Qemu-devel] [PATCH v3 06/10] palmetto-bmc: add board specific configuration Cédric Le Goater
2016-08-02 23:58   ` Andrew Jeffery
2016-08-11 10:27   ` Peter Maydell
2016-08-12  8:28     ` Cédric Le Goater
2016-08-02 17:15 ` [Qemu-devel] [PATCH v3 07/10] hw/misc: use macros to define hw-strap1 register on the AST2400 Aspeed SoC Cédric Le Goater
2016-08-03  0:13   ` Andrew Jeffery
2016-08-11 10:29   ` Peter Maydell
2016-08-02 17:15 ` [Qemu-devel] [PATCH v3 08/10] aspeed: add a AST2500 SoC and support to the SCU and SDMC controllers controllers Cédric Le Goater
2016-08-03  0:19   ` Andrew Jeffery
2016-08-11 10:33   ` Peter Maydell
2016-08-02 17:15 ` [Qemu-devel] [PATCH v3 09/10] arm: add support for an ast2500 evaluation board Cédric Le Goater
2016-08-03  0:22   ` Andrew Jeffery
2016-08-11 10:34   ` Peter Maydell
2016-08-02 17:15 ` [Qemu-devel] [PATCH v3 10/10] palmetto-bmc: remove extra no_sdcard assignement Cédric Le Goater
2016-08-03  0:23   ` Andrew Jeffery
2016-08-03  7:03     ` Cédric Le Goater
2016-08-11 10:35   ` Peter Maydell
2016-08-11 10:47 ` [Qemu-devel] [PATCH v3 00/10] arm: add ast2500 support Peter Maydell
2016-08-12  8:38   ` Cédric Le Goater
2016-08-12  9:22     ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1470181608.4428.36.camel@aj.id.au \
    --to=andrew@aj.id.au \
    --cc=clg@kaod.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).