On 22/8/25 17:15, Luc Michel wrote:
Refactor the SDHCI controllers creation using the VersalMap structure.

Signed-off-by: Luc Michel <[email protected]>
Reviewed-by: Francisco Iglesias <[email protected]>
---
  include/hw/arm/xlnx-versal.h |  5 +-
  hw/arm/xlnx-versal-virt.c    | 43 ++--------------
  hw/arm/xlnx-versal.c         | 96 ++++++++++++++++++++++++++++--------
  3 files changed, 83 insertions(+), 61 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>

+void versal_sdhci_plug_card(Versal *s, int sd_idx, BlockBackend *blk)
+{
+    DeviceState *sdhci, *card;
+
+    sdhci = DEVICE(versal_get_child_idx(s, "sdhci", sd_idx));
+
+    if (sdhci == NULL) {

Can that happen?

+        return;
+    }
+
+    card = qdev_new(TYPE_SD_CARD);
+    object_property_add_child(OBJECT(sdhci), "card[*]", OBJECT(card));
+    qdev_prop_set_drive_err(card, "drive", blk, &error_fatal);
+    qdev_realize_and_unref(card, qdev_get_child_bus(DEVICE(sdhci), "sd-bus"),
+                           &error_fatal);
+}


Reply via email to