[coreboot-gerrit] Change in coreboot[master]: soc/intel/apollolake: Use CAR for storage data structures

Lee Leahy (Code Review) gerrit at coreboot.org
Sat Apr 15 02:12:45 CEST 2017


Lee Leahy has uploaded a new change for review. ( https://review.coreboot.org/19302 )

Change subject: soc/intel/apollolake: Use CAR for storage data structures
......................................................................

soc/intel/apollolake: Use CAR for storage data structures

Perform eMMC initialization in bootblock and perform read operations in
romstage using the same data structures.

TEST=Build and run on Reef

Change-Id: Iadc893b5a742b240b8a7eb55fca135f7cd2c7b2e
Signed-off-by: Lee Leahy <Leroy.P.Leahy at intel.com>
---
M src/soc/intel/apollolake/Kconfig
M src/soc/intel/apollolake/bootblock/emmc_test.c
M src/soc/intel/apollolake/emmc_test.c
3 files changed, 64 insertions(+), 28 deletions(-)


  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/02/19302/1

diff --git a/src/soc/intel/apollolake/Kconfig b/src/soc/intel/apollolake/Kconfig
index 86ae77e..9e0119f 100644
--- a/src/soc/intel/apollolake/Kconfig
+++ b/src/soc/intel/apollolake/Kconfig
@@ -321,6 +321,7 @@
 	bool "Enable SD/MMC/eMMC testing"
 	default n
 	select DRIVERS_STORAGE
+	select CAR_DRIVERS_STORAGE
 	select SDHCI_CONTROLLER
 	help
 	  Read block 0 from each parition of the storage device.  User must
diff --git a/src/soc/intel/apollolake/bootblock/emmc_test.c b/src/soc/intel/apollolake/bootblock/emmc_test.c
index 93e4b0d..07d061f 100644
--- a/src/soc/intel/apollolake/bootblock/emmc_test.c
+++ b/src/soc/intel/apollolake/bootblock/emmc_test.c
@@ -13,39 +13,55 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  */
+#include <arch/early_variables.h>
 #include <bootblock_common.h>
+#include <assert.h>
+#include <console/console.h>
 #include <device/sdhci.h>
 #include <device/storage.h>
-#include <soc/iomap.h>
 #include <soc/emmc_test.h>
+#include <soc/iomap.h>
 #include <soc/pci_devs.h>
+
+extern void *_car_drivers_storage_start;
+extern void *_car_drivers_storage_end;
 
 void bootblock_soc_init(void)
 {
+	uint32_t bar;
+	dev_t dev;
 	int err;
-	struct sdhci_ctrlr sdhci_ctrlr;
-	struct storage_media media;
+	struct storage_media local_media;
+	struct sdhci_ctrlr local_sdhci_ctrlr;
+	struct storage_media *media;
+	uint32_t previous_bar;
+	uint16_t previous_command;
+	struct sdhci_ctrlr *sdhci_ctrlr;
 
-	/* Test the eMMC device */
-	if (IS_ENABLED(CONFIG_STORAGE_TEST)) {
-		uint32_t bar;
-		dev_t dev;
-		uint32_t previous_bar;
-		uint16_t previous_command;
-
-		/* Enable the SD/MMC controller and run the test.  Restore
-		 * the BAR and command registers upon completion.
-		 */
-		dev = PCH_DEV_EMMC;
-		bar = emmc_test_init(dev, &previous_bar, &previous_command);
-
-		/* Initialize the controller */
-		err = sdhci_controller_init(&sdhci_ctrlr, (void *)bar);
-
-		/* Initialize the SD/MMC/eMMC card or device */
-		if (!err)
-			err = storage_setup_media(&media,
-				&sdhci_ctrlr.sd_mmc_ctrlr);
-		emmc_test_complete(dev, previous_bar, previous_command);
+	if (IS_ENABLED(CONFIG_CAR_DRIVERS_STORAGE)
+		&& (ENV_BOOTBLOCK || ENV_VERSTAGE || ENV_ROMSTAGE)) {
+		media = car_get_var_ptr(&_car_drivers_storage_start);
+		sdhci_ctrlr = (void *)(((uintptr_t)(media + 1) + 0x7) & ~7);
+		ASSERT((sdhci_ctrlr + 1)
+			<= (struct sdhci_ctrlr *)&_car_drivers_storage_end);
+		sdhci_update_pointers(sdhci_ctrlr);
+	} else {
+		media = &local_media;
+		sdhci_ctrlr = &local_sdhci_ctrlr;
 	}
+
+	/* Enable the SD/MMC controller and run the test.  Restore
+	 * the BAR and command registers upon completion.
+	 */
+	dev = EMMC_DEV;
+	bar = emmc_test_init(dev, &previous_bar, &previous_command);
+
+	/* Initialize the controller */
+	err = sdhci_controller_init(sdhci_ctrlr, (void *)bar);
+
+	/* Initialize the SD/MMC/eMMC card or device */
+	if (!err)
+		err = storage_setup_media(media,
+			&sdhci_ctrlr->sd_mmc_ctrlr);
+	emmc_test_complete(dev, previous_bar, previous_command);
 }
diff --git a/src/soc/intel/apollolake/emmc_test.c b/src/soc/intel/apollolake/emmc_test.c
index 6f754bc..75443fb 100644
--- a/src/soc/intel/apollolake/emmc_test.c
+++ b/src/soc/intel/apollolake/emmc_test.c
@@ -15,6 +15,7 @@
 
 #include <arch/early_variables.h>
 #include <arch/io.h>
+#include <assert.h>
 #include <console/console.h>
 #include <device/sdhci.h>
 #include <device/storage.h>
@@ -29,6 +30,8 @@
 int log_full CAR_GLOBAL;
 long log_start_time CAR_GLOBAL;
 #endif
+extern uint8_t _car_drivers_storage_start;
+extern uint8_t _car_drivers_storage_end;
 
 uint32_t emmc_test_init(dev_t dev, uint32_t *previous_bar,
 	uint16_t *previous_command)
@@ -154,12 +157,28 @@
 	struct sdhci_ctrlr *sdhci_ctrlr;
 
 	/* Get the structure addresses */
-	media = &local_media;
-	sdhci_ctrlr = &local_sdhci_ctrlr;
-	full_initialization = 1;
+	media = NULL;
+	if (IS_ENABLED(CONFIG_CAR_DRIVERS_STORAGE)
+		&& (ENV_BOOTBLOCK || ENV_VERSTAGE || ENV_ROMSTAGE)) {
+		media = car_get_var_ptr(&_car_drivers_storage_start);
+		sdhci_ctrlr = (void *)(((uintptr_t)(media + 1) + 0x7) & ~7);
+		ASSERT((sdhci_ctrlr + 1)
+			<= (struct sdhci_ctrlr *)&_car_drivers_storage_end);
+	} else {
+		media = &local_media;
+		sdhci_ctrlr = &local_sdhci_ctrlr;
+		full_initialization = 1;
+	}
+	media->ctrlr = (struct sd_mmc_ctrlr *)sdhci_ctrlr;
+	sdhci_ctrlr->ioaddr = (void *)bar;
 
 	/* Initialize the controller */
-	if (full_initialization) {
+	if (!full_initialization) {
+		/* Perform fast initialization */
+		sdhci_update_pointers(sdhci_ctrlr);
+		sdhci_display_setup(sdhci_ctrlr);
+		storage_display_setup(media);
+	} else {
 		/* Initialize the log */
 		if (IS_ENABLED(CONFIG_STORAGE_LOG)) {
 			log_index = 0;

-- 
To view, visit https://review.coreboot.org/19302
To unsubscribe, visit https://review.coreboot.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iadc893b5a742b240b8a7eb55fca135f7cd2c7b2e
Gerrit-PatchSet: 1
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Owner: Lee Leahy <leroy.p.leahy at intel.com>



More information about the coreboot-gerrit mailing list