// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com) * 2002-2006 Thomas Gleixner (tglx@linutronix.de) * * Credits: * David Woodhouse for adding multichip support * * Aleph One Ltd. and Toby Churchill Ltd. for supporting the * rework for 2K page size chips * * This file contains all ONFI helpers.
*/
#include <linux/slab.h>
#include"internals.h"
#define JEDEC_PARAM_PAGES 3
/* * Check if the NAND chip is JEDEC compliant, returns 1 if it is, 0 otherwise.
*/ int nand_jedec_detect(struct nand_chip *chip)
{ struct nand_device *base = &chip->base; struct mtd_info *mtd = nand_to_mtd(chip); struct nand_memory_organization *memorg; struct nand_jedec_params *p; struct jedec_ecc_info *ecc; bool use_datain = false; int jedec_version = 0; char id[5]; int i, val, ret;
u16 crc;
memorg = nanddev_get_memorg(&chip->base);
/* Try JEDEC for unknown chip or LP */
ret = nand_readid_op(chip, 0x40, id, sizeof(id)); if (ret || strncmp(id, "JEDEC", sizeof(id))) return 0;
/* JEDEC chip: allocate a buffer to hold its parameter page */
p = kzalloc(sizeof(*p), GFP_KERNEL); if (!p) return -ENOMEM;
if (!nand_has_exec_op(chip) || chip->controller->supported_op.data_only_read)
use_datain = true;
for (i = 0; i < JEDEC_PARAM_PAGES; i++) { if (!i)
ret = nand_read_param_page_op(chip, 0x40, p, sizeof(*p)); elseif (use_datain)
ret = nand_read_data_op(chip, p, sizeof(*p), true, false); else
ret = nand_change_read_column_op(chip, sizeof(*p) * i,
p, sizeof(*p), true); if (ret) {
ret = 0; goto free_jedec_param_page;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.