[coreboot-gerrit] Patch set updated for coreboot: Pass the firmware sdhci data to deptcharge

Bora Guvendik (bora.guvendik@intel.com) gerrit at coreboot.org
Fri Jan 13 01:24:38 CET 2017


Bora Guvendik (bora.guvendik at intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/18106

-gerrit

commit c21f7dde830b448a2fb86d574d695d10b5c0b07f
Author: Bora Guvendik <bora.guvendik at intel.com>
Date:   Fri Dec 9 11:14:43 2016 -0800

    Pass the firmware sdhci data to deptcharge
    
    Write sdhci and mmc driver data to coreboot
    tables so that payload can use the data
    and start talking to emmc without
    reinitializing the storage driver.
    
    BUG=chrome-os-partner:59875
    BRANCH=reef
    TEST=None
    
    Change-Id: I496c103e4a4889b665bc4bcfe0dc8138c5741f87
    Signed-off-by: Bora Guvendik <bora.guvendik at intel.com>
---
 payloads/libpayload/include/coreboot_tables.h     | 53 ++++++++++++++
 payloads/libpayload/include/sysinfo.h             |  3 +
 payloads/libpayload/libc/coreboot.c               | 24 +++++++
 src/commonlib/include/commonlib/coreboot_tables.h | 53 ++++++++++++++
 src/lib/coreboot_table.c                          | 87 +++++++++++++++++++++++
 5 files changed, 220 insertions(+)

diff --git a/payloads/libpayload/include/coreboot_tables.h b/payloads/libpayload/include/coreboot_tables.h
index d77242a..fbe83b4 100644
--- a/payloads/libpayload/include/coreboot_tables.h
+++ b/payloads/libpayload/include/coreboot_tables.h
@@ -291,6 +291,59 @@ struct cb_tsc_info {
 	uint32_t freq_khz;
 };
 
+#define CB_TAG_SDHCI_HOST 0x0033
+struct cb_sdhci_host_info {
+	uint32_t tag;
+	uint32_t size;
+	int initialized;
+	unsigned quirks;
+	unsigned host_caps;
+	unsigned version;
+	unsigned clock;
+	unsigned clock_f_min;
+	unsigned clock_f_max;
+	unsigned clock_base;
+	int removable;
+	unsigned voltages;
+	unsigned dma64;
+};
+
+#define CB_TAG_MMC_MEDIA 0x0034
+struct cb_mmc_media_info {
+	uint32_t tag;
+	uint32_t size;
+	uint32_t caps;
+	uint32_t version;
+	uint32_t read_bl_len;
+	uint32_t write_bl_len;
+	uint64_t capacity;
+	int high_capacity;
+	uint32_t tran_speed;
+	uint32_t erase_size;
+	uint32_t trim_mult;
+	uint32_t ocr;
+	uint16_t rca;
+	uint32_t scr[2];
+	uint32_t csd[4];
+	uint32_t cid[4];
+	uint32_t op_cond_response;
+};
+
+#define CB_TAG_MMC_CTRLR 0x0035
+struct cb_mmc_ctrlr_info {
+	uint32_t tag;
+	uint32_t size;
+	uint32_t voltages;
+	uint32_t f_min;
+	uint32_t f_max;
+	uint32_t bus_width;
+	uint32_t bus_hz;
+	uint32_t caps;
+	uint32_t b_max;
+	uint32_t timing;
+	uint32_t hardcoded_voltage;
+};
+
 #define CB_TAG_SERIALNO		0x002a
 #define CB_MAX_SERIALNO_LENGTH	32
 
diff --git a/payloads/libpayload/include/sysinfo.h b/payloads/libpayload/include/sysinfo.h
index 2110d88..baf9446 100644
--- a/payloads/libpayload/include/sysinfo.h
+++ b/payloads/libpayload/include/sysinfo.h
@@ -124,6 +124,9 @@ struct sysinfo_t {
 	uint64_t boot_media_size;
 	uint64_t mtc_start;
 	uint32_t mtc_size;
+	struct cb_sdhci_host_info *sdhci_host;
+	struct cb_mmc_media_info *mmc_media;
+	struct cb_mmc_ctrlr_info *mmc_ctrlr;
 };
 
 extern struct sysinfo_t lib_sysinfo;
diff --git a/payloads/libpayload/libc/coreboot.c b/payloads/libpayload/libc/coreboot.c
index 9fc6a69..6d9c04d 100644
--- a/payloads/libpayload/libc/coreboot.c
+++ b/payloads/libpayload/libc/coreboot.c
@@ -151,6 +151,21 @@ static void cb_parse_board_id(unsigned char *ptr, struct sysinfo_t *info)
 	info->board_id = cbbid->board_id;
 }
 
