Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+44
+2
drivers/mtd/nand/raw/internals.h
··· 90 90 unsigned int timing_mode); 91 91 unsigned int 92 92 onfi_find_closest_sdr_mode(const struct nand_sdr_timings *spec_timings); 93 + unsigned int 94 + onfi_find_closest_nvddr_mode(const struct nand_nvddr_timings *spec_timings); 93 95 int nand_choose_best_sdr_timings(struct nand_chip *chip, 94 96 struct nand_interface_config *iface, 95 97 struct nand_sdr_timings *spec_timings);
+42
drivers/mtd/nand/raw/nand_timings.c
··· 601 601 } 602 602 603 603 /** 604 + * onfi_find_closest_nvddr_mode - Derive the closest ONFI NVDDR timing mode 605 + * given a set of timings 606 + * @spec_timings: the timings to challenge 607 + */ 608 + unsigned int 609 + onfi_find_closest_nvddr_mode(const struct nand_nvddr_timings *spec_timings) 610 + { 611 + const struct nand_nvddr_timings *onfi_timings; 612 + int mode; 613 + 614 + for (mode = ARRAY_SIZE(onfi_nvddr_timings) - 1; mode > 0; mode--) { 615 + onfi_timings = &onfi_nvddr_timings[mode].timings.nvddr; 616 + 617 + if (spec_timings->tCCS_min <= onfi_timings->tCCS_min && 618 + spec_timings->tAC_min <= onfi_timings->tAC_min && 619 + spec_timings->tADL_min <= onfi_timings->tADL_min && 620 + spec_timings->tCAD_min <= onfi_timings->tCAD_min && 621 + spec_timings->tCAH_min <= onfi_timings->tCAH_min && 622 + spec_timings->tCALH_min <= onfi_timings->tCALH_min && 623 + spec_timings->tCALS_min <= onfi_timings->tCALS_min && 624 + spec_timings->tCAS_min <= onfi_timings->tCAS_min && 625 + spec_timings->tCEH_min <= onfi_timings->tCEH_min && 626 + spec_timings->tCH_min <= onfi_timings->tCH_min && 627 + spec_timings->tCK_min <= onfi_timings->tCK_min && 628 + spec_timings->tCS_min <= onfi_timings->tCS_min && 629 + spec_timings->tDH_min <= onfi_timings->tDH_min && 630 + spec_timings->tDQSCK_min <= onfi_timings->tDQSCK_min && 631 + spec_timings->tDQSD_min <= onfi_timings->tDQSD_min && 632 + spec_timings->tDS_min <= onfi_timings->tDS_min && 633 + spec_timings->tDSC_min <= onfi_timings->tDSC_min && 634 + spec_timings->tRHW_min <= onfi_timings->tRHW_min && 635 + spec_timings->tRR_min <= onfi_timings->tRR_min && 636 + spec_timings->tWHR_min <= onfi_timings->tWHR_min && 637 + spec_timings->tWRCK_min <= onfi_timings->tWRCK_min && 638 + spec_timings->tWW_min <= onfi_timings->tWW_min) 639 + return mode; 640 + } 641 + 642 + return 0; 643 + } 644 + 645 + /* 604 646 * onfi_fill_sdr_interface_config - Initialize a SDR interface config from a 605 647 * given ONFI mode 606 648 * @chip: The NAND chip