1/* 2 * Broadcom NAND flash controller interface 3 * 4 * Copyright (C) 2010, 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/autoconf.h> 26#include <linux/vmalloc.h> 27 28#include <linux/mtd/nand.h> 29 30#define BRCMNAND_malloc(size) vmalloc(size) 31#define BRCMNAND_free(addr) vfree(addr) 32 33typedef enum 34{ 35 BRCMNAND_ECC_DISABLE = 0u, 36 BRCMNAND_ECC_BCH_1 = 1u, 37 BRCMNAND_ECC_BCH_2 = 2u, 38 BRCMNAND_ECC_BCH_3 = 3u, 39 BRCMNAND_ECC_BCH_4 = 4u, 40 BRCMNAND_ECC_BCH_5 = 5u, 41 BRCMNAND_ECC_BCH_6 = 6u, 42 BRCMNAND_ECC_BCH_7 = 7u, 43 BRCMNAND_ECC_BCH_8 = 8u, 44 BRCMNAND_ECC_BCH_9 = 9u, 45 BRCMNAND_ECC_BCH_10 = 10u, 46 BRCMNAND_ECC_BCH_11 = 11u, 47 BRCMNAND_ECC_BCH_12 = 12u, 48 BRCMNAND_ECC_RESVD_1 = 13u, 49 BRCMNAND_ECC_RESVD_2 = 14u, 50 BRCMNAND_ECC_HAMMING = 15u 51} brcmnand_ecc_level_t; 52 53struct brcmnand_mtd { 54 si_t *sih; 55 chipcregs_t *cc; 56 struct mtd_info mtd; 57 struct nand_chip chip; 58#ifdef CONFIG_MTD_PARTITIONS 59 struct mtd_partition *parts; 60#endif 61}; 62 63 64/** 65 * brcmnand_scan - [BrcmNAND Interface] Scan for the BrcmNAND device 66 * @param mtd MTD device structure 67 * @param maxchips Number of chips to scan for 68 * 69 * This fills out all the not initialized function pointers 70 * with the defaults. 71 * The flash ID is read and the mtd/chip structures are 72 * filled with the appropriate values. 73 * 74 * THT: For now, maxchips should always be 1. 75 */ 76extern int brcmnand_scan(struct mtd_info *mtd, int maxchips); 77 78/** 79 * brcmnand_release - [BrcmNAND Interface] Free resources held by the 80 * BrcmNAND device 81 * @param mtd MTD device structure 82 */ 83extern void brcmnand_release(struct mtd_info *mtd); 84 85extern int brcmnand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd); 86extern int brcmnand_default_bbt(struct mtd_info *mtd); 87extern int brcmnand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt); 88 89extern int brcmnand_update_bbt(struct mtd_info *mtd, loff_t offs); 90 91extern void* get_brcmnand_handle(void); 92 93extern void print_oobbuf(const unsigned char* buf, int len); 94extern void print_databuf(const unsigned char* buf, int len); 95 96#ifdef CONFIG_MTD_BRCMNAND_CORRECTABLE_ERR_HANDLING 97extern int brcmnand_cet_update(struct mtd_info *mtd, loff_t from, int *status); 98extern int brcmnand_cet_prepare_reboot(struct mtd_info *mtd); 99extern int brcmnand_cet_erasecallback(struct mtd_info *mtd, u_int32_t addr); 100extern int brcmnand_create_cet(struct mtd_info *mtd); 101#endif /* CONFIG_MTD_BRCMNAND_CORRECTABLE_ERR_HANDLING */ 102 103#endif /* _BRCMNAND_PRIV_H_ */ 104