リビジョン | f7c9aecbf850fd819643ea884de338f810e285f1 (tree) |
---|---|
日時 | 2022-01-28 23:29:46 |
作者 | Francisco Iglesias <francisco.iglesias@xili...> |
コミッター | Peter Maydell |
hw/arm/xlnx-versal: Connect Versal's PMC SLCR
Connect Versal's PMC SLCR (system-level control registers) model.
Signed-off-by: Francisco Iglesias <francisco.iglesias@xilinx.com>
Reviewed-by: Luc Michel <luc@lmichel.fr>
Message-id: 20220121161141.14389-4-francisco.iglesias@xilinx.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
@@ -21,11 +21,13 @@ | ||
21 | 21 | #include "kvm_arm.h" |
22 | 22 | #include "hw/misc/unimp.h" |
23 | 23 | #include "hw/arm/xlnx-versal.h" |
24 | +#include "qemu/log.h" | |
25 | +#include "hw/sysbus.h" | |
24 | 26 | |
25 | 27 | #define XLNX_VERSAL_ACPU_TYPE ARM_CPU_TYPE_NAME("cortex-a72") |
26 | 28 | #define GEM_REVISION 0x40070106 |
27 | 29 | |
28 | -#define VERSAL_NUM_PMC_APB_IRQS 2 | |
30 | +#define VERSAL_NUM_PMC_APB_IRQS 3 | |
29 | 31 | |
30 | 32 | static void versal_create_apu_cpus(Versal *s) |
31 | 33 | { |
@@ -271,6 +273,7 @@ static void versal_create_pmc_apb_irq_orgate(Versal *s, qemu_irq *pic) | ||
271 | 273 | * models: |
272 | 274 | * - RTC |
273 | 275 | * - BBRAM |
276 | + * - PMC SLCR | |
274 | 277 | */ |
275 | 278 | object_initialize_child(OBJECT(s), "pmc-apb-irq-orgate", |
276 | 279 | &s->pmc.apb_irq_orgate, TYPE_OR_IRQ); |
@@ -392,6 +395,23 @@ static void versal_create_efuse(Versal *s, qemu_irq *pic) | ||
392 | 395 | sysbus_connect_irq(SYS_BUS_DEVICE(ctrl), 0, pic[VERSAL_EFUSE_IRQ]); |
393 | 396 | } |
394 | 397 | |
398 | +static void versal_create_pmc_iou_slcr(Versal *s, qemu_irq *pic) | |
399 | +{ | |
400 | + SysBusDevice *sbd; | |
401 | + | |
402 | + object_initialize_child(OBJECT(s), "versal-pmc-iou-slcr", &s->pmc.iou.slcr, | |
403 | + TYPE_XILINX_VERSAL_PMC_IOU_SLCR); | |
404 | + | |
405 | + sbd = SYS_BUS_DEVICE(&s->pmc.iou.slcr); | |
406 | + sysbus_realize(sbd, &error_fatal); | |
407 | + | |
408 | + memory_region_add_subregion(&s->mr_ps, MM_PMC_PMC_IOU_SLCR, | |
409 | + sysbus_mmio_get_region(sbd, 0)); | |
410 | + | |
411 | + sysbus_connect_irq(sbd, 0, | |
412 | + qdev_get_gpio_in(DEVICE(&s->pmc.apb_irq_orgate), 2)); | |
413 | +} | |
414 | + | |
395 | 415 | /* This takes the board allocated linear DDR memory and creates aliases |
396 | 416 | * for each split DDR range/aperture on the Versal address map. |
397 | 417 | */ |
@@ -448,8 +468,31 @@ static void versal_unimp_area(Versal *s, const char *name, | ||
448 | 468 | memory_region_add_subregion(mr, base, mr_dev); |
449 | 469 | } |
450 | 470 | |
471 | +static void versal_unimp_sd_emmc_sel(void *opaque, int n, int level) | |
472 | +{ | |
473 | + qemu_log_mask(LOG_UNIMP, | |
474 | + "Selecting between enabling SD mode or eMMC mode on " | |
475 | + "controller %d is not yet implemented\n", n); | |
476 | +} | |
477 | + | |
478 | +static void versal_unimp_qspi_ospi_mux_sel(void *opaque, int n, int level) | |
479 | +{ | |
480 | + qemu_log_mask(LOG_UNIMP, | |
481 | + "Selecting between enabling the QSPI or OSPI linear address " | |
482 | + "region is not yet implemented\n"); | |
483 | +} | |
484 | + | |
485 | +static void versal_unimp_irq_parity_imr(void *opaque, int n, int level) | |
486 | +{ | |
487 | + qemu_log_mask(LOG_UNIMP, | |
488 | + "PMC SLCR parity interrupt behaviour " | |
489 | + "is not yet implemented\n"); | |
490 | +} | |
491 | + | |
451 | 492 | static void versal_unimp(Versal *s) |
452 | 493 | { |
494 | + qemu_irq gpio_in; | |
495 | + | |
453 | 496 | versal_unimp_area(s, "psm", &s->mr_ps, |
454 | 497 | MM_PSM_START, MM_PSM_END - MM_PSM_START); |
455 | 498 | versal_unimp_area(s, "crl", &s->mr_ps, |
@@ -464,6 +507,31 @@ static void versal_unimp(Versal *s) | ||
464 | 507 | MM_IOU_SCNTR, MM_IOU_SCNTR_SIZE); |
465 | 508 | versal_unimp_area(s, "iou-scntr-seucre", &s->mr_ps, |
466 | 509 | MM_IOU_SCNTRS, MM_IOU_SCNTRS_SIZE); |
510 | + | |
511 | + qdev_init_gpio_in_named(DEVICE(s), versal_unimp_sd_emmc_sel, | |
512 | + "sd-emmc-sel-dummy", 2); | |
513 | + qdev_init_gpio_in_named(DEVICE(s), versal_unimp_qspi_ospi_mux_sel, | |
514 | + "qspi-ospi-mux-sel-dummy", 1); | |
515 | + qdev_init_gpio_in_named(DEVICE(s), versal_unimp_irq_parity_imr, | |
516 | + "irq-parity-imr-dummy", 1); | |
517 | + | |
518 | + gpio_in = qdev_get_gpio_in_named(DEVICE(s), "sd-emmc-sel-dummy", 0); | |
519 | + qdev_connect_gpio_out_named(DEVICE(&s->pmc.iou.slcr), "sd-emmc-sel", 0, | |
520 | + gpio_in); | |
521 | + | |
522 | + gpio_in = qdev_get_gpio_in_named(DEVICE(s), "sd-emmc-sel-dummy", 1); | |
523 | + qdev_connect_gpio_out_named(DEVICE(&s->pmc.iou.slcr), "sd-emmc-sel", 1, | |
524 | + gpio_in); | |
525 | + | |
526 | + gpio_in = qdev_get_gpio_in_named(DEVICE(s), "qspi-ospi-mux-sel-dummy", 0); | |
527 | + qdev_connect_gpio_out_named(DEVICE(&s->pmc.iou.slcr), | |
528 | + "qspi-ospi-mux-sel", 0, | |
529 | + gpio_in); | |
530 | + | |
531 | + gpio_in = qdev_get_gpio_in_named(DEVICE(s), "irq-parity-imr-dummy", 0); | |
532 | + qdev_connect_gpio_out_named(DEVICE(&s->pmc.iou.slcr), | |
533 | + SYSBUS_DEVICE_GPIO_IRQ, 0, | |
534 | + gpio_in); | |
467 | 535 | } |
468 | 536 | |
469 | 537 | static void versal_realize(DeviceState *dev, Error **errp) |
@@ -483,6 +551,7 @@ static void versal_realize(DeviceState *dev, Error **errp) | ||
483 | 551 | versal_create_xrams(s, pic); |
484 | 552 | versal_create_bbram(s, pic); |
485 | 553 | versal_create_efuse(s, pic); |
554 | + versal_create_pmc_iou_slcr(s, pic); | |
486 | 555 | versal_map_ddr(s); |
487 | 556 | versal_unimp(s); |
488 | 557 |
@@ -26,6 +26,7 @@ | ||
26 | 26 | #include "hw/misc/xlnx-versal-xramc.h" |
27 | 27 | #include "hw/nvram/xlnx-bbram.h" |
28 | 28 | #include "hw/nvram/xlnx-versal-efuse.h" |
29 | +#include "hw/misc/xlnx-versal-pmc-iou-slcr.h" | |
29 | 30 | |
30 | 31 | #define TYPE_XLNX_VERSAL "xlnx-versal" |
31 | 32 | OBJECT_DECLARE_SIMPLE_TYPE(Versal, XLNX_VERSAL) |
@@ -78,6 +79,7 @@ struct Versal { | ||
78 | 79 | struct { |
79 | 80 | struct { |
80 | 81 | SDHCIState sd[XLNX_VERSAL_NR_SDS]; |
82 | + XlnxVersalPmcIouSlcr slcr; | |
81 | 83 | } iou; |
82 | 84 | |
83 | 85 | XlnxZynqMPRTC rtc; |
@@ -179,6 +181,9 @@ struct Versal { | ||
179 | 181 | #define MM_FPD_FPD_APU 0xfd5c0000 |
180 | 182 | #define MM_FPD_FPD_APU_SIZE 0x100 |
181 | 183 | |
184 | +#define MM_PMC_PMC_IOU_SLCR 0xf1060000 | |
185 | +#define MM_PMC_PMC_IOU_SLCR_SIZE 0x10000 | |
186 | + | |
182 | 187 | #define MM_PMC_SD0 0xf1040000U |
183 | 188 | #define MM_PMC_SD0_SIZE 0x10000 |
184 | 189 | #define MM_PMC_BBRAM_CTRL 0xf11f0000 |