1 From 09a84f8e89c3715160423701b0606ef99e2a05bf Mon Sep 17 00:00:00 2001
2 From: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
3 Date: Thu, 14 Nov 2013 18:25:31 -0300
4 Subject: [PATCH 145/203] mtd: nand: pxa3xx: Add helper function to set page
7 Let's simplify the code by first introducing a helper function
8 to set the page address, as done by the READ0, READOOB and SEQIN
11 Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
12 Tested-by: Daniel Mack <zonque@gmail.com>
13 Signed-off-by: Brian Norris <computersforpeace@gmail.com>
15 drivers/mtd/nand/pxa3xx_nand.c | 36 +++++++++++++++++++++---------------
16 1 file changed, 21 insertions(+), 15 deletions(-)
18 --- a/drivers/mtd/nand/pxa3xx_nand.c
19 +++ b/drivers/mtd/nand/pxa3xx_nand.c
20 @@ -587,6 +587,26 @@ static inline int is_buf_blank(uint8_t *
24 +static void set_command_address(struct pxa3xx_nand_info *info,
25 + unsigned int page_size, uint16_t column, int page_addr)
27 + /* small page addr setting */
28 + if (page_size < PAGE_CHUNK_SIZE) {
29 + info->ndcb1 = ((page_addr & 0xFFFFFF) << 8)
34 + info->ndcb1 = ((page_addr & 0xFFFF) << 16)
35 + | (column & 0xFFFF);
37 + if (page_addr & 0xFF0000)
38 + info->ndcb2 = (page_addr & 0xFF0000) >> 16;
44 static int prepare_command_pool(struct pxa3xx_nand_info *info, int command,
45 uint16_t column, int page_addr)
47 @@ -650,22 +670,8 @@ static int prepare_command_pool(struct p
48 info->ndcb0 |= NDCB0_DBC | (NAND_CMD_READSTART << 8);
51 - /* small page addr setting */
52 - if (unlikely(mtd->writesize < PAGE_CHUNK_SIZE)) {
53 - info->ndcb1 = ((page_addr & 0xFFFFFF) << 8)
58 - info->ndcb1 = ((page_addr & 0xFFFF) << 16)
59 - | (column & 0xFFFF);
61 - if (page_addr & 0xFF0000)
62 - info->ndcb2 = (page_addr & 0xFF0000) >> 16;
67 + set_command_address(info, mtd->writesize, column, page_addr);
68 info->buf_count = mtd->writesize + mtd->oobsize;
69 memset(info->data_buff, 0xFF, info->buf_count);