From: Scott Wood Date: Thu, 19 Oct 2017 21:30:09 -0500 Subject: [U-Boot] [PATCH] mtd: nand: fsl-ifc: fix support of multiple NAND devices In-Reply-To: <20171017080045.18950-1-kurt@linutronix.de> References: <20171017080045.18950-1-kurt@linutronix.de> Message-ID: <20171020023009.ff5r2iumyu3lnlpt@buserror.net> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Tue, Oct 17, 2017 at 10:00:45AM +0200, Kurt Kanzenbach wrote: > Currently the chipselect used to identify the corresponding NAND chip is stored > at the controller and only set during fsl_ifc_chip_init(). This way, only the > last NAND chip is working, as the previous value of cs_nand gets overwritten. > > In order to solve this issue the chipselect is moved from the controller to the > NAND chip structure. Thus, the correct chipselect for each NAND chip operation > is used. > > Tested on hardware with two NAND chips connected to the IFC controller. > > Signed-off-by: Kurt Kanzenbach > --- > drivers/mtd/nand/fsl_ifc_nand.c | 16 +++++++++------- > 1 file changed, 9 insertions(+), 7 deletions(-) > > diff --git a/drivers/mtd/nand/fsl_ifc_nand.c b/drivers/mtd/nand/fsl_ifc_nand.c > index bc6bdc9b2c..57737dbe94 100644 > --- a/drivers/mtd/nand/fsl_ifc_nand.c > +++ b/drivers/mtd/nand/fsl_ifc_nand.c > @@ -36,6 +36,7 @@ struct fsl_ifc_mtd { > > struct device *dev; > int bank; /* Chip select bank number */ > + unsigned int cs_nand; /* On which chipsel NAND is connected */ This is redundant with "bank" -- just do like the Linux driver does and write "priv->bank << IFC_NAND_CSEL_SHIFT" directly to the register when needed. > -static int fsl_ifc_sram_init(uint32_t ver) > +static int fsl_ifc_sram_init(struct mtd_info *mtd, uint32_t ver) > { > + struct nand_chip *chip = mtd_to_nand(mtd); > + struct fsl_ifc_mtd *priv = nand_get_controller_data(chip); Could pass in priv instead of mtd to make it more like the Linux driver. It's best to avoid gratuitous differences. -Scott