Skip to content

Commit 4cf1d12

Browse files
committed
Revert "mtd: spi-nor: parse SFDP 4-byte Address Instruction Table"
This reverts commit 1f70f3b. There are slightly different changes between what we applied back in linux4sam-6.0 and what reached mainline. Revert the 4BAIT, SMPT and non-uniform erase support and backport the support and fixes from mainline. Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
1 parent 128c156 commit 4cf1d12

1 file changed

Lines changed: 0 additions & 148 deletions

File tree

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

Lines changed: 0 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -2137,7 +2137,6 @@ struct sfdp_parameter_header {
21372137

21382138
#define SFDP_BFPT_ID 0xff00 /* Basic Flash Parameter Table */
21392139
#define SFDP_SECTOR_MAP_ID 0xff81 /* Sector Map Table */
2140-
#define SFDP_4BAIT_ID 0xff84u /* 4-byte Address Instruction Table */
21412140

21422141
#define SFDP_SIGNATURE 0x50444653U
21432142
#define SFDP_JESD216_MAJOR 1
@@ -2825,149 +2824,6 @@ static int spi_nor_parse_smpt(struct spi_nor *nor,
28252824
return ret;
28262825
}
28272826

2828-
struct sfdp_4bait {
2829-
/* The hardware capability. */
2830-
u32 hwcaps;
2831-
2832-
/*
2833-
* The <supported_bit> bit in DWORD1 of the 4BAIT tells us whether
2834-
* the associated 4-byte address op code is supported.
2835-
*/
2836-
u32 supported_bit;
2837-
};
2838-
2839-
static int spi_nor_parse_4bait(struct spi_nor *nor,
2840-
const struct sfdp_parameter_header *param_header,
2841-
struct spi_nor_flash_parameter *params)
2842-
{
2843-
static const struct sfdp_4bait reads[] = {
2844-
{ SNOR_HWCAPS_READ, BIT(0) },
2845-
{ SNOR_HWCAPS_READ_FAST, BIT(1) },
2846-
{ SNOR_HWCAPS_READ_1_1_2, BIT(2) },
2847-
{ SNOR_HWCAPS_READ_1_2_2, BIT(3) },
2848-
{ SNOR_HWCAPS_READ_1_1_4, BIT(4) },
2849-
{ SNOR_HWCAPS_READ_1_4_4, BIT(5) },
2850-
{ SNOR_HWCAPS_READ_1_1_1_DTR, BIT(13) },
2851-
{ SNOR_HWCAPS_READ_1_2_2_DTR, BIT(14) },
2852-
{ SNOR_HWCAPS_READ_1_4_4_DTR, BIT(15) },
2853-
};
2854-
static const struct sfdp_4bait programs[] = {
2855-
{ SNOR_HWCAPS_PP, BIT(6) },
2856-
{ SNOR_HWCAPS_PP_1_1_4, BIT(7) },
2857-
{ SNOR_HWCAPS_PP_1_4_4, BIT(8) },
2858-
};
2859-
static const struct sfdp_4bait erases[SNOR_ERASE_TYPE_MAX] = {
2860-
{ 0u /* not used */, BIT(9) },
2861-
{ 0u /* not used */, BIT(10) },
2862-
{ 0u /* not used */, BIT(11) },
2863-
{ 0u /* not used */, BIT(12) },
2864-
};
2865-
u32 dwords[2], addr, discard_hwcaps, read_hwcaps, pp_hwcaps, erase_mask;
2866-
struct spi_nor_erase_map *map = &nor->erase_map;
2867-
int i, err;
2868-
2869-
if (param_header->major != SFDP_JESD216_MAJOR ||
2870-
param_header->length < ARRAY_SIZE(dwords))
2871-
return -EINVAL;
2872-
2873-
/* Read the 4-byte Address Instruction Table. */
2874-
addr = SFDP_PARAM_HEADER_PTP(param_header);
2875-
err = spi_nor_read_sfdp(nor, addr, sizeof(dwords), dwords);
2876-
if (err)
2877-
return err;
2878-
2879-
/* Fix endianness of the 4BAIT DWORDs. */
2880-
for (i = 0; i < ARRAY_SIZE(dwords); i++)
2881-
dwords[i] = le32_to_cpu(dwords[i]);
2882-
2883-
/*
2884-
* Compute the subset of (Fast) Read commands for which the 4-byte
2885-
* version is supported.
2886-
*/
2887-
discard_hwcaps = 0;
2888-
read_hwcaps = 0;
2889-
for (i = 0; i < ARRAY_SIZE(reads); i++) {
2890-
const struct sfdp_4bait *read = &reads[i];
2891-
2892-
discard_hwcaps |= read->hwcaps;
2893-
if ((params->hwcaps.mask & read->hwcaps) &&
2894-
(dwords[0] & read->supported_bit))
2895-
read_hwcaps |= read->hwcaps;
2896-
}
2897-
2898-
/*
2899-
* Compute the subset of Page Program commands for which the 4-byte
2900-
* version is supported.
2901-
*/
2902-
pp_hwcaps = 0;
2903-
for (i = 0; i < ARRAY_SIZE(programs); i++) {
2904-
const struct sfdp_4bait *program = &programs[i];
2905-
2906-
discard_hwcaps |= program->hwcaps;
2907-
if ((params->hwcaps.mask & program->hwcaps) &&
2908-
(dwords[0] & program->supported_bit))
2909-
pp_hwcaps |= program->hwcaps;
2910-
}
2911-
2912-
/*
2913-
* Compute the subet of Sector Erase commands for which the 4-byte
2914-
* version is supported.
2915-
*/
2916-
erase_mask = 0;
2917-
for (i = 0; i < SNOR_ERASE_TYPE_MAX; i++) {
2918-
const struct sfdp_4bait *erase = &erases[i];
2919-
2920-
if (map->erase_type[i].size > 0 &&
2921-
(dwords[0] & erase->supported_bit))
2922-
erase_mask |= BIT(i);
2923-
}
2924-
2925-
/*
2926-
* We need at least one 4-byte op code per read, program and erase
2927-
* operation; the .read(), .write() and .erase() hooks share the
2928-
* nor->addr_width value.
2929-
*/
2930-
if (!read_hwcaps || !pp_hwcaps || !erase_mask)
2931-
return 0;
2932-
2933-
/*
2934-
* Discard all operations from the 4-byte instruction set which are
2935-
* not supported by this memory.
2936-
*/
2937-
params->hwcaps.mask &= ~discard_hwcaps;
2938-
params->hwcaps.mask |= (read_hwcaps | pp_hwcaps);
2939-
2940-
/* Use the 4-byte address instruction set. */
2941-
for (i = 0; i < SNOR_CMD_READ_MAX; i++) {
2942-
struct spi_nor_read_command *read_cmd = &params->reads[i];
2943-
2944-
read_cmd->opcode = spi_nor_convert_3to4_read(read_cmd->opcode);
2945-
}
2946-
for (i = 0; i < SNOR_CMD_PP_MAX; i++) {
2947-
struct spi_nor_pp_command *pp_cmd = &params->page_programs[i];
2948-
2949-
pp_cmd->opcode = spi_nor_convert_3to4_program(pp_cmd->opcode);
2950-
}
2951-
for (i = 0; i < SNOR_ERASE_TYPE_MAX; i++) {
2952-
struct spi_nor_erase_type *erase = &map->erase_type[i];
2953-
2954-
if (erase_mask & BIT(erase->idx))
2955-
erase->opcode = (dwords[1] >> (erase->idx * 8)) & 0xFF;
2956-
else
2957-
spi_nor_set_erase_type(erase, 0u, 0xFF);
2958-
}
2959-
2960-
/*
2961-
* We set nor->addr_width here to skip spi_nor_set_4byte_opcodes()
2962-
* later because this latest function implements a legacy quirk for
2963-
* the erase size of Spansion memory. However this quirk is no longer
2964-
* needed with new SFDP compliant memories.
2965-
*/
2966-
nor->addr_width = 4;
2967-
nor->flags |= SPI_NOR_4B_OPCODES;
2968-
return 0;
2969-
}
2970-
29712827
/**
29722828
* spi_nor_parse_sfdp() - parse the Serial Flash Discoverable Parameters.
29732829
* @nor: pointer to a 'struct spi_nor'
@@ -3066,10 +2922,6 @@ static int spi_nor_parse_sfdp(struct spi_nor *nor,
30662922
err = spi_nor_parse_smpt(nor, param_header);
30672923
break;
30682924

3069-
case SFDP_4BAIT_ID:
3070-
err = spi_nor_parse_4bait(nor, param_header, params);
3071-
break;
3072-
30732925
default:
30742926
break;
30752927
}

0 commit comments

Comments
 (0)