Skip to content

Commit 076aa4e

Browse files
committed
mtd: spi-nor: core: Move generic method to core - micron_st_nor_set_4byte_addr_mode
This method is described in JESD216 BFPT[SFDP_DWORD(16)], BIT(30) and BIT(22). Move the method to core. Reviewed-by: Michael Walle <michael@walle.cc> Link: https://lore.kernel.org/r/20230331074606.3559258-2-tudor.ambarus@linaro.org Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
1 parent f0a499a commit 076aa4e

3 files changed

Lines changed: 25 additions & 24 deletions

File tree

drivers/mtd/spi-nor/core.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,30 @@ int spi_nor_set_4byte_addr_mode(struct spi_nor *nor, bool enable)
538538
return ret;
539539
}
540540

541+
/**
542+
* micron_st_nor_set_4byte_addr_mode() - Set 4-byte address mode for ST and
543+
* Micron flashes.
544+
* @nor: pointer to 'struct spi_nor'.
545+
* @enable: true to enter the 4-byte address mode, false to exit the 4-byte
546+
* address mode.
547+
*
548+
* Return: 0 on success, -errno otherwise.
549+
*/
550+
int micron_st_nor_set_4byte_addr_mode(struct spi_nor *nor, bool enable)
551+
{
552+
int ret;
553+
554+
ret = spi_nor_write_enable(nor);
555+
if (ret)
556+
return ret;
557+
558+
ret = spi_nor_set_4byte_addr_mode(nor, enable);
559+
if (ret)
560+
return ret;
561+
562+
return spi_nor_write_disable(nor);
563+
}
564+
541565
/**
542566
* spansion_set_4byte_addr_mode() - Set 4-byte address mode for Spansion
543567
* flashes.

drivers/mtd/spi-nor/core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,7 @@ void spi_nor_spimem_setup_op(const struct spi_nor *nor,
648648
int spi_nor_write_enable(struct spi_nor *nor);
649649
int spi_nor_write_disable(struct spi_nor *nor);
650650
int spi_nor_set_4byte_addr_mode(struct spi_nor *nor, bool enable);
651+
int micron_st_nor_set_4byte_addr_mode(struct spi_nor *nor, bool enable);
651652
int spi_nor_wait_till_ready(struct spi_nor *nor);
652653
int spi_nor_global_block_unlock(struct spi_nor *nor);
653654
int spi_nor_prep_and_lock(struct spi_nor *nor);

drivers/mtd/spi-nor/micron-st.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -301,30 +301,6 @@ static const struct flash_info st_nor_parts[] = {
301301
{ "m25px80", INFO(0x207114, 0, 64 * 1024, 16) },
302302
};
303303

304-
/**
305-
* micron_st_nor_set_4byte_addr_mode() - Set 4-byte address mode for ST and
306-
* Micron flashes.
307-
* @nor: pointer to 'struct spi_nor'.
308-
* @enable: true to enter the 4-byte address mode, false to exit the 4-byte
309-
* address mode.
310-
*
311-
* Return: 0 on success, -errno otherwise.
312-
*/
313-
static int micron_st_nor_set_4byte_addr_mode(struct spi_nor *nor, bool enable)
314-
{
315-
int ret;
316-
317-
ret = spi_nor_write_enable(nor);
318-
if (ret)
319-
return ret;
320-
321-
ret = spi_nor_set_4byte_addr_mode(nor, enable);
322-
if (ret)
323-
return ret;
324-
325-
return spi_nor_write_disable(nor);
326-
}
327-
328304
/**
329305
* micron_st_nor_read_fsr() - Read the Flag Status Register.
330306
* @nor: pointer to 'struct spi_nor'

0 commit comments

Comments
 (0)