summaryrefslogtreecommitdiff
path: root/drivers/mtd/nand/raw/ingenic/jz4780_bch.h
blob: 451e0c770160abeef87a19eedd0b6596410b908b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * JZ4780 BCH controller
 *
 * Copyright (c) 2015 Imagination Technologies
 * Author: Alex Smith <alex.smith@imgtec.com>
 */

#ifndef __DRIVERS_MTD_NAND_JZ4780_BCH_H__
#define __DRIVERS_MTD_NAND_JZ4780_BCH_H__

#include <linux/types.h>

struct device;
struct device_node;
struct jz4780_bch;

/**
 * struct jz4780_bch_params - BCH parameters
 * @size: data bytes per ECC step.
 * @bytes: ECC bytes per step.
 * @strength: number of correctable bits per ECC step.
 */
struct jz4780_bch_params {
	int size;
	int bytes;
	int strength;
};

int jz4780_bch_calculate(struct jz4780_bch *bch,
				struct jz4780_bch_params *params,
				const u8 *buf, u8 *ecc_code);
int jz4780_bch_correct(struct jz4780_bch *bch,
			      struct jz4780_bch_params *params, u8 *buf,
			      u8 *ecc_code);

void jz4780_bch_release(struct jz4780_bch *bch);
struct jz4780_bch *of_jz4780_bch_get(struct device_node *np);

#endif /* __DRIVERS_MTD_NAND_JZ4780_BCH_H__ */