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

mtd: brcmnand: Force 8bit mode before doing nand_scan_ident()

Just like other NAND controllers, the NAND READID command only works
in 8bit mode for all versions of BRCMNAND controller.

This patch forces 8bit mode for each NAND CS in brcmnand_init_cs()
before doing nand_scan_ident() to ensure that BRCMNAND controller
is in 8bit mode when NAND READID command is issued.

Signed-off-by: Anup Patel <anup.patel@broadcom.com>
Reviewed-by: Ray Jui <rjui@broadcom.com>
Reviewed-by: Scott Branden <sbranden@broadcom.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>

authored by

Anup Patel and committed by
Brian Norris
4d1ea982 3f06d2a9

+10
+10
drivers/mtd/nand/brcmnand/brcmnand.c
··· 1913 1913 struct mtd_info *mtd; 1914 1914 struct nand_chip *chip; 1915 1915 int ret; 1916 + u16 cfg_offs; 1916 1917 struct mtd_part_parser_data ppdata = { .of_node = dn }; 1917 1918 1918 1919 ret = of_property_read_u32(dn, "reg", &host->cs); ··· 1955 1954 chip->ecc.write_oob = brcmnand_write_oob; 1956 1955 1957 1956 chip->controller = &ctrl->controller; 1957 + 1958 + /* 1959 + * The bootloader might have configured 16bit mode but 1960 + * NAND READID command only works in 8bit mode. We force 1961 + * 8bit mode here to ensure that NAND READID commands works. 1962 + */ 1963 + cfg_offs = brcmnand_cs_offset(ctrl, host->cs, BRCMNAND_CS_CFG); 1964 + nand_writereg(ctrl, cfg_offs, 1965 + nand_readreg(ctrl, cfg_offs) & ~CFG_BUS_WIDTH); 1958 1966 1959 1967 if (nand_scan_ident(mtd, 1, NULL)) 1960 1968 return -ENXIO;