Skip to content

Commit 5dbc889

Browse files
yopemiquelraynal
authored andcommitted
mtd: mchp48l640: make WEL behaviour configurable
The 48L640 resets the WEL bit (the Write Enable Latch bit in the status register) to zero on the completion of write operations. In preparation to support chips behaving differently, introduce .auto_disable_wel capability, and, if it's missing, explicitly reset the WEL bit after writes. Signed-off-by: David Jander <[email protected]> Reviewed-by: Heiko Schocher <[email protected]> Signed-off-by: Jonas Rebmann <[email protected]> Signed-off-by: Miquel Raynal <[email protected]>
1 parent b3c7828 commit 5dbc889

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

drivers/mtd/devices/mchp48l640.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
struct mchp48_caps {
2828
unsigned int size;
2929
unsigned int page_size;
30+
bool auto_disable_wel;
3031
};
3132

3233
struct mchp48l640_flash {
@@ -194,9 +195,15 @@ static int mchp48l640_write_page(struct mtd_info *mtd, loff_t to, size_t len,
194195
else
195196
goto fail;
196197

197-
ret = mchp48l640_waitforbit(flash, MCHP48L640_STATUS_WEL, false);
198-
if (ret)
199-
goto fail;
198+
if (flash->caps->auto_disable_wel) {
199+
ret = mchp48l640_waitforbit(flash, MCHP48L640_STATUS_WEL, false);
200+
if (ret)
201+
goto fail;
202+
} else {
203+
ret = mchp48l640_write_prepare(flash, false);
204+
if (ret)
205+
goto fail;
206+
}
200207

201208
kfree(cmd);
202209
return 0;
@@ -293,6 +300,7 @@ static int mchp48l640_read(struct mtd_info *mtd, loff_t from, size_t len,
293300
static const struct mchp48_caps mchp48l640_caps = {
294301
.size = SZ_8K,
295302
.page_size = 32,
303+
.auto_disable_wel = true,
296304
};
297305

298306
static int mchp48l640_probe(struct spi_device *spi)

0 commit comments

Comments
 (0)