aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/mtd
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/mtd')
-rw-r--r--include/linux/mtd/mtd.h16
-rw-r--r--include/linux/mtd/mtdram.h2
-rw-r--r--include/linux/mtd/nand.h176
-rw-r--r--include/linux/mtd/partitions.h8
4 files changed, 170 insertions, 32 deletions
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 8cc0e2fb6894..a1b0b4c8fd79 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -204,12 +204,12 @@ struct mtd_info {
204 struct mtd_oob_ops *ops); 204 struct mtd_oob_ops *ops);
205 int (*_write_oob) (struct mtd_info *mtd, loff_t to, 205 int (*_write_oob) (struct mtd_info *mtd, loff_t to,
206 struct mtd_oob_ops *ops); 206 struct mtd_oob_ops *ops);
207 int (*_get_fact_prot_info) (struct mtd_info *mtd, struct otp_info *buf, 207 int (*_get_fact_prot_info) (struct mtd_info *mtd, size_t len,
208 size_t len); 208 size_t *retlen, struct otp_info *buf);
209 int (*_read_fact_prot_reg) (struct mtd_info *mtd, loff_t from, 209 int (*_read_fact_prot_reg) (struct mtd_info *mtd, loff_t from,
210 size_t len, size_t *retlen, u_char *buf); 210 size_t len, size_t *retlen, u_char *buf);
211 int (*_get_user_prot_info) (struct mtd_info *mtd, struct otp_info *buf, 211 int (*_get_user_prot_info) (struct mtd_info *mtd, size_t len,
212 size_t len); 212 size_t *retlen, struct otp_info *buf);
213 int (*_read_user_prot_reg) (struct mtd_info *mtd, loff_t from, 213 int (*_read_user_prot_reg) (struct mtd_info *mtd, loff_t from,
214 size_t len, size_t *retlen, u_char *buf); 214 size_t len, size_t *retlen, u_char *buf);
215 int (*_write_user_prot_reg) (struct mtd_info *mtd, loff_t to, 215 int (*_write_user_prot_reg) (struct mtd_info *mtd, loff_t to,
@@ -278,12 +278,12 @@ static inline int mtd_write_oob(struct mtd_info *mtd, loff_t to,
278 return mtd->_write_oob(mtd, to, ops); 278 return mtd->_write_oob(mtd, to, ops);
279} 279}
280 280
281int mtd_get_fact_prot_info(struct mtd_info *mtd, struct otp_info *buf, 281int mtd_get_fact_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen,
282 size_t len); 282 struct otp_info *buf);
283int mtd_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, size_t len, 283int mtd_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, size_t len,
284 size_t *retlen, u_char *buf); 284 size_t *retlen, u_char *buf);
285int mtd_get_user_prot_info(struct mtd_info *mtd, struct otp_info *buf, 285int mtd_get_user_prot_info(struct mtd_info *mtd, size_t len, size_t *retlen,
286 size_t len); 286 struct otp_info *buf);
287int mtd_read_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len, 287int mtd_read_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len,
288 size_t *retlen, u_char *buf); 288 size_t *retlen, u_char *buf);
289int mtd_write_user_prot_reg(struct mtd_info *mtd, loff_t to, size_t len, 289int mtd_write_user_prot_reg(struct mtd_info *mtd, loff_t to, size_t len,
diff --git a/include/linux/mtd/mtdram.h b/include/linux/mtd/mtdram.h
index 68891313875d..628a6a21ddf0 100644
--- a/include/linux/mtd/mtdram.h
+++ b/include/linux/mtd/mtdram.h
@@ -3,6 +3,6 @@
3 3
4#include <linux/mtd/mtd.h> 4#include <linux/mtd/mtd.h>
5int mtdram_init_device(struct mtd_info *mtd, void *mapped_address, 5int mtdram_init_device(struct mtd_info *mtd, void *mapped_address,
6 unsigned long size, char *name); 6 unsigned long size, const char *name);
7 7
8#endif /* __MTD_MTDRAM_H__ */ 8#endif /* __MTD_MTDRAM_H__ */
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 9e6c8f9f306e..450d61ec7f06 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -52,14 +52,6 @@ extern int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
52#define NAND_MAX_CHIPS 8 52#define NAND_MAX_CHIPS 8
53 53
54/* 54/*
55 * This constant declares the max. oobsize / page, which
56 * is supported now. If you add a chip with bigger oobsize/page
57 * adjust this accordingly.
58 */
59#define NAND_MAX_OOBSIZE 744
60#define NAND_MAX_PAGESIZE 8192
61
62/*
63 * Constants for hardware specific CLE/ALE/NCE function 55 * Constants for hardware specific CLE/ALE/NCE function
64 * 56 *
65 * These are bits which can be or'ed to set/clear multiple 57 * These are bits which can be or'ed to set/clear multiple
@@ -219,6 +211,9 @@ struct nand_chip;
219/* ONFI feature address */ 211/* ONFI feature address */
220#define ONFI_FEATURE_ADDR_TIMING_MODE 0x1 212#define ONFI_FEATURE_ADDR_TIMING_MODE 0x1
221 213
214/* Vendor-specific feature address (Micron) */
215#define ONFI_FEATURE_ADDR_READ_RETRY 0x89
216
222/* ONFI subfeature parameters length */ 217/* ONFI subfeature parameters length */
223#define ONFI_SUBFEATURE_PARAM_LEN 4 218#define ONFI_SUBFEATURE_PARAM_LEN 4
224 219
@@ -279,16 +274,17 @@ struct nand_onfi_params {
279 __le16 io_pin_capacitance_typ; 274 __le16 io_pin_capacitance_typ;
280 __le16 input_pin_capacitance_typ; 275 __le16 input_pin_capacitance_typ;
281 u8 input_pin_capacitance_max; 276 u8 input_pin_capacitance_max;
282 u8 driver_strenght_support; 277 u8 driver_strength_support;
283 __le16 t_int_r; 278 __le16 t_int_r;
284 __le16 t_ald; 279 __le16 t_ald;
285 u8 reserved4[7]; 280 u8 reserved4[7];
286 281
287 /* vendor */ 282 /* vendor */
288 u8 reserved5[90]; 283 __le16 vendor_revision;
284 u8 vendor[88];
289 285
290 __le16 crc; 286 __le16 crc;
291} __attribute__((packed)); 287} __packed;
292 288
293#define ONFI_CRC_BASE 0x4F4E 289#define ONFI_CRC_BASE 0x4F4E
294 290
@@ -326,6 +322,104 @@ struct onfi_ext_param_page {
326 */ 322 */
327} __packed; 323} __packed;
328 324
325struct nand_onfi_vendor_micron {
326 u8 two_plane_read;
327 u8 read_cache;
328 u8 read_unique_id;
329 u8 dq_imped;
330 u8 dq_imped_num_settings;
331 u8 dq_imped_feat_addr;
332 u8 rb_pulldown_strength;
333 u8 rb_pulldown_strength_feat_addr;
334 u8 rb_pulldown_strength_num_settings;
335 u8 otp_mode;
336 u8 otp_page_start;
337 u8 otp_data_prot_addr;
338 u8 otp_num_pages;
339 u8 otp_feat_addr;
340 u8 read_retry_options;
341 u8 reserved[72];
342 u8 param_revision;
343} __packed;
344
345struct jedec_ecc_info {
346 u8 ecc_bits;
347 u8 codeword_size;
348 __le16 bb_per_lun;
349 __le16 block_endurance;
350 u8 reserved[2];
351} __packed;
352
353/* JEDEC features */
354#define JEDEC_FEATURE_16_BIT_BUS (1 << 0)
355
356struct nand_jedec_params {
357 /* rev info and features block */
358 /* 'J' 'E' 'S' 'D' */
359 u8 sig[4];
360 __le16 revision;
361 __le16 features;
362 u8 opt_cmd[3];
363 __le16 sec_cmd;
364 u8 num_of_param_pages;
365 u8 reserved0[18];
366
367 /* manufacturer information block */
368 char manufacturer[12];
369 char model[20];
370 u8 jedec_id[6];
371 u8 reserved1[10];
372
373 /* memory organization block */
374 __le32 byte_per_page;
375 __le16 spare_bytes_per_page;
376 u8 reserved2[6];
377 __le32 pages_per_block;
378 __le32 blocks_per_lun;
379 u8 lun_count;
380 u8 addr_cycles;
381 u8 bits_per_cell;
382 u8 programs_per_page;
383 u8 multi_plane_addr;
384 u8 multi_plane_op_attr;
385 u8 reserved3[38];
386
387 /* electrical parameter block */
388 __le16 async_sdr_speed_grade;
389 __le16 toggle_ddr_speed_grade;
390 __le16 sync_ddr_speed_grade;
391 u8 async_sdr_features;
392 u8 toggle_ddr_features;
393 u8 sync_ddr_features;
394 __le16 t_prog;
395 __le16 t_bers;
396 __le16 t_r;
397 __le16 t_r_multi_plane;
398 __le16 t_ccs;
399 __le16 io_pin_capacitance_typ;
400 __le16 input_pin_capacitance_typ;
401 __le16 clk_pin_capacitance_typ;
402 u8 driver_strength_support;
403 __le16 t_ald;
404 u8 reserved4[36];
405
406 /* ECC and endurance block */
407 u8 guaranteed_good_blocks;
408 __le16 guaranteed_block_endurance;
409 struct jedec_ecc_info ecc_info[4];
410 u8 reserved5[29];
411
412 /* reserved */
413 u8 reserved6[148];
414
415 /* vendor */
416 __le16 vendor_rev_num;
417 u8 reserved7[88];
418
419 /* CRC for Parameter Page */
420 __le16 crc;
421} __packed;
422
329/** 423/**
330 * struct nand_hw_control - Control structure for hardware controller (e.g ECC generator) shared among independent devices 424 * struct nand_hw_control - Control structure for hardware controller (e.g ECC generator) shared among independent devices
331 * @lock: protection lock 425 * @lock: protection lock
@@ -394,7 +488,7 @@ struct nand_ecc_ctrl {
394 int (*read_page)(struct mtd_info *mtd, struct nand_chip *chip, 488 int (*read_page)(struct mtd_info *mtd, struct nand_chip *chip,
395 uint8_t *buf, int oob_required, int page); 489 uint8_t *buf, int oob_required, int page);
396 int (*read_subpage)(struct mtd_info *mtd, struct nand_chip *chip, 490 int (*read_subpage)(struct mtd_info *mtd, struct nand_chip *chip,
397 uint32_t offs, uint32_t len, uint8_t *buf); 491 uint32_t offs, uint32_t len, uint8_t *buf, int page);
398 int (*write_subpage)(struct mtd_info *mtd, struct nand_chip *chip, 492 int (*write_subpage)(struct mtd_info *mtd, struct nand_chip *chip,
399 uint32_t offset, uint32_t data_len, 493 uint32_t offset, uint32_t data_len,
400 const uint8_t *data_buf, int oob_required); 494 const uint8_t *data_buf, int oob_required);
@@ -411,17 +505,17 @@ struct nand_ecc_ctrl {
411 505
412/** 506/**
413 * struct nand_buffers - buffer structure for read/write 507 * struct nand_buffers - buffer structure for read/write
414 * @ecccalc: buffer for calculated ECC 508 * @ecccalc: buffer pointer for calculated ECC, size is oobsize.
415 * @ecccode: buffer for ECC read from flash 509 * @ecccode: buffer pointer for ECC read from flash, size is oobsize.
416 * @databuf: buffer for data - dynamically sized 510 * @databuf: buffer pointer for data, size is (page size + oobsize).
417 * 511 *
418 * Do not change the order of buffers. databuf and oobrbuf must be in 512 * Do not change the order of buffers. databuf and oobrbuf must be in
419 * consecutive order. 513 * consecutive order.
420 */ 514 */
421struct nand_buffers { 515struct nand_buffers {
422 uint8_t ecccalc[NAND_MAX_OOBSIZE]; 516 uint8_t *ecccalc;
423 uint8_t ecccode[NAND_MAX_OOBSIZE]; 517 uint8_t *ecccode;
424 uint8_t databuf[NAND_MAX_PAGESIZE + NAND_MAX_OOBSIZE]; 518 uint8_t *databuf;
425}; 519};
426 520
427/** 521/**
@@ -432,6 +526,8 @@ struct nand_buffers {
432 * flash device. 526 * flash device.
433 * @read_byte: [REPLACEABLE] read one byte from the chip 527 * @read_byte: [REPLACEABLE] read one byte from the chip
434 * @read_word: [REPLACEABLE] read one word from the chip 528 * @read_word: [REPLACEABLE] read one word from the chip
529 * @write_byte: [REPLACEABLE] write a single byte to the chip on the
530 * low 8 I/O lines
435 * @write_buf: [REPLACEABLE] write data from the buffer to the chip 531 * @write_buf: [REPLACEABLE] write data from the buffer to the chip
436 * @read_buf: [REPLACEABLE] read data from the chip into the buffer 532 * @read_buf: [REPLACEABLE] read data from the chip into the buffer
437 * @select_chip: [REPLACEABLE] select chip nr 533 * @select_chip: [REPLACEABLE] select chip nr
@@ -451,6 +547,8 @@ struct nand_buffers {
451 * commands to the chip. 547 * commands to the chip.
452 * @waitfunc: [REPLACEABLE] hardwarespecific function for wait on 548 * @waitfunc: [REPLACEABLE] hardwarespecific function for wait on
453 * ready. 549 * ready.
550 * @setup_read_retry: [FLASHSPECIFIC] flash (vendor) specific function for
551 * setting the read-retry mode. Mostly needed for MLC NAND.
454 * @ecc: [BOARDSPECIFIC] ECC control structure 552 * @ecc: [BOARDSPECIFIC] ECC control structure
455 * @buffers: buffer structure for read/write 553 * @buffers: buffer structure for read/write
456 * @hwcontrol: platform-specific hardware control structure 554 * @hwcontrol: platform-specific hardware control structure
@@ -495,8 +593,13 @@ struct nand_buffers {
495 * @subpagesize: [INTERN] holds the subpagesize 593 * @subpagesize: [INTERN] holds the subpagesize
496 * @onfi_version: [INTERN] holds the chip ONFI version (BCD encoded), 594 * @onfi_version: [INTERN] holds the chip ONFI version (BCD encoded),
497 * non 0 if ONFI supported. 595 * non 0 if ONFI supported.
596 * @jedec_version: [INTERN] holds the chip JEDEC version (BCD encoded),
597 * non 0 if JEDEC supported.
498 * @onfi_params: [INTERN] holds the ONFI page parameter when ONFI is 598 * @onfi_params: [INTERN] holds the ONFI page parameter when ONFI is
499 * supported, 0 otherwise. 599 * supported, 0 otherwise.
600 * @jedec_params: [INTERN] holds the JEDEC parameter page when JEDEC is
601 * supported, 0 otherwise.
602 * @read_retries: [INTERN] the number of read retry modes supported
500 * @onfi_set_features: [REPLACEABLE] set the features for ONFI nand 603 * @onfi_set_features: [REPLACEABLE] set the features for ONFI nand
501 * @onfi_get_features: [REPLACEABLE] get the features for ONFI nand 604 * @onfi_get_features: [REPLACEABLE] get the features for ONFI nand
502 * @bbt: [INTERN] bad block table pointer 605 * @bbt: [INTERN] bad block table pointer
@@ -521,6 +624,7 @@ struct nand_chip {
521 624
522 uint8_t (*read_byte)(struct mtd_info *mtd); 625 uint8_t (*read_byte)(struct mtd_info *mtd);
523 u16 (*read_word)(struct mtd_info *mtd); 626 u16 (*read_word)(struct mtd_info *mtd);
627 void (*write_byte)(struct mtd_info *mtd, uint8_t byte);
524 void (*write_buf)(struct mtd_info *mtd, const uint8_t *buf, int len); 628 void (*write_buf)(struct mtd_info *mtd, const uint8_t *buf, int len);
525 void (*read_buf)(struct mtd_info *mtd, uint8_t *buf, int len); 629 void (*read_buf)(struct mtd_info *mtd, uint8_t *buf, int len);
526 void (*select_chip)(struct mtd_info *mtd, int chip); 630 void (*select_chip)(struct mtd_info *mtd, int chip);
@@ -544,6 +648,7 @@ struct nand_chip {
544 int feature_addr, uint8_t *subfeature_para); 648 int feature_addr, uint8_t *subfeature_para);
545 int (*onfi_get_features)(struct mtd_info *mtd, struct nand_chip *chip, 649 int (*onfi_get_features)(struct mtd_info *mtd, struct nand_chip *chip,
546 int feature_addr, uint8_t *subfeature_para); 650 int feature_addr, uint8_t *subfeature_para);
651 int (*setup_read_retry)(struct mtd_info *mtd, int retry_mode);
547 652
548 int chip_delay; 653 int chip_delay;
549 unsigned int options; 654 unsigned int options;
@@ -566,7 +671,13 @@ struct nand_chip {
566 int badblockbits; 671 int badblockbits;
567 672
568 int onfi_version; 673 int onfi_version;
569 struct nand_onfi_params onfi_params; 674 int jedec_version;
675 union {
676 struct nand_onfi_params onfi_params;
677 struct nand_jedec_params jedec_params;
678 };
679
680 int read_retries;
570 681
571 flstate_t state; 682 flstate_t state;
572 683
@@ -600,6 +711,8 @@ struct nand_chip {
600#define NAND_MFR_AMD 0x01 711#define NAND_MFR_AMD 0x01
601#define NAND_MFR_MACRONIX 0xc2 712#define NAND_MFR_MACRONIX 0xc2
602#define NAND_MFR_EON 0x92 713#define NAND_MFR_EON 0x92
714#define NAND_MFR_SANDISK 0x45
715#define NAND_MFR_INTEL 0x89
603 716
604/* The maximum expected count of bytes in the NAND ID sequence */ 717/* The maximum expected count of bytes in the NAND ID sequence */
605#define NAND_MAX_ID_LEN 8 718#define NAND_MAX_ID_LEN 8
@@ -805,4 +918,29 @@ static inline bool nand_is_slc(struct nand_chip *chip)
805{ 918{
806 return chip->bits_per_cell == 1; 919 return chip->bits_per_cell == 1;
807} 920}
921
922/**
923 * Check if the opcode's address should be sent only on the lower 8 bits
924 * @command: opcode to check
925 */
926static inline int nand_opcode_8bits(unsigned int command)
927{
928 switch (command) {
929 case NAND_CMD_READID:
930 case NAND_CMD_PARAM:
931 case NAND_CMD_GET_FEATURES:
932 case NAND_CMD_SET_FEATURES:
933 return 1;
934 default:
935 break;
936 }
937 return 0;
938}
939
940/* return the supported JEDEC features. */
941static inline int jedec_feature(struct nand_chip *chip)
942{
943 return chip->jedec_version ? le16_to_cpu(chip->jedec_params.features)
944 : 0;
945}
808#endif /* __LINUX_MTD_NAND_H */ 946#endif /* __LINUX_MTD_NAND_H */
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
index 1f8d24bdafda..6a35e6de5da1 100644
--- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h
@@ -37,7 +37,7 @@
37 */ 37 */
38 38
39struct mtd_partition { 39struct mtd_partition {
40 char *name; /* identifier string */ 40 const char *name; /* identifier string */
41 uint64_t size; /* partition size */ 41 uint64_t size; /* partition size */
42 uint64_t offset; /* offset within the master MTD space */ 42 uint64_t offset; /* offset within the master MTD space */
43 uint32_t mask_flags; /* master MTD flags to mask out for this partition */ 43 uint32_t mask_flags; /* master MTD flags to mask out for this partition */
@@ -76,11 +76,11 @@ struct mtd_part_parser {
76 struct mtd_part_parser_data *); 76 struct mtd_part_parser_data *);
77}; 77};
78 78
79extern int register_mtd_parser(struct mtd_part_parser *parser); 79extern void register_mtd_parser(struct mtd_part_parser *parser);
80extern int deregister_mtd_parser(struct mtd_part_parser *parser); 80extern void deregister_mtd_parser(struct mtd_part_parser *parser);
81 81
82int mtd_is_partition(const struct mtd_info *mtd); 82int mtd_is_partition(const struct mtd_info *mtd);
83int mtd_add_partition(struct mtd_info *master, char *name, 83int mtd_add_partition(struct mtd_info *master, const char *name,
84 long long offset, long long length); 84 long long offset, long long length);
85int mtd_del_partition(struct mtd_info *master, int partno); 85int mtd_del_partition(struct mtd_info *master, int partno);
86uint64_t mtd_get_device_size(const struct mtd_info *mtd); 86uint64_t mtd_get_device_size(const struct mtd_info *mtd);