Patrick Georgi has submitted this change. ( https://review.coreboot.org/c/coreboot/+/35775 )
Change subject: soc/mediatek/mt8183: Add the shared 'dramc_param' module
......................................................................
soc/mediatek/mt8183: Add the shared 'dramc_param' module
The dramc_param module simplifies the communication between coreboot and
MTK DRAM full calibration blob, and is shared by both implementations to
ensure the same format of parameters.
BUG=b:139099592
BRANCH=none
TEST=emerge-kukui coreboot
Change-Id: I4cfd634da1855a76706aab0b050197251e2ed4dd
Signed-off-by: Yu-Ping Wu <yupingso(a)chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/35775
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org>
Reviewed-by: Hung-Te Lin <hungte(a)chromium.org>
---
M src/soc/mediatek/mt8183/Makefile.inc
A src/soc/mediatek/mt8183/dramc_param.c
A src/soc/mediatek/mt8183/include/soc/dramc_param.h
3 files changed, 137 insertions(+), 0 deletions(-)
Approvals:
build bot (Jenkins): Verified
Hung-Te Lin: Looks good to me, approved
diff --git a/src/soc/mediatek/mt8183/Makefile.inc b/src/soc/mediatek/mt8183/Makefile.inc
index d1171ef..72a4d9c 100644
--- a/src/soc/mediatek/mt8183/Makefile.inc
+++ b/src/soc/mediatek/mt8183/Makefile.inc
@@ -27,6 +27,7 @@
romstage-y += auxadc.c
romstage-y += ../common/cbmem.c emi.c
romstage-y += dramc_init_setting.c
+romstage-y += dramc_param.c
romstage-y += dramc_pi_basic_api.c
romstage-y += dramc_pi_calibration_api.c
romstage-y += memory.c
diff --git a/src/soc/mediatek/mt8183/dramc_param.c b/src/soc/mediatek/mt8183/dramc_param.c
new file mode 100644
index 0000000..ef3c191
--- /dev/null
+++ b/src/soc/mediatek/mt8183/dramc_param.c
@@ -0,0 +1,58 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2019 MediaTek 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 <string.h>
+#include "soc/dramc_param.h"
+
+struct dramc_param *get_dramc_param_from_blob(void *blob)
+{
+ return (struct dramc_param *)blob;
+}
+
+int validate_dramc_param(const void *blob)
+{
+ const struct dramc_param *param = blob;
+ const struct dramc_param_header *hdr = ¶m->header;
+
+ if (hdr->magic != DRAMC_PARAM_HEADER_MAGIC)
+ return DRAMC_ERR_INVALID_MAGIC;
+
+ if (hdr->version != DRAMC_PARAM_HEADER_VERSION)
+ return DRAMC_ERR_INVALID_VERSION;
+
+ if (hdr->size != sizeof(*param))
+ return DRAMC_ERR_INVALID_SIZE;
+
+ /* TODO(hungte) Verify and check hdr->checksum. */
+ return DRAMC_SUCCESS;
+}
+
+int is_valid_dramc_param(const void *blob)
+{
+ return validate_dramc_param(blob) == DRAMC_SUCCESS;
+}
+
+int initialize_dramc_param(void *blob, u16 config)
+{
+ struct dramc_param *param = blob;
+ struct dramc_param_header *hdr = ¶m->header;
+
+ memset(blob, 0, sizeof(*param));
+ hdr->magic = DRAMC_PARAM_HEADER_MAGIC;
+ hdr->size = sizeof(*param);
+ hdr->version = DRAMC_PARAM_HEADER_VERSION;
+ hdr->config = config;
+ return 0;
+}
diff --git a/src/soc/mediatek/mt8183/include/soc/dramc_param.h b/src/soc/mediatek/mt8183/include/soc/dramc_param.h
new file mode 100644
index 0000000..c2df459
--- /dev/null
+++ b/src/soc/mediatek/mt8183/include/soc/dramc_param.h
@@ -0,0 +1,78 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2019 MediaTek 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_MEDIATEK_MT8183_DRAMC_PARAM_H
+#define SOC_MEDIATEK_MT8183_DRAMC_PARAM_H
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#include "emi.h"
+
+enum {
+ DRAMC_PARAM_HEADER_MAGIC = 0x44524d4b,
+ DRAMC_PARAM_HEADER_VERSION = 1,
+};
+
+enum DRAMC_PARAM_STATUS_CODES {
+ DRAMC_SUCCESS = 0,
+ DRAMC_ERR_INVALID_MAGIC,
+ DRAMC_ERR_INVALID_VERSION,
+ DRAMC_ERR_INVALID_SIZE,
+ DRAMC_ERR_INVALID_CHECKSUM,
+ DRAMC_ERR_INVALID_FLAGS,
+ DRAMC_ERR_RECALIBRATE,
+ DRAMC_ERR_INIT_DRAM,
+ DRAMC_ERR_COMPLEX_RW_MEM_TEST,
+ DRAMC_ERR_1ST_COMPLEX_RW_MEM_TEST,
+ DRAMC_ERR_2ND_COMPLEX_RW_MEM_TEST,
+};
+
+/* Bit flags */
+enum DRAMC_PARAM_CONFIG {
+ DRAMC_CONFIG_EMCP = 0x0001,
+};
+
+enum DRAMC_PARAM_FLAGS {
+ DRAMC_FLAG_HAS_SAVED_DATA = 0x0001,
+};
+
+struct dramc_param_header {
+ u32 status; /* DRAMC_PARAM_STATUS_CODES */
+ u32 magic;
+ u32 version;
+ u32 size; /* size of whole dramc_param */
+ u16 config; /* DRAMC_PARAM_CONFIG */
+ u16 flags; /* DRAMC_PARAM_FLAGS */
+ u32 checksum;
+};
+
+struct dramc_param {
+ struct dramc_param_header header;
+ struct sdram_params freq_params[DRAM_DFS_SHUFFLE_MAX];
+};
+
+struct dramc_param_ops {
+ struct dramc_param *param;
+ bool (*read_from_flash)(struct dramc_param *dparam);
+ bool (*write_to_flash)(const struct dramc_param *dparam);
+};
+
+struct dramc_param *get_dramc_param_from_blob(void *blob);
+int validate_dramc_param(const void *blob);
+int is_valid_dramc_param(const void *blob);
+int initialize_dramc_param(void *blob, u16 config);
+
+#endif /* SOC_MEDIATEK_MT8183_DRAMC_PARAM_H */
--
To view, visit https://review.coreboot.org/c/coreboot/+/35775
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I4cfd634da1855a76706aab0b050197251e2ed4dd
Gerrit-Change-Number: 35775
Gerrit-PatchSet: 13
Gerrit-Owner: Yu-Ping Wu <yupingso(a)google.com>
Gerrit-Reviewer: Hung-Te Lin <hungte(a)chromium.org>
Gerrit-Reviewer: Julius Werner <jwerner(a)chromium.org>
Gerrit-Reviewer: Martin Roth <martinroth(a)google.com>
Gerrit-Reviewer: Patrick Georgi <pgeorgi(a)google.com>
Gerrit-Reviewer: Yu-Ping Wu <yupingso(a)google.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-MessageType: merged
greg(a)unrelenting.technology has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/35867 )
Change subject: mb/[google/intel/lenovo]/*: fix posix shell bug with SPD files
......................................................................
mb/[google/intel/lenovo]/*: fix posix shell bug with SPD files
FreeBSD's sh (basic posix shell) did not interpret the '\%o' escape
in the same way bash/zsh do. As a result, the decoded files ended up
with ASCII numbers instead of the decoded binary data.
Change-Id: I95b414d959e5cd4479fcf100adcf390562032c68
Signed-off-by: Greg V <greg(a)unrelenting.technology>
---
M src/mainboard/google/auron/variants/auron_paine/spd/Makefile.inc
M src/mainboard/google/auron/variants/auron_yuna/spd/Makefile.inc
M src/mainboard/google/auron/variants/gandof/spd/Makefile.inc
M src/mainboard/google/auron/variants/lulu/spd/Makefile.inc
M src/mainboard/google/auron/variants/samus/spd/Makefile.inc
M src/mainboard/google/dragonegg/spd/Makefile.inc
M src/mainboard/google/drallion/spd/Makefile.inc
M src/mainboard/google/eve/spd/Makefile.inc
M src/mainboard/google/hatch/spd/Makefile.inc
M src/mainboard/google/poppy/spd/Makefile.inc
M src/mainboard/intel/kunimitsu/spd/Makefile.inc
M src/mainboard/lenovo/t430s/variants/t431s/spd/Makefile.inc
M src/mainboard/lenovo/x1_carbon_gen1/spd/Makefile.inc
13 files changed, 13 insertions(+), 13 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/67/35867/1
diff --git a/src/mainboard/google/auron/variants/auron_paine/spd/Makefile.inc b/src/mainboard/google/auron/variants/auron_paine/spd/Makefile.inc
index 26e1a75..44edc70 100644
--- a/src/mainboard/google/auron/variants/auron_paine/spd/Makefile.inc
+++ b/src/mainboard/google/auron/variants/auron_paine/spd/Makefile.inc
@@ -41,7 +41,7 @@
$(SPD_BIN): $(SPD_DEPS)
for f in $+; \
do for c in $$(cat $$f | grep -v ^#); \
- do printf $$(printf '\%o' 0x$$c); \
+ do printf $$(printf '\\%o' 0x$$c); \
done; \
done > $@
diff --git a/src/mainboard/google/auron/variants/auron_yuna/spd/Makefile.inc b/src/mainboard/google/auron/variants/auron_yuna/spd/Makefile.inc
index 26e1a75..44edc70 100644
--- a/src/mainboard/google/auron/variants/auron_yuna/spd/Makefile.inc
+++ b/src/mainboard/google/auron/variants/auron_yuna/spd/Makefile.inc
@@ -41,7 +41,7 @@
$(SPD_BIN): $(SPD_DEPS)
for f in $+; \
do for c in $$(cat $$f | grep -v ^#); \
- do printf $$(printf '\%o' 0x$$c); \
+ do printf $$(printf '\\%o' 0x$$c); \
done; \
done > $@
diff --git a/src/mainboard/google/auron/variants/gandof/spd/Makefile.inc b/src/mainboard/google/auron/variants/gandof/spd/Makefile.inc
index f3a2162..23d0b4e 100644
--- a/src/mainboard/google/auron/variants/gandof/spd/Makefile.inc
+++ b/src/mainboard/google/auron/variants/gandof/spd/Makefile.inc
@@ -33,7 +33,7 @@
$(SPD_BIN): $(SPD_DEPS)
for f in $+; \
do for c in $$(cat $$f | grep -v ^#); \
- do printf $$(printf '\%o' 0x$$c); \
+ do printf $$(printf '\\%o' 0x$$c); \
done; \
done > $@
diff --git a/src/mainboard/google/auron/variants/lulu/spd/Makefile.inc b/src/mainboard/google/auron/variants/lulu/spd/Makefile.inc
index bc1454f..86cb2d2 100644
--- a/src/mainboard/google/auron/variants/lulu/spd/Makefile.inc
+++ b/src/mainboard/google/auron/variants/lulu/spd/Makefile.inc
@@ -42,7 +42,7 @@
$(SPD_BIN): $(SPD_DEPS)
for f in $+; \
do for c in $$(cat $$f | grep -v ^#); \
- do printf $$(printf '\%o' 0x$$c); \
+ do printf $$(printf '\\%o' 0x$$c); \
done; \
done > $@
diff --git a/src/mainboard/google/auron/variants/samus/spd/Makefile.inc b/src/mainboard/google/auron/variants/samus/spd/Makefile.inc
index 6a357c0..a026ef3 100644
--- a/src/mainboard/google/auron/variants/samus/spd/Makefile.inc
+++ b/src/mainboard/google/auron/variants/samus/spd/Makefile.inc
@@ -41,7 +41,7 @@
$(SPD_BIN): $(SPD_DEPS)
for f in $+; \
do for c in $$(cat $$f | grep -v ^#); \
- do printf $$(printf '\%o' 0x$$c); \
+ do printf $$(printf '\\%o' 0x$$c); \
done; \
done > $@
diff --git a/src/mainboard/google/dragonegg/spd/Makefile.inc b/src/mainboard/google/dragonegg/spd/Makefile.inc
index 7aa9505..2fdd9d4 100644
--- a/src/mainboard/google/dragonegg/spd/Makefile.inc
+++ b/src/mainboard/google/dragonegg/spd/Makefile.inc
@@ -30,7 +30,7 @@
$(SPD_BIN): $(SPD_DEPS)
for f in $+; \
do for c in $$(cat $$f | grep -v ^#); \
- do printf $$(printf '\%o' 0x$$c); \
+ do printf $$(printf '\\%o' 0x$$c); \
done; \
done > $@
diff --git a/src/mainboard/google/drallion/spd/Makefile.inc b/src/mainboard/google/drallion/spd/Makefile.inc
index e35544b..9ab7394 100644
--- a/src/mainboard/google/drallion/spd/Makefile.inc
+++ b/src/mainboard/google/drallion/spd/Makefile.inc
@@ -25,7 +25,7 @@
$(SPD_BIN): $(SPD_DEPS)
for f in $+; \
do for c in $$(cat $$f | grep -v ^#); \
- do printf $$(printf '\%o' 0x$$c); \
+ do printf $$(printf '\\%o' 0x$$c); \
done; \
done > $@
diff --git a/src/mainboard/google/eve/spd/Makefile.inc b/src/mainboard/google/eve/spd/Makefile.inc
index c97a818..cb4f8a8 100644
--- a/src/mainboard/google/eve/spd/Makefile.inc
+++ b/src/mainboard/google/eve/spd/Makefile.inc
@@ -32,7 +32,7 @@
$(SPD_BIN): $(SPD_DEPS)
for f in $+; \
do for c in $$(cat $$f | grep -v ^#); \
- do printf $$(printf '\%o' 0x$$c); \
+ do printf $$(printf '\\%o' 0x$$c); \
done; \
done > $@
diff --git a/src/mainboard/google/hatch/spd/Makefile.inc b/src/mainboard/google/hatch/spd/Makefile.inc
index e35544b..9ab7394 100644
--- a/src/mainboard/google/hatch/spd/Makefile.inc
+++ b/src/mainboard/google/hatch/spd/Makefile.inc
@@ -25,7 +25,7 @@
$(SPD_BIN): $(SPD_DEPS)
for f in $+; \
do for c in $$(cat $$f | grep -v ^#); \
- do printf $$(printf '\%o' 0x$$c); \
+ do printf $$(printf '\\%o' 0x$$c); \
done; \
done > $@
diff --git a/src/mainboard/google/poppy/spd/Makefile.inc b/src/mainboard/google/poppy/spd/Makefile.inc
index 444ac00..dd57835 100644
--- a/src/mainboard/google/poppy/spd/Makefile.inc
+++ b/src/mainboard/google/poppy/spd/Makefile.inc
@@ -5,7 +5,7 @@
define gen_spd_bin
for f in $2; \
do for c in $$(cat $$f | grep -v ^#); \
- do printf $$(printf '\%o' 0x$$c); \
+ do printf $$(printf '\\%o' 0x$$c); \
done; \
done > $1
endef
diff --git a/src/mainboard/intel/kunimitsu/spd/Makefile.inc b/src/mainboard/intel/kunimitsu/spd/Makefile.inc
index 9856368e..4fa2d7e 100644
--- a/src/mainboard/intel/kunimitsu/spd/Makefile.inc
+++ b/src/mainboard/intel/kunimitsu/spd/Makefile.inc
@@ -43,7 +43,7 @@
$(SPD_BIN): $(SPD_DEPS)
for f in $+; \
do for c in $$(cat $$f | grep -v ^#); \
- do printf $$(printf '\%o' 0x$$c); \
+ do printf $$(printf '\\%o' 0x$$c); \
done; \
done > $@
diff --git a/src/mainboard/lenovo/t430s/variants/t431s/spd/Makefile.inc b/src/mainboard/lenovo/t430s/variants/t431s/spd/Makefile.inc
index 4b9ef55..72657b4 100644
--- a/src/mainboard/lenovo/t430s/variants/t431s/spd/Makefile.inc
+++ b/src/mainboard/lenovo/t430s/variants/t431s/spd/Makefile.inc
@@ -22,7 +22,7 @@
$(SPD_BIN): $(SPD_DEPS)
for f in $+; \
do for c in $$(cat $$f | grep -v ^#); \
- do printf $$(printf '\%o' 0x$$c); \
+ do printf $$(printf '\\%o' 0x$$c); \
done; \
done > $@
diff --git a/src/mainboard/lenovo/x1_carbon_gen1/spd/Makefile.inc b/src/mainboard/lenovo/x1_carbon_gen1/spd/Makefile.inc
index f5c233a..235fc10 100644
--- a/src/mainboard/lenovo/x1_carbon_gen1/spd/Makefile.inc
+++ b/src/mainboard/lenovo/x1_carbon_gen1/spd/Makefile.inc
@@ -24,7 +24,7 @@
$(SPD_BIN): $(SPD_DEPS)
for f in $+; \
do for c in $$(cat $$f | grep -v ^#); \
- do printf $$(printf '\%o' 0x$$c); \
+ do printf $$(printf '\\%o' 0x$$c); \
done; \
done > $@
--
To view, visit https://review.coreboot.org/c/coreboot/+/35867
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I95b414d959e5cd4479fcf100adcf390562032c68
Gerrit-Change-Number: 35867
Gerrit-PatchSet: 1
Gerrit-Owner: greg(a)unrelenting.technology
Gerrit-Reviewer: Alexander Couzens <lynxis(a)fe80.eu>
Gerrit-Reviewer: Martin Roth <martinroth(a)google.com>
Gerrit-Reviewer: Patrick Georgi <pgeorgi(a)google.com>
Gerrit-Reviewer: Patrick Rudolph <siro(a)das-labor.org>
Gerrit-Reviewer: greg(a)unrelenting.technology
Gerrit-MessageType: newchange