1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) Marvell International Ltd. and its affiliates
6 #include "mv_ddr_common.h"
7 #include "ddr_ml_wrapper.h"
9 void mv_ddr_ver_print(void)
11 printf("%s %s\n", mv_ddr_version_string, mv_ddr_build_message);
14 /* ceiling division for positive integers */
15 unsigned int ceil_div(unsigned int x, unsigned int y)
17 return (x % y) ? (x / y + 1) : (x / y);
21 * time to number of clocks calculation based on the rounding algorithm
22 * using 97.4% inverse factor per JEDEC Standard No. 21-C, 4.1.2.L-4:
23 * Serial Presence Detect (SPD) for DDR4 SDRAM Modules
25 unsigned int time_to_nclk(unsigned int t, unsigned int tclk)
27 /* t & tclk parameters are in ps */
28 return ((unsigned long)t * 1000 / tclk + 974) / 1000;
31 /* round division of two positive integers to the nearest whole number */
32 int round_div(unsigned int dividend, unsigned int divisor, unsigned int *quotient)
34 if (quotient == NULL) {
35 printf("%s: error: NULL quotient pointer found\n", __func__);
40 printf("%s: error: division by zero\n", __func__);
43 *quotient = (dividend + divisor / 2) / divisor;