aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/raw/sh_flctl.c
diff options
context:
space:
mode:
authorMiquel Raynal <miquel.raynal@bootlin.com>2018-07-20 11:15:11 -0400
committerMiquel Raynal <miquel.raynal@bootlin.com>2018-07-31 03:46:02 -0400
commit5f20da0fe8af638266a5e8449ab5ebfe6112c2c0 (patch)
treec9dde2d6c3a8f1fb67b889ab5446135ac7dd6de2 /drivers/mtd/nand/raw/sh_flctl.c
parent127483187a4afc143d59cb2809ccdb9399f7d27e (diff)
mtd: rawnand: sh_flctl: convert driver to nand_scan()
Two helpers have been added to the core to do all kind of controller side configuration/initialization between the detection phase and the final NAND scan. Implement these hooks so that we can convert the driver to just use nand_scan() instead of the nand_scan_ident() + nand_scan_tail() pair. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com>
Diffstat (limited to 'drivers/mtd/nand/raw/sh_flctl.c')
-rw-r--r--drivers/mtd/nand/raw/sh_flctl.c36
1 files changed, 15 insertions, 21 deletions
diff --git a/drivers/mtd/nand/raw/sh_flctl.c b/drivers/mtd/nand/raw/sh_flctl.c
index c7abceffcc40..bb8866e05ff7 100644
--- a/drivers/mtd/nand/raw/sh_flctl.c
+++ b/drivers/mtd/nand/raw/sh_flctl.c
@@ -1002,10 +1002,17 @@ static void flctl_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
1002 flctl->index += len; 1002 flctl->index += len;
1003} 1003}
1004 1004
1005static int flctl_chip_init_tail(struct mtd_info *mtd) 1005static int flctl_chip_attach_chip(struct nand_chip *chip)
1006{ 1006{
1007 struct mtd_info *mtd = nand_to_mtd(chip);
1007 struct sh_flctl *flctl = mtd_to_flctl(mtd); 1008 struct sh_flctl *flctl = mtd_to_flctl(mtd);
1008 struct nand_chip *chip = &flctl->chip; 1009
1010 /*
1011 * NAND_BUSWIDTH_16 may have been set by nand_scan_ident().
1012 * Add the SEL_16BIT flag in flctl->flcmncr_base.
1013 */
1014 if (chip->options & NAND_BUSWIDTH_16)
1015 flctl->flcmncr_base |= SEL_16BIT;
1009 1016
1010 if (mtd->writesize == 512) { 1017 if (mtd->writesize == 512) {
1011 flctl->page_size = 0; 1018 flctl->page_size = 0;
@@ -1063,6 +1070,10 @@ static int flctl_chip_init_tail(struct mtd_info *mtd)
1063 return 0; 1070 return 0;
1064} 1071}
1065 1072
1073static const struct nand_controller_ops flctl_nand_controller_ops = {
1074 .attach_chip = flctl_chip_attach_chip,
1075};
1076
1066static irqreturn_t flctl_handle_flste(int irq, void *dev_id) 1077static irqreturn_t flctl_handle_flste(int irq, void *dev_id)
1067{ 1078{
1068 struct sh_flctl *flctl = dev_id; 1079 struct sh_flctl *flctl = dev_id;
@@ -1191,25 +1202,8 @@ static int flctl_probe(struct platform_device *pdev)
1191 1202
1192 flctl_setup_dma(flctl); 1203 flctl_setup_dma(flctl);
1193 1204
1194 ret = nand_scan_ident(flctl_mtd, 1, NULL); 1205 nand->dummy_controller.ops = &flctl_nand_controller_ops;
1195 if (ret) 1206 ret = nand_scan(flctl_mtd, 1);
1196 goto err_chip;
1197
1198 if (nand->options & NAND_BUSWIDTH_16) {
1199 /*
1200 * NAND_BUSWIDTH_16 may have been set by nand_scan_ident().
1201 * Add the SEL_16BIT flag in pdata->flcmncr_val and re-assign
1202 * flctl->flcmncr_base to pdata->flcmncr_val.
1203 */
1204 pdata->flcmncr_val |= SEL_16BIT;
1205 flctl->flcmncr_base = pdata->flcmncr_val;
1206 }
1207
1208 ret = flctl_chip_init_tail(flctl_mtd);
1209 if (ret)
1210 goto err_chip;
1211
1212 ret = nand_scan_tail(flctl_mtd);
1213 if (ret) 1207 if (ret)
1214 goto err_chip; 1208 goto err_chip;
1215 1209