2020-03-13 19:42:48 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2005, Intec Automation Inc.
|
|
|
|
* Copyright (C) 2014, Freescale Semiconductor, Inc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/mtd/spi-nor.h>
|
|
|
|
|
|
|
|
#include "core.h"
|
|
|
|
|
2022-04-29 10:01:53 +00:00
|
|
|
#define WINBOND_NOR_OP_RDEAR 0xc8 /* Read Extended Address Register */
|
|
|
|
#define WINBOND_NOR_OP_WREAR 0xc5 /* Write Extended Address Register */
|
|
|
|
|
|
|
|
#define WINBOND_NOR_WREAR_OP(buf) \
|
|
|
|
SPI_MEM_OP(SPI_MEM_OP_CMD(WINBOND_NOR_OP_WREAR, 0), \
|
|
|
|
SPI_MEM_OP_NO_ADDR, \
|
|
|
|
SPI_MEM_OP_NO_DUMMY, \
|
|
|
|
SPI_MEM_OP_DATA_OUT(1, buf, 0))
|
|
|
|
|
2020-04-15 13:48:30 +00:00
|
|
|
static int
|
|
|
|
w25q256_post_bfpt_fixups(struct spi_nor *nor,
|
|
|
|
const struct sfdp_parameter_header *bfpt_header,
|
2021-03-06 09:50:00 +00:00
|
|
|
const struct sfdp_bfpt *bfpt)
|
2020-04-15 13:48:30 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* W25Q256JV supports 4B opcodes but W25Q256FV does not.
|
|
|
|
* Unfortunately, Winbond has re-used the same JEDEC ID for both
|
|
|
|
* variants which prevents us from defining a new entry in the parts
|
|
|
|
* table.
|
|
|
|
* To differentiate between W25Q256JV and W25Q256FV check SFDP header
|
|
|
|
* version: only JV has JESD216A compliant structure (version 5).
|
|
|
|
*/
|
|
|
|
if (bfpt_header->major == SFDP_JESD216_MAJOR &&
|
|
|
|
bfpt_header->minor == SFDP_JESD216A_MINOR)
|
|
|
|
nor->flags |= SNOR_F_4B_OPCODES;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-11-06 10:29:15 +00:00
|
|
|
static const struct spi_nor_fixups w25q256_fixups = {
|
2020-04-15 13:48:30 +00:00
|
|
|
.post_bfpt = w25q256_post_bfpt_fixups,
|
|
|
|
};
|
|
|
|
|
2022-02-23 13:43:40 +00:00
|
|
|
static const struct flash_info winbond_nor_parts[] = {
|
2020-03-13 19:42:48 +00:00
|
|
|
/* Winbond -- w25x "blocks" are 64K, "sectors" are 4KiB */
|
mtd: spi-nor: Rework the flash_info flags
Clarify for what the flash_info flags are used for. Split them in
four categories and a bool:
1/ FLAGS: flags that indicate support that is not defined by the JESD216
standard in its SFDP tables.
2/ NO_SFDP_FLAGS: these flags are used when the flash does not define the
SFDP tables. These flags indicate support that can be discovered via
SFDP. Used together with SPI_NOR_SKIP_SFDP flag.
3/ FIXUP_FLAGS: flags that indicate support that can be discovered
via SFDP ideally, but can not be discovered for this particular flash
because the SFDP table that indicates this support is not defined by
the flash. In case the table for this support is defined but has wrong
values, one should instead use a post_sfdp() hook to set the SNOR_F
equivalent flag.
4/ MFR_FLAGS: manufacturer private flags. Used in the manufacturer
fixup hooks to differentiate support between flashes of the same
manufacturer.
5/ PARSE_SFDP: sets info->parse_sfdp to true. All flash_info entries
that support SFDP should be converted to set info->parse_sfdp to true.
SPI NOR flashes that statically declare one of the
SPI_NOR_{DUAL, QUAD, OCTAL, OCTAL_DTR}_READ flags and do not support
the RDSFDP command are gratuiously receiving the RDSFDP command
in the attempt of parsing the SFDP tables. It is not desirable to issue
commands that are not supported, so introduce PARSE_SFDP to help on this
situation.
New flash additions/updates should be declared/updated to use either
PARSE_SFDP or SPI_NOR_SKIP_SFDP. Once all the flash_info entries are
converted to use SPI_NOR_SKIP_SFDP or PARSE_SFDP, we can get rid of the
SPI_NOR_SKIP_SFDP flag and use just the bool nor->info->parse_sfdp to
determine whether to parse SFDP or not. SPI_NOR_SKIP_SFDP flag is kept
just as a way to differentiate whether a flash is converted to the new
flags logic or not.
Support that can be discovered when parsing SFDP should not be duplicated
by explicit flags at flash declaration. All the flash parameters will be
discovered when parsing SFDP. Sometimes manufacturers wrongly define some
fields in the SFDP tables. If that's the case, SFDP data can be amended
with the fixups() hooks. It is not common, but if the SFDP tables are
entirely wrong, and it does not worth the hassle to tweak the SFDP
parameters by using the fixups hooks, or if the flash does not define the
SFDP tables at all, then statically init the flash with the
SPI_NOR_SKIP_SFDP flag and specify the rest of flash capabilities with
the flash info flags.
With time, we want to convert all flashes to use PARSE_SFDP and
stop triggering the SFDP parsing with the
SPI_NOR_{DUAL, QUAD, OCTAL*}_READ flags. Getting rid of the
SPI_NOR_{OCTAL, OCTAL_DTR}_READ trigger is easily achievable,
the rest are a long term goal.
Manufacturer specific flags like USE_CLSR, USE_FSR, SPI_NOR_XSR_RDY,
will be removed in a future series.
No functional changes intended in this patch.
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
Link: https://lore.kernel.org/r/20211207140254.87681-7-tudor.ambarus@microchip.com
2021-12-07 14:02:46 +00:00
|
|
|
{ "w25x05", INFO(0xef3010, 0, 64 * 1024, 1)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K) },
|
|
|
|
{ "w25x10", INFO(0xef3011, 0, 64 * 1024, 2)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K) },
|
|
|
|
{ "w25x20", INFO(0xef3012, 0, 64 * 1024, 4)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K) },
|
|
|
|
{ "w25x40", INFO(0xef3013, 0, 64 * 1024, 8)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K) },
|
|
|
|
{ "w25x80", INFO(0xef3014, 0, 64 * 1024, 16)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K) },
|
|
|
|
{ "w25x16", INFO(0xef3015, 0, 64 * 1024, 32)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K) },
|
|
|
|
{ "w25q16dw", INFO(0xef6015, 0, 64 * 1024, 32)
|
|
|
|
FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
|
|
|
|
SPI_NOR_QUAD_READ) },
|
|
|
|
{ "w25x32", INFO(0xef3016, 0, 64 * 1024, 64)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K) },
|
|
|
|
{ "w25q16jv-im/jm", INFO(0xef7015, 0, 64 * 1024, 32)
|
|
|
|
FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
|
|
|
|
SPI_NOR_QUAD_READ) },
|
|
|
|
{ "w25q20cl", INFO(0xef4012, 0, 64 * 1024, 4)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K) },
|
|
|
|
{ "w25q20bw", INFO(0xef5012, 0, 64 * 1024, 4)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K) },
|
|
|
|
{ "w25q20ew", INFO(0xef6012, 0, 64 * 1024, 4)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K) },
|
|
|
|
{ "w25q32", INFO(0xef4016, 0, 64 * 1024, 64)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K) },
|
|
|
|
{ "w25q32dw", INFO(0xef6016, 0, 64 * 1024, 64)
|
|
|
|
FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
|
|
|
|
OTP_INFO(256, 3, 0x1000, 0x1000) },
|
|
|
|
{ "w25q32jv", INFO(0xef7016, 0, 64 * 1024, 64)
|
|
|
|
FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
|
|
|
|
SPI_NOR_QUAD_READ) },
|
|
|
|
{ "w25q32jwm", INFO(0xef8016, 0, 64 * 1024, 64)
|
|
|
|
FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
|
|
|
|
OTP_INFO(256, 3, 0x1000, 0x1000) },
|
|
|
|
{ "w25q64jwm", INFO(0xef8017, 0, 64 * 1024, 128)
|
|
|
|
FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
|
|
|
|
SPI_NOR_QUAD_READ) },
|
|
|
|
{ "w25q128jwm", INFO(0xef8018, 0, 64 * 1024, 256)
|
|
|
|
FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
|
|
|
|
SPI_NOR_QUAD_READ) },
|
|
|
|
{ "w25q256jwm", INFO(0xef8019, 0, 64 * 1024, 512)
|
|
|
|
FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
|
|
|
|
SPI_NOR_QUAD_READ) },
|
|
|
|
{ "w25x64", INFO(0xef3017, 0, 64 * 1024, 128)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K) },
|
|
|
|
{ "w25q64", INFO(0xef4017, 0, 64 * 1024, 128)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
|
|
|
|
SPI_NOR_QUAD_READ) },
|
|
|
|
{ "w25q64dw", INFO(0xef6017, 0, 64 * 1024, 128)
|
|
|
|
FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
|
|
|
|
SPI_NOR_QUAD_READ) },
|
|
|
|
{ "w25q64jvm", INFO(0xef7017, 0, 64 * 1024, 128)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K) },
|
|
|
|
{ "w25q128fw", INFO(0xef6018, 0, 64 * 1024, 256)
|
|
|
|
FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
|
|
|
|
SPI_NOR_QUAD_READ) },
|
|
|
|
{ "w25q128jv", INFO(0xef7018, 0, 64 * 1024, 256)
|
|
|
|
FLAGS(SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
|
|
|
|
SPI_NOR_QUAD_READ) },
|
|
|
|
{ "w25q80", INFO(0xef5014, 0, 64 * 1024, 16)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K) },
|
|
|
|
{ "w25q80bl", INFO(0xef4014, 0, 64 * 1024, 16)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K) },
|
|
|
|
{ "w25q128", INFO(0xef4018, 0, 64 * 1024, 256)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K) },
|
|
|
|
{ "w25q256", INFO(0xef4019, 0, 64 * 1024, 512)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ)
|
|
|
|
.fixups = &w25q256_fixups },
|
|
|
|
{ "w25q256jvm", INFO(0xef7019, 0, 64 * 1024, 512)
|
2021-12-07 14:02:51 +00:00
|
|
|
PARSE_SFDP },
|
mtd: spi-nor: Rework the flash_info flags
Clarify for what the flash_info flags are used for. Split them in
four categories and a bool:
1/ FLAGS: flags that indicate support that is not defined by the JESD216
standard in its SFDP tables.
2/ NO_SFDP_FLAGS: these flags are used when the flash does not define the
SFDP tables. These flags indicate support that can be discovered via
SFDP. Used together with SPI_NOR_SKIP_SFDP flag.
3/ FIXUP_FLAGS: flags that indicate support that can be discovered
via SFDP ideally, but can not be discovered for this particular flash
because the SFDP table that indicates this support is not defined by
the flash. In case the table for this support is defined but has wrong
values, one should instead use a post_sfdp() hook to set the SNOR_F
equivalent flag.
4/ MFR_FLAGS: manufacturer private flags. Used in the manufacturer
fixup hooks to differentiate support between flashes of the same
manufacturer.
5/ PARSE_SFDP: sets info->parse_sfdp to true. All flash_info entries
that support SFDP should be converted to set info->parse_sfdp to true.
SPI NOR flashes that statically declare one of the
SPI_NOR_{DUAL, QUAD, OCTAL, OCTAL_DTR}_READ flags and do not support
the RDSFDP command are gratuiously receiving the RDSFDP command
in the attempt of parsing the SFDP tables. It is not desirable to issue
commands that are not supported, so introduce PARSE_SFDP to help on this
situation.
New flash additions/updates should be declared/updated to use either
PARSE_SFDP or SPI_NOR_SKIP_SFDP. Once all the flash_info entries are
converted to use SPI_NOR_SKIP_SFDP or PARSE_SFDP, we can get rid of the
SPI_NOR_SKIP_SFDP flag and use just the bool nor->info->parse_sfdp to
determine whether to parse SFDP or not. SPI_NOR_SKIP_SFDP flag is kept
just as a way to differentiate whether a flash is converted to the new
flags logic or not.
Support that can be discovered when parsing SFDP should not be duplicated
by explicit flags at flash declaration. All the flash parameters will be
discovered when parsing SFDP. Sometimes manufacturers wrongly define some
fields in the SFDP tables. If that's the case, SFDP data can be amended
with the fixups() hooks. It is not common, but if the SFDP tables are
entirely wrong, and it does not worth the hassle to tweak the SFDP
parameters by using the fixups hooks, or if the flash does not define the
SFDP tables at all, then statically init the flash with the
SPI_NOR_SKIP_SFDP flag and specify the rest of flash capabilities with
the flash info flags.
With time, we want to convert all flashes to use PARSE_SFDP and
stop triggering the SFDP parsing with the
SPI_NOR_{DUAL, QUAD, OCTAL*}_READ flags. Getting rid of the
SPI_NOR_{OCTAL, OCTAL_DTR}_READ trigger is easily achievable,
the rest are a long term goal.
Manufacturer specific flags like USE_CLSR, USE_FSR, SPI_NOR_XSR_RDY,
will be removed in a future series.
No functional changes intended in this patch.
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
Link: https://lore.kernel.org/r/20211207140254.87681-7-tudor.ambarus@microchip.com
2021-12-07 14:02:46 +00:00
|
|
|
{ "w25q256jw", INFO(0xef6019, 0, 64 * 1024, 512)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
|
|
|
|
SPI_NOR_QUAD_READ) },
|
|
|
|
{ "w25m512jv", INFO(0xef7119, 0, 64 * 1024, 1024)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_QUAD_READ |
|
|
|
|
SPI_NOR_DUAL_READ) },
|
2022-04-29 12:10:39 +00:00
|
|
|
{ "w25q512nwm", INFO(0xef8020, 0, 64 * 1024, 1024)
|
|
|
|
PARSE_SFDP
|
|
|
|
OTP_INFO(256, 3, 0x1000, 0x1000) },
|
mtd: spi-nor: Rework the flash_info flags
Clarify for what the flash_info flags are used for. Split them in
four categories and a bool:
1/ FLAGS: flags that indicate support that is not defined by the JESD216
standard in its SFDP tables.
2/ NO_SFDP_FLAGS: these flags are used when the flash does not define the
SFDP tables. These flags indicate support that can be discovered via
SFDP. Used together with SPI_NOR_SKIP_SFDP flag.
3/ FIXUP_FLAGS: flags that indicate support that can be discovered
via SFDP ideally, but can not be discovered for this particular flash
because the SFDP table that indicates this support is not defined by
the flash. In case the table for this support is defined but has wrong
values, one should instead use a post_sfdp() hook to set the SNOR_F
equivalent flag.
4/ MFR_FLAGS: manufacturer private flags. Used in the manufacturer
fixup hooks to differentiate support between flashes of the same
manufacturer.
5/ PARSE_SFDP: sets info->parse_sfdp to true. All flash_info entries
that support SFDP should be converted to set info->parse_sfdp to true.
SPI NOR flashes that statically declare one of the
SPI_NOR_{DUAL, QUAD, OCTAL, OCTAL_DTR}_READ flags and do not support
the RDSFDP command are gratuiously receiving the RDSFDP command
in the attempt of parsing the SFDP tables. It is not desirable to issue
commands that are not supported, so introduce PARSE_SFDP to help on this
situation.
New flash additions/updates should be declared/updated to use either
PARSE_SFDP or SPI_NOR_SKIP_SFDP. Once all the flash_info entries are
converted to use SPI_NOR_SKIP_SFDP or PARSE_SFDP, we can get rid of the
SPI_NOR_SKIP_SFDP flag and use just the bool nor->info->parse_sfdp to
determine whether to parse SFDP or not. SPI_NOR_SKIP_SFDP flag is kept
just as a way to differentiate whether a flash is converted to the new
flags logic or not.
Support that can be discovered when parsing SFDP should not be duplicated
by explicit flags at flash declaration. All the flash parameters will be
discovered when parsing SFDP. Sometimes manufacturers wrongly define some
fields in the SFDP tables. If that's the case, SFDP data can be amended
with the fixups() hooks. It is not common, but if the SFDP tables are
entirely wrong, and it does not worth the hassle to tweak the SFDP
parameters by using the fixups hooks, or if the flash does not define the
SFDP tables at all, then statically init the flash with the
SPI_NOR_SKIP_SFDP flag and specify the rest of flash capabilities with
the flash info flags.
With time, we want to convert all flashes to use PARSE_SFDP and
stop triggering the SFDP parsing with the
SPI_NOR_{DUAL, QUAD, OCTAL*}_READ flags. Getting rid of the
SPI_NOR_{OCTAL, OCTAL_DTR}_READ trigger is easily achievable,
the rest are a long term goal.
Manufacturer specific flags like USE_CLSR, USE_FSR, SPI_NOR_XSR_RDY,
will be removed in a future series.
No functional changes intended in this patch.
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
Link: https://lore.kernel.org/r/20211207140254.87681-7-tudor.ambarus@microchip.com
2021-12-07 14:02:46 +00:00
|
|
|
{ "w25q512jvq", INFO(0xef4020, 0, 64 * 1024, 1024)
|
|
|
|
NO_SFDP_FLAGS(SECT_4K | SPI_NOR_DUAL_READ |
|
|
|
|
SPI_NOR_QUAD_READ) },
|
2020-03-13 19:42:48 +00:00
|
|
|
};
|
|
|
|
|
2022-04-29 10:01:53 +00:00
|
|
|
/**
|
|
|
|
* winbond_nor_write_ear() - Write Extended Address Register.
|
|
|
|
* @nor: pointer to 'struct spi_nor'.
|
|
|
|
* @ear: value to write to the Extended Address Register.
|
|
|
|
*
|
|
|
|
* Return: 0 on success, -errno otherwise.
|
|
|
|
*/
|
|
|
|
static int winbond_nor_write_ear(struct spi_nor *nor, u8 ear)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
nor->bouncebuf[0] = ear;
|
|
|
|
|
|
|
|
if (nor->spimem) {
|
|
|
|
struct spi_mem_op op = WINBOND_NOR_WREAR_OP(nor->bouncebuf);
|
|
|
|
|
|
|
|
spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
|
|
|
|
|
|
|
|
ret = spi_mem_exec_op(nor->spimem, &op);
|
|
|
|
} else {
|
|
|
|
ret = spi_nor_controller_ops_write_reg(nor,
|
|
|
|
WINBOND_NOR_OP_WREAR,
|
|
|
|
nor->bouncebuf, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
dev_dbg(nor->dev, "error %d writing EAR\n", ret);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-03-13 19:42:48 +00:00
|
|
|
/**
|
2022-02-23 13:43:40 +00:00
|
|
|
* winbond_nor_set_4byte_addr_mode() - Set 4-byte address mode for Winbond
|
|
|
|
* flashes.
|
2020-03-13 19:42:48 +00:00
|
|
|
* @nor: pointer to 'struct spi_nor'.
|
|
|
|
* @enable: true to enter the 4-byte address mode, false to exit the 4-byte
|
|
|
|
* address mode.
|
|
|
|
*
|
|
|
|
* Return: 0 on success, -errno otherwise.
|
|
|
|
*/
|
2022-02-23 13:43:40 +00:00
|
|
|
static int winbond_nor_set_4byte_addr_mode(struct spi_nor *nor, bool enable)
|
2020-03-13 19:42:48 +00:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = spi_nor_set_4byte_addr_mode(nor, enable);
|
|
|
|
if (ret || enable)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* On Winbond W25Q256FV, leaving 4byte mode causes the Extended Address
|
|
|
|
* Register to be set to 1, so all 3-byte-address reads come from the
|
|
|
|
* second 16M. We must clear the register to enable normal behavior.
|
|
|
|
*/
|
|
|
|
ret = spi_nor_write_enable(nor);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2022-04-29 10:01:53 +00:00
|
|
|
ret = winbond_nor_write_ear(nor, 0);
|
2020-03-13 19:42:48 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return spi_nor_write_disable(nor);
|
|
|
|
}
|
|
|
|
|
2022-02-23 13:43:40 +00:00
|
|
|
static const struct spi_nor_otp_ops winbond_nor_otp_ops = {
|
2021-03-21 23:51:40 +00:00
|
|
|
.read = spi_nor_otp_read_secr,
|
|
|
|
.write = spi_nor_otp_write_secr,
|
2021-06-07 11:27:44 +00:00
|
|
|
.erase = spi_nor_otp_erase_secr,
|
2021-03-21 23:51:40 +00:00
|
|
|
.lock = spi_nor_otp_lock_sr2,
|
|
|
|
.is_locked = spi_nor_otp_is_locked_sr2,
|
|
|
|
};
|
|
|
|
|
2022-02-23 13:43:40 +00:00
|
|
|
static void winbond_nor_default_init(struct spi_nor *nor)
|
2020-03-13 19:42:48 +00:00
|
|
|
{
|
2022-02-23 13:43:40 +00:00
|
|
|
nor->params->set_4byte_addr_mode = winbond_nor_set_4byte_addr_mode;
|
2021-10-29 17:26:16 +00:00
|
|
|
}
|
|
|
|
|
2022-02-23 13:43:40 +00:00
|
|
|
static void winbond_nor_late_init(struct spi_nor *nor)
|
2021-10-29 17:26:16 +00:00
|
|
|
{
|
2021-03-21 23:51:40 +00:00
|
|
|
if (nor->params->otp.org->n_regions)
|
2022-02-23 13:43:40 +00:00
|
|
|
nor->params->otp.ops = &winbond_nor_otp_ops;
|
2020-03-13 19:42:48 +00:00
|
|
|
}
|
|
|
|
|
2022-02-23 13:43:40 +00:00
|
|
|
static const struct spi_nor_fixups winbond_nor_fixups = {
|
|
|
|
.default_init = winbond_nor_default_init,
|
|
|
|
.late_init = winbond_nor_late_init,
|
2020-03-13 19:42:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const struct spi_nor_manufacturer spi_nor_winbond = {
|
|
|
|
.name = "winbond",
|
2022-02-23 13:43:40 +00:00
|
|
|
.parts = winbond_nor_parts,
|
|
|
|
.nparts = ARRAY_SIZE(winbond_nor_parts),
|
|
|
|
.fixups = &winbond_nor_fixups,
|
2020-03-13 19:42:48 +00:00
|
|
|
};
|