diff options
Diffstat (limited to 'include/linux/mtd/onenand.h')
| -rw-r--r-- | include/linux/mtd/onenand.h | 155 |
1 files changed, 155 insertions, 0 deletions
diff --git a/include/linux/mtd/onenand.h b/include/linux/mtd/onenand.h new file mode 100644 index 000000000000..f1fd4215686a --- /dev/null +++ b/include/linux/mtd/onenand.h | |||
| @@ -0,0 +1,155 @@ | |||
| 1 | /* | ||
| 2 | * linux/include/linux/mtd/onenand.h | ||
| 3 | * | ||
| 4 | * Copyright (C) 2005 Samsung Electronics | ||
| 5 | * Kyungmin Park <kyungmin.park@samsung.com> | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License version 2 as | ||
| 9 | * published by the Free Software Foundation. | ||
| 10 | */ | ||
| 11 | |||
| 12 | #ifndef __LINUX_MTD_ONENAND_H | ||
| 13 | #define __LINUX_MTD_ONENAND_H | ||
| 14 | |||
| 15 | #include <linux/spinlock.h> | ||
| 16 | #include <linux/mtd/onenand_regs.h> | ||
| 17 | #include <linux/mtd/bbm.h> | ||
| 18 | |||
| 19 | #define MAX_BUFFERRAM 2 | ||
| 20 | #define MAX_ONENAND_PAGESIZE (2048 + 64) | ||
| 21 | |||
| 22 | /* Scan and identify a OneNAND device */ | ||
| 23 | extern int onenand_scan(struct mtd_info *mtd, int max_chips); | ||
| 24 | /* Free resources held by the OneNAND device */ | ||
| 25 | extern void onenand_release(struct mtd_info *mtd); | ||
| 26 | |||
| 27 | /** | ||
| 28 | * onenand_state_t - chip states | ||
| 29 | * Enumeration for OneNAND flash chip state | ||
| 30 | */ | ||
| 31 | typedef enum { | ||
| 32 | FL_READY, | ||
| 33 | FL_READING, | ||
| 34 | FL_WRITING, | ||
| 35 | FL_ERASING, | ||
| 36 | FL_SYNCING, | ||
| 37 | FL_UNLOCKING, | ||
| 38 | FL_LOCKING, | ||
| 39 | FL_PM_SUSPENDED, | ||
| 40 | } onenand_state_t; | ||
| 41 | |||
| 42 | /** | ||
| 43 | * struct onenand_bufferram - OneNAND BufferRAM Data | ||
| 44 | * @param block block address in BufferRAM | ||
| 45 | * @param page page address in BufferRAM | ||
| 46 | * @param valid valid flag | ||
| 47 | */ | ||
| 48 | struct onenand_bufferram { | ||
| 49 | int block; | ||
| 50 | int page; | ||
| 51 | int valid; | ||
| 52 | }; | ||
| 53 | |||
| 54 | /** | ||
| 55 | * struct onenand_chip - OneNAND Private Flash Chip Data | ||
| 56 | * @param base [BOARDSPECIFIC] address to access OneNAND | ||
| 57 | * @param chipsize [INTERN] the size of one chip for multichip arrays | ||
| 58 | * @param device_id [INTERN] device ID | ||
| 59 | * @param verstion_id [INTERN] version ID | ||
| 60 | * @param options [BOARDSPECIFIC] various chip options. They can partly be set to inform onenand_scan about | ||
| 61 | * @param erase_shift [INTERN] number of address bits in a block | ||
| 62 | * @param page_shift [INTERN] number of address bits in a page | ||
| 63 | * @param ppb_shift [INTERN] number of address bits in a pages per block | ||
| 64 | * @param page_mask [INTERN] a page per block mask | ||
| 65 | * @param bufferam_index [INTERN] BufferRAM index | ||
| 66 | * @param bufferam [INTERN] BufferRAM info | ||
| 67 | * @param readw [REPLACEABLE] hardware specific function for read short | ||
| 68 | * @param writew [REPLACEABLE] hardware specific function for write short | ||
| 69 | * @param command [REPLACEABLE] hardware specific function for writing commands to the chip | ||
| 70 | * @param wait [REPLACEABLE] hardware specific function for wait on ready | ||
| 71 | * @param read_bufferram [REPLACEABLE] hardware specific function for BufferRAM Area | ||
| 72 | * @param write_bufferram [REPLACEABLE] hardware specific function for BufferRAM Area | ||
| 73 | * @param read_word [REPLACEABLE] hardware specific function for read register of OneNAND | ||
| 74 | * @param write_word [REPLACEABLE] hardware specific function for write register of OneNAND | ||
| 75 | * @param scan_bbt [REPLACEALBE] hardware specific function for scaning Bad block Table | ||
| 76 | * @param chip_lock [INTERN] spinlock used to protect access to this structure and the chip | ||
| 77 | * @param wq [INTERN] wait queue to sleep on if a OneNAND operation is in progress | ||
| 78 | * @param state [INTERN] the current state of the OneNAND device | ||
| 79 | * @param autooob [REPLACEABLE] the default (auto)placement scheme | ||
| 80 | * @param bbm [REPLACEABLE] pointer to Bad Block Management | ||
| 81 | * @param priv [OPTIONAL] pointer to private chip date | ||
| 82 | */ | ||
| 83 | struct onenand_chip { | ||
| 84 | void __iomem *base; | ||
| 85 | unsigned int chipsize; | ||
| 86 | unsigned int device_id; | ||
| 87 | unsigned int density_mask; | ||
| 88 | unsigned int options; | ||
| 89 | |||
| 90 | unsigned int erase_shift; | ||
| 91 | unsigned int page_shift; | ||
| 92 | unsigned int ppb_shift; /* Pages per block shift */ | ||
| 93 | unsigned int page_mask; | ||
| 94 | |||
| 95 | unsigned int bufferram_index; | ||
| 96 | struct onenand_bufferram bufferram[MAX_BUFFERRAM]; | ||
| 97 | |||
| 98 | int (*command)(struct mtd_info *mtd, int cmd, loff_t address, size_t len); | ||
| 99 | int (*wait)(struct mtd_info *mtd, int state); | ||
| 100 | int (*read_bufferram)(struct mtd_info *mtd, int area, | ||
| 101 | unsigned char *buffer, int offset, size_t count); | ||
| 102 | int (*write_bufferram)(struct mtd_info *mtd, int area, | ||
| 103 | const unsigned char *buffer, int offset, size_t count); | ||
| 104 | unsigned short (*read_word)(void __iomem *addr); | ||
| 105 | void (*write_word)(unsigned short value, void __iomem *addr); | ||
| 106 | void (*mmcontrol)(struct mtd_info *mtd, int sync_read); | ||
| 107 | int (*block_markbad)(struct mtd_info *mtd, loff_t ofs); | ||
| 108 | int (*scan_bbt)(struct mtd_info *mtd); | ||
| 109 | |||
| 110 | spinlock_t chip_lock; | ||
| 111 | wait_queue_head_t wq; | ||
| 112 | onenand_state_t state; | ||
| 113 | |||
| 114 | struct nand_oobinfo *autooob; | ||
| 115 | |||
| 116 | void *bbm; | ||
| 117 | |||
| 118 | void *priv; | ||
| 119 | }; | ||
| 120 | |||
| 121 | /* | ||
| 122 | * Helper macros | ||
| 123 | */ | ||
| 124 | #define ONENAND_CURRENT_BUFFERRAM(this) (this->bufferram_index) | ||
| 125 | #define ONENAND_NEXT_BUFFERRAM(this) (this->bufferram_index ^ 1) | ||
| 126 | #define ONENAND_SET_NEXT_BUFFERRAM(this) (this->bufferram_index ^= 1) | ||
| 127 | |||
| 128 | #define ONENAND_GET_SYS_CFG1(this) \ | ||
| 129 | (this->read_word(this->base + ONENAND_REG_SYS_CFG1)) | ||
| 130 | #define ONENAND_SET_SYS_CFG1(v, this) \ | ||
| 131 | (this->write_word(v, this->base + ONENAND_REG_SYS_CFG1)) | ||
| 132 | |||
| 133 | /* | ||
| 134 | * Options bits | ||
| 135 | */ | ||
| 136 | #define ONENAND_CONT_LOCK (0x0001) | ||
| 137 | |||
| 138 | |||
| 139 | /* | ||
| 140 | * OneNAND Flash Manufacturer ID Codes | ||
| 141 | */ | ||
| 142 | #define ONENAND_MFR_SAMSUNG 0xec | ||
| 143 | #define ONENAND_MFR_UNKNOWN 0x00 | ||
| 144 | |||
| 145 | /** | ||
| 146 | * struct nand_manufacturers - NAND Flash Manufacturer ID Structure | ||
| 147 | * @param name: Manufacturer name | ||
| 148 | * @param id: manufacturer ID code of device. | ||
| 149 | */ | ||
| 150 | struct onenand_manufacturers { | ||
| 151 | int id; | ||
| 152 | char *name; | ||
| 153 | }; | ||
| 154 | |||
| 155 | #endif /* __LINUX_MTD_ONENAND_H */ | ||
