All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alistair Francis <alistair23@gmail.com>
To: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Cc: figlesia@xilinx.com, "Peter Maydell" <peter.maydell@linaro.org>,
	"Edgar Iglesias" <edgar.iglesias@xilinx.com>,
	"Sai Pavan Boddu" <sai.pavan.boddu@xilinx.com>,
	"Francisco Iglesias" <frasse.iglesias@gmail.com>,
	"Alistair Francis" <alistair@alistair23.me>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
	"KONRAD Frederic" <frederic.konrad@adacore.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	qemu-arm <qemu-arm@nongnu.org>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Luc Michel" <luc.michel@greensocs.com>
Subject: Re: [PATCH v1 10/11] hw/arm: versal-virt: Add support for SD
Date: Tue, 28 Apr 2020 10:54:22 -0700	[thread overview]
Message-ID: <CAKmqyKMoomzGq6_ZRLr2Cm6Tuz8EMWnDyX_V1Enj_Hp4wOV4jQ@mail.gmail.com> (raw)
In-Reply-To: <20200427181649.26851-11-edgar.iglesias@gmail.com>

On Mon, Apr 27, 2020 at 11:25 AM Edgar E. Iglesias
<edgar.iglesias@gmail.com> wrote:
>
> From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
>
> Add support for SD.
>
> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/arm/xlnx-versal-virt.c | 46 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 46 insertions(+)
>
> diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c
> index d7be1ad494..0afee48672 100644
> --- a/hw/arm/xlnx-versal-virt.c
> +++ b/hw/arm/xlnx-versal-virt.c
> @@ -20,6 +20,7 @@
>  #include "hw/arm/sysbus-fdt.h"
>  #include "hw/arm/fdt.h"
>  #include "cpu.h"
> +#include "hw/qdev-properties.h"
>  #include "hw/arm/xlnx-versal.h"
>
>  #define TYPE_XLNX_VERSAL_VIRT_MACHINE MACHINE_TYPE_NAME("xlnx-versal-virt")
> @@ -256,6 +257,32 @@ static void fdt_add_zdma_nodes(VersalVirt *s)
>      }
>  }
>
> +static void fdt_add_sd_nodes(VersalVirt *s)
> +{
> +    const char clocknames[] = "clk_xin\0clk_ahb";
> +    const char compat[] = "arasan,sdhci-8.9a";
> +    int i;
> +
> +    for (i = ARRAY_SIZE(s->soc.pmc.iou.sd) - 1; i >= 0; i--) {
> +        uint64_t addr = MM_PMC_SD0 + MM_PMC_SD0_SIZE * i;
> +        char *name = g_strdup_printf("/sdhci@%" PRIx64, addr);
> +
> +        qemu_fdt_add_subnode(s->fdt, name);
> +
> +        qemu_fdt_setprop_cells(s->fdt, name, "clocks",
> +                               s->phandle.clk_25Mhz, s->phandle.clk_25Mhz);
> +        qemu_fdt_setprop(s->fdt, name, "clock-names",
> +                         clocknames, sizeof(clocknames));
> +        qemu_fdt_setprop_cells(s->fdt, name, "interrupts",
> +                               GIC_FDT_IRQ_TYPE_SPI, VERSAL_SD0_IRQ_0 + i * 2,
> +                               GIC_FDT_IRQ_FLAGS_LEVEL_HI);
> +        qemu_fdt_setprop_sized_cells(s->fdt, name, "reg",
> +                                     2, addr, 2, MM_PMC_SD0_SIZE);
> +        qemu_fdt_setprop(s->fdt, name, "compatible", compat, sizeof(compat));
> +        g_free(name);
> +    }
> +}
> +
>  static void fdt_nop_memory_nodes(void *fdt, Error **errp)
>  {
>      Error *err = NULL;
> @@ -411,10 +438,23 @@ static void create_virtio_regions(VersalVirt *s)
>      }
>  }
>
> +static void sd_plugin_card(SDHCIState *sd, DriveInfo *di)
> +{
> +    BlockBackend *blk = di ? blk_by_legacy_dinfo(di) : NULL;
> +    DeviceState *card;
> +
> +    card = qdev_create(qdev_get_child_bus(DEVICE(sd), "sd-bus"), TYPE_SD_CARD);
> +    object_property_add_child(OBJECT(sd), "card[*]", OBJECT(card),
> +                              &error_fatal);
> +    qdev_prop_set_drive(card, "drive", blk, &error_fatal);
> +    object_property_set_bool(OBJECT(card), true, "realized", &error_fatal);
> +}
> +
>  static void versal_virt_init(MachineState *machine)
>  {
>      VersalVirt *s = XLNX_VERSAL_VIRT_MACHINE(machine);
>      int psci_conduit = QEMU_PSCI_CONDUIT_DISABLED;
> +    int i;
>
>      /*
>       * If the user provides an Operating System to be loaded, we expect them
> @@ -455,6 +495,7 @@ static void versal_virt_init(MachineState *machine)
>      fdt_add_gic_nodes(s);
>      fdt_add_timer_nodes(s);
>      fdt_add_zdma_nodes(s);
> +    fdt_add_sd_nodes(s);
>      fdt_add_cpu_nodes(s, psci_conduit);
>      fdt_add_clk_node(s, "/clk125", 125000000, s->phandle.clk_125Mhz);
>      fdt_add_clk_node(s, "/clk25", 25000000, s->phandle.clk_25Mhz);
> @@ -464,6 +505,11 @@ static void versal_virt_init(MachineState *machine)
>      memory_region_add_subregion_overlap(get_system_memory(),
>                                          0, &s->soc.fpd.apu.mr, 0);
>
> +    /* Plugin SD cards.  */
> +    for (i = 0; i < ARRAY_SIZE(s->soc.pmc.iou.sd); i++) {
> +        sd_plugin_card(&s->soc.pmc.iou.sd[i], drive_get_next(IF_SD));
> +    }
> +
>      s->binfo.ram_size = machine->ram_size;
>      s->binfo.loader_start = 0x0;
>      s->binfo.get_dtb = versal_virt_get_dtb;
> --
> 2.20.1
>
>


  reply	other threads:[~2020-04-28 18:06 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-27 18:16 [PATCH v1 00/11] hw/arm: versal: Add SD and the RTC Edgar E. Iglesias
2020-04-27 18:16 ` [PATCH v1 01/11] hw/arm: versal: Remove inclusion of arm_gicv3_common.h Edgar E. Iglesias
2020-04-27 20:08   ` Alistair Francis
2020-04-29  7:23   ` Luc Michel
2020-04-27 18:16 ` [PATCH v1 02/11] hw/arm: versal: Move misplaced comment Edgar E. Iglesias
2020-04-27 20:08   ` Alistair Francis
2020-04-28  7:46   ` Philippe Mathieu-Daudé
2020-04-29  7:23   ` Luc Michel
2020-04-27 18:16 ` [PATCH v1 03/11] hw/arm: versal-virt: Fix typo xlnx-ve -> xlnx-versal Edgar E. Iglesias
2020-04-27 22:18   ` Alistair Francis
2020-04-28  7:46   ` Philippe Mathieu-Daudé
2020-04-29  7:24   ` Luc Michel
2020-04-27 18:16 ` [PATCH v1 04/11] hw/arm: versal: Embedd the UARTs into the SoC type Edgar E. Iglesias
2020-04-27 22:16   ` Alistair Francis
2020-04-28  7:47   ` Philippe Mathieu-Daudé
2020-04-29  7:27   ` Luc Michel
2020-04-27 18:16 ` [PATCH v1 05/11] hw/arm: versal: Embedd the GEMs " Edgar E. Iglesias
2020-04-27 22:17   ` Alistair Francis
2020-04-28  7:48   ` Philippe Mathieu-Daudé
2020-04-29  7:27   ` Luc Michel
2020-04-27 18:16 ` [PATCH v1 06/11] hw/arm: versal: Embedd the ADMAs " Edgar E. Iglesias
2020-04-27 22:18   ` Alistair Francis
2020-04-28  7:49   ` Philippe Mathieu-Daudé
2020-04-29  7:28   ` Luc Michel
2020-04-27 18:16 ` [PATCH v1 07/11] hw/arm: versal: Embedd the APUs " Edgar E. Iglesias
2020-04-27 22:20   ` Alistair Francis
2020-04-28  7:50   ` Philippe Mathieu-Daudé
2020-04-29  7:28   ` Luc Michel
2020-04-27 18:16 ` [PATCH v1 08/11] hw/arm: versal: Add support for SD Edgar E. Iglesias
2020-04-27 22:24   ` Alistair Francis
2020-04-28  7:51   ` Philippe Mathieu-Daudé
2020-04-29  7:28   ` Luc Michel
2020-04-27 18:16 ` [PATCH v1 09/11] hw/arm: versal: Add support for the RTC Edgar E. Iglesias
2020-04-28  8:01   ` Philippe Mathieu-Daudé
2020-04-28 17:51   ` Alistair Francis
2020-04-29  7:28   ` Luc Michel
2020-04-27 18:16 ` [PATCH v1 10/11] hw/arm: versal-virt: Add support for SD Edgar E. Iglesias
2020-04-28 17:54   ` Alistair Francis [this message]
2020-04-29  7:36   ` Luc Michel
2020-04-27 18:16 ` [PATCH v1 11/11] hw/arm: versal-virt: Add support for the RTC Edgar E. Iglesias
2020-04-28 17:55   ` Alistair Francis
2020-04-29  7:57   ` Luc Michel
2020-05-04 10:13 ` [PATCH v1 00/11] hw/arm: versal: Add SD and " 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=CAKmqyKMoomzGq6_ZRLr2Cm6Tuz8EMWnDyX_V1Enj_Hp4wOV4jQ@mail.gmail.com \
    --to=alistair23@gmail.com \
    --cc=alistair@alistair23.me \
    --cc=edgar.iglesias@gmail.com \
    --cc=edgar.iglesias@xilinx.com \
    --cc=figlesia@xilinx.com \
    --cc=frasse.iglesias@gmail.com \
    --cc=frederic.konrad@adacore.com \
    --cc=luc.michel@greensocs.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=sai.pavan.boddu@xilinx.com \
    --cc=sstabellini@kernel.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 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.