mtd: rawnand: ams-delta: Don't hardcode read/write pulse widths

Instead of forcing Amstrad Delta specific read/write pulse widths, use
variables initialised from respective fields of chip SDR timings.

Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200212003929.6682-8-jmkrzyszt@gmail.com
This commit is contained in:
Janusz Krzysztofik 2020-02-12 01:39:22 +01:00 committed by Miquel Raynal
parent 241008ed0b
commit ccada49b05

View File

@ -40,12 +40,14 @@ struct ams_delta_nand {
struct gpio_desc *gpiod_cle;
struct gpio_descs *data_gpiods;
bool data_in;
unsigned int tRP;
unsigned int tWP;
};
static void ams_delta_write_commit(struct ams_delta_nand *priv)
{
gpiod_set_value(priv->gpiod_nwe, 1);
ndelay(40);
ndelay(priv->tWP);
gpiod_set_value(priv->gpiod_nwe, 0);
}
@ -82,7 +84,7 @@ static u8 ams_delta_io_read(struct ams_delta_nand *priv)
DECLARE_BITMAP(values, BITS_PER_TYPE(res)) = { 0, };
gpiod_set_value(priv->gpiod_nre, 1);
ndelay(40);
ndelay(priv->tRP);
gpiod_get_raw_array_value(data_gpiods->ndescs, data_gpiods->desc,
data_gpiods->info, values);
@ -187,8 +189,31 @@ static int ams_delta_exec_op(struct nand_chip *this,
return ret;
}
static int ams_delta_setup_data_interface(struct nand_chip *this, int csline,
const struct nand_data_interface *cf)
{
struct ams_delta_nand *priv = nand_get_controller_data(this);
const struct nand_sdr_timings *sdr = nand_get_sdr_timings(cf);
struct device *dev = &nand_to_mtd(this)->dev;
if (IS_ERR(sdr))
return PTR_ERR(sdr);
if (csline == NAND_DATA_IFACE_CHECK_ONLY)
return 0;
priv->tRP = DIV_ROUND_UP(sdr->tRP_min, 1000);
dev_dbg(dev, "using %u ns read pulse width\n", priv->tRP);
priv->tWP = DIV_ROUND_UP(sdr->tWP_min, 1000);
dev_dbg(dev, "using %u ns write pulse width\n", priv->tWP);
return 0;
}
static const struct nand_controller_ops ams_delta_ops = {
.exec_op = ams_delta_exec_op,
.setup_data_interface = ams_delta_setup_data_interface,
};
/*