summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2017-03-22 16:07:06 -0400
committerBoris Brezillon <boris.brezillon@free-electrons.com>2017-03-24 04:51:36 -0400
commit1aded58a27f253f399dcd5746417e684c92ccd7d (patch)
treec429fe034574c2d6e9d8b6db5203bc5268383211 /drivers/mtd/nand
parent60ca41f1d9ccf8b57f4ba05d8e8102658a36ef3b (diff)
mtd: nand: denali: consolidate INTR_STATUS__* and INTR_EN__* macros
The interrupts are enabled by INTR_EN register, then asserted interrupts can be observed via INTR_STATUS register. The bit fields are identical between INTR_EN and INTR_STATUS, so we can merge the bit field macros. Likewise for DATA_INTR. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r--drivers/mtd/nand/denali.c56
-rw-r--r--drivers/mtd/nand/denali.h61
2 files changed, 44 insertions, 73 deletions
diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
index c9806e644a43..2c59eb3c117e 100644
--- a/drivers/mtd/nand/denali.c
+++ b/drivers/mtd/nand/denali.c
@@ -45,16 +45,16 @@ MODULE_PARM_DESC(onfi_timing_mode,
45 * We define a macro here that combines all interrupts this driver uses into 45 * We define a macro here that combines all interrupts this driver uses into
46 * a single constant value, for convenience. 46 * a single constant value, for convenience.
47 */ 47 */
48#define DENALI_IRQ_ALL (INTR_STATUS__DMA_CMD_COMP | \ 48#define DENALI_IRQ_ALL (INTR__DMA_CMD_COMP | \
49 INTR_STATUS__ECC_TRANSACTION_DONE | \ 49 INTR__ECC_TRANSACTION_DONE | \
50 INTR_STATUS__ECC_ERR | \ 50 INTR__ECC_ERR | \
51 INTR_STATUS__PROGRAM_FAIL | \ 51 INTR__PROGRAM_FAIL | \
52 INTR_STATUS__LOAD_COMP | \ 52 INTR__LOAD_COMP | \
53 INTR_STATUS__PROGRAM_COMP | \ 53 INTR__PROGRAM_COMP | \
54 INTR_STATUS__TIME_OUT | \ 54 INTR__TIME_OUT | \
55 INTR_STATUS__ERASE_FAIL | \ 55 INTR__ERASE_FAIL | \
56 INTR_STATUS__RST_COMP | \ 56 INTR__RST_COMP | \
57 INTR_STATUS__ERASE_COMP) 57 INTR__ERASE_COMP)
58 58
59/* 59/*
60 * indicates whether or not the internal value for the flash bank is 60 * indicates whether or not the internal value for the flash bank is
@@ -159,7 +159,7 @@ static void read_status(struct denali_nand_info *denali)
159static void reset_bank(struct denali_nand_info *denali) 159static void reset_bank(struct denali_nand_info *denali)
160{ 160{
161 uint32_t irq_status; 161 uint32_t irq_status;
162 uint32_t irq_mask = INTR_STATUS__RST_COMP | INTR_STATUS__TIME_OUT; 162 uint32_t irq_mask = INTR__RST_COMP | INTR__TIME_OUT;
163 163
164 clear_interrupts(denali); 164 clear_interrupts(denali);
165 165
@@ -167,7 +167,7 @@ static void reset_bank(struct denali_nand_info *denali)
167 167
168 irq_status = wait_for_irq(denali, irq_mask); 168 irq_status = wait_for_irq(denali, irq_mask);
169 169
170 if (irq_status & INTR_STATUS__TIME_OUT) 170 if (irq_status & INTR__TIME_OUT)
171 dev_err(denali->dev, "reset bank failed.\n"); 171 dev_err(denali->dev, "reset bank failed.\n");
172} 172}
173 173
@@ -177,22 +177,22 @@ static uint16_t denali_nand_reset(struct denali_nand_info *denali)
177 int i; 177 int i;
178 178
179 for (i = 0; i < denali->max_banks; i++) 179 for (i = 0; i < denali->max_banks; i++)
180 iowrite32(INTR_STATUS__RST_COMP | INTR_STATUS__TIME_OUT, 180 iowrite32(INTR__RST_COMP | INTR__TIME_OUT,
181 denali->flash_reg + INTR_STATUS(i)); 181 denali->flash_reg + INTR_STATUS(i));
182 182
183 for (i = 0; i < denali->max_banks; i++) { 183 for (i = 0; i < denali->max_banks; i++) {
184 iowrite32(1 << i, denali->flash_reg + DEVICE_RESET); 184 iowrite32(1 << i, denali->flash_reg + DEVICE_RESET);
185 while (!(ioread32(denali->flash_reg + INTR_STATUS(i)) & 185 while (!(ioread32(denali->flash_reg + INTR_STATUS(i)) &
186 (INTR_STATUS__RST_COMP | INTR_STATUS__TIME_OUT))) 186 (INTR__RST_COMP | INTR__TIME_OUT)))
187 cpu_relax(); 187 cpu_relax();
188 if (ioread32(denali->flash_reg + INTR_STATUS(i)) & 188 if (ioread32(denali->flash_reg + INTR_STATUS(i)) &
189 INTR_STATUS__TIME_OUT) 189 INTR__TIME_OUT)
190 dev_dbg(denali->dev, 190 dev_dbg(denali->dev,
191 "NAND Reset operation timed out on bank %d\n", i); 191 "NAND Reset operation timed out on bank %d\n", i);
192 } 192 }
193 193
194 for (i = 0; i < denali->max_banks; i++) 194 for (i = 0; i < denali->max_banks; i++)
195 iowrite32(INTR_STATUS__RST_COMP | INTR_STATUS__TIME_OUT, 195 iowrite32(INTR__RST_COMP | INTR__TIME_OUT,
196 denali->flash_reg + INTR_STATUS(i)); 196 denali->flash_reg + INTR_STATUS(i));
197 197
198 return PASS; 198 return PASS;
@@ -716,7 +716,7 @@ static int denali_send_pipeline_cmd(struct denali_nand_info *denali,
716 uint32_t addr, cmd, irq_status, irq_mask; 716 uint32_t addr, cmd, irq_status, irq_mask;
717 717
718 if (op == DENALI_READ) 718 if (op == DENALI_READ)
719 irq_mask = INTR_STATUS__LOAD_COMP; 719 irq_mask = INTR__LOAD_COMP;
720 else if (op == DENALI_WRITE) 720 else if (op == DENALI_WRITE)
721 irq_mask = 0; 721 irq_mask = 0;
722 else 722 else
@@ -823,8 +823,7 @@ static int write_oob_data(struct mtd_info *mtd, uint8_t *buf, int page)
823{ 823{
824 struct denali_nand_info *denali = mtd_to_denali(mtd); 824 struct denali_nand_info *denali = mtd_to_denali(mtd);
825 uint32_t irq_status; 825 uint32_t irq_status;
826 uint32_t irq_mask = INTR_STATUS__PROGRAM_COMP | 826 uint32_t irq_mask = INTR__PROGRAM_COMP | INTR__PROGRAM_FAIL;
827 INTR_STATUS__PROGRAM_FAIL;
828 int status = 0; 827 int status = 0;
829 828
830 denali->page = page; 829 denali->page = page;
@@ -851,7 +850,7 @@ static int write_oob_data(struct mtd_info *mtd, uint8_t *buf, int page)
851static void read_oob_data(struct mtd_info *mtd, uint8_t *buf, int page) 850static void read_oob_data(struct mtd_info *mtd, uint8_t *buf, int page)
852{ 851{
853 struct denali_nand_info *denali = mtd_to_denali(mtd); 852 struct denali_nand_info *denali = mtd_to_denali(mtd);
854 uint32_t irq_mask = INTR_STATUS__LOAD_COMP; 853 uint32_t irq_mask = INTR__LOAD_COMP;
855 uint32_t irq_status, addr, cmd; 854 uint32_t irq_status, addr, cmd;
856 855
857 denali->page = page; 856 denali->page = page;
@@ -912,7 +911,7 @@ static bool handle_ecc(struct denali_nand_info *denali, uint8_t *buf,
912 bool check_erased_page = false; 911 bool check_erased_page = false;
913 unsigned int bitflips = 0; 912 unsigned int bitflips = 0;
914 913
915 if (irq_status & INTR_STATUS__ECC_ERR) { 914 if (irq_status & INTR__ECC_ERR) {
916 /* read the ECC errors. we'll ignore them for now */ 915 /* read the ECC errors. we'll ignore them for now */
917 uint32_t err_address, err_correction_info, err_byte, 916 uint32_t err_address, err_correction_info, err_byte,
918 err_sector, err_device, err_correction_value; 917 err_sector, err_device, err_correction_value;
@@ -969,7 +968,7 @@ static bool handle_ecc(struct denali_nand_info *denali, uint8_t *buf,
969 * for a while for this interrupt 968 * for a while for this interrupt
970 */ 969 */
971 while (!(read_interrupt_status(denali) & 970 while (!(read_interrupt_status(denali) &
972 INTR_STATUS__ECC_TRANSACTION_DONE)) 971 INTR__ECC_TRANSACTION_DONE))
973 cpu_relax(); 972 cpu_relax();
974 clear_interrupts(denali); 973 clear_interrupts(denali);
975 denali_set_intr_modes(denali, true); 974 denali_set_intr_modes(denali, true);
@@ -1020,8 +1019,7 @@ static int write_page(struct mtd_info *mtd, struct nand_chip *chip,
1020 dma_addr_t addr = denali->buf.dma_buf; 1019 dma_addr_t addr = denali->buf.dma_buf;
1021 size_t size = mtd->writesize + mtd->oobsize; 1020 size_t size = mtd->writesize + mtd->oobsize;
1022 uint32_t irq_status; 1021 uint32_t irq_status;
1023 uint32_t irq_mask = INTR_STATUS__DMA_CMD_COMP | 1022 uint32_t irq_mask = INTR__DMA_CMD_COMP | INTR__PROGRAM_FAIL;
1024 INTR_STATUS__PROGRAM_FAIL;
1025 1023
1026 /* 1024 /*
1027 * if it is a raw xfer, we want to disable ecc and send the spare area. 1025 * if it is a raw xfer, we want to disable ecc and send the spare area.
@@ -1119,8 +1117,7 @@ static int denali_read_page(struct mtd_info *mtd, struct nand_chip *chip,
1119 size_t size = mtd->writesize + mtd->oobsize; 1117 size_t size = mtd->writesize + mtd->oobsize;
1120 1118
1121 uint32_t irq_status; 1119 uint32_t irq_status;
1122 uint32_t irq_mask = INTR_STATUS__ECC_TRANSACTION_DONE | 1120 uint32_t irq_mask = INTR__ECC_TRANSACTION_DONE | INTR__ECC_ERR;
1123 INTR_STATUS__ECC_ERR;
1124 bool check_erased_page = false; 1121 bool check_erased_page = false;
1125 1122
1126 if (page != denali->page) { 1123 if (page != denali->page) {
@@ -1168,7 +1165,7 @@ static int denali_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
1168 struct denali_nand_info *denali = mtd_to_denali(mtd); 1165 struct denali_nand_info *denali = mtd_to_denali(mtd);
1169 dma_addr_t addr = denali->buf.dma_buf; 1166 dma_addr_t addr = denali->buf.dma_buf;
1170 size_t size = mtd->writesize + mtd->oobsize; 1167 size_t size = mtd->writesize + mtd->oobsize;
1171 uint32_t irq_mask = INTR_STATUS__DMA_CMD_COMP; 1168 uint32_t irq_mask = INTR__DMA_CMD_COMP;
1172 1169
1173 if (page != denali->page) { 1170 if (page != denali->page) {
1174 dev_err(denali->dev, 1171 dev_err(denali->dev,
@@ -1241,10 +1238,9 @@ static int denali_erase(struct mtd_info *mtd, int page)
1241 index_addr(denali, cmd, 0x1); 1238 index_addr(denali, cmd, 0x1);
1242 1239
1243 /* wait for erase to complete or failure to occur */ 1240 /* wait for erase to complete or failure to occur */
1244 irq_status = wait_for_irq(denali, INTR_STATUS__ERASE_COMP | 1241 irq_status = wait_for_irq(denali, INTR__ERASE_COMP | INTR__ERASE_FAIL);
1245 INTR_STATUS__ERASE_FAIL);
1246 1242
1247 return irq_status & INTR_STATUS__ERASE_FAIL ? NAND_STATUS_FAIL : PASS; 1243 return irq_status & INTR__ERASE_FAIL ? NAND_STATUS_FAIL : PASS;
1248} 1244}
1249 1245
1250static void denali_cmdfunc(struct mtd_info *mtd, unsigned int cmd, int col, 1246static void denali_cmdfunc(struct mtd_info *mtd, unsigned int cmd, int col,
diff --git a/drivers/mtd/nand/denali.h b/drivers/mtd/nand/denali.h
index 403a7c82d1c7..8df2285b678b 100644
--- a/drivers/mtd/nand/denali.h
+++ b/drivers/mtd/nand/denali.h
@@ -218,40 +218,22 @@
218 218
219#define INTR_STATUS(__bank) (0x410 + ((__bank) * 0x50)) 219#define INTR_STATUS(__bank) (0x410 + ((__bank) * 0x50))
220#define INTR_EN(__bank) (0x420 + ((__bank) * 0x50)) 220#define INTR_EN(__bank) (0x420 + ((__bank) * 0x50))
221 221#define INTR__ECC_TRANSACTION_DONE 0x0001
222#define INTR_STATUS__ECC_TRANSACTION_DONE 0x0001 222#define INTR__ECC_ERR 0x0002
223#define INTR_STATUS__ECC_ERR 0x0002 223#define INTR__DMA_CMD_COMP 0x0004
224#define INTR_STATUS__DMA_CMD_COMP 0x0004 224#define INTR__TIME_OUT 0x0008
225#define INTR_STATUS__TIME_OUT 0x0008 225#define INTR__PROGRAM_FAIL 0x0010
226#define INTR_STATUS__PROGRAM_FAIL 0x0010 226#define INTR__ERASE_FAIL 0x0020
227#define INTR_STATUS__ERASE_FAIL 0x0020 227#define INTR__LOAD_COMP 0x0040
228#define INTR_STATUS__LOAD_COMP 0x0040 228#define INTR__PROGRAM_COMP 0x0080
229#define INTR_STATUS__PROGRAM_COMP 0x0080 229#define INTR__ERASE_COMP 0x0100
230#define INTR_STATUS__ERASE_COMP 0x0100 230#define INTR__PIPE_CPYBCK_CMD_COMP 0x0200
231#define INTR_STATUS__PIPE_CPYBCK_CMD_COMP 0x0200 231#define INTR__LOCKED_BLK 0x0400
232#define INTR_STATUS__LOCKED_BLK 0x0400 232#define INTR__UNSUP_CMD 0x0800
233#define INTR_STATUS__UNSUP_CMD 0x0800 233#define INTR__INT_ACT 0x1000
234#define INTR_STATUS__INT_ACT 0x1000 234#define INTR__RST_COMP 0x2000
235#define INTR_STATUS__RST_COMP 0x2000 235#define INTR__PIPE_CMD_ERR 0x4000
236#define INTR_STATUS__PIPE_CMD_ERR 0x4000 236#define INTR__PAGE_XFER_INC 0x8000
237#define INTR_STATUS__PAGE_XFER_INC 0x8000
238
239#define INTR_EN__ECC_TRANSACTION_DONE 0x0001
240#define INTR_EN__ECC_ERR 0x0002
241#define INTR_EN__DMA_CMD_COMP 0x0004
242#define INTR_EN__TIME_OUT 0x0008
243#define INTR_EN__PROGRAM_FAIL 0x0010
244#define INTR_EN__ERASE_FAIL 0x0020
245#define INTR_EN__LOAD_COMP 0x0040
246#define INTR_EN__PROGRAM_COMP 0x0080
247#define INTR_EN__ERASE_COMP 0x0100
248#define INTR_EN__PIPE_CPYBCK_CMD_COMP 0x0200
249#define INTR_EN__LOCKED_BLK 0x0400
250#define INTR_EN__UNSUP_CMD 0x0800
251#define INTR_EN__INT_ACT 0x1000
252#define INTR_EN__RST_COMP 0x2000
253#define INTR_EN__PIPE_CMD_ERR 0x4000
254#define INTR_EN__PAGE_XFER_INC 0x8000
255 237
256#define PAGE_CNT(__bank) (0x430 + ((__bank) * 0x50)) 238#define PAGE_CNT(__bank) (0x430 + ((__bank) * 0x50))
257#define ERR_PAGE_ADDR(__bank) (0x440 + ((__bank) * 0x50)) 239#define ERR_PAGE_ADDR(__bank) (0x440 + ((__bank) * 0x50))
@@ -284,20 +266,13 @@
284#define IGNORE_ECC_DONE__FLAG 0x0001 266#define IGNORE_ECC_DONE__FLAG 0x0001
285 267
286#define DMA_INTR 0x720 268#define DMA_INTR 0x720
269#define DMA_INTR_EN 0x730
287#define DMA_INTR__TARGET_ERROR 0x0001 270#define DMA_INTR__TARGET_ERROR 0x0001
288#define DMA_INTR__DESC_COMP_CHANNEL0 0x0002 271#define DMA_INTR__DESC_COMP_CHANNEL0 0x0002
289#define DMA_INTR__DESC_COMP_CHANNEL1 0x0004 272#define DMA_INTR__DESC_COMP_CHANNEL1 0x0004
290#define DMA_INTR__DESC_COMP_CHANNEL2 0x0008 273#define DMA_INTR__DESC_COMP_CHANNEL2 0x0008
291#define DMA_INTR__DESC_COMP_CHANNEL3 0x0010 274#define DMA_INTR__DESC_COMP_CHANNEL3 0x0010
292#define DMA_INTR__MEMCOPY_DESC_COMP 0x0020 275#define DMA_INTR__MEMCOPY_DESC_COMP 0x0020
293
294#define DMA_INTR_EN 0x730
295#define DMA_INTR_EN__TARGET_ERROR 0x0001
296#define DMA_INTR_EN__DESC_COMP_CHANNEL0 0x0002
297#define DMA_INTR_EN__DESC_COMP_CHANNEL1 0x0004
298#define DMA_INTR_EN__DESC_COMP_CHANNEL2 0x0008
299#define DMA_INTR_EN__DESC_COMP_CHANNEL3 0x0010
300#define DMA_INTR_EN__MEMCOPY_DESC_COMP 0x0020
301 276
302#define TARGET_ERR_ADDR_LO 0x740 277#define TARGET_ERR_ADDR_LO 0x740
303#define TARGET_ERR_ADDR_LO__VALUE 0xffff 278#define TARGET_ERR_ADDR_LO__VALUE 0xffff