uboot/drivers/ddr/marvell/a38x/mv_ddr_common.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0
   2/*
   3 * Copyright (C) Marvell International Ltd. and its affiliates
   4 */
   5
   6#include "mv_ddr_common.h"
   7#include "ddr_ml_wrapper.h"
   8
   9void mv_ddr_ver_print(void)
  10{
  11        printf("%s %s\n", mv_ddr_version_string, mv_ddr_build_message);
  12}
  13
  14/* ceiling division for positive integers */
  15unsigned int ceil_div(unsigned int x, unsigned int y)
  16{
  17        return (x % y) ? (x / y + 1) : (x / y);
  18}
  19
  20/*
  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
  24 */
  25unsigned int time_to_nclk(unsigned int t, unsigned int tclk)
  26{
  27        /* t & tclk parameters are in ps */
  28        return ((unsigned long)t * 1000 / tclk + 974) / 1000;
  29}
  30
  31/* round division of two positive integers to the nearest whole number */
  32int round_div(unsigned int dividend, unsigned int divisor, unsigned int *quotient)
  33{
  34        if (quotient == NULL) {
  35                printf("%s: error: NULL quotient pointer found\n", __func__);
  36                return MV_FAIL;
  37        }
  38
  39        if (divisor == 0) {
  40                printf("%s: error: division by zero\n", __func__);
  41                return MV_FAIL;
  42        } else {
  43                *quotient = (dividend + divisor / 2) / divisor;
  44        }
  45
  46        return MV_OK;
  47}
  48