mvebu: backport mainline patches from kernel 3.13
[openwrt/staging/lynxis/omap.git] / target / linux / mvebu / patches-3.10 / 0145-mtd-nand-pxa3xx-Add-helper-function-to-set-page-addr.patch
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
5 address
6
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
9 commands.
10
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>
14 ---
15 drivers/mtd/nand/pxa3xx_nand.c | 36 +++++++++++++++++++++---------------
16 1 file changed, 21 insertions(+), 15 deletions(-)
17
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 *
21 return 1;
22 }
23
24 +static void set_command_address(struct pxa3xx_nand_info *info,
25 + unsigned int page_size, uint16_t column, int page_addr)
26 +{
27 + /* small page addr setting */
28 + if (page_size < PAGE_CHUNK_SIZE) {
29 + info->ndcb1 = ((page_addr & 0xFFFFFF) << 8)
30 + | (column & 0xFF);
31 +
32 + info->ndcb2 = 0;
33 + } else {
34 + info->ndcb1 = ((page_addr & 0xFFFF) << 16)
35 + | (column & 0xFFFF);
36 +
37 + if (page_addr & 0xFF0000)
38 + info->ndcb2 = (page_addr & 0xFF0000) >> 16;
39 + else
40 + info->ndcb2 = 0;
41 + }
42 +}
43 +
44 static int prepare_command_pool(struct pxa3xx_nand_info *info, int command,
45 uint16_t column, int page_addr)
46 {
47 @@ -650,22 +670,8 @@ static int prepare_command_pool(struct p
48 info->ndcb0 |= NDCB0_DBC | (NAND_CMD_READSTART << 8);
49
50 case NAND_CMD_SEQIN:
51 - /* small page addr setting */
52 - if (unlikely(mtd->writesize < PAGE_CHUNK_SIZE)) {
53 - info->ndcb1 = ((page_addr & 0xFFFFFF) << 8)
54 - | (column & 0xFF);
55 -
56 - info->ndcb2 = 0;
57 - } else {
58 - info->ndcb1 = ((page_addr & 0xFFFF) << 16)
59 - | (column & 0xFFFF);
60 -
61 - if (page_addr & 0xFF0000)
62 - info->ndcb2 = (page_addr & 0xFF0000) >> 16;
63 - else
64 - info->ndcb2 = 0;
65 - }
66
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);
70