Skip to content

Commit 81924da

Browse files
committed
mtd: spi-nor: Emphasise which is the generic set_4byte_addr_mode() method
Rename (*set_4byte)() to (*set_4byte_addr_mode)() for a better differentiation between the 4 byte address mode and opcodes. Rename macronix_set_4byte() to spi_nor_set_4byte_addr_mode(), it will be the only 4 byte address mode method exposed to the manufacturer drivers. Here's how the manufacturers enter and exit the 4 byte address mode: - eon, gidadevice, issi, macronix, xmc use EN4B/EX4B - micron-st needs WEN. st_micron_set_4byte_addr_mode() will become a private method, as they are the only ones that need WEN before the EN4B/EX4B commands. - newer spansion have a 4BAM opcode (this translates to a new, public command). Older spansion flashes use the BRWR command (legacy in core.c -> spansion_set_4byte_addr_mode()) - winbond's method is hackish and may be reason for just a flash fixup hook -> private method Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com> Reviewed-by: Vignesh Raghavendra <vigneshr@ti.com>
1 parent 7648a72 commit 81924da

2 files changed

Lines changed: 20 additions & 18 deletions

File tree

‎drivers/mtd/spi-nor/spi-nor.c‎

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -568,14 +568,14 @@ static int spi_nor_read_cr(struct spi_nor *nor, u8 *cr)
568568
}
569569

570570
/**
571-
* macronix_set_4byte() - Set 4-byte address mode for Macronix flashes.
571+
* spi_nor_set_4byte_addr_mode() - Enter/Exit 4-byte address mode.
572572
* @nor: pointer to 'struct spi_nor'.
573573
* @enable: true to enter the 4-byte address mode, false to exit the 4-byte
574574
* address mode.
575575
*
576576
* Return: 0 on success, -errno otherwise.
577577
*/
578-
static int macronix_set_4byte(struct spi_nor *nor, bool enable)
578+
static int spi_nor_set_4byte_addr_mode(struct spi_nor *nor, bool enable)
579579
{
580580
int ret;
581581

@@ -604,37 +604,39 @@ static int macronix_set_4byte(struct spi_nor *nor, bool enable)
604604
}
605605

606606
/**
607-
* st_micron_set_4byte() - Set 4-byte address mode for ST and Micron flashes.
607+
* st_micron_set_4byte_addr_mode() - Set 4-byte address mode for ST and Micron
608+
* flashes.
608609
* @nor: pointer to 'struct spi_nor'.
609610
* @enable: true to enter the 4-byte address mode, false to exit the 4-byte
610611
* address mode.
611612
*
612613
* Return: 0 on success, -errno otherwise.
613614
*/
614-
static int st_micron_set_4byte(struct spi_nor *nor, bool enable)
615+
static int st_micron_set_4byte_addr_mode(struct spi_nor *nor, bool enable)
615616
{
616617
int ret;
617618

618619
ret = spi_nor_write_enable(nor);
619620
if (ret)
620621
return ret;
621622

622-
ret = macronix_set_4byte(nor, enable);
623+
ret = spi_nor_set_4byte_addr_mode(nor, enable);
623624
if (ret)
624625
return ret;
625626

626627
return spi_nor_write_disable(nor);
627628
}
628629

629630
/**
630-
* spansion_set_4byte() - Set 4-byte address mode for Spansion flashes.
631+
* spansion_set_4byte_addr_mode() - Set 4-byte address mode for Spansion
632+
* flashes.
631633
* @nor: pointer to 'struct spi_nor'.
632634
* @enable: true to enter the 4-byte address mode, false to exit the 4-byte
633635
* address mode.
634636
*
635637
* Return: 0 on success, -errno otherwise.
636638
*/
637-
static int spansion_set_4byte(struct spi_nor *nor, bool enable)
639+
static int spansion_set_4byte_addr_mode(struct spi_nor *nor, bool enable)
638640
{
639641
int ret;
640642

@@ -692,18 +694,18 @@ static int spi_nor_write_ear(struct spi_nor *nor, u8 ear)
692694
}
693695

