1 From db95c66cebb6297595a5a32b369d1033b08775ce Mon Sep 17 00:00:00 2001
2 From: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
3 Date: Thu, 14 Nov 2013 18:25:38 -0300
4 Subject: [PATCH 152/203] mtd: nand: pxa3xx: Add multiple chunk write support
6 This commit adds write support for large pages (4 KiB, 8 KiB).
7 Such support is implemented by issuing a multiple command sequence,
8 transfering a set of 2 KiB chunks per transaction.
10 The splitted command sequence requires to send the SEQIN command
11 independently of the PAGEPROG command and therefore it's set as
14 Since PAGEPROG enables ECC, each 2 KiB chunk of data is written
15 together with ECC code at a controller-fixed location within
18 Currently, only devices with a 4 KiB page size has been tested.
20 Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
21 Tested-by: Daniel Mack <zonque@gmail.com>
22 Signed-off-by: Brian Norris <computersforpeace@gmail.com>
24 drivers/mtd/nand/pxa3xx_nand.c | 81 +++++++++++++++++++++++++++++++++++++-----
25 1 file changed, 73 insertions(+), 8 deletions(-)
27 --- a/drivers/mtd/nand/pxa3xx_nand.c
28 +++ b/drivers/mtd/nand/pxa3xx_nand.c
29 @@ -760,6 +760,20 @@ static int prepare_set_command(struct px
31 info->buf_start = column;
32 set_command_address(info, mtd->writesize, 0, page_addr);
35 + * Multiple page programming needs to execute the initial
36 + * SEQIN command that sets the page address.
38 + if (mtd->writesize > PAGE_CHUNK_SIZE) {
39 + info->ndcb0 |= NDCB0_CMD_TYPE(0x1)
40 + | NDCB0_EXT_CMD_TYPE(ext_cmd_type)
43 + /* No data transfer in this case */
44 + info->data_size = 0;
49 case NAND_CMD_PAGEPROG:
50 @@ -769,13 +783,40 @@ static int prepare_set_command(struct px
54 - info->ndcb0 |= NDCB0_CMD_TYPE(0x1)
58 - | (NAND_CMD_PAGEPROG << 8)
61 + /* Second command setting for large pages */
62 + if (mtd->writesize > PAGE_CHUNK_SIZE) {
64 + * Multiple page write uses the 'extended command'
65 + * field. This can be used to issue a command dispatch
66 + * or a naked-write depending on the current stage.
68 + info->ndcb0 |= NDCB0_CMD_TYPE(0x1)
70 + | NDCB0_EXT_CMD_TYPE(ext_cmd_type);
71 + info->ndcb3 = info->chunk_size +
75 + * This is the command dispatch that completes a chunked
76 + * page program operation.
78 + if (info->data_size == 0) {
79 + info->ndcb0 = NDCB0_CMD_TYPE(0x1)
80 + | NDCB0_EXT_CMD_TYPE(ext_cmd_type)
87 + info->ndcb0 |= NDCB0_CMD_TYPE(0x1)
91 + | (NAND_CMD_PAGEPROG << 8)
98 @@ -919,8 +960,15 @@ static void armada370_nand_cmdfunc(struc
99 case NAND_CMD_READOOB:
100 ext_cmd_type = EXT_CMD_TYPE_MONO;
102 + case NAND_CMD_SEQIN:
103 + ext_cmd_type = EXT_CMD_TYPE_DISPATCH;
105 + case NAND_CMD_PAGEPROG:
106 + ext_cmd_type = EXT_CMD_TYPE_NAKED_RW;
113 prepare_start_command(info, command);
114 @@ -958,7 +1006,16 @@ static void armada370_nand_cmdfunc(struc
117 /* Check if the sequence is complete */
118 - if (info->data_size == 0)
119 + if (info->data_size == 0 && command != NAND_CMD_PAGEPROG)
123 + * After a splitted program command sequence has issued
124 + * the command dispatch, the command sequence is complete.
126 + if (info->data_size == 0 &&
127 + command == NAND_CMD_PAGEPROG &&
128 + ext_cmd_type == EXT_CMD_TYPE_DISPATCH)
131 if (command == NAND_CMD_READ0 || command == NAND_CMD_READOOB) {
132 @@ -967,6 +1024,14 @@ static void armada370_nand_cmdfunc(struc
133 ext_cmd_type = EXT_CMD_TYPE_LAST_RW;
135 ext_cmd_type = EXT_CMD_TYPE_NAKED_RW;
138 + * If a splitted program command has no more data to transfer,
139 + * the command dispatch must be issued to complete.
141 + } else if (command == NAND_CMD_PAGEPROG &&
142 + info->data_size == 0) {
143 + ext_cmd_type = EXT_CMD_TYPE_DISPATCH;