aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorBoris Brezillon2018-09-06 14:05:13 +0200
committerMiquel Raynal2018-10-03 11:12:25 +0200
commit47bd59e538d4e7b3ad9c18bef5c1052657bdff59 (patch)
tree89ee6a0d584e3f3793697fcdc3585a0b3b4f955b /drivers
parent2f91eb6951d9e9d8d751a390cfd3e8b0216d88ef (diff)
mtd: rawnand: plat_nand: Pass a nand_chip object to all platform_nand_ctrl hooks
Let's make the raw NAND API consistent by patching all helpers and hooks to take a nand_chip object instead of an mtd_info one or remove the mtd_info object when both are passed. In order to do that, we first need to update the platform_nand_ctrl hooks to take a nand_chip object instead of an mtd_info. We add temporary plat_nand_xxx() wrappers to the do the mtd -> chip conversion, but those will be dropped when patching nand_chip hooks to take a nand_chip object. Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Reviewed-by: Alexander Sverdlin <alexander.sverdlin@gmail.com> Acked-by: Alexander Sverdlin <alexander.sverdlin@gmail.com> Acked-by: Robert Jarzmik <robert.jarzmik@free.fr> Acked-by: Krzysztof Halasa <khalasa@piap.pl> Acked-by: Paul Burton <paul.burton@mips.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/nand/raw/plat_nand.c57
1 files changed, 52 insertions, 5 deletions
diff --git a/drivers/mtd/nand/raw/plat_nand.c b/drivers/mtd/nand/raw/plat_nand.c
index 222626df4b96..24f904300c44 100644
--- a/drivers/mtd/nand/raw/plat_nand.c
+++ b/drivers/mtd/nand/raw/plat_nand.c
@@ -23,6 +23,42 @@ struct plat_nand_data {
void __iomem *io_base;
};
+static void plat_nand_cmd_ctrl(struct mtd_info *mtd, int dat, unsigned int ctrl)
+{
+ struct platform_nand_data *pdata = dev_get_platdata(mtd->dev.parent);
+
+ pdata->ctrl.cmd_ctrl(mtd_to_nand(mtd), dat, ctrl);
+}
+
+static int plat_nand_dev_ready(struct mtd_info *mtd)
+{
+ struct platform_nand_data *pdata = dev_get_platdata(mtd->dev.parent);
+
+ return pdata->ctrl.dev_ready(mtd_to_nand(mtd));
+}
+
+static void plat_nand_select_chip(struct mtd_info *mtd, int cs)
+{
+ struct platform_nand_data *pdata = dev_get_platdata(mtd->dev.parent);
+
+ pdata->ctrl.select_chip(mtd_to_nand(mtd), cs);
+}
+
+static void plat_nand_write_buf(struct mtd_info *mtd, const uint8_t *buf,
+ int len)
+{
+ struct platform_nand_data *pdata = dev_get_platdata(mtd->dev.parent);
+
+ pdata->ctrl.write_buf(mtd_to_nand(mtd), buf, len);
+}
+
+static void plat_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
+{
+ struct platform_nand_data *pdata = dev_get_platdata(mtd->dev.parent);
+
+ pdata->ctrl.read_buf(mtd_to_nand(mtd), buf, len);
+}
+
/*
* Probe for the NAND device.
*/
@@ -62,11 +98,22 @@ static int plat_nand_probe(struct platform_device *pdev)
data->chip.IO_ADDR_R = data->io_base;
data->chip.IO_ADDR_W = data->io_base;
- data->chip.cmd_ctrl = pdata->ctrl.cmd_ctrl;
- data->chip.dev_ready = pdata->ctrl.dev_ready;
- data->chip.select_chip = pdata->ctrl.select_chip;
- data->chip.write_buf = pdata->ctrl.write_buf;
- data->chip.read_buf = pdata->ctrl.read_buf;
+
+ if (pdata->ctrl.cmd_ctrl)
+ data->chip.cmd_ctrl = plat_nand_cmd_ctrl;
+
+ if (pdata->ctrl.dev_ready)
+ data->chip.dev_ready = plat_nand_dev_ready;
+
+ if (pdata->ctrl.select_chip)
+ data->chip.select_chip = plat_nand_select_chip;
+
+ if (pdata->ctrl.write_buf)
+ data->chip.write_buf = plat_nand_write_buf;
+
+ if (pdata->ctrl.read_buf)
+ data->chip.read_buf = plat_nand_read_buf;
+
data->chip.chip_delay = pdata->chip.chip_delay;
data->chip.options |= pdata->chip.options;
data->chip.bbt_options |= pdata->chip.bbt_options;