aboutsummaryrefslogtreecommitdiff
path: root/src/soc/intel/common/spi_flash.c
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2017-12-14 15:32:37 -0700
committerAaron Durbin <adurbin@chromium.org>2017-12-16 04:15:29 +0000
commit2b96f421e6539ceae5c1d0dcd07ed4dfe8a6016a (patch)
tree1a22758a7efb32f14193cadedacb339ab013bece /src/soc/intel/common/spi_flash.c
parent410f3b402a29af09070520bd13ea90e75ae2f5ec (diff)
soc/intel/common/fast_spi: implement spi_flash_ctrlr_protect_region()
In the fast spi support implement the callback for flash_protect(). This removes the need for having SOC_INTEL_COMMON_SPI_FLASH_PROTECT Kconfig option as well spi_flash_get_fpr_info() and separate spi_flash.[ch]. BUG=b:69614064 Change-Id: Iaf3b599a13a756262d3f36bae60de4f7fd00e7dc Signed-off-by: Aaron Durbn <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/22881 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Subrata Banik <subrata.banik@intel.com>
Diffstat (limited to 'src/soc/intel/common/spi_flash.c')
-rw-r--r--src/soc/intel/common/spi_flash.c66
1 files changed, 0 insertions, 66 deletions
diff --git a/src/soc/intel/common/spi_flash.c b/src/soc/intel/common/spi_flash.c
deleted file mode 100644
index c7717c9fe9..0000000000
--- a/src/soc/intel/common/spi_flash.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright 2016 Google 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 "spi_flash.h"
-
-/*
- * Protect range of SPI flash defined by [start, start+size-1] using Flash
- * Protected Range (FPR) register if available.
- */
-int spi_flash_protect(u32 start, u32 size)
-{
- struct fpr_info fpr_info;
- u32 end = start + size - 1;
- u32 reg;
- int fpr;
- uintptr_t fpr_base;
-
- if (spi_flash_get_fpr_info(&fpr_info) == -1) {
- printk(BIOS_ERR, "ERROR: FPR Info not found!\n");
- return -1;
- }
-
- fpr_base = fpr_info.base;
-
- /* Find first empty FPR */
- for (fpr = 0; fpr < fpr_info.max; fpr++) {
- reg = read32((void *)fpr_base);
- if (reg == 0)
- break;
- fpr_base += sizeof(uint32_t);
- }
-
- if (fpr >= fpr_info.max) {
- printk(BIOS_ERR, "ERROR: No SPI FPR free!\n");
- return -1;
- }
-
- /* Set protected range base and limit */
- reg = SPI_FPR(start, end) | SPI_FPR_WPE;
-
- /* Set the FPR register and verify it is protected */
- write32((void *)fpr_base, reg);
- reg = read32((void *)fpr_base);
- if (!(reg & SPI_FPR_WPE)) {
- printk(BIOS_ERR, "ERROR: Unable to set SPI FPR %d\n", fpr);
- return -1;
- }
-
- printk(BIOS_INFO, "%s: FPR %d is enabled for range 0x%08x-0x%08x\n",
- __func__, fpr, start, end);
- return 0;
-}