linux/drivers/mtd/nand/raw/nand_micron.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Copyright (C) 2017 Free Electrons
 * Copyright (C) 2017 NextThing Co
 *
 * Author: Boris Brezillon <[email protected]>
 */

#include <linux/slab.h>

#include "internals.h"

/*
 * Special Micron status bit 3 indicates that the block has been
 * corrected by on-die ECC and should be rewritten.
 */
#define NAND_ECC_STATUS_WRITE_RECOMMENDED

/*
 * On chips with 8-bit ECC and additional bit can be used to distinguish
 * cases where a errors were corrected without needing a rewrite
 *
 * Bit 4 Bit 3 Bit 0 Description
 * ----- ----- ----- -----------
 * 0     0     0     No Errors
 * 0     0     1     Multiple uncorrected errors
 * 0     1     0     4 - 6 errors corrected, recommend rewrite
 * 0     1     1     Reserved
 * 1     0     0     1 - 3 errors corrected
 * 1     0     1     Reserved
 * 1     1     0     7 - 8 errors corrected, recommend rewrite
 */
#define NAND_ECC_STATUS_MASK
#define NAND_ECC_STATUS_UNCORRECTABLE
#define NAND_ECC_STATUS_4_6_CORRECTED
#define NAND_ECC_STATUS_1_3_CORRECTED
#define NAND_ECC_STATUS_7_8_CORRECTED

struct nand_onfi_vendor_micron {} __packed;

struct micron_on_die_ecc {};

struct micron_nand {};

static int micron_nand_setup_read_retry(struct nand_chip *chip, int retry_mode)
{}

/*
 * Configure chip properties from Micron vendor-specific ONFI table
 */
static int micron_nand_onfi_init(struct nand_chip *chip)
{}

static int micron_nand_on_die_4_ooblayout_ecc(struct mtd_info *mtd,
					      int section,
					      struct mtd_oob_region *oobregion)
{}

static int micron_nand_on_die_4_ooblayout_free(struct mtd_info *mtd,
					       int section,
					       struct mtd_oob_region *oobregion)
{}

static const struct mtd_ooblayout_ops micron_nand_on_die_4_ooblayout_ops =;

static int micron_nand_on_die_8_ooblayout_ecc(struct mtd_info *mtd,
					      int section,
					      struct mtd_oob_region *oobregion)
{}

static int micron_nand_on_die_8_ooblayout_free(struct mtd_info *mtd,
					       int section,
					       struct mtd_oob_region *oobregion)
{}

static const struct mtd_ooblayout_ops micron_nand_on_die_8_ooblayout_ops =;

static int micron_nand_on_die_ecc_setup(struct nand_chip *chip, bool enable)
{}

static int micron_nand_on_die_ecc_status_4(struct nand_chip *chip, u8 status,
					   void *buf, int page,
					   int oob_required)
{}

static int micron_nand_on_die_ecc_status_8(struct nand_chip *chip, u8 status)
{}

static int
micron_nand_read_page_on_die_ecc(struct nand_chip *chip, uint8_t *buf,
				 int oob_required, int page)
{}

static int
micron_nand_write_page_on_die_ecc(struct nand_chip *chip, const uint8_t *buf,
				  int oob_required, int page)
{}

enum {};

#define MICRON_ID_INTERNAL_ECC_MASK
#define MICRON_ID_ECC_ENABLED

/*
 * Try to detect if the NAND support on-die ECC. To do this, we enable
 * the feature, and read back if it has been enabled as expected. We
 * also check if it can be disabled, because some Micron NANDs do not
 * allow disabling the on-die ECC and we don't support such NANDs for
 * now.
 *
 * This function also has the side effect of disabling on-die ECC if
 * it had been left enabled by the firmware/bootloader.
 */
static int micron_supports_on_die_ecc(struct nand_chip *chip)
{}

static int micron_nand_init(struct nand_chip *chip)
{}

static void micron_nand_cleanup(struct nand_chip *chip)
{}

static void micron_fixup_onfi_param_page(struct nand_chip *chip,
					 struct nand_onfi_params *p)
{}

const struct nand_manufacturer_ops micron_nand_manuf_ops =;