diff options
author | Miquel Raynal <miquel.raynal@bootlin.com> | 2018-07-25 09:31:36 -0400 |
---|---|---|
committer | Miquel Raynal <miquel.raynal@bootlin.com> | 2018-07-31 03:46:06 -0400 |
commit | 4918b905736fddc67f14618d5c82f7edc5944db8 (patch) | |
tree | f5b07277f709339c186e95f9dfe59c9629454ef3 | |
parent | 16909c81c6298c2db5587340106523e0a6c2bfe2 (diff) |
mtd: rawnand: brcmnand: 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>
-rw-r--r-- | drivers/mtd/nand/raw/brcmnand/brcmnand.c | 63 |
1 files changed, 36 insertions, 27 deletions
diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c index 2e5efa0f9ea2..4b90d5b380c2 100644 --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c | |||
@@ -2208,6 +2208,40 @@ static int brcmnand_setup_dev(struct brcmnand_host *host) | |||
2208 | return 0; | 2208 | return 0; |
2209 | } | 2209 | } |
2210 | 2210 | ||
2211 | static int brcmnand_attach_chip(struct nand_chip *chip) | ||
2212 | { | ||
2213 | struct mtd_info *mtd = nand_to_mtd(chip); | ||
2214 | struct brcmnand_host *host = nand_get_controller_data(chip); | ||
2215 | int ret; | ||
2216 | |||
2217 | chip->options |= NAND_NO_SUBPAGE_WRITE; | ||
2218 | /* | ||
2219 | * Avoid (for instance) kmap()'d buffers from JFFS2, which we can't DMA | ||
2220 | * to/from, and have nand_base pass us a bounce buffer instead, as | ||
2221 | * needed. | ||
2222 | */ | ||
2223 | chip->options |= NAND_USE_BOUNCE_BUFFER; | ||
2224 | |||
2225 | if (chip->bbt_options & NAND_BBT_USE_FLASH) | ||
2226 | chip->bbt_options |= NAND_BBT_NO_OOB; | ||
2227 | |||
2228 | if (brcmnand_setup_dev(host)) | ||
2229 | return -ENXIO; | ||
2230 | |||
2231 | chip->ecc.size = host->hwcfg.sector_size_1k ? 1024 : 512; | ||
2232 | |||
2233 | /* only use our internal HW threshold */ | ||
2234 | mtd->bitflip_threshold = 1; | ||
2235 | |||
2236 | ret = brcmstb_choose_ecc_layout(host); | ||
2237 | |||
2238 | return ret; | ||
2239 | } | ||
2240 | |||
2241 | static const struct nand_controller_ops brcmnand_controller_ops = { | ||
2242 | .attach_chip = brcmnand_attach_chip, | ||
2243 | }; | ||
2244 | |||
2211 | static int brcmnand_init_cs(struct brcmnand_host *host, struct device_node *dn) | 2245 | static int brcmnand_init_cs(struct brcmnand_host *host, struct device_node *dn) |
2212 | { | 2246 | { |
2213 | struct brcmnand_controller *ctrl = host->ctrl; | 2247 | struct brcmnand_controller *ctrl = host->ctrl; |
@@ -2267,33 +2301,7 @@ static int brcmnand_init_cs(struct brcmnand_host *host, struct device_node *dn) | |||
2267 | nand_writereg(ctrl, cfg_offs, | 2301 | nand_writereg(ctrl, cfg_offs, |
2268 | nand_readreg(ctrl, cfg_offs) & ~CFG_BUS_WIDTH); | 2302 | nand_readreg(ctrl, cfg_offs) & ~CFG_BUS_WIDTH); |
2269 | 2303 | ||
2270 | ret = nand_scan_ident(mtd, 1, NULL); | 2304 | ret = nand_scan(mtd, 1); |
2271 | if (ret) | ||
2272 | return ret; | ||
2273 | |||
2274 | chip->options |= NAND_NO_SUBPAGE_WRITE; | ||
2275 | /* | ||
2276 | * Avoid (for instance) kmap()'d buffers from JFFS2, which we can't DMA | ||
2277 | * to/from, and have nand_base pass us a bounce buffer instead, as | ||
2278 | * needed. | ||
2279 | */ | ||
2280 | chip->options |= NAND_USE_BOUNCE_BUFFER; | ||
2281 | |||
2282 | if (chip->bbt_options & NAND_BBT_USE_FLASH) | ||
2283 | chip->bbt_options |= NAND_BBT_NO_OOB; | ||
2284 | |||
2285 | if (brcmnand_setup_dev(host)) | ||
2286 | return -ENXIO; | ||
2287 | |||
2288 | chip->ecc.size = host->hwcfg.sector_size_1k ? 1024 : 512; | ||
2289 | /* only use our internal HW threshold */ | ||
2290 | mtd->bitflip_threshold = 1; | ||
2291 | |||
2292 | ret = brcmstb_choose_ecc_layout(host); | ||
2293 | if (ret) | ||
2294 | return ret; | ||
2295 | |||
2296 | ret = nand_scan_tail(mtd); | ||
2297 | if (ret) | 2305 | if (ret) |
2298 | return ret; | 2306 | return ret; |
2299 | 2307 | ||
@@ -2434,6 +2442,7 @@ int brcmnand_probe(struct platform_device *pdev, struct brcmnand_soc *soc) | |||
2434 | init_completion(&ctrl->done); | 2442 | init_completion(&ctrl->done); |
2435 | init_completion(&ctrl->dma_done); | 2443 | init_completion(&ctrl->dma_done); |
2436 | nand_controller_init(&ctrl->controller); | 2444 | nand_controller_init(&ctrl->controller); |
2445 | ctrl->controller.ops = &brcmnand_controller_ops; | ||
2437 | INIT_LIST_HEAD(&ctrl->host_list); | 2446 | INIT_LIST_HEAD(&ctrl->host_list); |
2438 | 2447 | ||
2439 | /* NAND register range */ | 2448 | /* NAND register range */ |