128-1-mtd-nand-store-timing-in-nand_chip.patch 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. --- a/drivers/mtd/nand/nand_base.c
  2. +++ b/drivers/mtd/nand/nand_base.c
  3. @@ -4249,6 +4249,8 @@ static inline bool is_full_id_nand(struc
  4. static bool find_full_id_nand(struct mtd_info *mtd, struct nand_chip *chip,
  5. struct nand_flash_dev *type, const u8 *id_data, int *busw)
  6. {
  7. + int mode;
  8. +
  9. if (!strncmp(type->id, id_data, type->id_len)) {
  10. mtd->writesize = type->pagesize;
  11. mtd->erasesize = type->erasesize;
  12. @@ -4259,8 +4261,9 @@ static bool find_full_id_nand(struct mtd
  13. chip->options |= type->options;
  14. chip->ecc_strength_ds = NAND_ECC_STRENGTH(type);
  15. chip->ecc_step_ds = NAND_ECC_STEP(type);
  16. - chip->onfi_timing_mode_default =
  17. - type->onfi_timing_mode_default;
  18. +
  19. + mode = type->onfi_timing_mode_default;
  20. + chip->sdr_timings = onfi_async_timing_mode_to_sdr_timings(mode);
  21. *busw = type->options & NAND_BUSWIDTH_16;
  22. --- a/drivers/mtd/nand/sunxi_nand.c
  23. +++ b/drivers/mtd/nand/sunxi_nand.c
  24. @@ -1425,7 +1425,7 @@ static int sunxi_nand_chip_init_timings(
  25. mode = onfi_get_async_timing_mode(&chip->nand);
  26. if (mode == ONFI_TIMING_MODE_UNKNOWN) {
  27. - mode = chip->nand.onfi_timing_mode_default;
  28. + timings = chip->nand.sdr_timings;
  29. } else {
  30. uint8_t feature[ONFI_SUBFEATURE_PARAM_LEN] = {};
  31. @@ -1439,9 +1439,10 @@ static int sunxi_nand_chip_init_timings(
  32. feature);
  33. if (ret)
  34. return ret;
  35. +
  36. + timings = onfi_async_timing_mode_to_sdr_timings(mode);
  37. }
  38. - timings = onfi_async_timing_mode_to_sdr_timings(mode);
  39. if (IS_ERR(timings))
  40. return PTR_ERR(timings);
  41. --- a/include/linux/mtd/nand.h
  42. +++ b/include/linux/mtd/nand.h
  43. @@ -612,6 +612,55 @@ struct nand_buffers {
  44. uint8_t *databuf;
  45. };
  46. +/*
  47. + * struct nand_sdr_timings - SDR NAND chip timings
  48. + *
  49. + * This struct defines the timing requirements of a SDR NAND chip.
  50. + * These informations can be found in every NAND datasheets and the timings
  51. + * meaning are described in the ONFI specifications:
  52. + * www.onfi.org/~/media/ONFI/specs/onfi_3_1_spec.pdf (chapter 4.15 Timing
  53. + * Parameters)
  54. + *
  55. + * All these timings are expressed in picoseconds.
  56. + */
  57. +
  58. +struct nand_sdr_timings {
  59. + u32 tALH_min;
  60. + u32 tADL_min;
  61. + u32 tALS_min;
  62. + u32 tAR_min;
  63. + u32 tCEA_max;
  64. + u32 tCEH_min;
  65. + u32 tCH_min;
  66. + u32 tCHZ_max;
  67. + u32 tCLH_min;
  68. + u32 tCLR_min;
  69. + u32 tCLS_min;
  70. + u32 tCOH_min;
  71. + u32 tCS_min;
  72. + u32 tDH_min;
  73. + u32 tDS_min;
  74. + u32 tFEAT_max;
  75. + u32 tIR_min;
  76. + u32 tITC_max;
  77. + u32 tRC_min;
  78. + u32 tREA_max;
  79. + u32 tREH_min;
  80. + u32 tRHOH_min;
  81. + u32 tRHW_min;
  82. + u32 tRHZ_max;
  83. + u32 tRLOH_min;
  84. + u32 tRP_min;
  85. + u32 tRR_min;
  86. + u64 tRST_max;
  87. + u32 tWB_max;
  88. + u32 tWC_min;
  89. + u32 tWH_min;
  90. + u32 tWHR_min;
  91. + u32 tWP_min;
  92. + u32 tWW_min;
  93. +};
  94. +
  95. /**
  96. * struct nand_chip - NAND Private Flash Chip Data
  97. * @IO_ADDR_R: [BOARDSPECIFIC] address to read the 8 I/O lines of the
  98. @@ -676,11 +725,7 @@ struct nand_buffers {
  99. * @ecc_step_ds: [INTERN] ECC step required by the @ecc_strength_ds,
  100. * also from the datasheet. It is the recommended ECC step
  101. * size, if known; if unknown, set to zero.
  102. - * @onfi_timing_mode_default: [INTERN] default ONFI timing mode. This field is
  103. - * either deduced from the datasheet if the NAND
  104. - * chip is not ONFI compliant or set to 0 if it is
  105. - * (an ONFI chip is always configured in mode 0
  106. - * after a NAND reset)
  107. + * @sdr_timings [INTERN] Pointer to default timings for SDR NAND.
  108. * @numchips: [INTERN] number of physical chips
  109. * @chipsize: [INTERN] the size of one chip for multichip arrays
  110. * @pagemask: [INTERN] page number mask = number of (pages / chip) - 1
  111. @@ -769,7 +814,7 @@ struct nand_chip {
  112. uint8_t bits_per_cell;
  113. uint16_t ecc_strength_ds;
  114. uint16_t ecc_step_ds;
  115. - int onfi_timing_mode_default;
  116. + const struct nand_sdr_timings *sdr_timings;
  117. int badblockpos;
  118. int badblockbits;
  119. @@ -1156,55 +1201,6 @@ struct ofnandpart_data {
  120. int ofnandpart_parse(struct mtd_info *master,
  121. const struct ofnandpart_data *data);
  122. -/*
  123. - * struct nand_sdr_timings - SDR NAND chip timings
  124. - *
  125. - * This struct defines the timing requirements of a SDR NAND chip.
  126. - * These informations can be found in every NAND datasheets and the timings
  127. - * meaning are described in the ONFI specifications:
  128. - * www.onfi.org/~/media/ONFI/specs/onfi_3_1_spec.pdf (chapter 4.15 Timing
  129. - * Parameters)
  130. - *
  131. - * All these timings are expressed in picoseconds.
  132. - */
  133. -
  134. -struct nand_sdr_timings {
  135. - u32 tALH_min;
  136. - u32 tADL_min;
  137. - u32 tALS_min;
  138. - u32 tAR_min;
  139. - u32 tCEA_max;
  140. - u32 tCEH_min;
  141. - u32 tCH_min;
  142. - u32 tCHZ_max;
  143. - u32 tCLH_min;
  144. - u32 tCLR_min;
  145. - u32 tCLS_min;
  146. - u32 tCOH_min;
  147. - u32 tCS_min;
  148. - u32 tDH_min;
  149. - u32 tDS_min;
  150. - u32 tFEAT_max;
  151. - u32 tIR_min;
  152. - u32 tITC_max;
  153. - u32 tRC_min;
  154. - u32 tREA_max;
  155. - u32 tREH_min;
  156. - u32 tRHOH_min;
  157. - u32 tRHW_min;
  158. - u32 tRHZ_max;
  159. - u32 tRLOH_min;
  160. - u32 tRP_min;
  161. - u32 tRR_min;
  162. - u64 tRST_max;
  163. - u32 tWB_max;
  164. - u32 tWC_min;
  165. - u32 tWH_min;
  166. - u32 tWHR_min;
  167. - u32 tWP_min;
  168. - u32 tWW_min;
  169. -};
  170. -
  171. /* get timing characteristics from ONFI timing mode. */
  172. const struct nand_sdr_timings *onfi_async_timing_mode_to_sdr_timings(int mode);
  173. #endif /* __LINUX_MTD_NAND_H */