2019-06-04 16:11:33 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
2010-08-09 03:58:20 +08:00
|
|
|
* Copyright (C) 2000-2010 Steven J. Hill <sjhill@realitydiluted.com>
|
|
|
|
* David Woodhouse <dwmw2@infradead.org>
|
|
|
|
* Thomas Gleixner <tglx@linutronix.de>
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
2020-09-30 07:01:16 +08:00
|
|
|
* This file is the header for the NAND Hamming ECC implementation.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
|
2020-09-30 07:01:15 +08:00
|
|
|
#ifndef __MTD_NAND_ECC_SW_HAMMING_H__
|
|
|
|
#define __MTD_NAND_ECC_SW_HAMMING_H__
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2020-09-30 07:01:19 +08:00
|
|
|
#include <linux/mtd/nand.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2020-09-30 07:01:20 +08:00
|
|
|
/**
|
|
|
|
* struct nand_ecc_sw_hamming_conf - private software Hamming ECC engine structure
|
2020-09-30 07:01:23 +08:00
|
|
|
* @req_ctx: Save request context and tweak the original request to fit the
|
|
|
|
* engine needs
|
2020-09-30 07:01:20 +08:00
|
|
|
* @code_size: Number of bytes needed to store a code (one code per step)
|
|
|
|
* @calc_buf: Buffer to use when calculating ECC bytes
|
|
|
|
* @code_buf: Buffer to use when reading (raw) ECC bytes from the chip
|
|
|
|
* @sm_order: Smart Media special ordering
|
|
|
|
*/
|
|
|
|
struct nand_ecc_sw_hamming_conf {
|
2020-09-30 07:01:23 +08:00
|
|
|
struct nand_ecc_req_tweak_ctx req_ctx;
|
2020-09-30 07:01:20 +08:00
|
|
|
unsigned int code_size;
|
|
|
|
u8 *calc_buf;
|
|
|
|
u8 *code_buf;
|
|
|
|
unsigned int sm_order;
|
|
|
|
};
|
|
|
|
|
2020-09-30 07:01:22 +08:00
|
|
|
#if IS_ENABLED(CONFIG_MTD_NAND_ECC_SW_HAMMING)
|
|
|
|
|
2020-09-30 07:01:23 +08:00
|
|
|
int nand_ecc_sw_hamming_init_ctx(struct nand_device *nand);
|
|
|
|
void nand_ecc_sw_hamming_cleanup_ctx(struct nand_device *nand);
|
2020-09-30 07:01:19 +08:00
|
|
|
int ecc_sw_hamming_calculate(const unsigned char *buf, unsigned int step_size,
|
|
|
|
unsigned char *code, bool sm_order);
|
|
|
|
int nand_ecc_sw_hamming_calculate(struct nand_device *nand,
|
|
|
|
const unsigned char *buf,
|
|
|
|
unsigned char *code);
|
|
|
|
int ecc_sw_hamming_correct(unsigned char *buf, unsigned char *read_ecc,
|
|
|
|
unsigned char *calc_ecc, unsigned int step_size,
|
|
|
|
bool sm_order);
|
|
|
|
int nand_ecc_sw_hamming_correct(struct nand_device *nand, unsigned char *buf,
|
|
|
|
unsigned char *read_ecc,
|
|
|
|
unsigned char *calc_ecc);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2020-09-30 07:01:22 +08:00
|
|
|
#else /* !CONFIG_MTD_NAND_ECC_SW_HAMMING */
|
|
|
|
|
2020-09-30 07:01:23 +08:00
|
|
|
static inline int nand_ecc_sw_hamming_init_ctx(struct nand_device *nand)
|
|
|
|
{
|
|
|
|
return -ENOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void nand_ecc_sw_hamming_cleanup_ctx(struct nand_device *nand) {}
|
|
|
|
|
2020-09-30 07:01:22 +08:00
|
|
|
static inline int ecc_sw_hamming_calculate(const unsigned char *buf,
|
|
|
|
unsigned int step_size,
|
|
|
|
unsigned char *code, bool sm_order)
|
|
|
|
{
|
|
|
|
return -ENOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int nand_ecc_sw_hamming_calculate(struct nand_device *nand,
|
|
|
|
const unsigned char *buf,
|
|
|
|
unsigned char *code)
|
|
|
|
{
|
|
|
|
return -ENOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int ecc_sw_hamming_correct(unsigned char *buf,
|
|
|
|
unsigned char *read_ecc,
|
|
|
|
unsigned char *calc_ecc,
|
|
|
|
unsigned int step_size, bool sm_order)
|
|
|
|
{
|
|
|
|
return -ENOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int nand_ecc_sw_hamming_correct(struct nand_device *nand,
|
|
|
|
unsigned char *buf,
|
|
|
|
unsigned char *read_ecc,
|
|
|
|
unsigned char *calc_ecc)
|
|
|
|
{
|
|
|
|
return -ENOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_MTD_NAND_ECC_SW_HAMMING */
|
|
|
|
|
2020-09-30 07:01:15 +08:00
|
|
|
#endif /* __MTD_NAND_ECC_SW_HAMMING_H__ */
|