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_ciis25lp256_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	 * IS25LP256 supports 4B opcodes, but the BFPT advertises a
198c2ecf20Sopenharmony_ci	 * BFPT_DWORD1_ADDRESS_BYTES_3_ONLY address width.
208c2ecf20Sopenharmony_ci	 * Overwrite the address width advertised by the BFPT.
218c2ecf20Sopenharmony_ci	 */
228c2ecf20Sopenharmony_ci	if ((bfpt->dwords[BFPT_DWORD(1)] & BFPT_DWORD1_ADDRESS_BYTES_MASK) ==
238c2ecf20Sopenharmony_ci		BFPT_DWORD1_ADDRESS_BYTES_3_ONLY)
248c2ecf20Sopenharmony_ci		nor->addr_width = 4;
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci	return 0;
278c2ecf20Sopenharmony_ci}
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_cistatic struct spi_nor_fixups is25lp256_fixups = {
308c2ecf20Sopenharmony_ci	.post_bfpt = is25lp256_post_bfpt_fixups,
318c2ecf20Sopenharmony_ci};
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_cistatic const struct flash_info issi_parts[] = {
348c2ecf20Sopenharmony_ci	/* ISSI */
358c2ecf20Sopenharmony_ci	{ "is25cd512",  INFO(0x7f9d20, 0, 32 * 1024,   2, SECT_4K) },
368c2ecf20Sopenharmony_ci	{ "is25lq040b", INFO(0x9d4013, 0, 64 * 1024,   8,
378c2ecf20Sopenharmony_ci			     SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
388c2ecf20Sopenharmony_ci	{ "is25lp016d", INFO(0x9d6015, 0, 64 * 1024,  32,
398c2ecf20Sopenharmony_ci			     SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
408c2ecf20Sopenharmony_ci	{ "is25lp080d", INFO(0x9d6014, 0, 64 * 1024,  16,
418c2ecf20Sopenharmony_ci			     SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
428c2ecf20Sopenharmony_ci	{ "is25lp032",  INFO(0x9d6016, 0, 64 * 1024,  64,
438c2ecf20Sopenharmony_ci			     SECT_4K | SPI_NOR_DUAL_READ) },
448c2ecf20Sopenharmony_ci	{ "is25lp064",  INFO(0x9d6017, 0, 64 * 1024, 128,
458c2ecf20Sopenharmony_ci			     SECT_4K | SPI_NOR_DUAL_READ) },
468c2ecf20Sopenharmony_ci	{ "is25lp128",  INFO(0x9d6018, 0, 64 * 1024, 256,
478c2ecf20Sopenharmony_ci			     SECT_4K | SPI_NOR_DUAL_READ) },
488c2ecf20Sopenharmony_ci	{ "is25lp256",  INFO(0x9d6019, 0, 64 * 1024, 512,
498c2ecf20Sopenharmony_ci			     SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ |
508c2ecf20Sopenharmony_ci			     SPI_NOR_4B_OPCODES)
518c2ecf20Sopenharmony_ci		.fixups = &is25lp256_fixups },
528c2ecf20Sopenharmony_ci	{ "is25wp032",  INFO(0x9d7016, 0, 64 * 1024,  64,
538c2ecf20Sopenharmony_ci			     SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
548c2ecf20Sopenharmony_ci	{ "is25wp064",  INFO(0x9d7017, 0, 64 * 1024, 128,
558c2ecf20Sopenharmony_ci			     SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
568c2ecf20Sopenharmony_ci	{ "is25wp128",  INFO(0x9d7018, 0, 64 * 1024, 256,
578c2ecf20Sopenharmony_ci			     SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
588c2ecf20Sopenharmony_ci	{ "is25wp256", INFO(0x9d7019, 0, 64 * 1024, 512,
598c2ecf20Sopenharmony_ci			    SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ |
608c2ecf20Sopenharmony_ci			    SPI_NOR_4B_OPCODES)
618c2ecf20Sopenharmony_ci		.fixups = &is25lp256_fixups },
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci	/* PMC */
648c2ecf20Sopenharmony_ci	{ "pm25lv512",   INFO(0,        0, 32 * 1024,    2, SECT_4K_PMC) },
658c2ecf20Sopenharmony_ci	{ "pm25lv010",   INFO(0,        0, 32 * 1024,    4, SECT_4K_PMC) },
668c2ecf20Sopenharmony_ci	{ "pm25lq032",   INFO(0x7f9d46, 0, 64 * 1024,   64, SECT_4K) },
678c2ecf20Sopenharmony_ci};
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_cistatic void issi_default_init(struct spi_nor *nor)
708c2ecf20Sopenharmony_ci{
718c2ecf20Sopenharmony_ci	nor->params->quad_enable = spi_nor_sr1_bit6_quad_enable;
728c2ecf20Sopenharmony_ci}
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_cistatic const struct spi_nor_fixups issi_fixups = {
758c2ecf20Sopenharmony_ci	.default_init = issi_default_init,
768c2ecf20Sopenharmony_ci};
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ciconst struct spi_nor_manufacturer spi_nor_issi = {
798c2ecf20Sopenharmony_ci	.name = "issi",
808c2ecf20Sopenharmony_ci	.parts = issi_parts,
818c2ecf20Sopenharmony_ci	.nparts = ARRAY_SIZE(issi_parts),
828c2ecf20Sopenharmony_ci	.fixups = &issi_fixups,
838c2ecf20Sopenharmony_ci};
84