18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2005, Intec Automation Inc. 48c2ecf20Sopenharmony_ci * Copyright (C) 2014, Freescale Semiconductor, Inc. 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#include <linux/mtd/spi-nor.h> 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include "core.h" 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_cistatic int 128c2ecf20Sopenharmony_cimx25l25635_post_bfpt_fixups(struct spi_nor *nor, 138c2ecf20Sopenharmony_ci const struct sfdp_parameter_header *bfpt_header, 148c2ecf20Sopenharmony_ci const struct sfdp_bfpt *bfpt, 158c2ecf20Sopenharmony_ci struct spi_nor_flash_parameter *params) 168c2ecf20Sopenharmony_ci{ 178c2ecf20Sopenharmony_ci /* 188c2ecf20Sopenharmony_ci * MX25L25635F supports 4B opcodes but MX25L25635E does not. 198c2ecf20Sopenharmony_ci * Unfortunately, Macronix has re-used the same JEDEC ID for both 208c2ecf20Sopenharmony_ci * variants which prevents us from defining a new entry in the parts 218c2ecf20Sopenharmony_ci * table. 228c2ecf20Sopenharmony_ci * We need a way to differentiate MX25L25635E and MX25L25635F, and it 238c2ecf20Sopenharmony_ci * seems that the F version advertises support for Fast Read 4-4-4 in 248c2ecf20Sopenharmony_ci * its BFPT table. 258c2ecf20Sopenharmony_ci */ 268c2ecf20Sopenharmony_ci if (bfpt->dwords[BFPT_DWORD(5)] & BFPT_DWORD5_FAST_READ_4_4_4) 278c2ecf20Sopenharmony_ci nor->flags |= SNOR_F_4B_OPCODES; 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci return 0; 308c2ecf20Sopenharmony_ci} 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_cistatic struct spi_nor_fixups mx25l25635_fixups = { 338c2ecf20Sopenharmony_ci .post_bfpt = mx25l25635_post_bfpt_fixups, 348c2ecf20Sopenharmony_ci}; 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_cistatic const struct flash_info macronix_parts[] = { 378c2ecf20Sopenharmony_ci /* Macronix */ 388c2ecf20Sopenharmony_ci { "mx25l512e", INFO(0xc22010, 0, 64 * 1024, 1, SECT_4K) }, 398c2ecf20Sopenharmony_ci { "mx25l2005a", INFO(0xc22012, 0, 64 * 1024, 4, SECT_4K) }, 408c2ecf20Sopenharmony_ci { "mx25l4005a", INFO(0xc22013, 0, 64 * 1024, 8, SECT_4K) }, 418c2ecf20Sopenharmony_ci { "mx25l8005", INFO(0xc22014, 0, 64 * 1024, 16, 0) }, 428c2ecf20Sopenharmony_ci { "mx25l1606e", INFO(0xc22015, 0, 64 * 1024, 32, SECT_4K) }, 438c2ecf20Sopenharmony_ci { "mx25l3205d", INFO(0xc22016, 0, 64 * 1024, 64, SECT_4K) }, 448c2ecf20Sopenharmony_ci { "mx25l3255e", INFO(0xc29e16, 0, 64 * 1024, 64, SECT_4K) }, 458c2ecf20Sopenharmony_ci { "mx25l6405d", INFO(0xc22017, 0, 64 * 1024, 128, SECT_4K) }, 468c2ecf20Sopenharmony_ci { "mx25u2033e", INFO(0xc22532, 0, 64 * 1024, 4, SECT_4K) }, 478c2ecf20Sopenharmony_ci { "mx25u3235f", INFO(0xc22536, 0, 64 * 1024, 64, 488c2ecf20Sopenharmony_ci SECT_4K | SPI_NOR_DUAL_READ | 498c2ecf20Sopenharmony_ci SPI_NOR_QUAD_READ) }, 508c2ecf20Sopenharmony_ci { "mx25u4035", INFO(0xc22533, 0, 64 * 1024, 8, SECT_4K) }, 518c2ecf20Sopenharmony_ci { "mx25u8035", INFO(0xc22534, 0, 64 * 1024, 16, SECT_4K) }, 528c2ecf20Sopenharmony_ci { "mx25u6435f", INFO(0xc22537, 0, 64 * 1024, 128, SECT_4K) }, 538c2ecf20Sopenharmony_ci { "mx25l12805d", INFO(0xc22018, 0, 64 * 1024, 256, SECT_4K) }, 548c2ecf20Sopenharmony_ci { "mx25l12855e", INFO(0xc22618, 0, 64 * 1024, 256, 0) }, 558c2ecf20Sopenharmony_ci { "mx25r1635f", INFO(0xc22815, 0, 64 * 1024, 32, 568c2ecf20Sopenharmony_ci SECT_4K | SPI_NOR_DUAL_READ | 578c2ecf20Sopenharmony_ci SPI_NOR_QUAD_READ) }, 588c2ecf20Sopenharmony_ci { "mx25r3235f", INFO(0xc22816, 0, 64 * 1024, 64, 598c2ecf20Sopenharmony_ci SECT_4K | SPI_NOR_DUAL_READ | 608c2ecf20Sopenharmony_ci SPI_NOR_QUAD_READ) }, 618c2ecf20Sopenharmony_ci { "mx25u12835f", INFO(0xc22538, 0, 64 * 1024, 256, 628c2ecf20Sopenharmony_ci SECT_4K | SPI_NOR_DUAL_READ | 638c2ecf20Sopenharmony_ci SPI_NOR_QUAD_READ) }, 648c2ecf20Sopenharmony_ci { "mx25l25635e", INFO(0xc22019, 0, 64 * 1024, 512, 658c2ecf20Sopenharmony_ci SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) 668c2ecf20Sopenharmony_ci .fixups = &mx25l25635_fixups }, 678c2ecf20Sopenharmony_ci { "mx25u25635f", INFO(0xc22539, 0, 64 * 1024, 512, 688c2ecf20Sopenharmony_ci SECT_4K | SPI_NOR_4B_OPCODES) }, 698c2ecf20Sopenharmony_ci { "mx25u51245g", INFO(0xc2253a, 0, 64 * 1024, 1024, 708c2ecf20Sopenharmony_ci SECT_4K | SPI_NOR_DUAL_READ | 718c2ecf20Sopenharmony_ci SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) }, 728c2ecf20Sopenharmony_ci { "mx25v8035f", INFO(0xc22314, 0, 64 * 1024, 16, 738c2ecf20Sopenharmony_ci SECT_4K | SPI_NOR_DUAL_READ | 748c2ecf20Sopenharmony_ci SPI_NOR_QUAD_READ) }, 758c2ecf20Sopenharmony_ci { "mx25l25655e", INFO(0xc22619, 0, 64 * 1024, 512, 0) }, 768c2ecf20Sopenharmony_ci { "mx66l51235l", INFO(0xc2201a, 0, 64 * 1024, 1024, 778c2ecf20Sopenharmony_ci SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | 788c2ecf20Sopenharmony_ci SPI_NOR_4B_OPCODES) }, 798c2ecf20Sopenharmony_ci { "mx66u51235f", INFO(0xc2253a, 0, 64 * 1024, 1024, 808c2ecf20Sopenharmony_ci SECT_4K | SPI_NOR_DUAL_READ | 818c2ecf20Sopenharmony_ci SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) }, 828c2ecf20Sopenharmony_ci { "mx66l1g45g", INFO(0xc2201b, 0, 64 * 1024, 2048, 838c2ecf20Sopenharmony_ci SECT_4K | SPI_NOR_DUAL_READ | 848c2ecf20Sopenharmony_ci SPI_NOR_QUAD_READ) }, 858c2ecf20Sopenharmony_ci { "mx66l1g55g", INFO(0xc2261b, 0, 64 * 1024, 2048, 868c2ecf20Sopenharmony_ci SPI_NOR_QUAD_READ) }, 878c2ecf20Sopenharmony_ci { "mx66u2g45g", INFO(0xc2253c, 0, 64 * 1024, 4096, 888c2ecf20Sopenharmony_ci SECT_4K | SPI_NOR_DUAL_READ | 898c2ecf20Sopenharmony_ci SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) }, 908c2ecf20Sopenharmony_ci}; 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_cistatic void macronix_default_init(struct spi_nor *nor) 938c2ecf20Sopenharmony_ci{ 948c2ecf20Sopenharmony_ci nor->params->quad_enable = spi_nor_sr1_bit6_quad_enable; 958c2ecf20Sopenharmony_ci nor->params->set_4byte_addr_mode = spi_nor_set_4byte_addr_mode; 968c2ecf20Sopenharmony_ci} 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_cistatic const struct spi_nor_fixups macronix_fixups = { 998c2ecf20Sopenharmony_ci .default_init = macronix_default_init, 1008c2ecf20Sopenharmony_ci}; 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ciconst struct spi_nor_manufacturer spi_nor_macronix = { 1038c2ecf20Sopenharmony_ci .name = "macronix", 1048c2ecf20Sopenharmony_ci .parts = macronix_parts, 1058c2ecf20Sopenharmony_ci .nparts = ARRAY_SIZE(macronix_parts), 1068c2ecf20Sopenharmony_ci .fixups = ¯onix_fixups, 1078c2ecf20Sopenharmony_ci}; 108