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 const struct flash_info micron_parts[] = { 128c2ecf20Sopenharmony_ci { "mt35xu512aba", INFO(0x2c5b1a, 0, 128 * 1024, 512, 138c2ecf20Sopenharmony_ci SECT_4K | USE_FSR | SPI_NOR_OCTAL_READ | 148c2ecf20Sopenharmony_ci SPI_NOR_4B_OPCODES) }, 158c2ecf20Sopenharmony_ci { "mt35xu02g", INFO(0x2c5b1c, 0, 128 * 1024, 2048, 168c2ecf20Sopenharmony_ci SECT_4K | USE_FSR | SPI_NOR_OCTAL_READ | 178c2ecf20Sopenharmony_ci SPI_NOR_4B_OPCODES) }, 188c2ecf20Sopenharmony_ci}; 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_cistatic const struct flash_info st_parts[] = { 218c2ecf20Sopenharmony_ci { "n25q016a", INFO(0x20bb15, 0, 64 * 1024, 32, 228c2ecf20Sopenharmony_ci SECT_4K | SPI_NOR_QUAD_READ) }, 238c2ecf20Sopenharmony_ci { "n25q032", INFO(0x20ba16, 0, 64 * 1024, 64, 248c2ecf20Sopenharmony_ci SPI_NOR_QUAD_READ) }, 258c2ecf20Sopenharmony_ci { "n25q032a", INFO(0x20bb16, 0, 64 * 1024, 64, 268c2ecf20Sopenharmony_ci SPI_NOR_QUAD_READ) }, 278c2ecf20Sopenharmony_ci { "n25q064", INFO(0x20ba17, 0, 64 * 1024, 128, 288c2ecf20Sopenharmony_ci SECT_4K | SPI_NOR_QUAD_READ) }, 298c2ecf20Sopenharmony_ci { "n25q064a", INFO(0x20bb17, 0, 64 * 1024, 128, 308c2ecf20Sopenharmony_ci SECT_4K | SPI_NOR_QUAD_READ) }, 318c2ecf20Sopenharmony_ci { "n25q128a11", INFO(0x20bb18, 0, 64 * 1024, 256, 328c2ecf20Sopenharmony_ci SECT_4K | USE_FSR | SPI_NOR_QUAD_READ | 338c2ecf20Sopenharmony_ci SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB | 348c2ecf20Sopenharmony_ci SPI_NOR_4BIT_BP | SPI_NOR_BP3_SR_BIT6) }, 358c2ecf20Sopenharmony_ci { "n25q128a13", INFO(0x20ba18, 0, 64 * 1024, 256, 368c2ecf20Sopenharmony_ci SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) }, 378c2ecf20Sopenharmony_ci { "mt25ql256a", INFO6(0x20ba19, 0x104400, 64 * 1024, 512, 388c2ecf20Sopenharmony_ci SECT_4K | USE_FSR | SPI_NOR_DUAL_READ | 398c2ecf20Sopenharmony_ci SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) }, 408c2ecf20Sopenharmony_ci { "n25q256a", INFO(0x20ba19, 0, 64 * 1024, 512, SECT_4K | 418c2ecf20Sopenharmony_ci USE_FSR | SPI_NOR_DUAL_READ | 428c2ecf20Sopenharmony_ci SPI_NOR_QUAD_READ) }, 438c2ecf20Sopenharmony_ci { "mt25qu256a", INFO6(0x20bb19, 0x104400, 64 * 1024, 512, 448c2ecf20Sopenharmony_ci SECT_4K | USE_FSR | SPI_NOR_DUAL_READ | 458c2ecf20Sopenharmony_ci SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) }, 468c2ecf20Sopenharmony_ci { "n25q256ax1", INFO(0x20bb19, 0, 64 * 1024, 512, 478c2ecf20Sopenharmony_ci SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) }, 488c2ecf20Sopenharmony_ci { "mt25ql512a", INFO6(0x20ba20, 0x104400, 64 * 1024, 1024, 498c2ecf20Sopenharmony_ci SECT_4K | USE_FSR | SPI_NOR_DUAL_READ | 508c2ecf20Sopenharmony_ci SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) }, 518c2ecf20Sopenharmony_ci { "n25q512ax3", INFO(0x20ba20, 0, 64 * 1024, 1024, 528c2ecf20Sopenharmony_ci SECT_4K | USE_FSR | SPI_NOR_QUAD_READ | 538c2ecf20Sopenharmony_ci SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB | 548c2ecf20Sopenharmony_ci SPI_NOR_4BIT_BP | SPI_NOR_BP3_SR_BIT6) }, 558c2ecf20Sopenharmony_ci { "mt25qu512a", INFO6(0x20bb20, 0x104400, 64 * 1024, 1024, 568c2ecf20Sopenharmony_ci SECT_4K | USE_FSR | SPI_NOR_DUAL_READ | 578c2ecf20Sopenharmony_ci SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) }, 588c2ecf20Sopenharmony_ci { "n25q512a", INFO(0x20bb20, 0, 64 * 1024, 1024, 598c2ecf20Sopenharmony_ci SECT_4K | USE_FSR | SPI_NOR_QUAD_READ | 608c2ecf20Sopenharmony_ci SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB | 618c2ecf20Sopenharmony_ci SPI_NOR_4BIT_BP | SPI_NOR_BP3_SR_BIT6) }, 628c2ecf20Sopenharmony_ci { "n25q00", INFO(0x20ba21, 0, 64 * 1024, 2048, 638c2ecf20Sopenharmony_ci SECT_4K | USE_FSR | SPI_NOR_QUAD_READ | 648c2ecf20Sopenharmony_ci SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB | 658c2ecf20Sopenharmony_ci SPI_NOR_4BIT_BP | SPI_NOR_BP3_SR_BIT6 | 668c2ecf20Sopenharmony_ci NO_CHIP_ERASE) }, 678c2ecf20Sopenharmony_ci { "n25q00a", INFO(0x20bb21, 0, 64 * 1024, 2048, 688c2ecf20Sopenharmony_ci SECT_4K | USE_FSR | SPI_NOR_QUAD_READ | 698c2ecf20Sopenharmony_ci NO_CHIP_ERASE) }, 708c2ecf20Sopenharmony_ci { "mt25ql02g", INFO(0x20ba22, 0, 64 * 1024, 4096, 718c2ecf20Sopenharmony_ci SECT_4K | USE_FSR | SPI_NOR_QUAD_READ | 728c2ecf20Sopenharmony_ci NO_CHIP_ERASE) }, 738c2ecf20Sopenharmony_ci { "mt25qu02g", INFO(0x20bb22, 0, 64 * 1024, 4096, 748c2ecf20Sopenharmony_ci SECT_4K | USE_FSR | SPI_NOR_DUAL_READ | 758c2ecf20Sopenharmony_ci SPI_NOR_QUAD_READ | NO_CHIP_ERASE) }, 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci { "m25p05", INFO(0x202010, 0, 32 * 1024, 2, 0) }, 788c2ecf20Sopenharmony_ci { "m25p10", INFO(0x202011, 0, 32 * 1024, 4, 0) }, 798c2ecf20Sopenharmony_ci { "m25p20", INFO(0x202012, 0, 64 * 1024, 4, 0) }, 808c2ecf20Sopenharmony_ci { "m25p40", INFO(0x202013, 0, 64 * 1024, 8, 0) }, 818c2ecf20Sopenharmony_ci { "m25p80", INFO(0x202014, 0, 64 * 1024, 16, 0) }, 828c2ecf20Sopenharmony_ci { "m25p16", INFO(0x202015, 0, 64 * 1024, 32, 0) }, 838c2ecf20Sopenharmony_ci { "m25p32", INFO(0x202016, 0, 64 * 1024, 64, 0) }, 848c2ecf20Sopenharmony_ci { "m25p64", INFO(0x202017, 0, 64 * 1024, 128, 0) }, 858c2ecf20Sopenharmony_ci { "m25p128", INFO(0x202018, 0, 256 * 1024, 64, 0) }, 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci { "m25p05-nonjedec", INFO(0, 0, 32 * 1024, 2, 0) }, 888c2ecf20Sopenharmony_ci { "m25p10-nonjedec", INFO(0, 0, 32 * 1024, 4, 0) }, 898c2ecf20Sopenharmony_ci { "m25p20-nonjedec", INFO(0, 0, 64 * 1024, 4, 0) }, 908c2ecf20Sopenharmony_ci { "m25p40-nonjedec", INFO(0, 0, 64 * 1024, 8, 0) }, 918c2ecf20Sopenharmony_ci { "m25p80-nonjedec", INFO(0, 0, 64 * 1024, 16, 0) }, 928c2ecf20Sopenharmony_ci { "m25p16-nonjedec", INFO(0, 0, 64 * 1024, 32, 0) }, 938c2ecf20Sopenharmony_ci { "m25p32-nonjedec", INFO(0, 0, 64 * 1024, 64, 0) }, 948c2ecf20Sopenharmony_ci { "m25p64-nonjedec", INFO(0, 0, 64 * 1024, 128, 0) }, 958c2ecf20Sopenharmony_ci { "m25p128-nonjedec", INFO(0, 0, 256 * 1024, 64, 0) }, 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci { "m45pe10", INFO(0x204011, 0, 64 * 1024, 2, 0) }, 988c2ecf20Sopenharmony_ci { "m45pe80", INFO(0x204014, 0, 64 * 1024, 16, 0) }, 998c2ecf20Sopenharmony_ci { "m45pe16", INFO(0x204015, 0, 64 * 1024, 32, 0) }, 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci { "m25pe20", INFO(0x208012, 0, 64 * 1024, 4, 0) }, 1028c2ecf20Sopenharmony_ci { "m25pe80", INFO(0x208014, 0, 64 * 1024, 16, 0) }, 1038c2ecf20Sopenharmony_ci { "m25pe16", INFO(0x208015, 0, 64 * 1024, 32, SECT_4K) }, 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci { "m25px16", INFO(0x207115, 0, 64 * 1024, 32, SECT_4K) }, 1068c2ecf20Sopenharmony_ci { "m25px32", INFO(0x207116, 0, 64 * 1024, 64, SECT_4K) }, 1078c2ecf20Sopenharmony_ci { "m25px32-s0", INFO(0x207316, 0, 64 * 1024, 64, SECT_4K) }, 1088c2ecf20Sopenharmony_ci { "m25px32-s1", INFO(0x206316, 0, 64 * 1024, 64, SECT_4K) }, 1098c2ecf20Sopenharmony_ci { "m25px64", INFO(0x207117, 0, 64 * 1024, 128, 0) }, 1108c2ecf20Sopenharmony_ci { "m25px80", INFO(0x207114, 0, 64 * 1024, 16, 0) }, 1118c2ecf20Sopenharmony_ci}; 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci/** 1148c2ecf20Sopenharmony_ci * st_micron_set_4byte_addr_mode() - Set 4-byte address mode for ST and Micron 1158c2ecf20Sopenharmony_ci * flashes. 1168c2ecf20Sopenharmony_ci * @nor: pointer to 'struct spi_nor'. 1178c2ecf20Sopenharmony_ci * @enable: true to enter the 4-byte address mode, false to exit the 4-byte 1188c2ecf20Sopenharmony_ci * address mode. 1198c2ecf20Sopenharmony_ci * 1208c2ecf20Sopenharmony_ci * Return: 0 on success, -errno otherwise. 1218c2ecf20Sopenharmony_ci */ 1228c2ecf20Sopenharmony_cistatic int st_micron_set_4byte_addr_mode(struct spi_nor *nor, bool enable) 1238c2ecf20Sopenharmony_ci{ 1248c2ecf20Sopenharmony_ci int ret; 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci ret = spi_nor_write_enable(nor); 1278c2ecf20Sopenharmony_ci if (ret) 1288c2ecf20Sopenharmony_ci return ret; 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ci ret = spi_nor_set_4byte_addr_mode(nor, enable); 1318c2ecf20Sopenharmony_ci if (ret) 1328c2ecf20Sopenharmony_ci return ret; 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci return spi_nor_write_disable(nor); 1358c2ecf20Sopenharmony_ci} 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_cistatic void micron_st_default_init(struct spi_nor *nor) 1388c2ecf20Sopenharmony_ci{ 1398c2ecf20Sopenharmony_ci nor->flags |= SNOR_F_HAS_LOCK; 1408c2ecf20Sopenharmony_ci nor->flags &= ~SNOR_F_HAS_16BIT_SR; 1418c2ecf20Sopenharmony_ci nor->params->quad_enable = NULL; 1428c2ecf20Sopenharmony_ci nor->params->set_4byte_addr_mode = st_micron_set_4byte_addr_mode; 1438c2ecf20Sopenharmony_ci} 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_cistatic const struct spi_nor_fixups micron_st_fixups = { 1468c2ecf20Sopenharmony_ci .default_init = micron_st_default_init, 1478c2ecf20Sopenharmony_ci}; 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ciconst struct spi_nor_manufacturer spi_nor_micron = { 1508c2ecf20Sopenharmony_ci .name = "micron", 1518c2ecf20Sopenharmony_ci .parts = micron_parts, 1528c2ecf20Sopenharmony_ci .nparts = ARRAY_SIZE(micron_parts), 1538c2ecf20Sopenharmony_ci .fixups = µn_st_fixups, 1548c2ecf20Sopenharmony_ci}; 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_ciconst struct spi_nor_manufacturer spi_nor_st = { 1578c2ecf20Sopenharmony_ci .name = "st", 1588c2ecf20Sopenharmony_ci .parts = st_parts, 1598c2ecf20Sopenharmony_ci .nparts = ARRAY_SIZE(st_parts), 1608c2ecf20Sopenharmony_ci .fixups = µn_st_fixups, 1618c2ecf20Sopenharmony_ci}; 162