+static void cb_parse_sdhci_info(unsigned char *ptr, struct sysinfo_t *info)
+{
+	info->sdhci_host = (struct cb_sdhci_host_info*)ptr;
+}
+
+static void cb_mmc_media_info(unsigned char *ptr, struct sysinfo_t *info)
+{
+	info->mmc_media = (struct cb_mmc_media_info*)ptr;
+}
+
+static void cb_mmc_ctrlr_info(unsigned char *ptr, struct sysinfo_t *info)
+{
+	info->mmc_ctrlr = (struct cb_mmc_ctrlr_info*)ptr;
+}
+
 static void cb_parse_ram_code(unsigned char *ptr, struct sysinfo_t *info)
 {
 	struct cb_ram_code *const ram_code = (struct cb_ram_code *)ptr;
@@ -375,6 +390,15 @@ int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
 		case CB_TAG_BOARD_ID:
 			cb_parse_board_id(ptr, info);
 			break;
+		case CB_TAG_SDHCI_HOST:
+			cb_parse_sdhci_info(ptr, info);
+			break;
+		case CB_TAG_MMC_MEDIA:
+			cb_mmc_media_info(ptr, info);
+			break;
+		case CB_TAG_MMC_CTRLR:
+			cb_mmc_ctrlr_info(ptr, info);
+			break;
 		case CB_TAG_RAM_CODE:
 			cb_parse_ram_code(ptr, info);
 			break;
diff --git a/src/commonlib/include/commonlib/coreboot_tables.h b/src/commonlib/include/commonlib/coreboot_tables.h
index 7d58fdd..b5d44f0 100644
--- a/src/commonlib/include/commonlib/coreboot_tables.h
+++ b/src/commonlib/include/commonlib/coreboot_tables.h
@@ -358,6 +358,59 @@ struct lb_tsc_info {
 	uint32_t freq_khz;
 };
 
+#define LB_TAG_SDHCI_HOST 0x0033
+struct lb_sdhci_host_info {
+	uint32_t tag;
+	uint32_t size;
+	int initialized;
+	unsigned quirks;
+	unsigned host_caps;
+	unsigned version;
+	unsigned clock;
+	unsigned clock_f_min;
+	unsigned clock_f_max;
+	unsigned clock_base;
+	int removable;
+	unsigned voltages;
+	unsigned dma64;
+};
+
+#define LB_TAG_MMC_MEDIA 0x0034
+struct lb_mmc_media_info {
+	uint32_t tag;
+	uint32_t size;
+	uint32_t caps;
+	uint32_t version;
+	uint32_t read_bl_len;
+	uint32_t write_bl_len;
+	uint64_t capacity;
+	int high_capacity;
+	uint32_t tran_speed;
+	uint32_t erase_size;
+	uint32_t trim_mult;
+	uint32_t ocr;
+	uint16_t rca;
+	uint32_t scr[2];
+	uint32_t csd[4];
+	uint32_t cid[4];
+	uint32_t op_cond_response;
+};
+
+#define LB_TAG_MMC_CTRLR 0x0035
+struct lb_mmc_ctrlr_info {
+	uint32_t tag;
+	uint32_t size;
+	uint32_t voltages;
+	uint32_t f_min;
+	uint32_t f_max;
+	uint32_t bus_width;
+	uint32_t bus_hz;
+	uint32_t caps;
+	uint32_t b_max;
+	uint32_t timing;
+	uint32_t hardcoded_voltage;
+};
+
 #define LB_TAG_SERIALNO		0x002a
 #define MAX_SERIALNO_LENGTH	32
 
diff --git a/src/lib/coreboot_table.c b/src/lib/coreboot_table.c
index f8da658..932c8fe 100644
--- a/src/lib/coreboot_table.c
+++ b/src/lib/coreboot_table.c
@@ -46,6 +46,9 @@
 #if CONFIG_ARCH_X86
 #include <cpu/x86/mtrr.h>
 #endif
+#if CONFIG_DRIVERS_STORAGE
+#include <drivers/storage/sdhci.h>
+#endif
 
 static struct lb_header *lb_table_init(unsigned long addr)
 {
@@ -152,6 +155,80 @@ void __attribute__((weak)) lb_framebuffer(struct lb_header *header)
 #endif
 }
 
+#if CONFIG_DRIVERS_STORAGE
+static void lb_sdhci_host( struct lb_header *header )
+{
+	struct lb_sdhci_host_info  *lb_host;
+	SdhciHost* host_ptr = sdhci_get_host_ptr();
+
+	lb_host = (struct lb_sdhci_host_info *)lb_new_record(header);
+
+	lb_host->tag = LB_TAG_SDHCI_HOST;
+	lb_host->size = sizeof(*lb_host);
+
+	lb_host->initialized = host_ptr->initialized;
+	lb_host->quirks = host_ptr->quirks;
+	lb_host->host_caps = host_ptr->host_caps;
+	lb_host->version = host_ptr->version;
+	lb_host->clock = host_ptr->clock;
+	lb_host->clock_f_min = host_ptr->clock_f_min;
+	lb_host->clock_f_max = host_ptr->clock_f_max;
+	lb_host->clock_base = host_ptr->clock_base;
+	lb_host->removable = host_ptr->removable;
+	lb_host->voltages = host_ptr->voltages;
+	lb_host->dma64 = host_ptr->dma64;
+}
+
+static void lb_mmc_media( struct lb_header *header )
+{
+	struct lb_mmc_media_info  *lb_mmc_media;
+	SdhciHost* host_ptr = sdhci_get_host_ptr();
+
+	lb_mmc_media = (struct lb_mmc_media_info *)lb_new_record(header);
+
+	lb_mmc_media->tag = LB_TAG_MMC_MEDIA;
+	lb_mmc_media->size = sizeof(*lb_mmc_media);
+
+	lb_mmc_media->caps = host_ptr->mmc_ctrlr.media->caps;
+	lb_mmc_media->version = host_ptr->mmc_ctrlr.media->version;
+	lb_mmc_media->read_bl_len = host_ptr->mmc_ctrlr.media->read_bl_len;
+	lb_mmc_media->write_bl_len = host_ptr->mmc_ctrlr.media->write_bl_len;
+	lb_mmc_media->capacity = host_ptr->mmc_ctrlr.media->capacity;
+	lb_mmc_media->high_capacity = host_ptr->mmc_ctrlr.media->high_capacity;
+	lb_mmc_media->tran_speed = host_ptr->mmc_ctrlr.media->tran_speed;
+	lb_mmc_media->erase_size = host_ptr->mmc_ctrlr.media->erase_size;
+	lb_mmc_media->trim_mult = host_ptr->mmc_ctrlr.media->trim_mult;
+	lb_mmc_media->ocr = host_ptr->mmc_ctrlr.media->ocr;
+	lb_mmc_media->rca = host_ptr->mmc_ctrlr.media->rca;
+	lb_mmc_media->op_cond_response = host_ptr->mmc_ctrlr.media->op_cond_response;
+
+	memcpy(&lb_mmc_media->scr[0],&host_ptr->mmc_ctrlr.media->scr[0],2);
+	memcpy(&lb_mmc_media->csd[0],&host_ptr->mmc_ctrlr.media->csd[0],4);
+	memcpy(&lb_mmc_media->cid[0],&host_ptr->mmc_ctrlr.media->cid[0],4);
+}
+
+static void lb_mmc_ctrlr( struct lb_header *header )
+{
+	struct lb_mmc_ctrlr_info  *lb_mmc_ctrlr;
+	SdhciHost* host_ptr = sdhci_get_host_ptr();
+
+	lb_mmc_ctrlr = (struct lb_mmc_ctrlr_info *)lb_new_record(header);
+
+	lb_mmc_ctrlr->tag = LB_TAG_MMC_CTRLR;
+	lb_mmc_ctrlr->size = sizeof(*lb_mmc_ctrlr);
+
+	lb_mmc_ctrlr->voltages = host_ptr->mmc_ctrlr.voltages;
+	lb_mmc_ctrlr->f_min = host_ptr->mmc_ctrlr.f_min;
+	lb_mmc_ctrlr->f_max = host_ptr->mmc_ctrlr.f_max;
+	lb_mmc_ctrlr->bus_width = host_ptr->mmc_ctrlr.bus_width;
+	lb_mmc_ctrlr->bus_hz = host_ptr->mmc_ctrlr.bus_hz;
+	lb_mmc_ctrlr->caps = host_ptr->mmc_ctrlr.caps;
+	lb_mmc_ctrlr->b_max = host_ptr->mmc_ctrlr.b_max;
+	lb_mmc_ctrlr->timing = host_ptr->mmc_ctrlr.timing;
+	lb_mmc_ctrlr->hardcoded_voltage = host_ptr->mmc_ctrlr.hardcoded_voltage;
+}
+#endif /* CONFIG_DRIVERS_STORAGE */
+
 void lb_add_gpios(struct lb_gpios *gpios, const struct lb_gpio *gpio_table,
 		  size_t count)
 {
@@ -534,6 +611,16 @@ static uintptr_t write_coreboot_table(uintptr_t rom_table_end)
 	lb_vboot_handoff(head);
 #endif
 
+#if CONFIG_DRIVERS_STORAGE
+	/* Add sdhci host information */
+	lb_sdhci_host(head);
+
+	/* Add mmc media information */
+	lb_mmc_media(head);
+
+	/* Add mmc ctrlr information */
+	lb_mmc_ctrlr(head);
+#endif
 	/* Add board ID if available */
 	lb_board_id(head);
 



More information about the coreboot-gerrit mailing list