2014-12-11 05:42:58 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the coreboot project.
|
|
|
|
*
|
|
|
|
* Copyright 2014 Google Inc.
|
2014-12-16 23:34:28 +01:00
|
|
|
* Copyright (c) 2014, The Linux Foundation. All rights reserved.
|
2014-12-11 05:42:58 +01:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2014-12-16 23:34:28 +01:00
|
|
|
#include <arch/cache.h>
|
|
|
|
#include <arch/io.h>
|
2014-12-11 05:42:58 +01:00
|
|
|
#include <cbfs.h>
|
2014-12-16 23:34:28 +01:00
|
|
|
#include <console/console.h>
|
2014-12-11 05:42:58 +01:00
|
|
|
#include <string.h>
|
2014-12-16 23:34:28 +01:00
|
|
|
#include <timer.h>
|
2014-12-11 05:42:58 +01:00
|
|
|
|
2014-12-16 23:34:28 +01:00
|
|
|
#include <soc/iomap.h>
|
2014-12-11 05:42:58 +01:00
|
|
|
#include <soc/soc_services.h>
|
|
|
|
|
|
|
|
#include "mbn_header.h"
|
|
|
|
|
2014-09-23 02:49:56 +02:00
|
|
|
static void *load_ipq_blob(const char *file_name)
|
2014-12-11 05:42:58 +01:00
|
|
|
{
|
|
|
|
struct mbn_header *blob_mbn;
|
2014-09-23 02:49:56 +02:00
|
|
|
void *blob_dest;
|
2015-05-16 06:39:23 +02:00
|
|
|
size_t blob_size;
|
2014-12-11 05:42:58 +01:00
|
|
|
|
2015-05-16 06:39:23 +02:00
|
|
|
blob_mbn = cbfs_boot_map_with_leak(file_name, CBFS_TYPE_RAW,
|
|
|
|
&blob_size);
|
|
|
|
if (!blob_mbn)
|
2014-12-11 05:42:58 +01:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* some sanity checks on the headers */
|
|
|
|
if ((blob_mbn->mbn_version != 3) ||
|
2015-05-16 06:39:23 +02:00
|
|
|
(blob_mbn->mbn_total_size > blob_size))
|
2014-12-11 05:42:58 +01:00
|
|
|
return NULL;
|
|
|
|
|
2014-09-23 02:49:56 +02:00
|
|
|
blob_dest = (void *) blob_mbn->mbn_destination;
|
|
|
|
if (blob_mbn->mbn_destination) {
|
|
|
|
/* Copy the blob to the appropriate memory location. */
|
|
|
|
memcpy(blob_dest, blob_mbn + 1, blob_mbn->mbn_total_size);
|
|
|
|
cache_sync_instructions();
|
|
|
|
return blob_dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The blob did not have to be relocated, return its address in CBFS
|
|
|
|
* cache.
|
|
|
|
*/
|
|
|
|
return blob_mbn + 1;
|
2014-12-11 05:42:58 +01:00
|
|
|
}
|
|
|
|
|
2014-09-23 02:49:56 +02:00
|
|
|
#ifdef __PRE_RAM__
|
|
|
|
|
2015-03-06 02:36:00 +01:00
|
|
|
#define DDR_VERSION() ((const char *)0x2a03f600)
|
|
|
|
#define MAX_DDR_VERSION_SIZE 48
|
|
|
|
|
2014-12-11 05:42:58 +01:00
|
|
|
int initialize_dram(void)
|
|
|
|
{
|
2014-09-23 02:49:56 +02:00
|
|
|
void *cdt;
|
2014-12-11 05:42:58 +01:00
|
|
|
int (*ddr_init_function)(void *cdt_header);
|
|
|
|
|
2014-09-23 02:49:56 +02:00
|
|
|
cdt = load_ipq_blob("cdt.mbn");
|
|
|
|
ddr_init_function = load_ipq_blob("ddr.mbn");
|
2014-12-11 05:42:58 +01:00
|
|
|
|
2014-09-23 02:49:56 +02:00
|
|
|
if (!cdt || !ddr_init_function) {
|
|
|
|
printk(BIOS_ERR, "cdt: %p, ddr_init_function: %p\n",
|
|
|
|
cdt, ddr_init_function);
|
2014-12-11 05:42:58 +01:00
|
|
|
die("could not find DDR initialization blobs\n");
|
|
|
|
}
|
|
|
|
|
2014-09-23 02:49:56 +02:00
|
|
|
if (ddr_init_function(cdt) < 0)
|
2014-12-11 05:42:58 +01:00
|
|
|
die("Fail to Initialize DDR\n");
|
|
|
|
|
2015-03-06 02:36:00 +01:00
|
|
|
/*
|
2018-02-12 12:24:25 +01:00
|
|
|
* Once DDR initializer finished, its version can be found at a fixed
|
2015-03-06 02:36:00 +01:00
|
|
|
* address in SRAM.
|
|
|
|
*/
|
|
|
|
printk(BIOS_INFO, "DDR version %.*s initialized\n",
|
|
|
|
MAX_DDR_VERSION_SIZE, DDR_VERSION());
|
2014-12-11 05:42:58 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2014-09-23 02:49:56 +02:00
|
|
|
|
|
|
|
#else /* __PRE_RAM__ */
|
|
|
|
|
|
|
|
void start_tzbsp(void)
|
|
|
|
{
|
|
|
|
void *tzbsp = load_ipq_blob("tz.mbn");
|
|
|
|
|
|
|
|
if (!tzbsp)
|
|
|
|
die("could not find or map TZBSP\n");
|
|
|
|
|
2014-12-16 23:34:28 +01:00
|
|
|
printk(BIOS_INFO, "Starting TZBSP\n");
|
|
|
|
|
2014-09-23 02:49:56 +02:00
|
|
|
tz_init_wrapper(0, 0, tzbsp);
|
|
|
|
}
|
|
|
|
|
2015-03-06 02:36:00 +01:00
|
|
|
/* RPM version is encoded in a 32 bit word at the fixed address */
|
|
|
|
#define RPM_VERSION() (*((u32 *)(0x00108008)))
|
2014-12-16 23:34:28 +01:00
|
|
|
void start_rpm(void)
|
|
|
|
{
|
|
|
|
u32 load_addr;
|
|
|
|
u32 ready_mask = 1 << 10;
|
2015-03-06 02:36:00 +01:00
|
|
|
u32 rpm_version;
|
|
|
|
|
2014-12-16 23:34:28 +01:00
|
|
|
struct stopwatch sw;
|
|
|
|
|
arm(64): Globally replace writel(v, a) with write32(a, v)
This patch is a raw application of the following spatch to src/:
@@
expression A, V;
@@
- writel(V, A)
+ write32(A, V)
@@
expression A, V;
@@
- writew(V, A)
+ write16(A, V)
@@
expression A, V;
@@
- writeb(V, A)
+ write8(A, V)
@@
expression A;
@@
- readl(A)
+ read32(A)
@@
expression A;
@@
- readb(A)
+ read8(A)
BRANCH=none
BUG=chromium:444723
TEST=None (depends on next patch)
Change-Id: I5dd96490c85ee2bcbc669f08bc6fff0ecc0f9e27
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 64f643da95d85954c4d4ea91c34a5c69b9b08eb6
Original-Change-Id: I366a2eb5b3a0df2279ebcce572fe814894791c42
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/254864
Reviewed-on: http://review.coreboot.org/9836
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-02-19 23:51:15 +01:00
|
|
|
if (read32(RPM_SIGNAL_COOKIE) == RPM_FW_MAGIC_NUM) {
|
2014-12-16 23:34:28 +01:00
|
|
|
printk(BIOS_INFO, "RPM appears to have already started\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
load_addr = (u32) load_ipq_blob("rpm.mbn");
|
|
|
|
if (!load_addr)
|
|
|
|
die("could not find or map RPM code\n");
|
|
|
|
|
|
|
|
printk(BIOS_INFO, "Starting RPM\n");
|
|
|
|
|
|
|
|
/* Clear 'ready' indication. */
|
2015-04-24 19:24:18 +02:00
|
|
|
/*
|
|
|
|
* RPM_INT_ACK is clear-on-write type register,
|
|
|
|
* read-modify-write is not recommended.
|
|
|
|
*/
|
|
|
|
write32(RPM_INT_ACK, ready_mask);
|
2014-12-16 23:34:28 +01:00
|
|
|
|
|
|
|
/* Set RPM entry address */
|
arm(64): Globally replace writel(v, a) with write32(a, v)
This patch is a raw application of the following spatch to src/:
@@
expression A, V;
@@
- writel(V, A)
+ write32(A, V)
@@
expression A, V;
@@
- writew(V, A)
+ write16(A, V)
@@
expression A, V;
@@
- writeb(V, A)
+ write8(A, V)
@@
expression A;
@@
- readl(A)
+ read32(A)
@@
expression A;
@@
- readb(A)
+ read8(A)
BRANCH=none
BUG=chromium:444723
TEST=None (depends on next patch)
Change-Id: I5dd96490c85ee2bcbc669f08bc6fff0ecc0f9e27
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 64f643da95d85954c4d4ea91c34a5c69b9b08eb6
Original-Change-Id: I366a2eb5b3a0df2279ebcce572fe814894791c42
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/254864
Reviewed-on: http://review.coreboot.org/9836
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-02-19 23:51:15 +01:00
|
|
|
write32(RPM_SIGNAL_ENTRY, load_addr);
|
2014-12-16 23:34:28 +01:00
|
|
|
/* Set cookie */
|
arm(64): Globally replace writel(v, a) with write32(a, v)
This patch is a raw application of the following spatch to src/:
@@
expression A, V;
@@
- writel(V, A)
+ write32(A, V)
@@
expression A, V;
@@
- writew(V, A)
+ write16(A, V)
@@
expression A, V;
@@
- writeb(V, A)
+ write8(A, V)
@@
expression A;
@@
- readl(A)
+ read32(A)
@@
expression A;
@@
- readb(A)
+ read8(A)
BRANCH=none
BUG=chromium:444723
TEST=None (depends on next patch)
Change-Id: I5dd96490c85ee2bcbc669f08bc6fff0ecc0f9e27
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 64f643da95d85954c4d4ea91c34a5c69b9b08eb6
Original-Change-Id: I366a2eb5b3a0df2279ebcce572fe814894791c42
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/254864
Reviewed-on: http://review.coreboot.org/9836
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-02-19 23:51:15 +01:00
|
|
|
write32(RPM_SIGNAL_COOKIE, RPM_FW_MAGIC_NUM);
|
2014-12-16 23:34:28 +01:00
|
|
|
|
|
|
|
/* Wait for RPM start indication, up to 100ms. */
|
|
|
|
stopwatch_init_usecs_expire(&sw, 100000);
|
arm(64): Globally replace writel(v, a) with write32(a, v)
This patch is a raw application of the following spatch to src/:
@@
expression A, V;
@@
- writel(V, A)
+ write32(A, V)
@@
expression A, V;
@@
- writew(V, A)
+ write16(A, V)
@@
expression A, V;
@@
- writeb(V, A)
+ write8(A, V)
@@
expression A;
@@
- readl(A)
+ read32(A)
@@
expression A;
@@
- readb(A)
+ read8(A)
BRANCH=none
BUG=chromium:444723
TEST=None (depends on next patch)
Change-Id: I5dd96490c85ee2bcbc669f08bc6fff0ecc0f9e27
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 64f643da95d85954c4d4ea91c34a5c69b9b08eb6
Original-Change-Id: I366a2eb5b3a0df2279ebcce572fe814894791c42
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/254864
Reviewed-on: http://review.coreboot.org/9836
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-02-19 23:51:15 +01:00
|
|
|
while (!(read32(RPM_INT) & ready_mask))
|
2014-12-16 23:34:28 +01:00
|
|
|
if (stopwatch_expired(&sw))
|
|
|
|
die("RPM Initialization failed\n");
|
|
|
|
|
|
|
|
/* Acknowledge RPM initialization */
|
arm(64): Globally replace writel(v, a) with write32(a, v)
This patch is a raw application of the following spatch to src/:
@@
expression A, V;
@@
- writel(V, A)
+ write32(A, V)
@@
expression A, V;
@@
- writew(V, A)
+ write16(A, V)
@@
expression A, V;
@@
- writeb(V, A)
+ write8(A, V)
@@
expression A;
@@
- readl(A)
+ read32(A)
@@
expression A;
@@
- readb(A)
+ read8(A)
BRANCH=none
BUG=chromium:444723
TEST=None (depends on next patch)
Change-Id: I5dd96490c85ee2bcbc669f08bc6fff0ecc0f9e27
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 64f643da95d85954c4d4ea91c34a5c69b9b08eb6
Original-Change-Id: I366a2eb5b3a0df2279ebcce572fe814894791c42
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/254864
Reviewed-on: http://review.coreboot.org/9836
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-02-19 23:51:15 +01:00
|
|
|
write32(RPM_INT_ACK, ready_mask);
|
2015-03-06 02:36:00 +01:00
|
|
|
|
|
|
|
/* Report RPM version, it is encoded in a 32 bit value. */
|
|
|
|
rpm_version = RPM_VERSION();
|
|
|
|
printk(BIOS_INFO, "Started RPM version %d.%d.%d\n",
|
|
|
|
rpm_version >> 24,
|
|
|
|
(rpm_version >> 16) & 0xff,
|
|
|
|
rpm_version & 0xffff);
|
2014-12-16 23:34:28 +01:00
|
|
|
}
|
2014-09-23 02:49:56 +02:00
|
|
|
#endif /* !__PRE_RAM__ */
|