2 * Broadcom NAND flash controller interface
4 * Copyright (C) 2012, Broadcom Corporation. All Rights Reserved.
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
13 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
15 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
16 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 #ifndef _BRCMNAND_PRIV_H_
23 #define _BRCMNAND_PRIV_H_
25 #include <linux/version.h>
27 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
28 #include <linux/autoconf.h>
31 #include <linux/vmalloc.h>
33 #include <linux/mtd/nand.h>
35 #define BRCMNAND_malloc(size) vmalloc(size)
36 #define BRCMNAND_free(addr) vfree(addr)
40 BRCMNAND_ECC_DISABLE
= 0u,
41 BRCMNAND_ECC_BCH_1
= 1u,
42 BRCMNAND_ECC_BCH_2
= 2u,
43 BRCMNAND_ECC_BCH_3
= 3u,
44 BRCMNAND_ECC_BCH_4
= 4u,
45 BRCMNAND_ECC_BCH_5
= 5u,
46 BRCMNAND_ECC_BCH_6
= 6u,
47 BRCMNAND_ECC_BCH_7
= 7u,
48 BRCMNAND_ECC_BCH_8
= 8u,
49 BRCMNAND_ECC_BCH_9
= 9u,
50 BRCMNAND_ECC_BCH_10
= 10u,
51 BRCMNAND_ECC_BCH_11
= 11u,
52 BRCMNAND_ECC_BCH_12
= 12u,
53 BRCMNAND_ECC_RESVD_1
= 13u,
54 BRCMNAND_ECC_RESVD_2
= 14u,
55 BRCMNAND_ECC_HAMMING
= 15u
56 } brcmnand_ecc_level_t
;
62 struct nand_chip chip
;
63 brcmnand_ecc_level_t level
;
65 #ifdef CONFIG_MTD_PARTITIONS
66 struct mtd_partition
*parts
;
72 * brcmnand_scan - [BrcmNAND Interface] Scan for the BrcmNAND device
73 * @param mtd MTD device structure
74 * @param maxchips Number of chips to scan for
76 * This fills out all the not initialized function pointers
78 * The flash ID is read and the mtd/chip structures are
79 * filled with the appropriate values.
81 * THT: For now, maxchips should always be 1.
83 extern int brcmnand_scan(struct mtd_info
*mtd
, int maxchips
);
86 * brcmnand_release - [BrcmNAND Interface] Free resources held by the
88 * @param mtd MTD device structure
90 extern void brcmnand_release(struct mtd_info
*mtd
);
92 extern int brcmnand_scan_bbt(struct mtd_info
*mtd
, struct nand_bbt_descr
*bd
);
93 extern int brcmnand_default_bbt(struct mtd_info
*mtd
);
94 extern int brcmnand_isbad_bbt(struct mtd_info
*mtd
, loff_t offs
, int allowbbt
);
96 extern int brcmnand_update_bbt(struct mtd_info
*mtd
, loff_t offs
);
98 extern void* get_brcmnand_handle(void);
100 extern void print_oobbuf(const unsigned char* buf
, int len
);
101 extern void print_databuf(const unsigned char* buf
, int len
);
103 #ifdef CONFIG_MTD_BRCMNAND_CORRECTABLE_ERR_HANDLING
104 extern int brcmnand_cet_update(struct mtd_info
*mtd
, loff_t from
, int *status
);
105 extern int brcmnand_cet_prepare_reboot(struct mtd_info
*mtd
);
106 extern int brcmnand_cet_erasecallback(struct mtd_info
*mtd
, u_int32_t addr
);
107 extern int brcmnand_create_cet(struct mtd_info
*mtd
);
108 #endif /* CONFIG_MTD_BRCMNAND_CORRECTABLE_ERR_HANDLING */
110 #endif /* _BRCMNAND_PRIV_H_ */