Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7a08dbae authored by Boris Brezillon's avatar Boris Brezillon Committed by Miquel Raynal
Browse files

mtd: rawnand: Move ->setup_data_interface() to nand_controller_ops



->setup_data_interface() is a controller specific method and should
thus be placed in nand_controller_ops.

In order to make that work with controllers that support keeping
pre-configured timings we need to add a new NAND_KEEP_TIMINGS flag to
inform the core it should skip the timings selection step.

Signed-off-by: default avatarBoris Brezillon <boris.brezillon@bootlin.com>
Tested-by: default avatarJanusz Krzysztofik <jmkrzyszt@gmail.com>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
parent f2abfeb2
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -1479,8 +1479,8 @@ static void atmel_nand_init(struct atmel_nand_controller *nc,
	chip->legacy.write_buf = atmel_nand_write_buf;
	chip->legacy.select_chip = atmel_nand_select_chip;

	if (nc->mck && nc->caps->ops->setup_data_interface)
		chip->setup_data_interface = atmel_nand_setup_data_interface;
	if (!nc->mck || !nc->caps->ops->setup_data_interface)
		chip->options |= NAND_KEEP_TIMINGS;

	/* Some NANDs require a longer delay than the default one (20us). */
	chip->legacy.chip_delay = 40;
@@ -1908,6 +1908,7 @@ static int atmel_nand_attach_chip(struct nand_chip *chip)

static const struct nand_controller_ops atmel_nand_controller_ops = {
	.attach_chip = atmel_nand_attach_chip,
	.setup_data_interface = atmel_nand_setup_data_interface,
};

static int atmel_nand_controller_init(struct atmel_nand_controller *nc,
+2 −1
Original line number Diff line number Diff line
@@ -1316,6 +1316,7 @@ static void denali_detach_chip(struct nand_chip *chip)
static const struct nand_controller_ops denali_controller_ops = {
	.attach_chip = denali_attach_chip,
	.detach_chip = denali_detach_chip,
	.setup_data_interface = denali_setup_data_interface,
};

int denali_init(struct denali_nand_info *denali)
@@ -1372,7 +1373,7 @@ int denali_init(struct denali_nand_info *denali)

	/* clk rate info is needed for setup_data_interface */
	if (denali->clk_rate && denali->clk_x_rate)
		chip->setup_data_interface = denali_setup_data_interface;
		chip->options |= NAND_KEEP_TIMINGS;

	chip->dummy_controller.ops = &denali_controller_ops;
	ret = nand_scan(chip, denali->max_banks);
+4 −3
Original line number Diff line number Diff line
@@ -996,6 +996,7 @@ static int fsmc_nand_attach_chip(struct nand_chip *nand)
static const struct nand_controller_ops fsmc_nand_controller_ops = {
	.attach_chip = fsmc_nand_attach_chip,
	.exec_op = fsmc_exec_op,
	.setup_data_interface = fsmc_setup_data_interface,
};

/*
@@ -1108,10 +1109,10 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)
		}
	}

	if (host->dev_timings)
	if (host->dev_timings) {
		fsmc_nand_setup(host, host->dev_timings);
	else
		nand->setup_data_interface = fsmc_setup_data_interface;
		nand->options |= NAND_KEEP_TIMINGS;
	}

	if (AMBA_REV_BITS(host->pid) >= 8) {
		nand->ecc.read_page = fsmc_read_page_hwecc;
+1 −1
Original line number Diff line number Diff line
@@ -1889,6 +1889,7 @@ static int gpmi_nand_attach_chip(struct nand_chip *chip)

static const struct nand_controller_ops gpmi_nand_controller_ops = {
	.attach_chip = gpmi_nand_attach_chip,
	.setup_data_interface = gpmi_setup_data_interface,
};

static int gpmi_nand_init(struct gpmi_nand_data *this)
@@ -1908,7 +1909,6 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)
	nand_set_controller_data(chip, this);
	nand_set_flash_node(chip, this->pdev->dev.of_node);
	chip->legacy.select_chip	= gpmi_select_chip;
	chip->setup_data_interface = gpmi_setup_data_interface;
	chip->legacy.cmd_ctrl	= gpmi_cmd_ctrl;
	chip->legacy.dev_ready	= gpmi_dev_ready;
	chip->legacy.read_byte	= gpmi_read_byte;
+12 −0
Original line number Diff line number Diff line
@@ -116,6 +116,18 @@ static inline int nand_exec_op(struct nand_chip *chip,
	return chip->controller->ops->exec_op(chip, op, false);
}

static inline bool nand_has_setup_data_iface(struct nand_chip *chip)
{
	if (!chip->controller || !chip->controller->ops ||
	    !chip->controller->ops->setup_data_interface)
		return false;

	if (chip->options & NAND_KEEP_TIMINGS)
		return false;

	return true;
}

/* BBT functions */
int nand_markbad_bbt(struct nand_chip *chip, loff_t offs);
int nand_isreserved_bbt(struct nand_chip *chip, loff_t offs);
Loading