This is in preparation for use for generic SPD calculations. I had to also rewrite uses of mclk_to_picos like this: - pdimm->trtp_ps = mclk_to_picos(c, 2); /* By the book. */ + pdimm->trtp_ps = mclk_ps * 2; /* By the book. */ This is the same result as: mclk_to_picos(c, mclk) expands to: get_memory_clk_period_ps(c) * mclk, and that can just be rewritten as mclk_ps * mclk. Signed-off-by: John Watts <contact@xxxxxxxxxx> --- drivers/ddr/fsl/ddr1_dimm_params.c | 10 +++++----- drivers/ddr/fsl/ddr2_dimm_params.c | 4 ++-- drivers/ddr/fsl/ddr3_dimm_params.c | 2 +- drivers/ddr/fsl/ddr4_dimm_params.c | 2 +- drivers/ddr/fsl/fsl_ddr.h | 8 ++++---- drivers/ddr/fsl/main.c | 9 +++++---- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/drivers/ddr/fsl/ddr1_dimm_params.c b/drivers/ddr/fsl/ddr1_dimm_params.c index f5f9067073..9a7f26bd49 100644 --- a/drivers/ddr/fsl/ddr1_dimm_params.c +++ b/drivers/ddr/fsl/ddr1_dimm_params.c @@ -216,7 +216,7 @@ compute_derated_DDR1_CAS_latency(unsigned int mclk_ps) * * FIXME: use #define for the retvals */ -unsigned int ddr1_compute_dimm_parameters(struct fsl_ddr_controller *c, +unsigned int ddr1_compute_dimm_parameters(unsigned int mclk_ps, const struct ddr1_spd_eeprom *spd, struct dimm_params *pdimm) { @@ -288,15 +288,15 @@ unsigned int ddr1_compute_dimm_parameters(struct fsl_ddr_controller *c, /* Compute CAS latencies below that defined by SPD */ pdimm->caslat_lowest_derated = compute_derated_DDR1_CAS_latency( - get_memory_clk_period_ps(c)); + mclk_ps); /* Compute timing parameters */ pdimm->trcd_ps = spd->trcd * 250; pdimm->trp_ps = spd->trp * 250; pdimm->tras_ps = spd->tras * 1000; - pdimm->twr_ps = mclk_to_picos(c, 3); - pdimm->twtr_ps = mclk_to_picos(c, 1); + pdimm->twr_ps = mclk_ps * 3; + pdimm->twtr_ps = mclk_ps * 1; pdimm->trfc_ps = compute_trfc_ps_from_spd(0, spd->trfc); pdimm->trrd_ps = spd->trrd * 250; @@ -311,7 +311,7 @@ unsigned int ddr1_compute_dimm_parameters(struct fsl_ddr_controller *c, pdimm->tdh_ps = convert_bcd_hundredths_to_cycle_time_ps(spd->data_hold); - pdimm->trtp_ps = mclk_to_picos(c, 2); /* By the book. */ + pdimm->trtp_ps = mclk_ps * 2; /* By the book. */ pdimm->tdqsq_max_ps = spd->tdqsq * 10; pdimm->tqhs_ps = spd->tqhs * 10; diff --git a/drivers/ddr/fsl/ddr2_dimm_params.c b/drivers/ddr/fsl/ddr2_dimm_params.c index e33a8ded48..6f17d55c1f 100644 --- a/drivers/ddr/fsl/ddr2_dimm_params.c +++ b/drivers/ddr/fsl/ddr2_dimm_params.c @@ -201,7 +201,7 @@ compute_derated_DDR2_CAS_latency(unsigned int mclk_ps) * * FIXME: use #define for the retvals */ -unsigned int ddr2_compute_dimm_parameters(struct fsl_ddr_controller *c, +unsigned int ddr2_compute_dimm_parameters(unsigned int mclk_ps, const struct ddr2_spd_eeprom *spd, struct dimm_params *pdimm) { @@ -289,7 +289,7 @@ unsigned int ddr2_compute_dimm_parameters(struct fsl_ddr_controller *c, /* Compute CAS latencies below that defined by SPD */ pdimm->caslat_lowest_derated = compute_derated_DDR2_CAS_latency( - get_memory_clk_period_ps(c)); + mclk_ps); /* Compute timing parameters */ pdimm->trcd_ps = spd->trcd * 250; diff --git a/drivers/ddr/fsl/ddr3_dimm_params.c b/drivers/ddr/fsl/ddr3_dimm_params.c index 92012a5af9..cfea35ca05 100644 --- a/drivers/ddr/fsl/ddr3_dimm_params.c +++ b/drivers/ddr/fsl/ddr3_dimm_params.c @@ -79,7 +79,7 @@ compute_ranksize(const struct ddr3_spd_eeprom *spd) * Writes the results to the struct dimm_params structure pointed by pdimm. * */ -unsigned int ddr3_compute_dimm_parameters(struct fsl_ddr_controller *c, +unsigned int ddr3_compute_dimm_parameters(unsigned int mclk_ps, const struct ddr3_spd_eeprom *spd, struct dimm_params *pdimm) { diff --git a/drivers/ddr/fsl/ddr4_dimm_params.c b/drivers/ddr/fsl/ddr4_dimm_params.c index 0be2de8de6..41c63f3613 100644 --- a/drivers/ddr/fsl/ddr4_dimm_params.c +++ b/drivers/ddr/fsl/ddr4_dimm_params.c @@ -124,7 +124,7 @@ compute_ranksize(const struct ddr4_spd_eeprom *spd) * Writes the results to the struct dimm_params structure pointed by pdimm. * */ -unsigned int ddr4_compute_dimm_parameters(struct fsl_ddr_controller *c, +unsigned int ddr4_compute_dimm_parameters(unsigned int mclk_ps, const struct ddr4_spd_eeprom *spd, struct dimm_params *pdimm) { diff --git a/drivers/ddr/fsl/fsl_ddr.h b/drivers/ddr/fsl/fsl_ddr.h index 459a7ee8e8..87edd10ac1 100644 --- a/drivers/ddr/fsl/fsl_ddr.h +++ b/drivers/ddr/fsl/fsl_ddr.h @@ -204,16 +204,16 @@ struct fsl_ddr_controller; u32 fsl_ddr_get_version(struct fsl_ddr_controller *c); -unsigned int ddr1_compute_dimm_parameters(struct fsl_ddr_controller *c, +unsigned int ddr1_compute_dimm_parameters(unsigned int mclk_ps, const struct ddr1_spd_eeprom *spd, struct dimm_params *pdimm); -unsigned int ddr2_compute_dimm_parameters(struct fsl_ddr_controller *c, +unsigned int ddr2_compute_dimm_parameters(unsigned int mclk_ps, const struct ddr2_spd_eeprom *spd, struct dimm_params *pdimm); -unsigned int ddr3_compute_dimm_parameters(struct fsl_ddr_controller *c, +unsigned int ddr3_compute_dimm_parameters(unsigned int mclk_ps, const struct ddr3_spd_eeprom *spd, struct dimm_params *pdimm); -unsigned int ddr4_compute_dimm_parameters(struct fsl_ddr_controller *c, +unsigned int ddr4_compute_dimm_parameters(unsigned int mclk_ps, const struct ddr4_spd_eeprom *spd, struct dimm_params *pdimm); void fsl_ddr_set_intl3r(const unsigned int granule_size); diff --git a/drivers/ddr/fsl/main.c b/drivers/ddr/fsl/main.c index aa2f2e1aa1..c70be6fcf9 100644 --- a/drivers/ddr/fsl/main.c +++ b/drivers/ddr/fsl/main.c @@ -238,19 +238,20 @@ static int compute_dimm_parameters(struct fsl_ddr_controller *c, struct spd_eeprom *spd, struct dimm_params *pdimm) { + unsigned int mclk_ps = get_memory_clk_period_ps(c); const memctl_options_t *popts = &c->memctl_opts; int ret = -EINVAL; memset(pdimm, 0, sizeof(*pdimm)); if (is_ddr1(popts)) - ret = ddr1_compute_dimm_parameters(c, (void *)spd, pdimm); + ret = ddr1_compute_dimm_parameters(mclk_ps, (void *)spd, pdimm); else if (is_ddr2(popts)) - ret = ddr2_compute_dimm_parameters(c, (void *)spd, pdimm); + ret = ddr2_compute_dimm_parameters(mclk_ps, (void *)spd, pdimm); else if (is_ddr3(popts)) - ret = ddr3_compute_dimm_parameters(c, (void *)spd, pdimm); + ret = ddr3_compute_dimm_parameters(mclk_ps, (void *)spd, pdimm); else if (is_ddr4(popts)) - ret = ddr4_compute_dimm_parameters(c, (void *)spd, pdimm); + ret = ddr4_compute_dimm_parameters(mclk_ps, (void *)spd, pdimm); return ret; } -- 2.39.0