diff options
author | Jaiprakash Singh <b44839@freescale.com> | 2015-05-20 22:17:11 -0400 |
---|---|---|
committer | Scott Wood <scottwood@freescale.com> | 2015-08-07 23:59:34 -0400 |
commit | cf184dc2dd33847f4b211b01d8c7ec0526e6c5e4 (patch) | |
tree | fc8bfced6f839edc21c9548d81697f7de17cdf86 /drivers/mtd/nand/fsl_ifc_nand.c | |
parent | 3fa647bff31fe7b8818a40742506d47d0dc7f8f5 (diff) |
fsl_ifc: Change IO accessor based on endianness
IFC IO accressor are set at run time based
on IFC IP registers endianness.IFC node in
DTS file contains information about
endianness.
Signed-off-by: Jaiprakash Singh <b44839@freescale.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
Acked-by: Brian Norris <computersforpeace@gmail.com>
Diffstat (limited to 'drivers/mtd/nand/fsl_ifc_nand.c')
-rw-r--r-- | drivers/mtd/nand/fsl_ifc_nand.c | 258 |
1 files changed, 130 insertions, 128 deletions
diff --git a/drivers/mtd/nand/fsl_ifc_nand.c b/drivers/mtd/nand/fsl_ifc_nand.c index 51394e59901b..a4e27e891153 100644 --- a/drivers/mtd/nand/fsl_ifc_nand.c +++ b/drivers/mtd/nand/fsl_ifc_nand.c | |||
@@ -238,8 +238,8 @@ static void set_addr(struct mtd_info *mtd, int column, int page_addr, int oob) | |||
238 | 238 | ||
239 | ifc_nand_ctrl->page = page_addr; | 239 | ifc_nand_ctrl->page = page_addr; |
240 | /* Program ROW0/COL0 */ | 240 | /* Program ROW0/COL0 */ |
241 | iowrite32be(page_addr, &ifc->ifc_nand.row0); | 241 | ifc_out32(page_addr, &ifc->ifc_nand.row0); |
242 | iowrite32be((oob ? IFC_NAND_COL_MS : 0) | column, &ifc->ifc_nand.col0); | 242 | ifc_out32((oob ? IFC_NAND_COL_MS : 0) | column, &ifc->ifc_nand.col0); |
243 | 243 | ||
244 | buf_num = page_addr & priv->bufnum_mask; | 244 | buf_num = page_addr & priv->bufnum_mask; |
245 | 245 | ||
@@ -301,19 +301,19 @@ static void fsl_ifc_run_command(struct mtd_info *mtd) | |||
301 | int i; | 301 | int i; |
302 | 302 | ||
303 | /* set the chip select for NAND Transaction */ | 303 | /* set the chip select for NAND Transaction */ |
304 | iowrite32be(priv->bank << IFC_NAND_CSEL_SHIFT, | 304 | ifc_out32(priv->bank << IFC_NAND_CSEL_SHIFT, |
305 | &ifc->ifc_nand.nand_csel); | 305 | &ifc->ifc_nand.nand_csel); |
306 | 306 | ||
307 | dev_vdbg(priv->dev, | 307 | dev_vdbg(priv->dev, |
308 | "%s: fir0=%08x fcr0=%08x\n", | 308 | "%s: fir0=%08x fcr0=%08x\n", |
309 | __func__, | 309 | __func__, |
310 | ioread32be(&ifc->ifc_nand.nand_fir0), | 310 | ifc_in32(&ifc->ifc_nand.nand_fir0), |
311 | ioread32be(&ifc->ifc_nand.nand_fcr0)); | 311 | ifc_in32(&ifc->ifc_nand.nand_fcr0)); |
312 | 312 | ||
313 | ctrl->nand_stat = 0; | 313 | ctrl->nand_stat = 0; |
314 | 314 | ||
315 | /* start read/write seq */ | 315 | /* start read/write seq */ |
316 | iowrite32be(IFC_NAND_SEQ_STRT_FIR_STRT, &ifc->ifc_nand.nandseq_strt); | 316 | ifc_out32(IFC_NAND_SEQ_STRT_FIR_STRT, &ifc->ifc_nand.nandseq_strt); |
317 | 317 | ||
318 | /* wait for command complete flag or timeout */ | 318 | /* wait for command complete flag or timeout */ |
319 | wait_event_timeout(ctrl->nand_wait, ctrl->nand_stat, | 319 | wait_event_timeout(ctrl->nand_wait, ctrl->nand_stat, |
@@ -336,7 +336,7 @@ static void fsl_ifc_run_command(struct mtd_info *mtd) | |||
336 | int sector_end = sector + chip->ecc.steps - 1; | 336 | int sector_end = sector + chip->ecc.steps - 1; |
337 | 337 | ||
338 | for (i = sector / 4; i <= sector_end / 4; i++) | 338 | for (i = sector / 4; i <= sector_end / 4; i++) |
339 | eccstat[i] = ioread32be(&ifc->ifc_nand.nand_eccstat[i]); | 339 | eccstat[i] = ifc_in32(&ifc->ifc_nand.nand_eccstat[i]); |
340 | 340 | ||
341 | for (i = sector; i <= sector_end; i++) { | 341 | for (i = sector; i <= sector_end; i++) { |
342 | errors = check_read_ecc(mtd, ctrl, eccstat, i); | 342 | errors = check_read_ecc(mtd, ctrl, eccstat, i); |
@@ -376,33 +376,33 @@ static void fsl_ifc_do_read(struct nand_chip *chip, | |||
376 | 376 | ||
377 | /* Program FIR/IFC_NAND_FCR0 for Small/Large page */ | 377 | /* Program FIR/IFC_NAND_FCR0 for Small/Large page */ |
378 | if (mtd->writesize > 512) { | 378 | if (mtd->writesize > 512) { |
379 | iowrite32be((IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) | | 379 | ifc_out32((IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) | |
380 | (IFC_FIR_OP_CA0 << IFC_NAND_FIR0_OP1_SHIFT) | | 380 | (IFC_FIR_OP_CA0 << IFC_NAND_FIR0_OP1_SHIFT) | |
381 | (IFC_FIR_OP_RA0 << IFC_NAND_FIR0_OP2_SHIFT) | | 381 | (IFC_FIR_OP_RA0 << IFC_NAND_FIR0_OP2_SHIFT) | |
382 | (IFC_FIR_OP_CMD1 << IFC_NAND_FIR0_OP3_SHIFT) | | 382 | (IFC_FIR_OP_CMD1 << IFC_NAND_FIR0_OP3_SHIFT) | |
383 | (IFC_FIR_OP_RBCD << IFC_NAND_FIR0_OP4_SHIFT), | 383 | (IFC_FIR_OP_RBCD << IFC_NAND_FIR0_OP4_SHIFT), |
384 | &ifc->ifc_nand.nand_fir0); | 384 | &ifc->ifc_nand.nand_fir0); |
385 | iowrite32be(0x0, &ifc->ifc_nand.nand_fir1); | 385 | ifc_out32(0x0, &ifc->ifc_nand.nand_fir1); |
386 | 386 | ||
387 | iowrite32be((NAND_CMD_READ0 << IFC_NAND_FCR0_CMD0_SHIFT) | | 387 | ifc_out32((NAND_CMD_READ0 << IFC_NAND_FCR0_CMD0_SHIFT) | |
388 | (NAND_CMD_READSTART << IFC_NAND_FCR0_CMD1_SHIFT), | 388 | (NAND_CMD_READSTART << IFC_NAND_FCR0_CMD1_SHIFT), |
389 | &ifc->ifc_nand.nand_fcr0); | 389 | &ifc->ifc_nand.nand_fcr0); |
390 | } else { | 390 | } else { |
391 | iowrite32be((IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) | | 391 | ifc_out32((IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) | |
392 | (IFC_FIR_OP_CA0 << IFC_NAND_FIR0_OP1_SHIFT) | | 392 | (IFC_FIR_OP_CA0 << IFC_NAND_FIR0_OP1_SHIFT) | |
393 | (IFC_FIR_OP_RA0 << IFC_NAND_FIR0_OP2_SHIFT) | | 393 | (IFC_FIR_OP_RA0 << IFC_NAND_FIR0_OP2_SHIFT) | |
394 | (IFC_FIR_OP_RBCD << IFC_NAND_FIR0_OP3_SHIFT), | 394 | (IFC_FIR_OP_RBCD << IFC_NAND_FIR0_OP3_SHIFT), |
395 | &ifc->ifc_nand.nand_fir0); | 395 | &ifc->ifc_nand.nand_fir0); |
396 | iowrite32be(0x0, &ifc->ifc_nand.nand_fir1); | 396 | ifc_out32(0x0, &ifc->ifc_nand.nand_fir1); |
397 | 397 | ||
398 | if (oob) | 398 | if (oob) |
399 | iowrite32be(NAND_CMD_READOOB << | 399 | ifc_out32(NAND_CMD_READOOB << |
400 | IFC_NAND_FCR0_CMD0_SHIFT, | 400 | IFC_NAND_FCR0_CMD0_SHIFT, |
401 | &ifc->ifc_nand.nand_fcr0); | 401 | &ifc->ifc_nand.nand_fcr0); |
402 | else | 402 | else |
403 | iowrite32be(NAND_CMD_READ0 << | 403 | ifc_out32(NAND_CMD_READ0 << |
404 | IFC_NAND_FCR0_CMD0_SHIFT, | 404 | IFC_NAND_FCR0_CMD0_SHIFT, |
405 | &ifc->ifc_nand.nand_fcr0); | 405 | &ifc->ifc_nand.nand_fcr0); |
406 | } | 406 | } |
407 | } | 407 | } |
408 | 408 | ||
@@ -422,7 +422,7 @@ static void fsl_ifc_cmdfunc(struct mtd_info *mtd, unsigned int command, | |||
422 | switch (command) { | 422 | switch (command) { |
423 | /* READ0 read the entire buffer to use hardware ECC. */ | 423 | /* READ0 read the entire buffer to use hardware ECC. */ |
424 | case NAND_CMD_READ0: | 424 | case NAND_CMD_READ0: |
425 | iowrite32be(0, &ifc->ifc_nand.nand_fbcr); | 425 | ifc_out32(0, &ifc->ifc_nand.nand_fbcr); |
426 | set_addr(mtd, 0, page_addr, 0); | 426 | set_addr(mtd, 0, page_addr, 0); |
427 | 427 | ||
428 | ifc_nand_ctrl->read_bytes = mtd->writesize + mtd->oobsize; | 428 | ifc_nand_ctrl->read_bytes = mtd->writesize + mtd->oobsize; |
@@ -437,7 +437,7 @@ static void fsl_ifc_cmdfunc(struct mtd_info *mtd, unsigned int command, | |||
437 | 437 | ||
438 | /* READOOB reads only the OOB because no ECC is performed. */ | 438 | /* READOOB reads only the OOB because no ECC is performed. */ |
439 | case NAND_CMD_READOOB: | 439 | case NAND_CMD_READOOB: |
440 | iowrite32be(mtd->oobsize - column, &ifc->ifc_nand.nand_fbcr); | 440 | ifc_out32(mtd->oobsize - column, &ifc->ifc_nand.nand_fbcr); |
441 | set_addr(mtd, column, page_addr, 1); | 441 | set_addr(mtd, column, page_addr, 1); |
442 | 442 | ||
443 | ifc_nand_ctrl->read_bytes = mtd->writesize + mtd->oobsize; | 443 | ifc_nand_ctrl->read_bytes = mtd->writesize + mtd->oobsize; |
@@ -453,19 +453,19 @@ static void fsl_ifc_cmdfunc(struct mtd_info *mtd, unsigned int command, | |||
453 | if (command == NAND_CMD_PARAM) | 453 | if (command == NAND_CMD_PARAM) |
454 | timing = IFC_FIR_OP_RBCD; | 454 | timing = IFC_FIR_OP_RBCD; |
455 | 455 | ||
456 | iowrite32be((IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) | | 456 | ifc_out32((IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) | |
457 | (IFC_FIR_OP_UA << IFC_NAND_FIR0_OP1_SHIFT) | | 457 | (IFC_FIR_OP_UA << IFC_NAND_FIR0_OP1_SHIFT) | |
458 | (timing << IFC_NAND_FIR0_OP2_SHIFT), | 458 | (timing << IFC_NAND_FIR0_OP2_SHIFT), |
459 | &ifc->ifc_nand.nand_fir0); | 459 | &ifc->ifc_nand.nand_fir0); |
460 | iowrite32be(command << IFC_NAND_FCR0_CMD0_SHIFT, | 460 | ifc_out32(command << IFC_NAND_FCR0_CMD0_SHIFT, |
461 | &ifc->ifc_nand.nand_fcr0); | 461 | &ifc->ifc_nand.nand_fcr0); |
462 | iowrite32be(column, &ifc->ifc_nand.row3); | 462 | ifc_out32(column, &ifc->ifc_nand.row3); |
463 | 463 | ||
464 | /* | 464 | /* |
465 | * although currently it's 8 bytes for READID, we always read | 465 | * although currently it's 8 bytes for READID, we always read |
466 | * the maximum 256 bytes(for PARAM) | 466 | * the maximum 256 bytes(for PARAM) |
467 | */ | 467 | */ |
468 | iowrite32be(256, &ifc->ifc_nand.nand_fbcr); | 468 | ifc_out32(256, &ifc->ifc_nand.nand_fbcr); |
469 | ifc_nand_ctrl->read_bytes = 256; | 469 | ifc_nand_ctrl->read_bytes = 256; |
470 | 470 | ||
471 | set_addr(mtd, 0, 0, 0); | 471 | set_addr(mtd, 0, 0, 0); |
@@ -480,16 +480,16 @@ static void fsl_ifc_cmdfunc(struct mtd_info *mtd, unsigned int command, | |||
480 | 480 | ||
481 | /* ERASE2 uses the block and page address from ERASE1 */ | 481 | /* ERASE2 uses the block and page address from ERASE1 */ |
482 | case NAND_CMD_ERASE2: | 482 | case NAND_CMD_ERASE2: |
483 | iowrite32be((IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) | | 483 | ifc_out32((IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) | |
484 | (IFC_FIR_OP_RA0 << IFC_NAND_FIR0_OP1_SHIFT) | | 484 | (IFC_FIR_OP_RA0 << IFC_NAND_FIR0_OP1_SHIFT) | |
485 | (IFC_FIR_OP_CMD1 << IFC_NAND_FIR0_OP2_SHIFT), | 485 | (IFC_FIR_OP_CMD1 << IFC_NAND_FIR0_OP2_SHIFT), |
486 | &ifc->ifc_nand.nand_fir0); | 486 | &ifc->ifc_nand.nand_fir0); |
487 | 487 | ||
488 | iowrite32be((NAND_CMD_ERASE1 << IFC_NAND_FCR0_CMD0_SHIFT) | | 488 | ifc_out32((NAND_CMD_ERASE1 << IFC_NAND_FCR0_CMD0_SHIFT) | |
489 | (NAND_CMD_ERASE2 << IFC_NAND_FCR0_CMD1_SHIFT), | 489 | (NAND_CMD_ERASE2 << IFC_NAND_FCR0_CMD1_SHIFT), |
490 | &ifc->ifc_nand.nand_fcr0); | 490 | &ifc->ifc_nand.nand_fcr0); |
491 | 491 | ||
492 | iowrite32be(0, &ifc->ifc_nand.nand_fbcr); | 492 | ifc_out32(0, &ifc->ifc_nand.nand_fbcr); |
493 | ifc_nand_ctrl->read_bytes = 0; | 493 | ifc_nand_ctrl->read_bytes = 0; |
494 | fsl_ifc_run_command(mtd); | 494 | fsl_ifc_run_command(mtd); |
495 | return; | 495 | return; |
@@ -506,19 +506,18 @@ static void fsl_ifc_cmdfunc(struct mtd_info *mtd, unsigned int command, | |||
506 | (NAND_CMD_STATUS << IFC_NAND_FCR0_CMD1_SHIFT) | | 506 | (NAND_CMD_STATUS << IFC_NAND_FCR0_CMD1_SHIFT) | |
507 | (NAND_CMD_PAGEPROG << IFC_NAND_FCR0_CMD2_SHIFT); | 507 | (NAND_CMD_PAGEPROG << IFC_NAND_FCR0_CMD2_SHIFT); |
508 | 508 | ||
509 | iowrite32be( | 509 | ifc_out32( |
510 | (IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) | | 510 | (IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) | |
511 | (IFC_FIR_OP_CA0 << IFC_NAND_FIR0_OP1_SHIFT) | | 511 | (IFC_FIR_OP_CA0 << IFC_NAND_FIR0_OP1_SHIFT) | |
512 | (IFC_FIR_OP_RA0 << IFC_NAND_FIR0_OP2_SHIFT) | | 512 | (IFC_FIR_OP_RA0 << IFC_NAND_FIR0_OP2_SHIFT) | |
513 | (IFC_FIR_OP_WBCD << IFC_NAND_FIR0_OP3_SHIFT) | | 513 | (IFC_FIR_OP_WBCD << IFC_NAND_FIR0_OP3_SHIFT) | |
514 | (IFC_FIR_OP_CMD2 << IFC_NAND_FIR0_OP4_SHIFT), | 514 | (IFC_FIR_OP_CMD2 << IFC_NAND_FIR0_OP4_SHIFT), |
515 | &ifc->ifc_nand.nand_fir0); | 515 | &ifc->ifc_nand.nand_fir0); |
516 | iowrite32be( | 516 | ifc_out32( |
517 | (IFC_FIR_OP_CW1 << IFC_NAND_FIR1_OP5_SHIFT) | | 517 | (IFC_FIR_OP_CW1 << IFC_NAND_FIR1_OP5_SHIFT) | |
518 | (IFC_FIR_OP_RDSTAT << | 518 | (IFC_FIR_OP_RDSTAT << IFC_NAND_FIR1_OP6_SHIFT) | |
519 | IFC_NAND_FIR1_OP6_SHIFT) | | 519 | (IFC_FIR_OP_NOP << IFC_NAND_FIR1_OP7_SHIFT), |
520 | (IFC_FIR_OP_NOP << IFC_NAND_FIR1_OP7_SHIFT), | 520 | &ifc->ifc_nand.nand_fir1); |
521 | &ifc->ifc_nand.nand_fir1); | ||
522 | } else { | 521 | } else { |
523 | nand_fcr0 = ((NAND_CMD_PAGEPROG << | 522 | nand_fcr0 = ((NAND_CMD_PAGEPROG << |
524 | IFC_NAND_FCR0_CMD1_SHIFT) | | 523 | IFC_NAND_FCR0_CMD1_SHIFT) | |
@@ -527,20 +526,19 @@ static void fsl_ifc_cmdfunc(struct mtd_info *mtd, unsigned int command, | |||
527 | (NAND_CMD_STATUS << | 526 | (NAND_CMD_STATUS << |
528 | IFC_NAND_FCR0_CMD3_SHIFT)); | 527 | IFC_NAND_FCR0_CMD3_SHIFT)); |
529 | 528 | ||
530 | iowrite32be( | 529 | ifc_out32( |
531 | (IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) | | 530 | (IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) | |
532 | (IFC_FIR_OP_CMD2 << IFC_NAND_FIR0_OP1_SHIFT) | | 531 | (IFC_FIR_OP_CMD2 << IFC_NAND_FIR0_OP1_SHIFT) | |
533 | (IFC_FIR_OP_CA0 << IFC_NAND_FIR0_OP2_SHIFT) | | 532 | (IFC_FIR_OP_CA0 << IFC_NAND_FIR0_OP2_SHIFT) | |
534 | (IFC_FIR_OP_RA0 << IFC_NAND_FIR0_OP3_SHIFT) | | 533 | (IFC_FIR_OP_RA0 << IFC_NAND_FIR0_OP3_SHIFT) | |
535 | (IFC_FIR_OP_WBCD << IFC_NAND_FIR0_OP4_SHIFT), | 534 | (IFC_FIR_OP_WBCD << IFC_NAND_FIR0_OP4_SHIFT), |
536 | &ifc->ifc_nand.nand_fir0); | 535 | &ifc->ifc_nand.nand_fir0); |
537 | iowrite32be( | 536 | ifc_out32( |
538 | (IFC_FIR_OP_CMD1 << IFC_NAND_FIR1_OP5_SHIFT) | | 537 | (IFC_FIR_OP_CMD1 << IFC_NAND_FIR1_OP5_SHIFT) | |
539 | (IFC_FIR_OP_CW3 << IFC_NAND_FIR1_OP6_SHIFT) | | 538 | (IFC_FIR_OP_CW3 << IFC_NAND_FIR1_OP6_SHIFT) | |
540 | (IFC_FIR_OP_RDSTAT << | 539 | (IFC_FIR_OP_RDSTAT << IFC_NAND_FIR1_OP7_SHIFT) | |
541 | IFC_NAND_FIR1_OP7_SHIFT) | | 540 | (IFC_FIR_OP_NOP << IFC_NAND_FIR1_OP8_SHIFT), |
542 | (IFC_FIR_OP_NOP << IFC_NAND_FIR1_OP8_SHIFT), | 541 | &ifc->ifc_nand.nand_fir1); |
543 | &ifc->ifc_nand.nand_fir1); | ||
544 | 542 | ||
545 | if (column >= mtd->writesize) | 543 | if (column >= mtd->writesize) |
546 | nand_fcr0 |= | 544 | nand_fcr0 |= |
@@ -555,7 +553,7 @@ static void fsl_ifc_cmdfunc(struct mtd_info *mtd, unsigned int command, | |||
555 | column -= mtd->writesize; | 553 | column -= mtd->writesize; |
556 | ifc_nand_ctrl->oob = 1; | 554 | ifc_nand_ctrl->oob = 1; |
557 | } | 555 | } |
558 | iowrite32be(nand_fcr0, &ifc->ifc_nand.nand_fcr0); | 556 | ifc_out32(nand_fcr0, &ifc->ifc_nand.nand_fcr0); |
559 | set_addr(mtd, column, page_addr, ifc_nand_ctrl->oob); | 557 | set_addr(mtd, column, page_addr, ifc_nand_ctrl->oob); |
560 | return; | 558 | return; |
561 | } | 559 | } |
@@ -563,24 +561,26 @@ static void fsl_ifc_cmdfunc(struct mtd_info *mtd, unsigned int command, | |||
563 | /* PAGEPROG reuses all of the setup from SEQIN and adds the length */ | 561 | /* PAGEPROG reuses all of the setup from SEQIN and adds the length */ |
564 | case NAND_CMD_PAGEPROG: { | 562 | case NAND_CMD_PAGEPROG: { |
565 | if (ifc_nand_ctrl->oob) { | 563 | if (ifc_nand_ctrl->oob) { |
566 | iowrite32be(ifc_nand_ctrl->index - | 564 | ifc_out32(ifc_nand_ctrl->index - |
567 | ifc_nand_ctrl->column, | 565 | ifc_nand_ctrl->column, |
568 | &ifc->ifc_nand.nand_fbcr); | 566 | &ifc->ifc_nand.nand_fbcr); |
569 | } else { | 567 | } else { |
570 | iowrite32be(0, &ifc->ifc_nand.nand_fbcr); | 568 | ifc_out32(0, &ifc->ifc_nand.nand_fbcr); |
571 | } | 569 | } |
572 | 570 | ||
573 | fsl_ifc_run_command(mtd); | 571 | fsl_ifc_run_command(mtd); |
574 | return; | 572 | return; |
575 | } | 573 | } |
576 | 574 | ||
577 | case NAND_CMD_STATUS: | 575 | case NAND_CMD_STATUS: { |
578 | iowrite32be((IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) | | 576 | void __iomem *addr; |
579 | (IFC_FIR_OP_RB << IFC_NAND_FIR0_OP1_SHIFT), | 577 | |
580 | &ifc->ifc_nand.nand_fir0); | 578 | ifc_out32((IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) | |
581 | iowrite32be(NAND_CMD_STATUS << IFC_NAND_FCR0_CMD0_SHIFT, | 579 | (IFC_FIR_OP_RB << IFC_NAND_FIR0_OP1_SHIFT), |
582 | &ifc->ifc_nand.nand_fcr0); | 580 | &ifc->ifc_nand.nand_fir0); |
583 | iowrite32be(1, &ifc->ifc_nand.nand_fbcr); | 581 | ifc_out32(NAND_CMD_STATUS << IFC_NAND_FCR0_CMD0_SHIFT, |
582 | &ifc->ifc_nand.nand_fcr0); | ||
583 | ifc_out32(1, &ifc->ifc_nand.nand_fbcr); | ||
584 | set_addr(mtd, 0, 0, 0); | 584 | set_addr(mtd, 0, 0, 0); |
585 | ifc_nand_ctrl->read_bytes = 1; | 585 | ifc_nand_ctrl->read_bytes = 1; |
586 | 586 | ||
@@ -590,17 +590,19 @@ static void fsl_ifc_cmdfunc(struct mtd_info *mtd, unsigned int command, | |||
590 | * The chip always seems to report that it is | 590 | * The chip always seems to report that it is |
591 | * write-protected, even when it is not. | 591 | * write-protected, even when it is not. |
592 | */ | 592 | */ |
593 | addr = ifc_nand_ctrl->addr; | ||
593 | if (chip->options & NAND_BUSWIDTH_16) | 594 | if (chip->options & NAND_BUSWIDTH_16) |
594 | setbits16(ifc_nand_ctrl->addr, NAND_STATUS_WP); | 595 | ifc_out16(ifc_in16(addr) | (NAND_STATUS_WP), addr); |
595 | else | 596 | else |
596 | setbits8(ifc_nand_ctrl->addr, NAND_STATUS_WP); | 597 | ifc_out8(ifc_in8(addr) | (NAND_STATUS_WP), addr); |
597 | return; | 598 | return; |
599 | } | ||
598 | 600 | ||
599 | case NAND_CMD_RESET: | 601 | case NAND_CMD_RESET: |
600 | iowrite32be(IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT, | 602 | ifc_out32(IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT, |
601 | &ifc->ifc_nand.nand_fir0); | 603 | &ifc->ifc_nand.nand_fir0); |
602 | iowrite32be(NAND_CMD_RESET << IFC_NAND_FCR0_CMD0_SHIFT, | 604 | ifc_out32(NAND_CMD_RESET << IFC_NAND_FCR0_CMD0_SHIFT, |
603 | &ifc->ifc_nand.nand_fcr0); | 605 | &ifc->ifc_nand.nand_fcr0); |
604 | fsl_ifc_run_command(mtd); | 606 | fsl_ifc_run_command(mtd); |
605 | return; | 607 | return; |
606 | 608 | ||
@@ -658,7 +660,7 @@ static uint8_t fsl_ifc_read_byte(struct mtd_info *mtd) | |||
658 | */ | 660 | */ |
659 | if (ifc_nand_ctrl->index < ifc_nand_ctrl->read_bytes) { | 661 | if (ifc_nand_ctrl->index < ifc_nand_ctrl->read_bytes) { |
660 | offset = ifc_nand_ctrl->index++; | 662 | offset = ifc_nand_ctrl->index++; |
661 | return in_8(ifc_nand_ctrl->addr + offset); | 663 | return ifc_in8(ifc_nand_ctrl->addr + offset); |
662 | } | 664 | } |
663 | 665 | ||
664 | dev_err(priv->dev, "%s: beyond end of buffer\n", __func__); | 666 | dev_err(priv->dev, "%s: beyond end of buffer\n", __func__); |
@@ -680,7 +682,7 @@ static uint8_t fsl_ifc_read_byte16(struct mtd_info *mtd) | |||
680 | * next byte. | 682 | * next byte. |
681 | */ | 683 | */ |
682 | if (ifc_nand_ctrl->index < ifc_nand_ctrl->read_bytes) { | 684 | if (ifc_nand_ctrl->index < ifc_nand_ctrl->read_bytes) { |
683 | data = in_be16(ifc_nand_ctrl->addr + ifc_nand_ctrl->index); | 685 | data = ifc_in16(ifc_nand_ctrl->addr + ifc_nand_ctrl->index); |
684 | ifc_nand_ctrl->index += 2; | 686 | ifc_nand_ctrl->index += 2; |
685 | return (uint8_t) data; | 687 | return (uint8_t) data; |
686 | } | 688 | } |
@@ -726,18 +728,18 @@ static int fsl_ifc_wait(struct mtd_info *mtd, struct nand_chip *chip) | |||
726 | u32 nand_fsr; | 728 | u32 nand_fsr; |
727 | 729 | ||
728 | /* Use READ_STATUS command, but wait for the device to be ready */ | 730 | /* Use READ_STATUS command, but wait for the device to be ready */ |
729 | iowrite32be((IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) | | 731 | ifc_out32((IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) | |
730 | (IFC_FIR_OP_RDSTAT << IFC_NAND_FIR0_OP1_SHIFT), | 732 | (IFC_FIR_OP_RDSTAT << IFC_NAND_FIR0_OP1_SHIFT), |
731 | &ifc->ifc_nand.nand_fir0); | 733 | &ifc->ifc_nand.nand_fir0); |
732 | iowrite32be(NAND_CMD_STATUS << IFC_NAND_FCR0_CMD0_SHIFT, | 734 | ifc_out32(NAND_CMD_STATUS << IFC_NAND_FCR0_CMD0_SHIFT, |
733 | &ifc->ifc_nand.nand_fcr0); | 735 | &ifc->ifc_nand.nand_fcr0); |
734 | iowrite32be(1, &ifc->ifc_nand.nand_fbcr); | 736 | ifc_out32(1, &ifc->ifc_nand.nand_fbcr); |
735 | set_addr(mtd, 0, 0, 0); | 737 | set_addr(mtd, 0, 0, 0); |
736 | ifc_nand_ctrl->read_bytes = 1; | 738 | ifc_nand_ctrl->read_bytes = 1; |
737 | 739 | ||
738 | fsl_ifc_run_command(mtd); | 740 | fsl_ifc_run_command(mtd); |
739 | 741 | ||
740 | nand_fsr = ioread32be(&ifc->ifc_nand.nand_fsr); | 742 | nand_fsr = ifc_in32(&ifc->ifc_nand.nand_fsr); |
741 | 743 | ||
742 | /* | 744 | /* |
743 | * The chip always seems to report that it is | 745 | * The chip always seems to report that it is |
@@ -829,34 +831,34 @@ static void fsl_ifc_sram_init(struct fsl_ifc_mtd *priv) | |||
829 | uint32_t cs = priv->bank; | 831 | uint32_t cs = priv->bank; |
830 | 832 | ||
831 | /* Save CSOR and CSOR_ext */ | 833 | /* Save CSOR and CSOR_ext */ |
832 | csor = ioread32be(&ifc->csor_cs[cs].csor); | 834 | csor = ifc_in32(&ifc->csor_cs[cs].csor); |
833 | csor_ext = ioread32be(&ifc->csor_cs[cs].csor_ext); | 835 | csor_ext = ifc_in32(&ifc->csor_cs[cs].csor_ext); |
834 | 836 | ||
835 | /* chage PageSize 8K and SpareSize 1K*/ | 837 | /* chage PageSize 8K and SpareSize 1K*/ |
836 | csor_8k = (csor & ~(CSOR_NAND_PGS_MASK)) | 0x0018C000; | 838 | csor_8k = (csor & ~(CSOR_NAND_PGS_MASK)) | 0x0018C000; |
837 | iowrite32be(csor_8k, &ifc->csor_cs[cs].csor); | 839 | ifc_out32(csor_8k, &ifc->csor_cs[cs].csor); |
838 | iowrite32be(0x0000400, &ifc->csor_cs[cs].csor_ext); | 840 | ifc_out32(0x0000400, &ifc->csor_cs[cs].csor_ext); |
839 | 841 | ||
840 | /* READID */ | 842 | /* READID */ |
841 | iowrite32be((IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) | | 843 | ifc_out32((IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) | |
842 | (IFC_FIR_OP_UA << IFC_NAND_FIR0_OP1_SHIFT) | | 844 | (IFC_FIR_OP_UA << IFC_NAND_FIR0_OP1_SHIFT) | |
843 | (IFC_FIR_OP_RB << IFC_NAND_FIR0_OP2_SHIFT), | 845 | (IFC_FIR_OP_RB << IFC_NAND_FIR0_OP2_SHIFT), |
844 | &ifc->ifc_nand.nand_fir0); | 846 | &ifc->ifc_nand.nand_fir0); |
845 | iowrite32be(NAND_CMD_READID << IFC_NAND_FCR0_CMD0_SHIFT, | 847 | ifc_out32(NAND_CMD_READID << IFC_NAND_FCR0_CMD0_SHIFT, |
846 | &ifc->ifc_nand.nand_fcr0); | 848 | &ifc->ifc_nand.nand_fcr0); |
847 | iowrite32be(0x0, &ifc->ifc_nand.row3); | 849 | ifc_out32(0x0, &ifc->ifc_nand.row3); |
848 | 850 | ||
849 | iowrite32be(0x0, &ifc->ifc_nand.nand_fbcr); | 851 | ifc_out32(0x0, &ifc->ifc_nand.nand_fbcr); |
850 | 852 | ||
851 | /* Program ROW0/COL0 */ | 853 | /* Program ROW0/COL0 */ |
852 | iowrite32be(0x0, &ifc->ifc_nand.row0); | 854 | ifc_out32(0x0, &ifc->ifc_nand.row0); |
853 | iowrite32be(0x0, &ifc->ifc_nand.col0); | 855 | ifc_out32(0x0, &ifc->ifc_nand.col0); |
854 | 856 | ||
855 | /* set the chip select for NAND Transaction */ | 857 | /* set the chip select for NAND Transaction */ |
856 | iowrite32be(cs << IFC_NAND_CSEL_SHIFT, &ifc->ifc_nand.nand_csel); | 858 | ifc_out32(cs << IFC_NAND_CSEL_SHIFT, &ifc->ifc_nand.nand_csel); |
857 | 859 | ||
858 | /* start read seq */ | 860 | /* start read seq */ |
859 | iowrite32be(IFC_NAND_SEQ_STRT_FIR_STRT, &ifc->ifc_nand.nandseq_strt); | 861 | ifc_out32(IFC_NAND_SEQ_STRT_FIR_STRT, &ifc->ifc_nand.nandseq_strt); |
860 | 862 | ||
861 | /* wait for command complete flag or timeout */ | 863 | /* wait for command complete flag or timeout */ |
862 | wait_event_timeout(ctrl->nand_wait, ctrl->nand_stat, | 864 | wait_event_timeout(ctrl->nand_wait, ctrl->nand_stat, |
@@ -866,8 +868,8 @@ static void fsl_ifc_sram_init(struct fsl_ifc_mtd *priv) | |||
866 | printk(KERN_ERR "fsl-ifc: Failed to Initialise SRAM\n"); | 868 | printk(KERN_ERR "fsl-ifc: Failed to Initialise SRAM\n"); |
867 | 869 | ||
868 | /* Restore CSOR and CSOR_ext */ | 870 | /* Restore CSOR and CSOR_ext */ |
869 | iowrite32be(csor, &ifc->csor_cs[cs].csor); | 871 | ifc_out32(csor, &ifc->csor_cs[cs].csor); |
870 | iowrite32be(csor_ext, &ifc->csor_cs[cs].csor_ext); | 872 | ifc_out32(csor_ext, &ifc->csor_cs[cs].csor_ext); |
871 | } | 873 | } |
872 | 874 | ||
873 | static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv) | 875 | static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv) |
@@ -884,7 +886,7 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv) | |||
884 | 886 | ||
885 | /* fill in nand_chip structure */ | 887 | /* fill in nand_chip structure */ |
886 | /* set up function call table */ | 888 | /* set up function call table */ |
887 | if ((ioread32be(&ifc->cspr_cs[priv->bank].cspr)) & CSPR_PORT_SIZE_16) | 889 | if ((ifc_in32(&ifc->cspr_cs[priv->bank].cspr)) & CSPR_PORT_SIZE_16) |
888 | chip->read_byte = fsl_ifc_read_byte16; | 890 | chip->read_byte = fsl_ifc_read_byte16; |
889 | else | 891 | else |
890 | chip->read_byte = fsl_ifc_read_byte; | 892 | chip->read_byte = fsl_ifc_read_byte; |
@@ -898,13 +900,13 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv) | |||
898 | chip->bbt_td = &bbt_main_descr; | 900 | chip->bbt_td = &bbt_main_descr; |
899 | chip->bbt_md = &bbt_mirror_descr; | 901 | chip->bbt_md = &bbt_mirror_descr; |
900 | 902 | ||
901 | iowrite32be(0x0, &ifc->ifc_nand.ncfgr); | 903 | ifc_out32(0x0, &ifc->ifc_nand.ncfgr); |
902 | 904 | ||
903 | /* set up nand options */ | 905 | /* set up nand options */ |
904 | chip->bbt_options = NAND_BBT_USE_FLASH; | 906 | chip->bbt_options = NAND_BBT_USE_FLASH; |
905 | chip->options = NAND_NO_SUBPAGE_WRITE; | 907 | chip->options = NAND_NO_SUBPAGE_WRITE; |
906 | 908 | ||
907 | if (ioread32be(&ifc->cspr_cs[priv->bank].cspr) & CSPR_PORT_SIZE_16) { | 909 | if (ifc_in32(&ifc->cspr_cs[priv->bank].cspr) & CSPR_PORT_SIZE_16) { |
908 | chip->read_byte = fsl_ifc_read_byte16; | 910 | chip->read_byte = fsl_ifc_read_byte16; |
909 | chip->options |= NAND_BUSWIDTH_16; | 911 | chip->options |= NAND_BUSWIDTH_16; |
910 | } else { | 912 | } else { |
@@ -917,7 +919,7 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv) | |||
917 | chip->ecc.read_page = fsl_ifc_read_page; | 919 | chip->ecc.read_page = fsl_ifc_read_page; |
918 | chip->ecc.write_page = fsl_ifc_write_page; | 920 | chip->ecc.write_page = fsl_ifc_write_page; |
919 | 921 | ||
920 | csor = ioread32be(&ifc->csor_cs[priv->bank].csor); | 922 | csor = ifc_in32(&ifc->csor_cs[priv->bank].csor); |
921 | 923 | ||
922 | /* Hardware generates ECC per 512 Bytes */ | 924 | /* Hardware generates ECC per 512 Bytes */ |
923 | chip->ecc.size = 512; | 925 | chip->ecc.size = 512; |
@@ -1006,7 +1008,7 @@ static int fsl_ifc_chip_remove(struct fsl_ifc_mtd *priv) | |||
1006 | static int match_bank(struct fsl_ifc_regs __iomem *ifc, int bank, | 1008 | static int match_bank(struct fsl_ifc_regs __iomem *ifc, int bank, |
1007 | phys_addr_t addr) | 1009 | phys_addr_t addr) |
1008 | { | 1010 | { |
1009 | u32 cspr = ioread32be(&ifc->cspr_cs[bank].cspr); | 1011 | u32 cspr = ifc_in32(&ifc->cspr_cs[bank].cspr); |
1010 | 1012 | ||
1011 | if (!(cspr & CSPR_V)) | 1013 | if (!(cspr & CSPR_V)) |
1012 | return 0; | 1014 | return 0; |
@@ -1092,16 +1094,16 @@ static int fsl_ifc_nand_probe(struct platform_device *dev) | |||
1092 | 1094 | ||
1093 | dev_set_drvdata(priv->dev, priv); | 1095 | dev_set_drvdata(priv->dev, priv); |
1094 | 1096 | ||
1095 | iowrite32be(IFC_NAND_EVTER_EN_OPC_EN | | 1097 | ifc_out32(IFC_NAND_EVTER_EN_OPC_EN | |
1096 | IFC_NAND_EVTER_EN_FTOER_EN | | 1098 | IFC_NAND_EVTER_EN_FTOER_EN | |
1097 | IFC_NAND_EVTER_EN_WPER_EN, | 1099 | IFC_NAND_EVTER_EN_WPER_EN, |
1098 | &ifc->ifc_nand.nand_evter_en); | 1100 | &ifc->ifc_nand.nand_evter_en); |
1099 | 1101 | ||
1100 | /* enable NAND Machine Interrupts */ | 1102 | /* enable NAND Machine Interrupts */ |
1101 | iowrite32be(IFC_NAND_EVTER_INTR_OPCIR_EN | | 1103 | ifc_out32(IFC_NAND_EVTER_INTR_OPCIR_EN | |
1102 | IFC_NAND_EVTER_INTR_FTOERIR_EN | | 1104 | IFC_NAND_EVTER_INTR_FTOERIR_EN | |
1103 | IFC_NAND_EVTER_INTR_WPERIR_EN, | 1105 | IFC_NAND_EVTER_INTR_WPERIR_EN, |
1104 | &ifc->ifc_nand.nand_evter_intr_en); | 1106 | &ifc->ifc_nand.nand_evter_intr_en); |
1105 | priv->mtd.name = kasprintf(GFP_KERNEL, "%llx.flash", (u64)res.start); | 1107 | priv->mtd.name = kasprintf(GFP_KERNEL, "%llx.flash", (u64)res.start); |
1106 | if (!priv->mtd.name) { | 1108 | if (!priv->mtd.name) { |
1107 | ret = -ENOMEM; | 1109 | ret = -ENOMEM; |