• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/linux/linux-2.6.36/drivers/mtd/bcm947xx/nand/
1/*
2 * Broadcom NAND flash controller interface
3 *
4 * Copyright (C) 2013, Broadcom Corporation. All Rights Reserved.
5 *
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.
9 *
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.
17 *
18 * $Id $
19 */
20
21
22#ifndef _BRCMNAND_PRIV_H_
23#define _BRCMNAND_PRIV_H_
24
25#include <linux/version.h>
26
27#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
28#include <linux/autoconf.h>
29#endif
30
31#include <linux/vmalloc.h>
32
33#include <linux/mtd/nand.h>
34
35#define BRCMNAND_malloc(size) vmalloc(size)
36#define BRCMNAND_free(addr) vfree(addr)
37
38typedef enum
39{
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;
57
58struct brcmnand_mtd {
59	si_t *sih;
60	chipcregs_t *cc;
61	struct mtd_info mtd;
62	struct nand_chip chip;
63	brcmnand_ecc_level_t level;
64	hndnand_t * nflash;
65#ifdef CONFIG_MTD_PARTITIONS
66	struct mtd_partition *parts;
67#endif
68};
69
70
71/**
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
75 *
76 * This fills out all the not initialized function pointers
77 * with the defaults.
78 * The flash ID is read and the mtd/chip structures are
79 * filled with the appropriate values.
80 *
81 * THT: For now, maxchips should always be 1.
82 */
83extern int brcmnand_scan(struct mtd_info *mtd, int maxchips);
84
85/**
86 * brcmnand_release - [BrcmNAND Interface] Free resources held by the
87 *  BrcmNAND device
88 * @param mtd       MTD device structure
89 */
90extern void brcmnand_release(struct mtd_info *mtd);
91
92extern int brcmnand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd);
93extern int brcmnand_default_bbt(struct mtd_info *mtd);
94extern int brcmnand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt);
95
96extern int brcmnand_update_bbt(struct mtd_info *mtd, loff_t offs);
97
98extern void* get_brcmnand_handle(void);
99
100extern void print_oobbuf(const unsigned char* buf, int len);
101extern void print_databuf(const unsigned char* buf, int len);
102
103#ifdef CONFIG_MTD_BRCMNAND_CORRECTABLE_ERR_HANDLING
104extern int brcmnand_cet_update(struct mtd_info *mtd, loff_t from, int *status);
105extern int brcmnand_cet_prepare_reboot(struct mtd_info *mtd);
106extern int brcmnand_cet_erasecallback(struct mtd_info *mtd, u_int32_t addr);
107extern int brcmnand_create_cet(struct mtd_info *mtd);
108#endif /* CONFIG_MTD_BRCMNAND_CORRECTABLE_ERR_HANDLING */
109
110#endif /* _BRCMNAND_PRIV_H_ */
111