[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 17/22] sd: emmc: Support boot area in emmc image
From: |
Sai Pavan Boddu |
Subject: |
[PATCH v2 17/22] sd: emmc: Support boot area in emmc image |
Date: |
Mon, 22 Feb 2021 13:50:34 +0530 |
From: Joel Stanley <joel@jms.id.au>
This assumes a specially constructued image:
dd if=/dev/zero of=mmc-bootarea.img count=2 bs=1M
dd if=u-boot-spl.bin of=mmc-bootarea.img conv=notrunc
dd if=u-boot.bin of=mmc-bootarea.img conv=notrunc count=64 bs=1K
cat mmc-bootarea.img obmc-phosphor-image.wic > mmc.img
truncate --size 16GB mmc.img
truncate --size 128MB mmc-bootarea.img
Signed-off-by: Joel Stanley <joel@jms.id.au>
[clg: - changes on the definition names ]
Signed-off-by: Cédric Le Goater <clg@kaod.org>
[spb: use data_start property to access right emmc partition,
Clean up PARTITION_ENABLE support as incomplete,
Fix commit message to be generic.]
Signed-off-by: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com>
---
hw/sd/sd.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 60799aa..ab29e54 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -1040,6 +1040,34 @@ static void sd_lock_command(SDState *sd)
sd->card_status &= ~CARD_IS_LOCKED;
}
+/*
+ * This requires a disk image that has two boot partitions inserted at the
+ * beginning of it. The size of the boot partitions are configured in the
+ * ext_csd structure, which is hardcoded in qemu. They are currently set to
+ * 1MB each.
+ */
+static uint32_t sd_bootpart_offset(SDState *sd)
+{
+ unsigned int access = sd->ext_csd[EXT_CSD_PART_CONFIG] &
+ EXT_CSD_PART_CONFIG_ACC_MASK;
+ unsigned int boot_capacity = sd->ext_csd[EXT_CSD_BOOT_MULT] << 17;
+
+ if (!sd->emmc) {
+ return 0;
+ }
+
+ switch (access) {
+ case EXT_CSD_PART_CONFIG_ACC_DEFAULT:
+ return boot_capacity * 2;
+ case EXT_CSD_PART_CONFIG_ACC_BOOT0:
+ return 0;
+ case EXT_CSD_PART_CONFIG_ACC_BOOT0 + 1:
+ return boot_capacity * 1;
+ default:
+ g_assert_not_reached();
+ }
+}
+
static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)
{
uint32_t rca = 0x0000;
@@ -1355,6 +1383,9 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,
SDRequest req)
return sd_r1;
}
+ if (sd->emmc) {
+ addr += sd_bootpart_offset(sd);
+ }
sd->state = sd_sendingdata_state;
sd->data_start = addr;
sd->data_offset = 0;
@@ -1374,6 +1405,9 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,
SDRequest req)
return sd_r1;
}
+ if (sd->emmc) {
+ addr += sd_bootpart_offset(sd);
+ }
sd->state = sd_sendingdata_state;
sd->data_start = addr;
sd->data_offset = 0;
@@ -1430,6 +1464,9 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,
SDRequest req)
return sd_r1;
}
+ if (sd->emmc) {
+ addr += sd_bootpart_offset(sd);
+ }
sd->state = sd_receivingdata_state;
sd->data_start = addr;
sd->data_offset = 0;
@@ -1460,6 +1497,9 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,
SDRequest req)
return sd_r1;
}
+ if (sd->emmc) {
+ addr += sd_bootpart_offset(sd);
+ }
sd->state = sd_receivingdata_state;
sd->data_start = addr;
sd->data_offset = 0;
--
2.7.4
- [PATCH v2 02/22] sd: sd: Remove usage of tabs in the file, (continued)
- [PATCH v2 02/22] sd: sd: Remove usage of tabs in the file, Sai Pavan Boddu, 2021/02/22
- [PATCH v2 10/22] sd: emmc: support idle state in CMD2, Sai Pavan Boddu, 2021/02/22
- [PATCH v2 08/22] sd: emmc: Dont not update CARD_CAPACITY for eMMC cards, Sai Pavan Boddu, 2021/02/22
- [PATCH v2 05/22] sd: emmc: Add support for EXT_CSD & CSD for eMMC, Sai Pavan Boddu, 2021/02/22
- [PATCH v2 12/22] sd: emmc: add CMD21 tuning sequence, Sai Pavan Boddu, 2021/02/22
- [PATCH v2 22/22] docs: arm: xlnx-versal-virt: Add eMMC support documentation, Sai Pavan Boddu, 2021/02/22
- [PATCH v2 14/22] sd: emmc: Add support for emmc erase, Sai Pavan Boddu, 2021/02/22
- [PATCH v2 19/22] sd: sdhci: Support eMMC devices, Sai Pavan Boddu, 2021/02/22
- [PATCH v2 11/22] sd: emmc: Add mmc switch function support, Sai Pavan Boddu, 2021/02/22
- [PATCH v2 06/22] sd: emmc: Update CMD8 to send EXT_CSD register, Sai Pavan Boddu, 2021/02/22
- [PATCH v2 17/22] sd: emmc: Support boot area in emmc image,
Sai Pavan Boddu <=
- [PATCH v2 21/22] docs: devel: emmc: Add a doc for emmc card emulation, Sai Pavan Boddu, 2021/02/22
- [PATCH v2 20/22] arm: xlnx-versal: Add emmc to versal, Sai Pavan Boddu, 2021/02/22