hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/rkflash/sfc_nand.c
....@@ -112,11 +112,7 @@
112112 /* HYF2GQ4UHCCAE */
113113 { 0xC9, 0x5A, 0x00, 4, 0x40, 1, 2048, 0x4C, 19, 0xE, 1, { 0x04, 0x24, 0xFF, 0xFF }, &sfc_nand_get_ecc_status0 },
114114 /* HYF4GQ4UAACBE */
115
- { 0xC9, 0xD4, 0x00, 8, 0x40, 1, 2048, 0x4C, 20, 0xE, 1, { 0x20, 0x40, 0x24, 0x44 }, &sfc_nand_get_ecc_status0 },
116
- /* HYF2GQ4IAACAE */
117
- { 0xC9, 0x82, 0x00, 4, 0x40, 1, 2048, 0x4C, 20, 0xE, 1, { 0x04, 0x24, 0xFF, 0xFF }, &sfc_nand_get_ecc_status0 },
118
- /* HYF1GQ4IDACAE */
119
- { 0xC9, 0x81, 0x00, 4, 0x40, 1, 1024, 0x4C, 20, 0x4, 1, { 0x04, 0x14, 0xFF, 0xFF }, &sfc_nand_get_ecc_status0 },
115
+ { 0xC9, 0xD4, 0x00, 8, 0x40, 1, 2048, 0x4C, 20, 0x4, 1, { 0x20, 0x40, 0x24, 0x44 }, &sfc_nand_get_ecc_status0 },
120116
121117 /* FS35ND01G-S1 */
122118 { 0xCD, 0xB1, 0x00, 4, 0x40, 1, 1024, 0x0C, 18, 0x4, 1, { 0x10, 0x14, 0xFF, 0xFF }, &sfc_nand_get_ecc_status5 },
....@@ -153,10 +149,6 @@
153149 { 0xE5, 0xF4, 0x00, 4, 0x40, 2, 2048, 0x0C, 20, 0x8, 1, { 0x04, 0x14, 0xFF, 0xFF }, &sfc_nand_get_ecc_status6 },
154150 /* DS35M1GB-IB */
155151 { 0xE5, 0xA1, 0x00, 4, 0x40, 1, 1024, 0x0C, 18, 0x8, 1, { 0x04, 0x14, 0xFF, 0xFF }, &sfc_nand_get_ecc_status6 },
156
- /* DS35Q12B-IB */
157
- { 0xE5, 0xF5, 0x00, 4, 0x40, 1, 512, 0x0C, 17, 0x8, 1, { 0x04, 0x14, 0xFF, 0xFF }, &sfc_nand_get_ecc_status6 },
158
- /* DS35M12B-IB */
159
- { 0xE5, 0xA5, 0x00, 4, 0x40, 1, 512, 0x0C, 17, 0x8, 1, { 0x04, 0x14, 0xFF, 0xFF }, &sfc_nand_get_ecc_status6 },
160152
161153 /* EM73C044VCC-H */
162154 { 0xD5, 0x22, 0x00, 4, 0x40, 1, 1024, 0x0C, 18, 0x8, 1, { 0x04, 0x14, 0xFF, 0xFF }, &sfc_nand_get_ecc_status0 },
....@@ -214,16 +206,10 @@
214206 { 0xEA, 0xC1, 0x00, 4, 0x40, 1, 1024, 0x0C, 18, 0x4, 1, { 0x04, 0x08, 0xFF, 0xFF }, &sfc_nand_get_ecc_status1 },
215207 /* TX25G01 */
216208 { 0xA1, 0xF1, 0x00, 4, 0x40, 1, 1024, 0x0C, 18, 0x4, 1, { 0x04, 0x14, 0xFF, 0xFF }, &sfc_nand_get_ecc_status8 },
217
- /* ANV1GCP0CLG, HYF1GQ4UTXCAE */
218
- { 0x01, 0x15, 0x00, 4, 0x40, 1, 1024, 0x4C, 18, 0x4, 0, { 0x04, 0x08, 0xFF, 0xFF }, &sfc_nand_get_ecc_status9 },
219
- /* S35ML02G3, ANV1GCP0CLG */
220
- { 0x01, 0x25, 0x00, 4, 0x40, 2, 1024, 0x4C, 19, 0x4, 0, { 0x04, 0x08, 0x0C, 0x10 }, &sfc_nand_get_ecc_status9 },
209
+ /* S35ML02G3 */
210
+ { 0x01, 0x25, 0x00, 4, 0x40, 2, 1024, 0x4C, 19, 0x4, 1, { 0x04, 0x08, 0x0C, 0x10 }, &sfc_nand_get_ecc_status9 },
221211 /* S35ML04G3 */
222
- { 0x01, 0x35, 0x00, 4, 0x40, 2, 2048, 0x4C, 20, 0x4, 0, { 0x04, 0x08, 0x0C, 0x10 }, &sfc_nand_get_ecc_status9 },
223
- /* GSS01GSAK1 */
224
- { 0x52, 0xBA, 0x13, 4, 0x40, 1, 1024, 0x4C, 18, 0x4, 0, { 0x04, 0x08, 0xFF, 0xFF }, &sfc_nand_get_ecc_status1 },
225
- /* GSS02GSAK1 */
226
- { 0x52, 0xBA, 0x23, 4, 0x40, 1, 2048, 0x4C, 19, 0x4, 0, { 0x04, 0x08, 0xFF, 0xFF }, &sfc_nand_get_ecc_status1 },
212
+ { 0x01, 0x35, 0x00, 4, 0x40, 2, 2048, 0x4C, 20, 0x4, 1, { 0x04, 0x08, 0x0C, 0x10 }, &sfc_nand_get_ecc_status9 },
227213 };
228214
229215 static struct nand_info *p_nand_info;
....@@ -325,7 +311,7 @@
325311 return ret;
326312 }
327313
328
-static int sfc_nand_wait_busy(u8 *data, int timeout)
314
+static int sfc_nand_wait_busy_sleep(u8 *data, int timeout, int sleep_us)
329315 {
330316 int ret;
331317 int i;
....@@ -333,7 +319,9 @@
333319
334320 *data = 0;
335321
336
- for (i = 0; i < timeout; i++) {
322
+ for (i = 0; i < timeout; i += sleep_us) {
323
+ usleep_range(sleep_us, sleep_us + 50);
324
+
337325 ret = sfc_nand_read_feature(0xC0, &status);
338326
339327 if (ret != SFC_OK)
....@@ -343,8 +331,6 @@
343331
344332 if (!(status & (1 << 0)))
345333 return SFC_OK;
346
-
347
- sfc_delay(1);
348334 }
349335
350336 return SFC_NAND_WAIT_TIME_OUT;
....@@ -808,7 +794,7 @@
808794 if (ret != SFC_OK)
809795 return ret;
810796
811
- ret = sfc_nand_wait_busy(&status, 1000 * 1000);
797
+ ret = sfc_nand_wait_busy_sleep(&status, 1000 * 1000, 1000);
812798
813799 if (status & (1 << 2))
814800 return SFC_NAND_PROG_ERASE_ERROR;
....@@ -865,6 +851,7 @@
865851 op.sfctrl.d32 = 0;
866852 op.sfctrl.b.datalines = sfc_nand_dev.prog_lines;
867853 op.sfctrl.b.addrbits = 16;
854
+ op.sfctrl.b.enbledma = 0;
868855 plane = p_nand_info->plane_per_die == 2 ? ((addr >> 6) & 0x1) << 12 : 0;
869856 sfc_request(&op, plane, p_page_buf, page_size);
870857
....@@ -877,7 +864,7 @@
877864 if (p_nand_info->id0 == MID_GIGADEV) {
878865 sfc_nand_read_cache(addr, (u32 *)sfc_nand_dev.recheck_buffer, 0, data_area_size);
879866 if (memcmp(sfc_nand_dev.recheck_buffer, p_page_buf, data_area_size)) {
880
- rkflash_print_error("%s %x cache bitflip\n", __func__, addr);
867
+ rkflash_print_error("%s cache bitflip1\n", __func__);
881868 msleep(1000);
882869 sfc_request(&op, plane, p_page_buf, page_size);
883870 }
....@@ -894,7 +881,8 @@
894881 if (ret != SFC_OK)
895882 return ret;
896883
897
- ret = sfc_nand_wait_busy(&status, 1000 * 1000);
884
+ ret = sfc_nand_wait_busy_sleep(&status, 1000 * 1000, 200);
885
+
898886 if (status & (1 << 3))
899887 return SFC_NAND_PROG_ERASE_ERROR;
900888
....@@ -945,9 +933,9 @@
945933 sfc_get_version() < SFC_VER_3)
946934 sfc_nand_rw_preset();
947935
948
- sfc_nand_wait_busy(&status, 1000 * 1000);
936
+ sfc_nand_wait_busy_sleep(&status, 1000 * 1000, 50);
949937 if (sfc_nand_dev.manufacturer == 0x01 && status)
950
- sfc_nand_wait_busy(&status, 1000 * 1000);
938
+ sfc_nand_wait_busy_sleep(&status, 1000 * 1000, 50);
951939
952940 ecc_result = p_nand_info->ecc_status();
953941
....@@ -959,6 +947,7 @@
959947 op.sfctrl.d32 = 0;
960948 op.sfctrl.b.datalines = sfc_nand_dev.read_lines;
961949 op.sfctrl.b.addrbits = 16;
950
+ op.sfctrl.b.enbledma = 0;
962951
963952 plane = p_nand_info->plane_per_die == 2 ? ((row >> 6) & 0x1) << 12 : 0;
964953 ret = sfc_request(&op, plane | column, p_page_buf, len);
....@@ -983,7 +972,9 @@
983972 u32 sec_per_page = p_nand_info->sec_per_page;
984973 u32 data_size = sec_per_page * SFC_NAND_SECTOR_SIZE;
985974 struct nand_mega_area *meta = &p_nand_info->meta;
975
+ int retries = 0;
986976
977
+retry:
987978 ret = sfc_nand_read_page_raw(cs, addr, gp_page_buf);
988979 memcpy(p_data, gp_page_buf, data_size);
989980 p_spare[0] = gp_page_buf[(data_size + meta->off0) / 4];
....@@ -1005,6 +996,10 @@
1005996
1006997 if (p_spare)
1007998 rkflash_print_hex("spare:", p_spare, 4, 2);
999
+ if (ret == SFC_NAND_ECC_ERROR && retries < 1) {
1000
+ retries++;
1001
+ goto retry;
1002
+ }
10081003 }
10091004
10101005 return ret;