diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2009-06-02 05:37:53 -0400 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2009-11-12 02:31:41 -0500 |
commit | 06ecb04ac5c038248d2bcee92a2a4259f2acfa31 (patch) | |
tree | 93d0133ce29590cab534caaeebd59c130a61333d /drivers/mtd/nand | |
parent | 13e1add1073f55d5361e5357016b631efc03bff8 (diff) |
mxc_nand: merge send_read_page and send_prog_page
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r-- | drivers/mtd/nand/mxc_nand.c | 54 |
1 files changed, 13 insertions, 41 deletions
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c index dafa1f0e04db..8aa8a429e6b8 100644 --- a/drivers/mtd/nand/mxc_nand.c +++ b/drivers/mtd/nand/mxc_nand.c | |||
@@ -226,12 +226,10 @@ static void send_addr(struct mxc_nand_host *host, uint16_t addr, int islast) | |||
226 | wait_op_done(host, TROP_US_DELAY, addr, islast); | 226 | wait_op_done(host, TROP_US_DELAY, addr, islast); |
227 | } | 227 | } |
228 | 228 | ||
229 | /* This function requests the NANDFC to initate the transfer | 229 | static void send_page(struct mxc_nand_host *host, uint8_t buf_id, |
230 | * of data currently in the NANDFC RAM buffer to the NAND device. */ | 230 | int spare_only, unsigned int ops) |
231 | static void send_prog_page(struct mxc_nand_host *host, uint8_t buf_id, | ||
232 | int spare_only) | ||
233 | { | 231 | { |
234 | DEBUG(MTD_DEBUG_LEVEL3, "send_prog_page (%d)\n", spare_only); | 232 | DEBUG(MTD_DEBUG_LEVEL3, "send_page (%d)\n", spare_only); |
235 | 233 | ||
236 | /* NANDFC buffer 0 is used for page read/write */ | 234 | /* NANDFC buffer 0 is used for page read/write */ |
237 | writew(buf_id, host->regs + NFC_BUF_ADDR); | 235 | writew(buf_id, host->regs + NFC_BUF_ADDR); |
@@ -246,33 +244,7 @@ static void send_prog_page(struct mxc_nand_host *host, uint8_t buf_id, | |||
246 | writew(config1, host->regs + NFC_CONFIG1); | 244 | writew(config1, host->regs + NFC_CONFIG1); |
247 | } | 245 | } |
248 | 246 | ||
249 | writew(NFC_INPUT, host->regs + NFC_CONFIG2); | 247 | writew(ops, host->regs + NFC_CONFIG2); |
250 | |||
251 | /* Wait for operation to complete */ | ||
252 | wait_op_done(host, TROP_US_DELAY, spare_only, true); | ||
253 | } | ||
254 | |||
255 | /* Requests NANDFC to initated the transfer of data from the | ||
256 | * NAND device into in the NANDFC ram buffer. */ | ||
257 | static void send_read_page(struct mxc_nand_host *host, uint8_t buf_id, | ||
258 | int spare_only) | ||
259 | { | ||
260 | DEBUG(MTD_DEBUG_LEVEL3, "send_read_page (%d)\n", spare_only); | ||
261 | |||
262 | /* NANDFC buffer 0 is used for page read/write */ | ||
263 | writew(buf_id, host->regs + NFC_BUF_ADDR); | ||
264 | |||
265 | /* Configure spare or page+spare access */ | ||
266 | if (!host->pagesize_2k) { | ||
267 | uint32_t config1 = readw(host->regs + NFC_CONFIG1); | ||
268 | if (spare_only) | ||
269 | config1 |= NFC_SP_EN; | ||
270 | else | ||
271 | config1 &= ~NFC_SP_EN; | ||
272 | writew(config1, host->regs + NFC_CONFIG1); | ||
273 | } | ||
274 | |||
275 | writew(NFC_OUTPUT, host->regs + NFC_CONFIG2); | ||
276 | 248 | ||
277 | /* Wait for operation to complete */ | 249 | /* Wait for operation to complete */ |
278 | wait_op_done(host, TROP_US_DELAY, spare_only, true); | 250 | wait_op_done(host, TROP_US_DELAY, spare_only, true); |
@@ -756,13 +728,13 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command, | |||
756 | break; | 728 | break; |
757 | 729 | ||
758 | case NAND_CMD_PAGEPROG: | 730 | case NAND_CMD_PAGEPROG: |
759 | send_prog_page(host, 0, host->spare_only); | 731 | send_page(host, 0, host->spare_only, NFC_INPUT); |
760 | 732 | ||
761 | if (host->pagesize_2k) { | 733 | if (host->pagesize_2k) { |
762 | /* data in 4 areas datas */ | 734 | /* data in 4 areas datas */ |
763 | send_prog_page(host, 1, host->spare_only); | 735 | send_page(host, 1, host->spare_only, NFC_INPUT); |
764 | send_prog_page(host, 2, host->spare_only); | 736 | send_page(host, 2, host->spare_only, NFC_INPUT); |
765 | send_prog_page(host, 3, host->spare_only); | 737 | send_page(host, 3, host->spare_only, NFC_INPUT); |
766 | } | 738 | } |
767 | 739 | ||
768 | break; | 740 | break; |
@@ -827,12 +799,12 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command, | |||
827 | /* send read confirm command */ | 799 | /* send read confirm command */ |
828 | send_cmd(host, NAND_CMD_READSTART, true); | 800 | send_cmd(host, NAND_CMD_READSTART, true); |
829 | /* read for each AREA */ | 801 | /* read for each AREA */ |
830 | send_read_page(host, 0, host->spare_only); | 802 | send_page(host, 0, host->spare_only, NFC_OUTPUT); |
831 | send_read_page(host, 1, host->spare_only); | 803 | send_page(host, 1, host->spare_only, NFC_OUTPUT); |
832 | send_read_page(host, 2, host->spare_only); | 804 | send_page(host, 2, host->spare_only, NFC_OUTPUT); |
833 | send_read_page(host, 3, host->spare_only); | 805 | send_page(host, 3, host->spare_only, NFC_OUTPUT); |
834 | } else | 806 | } else |
835 | send_read_page(host, 0, host->spare_only); | 807 | send_page(host, 0, host->spare_only, NFC_OUTPUT); |
836 | break; | 808 | break; |
837 | 809 | ||
838 | case NAND_CMD_READID: | 810 | case NAND_CMD_READID: |