[coreboot-gerrit] New patch to review for coreboot: marvell/mvmap2315: add BootROM driver
hakim giydan (hgiydan@marvell.com)
gerrit at coreboot.org
Thu Jun 30 03:53:50 CEST 2016
hakim giydan (hgiydan at marvell.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15509
-gerrit
commit 380bc6655255277a15fb4de50c445c93e6a27e18
Author: Hakim Giydan <hgiydan at marvell.com>
Date: Wed Jun 29 18:53:06 2016 -0700
marvell/mvmap2315: add BootROM driver
this driver is SD & EMMC driver using BootROM callback.
we are using BootROM callbacks to save LCM memory space
and reduce romstage size.
Change-Id: Iaeff9f01dbfad7f313aa237e8c71c36c4ed1e06f
Signed-off-by: Hakim Giydan <hgiydan at marvell.com>
---
src/soc/marvell/mvmap2315/Makefile.inc | 2 +
src/soc/marvell/mvmap2315/bootrom.c | 188 ++++++++++
src/soc/marvell/mvmap2315/gic.c | 19 +-
src/soc/marvell/mvmap2315/include/soc/addressmap.h | 14 +-
src/soc/marvell/mvmap2315/include/soc/bdb.h | 245 ++++++++++++
src/soc/marvell/mvmap2315/include/soc/bootrom.h | 125 +++++++
src/soc/marvell/mvmap2315/include/soc/clock.h | 5 +-
src/soc/marvell/mvmap2315/include/soc/gic.h | 412 +++++++++++++++++++++
src/soc/marvell/mvmap2315/romstage.c | 13 +
9 files changed, 1017 insertions(+), 6 deletions(-)
diff --git a/src/soc/marvell/mvmap2315/Makefile.inc b/src/soc/marvell/mvmap2315/Makefile.inc
index 994c745..ebb0515 100644
--- a/src/soc/marvell/mvmap2315/Makefile.inc
+++ b/src/soc/marvell/mvmap2315/Makefile.inc
@@ -27,8 +27,10 @@ ramstage-y += stage_entry.S
ramstage-y += uart.c
romstage-y += assert.c
+romstage-y += bootrom.c
romstage-y += cbmem.c
romstage-y += clock.c
+romstage-y += gic.c
romstage-y += media.c
romstage-y += monotonic_timer.c
romstage-y += pinconfig.c
diff --git a/src/soc/marvell/mvmap2315/bootrom.c b/src/soc/marvell/mvmap2315/bootrom.c
new file mode 100644
index 0000000..3873051
--- /dev/null
+++ b/src/soc/marvell/mvmap2315/bootrom.c
@@ -0,0 +1,188 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2016 Marvell, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <arch/io.h>
+#include <console/console.h>
+#include <soc/addressmap.h>
+#include <soc/bdb.h>
+#include <soc/bootrom.h>
+#include <soc/clock.h>
+#include <reset.h>
+#include <string.h>
+
+struct bootrom_ops bootrom_callbacks = {
+ .security_init = (security_init_F) MVMAP2315_BM_CB_SECURITY_INIT,
+ .sha_msg_digest = (sha_msg_digest_F) MVMAP2315_BM_CB_SHA_MSG_DIGEST,
+ .media_init = (media_init_F) MVMAP2315_BM_CB_MEDIA_INIT,
+ .media_read = (media_read_F) MVMAP2315_BM_CB_MEDIA_READ,
+ .media_write = (media_write_F) MVMAP2315_BM_CB_MEDIA_WRITE,
+ .media_shutdown = (media_shutdown_F) MVMAP2315_BM_CB_MEDIA_SHUTDOWN,
+};
+
+void set_bdb_pointers(u8 *start_addr, struct bdb_pointer *bdb_in)
+{
+ bdb_in->bdb_h
+ = (struct bdb_header *)start_addr;
+
+ bdb_in->bdb_k
+ = (struct bdb_key *)(start_addr
+ + (bdb_in->bdb_h->struct_size));
+
+ bdb_in->bdb_oem_0
+ = (u8 *)((u32)(bdb_in->bdb_k)
+ + (bdb_in->bdb_k->struct_size));
+
+ bdb_in->sub_k
+ = (struct bdb_key *)((u32)(bdb_in->bdb_oem_0)
+ + (bdb_in->bdb_h->oem_area_0_size));
+
+ bdb_in->bdb_h_s
+ = (struct bdb_sig *)((u32)(bdb_in->bdb_oem_0)
+ + (bdb_in->bdb_h->signed_size));
+
+ bdb_in->bdb_d
+ = (struct bdb_data *)((u32)(bdb_in->bdb_h_s)
+ + (bdb_in->bdb_h_s->struct_size));
+
+ bdb_in->oem_1
+ = (u8 *)((u32)(bdb_in->bdb_d)
+ + (bdb_in->bdb_d->struct_size));
+
+ bdb_in->bdb_hash
+ = (struct bdb_hash *)((u32)(bdb_in->oem_1)
+ + (bdb_in->bdb_d->oem_area_1_size));
+
+ bdb_in->bdb_s
+ = (struct bdb_sig *)((u32)(bdb_in->bdb_d)
+ + (bdb_in->bdb_d->signed_size));
+}
+
+static struct bdb_hash *find_bdb_image(struct bdb_pointer *bdb_info,
+ u8 image_type)
+{
+ u8 i;
+
+ if (bdb_info) {
+ for (i = 0; i < bdb_info->bdb_d->num_hashes; i++) {
+ if (bdb_info->bdb_hash[i].type == image_type)
+ return &bdb_info->bdb_hash[i];
+ }
+ }
+
+ return NULL;
+}
+
+static void image_failure(void)
+{
+ /* TODO: implement image_filaure function to choose between
+ * image B, or recovery
+ * for now just reset the system
+ */
+ hard_reset();
+}
+
+static void set_image_parameters(struct media_params *flash_read_info,
+ struct bdb_hash *image_info)
+{
+ (*flash_read_info).flash_offset
+ = (u32)(image_info->offset);
+ (*flash_read_info).local_buffer
+ = (u32)(image_info->load_address);
+ (*flash_read_info).size = image_info->size;
+ (*flash_read_info).image_id = 0x0;
+ (*flash_read_info).partition_num = (u32)image_info->partition;
+}
+
+void load_and_validate_image(struct bdb_pointer *bdb_info, u8 image_type)
+{
+ struct bdb_hash *image_info;
+ u32 reg;
+ u32 rc;
+ struct media_params flash_read_info;
+ u8 image_digest[32];
+ u32 media_type;
+
+ /* TODO: use bootrom callback pointer
+ * register to find the location of media_type
+ */
+ media_type = read32((void *)MVMAP2315_BRM_CBS_MEDIA_TYPE);
+
+ reg = read32(&mvmap2315_apmu_clk->apaonclk_sdmmc_clkgenconfig);
+ reg &= ~MVMAP2315_SDMMC_CLK_RSTN;
+ write32(&mvmap2315_apmu_clk->apaonclk_sdmmc_clkgenconfig, reg);
+
+ reg = read32(&mvmap2315_apmu_clk->apaonclk_sdmmc_clkgenconfig);
+ reg |= MVMAP2315_SDMMC_CLK_RSTN;
+ write32(&mvmap2315_apmu_clk->apaonclk_sdmmc_clkgenconfig, reg);
+
+ image_info = find_bdb_image(bdb_info, image_type);
+
+ if (!image_info) {
+ printk(BIOS_INFO, "Unable to find image type %d in BDB.\n",
+ image_type);
+ printk(BIOS_INFO, "Resetting system!!\n");
+ image_failure();
+ }
+
+ set_image_parameters(&flash_read_info, image_info);
+
+ rc = bootrom_callbacks.media_init(media_type, 0, 200);
+
+ if (rc) {
+ printk(BIOS_INFO, "media_init callback failed with rc=%x.\n",
+ rc);
+ printk(BIOS_INFO, "Resetting system!!\n");
+
+ image_failure();
+ }
+
+ rc = bootrom_callbacks.media_read(media_type, 0, &flash_read_info);
+ if (rc) {
+ printk(BIOS_INFO, "media_read callback failed with rc=%x.\n",
+ rc);
+ printk(BIOS_INFO, "Resetting system!!\n");
+
+ image_failure();
+ }
+
+ rc = bootrom_callbacks.media_shutdown(media_type, 0, &flash_read_info);
+ if (rc) {
+ printk(BIOS_INFO, "WARNING: media_shutdown callback ");
+ printk(BIOS_INFO, "failed with rc=%x.\n", rc);
+ }
+
+ rc = bootrom_callbacks.security_init(0x0);
+ if (rc) {
+ printk(BIOS_INFO, "WARNING: security_init callback ");
+ printk(BIOS_INFO, "failed with rc=%x.\n", rc);
+ }
+
+ rc = bootrom_callbacks.sha_msg_digest(
+ ((u8 *)(flash_read_info.local_buffer)),
+ image_info->size, &image_digest[0], 32);
+ if (rc) {
+ printk(BIOS_INFO, "sha_msg_digest callback failed with rc=%x.\n",
+ rc);
+ printk(BIOS_INFO, "Resetting system!!\n");
+
+ image_failure();
+ }
+ if (memcmp(&image_digest[0], &image_info->digest[0], 32)) {
+ printk(BIOS_INFO, "image hash doesn't match BDB expected");
+ printk(BIOS_INFO, "value.\nResetting system!!\n");
+
+ image_failure();
+ }
+}
diff --git a/src/soc/marvell/mvmap2315/gic.c b/src/soc/marvell/mvmap2315/gic.c
index 9d0f9a6..ef5fa79 100644
--- a/src/soc/marvell/mvmap2315/gic.c
+++ b/src/soc/marvell/mvmap2315/gic.c
@@ -14,17 +14,32 @@
* GNU General Public License for more details.
*/
+#include <arch/io.h>
#include <soc/addressmap.h>
+#include <soc/gic.h>
#include <gic.h>
/* Return a pointer to the base of the GIC distributor mmio region. */
void *gicd_base(void)
{
- return (void *)MVMAP2315_GICD_BASE;
+ return (void *)MVMAP2315_AP_GICD_BASE;
}
/* Return a pointer to the base of the GIC cpu mmio region. */
void *gicc_base(void)
{
- return (void *)MVMAP2315_GICC_BASE;
+ return (void *)MVMAP2315_AP_GICC_BASE;
+}
+
+void enable_bcm_gic(void)
+{
+ u32 reg;
+
+ reg = read32(&mvmap2315_bcm_gicc->ctrl);
+ reg |= (MVMAP2315_BCM_GICC_EN0 & MVMAP2315_BCM_GICD_FIQ_EN);
+ write32(&mvmap2315_bcm_gicc->ctrl, reg);
+
+ reg = read32(&mvmap2315_bcm_gicd->ctrl);
+ reg |= MVMAP2315_BCM_GICD_EN0;
+ write32(&mvmap2315_bcm_gicd->ctrl, reg);
}
diff --git a/src/soc/marvell/mvmap2315/include/soc/addressmap.h b/src/soc/marvell/mvmap2315/include/soc/addressmap.h
index 242c5c2..9d20a75 100644
--- a/src/soc/marvell/mvmap2315/include/soc/addressmap.h
+++ b/src/soc/marvell/mvmap2315/include/soc/addressmap.h
@@ -22,15 +22,25 @@
enum {
MVMAP2315_RAM_BASE = 0x00000000,
MVMAP2315_CBFS_BASE = 0x00400000,
+ MVMAP2315_BDB_LCM_BASE = 0xE0000000,
+ MVMAP2315_BRM_CBS_MEDIA_TYPE = 0xE0002004,
+ MVMAP2315_BCM_GICD_BASE = 0xE0111000,
+ MVMAP2315_BCM_GICC_BASE = 0xE0112000,
MVMAP2315_MAIN_PLL_BASE = 0xE0125000,
MVMAP2315_APMU_CLK_BASE = 0xE0125400,
MVMAP2315_GENTIMER_BASE = 0xE0137000,
MVMAP2315_PADWRAP_BASE = 0xE0140000,
MVMAP2315_TIMER0_BASE = 0xE1020000,
MVMAP2315_MPMU_CLK_BASE = 0xEF000800,
- MVMAP2315_GICD_BASE = 0xF0401000,
- MVMAP2315_GICC_BASE = 0xF0402000,
+ MVMAP2315_AP_GICD_BASE = 0xF0401000,
+ MVMAP2315_AP_GICC_BASE = 0xF0402000,
MVMAP2315_FLASH_BASE = 0xFE000000,
+ MVMAP2315_BM_CB_SECURITY_INIT = 0xFFE00040,
+ MVMAP2315_BM_CB_SHA_MSG_DIGEST = 0xFFE00044,
+ MVMAP2315_BM_CB_MEDIA_INIT = 0xFFE00084,
+ MVMAP2315_BM_CB_MEDIA_READ = 0xFFE00088,
+ MVMAP2315_BM_CB_MEDIA_WRITE = 0xFFE0008C,
+ MVMAP2315_BM_CB_MEDIA_SHUTDOWN = 0xFFE00098,
};
#endif /* __SOC_MARVELL_MVMAP2315_ADDRESS_MAP_H__ */
diff --git a/src/soc/marvell/mvmap2315/include/soc/bdb.h b/src/soc/marvell/mvmap2315/include/soc/bdb.h
new file mode 100644
index 0000000..42b94f1
--- /dev/null
+++ b/src/soc/marvell/mvmap2315/include/soc/bdb.h
@@ -0,0 +1,245 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2016 Marvell, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __SOC_MARVELL_MVMAP2315_BDB_H__
+#define __SOC_MARVELL_MVMAP2315_BDB_H__
+
+#include <stdint.h>
+#include <stdlib.h>
+
+/* bdb_image_type */
+enum {
+ BDB_RESERVED = 0,
+ SP_RW_FIRMWARE = 1,
+ AP_RW_FIRMWARE = 2,
+ MCU_FIRMWARE = 3,
+ APMU_FIRMWARE = 4,
+ WTM_RW_FIRMWARE = 5,
+ KERNEL_IMAGE = 128,
+ KERNEL_COMMAND_LINE = 129,
+ SIXTEEN_BIT_VMLINUX_HEADER = 130
+};
+
+#pragma pack(push, 1)
+struct bdb_header {
+ /* Magic number to identify struct = BDB_HEADER_MAGIC. */
+ u32 struct_magic;
+
+ /* Structure version = BDB_HEADER_VERSION{MAJOR,MINOR} */
+ u8 struct_major_version;
+ u8 struct_minor_version;
+
+ /* Size of structure in bytes */
+ u16 struct_size;
+
+ /* Recommended address in SP SRAM to load BDB. Set to -1 to use
+ * default address.
+ */
+ u64 bdb_load_address;
+
+ /* Size of the entire BDB in bytes */
+ u32 bdb_size;
+
+ /* Number of bytes following the BDB key which are signed by the BDB
+ * header signature.
+ */
+ u32 signed_size;
+
+ /* Size of OEM area 0 in bytes, or 0 if not present */
+ u32 oem_area_0_size;
+
+ /* Reserved; set 0 */
+ u8 reserved0[8];
+};
+
+#pragma pack(pop)
+
+#pragma pack(push, 1)
+struct bdb_key {
+ /* Magic number to identify struct = BDB_KEY_MAGIC. */
+ u32 struct_magic;
+
+ /* Structure version = BDB_KEY_VERSION{MAJOR,MINOR} */
+ u8 struct_major_version;
+ u8 struct_minor_version;
+
+ /* Size of structure in bytes, including variable-length key data */
+ u16 struct_size;
+
+ /* Hash algorithm (enum bdb_hash_alg) */
+ u8 hash_alg;
+
+ /* Signature algorithm (enum bdb_sig_alg) */
+ u8 sig_alg;
+
+ /* Reserved; set 0 */
+ u8 reserved0[2];
+
+ /* Key version */
+ u32 key_version;
+
+ /* Description; null-terminated ASCII */
+ char description[128];
+
+ /*
+ * Key data. Variable-length; size is struct_size -
+ * offset_of(bdb_key, key_data).
+ */
+ u8 key_data[];
+};
+
+#pragma pack(pop)
+
+#pragma pack(push, 1)
+struct bdb_sig {
+ /* Magic number to identify struct = BDB_SIG_MAGIC. */
+ u32 struct_magic;
+
+ /* Structure version = BDB_SIG_VERSION{MAJOR,MINOR} */
+ u8 struct_major_version;
+ u8 struct_minor_version;
+
+ /* Size of structure in bytes, including variable-length signature
+ * data.
+ */
+ u16 struct_size;
+
+ /* Hash algorithm used for this signature (enum bdb_hash_alg) */
+ u8 hash_alg;
+
+ /* Signature algorithm (enum bdb_sig_alg) */
+ u8 sig_alg;
+
+ /* Reserved; set 0 */
+ u8 reserved0[2];
+
+ /* Number of bytes of data signed by this signature */
+ u32 signed_size;
+
+ /* Description; null-terminated ASCII */
+ char description[128];
+
+ /* Signature data. Variable-length; size is struct_size -
+ * offset_of(bdb_sig, sig_data).
+ */
+ u8 sig_SOC_MARVELL_MVMAP2315_data[];
+};
+
+#pragma pack(pop)
+
+#pragma pack(push, 1)
+struct bdb_data {
+ /* Magic number to identify struct = BDB_DATA_MAGIC. */
+ u32 struct_magic;
+
+ /* Structure version = BDB_DATA_VERSION{MAJOR,MINOR} */
+ u8 struct_major_version;
+ u8 struct_minor_version;
+
+ /* Size of structure in bytes, NOT including hashes which follow. */
+ u16 struct_size;
+
+ /* Version of data (RW firmware) contained */
+ u32 data_version;
+
+ /* Size of OEM area 1 in bytes, or 0 if not present */
+ u32 oem_area_1_size;
+
+ /* Number of hashes which follow */
+ u8 num_hashes;
+
+ /* Size of each hash entry in bytes */
+ u8 hash_entry_size;
+
+ /* Reserved; set 0 */
+ u8 reserved0[2];
+
+ /* Number of bytes of data signed by the subkey,
+ * including this header
+ */
+ u32 signed_size;
+
+ /* Reserved; set 0 */
+ u8 reserved1[8];
+
+ /* Description; null-terminated ASCII */
+ char description[128];
+};
+
+#pragma pack(pop)
+
+/* Hash entries which follow the structure */
+#pragma pack(push, 1)
+struct bdb_hash {
+ /* Offset of data from start of partition */
+ u64 offset;
+
+ /* Size of data in bytes */
+ u32 size;
+
+ /* Partition number containing data */
+ u8 partition;
+
+ /* Type of data; enum bdb_data_type */
+ u8 type;
+
+ /* Reserved; set 0 */
+ u8 reserved0[2];
+
+ /* Address in RAM to load data. -1 means use default. */
+ u64 load_address;
+
+ /* SHA-256 hash digest */
+ u8 digest[32];
+};
+
+#pragma pack(pop)
+
+struct bdb_pointer {
+ /* Pointer to BDB header */
+ struct bdb_header *bdb_h;
+ /* Pointer to BDB Key */
+ struct bdb_key *bdb_k;
+ /* Pointer to OEM area 0 */
+ u8 *bdb_oem_0;
+ /* Pointer to subkey */
+ struct bdb_key *sub_k;
+ /* Pointer to BDB Header Signature */
+ struct bdb_sig *bdb_h_s;
+ /* Pointer to BDB Data Structure */
+ struct bdb_data *bdb_d;
+ /* Pointer to OEM Area 1 */
+ u8 *oem_1;
+ /* Pointer to Hashes */
+ struct bdb_hash *bdb_hash;
+ /* Pointer to BDB Data Signature */
+ struct bdb_sig *bdb_s;
+};
+
+/*
+ * find_bdb_image -- Search for image info in BDB via image type
+ *
+ * @pBDB_h: BDB base address
+ * @image_id image type field of desired image
+ *
+ * find_bdb_image will search the boot d block start at pBDB_h
+ * for a hash image entry with the type image_id. A pointer
+ * to the hash entry in question is returned if the search is
+ * successful, otherwise a NULL pointer is returned.
+ *
+ */
+void set_bdb_pointers(u8 *start_addr, struct bdb_pointer *bdb_in);
+
+#endif /* __SOC_MARVELL_MVMAP2315_BDB_H__ */
diff --git a/src/soc/marvell/mvmap2315/include/soc/bootrom.h b/src/soc/marvell/mvmap2315/include/soc/bootrom.h
new file mode 100644
index 0000000..3801def
--- /dev/null
+++ b/src/soc/marvell/mvmap2315/include/soc/bootrom.h
@@ -0,0 +1,125 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2016 Marvell, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __SOC_MARVELL_MVMAP2315_BOOTROM_H__
+#define __SOC_MARVELL_MVMAP2315_BOOTROM_H__
+
+#include <stdint.h>
+#include <stdlib.h>
+
+#include <soc/bdb.h>
+
+/*
+ * struct media_parms - flash read/write info for bootROM callbacks
+ *
+ * @flash_offset: offset from flash base address for read/write
+ * @local_buffer: buffer for read or write data.
+ * @size: Bytes of data to read/write
+ * @image_id: not needed, set to 0x0
+ * @partition_num: media partition number
+ *
+ * parameters passed to flash read and write operations. local_buffer
+ * is the address of a buffer of at least size bytes. For write operations,
+ * this buffer should be populated with the data to be written to flash
+ * before the call to media_write. For read operations, the buffer
+ * will be populated during the call to media_read.
+ *
+ */
+struct media_params {
+ u32 flash_offset;
+ u32 local_buffer;
+ u32 size;
+ u32 image_id;
+ u32 partition_num;
+};
+
+/*
+ * function pointer type definitions for the bootrom callback functions
+ *
+ */
+typedef u32 (*security_init_F)(u32 adv_ver);
+typedef u32 (*sha_msg_digest_F)(const u8 *src_msg_in,
+ u32 src_msg_len,
+ u8 *msg_digest_out,
+ u32 digest_len);
+typedef u32 (*media_init_F)(u32 media_id,
+ u32 context,
+ u32 clock_input_mhz);
+typedef u32 (*media_read_F)(u32 media_id,
+ u32 context,
+ struct media_params *);
+typedef u32 (*media_write_F)(u32 media_id,
+ u32 context,
+ struct media_params *);
+typedef u32 (*media_shutdown_F)(u32 media_id,
+ u32 context,
+ struct media_params *);
+
+/*
+ * struct bootrom_ops - bootrom callback functions
+ *
+ * @security_init: used to initialize BCM hardware.
+ * Must be called prior to using the sha_message_digest callback.
+ *
+ * @sha_msg_digest: Calculates the digest_len SHA hash of the src_msg_len
+ * byte image starting at address src_msg_in, and places the result at
+ * msg_digest_out.
+ *
+ * @media_init: Configures a flash media device.
+ * Call before media_read or media_write.
+ *
+ * @media_read: Read data from specified media.
+ *
+ * @media_write: Write data to specified media.
+ *
+ * @media_shutdown: Shut down flash device.
+ *
+ * The MVMAP2315 bootROM provides callback functions to assist SP RW code
+ * in loading and validating additional images that are specified in the
+ * validated boot descriptor block.
+ *
+ */
+struct bootrom_ops {
+ security_init_F security_init;
+ sha_msg_digest_F sha_msg_digest;
+ media_init_F media_init;
+ media_read_F media_read;
+ media_write_F media_write;
+ media_shutdown_F media_shutdown;
+};
+
+/*
+ * load_and_validate_image - find image info in BDB, load to specified address,
+ * calculate image hash, and compare BDB's expected hash.
+ *
+ * @bdb_info bdb_pointer structure populated with pointers to BDB's sections
+ * @image_type type of image for which to search
+ *
+ * load_and_validate_image searches the designated BDB's image hash entries
+ * for an image of type image_type. If the search is successful, bootrom
+ * callbacks are used to load the image from the flash offset address specified
+ * in the BDB entry in question to the memory address specified in that entry,
+ * and then validate the SHA256 hash of the image against the expected value
+ * specified in the BDB. If the image load or SHA validation checks fail,
+ * the function image_failure() is called to set appropriate flags in the
+ * VB_POWER_CLEAR registers, and the entire SoC is reset so that the bootrom
+ * can attempt to boot using the alternate BDB/image. If the image load and
+ * SHA validation passes, the function returns to the calling function.
+ *
+ */
+void load_and_validate_image(struct bdb_pointer *bdb_info,
+ u8 image_type);
+
+#endif /* __SOC_MARVELL_MVMAP2315_BOOTROM_H__ */
diff --git a/src/soc/marvell/mvmap2315/include/soc/clock.h b/src/soc/marvell/mvmap2315/include/soc/clock.h
index 12d32c1..a982198 100644
--- a/src/soc/marvell/mvmap2315/include/soc/clock.h
+++ b/src/soc/marvell/mvmap2315/include/soc/clock.h
@@ -50,7 +50,7 @@ static struct mvmap2315_gentimer_regs * const mvmap2315_gentimer
= (void *)MVMAP2315_GENTIMER_BASE;
#define MVMAP2315_PLL_LOCK BIT(0)
-#define MVMAP2315_PLL_BYPASS_EN BIT(16)
+#define MVMAP2315_PLL_BYPASS_EN BIT(16)
struct mvmap2315_main_pll_regs {
u32 rst_prediv;
@@ -70,7 +70,8 @@ check_member(mvmap2315_main_pll_regs, reserve_out, 0x28);
static struct mvmap2315_main_pll_regs * const mvmap2315_pll
= (void *)MVMAP2315_MAIN_PLL_BASE;
-#define MVMAP2315_UART_CLK_EN BIT(0)
+#define MVMAP2315_UART_CLK_EN BIT(1)
+#define MVMAP2315_SDMMC_CLK_RSTN BIT(0)
struct mvmap2315_apmu_clk_regs {
u32 uartfracdivcfg0;
u8 _reserved0[0x0c];
diff --git a/src/soc/marvell/mvmap2315/include/soc/gic.h b/src/soc/marvell/mvmap2315/include/soc/gic.h
new file mode 100644
index 0000000..520ea51
--- /dev/null
+++ b/src/soc/marvell/mvmap2315/include/soc/gic.h
@@ -0,0 +1,412 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2016 Marvell, Inc.
+ *
+ * This program is free software;
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY;
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+#ifndef __SOC_MARVELL_MVMAP2315_GIC_H__
+#define __SOC_MARVELL_MVMAP2315_GIC_H__
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <types.h>
+
+#define MVMAP2315_BCM_GICC_EN0 BIT(0)
+#define MVMAP2315_BCM_GICD_FIQ_EN BIT(3)
+struct mvmap2315_bcm_gicc_regs {
+ u32 ctrl;
+ u32 pmr;
+ u32 bpr;
+ u32 iar;
+ u32 eoir;
+ u32 rpr;
+ u32 hppir;
+ u32 abpr;
+ u32 aiar;
+ u32 aeoir;
+ u32 ahppir;
+};
+
+check_member(mvmap2315_bcm_gicc_regs, ahppir, 0x28);
+static struct mvmap2315_bcm_gicc_regs * const mvmap2315_bcm_gicc
+ = (void *)MVMAP2315_BCM_GICC_BASE;
+
+#define MVMAP2315_BCM_GICD_EN0 BIT(0)
+struct mvmap2315_bcm_gicd_regs {
+ u32 ctrl;
+ u32 typer;
+ u32 iidr;
+ u8 _reserved0[0x74];
+ u32 igroup0;
+ u32 igroup1;
+ u32 igroup2;
+ u32 igroup3;
+ u32 igroup4;
+ u32 igroup5;
+ u32 igroup6;
+ u32 igroup7;
+ u32 igroup8;
+ u32 igroup9;
+ u32 igroup10;
+ u32 igroup11;
+ u8 _reserved1[0x50];
+ u32 isenable0;
+ u32 isenable1;
+ u32 isenable2;
+ u32 isenable3;
+ u32 isenable4;
+ u32 isenable5;
+ u32 isenable6;
+ u32 isenable7;
+ u32 isenable8;
+ u32 isenable9;
+ u32 isenable10;
+ u32 isenable11;
+ u8 _reserved2[0x50];
+ u32 icenable0;
+ u32 icenable1;
+ u32 icenable2;
+ u32 icenable3;
+ u32 icenable4;
+ u32 icenable5;
+ u32 icenable6;
+ u32 icenable7;
+ u32 icenable8;
+ u32 icenable9;
+ u32 icenable10;
+ u32 icenable11;
+ u8 _reserved3[0x50];
+ u32 ispendr0;
+ u32 ispendr1;
+ u32 ispendr2;
+ u32 ispendr3;
+ u32 ispendr4;
+ u32 ispendr5;
+ u32 ispendr6;
+ u32 ispendr7;
+ u32 ispendr8;
+ u32 ispendr9;
+ u32 ispendr10;
+ u32 ispendr11;
+ u8 _reserved4[0x50];
+ u32 icpendr0;
+ u32 icpendr1;
+ u32 icpendr2;
+ u32 icpendr3;
+ u32 icpendr4;
+ u32 icpendr5;
+ u32 icpendr6;
+ u32 icpendr7;
+ u32 icpendr8;
+ u32 icpendr9;
+ u32 icpendr10;
+ u32 icpendr11;
+ u8 _reserved5[0x50];
+ u32 isactive0;
+ u32 isactive1;
+ u32 isactive2;
+ u32 isactive3;
+ u32 isactive4;
+ u32 isactive5;
+ u32 isactive6;
+ u32 isactive7;
+ u32 isactive8;
+ u32 isactive9;
+ u32 isactive10;
+ u32 isactive11;
+ u8 _reserved6[0x50];
+ u32 icactive0;
+ u32 icactive1;
+ u32 icactive2;
+ u32 icactive3;
+ u32 icactive4;
+ u32 icactive5;
+ u32 icactive6;
+ u32 icactive7;
+ u32 icactive8;
+ u32 icactive9;
+ u32 icactive10;
+ u32 icactive11;
+ u8 _reserved7[0x50];
+ u32 ipriority0;
+ u32 ipriority1;
+ u32 ipriority2;
+ u32 ipriority3;
+ u32 ipriority4;
+ u32 ipriority5;
+ u32 ipriority6;
+ u32 ipriority7;
+ u32 ipriority8;
+ u32 ipriority9;
+ u32 ipriority10;
+ u32 ipriority11;
+ u32 ipriority12;
+ u32 ipriority13;
+ u32 ipriority14;
+ u32 ipriority15;
+ u32 ipriority16;
+ u32 ipriority17;
+ u32 ipriority18;
+ u32 ipriority19;
+ u32 ipriority20;
+ u32 ipriority21;
+ u32 ipriority22;
+ u32 ipriority23;
+ u32 ipriority24;
+ u32 ipriority25;
+ u32 ipriority26;
+ u32 ipriority27;
+ u32 ipriority28;
+ u32 ipriority29;
+ u32 ipriority30;
+ u32 ipriority31;
+ u32 ipriority32;
+ u32 ipriority33;
+ u32 ipriority34;
+ u32 ipriority35;
+ u32 ipriority36;
+ u32 ipriority37;
+ u32 ipriority38;
+ u32 ipriority39;
+ u32 ipriority40;
+ u32 ipriority41;
+ u32 ipriority42;
+ u32 ipriority43;
+ u32 ipriority44;
+ u32 ipriority45;
+ u32 ipriority46;
+ u32 ipriority47;
+ u32 ipriority48;
+ u32 ipriority49;
+ u32 ipriority50;
+ u32 ipriority51;
+ u32 ipriority52;
+ u32 ipriority53;
+ u32 ipriority54;
+ u32 ipriority55;
+ u32 ipriority56;
+ u32 ipriority57;
+ u32 ipriority58;
+ u32 ipriority59;
+ u32 ipriority60;
+ u32 ipriority61;
+ u32 ipriority62;
+ u32 ipriority63;
+ u32 ipriority64;
+ u32 ipriority65;
+ u32 ipriority66;
+ u32 ipriority67;
+ u32 ipriority68;
+ u32 ipriority69;
+ u32 ipriority70;
+ u32 ipriority71;
+ u32 ipriority72;
+ u32 ipriority73;
+ u32 ipriority74;
+ u32 ipriority75;
+ u32 ipriority76;
+ u32 ipriority77;
+ u32 ipriority78;
+ u32 ipriority79;
+ u32 ipriority80;
+ u32 ipriority81;
+ u32 ipriority82;
+ u32 ipriority83;
+ u32 ipriority84;
+ u32 ipriority85;
+ u32 ipriority86;
+ u32 ipriority87;
+ u32 ipriority88;
+ u32 ipriority89;
+ u32 ipriority90;
+ u32 ipriority91;
+ u32 ipriority92;
+ u32 ipriority93;
+ u32 ipriority94;
+ u32 ipriority95;
+ u8 _reserved8[0x280];
+ u32 itargets0;
+ u32 itargets1;
+ u32 itargets2;
+ u32 itargets3;
+ u32 itargets4;
+ u32 itargets5;
+ u32 itargets6;
+ u32 itargets7;
+ u32 itargets8;
+ u32 itargets9;
+ u32 itargets10;
+ u32 itargets11;
+ u32 itargets12;
+ u32 itargets13;
+ u32 itargets14;
+ u32 itargets15;
+ u32 itargets16;
+ u32 itargets17;
+ u32 itargets18;
+ u32 itargets19;
+ u32 itargets20;
+ u32 itargets21;
+ u32 itargets22;
+ u32 itargets23;
+ u32 itargets24;
+ u32 itargets25;
+ u32 itargets26;
+ u32 itargets27;
+ u32 itargets28;
+ u32 itargets29;
+ u32 itargets30;
+ u32 itargets31;
+ u32 itargets32;
+ u32 itargets33;
+ u32 itargets34;
+ u32 itargets35;
+ u32 itargets36;
+ u32 itargets37;
+ u32 itargets38;
+ u32 itargets39;
+ u32 itargets40;
+ u32 itargets41;
+ u32 itargets42;
+ u32 itargets43;
+ u32 itargets44;
+ u32 itargets45;
+ u32 itargets46;
+ u32 itargets47;
+ u32 itargets48;
+ u32 itargets49;
+ u32 itargets50;
+ u32 itargets51;
+ u32 itargets52;
+ u32 itargets53;
+ u32 itargets54;
+ u32 itargets55;
+ u32 itargets56;
+ u32 itargets57;
+ u32 itargets58;
+ u32 itargets59;
+ u32 itargets60;
+ u32 itargets61;
+ u32 itargets62;
+ u32 itargets63;
+ u32 itargets64;
+ u32 itargets65;
+ u32 itargets66;
+ u32 itargets67;
+ u32 itargets68;
+ u32 itargets69;
+ u32 itargets70;
+ u32 itargets71;
+ u32 itargets72;
+ u32 itargets73;
+ u32 itargets74;
+ u32 itargets75;
+ u32 itargets76;
+ u32 itargets77;
+ u32 itargets78;
+ u32 itargets79;
+ u32 itargets80;
+ u32 itargets81;
+ u32 itargets82;
+ u32 itargets83;
+ u32 itargets84;
+ u32 itargets85;
+ u32 itargets86;
+ u32 itargets87;
+ u32 itargets88;
+ u32 itargets89;
+ u32 itargets90;
+ u32 itargets91;
+ u32 itargets92;
+ u32 itargets93;
+ u32 itargets94;
+ u32 itargets95;
+ u8 _reserved9[0x280];
+ u32 icfg0;
+ u32 icfg1;
+ u32 icfg2;
+ u32 icfg3;
+ u32 icfg4;
+ u32 icfg5;
+ u32 icfg6;
+ u32 icfg7;
+ u32 icfg8;
+ u32 icfg9;
+ u32 icfg10;
+ u32 icfg11;
+ u32 icfg12;
+ u32 icfg13;
+ u32 icfg14;
+ u32 icfg15;
+ u32 icfg16;
+ u32 icfg17;
+ u32 icfg18;
+ u32 icfg19;
+ u32 icfg20;
+ u32 icfg21;
+ u32 icfg22;
+ u32 icfg23;
+ u8 _reserved10[0xa0];
+ u32 ppisr;
+ u32 spisr0;
+ u32 spisr1;
+ u32 spisr2;
+ u32 spisr3;
+ u32 spisr4;
+ u32 spisr5;
+ u32 spisr6;
+ u32 spisr7;
+ u32 spisr8;
+ u32 spisr9;
+ u32 spisr10;
+ u8 _reserved11[0xd0];
+ u32 nsacr0;
+ u32 nsacr1;
+ u32 nsacr2;
+ u32 nsacr3;
+ u32 nsacr4;
+ u32 nsacr5;
+ u32 nsacr6;
+ u32 nsacr7;
+ u32 nsacr8;
+ u32 nsacr9;
+ u32 nsacr10;
+ u32 nsacr11;
+ u32 nsacr12;
+ u32 nsacr13;
+ u32 nsacr14;
+ u32 nsacr15;
+ u32 nsacr16;
+ u32 nsacr17;
+ u32 nsacr18;
+ u32 nsacr19;
+ u32 nsacr20;
+ u32 nsacr21;
+ u8 _reserved12[0xa8];
+ u32 sgir;
+ u8 _reserved13[0x0c];
+ u32 cpendsgir0;
+ u32 cpendsgir1;
+ u32 cpendsgir2;
+ u32 cpendsgir3;
+ u32 spendsgir0;
+ u32 spendsgir1;
+ u32 spendsgir2;
+ u32 spendsgir3;
+};
+
+check_member(mvmap2315_bcm_gicd_regs, spendsgir3, 0xF2C);
+static struct mvmap2315_bcm_gicd_regs * const mvmap2315_bcm_gicd
+ = (void *)MVMAP2315_BCM_GICD_BASE;
+
+void enable_bcm_gic(void);
+
+#endif /* __SOC_MARVELL_MVMAP2315_GIC_H__ */
diff --git a/src/soc/marvell/mvmap2315/romstage.c b/src/soc/marvell/mvmap2315/romstage.c
index 6752461..bc9172e 100644
--- a/src/soc/marvell/mvmap2315/romstage.c
+++ b/src/soc/marvell/mvmap2315/romstage.c
@@ -16,8 +16,12 @@
#include <console/console.h>
#include <console/uart.h>
#include <program_loading.h>
+#include <soc/addressmap.h>
#include <soc/assert.h>
+#include <soc/bdb.h>
+#include <soc/bootrom.h>
#include <soc/clock.h>
+#include <soc/gic.h>
#include <soc/monotonic_timer.h>
#include <soc/power.h>
#include <soc/romstage.h>
@@ -30,10 +34,14 @@
*/
void main(void)
{
+ struct bdb_pointer bdb_info;
u32 boot_path;
configure_main_clk_pll();
+ /* enabling BCM GIC for Bootrom callbacks */
+ enable_bcm_gic();
+
timestamp_init(0);
asm volatile ("bl cpu_enable_icache" : : : "r0", "r1");
@@ -50,6 +58,11 @@ void main(void)
timestamp_add_now(TS_START_ROMSTAGE);
+ set_bdb_pointers((u8 *)MVMAP2315_BDB_LCM_BASE, &bdb_info);
+
+ printk(BIOS_INFO, "loading and validating APMU FIRMWARE\n");
+ load_and_validate_image(&bdb_info, APMU_FIRMWARE);
+
boot_path = get_boot_path();
switch (boot_path) {
More information about the coreboot-gerrit
mailing list