hakim giydan (hgiydan(a)marvell.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/16161
-gerrit
commit 755b8c160fa246ded52d8588d47d4da9a2814dc1
Author: Hakim Giydan <hgiydan(a)marvell.com>
Date: Wed Aug 17 13:54:38 2016 -0700
soc/marvell/mvmap2315: Add NVM driver
This driver uses BootROM callback to read and write
to the nvm using I2C.
Testing: booted successfully.
Change-Id: I8639af3e004f6631d7e596507c106159835f979f
Signed-off-by: Hakim Giydan <hgiydan(a)marvell.com>
---
src/soc/marvell/mvmap2315/Makefile.inc | 1 +
src/soc/marvell/mvmap2315/include/soc/nvm.h | 25 +++++++
src/soc/marvell/mvmap2315/nvm.c | 105 ++++++++++++++++++++++++++++
3 files changed, 131 insertions(+)
diff --git a/src/soc/marvell/mvmap2315/Makefile.inc b/src/soc/marvell/mvmap2315/Makefile.inc
index 0d1ef2b..e16286b 100644
--- a/src/soc/marvell/mvmap2315/Makefile.inc
+++ b/src/soc/marvell/mvmap2315/Makefile.inc
@@ -27,6 +27,7 @@ bootblock-y += gpio.c
bootblock-y += flash.c
bootblock-y += load_validate.c
bootblock-y += media.c
+bootblock-y += nvm.c
bootblock-y += pinmux.c
bootblock-y += pmic.c
bootblock-y += reset.c
diff --git a/src/soc/marvell/mvmap2315/include/soc/nvm.h b/src/soc/marvell/mvmap2315/include/soc/nvm.h
new file mode 100644
index 0000000..ede0d97
--- /dev/null
+++ b/src/soc/marvell/mvmap2315/include/soc/nvm.h
@@ -0,0 +1,25 @@
+/*
+ * 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_NVM_H__
+#define __SOC_MARVELL_MVMAP2315_NVM_H__
+
+#define MVMAP2315_NVM_LOCKDOWN_FLAG BIT(0)
+
+u32 nvm_init(void);
+u32 nvm_read(u32 offset, u32 *buffer, u32 size);
+u32 nvm_write(u32 offset, u32 *buffer, u32 size);
+void nvm_lockdown(void);
+
+#endif /* __SOC_MARVELL_MVMAP2315_NVM_H__ */
diff --git a/src/soc/marvell/mvmap2315/nvm.c b/src/soc/marvell/mvmap2315/nvm.c
new file mode 100644
index 0000000..7e33e98
--- /dev/null
+++ b/src/soc/marvell/mvmap2315/nvm.c
@@ -0,0 +1,105 @@
+/*
+ * 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 <stddef.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#include <arch/io.h>
+#include <console/console.h>
+#include <soc/bdb.h>
+#include <soc/clock.h>
+#include <soc/flash.h>
+#include <soc/load_validate.h>
+#include <soc/nvm.h>
+
+struct flash_ops nvm_callbacks = {
+ .init = (void *)MVMAP2315_FLASH_INIT,
+ .read = (void *)MVMAP2315_FLASH_READ,
+ .write = (void *)MVMAP2315_FLASH_WRITE,
+};
+
+static void set_nvm_parameters(struct flash_params *eeprom_info, u32 offset,
+ u32 *buffer, u32 size)
+{
+ eeprom_info->offset = offset;
+ eeprom_info->buff = (u32)buffer;
+ eeprom_info->size = size;
+ eeprom_info->id = 0x0;
+ eeprom_info->partition = 0x0;
+}
+
+u32 nvm_init(void)
+{
+ int rc;
+
+ clrbits_le32(&mvmap2315_apmu_clk->apaonclk_sdmmc_clkgenconfig,
+ MVMAP2315_SDMMC_CLK_RSTN);
+ setbits_le32(&mvmap2315_apmu_clk->apaonclk_sdmmc_clkgenconfig,
+ MVMAP2315_SDMMC_CLK_RSTN);
+
+ rc = nvm_callbacks.init(MVMAP2315_EEPROM, 0, 0);
+
+ if (rc)
+ printk(BIOS_DEBUG, "nvm_init failed with rc=%x.\n", rc);
+
+ return rc;
+}
+
+u32 nvm_read(u32 offset, u32 *buffer, u32 size)
+{
+ struct flash_params eeprom_read_info;
+ u32 rc;
+
+ set_nvm_parameters(&eeprom_read_info, offset, buffer, size);
+
+ rc = nvm_init();
+
+ if (rc)
+ return rc;
+
+ rc = nvm_callbacks.read(MVMAP2315_EEPROM, 0, &eeprom_read_info);
+
+ if (rc)
+ printk(BIOS_INFO, "nvm_read callback failed, rc=%x\n", rc);
+
+ return rc;
+}
+
+u32 nvm_write(u32 offset, u32 *buffer, u32 size)
+{
+ struct flash_params eeprom_read_info;
+ u32 rc;
+
+ set_nvm_parameters(&eeprom_read_info, offset, buffer, size);
+
+ rc = nvm_init();
+
+ if (rc)
+ return rc;
+
+ rc = nvm_callbacks.write(MVMAP2315_EEPROM, 0, &eeprom_read_info);
+
+ if (rc)
+ printk(BIOS_INFO, "nvm_write callback failed, rc=%x\n", rc);
+
+ return rc;
+}
+
+void nvm_lockdown(void)
+{
+ setbits_le32(&mvmap2315_mcu_secconfig->boot_hw_lockdown_nvm,
+ MVMAP2315_NVM_LOCKDOWN_FLAG);
+}
hakim giydan (hgiydan(a)marvell.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15335
-gerrit
commit c8d3b4bf51b1db7a0b5d5b64b3c765a52959df7e
Author: Hakim Giydan <hgiydan(a)marvell.com>
Date: Wed Aug 17 13:44:27 2016 -0700
arch/arm: Add armv7-r configuration
This change adds armv7-r support for all stages.
armv7-r is an ARM processor based on the Cortex-R series.
Currently, there is support for armv7-a and armv7-m and
armv7-a files has been modfied to accommodate armv7-r by
adding ENV_ARMV7_A, ENV_ARMV7_R and ENV_ARMV7_M constants
to src/include/rules.h.
armv7-r exceptions support will added in a later time.
Change-Id: If94415d07fd6bd96c43d087374f609a2211f1885
Signed-off-by: Hakim Giydan <hgiydan(a)marvell.com>
---
src/arch/arm/armv7/Kconfig | 16 +++++++++++
src/arch/arm/armv7/Makefile.inc | 59 +++++++++++++++++++++++++++++++++++++--
src/arch/arm/armv7/cpu.S | 12 ++++++++
src/arch/arm/armv7/exception_m.c | 36 ------------------------
src/arch/arm/armv7/exception_mr.c | 36 ++++++++++++++++++++++++
src/include/rules.h | 13 +++++++++
util/xcompile/xcompile | 2 +-
7 files changed, 134 insertions(+), 40 deletions(-)
diff --git a/src/arch/arm/armv7/Kconfig b/src/arch/arm/armv7/Kconfig
index 0ab3542..3734426 100644
--- a/src/arch/arm/armv7/Kconfig
+++ b/src/arch/arm/armv7/Kconfig
@@ -19,3 +19,19 @@ config ARCH_BOOTBLOCK_ARMV7_M
config ARCH_VERSTAGE_ARMV7_M
def_bool n
select ARCH_VERSTAGE_ARM
+
+config ARCH_BOOTBLOCK_ARMV7_R
+ def_bool n
+ select ARCH_BOOTBLOCK_ARM
+
+config ARCH_VERSTAGE_ARMV7_R
+ def_bool n
+ select ARCH_VERSTAGE_ARM
+
+config ARCH_ROMSTAGE_ARMV7_R
+ def_bool n
+ select ARCH_ROMSTAGE_ARM
+
+config ARCH_RAMSTAGE_ARMV7_R
+ def_bool n
+ select ARCH_RAMSTAGE_ARM
diff --git a/src/arch/arm/armv7/Makefile.inc b/src/arch/arm/armv7/Makefile.inc
index 2e9c49c..d978f00 100644
--- a/src/arch/arm/armv7/Makefile.inc
+++ b/src/arch/arm/armv7/Makefile.inc
@@ -16,10 +16,12 @@
###############################################################################
armv7_flags = -mthumb -I$(src)/arch/arm/include/armv7/ -D__COREBOOT_ARM_ARCH__=7
-armv7-a_flags = -march=armv7-a $(armv7_flags)
-armv7-m_flags = -march=armv7-m $(armv7_flags)
+armv7-a_flags = -march=armv7-a $(armv7_flags) -D__COREBOOT_ARM_V7_A__
+armv7-m_flags = -march=armv7-m $(armv7_flags) -D__COREBOOT_ARM_V7_M__
+armv7-r_flags = -march=armv7-r $(armv7_flags) -D__COREBOOT_ARM_V7_R__
armv7_asm_flags = -Wa,-mthumb -Wa,-mimplicit-it=always -Wa,-mno-warn-deprecated
+armv7-r_asm_flags = $(armv7-r_flags) $(armv7_asm_flags)
###############################################################################
# bootblock
@@ -46,9 +48,22 @@ bootblock-S-ccopts += $(armv7_asm_flags)
ifneq ($(CONFIG_BOOTBLOCK_CUSTOM),y)
bootblock-y += bootblock_m.S
endif
-bootblock-y += exception_m.c
+bootblock-y += exception_mr.c
bootblock-y += cache_m.c
+else ifeq ($(CONFIG_ARCH_BOOTBLOCK_ARMV7_R),y)
+bootblock-generic-ccopts += $(armv7-r_flags)
+bootblock-S-ccopts += $(armv7-r_asm_flags)
+
+ifneq ($(CONFIG_BOOTBLOCK_CUSTOM),y)
+bootblock-y += bootblock.S
+endif
+
+bootblock-y += cache.c
+bootblock-y += cpu.S
+bootblock-y += exception_mr.c
+bootblock-y += mmu.c
+
endif # CONFIG_ARCH_BOOTBLOCK_ARMV7
################################################################################
@@ -73,6 +88,17 @@ libverstage-S-ccopts += $(armv7_asm_flags)
verstage-generic-ccopts += $(armv7-m_flags)
verstage-S-ccopts += $(armv7_asm_flags)
+else ifeq ($(CONFIG_ARCH_VERSTAGE_ARMV7_R),y)
+libverstage-generic-ccopts += $(armv7-r_flags)
+libverstage-S-ccopts += $(armv7-r_asm_flags)
+verstage-generic-ccopts += $(armv7-r_flags)
+verstage-S-ccopts += $(armv7-r_asm_flags)
+
+verstage-y += cache.c
+verstage-y += cpu.S
+verstage-y += exception_mr.c
+verstage-y += mmu.c
+
endif # CONFIG_ARCH_VERSTAGE_ARMV7_M
################################################################################
@@ -91,6 +117,18 @@ romstage-S-ccopts += $(armv7_asm_flags)
rmodules_arm-generic-ccopts += $(armv7-a_flags)
rmodules_arm-S-ccopts += $(armv7_asm_flags)
+else ifeq ($(CONFIG_ARCH_ROMSTAGE_ARMV7_R),y)
+romstage-y += cache.c
+romstage-y += cpu.S
+romstage-y += exception_mr.c
+romstage-y += mmu.c
+
+romstage-generic-ccopts += $(armv7-r_flags)
+romstage-S-ccopts += $(armv7-r_asm_flags)
+
+rmodules_arm-generic-ccopts += $(armv7-r_flags)
+rmodules_arm-S-ccopts += $(armv7-r_asm_flags)
+
endif # CONFIG_ARCH_ROMSTAGE_ARMV7
###############################################################################
@@ -111,4 +149,19 @@ ramstage-S-ccopts += $(armv7_asm_flags)
# All rmodule code is armv7 if ramstage is armv7.
rmodules_arm-generic-ccopts += $(armv7-a_flags)
rmodules_arm-S-ccopts += $(armv7_asm_flags)
+
+else ifeq ($(CONFIG_ARCH_RAMSTAGE_ARMV7_R),y)
+
+ramstage-y += cache.c
+ramstage-y += cpu.S
+ramstage-y += exception_mr.c
+ramstage-y += mmu.c
+
+ramstage-generic-ccopts += $(armv7-r_flags)
+ramstage-S-ccopts += $(armv7-r_asm_flags)
+
+# All rmodule code is armv7 if ramstage is armv7.
+rmodules_arm-generic-ccopts += $(armv7-r_flags)
+rmodules_arm-S-ccopts += $(armv7-r_asm_flags)
+
endif # CONFIG_ARCH_RAMSTAGE_ARMV7
diff --git a/src/arch/arm/armv7/cpu.S b/src/arch/arm/armv7/cpu.S
index 6c00f62..21a16d2 100644
--- a/src/arch/arm/armv7/cpu.S
+++ b/src/arch/arm/armv7/cpu.S
@@ -31,6 +31,7 @@
*/
#include <arch/asm.h>
+#include <rules.h>
/*
* Dcache invalidations by set/way work by passing a [way:sbz:set:sbz:level:0]
@@ -126,6 +127,7 @@ ENTRY(arm_init_caches)
/* Flush and invalidate dcache in ascending order */
bl dcache_invalidate_all
+#if ENV_ARMV7_A
/* Deactivate MMU (0), Alignment Check (1) and DCache (2) */
and r4, # ~(1 << 0) & ~(1 << 1) & ~(1 << 2)
mcr p15, 0, r4, c1, c0, 0
@@ -133,6 +135,16 @@ ENTRY(arm_init_caches)
/* Invalidate icache and TLB for good measure */
mcr p15, 0, r0, c7, c5, 0
mcr p15, 0, r0, c8, c7, 0
+#endif
+
+#if ENV_ARMV7_R
+ /* Deactivate Alignment Check (1) and DCache (2) */
+ and r4, # ~(1 << 1) & ~(1 << 2)
+ mcr p15, 0, r4, c1, c0, 0
+
+ /* Invalidate icache for good measure */
+ mcr p15, 0, r0, c7, c5, 0
+#endif
dsb
isb
diff --git a/src/arch/arm/armv7/exception_m.c b/src/arch/arm/armv7/exception_m.c
deleted file mode 100644
index d76cc6a..0000000
--- a/src/arch/arm/armv7/exception_m.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * This file is part of the libpayload project.
- *
- * Copyright 2013 Google Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <arch/exception.h>
-#include <console/console.h>
-
-void exception_init(void)
-{
- printk(BIOS_DEBUG, "Exception handlers not installed.\n");
-}
diff --git a/src/arch/arm/armv7/exception_mr.c b/src/arch/arm/armv7/exception_mr.c
new file mode 100644
index 0000000..d76cc6a
--- /dev/null
+++ b/src/arch/arm/armv7/exception_mr.c
@@ -0,0 +1,36 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright 2013 Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <arch/exception.h>
+#include <console/console.h>
+
+void exception_init(void)
+{
+ printk(BIOS_DEBUG, "Exception handlers not installed.\n");
+}
diff --git a/src/include/rules.h b/src/include/rules.h
index 89fdd21..a632804 100644
--- a/src/include/rules.h
+++ b/src/include/rules.h
@@ -131,6 +131,19 @@
#elif __COREBOOT_ARM_ARCH__ == 7
#define ENV_ARMV4 0
#define ENV_ARMV7 1
+#if defined(__COREBOOT_ARM_V7_A__)
+#define ENV_ARMV7_A 1
+#define ENV_ARMV7_M 0
+#define ENV_ARMV7_R 0
+#elif defined(__COREBOOT_ARM_V7_M__)
+#define ENV_ARMV7_A 0
+#define ENV_ARMV7_M 1
+#define ENV_ARMV7_R 0
+#elif defined(__COREBOOT_ARM_V7_R__)
+#define ENV_ARMV7_A 0
+#define ENV_ARMV7_M 0
+#define ENV_ARMV7_R 1
+#endif
#else
#define ENV_ARMV4 0
#define ENV_ARMV7 0
diff --git a/util/xcompile/xcompile b/util/xcompile/xcompile
index 6c75da6..37e6404 100755
--- a/util/xcompile/xcompile
+++ b/util/xcompile/xcompile
@@ -316,7 +316,7 @@ arch_config_arm() {
TBFDARCHS="littlearm"
TCLIST="armv7-a armv7a arm"
TWIDTH="32"
- TSUPP="arm armv4 armv7 armv7_m"
+ TSUPP="arm armv4 armv7 armv7_m armv7_r"
TABI="eabi"
}