aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/linux/mtd/mtd.h16
-rw-r--r--include/linux/mtd/nand.h135
-rw-r--r--include/linux/of_mtd.h12
-rw-r--r--include/linux/platform_data/elm.h10
-rw-r--r--include/linux/platform_data/mtd-nand-s3c2410.h8
5 files changed, 147 insertions, 34 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/nand.h b/include/linux/mtd/nand.h
index 32f8612469d8..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
@@ -350,6 +342,84 @@ struct nand_onfi_vendor_micron {
350 u8 param_revision; 342 u8 param_revision;
351} __packed; 343} __packed;
352 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
353/** 423/**
354 * 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
355 * @lock: protection lock 425 * @lock: protection lock
@@ -418,7 +488,7 @@ struct nand_ecc_ctrl {
418 int (*read_page)(struct mtd_info *mtd, struct nand_chip *chip, 488 int (*read_page)(struct mtd_info *mtd, struct nand_chip *chip,
419 uint8_t *buf, int oob_required, int page); 489 uint8_t *buf, int oob_required, int page);
420 int (*read_subpage)(struct mtd_info *mtd, struct nand_chip *chip, 490 int (*read_subpage)(struct mtd_info *mtd, struct nand_chip *chip,
421 uint32_t offs, uint32_t len, uint8_t *buf); 491 uint32_t offs, uint32_t len, uint8_t *buf, int page);
422 int (*write_subpage)(struct mtd_info *mtd, struct nand_chip *chip, 492 int (*write_subpage)(struct mtd_info *mtd, struct nand_chip *chip,
423 uint32_t offset, uint32_t data_len, 493 uint32_t offset, uint32_t data_len,
424 const uint8_t *data_buf, int oob_required); 494 const uint8_t *data_buf, int oob_required);
@@ -435,17 +505,17 @@ struct nand_ecc_ctrl {
435 505
436/** 506/**
437 * struct nand_buffers - buffer structure for read/write 507 * struct nand_buffers - buffer structure for read/write
438 * @ecccalc: buffer for calculated ECC 508 * @ecccalc: buffer pointer for calculated ECC, size is oobsize.
439 * @ecccode: buffer for ECC read from flash 509 * @ecccode: buffer pointer for ECC read from flash, size is oobsize.
440 * @databuf: buffer for data - dynamically sized 510 * @databuf: buffer pointer for data, size is (page size + oobsize).
441 * 511 *
442 * 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
443 * consecutive order. 513 * consecutive order.
444 */ 514 */
445struct nand_buffers { 515struct nand_buffers {
446 uint8_t ecccalc[NAND_MAX_OOBSIZE]; 516 uint8_t *ecccalc;
447 uint8_t ecccode[NAND_MAX_OOBSIZE]; 517 uint8_t *ecccode;
448 uint8_t databuf[NAND_MAX_PAGESIZE + NAND_MAX_OOBSIZE]; 518 uint8_t *databuf;
449}; 519};
450 520
451/** 521/**
@@ -523,8 +593,12 @@ struct nand_buffers {
523 * @subpagesize: [INTERN] holds the subpagesize 593 * @subpagesize: [INTERN] holds the subpagesize
524 * @onfi_version: [INTERN] holds the chip ONFI version (BCD encoded), 594 * @onfi_version: [INTERN] holds the chip ONFI version (BCD encoded),
525 * 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.
526 * @onfi_params: [INTERN] holds the ONFI page parameter when ONFI is 598 * @onfi_params: [INTERN] holds the ONFI page parameter when ONFI is
527 * supported, 0 otherwise. 599 * supported, 0 otherwise.
600 * @jedec_params: [INTERN] holds the JEDEC parameter page when JEDEC is
601 * supported, 0 otherwise.
528 * @read_retries: [INTERN] the number of read retry modes supported 602 * @read_retries: [INTERN] the number of read retry modes supported
529 * @onfi_set_features: [REPLACEABLE] set the features for ONFI nand 603 * @onfi_set_features: [REPLACEABLE] set the features for ONFI nand
530 * @onfi_get_features: [REPLACEABLE] get the features for ONFI nand 604 * @onfi_get_features: [REPLACEABLE] get the features for ONFI nand
@@ -597,7 +671,11 @@ struct nand_chip {
597 int badblockbits; 671 int badblockbits;
598 672
599 int onfi_version; 673 int onfi_version;
600 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 };
601 679
602 int read_retries; 680 int read_retries;
603 681
@@ -840,4 +918,29 @@ static inline bool nand_is_slc(struct nand_chip *chip)
840{ 918{
841 return chip->bits_per_cell == 1; 919 return chip->bits_per_cell == 1;
842} 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}
843#endif /* __LINUX_MTD_NAND_H */ 946#endif /* __LINUX_MTD_NAND_H */
diff --git a/include/linux/of_mtd.h b/include/linux/of_mtd.h
index cb32d9c1e8dc..e266caa36402 100644
--- a/include/linux/of_mtd.h
+++ b/include/linux/of_mtd.h
@@ -13,6 +13,8 @@
13 13
14#include <linux/of.h> 14#include <linux/of.h>
15int of_get_nand_ecc_mode(struct device_node *np); 15int of_get_nand_ecc_mode(struct device_node *np);
16int of_get_nand_ecc_step_size(struct device_node *np);
17int of_get_nand_ecc_strength(struct device_node *np);
16int of_get_nand_bus_width(struct device_node *np); 18int of_get_nand_bus_width(struct device_node *np);
17bool of_get_nand_on_flash_bbt(struct device_node *np); 19bool of_get_nand_on_flash_bbt(struct device_node *np);
18 20
@@ -23,6 +25,16 @@ static inline int of_get_nand_ecc_mode(struct device_node *np)
23 return -ENOSYS; 25 return -ENOSYS;
24} 26}
25 27
28static inline int of_get_nand_ecc_step_size(struct device_node *np)
29{
30 return -ENOSYS;
31}
32
33static inline int of_get_nand_ecc_strength(struct device_node *np)
34{
35 return -ENOSYS;
36}
37
26static inline int of_get_nand_bus_width(struct device_node *np) 38static inline int of_get_nand_bus_width(struct device_node *np)
27{ 39{
28 return -ENOSYS; 40 return -ENOSYS;
diff --git a/include/linux/platform_data/elm.h b/include/linux/platform_data/elm.h
index bf0a83b7ed9d..4edb40676b3f 100644
--- a/include/linux/platform_data/elm.h
+++ b/include/linux/platform_data/elm.h
@@ -26,13 +26,6 @@ enum bch_ecc {
26/* ELM support 8 error syndrome process */ 26/* ELM support 8 error syndrome process */
27#define ERROR_VECTOR_MAX 8 27#define ERROR_VECTOR_MAX 8
28 28
29#define BCH8_ECC_OOB_BYTES 13
30#define BCH4_ECC_OOB_BYTES 7
31/* RBL requires 14 byte even though BCH8 uses only 13 byte */
32#define BCH8_SIZE (BCH8_ECC_OOB_BYTES + 1)
33/* Uses 1 extra byte to handle erased pages */
34#define BCH4_SIZE (BCH4_ECC_OOB_BYTES + 1)
35
36/** 29/**
37 * struct elm_errorvec - error vector for elm 30 * struct elm_errorvec - error vector for elm
38 * @error_reported: set true for vectors error is reported 31 * @error_reported: set true for vectors error is reported
@@ -50,5 +43,6 @@ struct elm_errorvec {
50 43
51void elm_decode_bch_error_page(struct device *dev, u8 *ecc_calc, 44void elm_decode_bch_error_page(struct device *dev, u8 *ecc_calc,
52 struct elm_errorvec *err_vec); 45 struct elm_errorvec *err_vec);
53int elm_config(struct device *dev, enum bch_ecc bch_type); 46int elm_config(struct device *dev, enum bch_ecc bch_type,
47 int ecc_steps, int ecc_step_size, int ecc_syndrome_size);
54#endif /* __ELM_H */ 48#endif /* __ELM_H */
diff --git a/include/linux/platform_data/mtd-nand-s3c2410.h b/include/linux/platform_data/mtd-nand-s3c2410.h
index b64115fa93a4..36bb92172f47 100644
--- a/include/linux/platform_data/mtd-nand-s3c2410.h
+++ b/include/linux/platform_data/mtd-nand-s3c2410.h
@@ -1,5 +1,4 @@
1/* arch/arm/mach-s3c2410/include/mach/nand.h 1/*
2 *
3 * Copyright (c) 2004 Simtec Electronics 2 * Copyright (c) 2004 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk> 3 * Ben Dooks <ben@simtec.co.uk>
5 * 4 *
@@ -10,6 +9,9 @@
10 * published by the Free Software Foundation. 9 * published by the Free Software Foundation.
11*/ 10*/
12 11
12#ifndef __MTD_NAND_S3C2410_H
13#define __MTD_NAND_S3C2410_H
14
13/** 15/**
14 * struct s3c2410_nand_set - define a set of one or more nand chips 16 * struct s3c2410_nand_set - define a set of one or more nand chips
15 * @disable_ecc: Entirely disable ECC - Dangerous 17 * @disable_ecc: Entirely disable ECC - Dangerous
@@ -65,3 +67,5 @@ struct s3c2410_platform_nand {
65 * it with the s3c_device_nand. This allows @nand to be __initdata. 67 * it with the s3c_device_nand. This allows @nand to be __initdata.
66*/ 68*/
67extern void s3c_nand_set_platdata(struct s3c2410_platform_nand *nand); 69extern void s3c_nand_set_platdata(struct s3c2410_platform_nand *nand);
70
71#endif /*__MTD_NAND_S3C2410_H */