mtd: rawnand: Add a helper to find the closest ONFI NV-DDR mode
Introduce a similar helper to onfi_find_closest_sdr_mode(), but for NV-DDR timings. It just takes a timing structure as parameter and returns the closest mode by comparing all minimum timings. This is useful for rigid controllers on which tuning the timings is not possible. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/20210505213750.257417-16-miquel.raynal@bootlin.com
This commit is contained in:
parent
09cdb237c3
commit
e32df79f19
@ -90,6 +90,8 @@ void onfi_fill_interface_config(struct nand_chip *chip,
|
|||||||
unsigned int timing_mode);
|
unsigned int timing_mode);
|
||||||
unsigned int
|
unsigned int
|
||||||
onfi_find_closest_sdr_mode(const struct nand_sdr_timings *spec_timings);
|
onfi_find_closest_sdr_mode(const struct nand_sdr_timings *spec_timings);
|
||||||
|
unsigned int
|
||||||
|
onfi_find_closest_nvddr_mode(const struct nand_nvddr_timings *spec_timings);
|
||||||
int nand_choose_best_sdr_timings(struct nand_chip *chip,
|
int nand_choose_best_sdr_timings(struct nand_chip *chip,
|
||||||
struct nand_interface_config *iface,
|
struct nand_interface_config *iface,
|
||||||
struct nand_sdr_timings *spec_timings);
|
struct nand_sdr_timings *spec_timings);
|
||||||
|
@ -601,6 +601,48 @@ onfi_find_closest_sdr_mode(const struct nand_sdr_timings *spec_timings)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* onfi_find_closest_nvddr_mode - Derive the closest ONFI NVDDR timing mode
|
||||||
|
* given a set of timings
|
||||||
|
* @spec_timings: the timings to challenge
|
||||||
|
*/
|
||||||
|
unsigned int
|
||||||
|
onfi_find_closest_nvddr_mode(const struct nand_nvddr_timings *spec_timings)
|
||||||
|
{
|
||||||
|
const struct nand_nvddr_timings *onfi_timings;
|
||||||
|
int mode;
|
||||||
|
|
||||||
|
for (mode = ARRAY_SIZE(onfi_nvddr_timings) - 1; mode > 0; mode--) {
|
||||||
|
onfi_timings = &onfi_nvddr_timings[mode].timings.nvddr;
|
||||||
|
|
||||||
|
if (spec_timings->tCCS_min <= onfi_timings->tCCS_min &&
|
||||||
|
spec_timings->tAC_min <= onfi_timings->tAC_min &&
|
||||||
|
spec_timings->tADL_min <= onfi_timings->tADL_min &&
|
||||||
|
spec_timings->tCAD_min <= onfi_timings->tCAD_min &&
|
||||||
|
spec_timings->tCAH_min <= onfi_timings->tCAH_min &&
|
||||||
|
spec_timings->tCALH_min <= onfi_timings->tCALH_min &&
|
||||||
|
spec_timings->tCALS_min <= onfi_timings->tCALS_min &&
|
||||||
|
spec_timings->tCAS_min <= onfi_timings->tCAS_min &&
|
||||||
|
spec_timings->tCEH_min <= onfi_timings->tCEH_min &&
|
||||||
|
spec_timings->tCH_min <= onfi_timings->tCH_min &&
|
||||||
|
spec_timings->tCK_min <= onfi_timings->tCK_min &&
|
||||||
|
spec_timings->tCS_min <= onfi_timings->tCS_min &&
|
||||||
|
spec_timings->tDH_min <= onfi_timings->tDH_min &&
|
||||||
|
spec_timings->tDQSCK_min <= onfi_timings->tDQSCK_min &&
|
||||||
|
spec_timings->tDQSD_min <= onfi_timings->tDQSD_min &&
|
||||||
|
spec_timings->tDS_min <= onfi_timings->tDS_min &&
|
||||||
|
spec_timings->tDSC_min <= onfi_timings->tDSC_min &&
|
||||||
|
spec_timings->tRHW_min <= onfi_timings->tRHW_min &&
|
||||||
|
spec_timings->tRR_min <= onfi_timings->tRR_min &&
|
||||||
|
spec_timings->tWHR_min <= onfi_timings->tWHR_min &&
|
||||||
|
spec_timings->tWRCK_min <= onfi_timings->tWRCK_min &&
|
||||||
|
spec_timings->tWW_min <= onfi_timings->tWW_min)
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
* onfi_fill_sdr_interface_config - Initialize a SDR interface config from a
|
* onfi_fill_sdr_interface_config - Initialize a SDR interface config from a
|
||||||
* given ONFI mode
|
* given ONFI mode
|
||||||
* @chip: The NAND chip
|
* @chip: The NAND chip
|
||||||
|
Loading…
x
Reference in New Issue
Block a user