提交 2d69c7fa 编写于 作者: S Sascha Hauer

mxc_nand: Get rid of pagesize_2k flag

Later versions of this controller also allow 4k pagesize,
so use mtd->writesize instead of a flag.
Signed-off-by: NSascha Hauer <s.hauer@pengutronix.de>
上级 c6de7e1b
...@@ -101,7 +101,6 @@ struct mxc_nand_host { ...@@ -101,7 +101,6 @@ struct mxc_nand_host {
void __iomem *base; void __iomem *base;
void __iomem *regs; void __iomem *regs;
int status_request; int status_request;
int pagesize_2k;
struct clk *clk; struct clk *clk;
int clk_act; int clk_act;
int irq; int irq;
...@@ -214,11 +213,13 @@ static void send_addr(struct mxc_nand_host *host, uint16_t addr, int islast) ...@@ -214,11 +213,13 @@ static void send_addr(struct mxc_nand_host *host, uint16_t addr, int islast)
wait_op_done(host, TROP_US_DELAY, islast); wait_op_done(host, TROP_US_DELAY, islast);
} }
static void send_page(struct mxc_nand_host *host, unsigned int ops) static void send_page(struct mtd_info *mtd, unsigned int ops)
{ {
struct nand_chip *nand_chip = mtd->priv;
struct mxc_nand_host *host = nand_chip->priv;
int bufs, i; int bufs, i;
if (host->pagesize_2k) if (mtd->writesize > 512)
bufs = 4; bufs = 4;
else else
bufs = 1; bufs = 1;
...@@ -490,7 +491,7 @@ static void mxc_do_addr_cycle(struct mtd_info *mtd, int column, int page_addr) ...@@ -490,7 +491,7 @@ static void mxc_do_addr_cycle(struct mtd_info *mtd, int column, int page_addr)
* the full page. * the full page.
*/ */
send_addr(host, 0, page_addr == -1); send_addr(host, 0, page_addr == -1);
if (host->pagesize_2k) if (mtd->writesize > 512)
/* another col addr cycle for 2k page */ /* another col addr cycle for 2k page */
send_addr(host, 0, false); send_addr(host, 0, false);
} }
...@@ -500,7 +501,7 @@ static void mxc_do_addr_cycle(struct mtd_info *mtd, int column, int page_addr) ...@@ -500,7 +501,7 @@ static void mxc_do_addr_cycle(struct mtd_info *mtd, int column, int page_addr)
/* paddr_0 - p_addr_7 */ /* paddr_0 - p_addr_7 */
send_addr(host, (page_addr & 0xff), false); send_addr(host, (page_addr & 0xff), false);
if (host->pagesize_2k) { if (mtd->writesize > 512) {
if (mtd->size >= 0x10000000) { if (mtd->size >= 0x10000000) {
/* paddr_8 - paddr_15 */ /* paddr_8 - paddr_15 */
send_addr(host, (page_addr >> 8) & 0xff, false); send_addr(host, (page_addr >> 8) & 0xff, false);
...@@ -554,16 +555,16 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command, ...@@ -554,16 +555,16 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
else else
host->buf_start = column + mtd->writesize; host->buf_start = column + mtd->writesize;
if (host->pagesize_2k) if (mtd->writesize > 512)
command = NAND_CMD_READ0; /* only READ0 is valid */ command = NAND_CMD_READ0; /* only READ0 is valid */
send_cmd(host, command, false); send_cmd(host, command, false);
mxc_do_addr_cycle(mtd, column, page_addr); mxc_do_addr_cycle(mtd, column, page_addr);
if (host->pagesize_2k) if (mtd->writesize > 512)
send_cmd(host, NAND_CMD_READSTART, true); send_cmd(host, NAND_CMD_READSTART, true);
send_page(host, NFC_OUTPUT); send_page(mtd, NFC_OUTPUT);
memcpy(host->data_buf, host->main_area0, mtd->writesize); memcpy(host->data_buf, host->main_area0, mtd->writesize);
copy_spare(mtd, true); copy_spare(mtd, true);
...@@ -578,7 +579,7 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command, ...@@ -578,7 +579,7 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
* pointer to spare area, we must write the whole page * pointer to spare area, we must write the whole page
* including OOB together. * including OOB together.
*/ */
if (host->pagesize_2k) if (mtd->writesize > 512)
/* call ourself to read a page */ /* call ourself to read a page */
mxc_nand_command(mtd, NAND_CMD_READ0, 0, mxc_nand_command(mtd, NAND_CMD_READ0, 0,
page_addr); page_addr);
...@@ -586,13 +587,13 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command, ...@@ -586,13 +587,13 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
host->buf_start = column; host->buf_start = column;
/* Set program pointer to spare region */ /* Set program pointer to spare region */
if (!host->pagesize_2k) if (mtd->writesize == 512)
send_cmd(host, NAND_CMD_READOOB, false); send_cmd(host, NAND_CMD_READOOB, false);
} else { } else {
host->buf_start = column; host->buf_start = column;
/* Set program pointer to page start */ /* Set program pointer to page start */
if (!host->pagesize_2k) if (mtd->writesize == 512)
send_cmd(host, NAND_CMD_READ0, false); send_cmd(host, NAND_CMD_READ0, false);
} }
...@@ -603,7 +604,7 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command, ...@@ -603,7 +604,7 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
case NAND_CMD_PAGEPROG: case NAND_CMD_PAGEPROG:
memcpy(host->main_area0, host->data_buf, mtd->writesize); memcpy(host->main_area0, host->data_buf, mtd->writesize);
copy_spare(mtd, false); copy_spare(mtd, false);
send_page(host, NFC_INPUT); send_page(mtd, NFC_INPUT);
send_cmd(host, command, true); send_cmd(host, command, true);
mxc_do_addr_cycle(mtd, column, page_addr); mxc_do_addr_cycle(mtd, column, page_addr);
break; break;
...@@ -745,10 +746,8 @@ static int __init mxcnd_probe(struct platform_device *pdev) ...@@ -745,10 +746,8 @@ static int __init mxcnd_probe(struct platform_device *pdev)
goto escan; goto escan;
} }
if (mtd->writesize == 2048) { if (mtd->writesize == 2048)
host->pagesize_2k = 1;
this->ecc.layout = &nand_hw_eccoob_largepage; this->ecc.layout = &nand_hw_eccoob_largepage;
}
/* second phase scan */ /* second phase scan */
if (nand_scan_tail(mtd)) { if (nand_scan_tail(mtd)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册