694696
/**
695-
* winbond_set_4byte() - Set 4-byte address mode for Winbond flashes.
697+
* winbond_set_4byte_addr_mode() - Set 4-byte address mode for Winbond flashes.
696698
* @nor: pointer to 'struct spi_nor'.
697699
* @enable: true to enter the 4-byte address mode, false to exit the 4-byte
698700
* address mode.
699701
*
700702
* Return: 0 on success, -errno otherwise.
701703
*/
702-
static int winbond_set_4byte(struct spi_nor *nor, bool enable)
704+
static int winbond_set_4byte_addr_mode(struct spi_nor *nor, bool enable)
703705
{
704706
int ret;
705707

706-
ret = macronix_set_4byte(nor, enable);
708+
ret = spi_nor_set_4byte_addr_mode(nor, enable);
707709
if (ret || enable)
708710
return ret;
709711

@@ -4655,7 +4657,7 @@ static void issi_set_default_init(struct spi_nor *nor)
46554657
static void macronix_set_default_init(struct spi_nor *nor)
46564658
{
46574659
nor->params.quad_enable = spi_nor_sr1_bit6_quad_enable;
4658-
nor->params.set_4byte = macronix_set_4byte;
4660+
nor->params.set_4byte_addr_mode = spi_nor_set_4byte_addr_mode;
46594661
}
46604662

46614663
static void sst_set_default_init(struct spi_nor *nor)
@@ -4668,12 +4670,12 @@ static void st_micron_set_default_init(struct spi_nor *nor)
46684670
nor->flags |= SNOR_F_HAS_LOCK;
46694671
nor->flags &= ~SNOR_F_HAS_16BIT_SR;
46704672
nor->params.quad_enable = NULL;
4671-
nor->params.set_4byte = st_micron_set_4byte;
4673+
nor->params.set_4byte_addr_mode = st_micron_set_4byte_addr_mode;
46724674
}
46734675

46744676
static void winbond_set_default_init(struct spi_nor *nor)
46754677
{
4676-
nor->params.set_4byte = winbond_set_4byte;
4678+
nor->params.set_4byte_addr_mode = winbond_set_4byte_addr_mode;
46774679
}
46784680

46794681
/**
@@ -4759,7 +4761,7 @@ static void spi_nor_info_init_params(struct spi_nor *nor)
47594761

47604762
/* Initialize legacy flash parameters and settings. */
47614763
params->quad_enable = spi_nor_sr2_bit1_quad_enable;
4762-
params->set_4byte = spansion_set_4byte;
4764+
params->set_4byte_addr_mode = spansion_set_4byte_addr_mode;
47634765
params->setup = spi_nor_default_setup;
47644766
/* Default to 16-bit Write Status (01h) Command */
47654767
nor->flags |= SNOR_F_HAS_16BIT_SR;
@@ -5011,7 +5013,7 @@ static int spi_nor_init(struct spi_nor *nor)
50115013
*/
50125014
WARN_ONCE(nor->flags & SNOR_F_BROKEN_RESET,
50135015
"enabling reset hack; may not recover from unexpected reboots\n");
5014-
nor->params.set_4byte(nor, true);
5016+
nor->params.set_4byte_addr_mode(nor, true);
50155017
}
50165018

50175019
return 0;
@@ -5035,7 +5037,7 @@ void spi_nor_restore(struct spi_nor *nor)
50355037
/* restore the addressing mode */
50365038
if (nor->addr_width == 4 && !(nor->flags & SNOR_F_4B_OPCODES) &&
50375039
nor->flags & SNOR_F_BROKEN_RESET)
5038-
nor->params.set_4byte(nor, false);
5040+
nor->params.set_4byte_addr_mode(nor, false);
50395041
}
50405042
EXPORT_SYMBOL_GPL(spi_nor_restore);
50415043

‎include/linux/mtd/spi-nor.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ struct spi_nor_locking_ops {
520520
* @erase_map: the erase map parsed from the SFDP Sector Map Parameter
521521
* Table.
522522
* @quad_enable: enables SPI NOR quad mode.
523-
* @set_4byte: puts the SPI NOR in 4 byte addressing mode.
523+
* @set_4byte_addr_mode: puts the SPI NOR in 4 byte addressing mode.
524524
* @convert_addr: converts an absolute address into something the flash
525525
* will understand. Particularly useful when pagesize is
526526
* not a power-of-2.
@@ -541,7 +541,7 @@ struct spi_nor_flash_parameter {
541541
struct spi_nor_erase_map erase_map;
542542

543543
int (*quad_enable)(struct spi_nor *nor);
544-
int (*set_4byte)(struct spi_nor *nor, bool enable);
544+
int (*set_4byte_addr_mode)(struct spi_nor *nor, bool enable);
545545
u32 (*convert_addr)(struct spi_nor *nor, u32 addr);
546546
int (*setup)(struct spi_nor *nor, const struct spi_nor_hwcaps *hwcaps);
547547

0 commit comments

Comments
 (0)