#define ARASAN_NAND_MEM_ADDR1_PAGE_SHIFT 16
#define ARASAN_NAND_MEM_ADDR2_PAGE_MASK 0xFF
#define ARASAN_NAND_MEM_ADDR2_CS_MASK 0xC0000000
+#define ARASAN_NAND_MEM_ADDR2_CS0_MASK (0x3 << 30)
+#define ARASAN_NAND_MEM_ADDR2_CS1_MASK (0x1 << 30)
#define ARASAN_NAND_MEM_ADDR2_BCH_MASK 0xE000000
#define ARASAN_NAND_MEM_ADDR2_BCH_SHIFT 25
static void arasan_nand_select_chip(struct mtd_info *mtd, int chip)
{
+ u32 reg_val;
+
+ reg_val = readl(&arasan_nand_base->memadr_reg2);
+ if (chip == 0) {
+ reg_val &= ~ARASAN_NAND_MEM_ADDR2_CS0_MASK;
+ writel(reg_val, &arasan_nand_base->memadr_reg2);
+ } else if (chip == 1) {
+ reg_val |= ARASAN_NAND_MEM_ADDR2_CS1_MASK;
+ writel(reg_val, &arasan_nand_base->memadr_reg2);
+ }
}
static void arasan_nand_enable_ecc(void)
reg_val &= ~ARASAN_NAND_MEM_ADDR2_PAGE_MASK;
reg_val |= (page_addr >> ARASAN_NAND_MEM_ADDR1_PAGE_SHIFT);
writel(reg_val, &arasan_nand_base->memadr_reg2);
- reg_val = readl(&arasan_nand_base->memadr_reg2);
- reg_val &= ~ARASAN_NAND_MEM_ADDR2_CS_MASK;
- writel(reg_val, &arasan_nand_base->memadr_reg2);
return 0;
}
reg_val &= ~ARASAN_NAND_MEM_ADDR2_PAGE_MASK;
reg_val |= (page_addr >> ARASAN_NAND_MEM_ADDR1_PAGE_SHIFT);
writel(reg_val, &arasan_nand_base->memadr_reg2);
- reg_val = readl(&arasan_nand_base->memadr_reg2);
- reg_val &= ~ARASAN_NAND_MEM_ADDR2_CS_MASK;
- writel(reg_val, &arasan_nand_base->memadr_reg2);
writel(curr_cmd->pgm, &arasan_nand_base->pgm_reg);
while (!(readl(&arasan_nand_base->intsts_reg) &
reg_val |= (1 << ARASAN_NAND_PKT_REG_PKT_CNT_SHFT) | 1;
writel(reg_val, &arasan_nand_base->pkt_reg);
- reg_val = readl(&arasan_nand_base->memadr_reg2);
- reg_val &= ~ARASAN_NAND_MEM_ADDR2_CS_MASK;
- writel(reg_val, &arasan_nand_base->memadr_reg2);
-
writel(curr_cmd->pgm, &arasan_nand_base->pgm_reg);
while (!(readl(&arasan_nand_base->intsts_reg) &
ARASAN_NAND_INT_STS_XFR_CMPLT_MASK) && timeout) {
reg_val |= (page_addr >> ARASAN_NAND_MEM_ADDR1_PAGE_SHIFT);
writel(reg_val, &arasan_nand_base->memadr_reg2);
- reg_val = readl(&arasan_nand_base->memadr_reg2);
- reg_val &= ~ARASAN_NAND_MEM_ADDR2_CS_MASK;
- writel(reg_val, &arasan_nand_base->memadr_reg2);
buf_index = 0;
return 0;
writel(0x0, &arasan_nand_base->pgm_reg);
/* first scan to find the device and get the page size */
- if (nand_scan_ident(mtd, 1, NULL)) {
+ if (nand_scan_ident(mtd, CONFIG_SYS_NAND_MAX_CHIPS, NULL)) {
printf("%s: nand_scan_ident failed\n", __func__);
goto fail;
}