1 commit 97d90da8a886949f09bb4754843fb0b504956ad2
2 Author: Boris Brezillon <boris.brezillon@free-electrons.com>
3 Date: Thu Nov 30 18:01:29 2017 +0100
5 mtd: nand: provide several helpers to do common NAND operations
7 This is part of the process of removing direct calls to ->cmdfunc()
8 outside of the core in order to introduce a better interface to execute
11 Here we provide several helpers and make use of them to remove all
12 direct calls to ->cmdfunc(). This way, we can easily modify those
13 helpers to make use of the new ->exec_op() interface when available.
15 Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
16 [miquel.raynal@free-electrons.com: rebased and fixed some conflicts]
17 Signed-off-by: Miquel Raynal <miquel.raynal@free-electrons.com>
18 Acked-by: Masahiro Yamada <yamada.masahiro@socionext.com>
20 --- a/drivers/mtd/nand/nand_base.c
21 +++ b/drivers/mtd/nand/nand_base.c
22 @@ -561,14 +561,19 @@ static int nand_block_markbad_lowlevel(s
23 static int nand_check_wp(struct mtd_info *mtd)
25 struct nand_chip *chip = mtd_to_nand(mtd);
29 /* Broken xD cards report WP despite being writable */
30 if (chip->options & NAND_BROKEN_XD)
33 /* Check the WP bit */
34 - chip->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1);
35 - return (chip->read_byte(mtd) & NAND_STATUS_WP) ? 0 : 1;
36 + ret = nand_status_op(chip, &status);
40 + return status & NAND_STATUS_WP ? 0 : 1;
44 @@ -667,10 +672,17 @@ EXPORT_SYMBOL_GPL(nand_wait_ready);
45 static void nand_wait_status_ready(struct mtd_info *mtd, unsigned long timeo)
47 register struct nand_chip *chip = mtd_to_nand(mtd);
50 timeo = jiffies + msecs_to_jiffies(timeo);
52 - if ((chip->read_byte(mtd) & NAND_STATUS_READY))
55 + ret = nand_read_data_op(chip, &status, sizeof(status), true);
59 + if (status & NAND_STATUS_READY)
61 touch_softlockup_watchdog();
62 } while (time_before(jiffies, timeo));
63 @@ -1021,7 +1033,15 @@ static void panic_nand_wait(struct mtd_i
64 if (chip->dev_ready(mtd))
67 - if (chip->read_byte(mtd) & NAND_STATUS_READY)
71 + ret = nand_read_data_op(chip, &status, sizeof(status),
76 + if (status & NAND_STATUS_READY)
80 @@ -1038,8 +1058,9 @@ static void panic_nand_wait(struct mtd_i
81 static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip)
85 unsigned long timeo = 400;
90 * Apply this short delay always to ensure that we do wait tWB in any
91 @@ -1047,7 +1068,9 @@ static int nand_wait(struct mtd_info *mt
95 - chip->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1);
96 + ret = nand_status_op(chip, NULL);
100 if (in_interrupt() || oops_in_progress)
101 panic_nand_wait(mtd, chip, timeo);
102 @@ -1058,14 +1081,22 @@ static int nand_wait(struct mtd_info *mt
103 if (chip->dev_ready(mtd))
106 - if (chip->read_byte(mtd) & NAND_STATUS_READY)
107 + ret = nand_read_data_op(chip, &status,
108 + sizeof(status), true);
112 + if (status & NAND_STATUS_READY)
116 } while (time_before(jiffies, timeo));
119 - status = (int)chip->read_byte(mtd);
120 + ret = nand_read_data_op(chip, &status, sizeof(status), true);
124 /* This can happen if in case of timeout or buggy dev_ready */
125 WARN_ON(!(status & NAND_STATUS_READY));
127 @@ -1220,6 +1251,516 @@ static void nand_release_data_interface(
131 + * nand_read_page_op - Do a READ PAGE operation
132 + * @chip: The NAND chip
133 + * @page: page to read
134 + * @offset_in_page: offset within the page
135 + * @buf: buffer used to store the data
136 + * @len: length of the buffer
138 + * This function issues a READ PAGE operation.
139 + * This function does not select/unselect the CS line.
141 + * Returns 0 on success, a negative error code otherwise.
143 +int nand_read_page_op(struct nand_chip *chip, unsigned int page,
144 + unsigned int offset_in_page, void *buf, unsigned int len)
146 + struct mtd_info *mtd = nand_to_mtd(chip);
151 + if (offset_in_page + len > mtd->writesize + mtd->oobsize)
154 + chip->cmdfunc(mtd, NAND_CMD_READ0, offset_in_page, page);
156 + chip->read_buf(mtd, buf, len);
160 +EXPORT_SYMBOL_GPL(nand_read_page_op);
163 + * nand_read_param_page_op - Do a READ PARAMETER PAGE operation
164 + * @chip: The NAND chip
165 + * @page: parameter page to read
166 + * @buf: buffer used to store the data
167 + * @len: length of the buffer
169 + * This function issues a READ PARAMETER PAGE operation.
170 + * This function does not select/unselect the CS line.
172 + * Returns 0 on success, a negative error code otherwise.
174 +static int nand_read_param_page_op(struct nand_chip *chip, u8 page, void *buf,
177 + struct mtd_info *mtd = nand_to_mtd(chip);
184 + chip->cmdfunc(mtd, NAND_CMD_PARAM, page, -1);
185 + for (i = 0; i < len; i++)
186 + p[i] = chip->read_byte(mtd);
192 + * nand_change_read_column_op - Do a CHANGE READ COLUMN operation
193 + * @chip: The NAND chip
194 + * @offset_in_page: offset within the page
195 + * @buf: buffer used to store the data
196 + * @len: length of the buffer
197 + * @force_8bit: force 8-bit bus access
199 + * This function issues a CHANGE READ COLUMN operation.
200 + * This function does not select/unselect the CS line.
202 + * Returns 0 on success, a negative error code otherwise.
204 +int nand_change_read_column_op(struct nand_chip *chip,
205 + unsigned int offset_in_page, void *buf,
206 + unsigned int len, bool force_8bit)
208 + struct mtd_info *mtd = nand_to_mtd(chip);
213 + if (offset_in_page + len > mtd->writesize + mtd->oobsize)
216 + chip->cmdfunc(mtd, NAND_CMD_RNDOUT, offset_in_page, -1);
218 + chip->read_buf(mtd, buf, len);
222 +EXPORT_SYMBOL_GPL(nand_change_read_column_op);
225 + * nand_read_oob_op - Do a READ OOB operation
226 + * @chip: The NAND chip
227 + * @page: page to read
228 + * @offset_in_oob: offset within the OOB area
229 + * @buf: buffer used to store the data
230 + * @len: length of the buffer
232 + * This function issues a READ OOB operation.
233 + * This function does not select/unselect the CS line.
235 + * Returns 0 on success, a negative error code otherwise.
237 +int nand_read_oob_op(struct nand_chip *chip, unsigned int page,
238 + unsigned int offset_in_oob, void *buf, unsigned int len)
240 + struct mtd_info *mtd = nand_to_mtd(chip);
245 + if (offset_in_oob + len > mtd->oobsize)
248 + chip->cmdfunc(mtd, NAND_CMD_READOOB, offset_in_oob, page);
250 + chip->read_buf(mtd, buf, len);
254 +EXPORT_SYMBOL_GPL(nand_read_oob_op);
257 + * nand_prog_page_begin_op - starts a PROG PAGE operation
258 + * @chip: The NAND chip
259 + * @page: page to write
260 + * @offset_in_page: offset within the page
261 + * @buf: buffer containing the data to write to the page
262 + * @len: length of the buffer
264 + * This function issues the first half of a PROG PAGE operation.
265 + * This function does not select/unselect the CS line.
267 + * Returns 0 on success, a negative error code otherwise.
269 +int nand_prog_page_begin_op(struct nand_chip *chip, unsigned int page,
270 + unsigned int offset_in_page, const void *buf,
273 + struct mtd_info *mtd = nand_to_mtd(chip);
278 + if (offset_in_page + len > mtd->writesize + mtd->oobsize)
281 + chip->cmdfunc(mtd, NAND_CMD_SEQIN, offset_in_page, page);
284 + chip->write_buf(mtd, buf, len);
288 +EXPORT_SYMBOL_GPL(nand_prog_page_begin_op);
291 + * nand_prog_page_end_op - ends a PROG PAGE operation
292 + * @chip: The NAND chip
294 + * This function issues the second half of a PROG PAGE operation.
295 + * This function does not select/unselect the CS line.
297 + * Returns 0 on success, a negative error code otherwise.
299 +int nand_prog_page_end_op(struct nand_chip *chip)
301 + struct mtd_info *mtd = nand_to_mtd(chip);
304 + chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1);
306 + status = chip->waitfunc(mtd, chip);
307 + if (status & NAND_STATUS_FAIL)
312 +EXPORT_SYMBOL_GPL(nand_prog_page_end_op);
315 + * nand_prog_page_op - Do a full PROG PAGE operation
316 + * @chip: The NAND chip
317 + * @page: page to write
318 + * @offset_in_page: offset within the page
319 + * @buf: buffer containing the data to write to the page
320 + * @len: length of the buffer
322 + * This function issues a full PROG PAGE operation.
323 + * This function does not select/unselect the CS line.
325 + * Returns 0 on success, a negative error code otherwise.
327 +int nand_prog_page_op(struct nand_chip *chip, unsigned int page,
328 + unsigned int offset_in_page, const void *buf,
331 + struct mtd_info *mtd = nand_to_mtd(chip);
337 + if (offset_in_page + len > mtd->writesize + mtd->oobsize)
340 + chip->cmdfunc(mtd, NAND_CMD_SEQIN, offset_in_page, page);
341 + chip->write_buf(mtd, buf, len);
342 + chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1);
344 + status = chip->waitfunc(mtd, chip);
345 + if (status & NAND_STATUS_FAIL)
350 +EXPORT_SYMBOL_GPL(nand_prog_page_op);
353 + * nand_change_write_column_op - Do a CHANGE WRITE COLUMN operation
354 + * @chip: The NAND chip
355 + * @offset_in_page: offset within the page
356 + * @buf: buffer containing the data to send to the NAND
357 + * @len: length of the buffer
358 + * @force_8bit: force 8-bit bus access
360 + * This function issues a CHANGE WRITE COLUMN operation.
361 + * This function does not select/unselect the CS line.
363 + * Returns 0 on success, a negative error code otherwise.
365 +int nand_change_write_column_op(struct nand_chip *chip,
366 + unsigned int offset_in_page,
367 + const void *buf, unsigned int len,
370 + struct mtd_info *mtd = nand_to_mtd(chip);
375 + if (offset_in_page + len > mtd->writesize + mtd->oobsize)
378 + chip->cmdfunc(mtd, NAND_CMD_RNDIN, offset_in_page, -1);
380 + chip->write_buf(mtd, buf, len);
384 +EXPORT_SYMBOL_GPL(nand_change_write_column_op);
387 + * nand_readid_op - Do a READID operation
388 + * @chip: The NAND chip
389 + * @addr: address cycle to pass after the READID command
390 + * @buf: buffer used to store the ID
391 + * @len: length of the buffer
393 + * This function sends a READID command and reads back the ID returned by the
395 + * This function does not select/unselect the CS line.
397 + * Returns 0 on success, a negative error code otherwise.
399 +int nand_readid_op(struct nand_chip *chip, u8 addr, void *buf,
402 + struct mtd_info *mtd = nand_to_mtd(chip);
409 + chip->cmdfunc(mtd, NAND_CMD_READID, addr, -1);
411 + for (i = 0; i < len; i++)
412 + id[i] = chip->read_byte(mtd);
416 +EXPORT_SYMBOL_GPL(nand_readid_op);
419 + * nand_status_op - Do a STATUS operation
420 + * @chip: The NAND chip
421 + * @status: out variable to store the NAND status
423 + * This function sends a STATUS command and reads back the status returned by
425 + * This function does not select/unselect the CS line.
427 + * Returns 0 on success, a negative error code otherwise.
429 +int nand_status_op(struct nand_chip *chip, u8 *status)
431 + struct mtd_info *mtd = nand_to_mtd(chip);
433 + chip->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1);
435 + *status = chip->read_byte(mtd);
439 +EXPORT_SYMBOL_GPL(nand_status_op);
442 + * nand_exit_status_op - Exit a STATUS operation
443 + * @chip: The NAND chip
445 + * This function sends a READ0 command to cancel the effect of the STATUS
446 + * command to avoid reading only the status until a new read command is sent.
448 + * This function does not select/unselect the CS line.
450 + * Returns 0 on success, a negative error code otherwise.
452 +int nand_exit_status_op(struct nand_chip *chip)
454 + struct mtd_info *mtd = nand_to_mtd(chip);
456 + chip->cmdfunc(mtd, NAND_CMD_READ0, -1, -1);
460 +EXPORT_SYMBOL_GPL(nand_exit_status_op);
463 + * nand_erase_op - Do an erase operation
464 + * @chip: The NAND chip
465 + * @eraseblock: block to erase
467 + * This function sends an ERASE command and waits for the NAND to be ready
468 + * before returning.
469 + * This function does not select/unselect the CS line.
471 + * Returns 0 on success, a negative error code otherwise.
473 +int nand_erase_op(struct nand_chip *chip, unsigned int eraseblock)
475 + struct mtd_info *mtd = nand_to_mtd(chip);
476 + unsigned int page = eraseblock <<
477 + (chip->phys_erase_shift - chip->page_shift);
480 + chip->cmdfunc(mtd, NAND_CMD_ERASE1, -1, page);
481 + chip->cmdfunc(mtd, NAND_CMD_ERASE2, -1, -1);
483 + status = chip->waitfunc(mtd, chip);
487 + if (status & NAND_STATUS_FAIL)
492 +EXPORT_SYMBOL_GPL(nand_erase_op);
495 + * nand_set_features_op - Do a SET FEATURES operation
496 + * @chip: The NAND chip
497 + * @feature: feature id
498 + * @data: 4 bytes of data
500 + * This function sends a SET FEATURES command and waits for the NAND to be
501 + * ready before returning.
502 + * This function does not select/unselect the CS line.
504 + * Returns 0 on success, a negative error code otherwise.
506 +static int nand_set_features_op(struct nand_chip *chip, u8 feature,
509 + struct mtd_info *mtd = nand_to_mtd(chip);
510 + const u8 *params = data;
513 + chip->cmdfunc(mtd, NAND_CMD_SET_FEATURES, feature, -1);
514 + for (i = 0; i < ONFI_SUBFEATURE_PARAM_LEN; ++i)
515 + chip->write_byte(mtd, params[i]);
517 + status = chip->waitfunc(mtd, chip);
518 + if (status & NAND_STATUS_FAIL)
525 + * nand_get_features_op - Do a GET FEATURES operation
526 + * @chip: The NAND chip
527 + * @feature: feature id
528 + * @data: 4 bytes of data
530 + * This function sends a GET FEATURES command and waits for the NAND to be
531 + * ready before returning.
532 + * This function does not select/unselect the CS line.
534 + * Returns 0 on success, a negative error code otherwise.
536 +static int nand_get_features_op(struct nand_chip *chip, u8 feature,
539 + struct mtd_info *mtd = nand_to_mtd(chip);
543 + chip->cmdfunc(mtd, NAND_CMD_GET_FEATURES, feature, -1);
544 + for (i = 0; i < ONFI_SUBFEATURE_PARAM_LEN; ++i)
545 + params[i] = chip->read_byte(mtd);
551 + * nand_reset_op - Do a reset operation
552 + * @chip: The NAND chip
554 + * This function sends a RESET command and waits for the NAND to be ready
555 + * before returning.
556 + * This function does not select/unselect the CS line.
558 + * Returns 0 on success, a negative error code otherwise.
560 +int nand_reset_op(struct nand_chip *chip)
562 + struct mtd_info *mtd = nand_to_mtd(chip);
564 + chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);
568 +EXPORT_SYMBOL_GPL(nand_reset_op);
571 + * nand_read_data_op - Read data from the NAND
572 + * @chip: The NAND chip
573 + * @buf: buffer used to store the data
574 + * @len: length of the buffer
575 + * @force_8bit: force 8-bit bus access
577 + * This function does a raw data read on the bus. Usually used after launching
578 + * another NAND operation like nand_read_page_op().
579 + * This function does not select/unselect the CS line.
581 + * Returns 0 on success, a negative error code otherwise.
583 +int nand_read_data_op(struct nand_chip *chip, void *buf, unsigned int len,
586 + struct mtd_info *mtd = nand_to_mtd(chip);
595 + for (i = 0; i < len; i++)
596 + p[i] = chip->read_byte(mtd);
598 + chip->read_buf(mtd, buf, len);
603 +EXPORT_SYMBOL_GPL(nand_read_data_op);
606 + * nand_write_data_op - Write data from the NAND
607 + * @chip: The NAND chip
608 + * @buf: buffer containing the data to send on the bus
609 + * @len: length of the buffer
610 + * @force_8bit: force 8-bit bus access
612 + * This function does a raw data write on the bus. Usually used after launching
613 + * another NAND operation like nand_write_page_begin_op().
614 + * This function does not select/unselect the CS line.
616 + * Returns 0 on success, a negative error code otherwise.
618 +int nand_write_data_op(struct nand_chip *chip, const void *buf,
619 + unsigned int len, bool force_8bit)
621 + struct mtd_info *mtd = nand_to_mtd(chip);
630 + for (i = 0; i < len; i++)
631 + chip->write_byte(mtd, p[i]);
633 + chip->write_buf(mtd, buf, len);
638 +EXPORT_SYMBOL_GPL(nand_write_data_op);
641 * nand_reset - Reset and initialize a NAND device
642 * @chip: The NAND chip
643 * @chipnr: Internal die id
644 @@ -1240,8 +1781,10 @@ int nand_reset(struct nand_chip *chip, i
645 * interface settings, hence this weird ->select_chip() dance.
647 chip->select_chip(mtd, chipnr);
648 - chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);
649 + ret = nand_reset_op(chip);
650 chip->select_chip(mtd, -1);
654 chip->select_chip(mtd, chipnr);
655 ret = nand_setup_data_interface(chip, chipnr);
656 @@ -1397,9 +1940,19 @@ EXPORT_SYMBOL(nand_check_erased_ecc_chun
657 int nand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
658 uint8_t *buf, int oob_required, int page)
660 - chip->read_buf(mtd, buf, mtd->writesize);
662 - chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
665 + ret = nand_read_data_op(chip, buf, mtd->writesize, false);
669 + if (oob_required) {
670 + ret = nand_read_data_op(chip, chip->oob_poi, mtd->oobsize,
678 EXPORT_SYMBOL(nand_read_page_raw);
679 @@ -1421,29 +1974,46 @@ static int nand_read_page_raw_syndrome(s
680 int eccsize = chip->ecc.size;
681 int eccbytes = chip->ecc.bytes;
682 uint8_t *oob = chip->oob_poi;
684 + int steps, size, ret;
686 for (steps = chip->ecc.steps; steps > 0; steps--) {
687 - chip->read_buf(mtd, buf, eccsize);
688 + ret = nand_read_data_op(chip, buf, eccsize, false);
694 if (chip->ecc.prepad) {
695 - chip->read_buf(mtd, oob, chip->ecc.prepad);
696 + ret = nand_read_data_op(chip, oob, chip->ecc.prepad,
701 oob += chip->ecc.prepad;
704 - chip->read_buf(mtd, oob, eccbytes);
705 + ret = nand_read_data_op(chip, oob, eccbytes, false);
711 if (chip->ecc.postpad) {
712 - chip->read_buf(mtd, oob, chip->ecc.postpad);
713 + ret = nand_read_data_op(chip, oob, chip->ecc.postpad,
718 oob += chip->ecc.postpad;
722 size = mtd->oobsize - (oob - chip->oob_poi);
724 - chip->read_buf(mtd, oob, size);
726 + ret = nand_read_data_op(chip, oob, size, false);
733 @@ -1532,7 +2102,9 @@ static int nand_read_subpage(struct mtd_
734 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, data_col_addr, -1);
736 p = bufpoi + data_col_addr;
737 - chip->read_buf(mtd, p, datafrag_len);
738 + ret = nand_read_data_op(chip, p, datafrag_len, false);
743 for (i = 0; i < eccfrag_len ; i += chip->ecc.bytes, p += chip->ecc.size)
744 @@ -1550,8 +2122,11 @@ static int nand_read_subpage(struct mtd_
748 - chip->cmdfunc(mtd, NAND_CMD_RNDOUT, mtd->writesize, -1);
749 - chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
750 + ret = nand_change_read_column_op(chip, mtd->writesize,
751 + chip->oob_poi, mtd->oobsize,
757 * Send the command to read the particular ECC bytes take care
758 @@ -1565,9 +2140,12 @@ static int nand_read_subpage(struct mtd_
762 - chip->cmdfunc(mtd, NAND_CMD_RNDOUT,
763 - mtd->writesize + aligned_pos, -1);
764 - chip->read_buf(mtd, &chip->oob_poi[aligned_pos], aligned_len);
765 + ret = nand_change_read_column_op(chip,
766 + mtd->writesize + aligned_pos,
767 + &chip->oob_poi[aligned_pos],
768 + aligned_len, false);
773 ret = mtd_ooblayout_get_eccbytes(mtd, chip->buffers->ecccode,
774 @@ -1624,10 +2202,17 @@ static int nand_read_page_hwecc(struct m
776 for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {
777 chip->ecc.hwctl(mtd, NAND_ECC_READ);
778 - chip->read_buf(mtd, p, eccsize);
780 + ret = nand_read_data_op(chip, p, eccsize, false);
784 chip->ecc.calculate(mtd, p, &ecc_calc[i]);
786 - chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
788 + ret = nand_read_data_op(chip, chip->oob_poi, mtd->oobsize, false);
792 ret = mtd_ooblayout_get_eccbytes(mtd, ecc_code, chip->oob_poi, 0,
794 @@ -1686,9 +2271,13 @@ static int nand_read_page_hwecc_oob_firs
795 unsigned int max_bitflips = 0;
797 /* Read the OOB area first */
798 - chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);
799 - chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
800 - chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page);
801 + ret = nand_read_oob_op(chip, page, 0, chip->oob_poi, mtd->oobsize);
805 + ret = nand_read_page_op(chip, page, 0, NULL, 0);
809 ret = mtd_ooblayout_get_eccbytes(mtd, ecc_code, chip->oob_poi, 0,
811 @@ -1699,7 +2288,11 @@ static int nand_read_page_hwecc_oob_firs
814 chip->ecc.hwctl(mtd, NAND_ECC_READ);
815 - chip->read_buf(mtd, p, eccsize);
817 + ret = nand_read_data_op(chip, p, eccsize, false);
821 chip->ecc.calculate(mtd, p, &ecc_calc[i]);
823 stat = chip->ecc.correct(mtd, p, &ecc_code[i], NULL);
824 @@ -1736,7 +2329,7 @@ static int nand_read_page_hwecc_oob_firs
825 static int nand_read_page_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
826 uint8_t *buf, int oob_required, int page)
828 - int i, eccsize = chip->ecc.size;
829 + int ret, i, eccsize = chip->ecc.size;
830 int eccbytes = chip->ecc.bytes;
831 int eccsteps = chip->ecc.steps;
832 int eccpadbytes = eccbytes + chip->ecc.prepad + chip->ecc.postpad;
833 @@ -1748,21 +2341,36 @@ static int nand_read_page_syndrome(struc
836 chip->ecc.hwctl(mtd, NAND_ECC_READ);
837 - chip->read_buf(mtd, p, eccsize);
839 + ret = nand_read_data_op(chip, p, eccsize, false);
843 if (chip->ecc.prepad) {
844 - chip->read_buf(mtd, oob, chip->ecc.prepad);
845 + ret = nand_read_data_op(chip, oob, chip->ecc.prepad,
850 oob += chip->ecc.prepad;
853 chip->ecc.hwctl(mtd, NAND_ECC_READSYN);
854 - chip->read_buf(mtd, oob, eccbytes);
856 + ret = nand_read_data_op(chip, oob, eccbytes, false);
860 stat = chip->ecc.correct(mtd, p, oob, NULL);
864 if (chip->ecc.postpad) {
865 - chip->read_buf(mtd, oob, chip->ecc.postpad);
866 + ret = nand_read_data_op(chip, oob, chip->ecc.postpad,
871 oob += chip->ecc.postpad;
874 @@ -1786,8 +2394,11 @@ static int nand_read_page_syndrome(struc
876 /* Calculate remaining oob bytes */
877 i = mtd->oobsize - (oob - chip->oob_poi);
879 - chip->read_buf(mtd, oob, i);
881 + ret = nand_read_data_op(chip, oob, i, false);
888 @@ -1908,8 +2519,11 @@ static int nand_do_read_ops(struct mtd_i
892 - if (nand_standard_page_accessors(&chip->ecc))
893 - chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page);
894 + if (nand_standard_page_accessors(&chip->ecc)) {
895 + ret = nand_read_page_op(chip, page, 0, NULL, 0);
901 * Now read the page into the buffer. Absent an error,
902 @@ -2068,9 +2682,7 @@ static int nand_read(struct mtd_info *mt
904 int nand_read_oob_std(struct mtd_info *mtd, struct nand_chip *chip, int page)
906 - chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);
907 - chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
909 + return nand_read_oob_op(chip, page, 0, chip->oob_poi, mtd->oobsize);
911 EXPORT_SYMBOL(nand_read_oob_std);
913 @@ -2088,25 +2700,43 @@ int nand_read_oob_syndrome(struct mtd_in
914 int chunk = chip->ecc.bytes + chip->ecc.prepad + chip->ecc.postpad;
915 int eccsize = chip->ecc.size;
916 uint8_t *bufpoi = chip->oob_poi;
917 - int i, toread, sndrnd = 0, pos;
918 + int i, toread, sndrnd = 0, pos, ret;
920 + ret = nand_read_page_op(chip, page, chip->ecc.size, NULL, 0);
924 - chip->cmdfunc(mtd, NAND_CMD_READ0, chip->ecc.size, page);
925 for (i = 0; i < chip->ecc.steps; i++) {
929 pos = eccsize + i * (eccsize + chunk);
930 if (mtd->writesize > 512)
931 - chip->cmdfunc(mtd, NAND_CMD_RNDOUT, pos, -1);
932 + ret = nand_change_read_column_op(chip, pos,
936 - chip->cmdfunc(mtd, NAND_CMD_READ0, pos, page);
937 + ret = nand_read_page_op(chip, page, pos, NULL,
944 toread = min_t(int, length, chunk);
945 - chip->read_buf(mtd, bufpoi, toread);
947 + ret = nand_read_data_op(chip, bufpoi, toread, false);
955 - chip->read_buf(mtd, bufpoi, length);
957 + ret = nand_read_data_op(chip, bufpoi, length, false);
964 @@ -2120,18 +2750,8 @@ EXPORT_SYMBOL(nand_read_oob_syndrome);
966 int nand_write_oob_std(struct mtd_info *mtd, struct nand_chip *chip, int page)
969 - const uint8_t *buf = chip->oob_poi;
970 - int length = mtd->oobsize;
972 - chip->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->writesize, page);
973 - chip->write_buf(mtd, buf, length);
974 - /* Send command to program the OOB data */
975 - chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1);
977 - status = chip->waitfunc(mtd, chip);
979 - return status & NAND_STATUS_FAIL ? -EIO : 0;
980 + return nand_prog_page_op(chip, page, mtd->writesize, chip->oob_poi,
983 EXPORT_SYMBOL(nand_write_oob_std);
985 @@ -2147,7 +2767,7 @@ int nand_write_oob_syndrome(struct mtd_i
987 int chunk = chip->ecc.bytes + chip->ecc.prepad + chip->ecc.postpad;
988 int eccsize = chip->ecc.size, length = mtd->oobsize;
989 - int i, len, pos, status = 0, sndcmd = 0, steps = chip->ecc.steps;
990 + int ret, i, len, pos, sndcmd = 0, steps = chip->ecc.steps;
991 const uint8_t *bufpoi = chip->oob_poi;
994 @@ -2161,7 +2781,10 @@ int nand_write_oob_syndrome(struct mtd_i
998 - chip->cmdfunc(mtd, NAND_CMD_SEQIN, pos, page);
999 + ret = nand_prog_page_begin_op(chip, page, pos, NULL, 0);
1003 for (i = 0; i < steps; i++) {
1005 if (mtd->writesize <= 512) {
1006 @@ -2170,28 +2793,40 @@ int nand_write_oob_syndrome(struct mtd_i
1009 int num = min_t(int, len, 4);
1010 - chip->write_buf(mtd, (uint8_t *)&fill,
1013 + ret = nand_write_data_op(chip, &fill,
1021 pos = eccsize + i * (eccsize + chunk);
1022 - chip->cmdfunc(mtd, NAND_CMD_RNDIN, pos, -1);
1023 + ret = nand_change_write_column_op(chip, pos,
1031 len = min_t(int, length, chunk);
1032 - chip->write_buf(mtd, bufpoi, len);
1034 + ret = nand_write_data_op(chip, bufpoi, len, false);
1042 - chip->write_buf(mtd, bufpoi, length);
1044 - chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1);
1045 - status = chip->waitfunc(mtd, chip);
1047 + ret = nand_write_data_op(chip, bufpoi, length, false);
1052 - return status & NAND_STATUS_FAIL ? -EIO : 0;
1053 + return nand_prog_page_end_op(chip);
1055 EXPORT_SYMBOL(nand_write_oob_syndrome);
1057 @@ -2346,9 +2981,18 @@ static int nand_read_oob(struct mtd_info
1058 int nand_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
1059 const uint8_t *buf, int oob_required, int page)
1061 - chip->write_buf(mtd, buf, mtd->writesize);
1063 - chip->write_buf(mtd, chip->oob_poi, mtd->oobsize);
1066 + ret = nand_write_data_op(chip, buf, mtd->writesize, false);
1070 + if (oob_required) {
1071 + ret = nand_write_data_op(chip, chip->oob_poi, mtd->oobsize,
1079 @@ -2372,29 +3016,46 @@ static int nand_write_page_raw_syndrome(
1080 int eccsize = chip->ecc.size;
1081 int eccbytes = chip->ecc.bytes;
1082 uint8_t *oob = chip->oob_poi;
1084 + int steps, size, ret;
1086 for (steps = chip->ecc.steps; steps > 0; steps--) {
1087 - chip->write_buf(mtd, buf, eccsize);
1088 + ret = nand_write_data_op(chip, buf, eccsize, false);
1094 if (chip->ecc.prepad) {
1095 - chip->write_buf(mtd, oob, chip->ecc.prepad);
1096 + ret = nand_write_data_op(chip, oob, chip->ecc.prepad,
1101 oob += chip->ecc.prepad;
1104 - chip->write_buf(mtd, oob, eccbytes);
1105 + ret = nand_write_data_op(chip, oob, eccbytes, false);
1111 if (chip->ecc.postpad) {
1112 - chip->write_buf(mtd, oob, chip->ecc.postpad);
1113 + ret = nand_write_data_op(chip, oob, chip->ecc.postpad,
1118 oob += chip->ecc.postpad;
1122 size = mtd->oobsize - (oob - chip->oob_poi);
1124 - chip->write_buf(mtd, oob, size);
1126 + ret = nand_write_data_op(chip, oob, size, false);
1133 @@ -2448,7 +3109,11 @@ static int nand_write_page_hwecc(struct
1135 for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {
1136 chip->ecc.hwctl(mtd, NAND_ECC_WRITE);
1137 - chip->write_buf(mtd, p, eccsize);
1139 + ret = nand_write_data_op(chip, p, eccsize, false);
1143 chip->ecc.calculate(mtd, p, &ecc_calc[i]);
1146 @@ -2457,7 +3122,9 @@ static int nand_write_page_hwecc(struct
1150 - chip->write_buf(mtd, chip->oob_poi, mtd->oobsize);
1151 + ret = nand_write_data_op(chip, chip->oob_poi, mtd->oobsize, false);
1157 @@ -2493,7 +3160,9 @@ static int nand_write_subpage_hwecc(stru
1158 chip->ecc.hwctl(mtd, NAND_ECC_WRITE);
1160 /* write data (untouched subpages already masked by 0xFF) */
1161 - chip->write_buf(mtd, buf, ecc_size);
1162 + ret = nand_write_data_op(chip, buf, ecc_size, false);
1166 /* mask ECC of un-touched subpages by padding 0xFF */
1167 if ((step < start_step) || (step > end_step))
1168 @@ -2520,7 +3189,9 @@ static int nand_write_subpage_hwecc(stru
1171 /* write OOB buffer to NAND device */
1172 - chip->write_buf(mtd, chip->oob_poi, mtd->oobsize);
1173 + ret = nand_write_data_op(chip, chip->oob_poi, mtd->oobsize, false);
1179 @@ -2547,31 +3218,49 @@ static int nand_write_page_syndrome(stru
1180 int eccsteps = chip->ecc.steps;
1181 const uint8_t *p = buf;
1182 uint8_t *oob = chip->oob_poi;
1185 for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {
1187 chip->ecc.hwctl(mtd, NAND_ECC_WRITE);
1188 - chip->write_buf(mtd, p, eccsize);
1190 + ret = nand_write_data_op(chip, p, eccsize, false);
1194 if (chip->ecc.prepad) {
1195 - chip->write_buf(mtd, oob, chip->ecc.prepad);
1196 + ret = nand_write_data_op(chip, oob, chip->ecc.prepad,
1201 oob += chip->ecc.prepad;
1204 chip->ecc.calculate(mtd, p, oob);
1205 - chip->write_buf(mtd, oob, eccbytes);
1207 + ret = nand_write_data_op(chip, oob, eccbytes, false);
1213 if (chip->ecc.postpad) {
1214 - chip->write_buf(mtd, oob, chip->ecc.postpad);
1215 + ret = nand_write_data_op(chip, oob, chip->ecc.postpad,
1220 oob += chip->ecc.postpad;
1224 /* Calculate remaining oob bytes */
1225 i = mtd->oobsize - (oob - chip->oob_poi);
1227 - chip->write_buf(mtd, oob, i);
1229 + ret = nand_write_data_op(chip, oob, i, false);
1236 @@ -2599,8 +3288,11 @@ static int nand_write_page(struct mtd_in
1240 - if (nand_standard_page_accessors(&chip->ecc))
1241 - chip->cmdfunc(mtd, NAND_CMD_SEQIN, 0x00, page);
1242 + if (nand_standard_page_accessors(&chip->ecc)) {
1243 + status = nand_prog_page_begin_op(chip, page, 0, NULL, 0);
1249 status = chip->ecc.write_page_raw(mtd, chip, buf,
1250 @@ -2615,13 +3307,8 @@ static int nand_write_page(struct mtd_in
1254 - if (nand_standard_page_accessors(&chip->ecc)) {
1255 - chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1);
1257 - status = chip->waitfunc(mtd, chip);
1258 - if (status & NAND_STATUS_FAIL)
1261 + if (nand_standard_page_accessors(&chip->ecc))
1262 + return nand_prog_page_end_op(chip);
1266 @@ -2994,17 +3681,12 @@ out:
1267 static int single_erase(struct mtd_info *mtd, int page)
1269 struct nand_chip *chip = mtd_to_nand(mtd);
1271 + unsigned int eraseblock;
1273 /* Send commands to erase a block */
1274 - chip->cmdfunc(mtd, NAND_CMD_ERASE1, -1, page);
1275 - chip->cmdfunc(mtd, NAND_CMD_ERASE2, -1, -1);
1277 - status = chip->waitfunc(mtd, chip);
1280 + eraseblock = page >> (chip->phys_erase_shift - chip->page_shift);
1282 - return status & NAND_STATUS_FAIL ? -EIO : 0;
1283 + return nand_erase_op(chip, eraseblock);
1287 @@ -3231,22 +3913,12 @@ static int nand_max_bad_blocks(struct mt
1288 static int nand_onfi_set_features(struct mtd_info *mtd, struct nand_chip *chip,
1289 int addr, uint8_t *subfeature_param)
1294 if (!chip->onfi_version ||
1295 !(le16_to_cpu(chip->onfi_params.opt_cmd)
1296 & ONFI_OPT_CMD_SET_GET_FEATURES))
1299 - chip->cmdfunc(mtd, NAND_CMD_SET_FEATURES, addr, -1);
1300 - for (i = 0; i < ONFI_SUBFEATURE_PARAM_LEN; ++i)
1301 - chip->write_byte(mtd, subfeature_param[i]);
1303 - status = chip->waitfunc(mtd, chip);
1304 - if (status & NAND_STATUS_FAIL)
1307 + return nand_set_features_op(chip, addr, subfeature_param);
1311 @@ -3259,17 +3931,12 @@ static int nand_onfi_set_features(struct
1312 static int nand_onfi_get_features(struct mtd_info *mtd, struct nand_chip *chip,
1313 int addr, uint8_t *subfeature_param)
1317 if (!chip->onfi_version ||
1318 !(le16_to_cpu(chip->onfi_params.opt_cmd)
1319 & ONFI_OPT_CMD_SET_GET_FEATURES))
1322 - chip->cmdfunc(mtd, NAND_CMD_GET_FEATURES, addr, -1);
1323 - for (i = 0; i < ONFI_SUBFEATURE_PARAM_LEN; ++i)
1324 - *subfeature_param++ = chip->read_byte(mtd);
1326 + return nand_get_features_op(chip, addr, subfeature_param);
1330 @@ -3412,12 +4079,11 @@ static u16 onfi_crc16(u16 crc, u8 const
1331 static int nand_flash_detect_ext_param_page(struct nand_chip *chip,
1332 struct nand_onfi_params *p)
1334 - struct mtd_info *mtd = nand_to_mtd(chip);
1335 struct onfi_ext_param_page *ep;
1336 struct onfi_ext_section *s;
1337 struct onfi_ext_ecc_info *ecc;
1339 - int ret = -EINVAL;
1344 @@ -3427,14 +4093,18 @@ static int nand_flash_detect_ext_param_p
1347 /* Send our own NAND_CMD_PARAM. */
1348 - chip->cmdfunc(mtd, NAND_CMD_PARAM, 0, -1);
1349 + ret = nand_read_param_page_op(chip, 0, NULL, 0);
1353 /* Use the Change Read Column command to skip the ONFI param pages. */
1354 - chip->cmdfunc(mtd, NAND_CMD_RNDOUT,
1355 - sizeof(*p) * p->num_of_param_pages , -1);
1356 + ret = nand_change_read_column_op(chip,
1357 + sizeof(*p) * p->num_of_param_pages,
1362 - /* Read out the Extended Parameter Page. */
1363 - chip->read_buf(mtd, (uint8_t *)ep, len);
1365 if ((onfi_crc16(ONFI_CRC_BASE, ((uint8_t *)ep) + 2, len - 2)
1366 != le16_to_cpu(ep->crc))) {
1367 pr_debug("fail in the CRC.\n");
1368 @@ -3487,19 +4157,23 @@ static int nand_flash_detect_onfi(struct
1370 struct mtd_info *mtd = nand_to_mtd(chip);
1371 struct nand_onfi_params *p = &chip->onfi_params;
1377 /* Try ONFI for unknown chip or LP */
1378 - chip->cmdfunc(mtd, NAND_CMD_READID, 0x20, -1);
1379 - if (chip->read_byte(mtd) != 'O' || chip->read_byte(mtd) != 'N' ||
1380 - chip->read_byte(mtd) != 'F' || chip->read_byte(mtd) != 'I')
1381 + ret = nand_readid_op(chip, 0x20, id, sizeof(id));
1382 + if (ret || strncmp(id, "ONFI", 4))
1385 + ret = nand_read_param_page_op(chip, 0, NULL, 0);
1389 - chip->cmdfunc(mtd, NAND_CMD_PARAM, 0, -1);
1390 for (i = 0; i < 3; i++) {
1391 - for (j = 0; j < sizeof(*p); j++)
1392 - ((uint8_t *)p)[j] = chip->read_byte(mtd);
1393 + ret = nand_read_data_op(chip, p, sizeof(*p), true);
1397 if (onfi_crc16(ONFI_CRC_BASE, (uint8_t *)p, 254) ==
1398 le16_to_cpu(p->crc)) {
1400 @@ -3590,20 +4264,22 @@ static int nand_flash_detect_jedec(struc
1401 struct mtd_info *mtd = nand_to_mtd(chip);
1402 struct nand_jedec_params *p = &chip->jedec_params;
1403 struct jedec_ecc_info *ecc;
1409 /* Try JEDEC for unknown chip or LP */
1410 - chip->cmdfunc(mtd, NAND_CMD_READID, 0x40, -1);
1411 - if (chip->read_byte(mtd) != 'J' || chip->read_byte(mtd) != 'E' ||
1412 - chip->read_byte(mtd) != 'D' || chip->read_byte(mtd) != 'E' ||
1413 - chip->read_byte(mtd) != 'C')
1414 + ret = nand_readid_op(chip, 0x40, id, sizeof(id));
1415 + if (ret || strncmp(id, "JEDEC", sizeof(id)))
1418 + ret = nand_read_param_page_op(chip, 0x40, NULL, 0);
1422 - chip->cmdfunc(mtd, NAND_CMD_PARAM, 0x40, -1);
1423 for (i = 0; i < 3; i++) {
1424 - for (j = 0; j < sizeof(*p); j++)
1425 - ((uint8_t *)p)[j] = chip->read_byte(mtd);
1426 + ret = nand_read_data_op(chip, p, sizeof(*p), true);
1430 if (onfi_crc16(ONFI_CRC_BASE, (uint8_t *)p, 510) ==
1431 le16_to_cpu(p->crc))
1432 @@ -3882,8 +4558,7 @@ static int nand_detect(struct nand_chip
1434 const struct nand_manufacturer *manufacturer;
1435 struct mtd_info *mtd = nand_to_mtd(chip);
1439 u8 *id_data = chip->id.data;
1442 @@ -3891,17 +4566,21 @@ static int nand_detect(struct nand_chip
1443 * Reset the chip, required by some chips (e.g. Micron MT29FxGxxxxx)
1446 - nand_reset(chip, 0);
1447 + ret = nand_reset(chip, 0);
1451 /* Select the device */
1452 chip->select_chip(mtd, 0);
1454 /* Send the command for reading device ID */
1455 - chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1);
1456 + ret = nand_readid_op(chip, 0, id_data, 2);
1460 /* Read manufacturer and device IDs */
1461 - maf_id = chip->read_byte(mtd);
1462 - dev_id = chip->read_byte(mtd);
1463 + maf_id = id_data[0];
1464 + dev_id = id_data[1];
1467 * Try again to make sure, as some systems the bus-hold or other
1468 @@ -3910,11 +4589,10 @@ static int nand_detect(struct nand_chip
1469 * not match, ignore the device completely.
1472 - chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1);
1474 /* Read entire ID string */
1475 - for (i = 0; i < ARRAY_SIZE(chip->id.data); i++)
1476 - id_data[i] = chip->read_byte(mtd);
1477 + ret = nand_readid_op(chip, 0, id_data, sizeof(chip->id.data));
1481 if (id_data[0] != maf_id || id_data[1] != dev_id) {
1482 pr_info("second ID read did not match %02x,%02x against %02x,%02x\n",
1483 @@ -4238,15 +4916,16 @@ int nand_scan_ident(struct mtd_info *mtd
1485 /* Check for a chip array */
1486 for (i = 1; i < maxchips; i++) {
1489 /* See comment in nand_get_flash_type for reset */
1490 nand_reset(chip, i);
1492 chip->select_chip(mtd, i);
1493 /* Send the command for reading device ID */
1494 - chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1);
1495 + nand_readid_op(chip, 0, id, sizeof(id));
1496 /* Read manufacturer and device IDs */
1497 - if (nand_maf_id != chip->read_byte(mtd) ||
1498 - nand_dev_id != chip->read_byte(mtd)) {
1499 + if (nand_maf_id != id[0] || nand_dev_id != id[1]) {
1500 chip->select_chip(mtd, -1);
1503 --- a/drivers/mtd/nand/qcom_nandc.c
1504 +++ b/drivers/mtd/nand/qcom_nandc.c
1505 @@ -1990,7 +1990,7 @@ static int qcom_nandc_write_oob(struct m
1506 struct nand_ecc_ctrl *ecc = &chip->ecc;
1507 u8 *oob = chip->oob_poi;
1508 int data_size, oob_size;
1509 - int ret, status = 0;
1512 host->use_ecc = true;
1514 @@ -2027,11 +2027,7 @@ static int qcom_nandc_write_oob(struct m
1518 - chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1);
1520 - status = chip->waitfunc(mtd, chip);
1522 - return status & NAND_STATUS_FAIL ? -EIO : 0;
1523 + return nand_prog_page_end_op(chip);
1526 static int qcom_nandc_block_bad(struct mtd_info *mtd, loff_t ofs)
1527 @@ -2081,7 +2077,7 @@ static int qcom_nandc_block_markbad(stru
1528 struct qcom_nand_host *host = to_qcom_nand_host(chip);
1529 struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
1530 struct nand_ecc_ctrl *ecc = &chip->ecc;
1531 - int page, ret, status = 0;
1534 clear_read_regs(nandc);
1535 clear_bam_transaction(nandc);
1536 @@ -2114,11 +2110,7 @@ static int qcom_nandc_block_markbad(stru
1540 - chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1);
1542 - status = chip->waitfunc(mtd, chip);
1544 - return status & NAND_STATUS_FAIL ? -EIO : 0;
1545 + return nand_prog_page_end_op(chip);
1549 --- a/include/linux/mtd/rawnand.h
1550 +++ b/include/linux/mtd/rawnand.h
1551 @@ -1311,6 +1311,35 @@ int nand_write_page_raw(struct mtd_info
1552 /* Reset and initialize a NAND device */
1553 int nand_reset(struct nand_chip *chip, int chipnr);
1555 +/* NAND operation helpers */
1556 +int nand_reset_op(struct nand_chip *chip);
1557 +int nand_readid_op(struct nand_chip *chip, u8 addr, void *buf,
1558 + unsigned int len);
1559 +int nand_status_op(struct nand_chip *chip, u8 *status);
1560 +int nand_exit_status_op(struct nand_chip *chip);
1561 +int nand_erase_op(struct nand_chip *chip, unsigned int eraseblock);
1562 +int nand_read_page_op(struct nand_chip *chip, unsigned int page,
1563 + unsigned int offset_in_page, void *buf, unsigned int len);
1564 +int nand_change_read_column_op(struct nand_chip *chip,
1565 + unsigned int offset_in_page, void *buf,
1566 + unsigned int len, bool force_8bit);
1567 +int nand_read_oob_op(struct nand_chip *chip, unsigned int page,
1568 + unsigned int offset_in_page, void *buf, unsigned int len);
1569 +int nand_prog_page_begin_op(struct nand_chip *chip, unsigned int page,
1570 + unsigned int offset_in_page, const void *buf,
1571 + unsigned int len);
1572 +int nand_prog_page_end_op(struct nand_chip *chip);
1573 +int nand_prog_page_op(struct nand_chip *chip, unsigned int page,
1574 + unsigned int offset_in_page, const void *buf,
1575 + unsigned int len);
1576 +int nand_change_write_column_op(struct nand_chip *chip,
1577 + unsigned int offset_in_page, const void *buf,
1578 + unsigned int len, bool force_8bit);
1579 +int nand_read_data_op(struct nand_chip *chip, void *buf, unsigned int len,
1581 +int nand_write_data_op(struct nand_chip *chip, const void *buf,
1582 + unsigned int len, bool force_8bit);
1584 /* Free resources held by the NAND device */
1585 void nand_cleanup(struct nand_chip *chip);