diff options
author | Ezequiel Garcia <ezequiel.garcia@free-electrons.com> | 2013-11-14 16:25:31 -0500 |
---|---|---|
committer | Brian Norris <computersforpeace@gmail.com> | 2014-01-03 14:22:12 -0500 |
commit | 86beebae3acf531b75e63d88b7ec9b3804ce895e (patch) | |
tree | 1f527cdaf685ccf767a965155d122243288f7f0d /drivers/mtd/nand/pxa3xx_nand.c | |
parent | f0e6a32e9af51e2a65c3cbedbad4cbc6b1479330 (diff) |
mtd: nand: pxa3xx: Add helper function to set page address
Let's simplify the code by first introducing a helper function
to set the page address, as done by the READ0, READOOB and SEQIN
commands.
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Tested-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Diffstat (limited to 'drivers/mtd/nand/pxa3xx_nand.c')
-rw-r--r-- | drivers/mtd/nand/pxa3xx_nand.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c index 2962614899ea..446916377401 100644 --- a/drivers/mtd/nand/pxa3xx_nand.c +++ b/drivers/mtd/nand/pxa3xx_nand.c | |||
@@ -583,6 +583,26 @@ static inline int is_buf_blank(uint8_t *buf, size_t len) | |||
583 | return 1; | 583 | return 1; |
584 | } | 584 | } |
585 | 585 | ||
586 | static void set_command_address(struct pxa3xx_nand_info *info, | ||
587 | unsigned int page_size, uint16_t column, int page_addr) | ||
588 | { | ||
589 | /* small page addr setting */ | ||
590 | if (page_size < PAGE_CHUNK_SIZE) { | ||
591 | info->ndcb1 = ((page_addr & 0xFFFFFF) << 8) | ||
592 | | (column & 0xFF); | ||
593 | |||
594 | info->ndcb2 = 0; | ||
595 | } else { | ||
596 | info->ndcb1 = ((page_addr & 0xFFFF) << 16) | ||
597 | | (column & 0xFFFF); | ||
598 | |||
599 | if (page_addr & 0xFF0000) | ||
600 | info->ndcb2 = (page_addr & 0xFF0000) >> 16; | ||
601 | else | ||
602 | info->ndcb2 = 0; | ||
603 | } | ||
604 | } | ||
605 | |||
586 | static int prepare_command_pool(struct pxa3xx_nand_info *info, int command, | 606 | static int prepare_command_pool(struct pxa3xx_nand_info *info, int command, |
587 | uint16_t column, int page_addr) | 607 | uint16_t column, int page_addr) |
588 | { | 608 | { |
@@ -646,22 +666,8 @@ static int prepare_command_pool(struct pxa3xx_nand_info *info, int command, | |||
646 | info->ndcb0 |= NDCB0_DBC | (NAND_CMD_READSTART << 8); | 666 | info->ndcb0 |= NDCB0_DBC | (NAND_CMD_READSTART << 8); |
647 | 667 | ||
648 | case NAND_CMD_SEQIN: | 668 | case NAND_CMD_SEQIN: |
649 | /* small page addr setting */ | ||
650 | if (unlikely(mtd->writesize < PAGE_CHUNK_SIZE)) { | ||
651 | info->ndcb1 = ((page_addr & 0xFFFFFF) << 8) | ||
652 | | (column & 0xFF); | ||
653 | |||
654 | info->ndcb2 = 0; | ||
655 | } else { | ||
656 | info->ndcb1 = ((page_addr & 0xFFFF) << 16) | ||
657 | | (column & 0xFFFF); | ||
658 | |||
659 | if (page_addr & 0xFF0000) | ||
660 | info->ndcb2 = (page_addr & 0xFF0000) >> 16; | ||
661 | else | ||
662 | info->ndcb2 = 0; | ||
663 | } | ||
664 | 669 | ||
670 | set_command_address(info, mtd->writesize, column, page_addr); | ||
665 | info->buf_count = mtd->writesize + mtd->oobsize; | 671 | info->buf_count = mtd->writesize + mtd->oobsize; |
666 | memset(info->data_buff, 0xFF, info->buf_count); | 672 | memset(info->data_buff, 0xFF, info->buf_count); |
667 | 673 | ||