@@ -998,13 +998,16 @@ static void denali_setup_dma(struct denali_nand_info *denali, int op)
998
998
* configuration details.
999
999
*/
1000
1000
static int write_page (struct mtd_info * mtd , struct nand_chip * chip ,
1001
- const uint8_t * buf , bool raw_xfer )
1001
+ const uint8_t * buf , int page , bool raw_xfer )
1002
1002
{
1003
1003
struct denali_nand_info * denali = mtd_to_denali (mtd );
1004
1004
dma_addr_t addr = denali -> buf .dma_buf ;
1005
1005
size_t size = mtd -> writesize + mtd -> oobsize ;
1006
1006
uint32_t irq_status ;
1007
1007
uint32_t irq_mask = INTR__DMA_CMD_COMP | INTR__PROGRAM_FAIL ;
1008
+ int ret = 0 ;
1009
+
1010
+ denali -> page = page ;
1008
1011
1009
1012
/*
1010
1013
* if it is a raw xfer, we want to disable ecc and send the spare area.
@@ -1036,13 +1039,13 @@ static int write_page(struct mtd_info *mtd, struct nand_chip *chip,
1036
1039
if (irq_status == 0 ) {
1037
1040
dev_err (denali -> dev , "timeout on write_page (type = %d)\n" ,
1038
1041
raw_xfer );
1039
- denali -> status = NAND_STATUS_FAIL ;
1042
+ ret = - EIO ;
1040
1043
}
1041
1044
1042
1045
denali_enable_dma (denali , false);
1043
1046
dma_sync_single_for_cpu (denali -> dev , addr , size , DMA_TO_DEVICE );
1044
1047
1045
- return 0 ;
1048
+ return ret ;
1046
1049
}
1047
1050
1048
1051
/* NAND core entry points */
@@ -1059,7 +1062,7 @@ static int denali_write_page(struct mtd_info *mtd, struct nand_chip *chip,
1059
1062
* for regular page writes, we let HW handle all the ECC
1060
1063
* data written to the device.
1061
1064
*/
1062
- return write_page (mtd , chip , buf , false);
1065
+ return write_page (mtd , chip , buf , page , false);
1063
1066
}
1064
1067
1065
1068
/*
@@ -1075,7 +1078,7 @@ static int denali_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
1075
1078
* for raw page writes, we want to disable ECC and simply write
1076
1079
* whatever data is in the buffer.
1077
1080
*/
1078
- return write_page (mtd , chip , buf , true);
1081
+ return write_page (mtd , chip , buf , page , true);
1079
1082
}
1080
1083
1081
1084
static int denali_write_oob (struct mtd_info * mtd , struct nand_chip * chip ,
@@ -1105,12 +1108,7 @@ static int denali_read_page(struct mtd_info *mtd, struct nand_chip *chip,
1105
1108
unsigned long uncor_ecc_flags = 0 ;
1106
1109
int stat = 0 ;
1107
1110
1108
- if (page != denali -> page ) {
1109
- dev_err (denali -> dev ,
1110
- "IN %s: page %d is not equal to denali->page %d" ,
1111
- __func__ , page , denali -> page );
1112
- BUG ();
1113
- }
1111
+ denali -> page = page ;
1114
1112
1115
1113
setup_ecc_for_xfer (denali , true, false);
1116
1114
@@ -1154,12 +1152,7 @@ static int denali_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
1154
1152
size_t size = mtd -> writesize + mtd -> oobsize ;
1155
1153
uint32_t irq_mask = INTR__DMA_CMD_COMP ;
1156
1154
1157
- if (page != denali -> page ) {
1158
- dev_err (denali -> dev ,
1159
- "IN %s: page %d is not equal to denali->page %d" ,
1160
- __func__ , page , denali -> page );
1161
- BUG ();
1162
- }
1155
+ denali -> page = page ;
1163
1156
1164
1157
setup_ecc_for_xfer (denali , false, true);
1165
1158
denali_enable_dma (denali , true);
@@ -1204,12 +1197,7 @@ static void denali_select_chip(struct mtd_info *mtd, int chip)
1204
1197
1205
1198
static int denali_waitfunc (struct mtd_info * mtd , struct nand_chip * chip )
1206
1199
{
1207
- struct denali_nand_info * denali = mtd_to_denali (mtd );
1208
- int status = denali -> status ;
1209
-
1210
- denali -> status = 0 ;
1211
-
1212
- return status ;
1200
+ return 0 ;
1213
1201
}
1214
1202
1215
1203
static int denali_erase (struct mtd_info * mtd , int page )
@@ -1238,8 +1226,6 @@ static void denali_cmdfunc(struct mtd_info *mtd, unsigned int cmd, int col,
1238
1226
int i ;
1239
1227
1240
1228
switch (cmd ) {
1241
- case NAND_CMD_PAGEPROG :
1242
- break ;
1243
1229
case NAND_CMD_STATUS :
1244
1230
read_status (denali );
1245
1231
break ;
@@ -1259,10 +1245,6 @@ static void denali_cmdfunc(struct mtd_info *mtd, unsigned int cmd, int col,
1259
1245
write_byte_to_buf (denali , id );
1260
1246
}
1261
1247
break ;
1262
- case NAND_CMD_READ0 :
1263
- case NAND_CMD_SEQIN :
1264
- denali -> page = page ;
1265
- break ;
1266
1248
case NAND_CMD_RESET :
1267
1249
reset_bank (denali );
1268
1250
break ;
@@ -1605,6 +1587,7 @@ int denali_init(struct denali_nand_info *denali)
1605
1587
1606
1588
mtd_set_ooblayout (mtd , & denali_ooblayout_ops );
1607
1589
1590
+ chip -> ecc .options |= NAND_ECC_CUSTOM_PAGE_ACCESS ;
1608
1591
chip -> ecc .read_page = denali_read_page ;
1609
1592
chip -> ecc .read_page_raw = denali_read_page_raw ;
1610
1593
chip -> ecc .write_page = denali_write_page ;
0 commit comments