blob: bf4718088a3ab82fe0108d510cc6fc30197e3548 [file] [log] [blame]
Alex Smithae02ab02016-01-04 12:34:43 +00001/*
2 * JZ4780 BCH controller
3 *
4 * Copyright (c) 2015 Imagination Technologies
5 * Author: Alex Smith <alex.smith@imgtec.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published
9 * by the Free Software Foundation.
10 */
11
12#ifndef __DRIVERS_MTD_NAND_JZ4780_BCH_H__
13#define __DRIVERS_MTD_NAND_JZ4780_BCH_H__
14
15#include <linux/types.h>
16
17struct device;
18struct device_node;
19struct jz4780_bch;
20
21/**
22 * struct jz4780_bch_params - BCH parameters
23 * @size: data bytes per ECC step.
24 * @bytes: ECC bytes per step.
25 * @strength: number of correctable bits per ECC step.
26 */
27struct jz4780_bch_params {
28 int size;
29 int bytes;
30 int strength;
31};
32
33int jz4780_bch_calculate(struct jz4780_bch *bch,
34 struct jz4780_bch_params *params,
35 const u8 *buf, u8 *ecc_code);
36int jz4780_bch_correct(struct jz4780_bch *bch,
37 struct jz4780_bch_params *params, u8 *buf,
38 u8 *ecc_code);
39
40void jz4780_bch_release(struct jz4780_bch *bch);
41struct jz4780_bch *of_jz4780_bch_get(struct device_node *np);
42
43#endif /* __DRIVERS_MTD_NAND_JZ4780_BCH_H__ */