summaryrefslogtreecommitdiff
path: root/drivers/ddr/marvell/a38x/mv_ddr_common.c
diff options
context:
space:
mode:
authorChris Packham <judge.packham@gmail.com>2018-05-10 13:28:29 +1200
committerStefan Roese <sr@denx.de>2018-05-14 10:01:56 +0200
commit2b4ffbf6b4944a0b3125fd2c9c0ba3568264367a (patch)
treedc75d0e07677505b8611a670483a349f214c9e75 /drivers/ddr/marvell/a38x/mv_ddr_common.c
parent00a7767766ace1f3ca3de7f9d44e145b9092bbad (diff)
ARM: mvebu: a38x: sync ddr training code with upstream
This syncs drivers/ddr/marvell/a38x/ with the mv_ddr-armada-17.10 branch of https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell.git. The upstream code is incorporated omitting the ddr4 and apn806 and folding the nested a38x directory up one level. After that a semi-automated step is used to drop unused features with unifdef find drivers/ddr/marvell/a38x/ -name '*.[ch]' | \ xargs unifdef -m -UMV_DDR -UMV_DDR_ATF -UCONFIG_DDR4 \ -UCONFIG_APN806 -UCONFIG_MC_STATIC \ -UCONFIG_MC_STATIC_PRINT -UCONFIG_PHY_STATIC \ -UCONFIG_64BIT INTER_REGS_BASE is updated to be defined as SOC_REGS_PHY_BASE. Some now empty files are removed and the ternary license is replaced with a SPDX GPL-2.0+ identifier. Signed-off-by: Chris Packham <judge.packham@gmail.com> Signed-off-by: Stefan Roese <sr@denx.de>
Diffstat (limited to 'drivers/ddr/marvell/a38x/mv_ddr_common.c')
-rw-r--r--drivers/ddr/marvell/a38x/mv_ddr_common.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/drivers/ddr/marvell/a38x/mv_ddr_common.c b/drivers/ddr/marvell/a38x/mv_ddr_common.c
new file mode 100644
index 00000000000..7afabbfd880
--- /dev/null
+++ b/drivers/ddr/marvell/a38x/mv_ddr_common.c
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ */
+
+#include "mv_ddr_common.h"
+#include "ddr_ml_wrapper.h"
+
+void mv_ddr_ver_print(void)
+{
+ printf("%s %s\n", mv_ddr_version_string, mv_ddr_build_message);
+}
+
+/* ceiling division for positive integers */
+unsigned int ceil_div(unsigned int x, unsigned int y)
+{
+ return (x % y) ? (x / y + 1) : (x / y);
+}
+
+/*
+ * time to number of clocks calculation based on the rounding algorithm
+ * using 97.4% inverse factor per JEDEC Standard No. 21-C, 4.1.2.L-4:
+ * Serial Presence Detect (SPD) for DDR4 SDRAM Modules
+ */
+unsigned int time_to_nclk(unsigned int t, unsigned int tclk)
+{
+ /* t & tclk parameters are in ps */
+ return ((unsigned long)t * 1000 / tclk + 974) / 1000;
+}
+
+/* round division of two positive integers to the nearest whole number */
+int round_div(unsigned int dividend, unsigned int divisor, unsigned int *quotient)
+{
+ if (quotient == NULL) {
+ printf("%s: error: NULL quotient pointer found\n", __func__);
+ return MV_FAIL;
+ }
+
+ if (divisor == 0) {
+ printf("%s: error: division by zero\n", __func__);
+ return MV_FAIL;
+ } else {
+ *quotient = (dividend + divisor / 2) / divisor;
+ }
+
+ return MV_OK;
+}