2007-09-10 08:15:14 +00:00
|
|
|
/*
|
|
|
|
* linux/include/linux/mtd/onenand.h
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005-2007 Samsung Electronics
|
|
|
|
* Kyungmin Park <kyungmin.park@samsung.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __LINUX_MTD_ONENAND_H
|
|
|
|
#define __LINUX_MTD_ONENAND_H
|
|
|
|
|
|
|
|
#include <linux/mtd/onenand_regs.h>
|
|
|
|
|
|
|
|
/* Note: The header order is impoertant */
|
|
|
|
#include <onenand_uboot.h>
|
|
|
|
|
2008-08-13 00:11:02 +00:00
|
|
|
#include <linux/mtd/compat.h>
|
2007-09-10 08:15:14 +00:00
|
|
|
#include <linux/mtd/bbm.h>
|
|
|
|
|
2009-11-06 11:45:31 +00:00
|
|
|
#define MAX_DIES 2
|
2007-09-10 08:15:14 +00:00
|
|
|
#define MAX_BUFFERRAM 2
|
2009-11-06 11:45:31 +00:00
|
|
|
#define MAX_ONENAND_PAGESIZE (4096 + 128)
|
2007-09-10 08:15:14 +00:00
|
|
|
|
|
|
|
/* Scan and identify a OneNAND device */
|
|
|
|
extern int onenand_scan (struct mtd_info *mtd, int max_chips);
|
|
|
|
/* Free resources held by the OneNAND device */
|
|
|
|
extern void onenand_release (struct mtd_info *mtd);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct onenand_bufferram - OneNAND BufferRAM Data
|
2008-11-04 00:24:07 +00:00
|
|
|
* @param blockpage block & page address in BufferRAM
|
2007-09-10 08:15:14 +00:00
|
|
|
*/
|
|
|
|
struct onenand_bufferram {
|
2008-11-04 00:24:07 +00:00
|
|
|
int blockpage;
|
2007-09-10 08:15:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct onenand_chip - OneNAND Private Flash Chip Data
|
|
|
|
* @param base [BOARDSPECIFIC] address to access OneNAND
|
2009-11-06 11:45:31 +00:00
|
|
|
* @dies: [INTERN][FLEXONENAND] number of dies on chip
|
|
|
|
* @boundary: [INTERN][FLEXONENAND] Boundary of the dies
|
|
|
|
* @diesize: [INTERN][FLEXONENAND] Size of the dies
|
2007-09-10 08:15:14 +00:00
|
|
|
* @param chipsize [INTERN] the size of one chip for multichip arrays
|
|
|
|
* @param device_id [INTERN] device ID
|
|
|
|
* @param verstion_id [INTERN] version ID
|
2009-11-06 11:45:31 +00:00
|
|
|
* @technology [INTERN] describes the internal NAND array technology such as SLC or MLC.
|
|
|
|
* @density_mask: [INTERN] chip density, used for DDP devices
|
2007-09-10 08:15:14 +00:00
|
|
|
* @param options [BOARDSPECIFIC] various chip options. They can partly be set to inform onenand_scan about
|
|
|
|
* @param erase_shift [INTERN] number of address bits in a block
|
|
|
|
* @param page_shift [INTERN] number of address bits in a page
|
|
|
|
* @param ppb_shift [INTERN] number of address bits in a pages per block
|
|
|
|
* @param page_mask [INTERN] a page per block mask
|
2008-10-24 21:20:43 +00:00
|
|
|
* @param writesize [INTERN] a real page size
|
2007-09-10 08:15:14 +00:00
|
|
|
* @param bufferam_index [INTERN] BufferRAM index
|
|
|
|
* @param bufferam [INTERN] BufferRAM info
|
|
|
|
* @param readw [REPLACEABLE] hardware specific function for read short
|
|
|
|
* @param writew [REPLACEABLE] hardware specific function for write short
|
|
|
|
* @param command [REPLACEABLE] hardware specific function for writing commands to the chip
|
|
|
|
* @param wait [REPLACEABLE] hardware specific function for wait on ready
|
|
|
|
* @param read_bufferram [REPLACEABLE] hardware specific function for BufferRAM Area
|
|
|
|
* @param write_bufferram [REPLACEABLE] hardware specific function for BufferRAM Area
|
|
|
|
* @param chip_lock [INTERN] spinlock used to protect access to this structure and the chip
|
|
|
|
* @param wq [INTERN] wait queue to sleep on if a OneNAND operation is in progress
|
|
|
|
* @param state [INTERN] the current state of the OneNAND device
|
|
|
|
* @param autooob [REPLACEABLE] the default (auto)placement scheme
|
|
|
|
* @param priv [OPTIONAL] pointer to private chip date
|
|
|
|
*/
|
|
|
|
struct onenand_chip {
|
|
|
|
void __iomem *base;
|
2009-11-06 11:45:31 +00:00
|
|
|
unsigned int dies;
|
|
|
|
unsigned int boundary[MAX_DIES];
|
|
|
|
unsigned int diesize[MAX_DIES];
|
2007-09-10 08:15:14 +00:00
|
|
|
unsigned int chipsize;
|
|
|
|
unsigned int device_id;
|
2008-11-04 00:24:07 +00:00
|
|
|
unsigned int version_id;
|
2009-11-06 11:45:31 +00:00
|
|
|
unsigned int technology;
|
2008-11-04 00:24:07 +00:00
|
|
|
unsigned int density_mask;
|
2007-09-10 08:15:14 +00:00
|
|
|
unsigned int options;
|
|
|
|
|
|
|
|
unsigned int erase_shift;
|
|
|
|
unsigned int page_shift;
|
|
|
|
unsigned int ppb_shift; /* Pages per block shift */
|
|
|
|
unsigned int page_mask;
|
2008-08-18 23:42:53 +00:00
|
|
|
unsigned int writesize;
|
2007-09-10 08:15:14 +00:00
|
|
|
|
|
|
|
unsigned int bufferram_index;
|
|
|
|
struct onenand_bufferram bufferram[MAX_BUFFERRAM];
|
|
|
|
|
2008-11-04 00:24:07 +00:00
|
|
|
int (*command) (struct mtd_info *mtd, int cmd, loff_t address,
|
2007-09-10 08:15:14 +00:00
|
|
|
size_t len);
|
2008-11-04 00:24:07 +00:00
|
|
|
int (*wait) (struct mtd_info *mtd, int state);
|
|
|
|
int (*bbt_wait) (struct mtd_info *mtd, int state);
|
2009-07-21 02:58:04 +00:00
|
|
|
void (*unlock_all)(struct mtd_info *mtd);
|
2008-11-04 00:24:07 +00:00
|
|
|
int (*read_bufferram) (struct mtd_info *mtd, loff_t addr, int area,
|
2007-09-10 08:15:14 +00:00
|
|
|
unsigned char *buffer, int offset, size_t count);
|
2008-11-04 00:24:07 +00:00
|
|
|
int (*write_bufferram) (struct mtd_info *mtd, loff_t addr, int area,
|
2007-09-10 08:15:14 +00:00
|
|
|
const unsigned char *buffer, int offset,
|
|
|
|
size_t count);
|
2008-11-04 00:24:07 +00:00
|
|
|
unsigned short (*read_word) (void __iomem *addr);
|
|
|
|
void (*write_word) (unsigned short value, void __iomem *addr);
|
|
|
|
void (*mmcontrol) (struct mtd_info *mtd, int sync_read);
|
2008-08-13 00:11:02 +00:00
|
|
|
int (*block_markbad)(struct mtd_info *mtd, loff_t ofs);
|
|
|
|
int (*scan_bbt)(struct mtd_info *mtd);
|
2007-09-10 08:15:14 +00:00
|
|
|
|
2008-11-04 00:24:07 +00:00
|
|
|
unsigned char *main_buf;
|
|
|
|
unsigned char *spare_buf;
|
|
|
|
#ifdef DONT_USE_UBOOT
|
|
|
|
spinlock_t chip_lock;
|
|
|
|
wait_queue_head_t wq;
|
|
|
|
#endif
|
2008-08-13 00:11:02 +00:00
|
|
|
int state;
|
2008-11-04 00:24:07 +00:00
|
|
|
unsigned char *page_buf;
|
|
|
|
unsigned char *oob_buf;
|
2007-09-10 08:15:14 +00:00
|
|
|
|
|
|
|
struct nand_oobinfo *autooob;
|
2008-12-02 10:06:47 +00:00
|
|
|
int subpagesize;
|
2008-11-04 00:24:07 +00:00
|
|
|
struct nand_ecclayout *ecclayout;
|
2007-09-10 08:15:14 +00:00
|
|
|
|
|
|
|
void *bbm;
|
|
|
|
|
|
|
|
void *priv;
|
|
|
|
};
|
|
|
|
|
2008-08-18 23:42:53 +00:00
|
|
|
/*
|
|
|
|
* Helper macros
|
|
|
|
*/
|
2007-09-10 08:15:14 +00:00
|
|
|
#define ONENAND_CURRENT_BUFFERRAM(this) (this->bufferram_index)
|
|
|
|
#define ONENAND_NEXT_BUFFERRAM(this) (this->bufferram_index ^ 1)
|
|
|
|
#define ONENAND_SET_NEXT_BUFFERRAM(this) (this->bufferram_index ^= 1)
|
2008-08-18 23:42:53 +00:00
|
|
|
#define ONENAND_SET_PREV_BUFFERRAM(this) (this->bufferram_index ^= 1)
|
|
|
|
#define ONENAND_SET_BUFFERRAM0(this) (this->bufferram_index = 0)
|
|
|
|
#define ONENAND_SET_BUFFERRAM1(this) (this->bufferram_index = 1)
|
|
|
|
|
2009-11-06 11:45:31 +00:00
|
|
|
#define FLEXONENAND(this) (this->device_id & DEVICE_IS_FLEXONENAND)
|
|
|
|
#define ONENAND_IS_MLC(this) (this->technology & ONENAND_TECHNOLOGY_IS_MLC)
|
2008-08-18 23:42:53 +00:00
|
|
|
#define ONENAND_IS_DDP(this) \
|
|
|
|
(this->device_id & ONENAND_DEVICE_IS_DDP)
|
|
|
|
|
|
|
|
#define ONENAND_IS_2PLANE(this) (0)
|
2007-09-10 08:15:14 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Options bits
|
|
|
|
*/
|
2008-11-04 00:24:07 +00:00
|
|
|
#define ONENAND_HAS_CONT_LOCK (0x0001)
|
|
|
|
#define ONENAND_HAS_UNLOCK_ALL (0x0002)
|
|
|
|
#define ONENAND_HAS_2PLANE (0x0004)
|
2009-10-01 08:20:08 +00:00
|
|
|
#define ONENAND_RUNTIME_BADBLOCK_CHECK (0x0200)
|
2008-08-18 23:42:53 +00:00
|
|
|
#define ONENAND_PAGEBUF_ALLOC (0x1000)
|
|
|
|
#define ONENAND_OOBBUF_ALLOC (0x2000)
|
2007-09-10 08:15:14 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* OneNAND Flash Manufacturer ID Codes
|
|
|
|
*/
|
2010-10-11 19:48:03 +00:00
|
|
|
#define ONENAND_MFR_NUMONYX 0x20
|
2007-09-10 08:15:14 +00:00
|
|
|
#define ONENAND_MFR_SAMSUNG 0xec
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct nand_manufacturers - NAND Flash Manufacturer ID Structure
|
|
|
|
* @param name: Manufacturer name
|
|
|
|
* @param id: manufacturer ID code of device.
|
|
|
|
*/
|
|
|
|
struct onenand_manufacturers {
|
|
|
|
int id;
|
|
|
|
char *name;
|
|
|
|
};
|
|
|
|
|
2008-08-18 23:42:53 +00:00
|
|
|
int onenand_bbt_read_oob(struct mtd_info *mtd, loff_t from,
|
|
|
|
struct mtd_oob_ops *ops);
|
|
|
|
|
2009-11-06 11:45:31 +00:00
|
|
|
unsigned int onenand_block(struct onenand_chip *this, loff_t addr);
|
|
|
|
int flexonenand_region(struct mtd_info *mtd, loff_t addr);
|
2007-09-10 08:15:14 +00:00
|
|
|
#endif /* __LINUX_MTD_ONENAND_H */
|