Lines Matching +full:wait +full:- +full:on +full:- +full:read
1 // SPDX-License-Identifier: GPL-2.0
4 * 2002-2006 Thomas Gleixner (tglx@linutronix.de)
23 * nand_read_byte - [DEFAULT] read one byte from the chip
26 * Default read function for 8bit buswidth
30 return readb(chip->legacy.IO_ADDR_R); in nand_read_byte()
34 * nand_read_byte16 - [DEFAULT] read one byte endianness aware from the chip
37 * Default read function for 16bit buswidth with endianness conversion.
42 return (uint8_t) cpu_to_le16(readw(chip->legacy.IO_ADDR_R)); in nand_read_byte16()
46 * nand_select_chip - [DEFAULT] control CE line
48 * @chipnr: chipnumber to select, -1 for deselect
55 case -1: in nand_select_chip()
56 chip->legacy.cmd_ctrl(chip, NAND_CMD_NONE, in nand_select_chip()
68 * nand_write_byte - [DEFAULT] write single byte to chip
76 chip->legacy.write_buf(chip, &byte, 1); in nand_write_byte()
80 * nand_write_byte16 - [DEFAULT] write single byte to a chip with width 16
84 * Default function to write a byte to I/O[7:0] on a 16-bit wide chip.
92 * a byte. The ONFi spec (Revision 3.1; 2012-09-19, Section 2.16) reads: in nand_write_byte16()
94 * When the host supports a 16-bit bus width, only data is in nand_write_byte16()
95 * transferred at the 16-bit width. All address and command line in nand_write_byte16()
96 * transfers shall use only the lower 8-bits of the data bus. During in nand_write_byte16()
97 * command transfers, the host may place any value on the upper in nand_write_byte16()
98 * 8-bits of the data bus. During address transfers, the host shall in nand_write_byte16()
99 * set the upper 8-bits of the data bus to 00h. in nand_write_byte16()
103 * neither an address nor a command transfer. Let's assume a 0 on the in nand_write_byte16()
106 chip->legacy.write_buf(chip, (uint8_t *)&word, 2); in nand_write_byte16()
110 * nand_write_buf - [DEFAULT] write buffer to chip
119 iowrite8_rep(chip->legacy.IO_ADDR_W, buf, len); in nand_write_buf()
123 * nand_read_buf - [DEFAULT] read chip data into buffer
126 * @len: number of bytes to read
128 * Default read function for 8bit buswidth.
132 ioread8_rep(chip->legacy.IO_ADDR_R, buf, len); in nand_read_buf()
136 * nand_write_buf16 - [DEFAULT] write buffer to chip
148 iowrite16_rep(chip->legacy.IO_ADDR_W, p, len >> 1); in nand_write_buf16()
152 * nand_read_buf16 - [DEFAULT] read chip data into buffer
155 * @len: number of bytes to read
157 * Default read function for 16bit buswidth.
163 ioread16_rep(chip->legacy.IO_ADDR_R, p, len >> 1); in nand_read_buf16()
167 * panic_nand_wait_ready - [GENERIC] Wait for the ready pin after commands.
171 * Helper function for nand_wait_ready used when needing to wait in interrupt
178 /* Wait for the device to get ready */ in panic_nand_wait_ready()
180 if (chip->legacy.dev_ready(chip)) in panic_nand_wait_ready()
188 * nand_wait_ready - [GENERIC] Wait for the ready pin after commands.
191 * Wait for the ready pin after a command, and warn if a timeout occurs.
198 if (mtd->oops_panic_write) in nand_wait_ready()
201 /* Wait until command is processed or timeout occurs */ in nand_wait_ready()
204 if (chip->legacy.dev_ready(chip)) in nand_wait_ready()
209 if (!chip->legacy.dev_ready(chip)) in nand_wait_ready()
215 * nand_wait_status_ready - [GENERIC] Wait for the ready status after commands.
219 * Wait for status ready (i.e. command done) or timeout.
241 * nand_command - [DEFAULT] Send command to NAND device
244 * @column: the column address for this command, -1 if none
245 * @page_addr: the page address for this command, -1 if none
260 if (column >= mtd->writesize) { in nand_command()
262 column -= mtd->writesize; in nand_command()
265 /* First 256 bytes --> READ0 */ in nand_command()
268 column -= 256; in nand_command()
271 chip->legacy.cmd_ctrl(chip, readcmd, ctrl); in nand_command()
275 chip->legacy.cmd_ctrl(chip, command, ctrl); in nand_command()
280 if (column != -1) { in nand_command()
282 if (chip->options & NAND_BUSWIDTH_16 && in nand_command()
285 chip->legacy.cmd_ctrl(chip, column, ctrl); in nand_command()
288 if (page_addr != -1) { in nand_command()
289 chip->legacy.cmd_ctrl(chip, page_addr, ctrl); in nand_command()
291 chip->legacy.cmd_ctrl(chip, page_addr >> 8, ctrl); in nand_command()
292 if (chip->options & NAND_ROW_ADDR_3) in nand_command()
293 chip->legacy.cmd_ctrl(chip, page_addr >> 16, ctrl); in nand_command()
295 chip->legacy.cmd_ctrl(chip, NAND_CMD_NONE, in nand_command()
315 if (chip->legacy.dev_ready) in nand_command()
317 udelay(chip->legacy.chip_delay); in nand_command()
318 chip->legacy.cmd_ctrl(chip, NAND_CMD_STATUS, in nand_command()
320 chip->legacy.cmd_ctrl(chip, NAND_CMD_NONE, in nand_command()
322 /* EZ-NAND can take upto 250ms as per ONFi v4.0 */ in nand_command()
326 /* This applies to read commands */ in nand_command()
331 * this information to detect that we should not wait for the in nand_command()
334 if (column == -1 && page_addr == -1) in nand_command()
342 if (!chip->legacy.dev_ready) { in nand_command()
343 udelay(chip->legacy.chip_delay); in nand_command()
348 * Apply this short delay always to ensure that we do wait tWB in in nand_command()
349 * any case on any machine. in nand_command()
365 if (!(chip->options & NAND_WAIT_TCCS)) in nand_ccs_delay()
369 * Wait tCCS_min if it is correctly defined, otherwise wait 500ns in nand_ccs_delay()
373 ndelay(sdr->tCCS_min / 1000); in nand_ccs_delay()
379 * nand_command_lp - [DEFAULT] Send command to NAND large page device
382 * @column: the column address for this command, -1 if none
383 * @page_addr: the page address for this command, -1 if none
396 column += mtd->writesize; in nand_command_lp()
402 chip->legacy.cmd_ctrl(chip, command, in nand_command_lp()
405 if (column != -1 || page_addr != -1) { in nand_command_lp()
409 if (column != -1) { in nand_command_lp()
411 if (chip->options & NAND_BUSWIDTH_16 && in nand_command_lp()
414 chip->legacy.cmd_ctrl(chip, column, ctrl); in nand_command_lp()
419 chip->legacy.cmd_ctrl(chip, column >> 8, ctrl); in nand_command_lp()
421 if (page_addr != -1) { in nand_command_lp()
422 chip->legacy.cmd_ctrl(chip, page_addr, ctrl); in nand_command_lp()
423 chip->legacy.cmd_ctrl(chip, page_addr >> 8, in nand_command_lp()
425 if (chip->options & NAND_ROW_ADDR_3) in nand_command_lp()
426 chip->legacy.cmd_ctrl(chip, page_addr >> 16, in nand_command_lp()
430 chip->legacy.cmd_ctrl(chip, NAND_CMD_NONE, in nand_command_lp()
455 if (chip->legacy.dev_ready) in nand_command_lp()
457 udelay(chip->legacy.chip_delay); in nand_command_lp()
458 chip->legacy.cmd_ctrl(chip, NAND_CMD_STATUS, in nand_command_lp()
460 chip->legacy.cmd_ctrl(chip, NAND_CMD_NONE, in nand_command_lp()
462 /* EZ-NAND can take upto 250ms as per ONFi v4.0 */ in nand_command_lp()
468 chip->legacy.cmd_ctrl(chip, NAND_CMD_RNDOUTSTART, in nand_command_lp()
470 chip->legacy.cmd_ctrl(chip, NAND_CMD_NONE, in nand_command_lp()
483 if (column == -1 && page_addr == -1) in nand_command_lp()
486 chip->legacy.cmd_ctrl(chip, NAND_CMD_READSTART, in nand_command_lp()
488 chip->legacy.cmd_ctrl(chip, NAND_CMD_NONE, in nand_command_lp()
490 fallthrough; /* This applies to read commands */ in nand_command_lp()
496 if (!chip->legacy.dev_ready) { in nand_command_lp()
497 udelay(chip->legacy.chip_delay); in nand_command_lp()
503 * Apply this short delay always to ensure that we do wait tWB in in nand_command_lp()
504 * any case on any machine. in nand_command_lp()
512 * nand_get_set_features_notsupp - set/get features stub returning -ENOTSUPP
523 return -ENOTSUPP; in nand_get_set_features_notsupp()
528 * nand_wait - [DEFAULT] wait until the command is done
531 * Wait for command done. This applies to erase and program only.
541 * Apply this short delay always to ensure that we do wait tWB in any in nand_wait()
542 * case on any machine. in nand_wait()
550 if (mtd->oops_panic_write) { in nand_wait()
555 if (chip->legacy.dev_ready) { in nand_wait()
556 if (chip->legacy.dev_ready(chip)) in nand_wait()
583 unsigned int busw = chip->options & NAND_BUSWIDTH_16; in nand_legacy_set_defaults()
589 if (!chip->legacy.chip_delay) in nand_legacy_set_defaults()
590 chip->legacy.chip_delay = 20; in nand_legacy_set_defaults()
593 if (!chip->legacy.cmdfunc) in nand_legacy_set_defaults()
594 chip->legacy.cmdfunc = nand_command; in nand_legacy_set_defaults()
596 /* check, if a user supplied wait function given */ in nand_legacy_set_defaults()
597 if (chip->legacy.waitfunc == NULL) in nand_legacy_set_defaults()
598 chip->legacy.waitfunc = nand_wait; in nand_legacy_set_defaults()
600 if (!chip->legacy.select_chip) in nand_legacy_set_defaults()
601 chip->legacy.select_chip = nand_select_chip; in nand_legacy_set_defaults()
603 /* If called twice, pointers that depend on busw may need to be reset */ in nand_legacy_set_defaults()
604 if (!chip->legacy.read_byte || chip->legacy.read_byte == nand_read_byte) in nand_legacy_set_defaults()
605 chip->legacy.read_byte = busw ? nand_read_byte16 : nand_read_byte; in nand_legacy_set_defaults()
606 if (!chip->legacy.write_buf || chip->legacy.write_buf == nand_write_buf) in nand_legacy_set_defaults()
607 chip->legacy.write_buf = busw ? nand_write_buf16 : nand_write_buf; in nand_legacy_set_defaults()
608 if (!chip->legacy.write_byte || chip->legacy.write_byte == nand_write_byte) in nand_legacy_set_defaults()
609 chip->legacy.write_byte = busw ? nand_write_byte16 : nand_write_byte; in nand_legacy_set_defaults()
610 if (!chip->legacy.read_buf || chip->legacy.read_buf == nand_read_buf) in nand_legacy_set_defaults()
611 chip->legacy.read_buf = busw ? nand_read_buf16 : nand_read_buf; in nand_legacy_set_defaults()
619 if (mtd->writesize > 512 && chip->legacy.cmdfunc == nand_command) in nand_legacy_adjust_cmdfunc()
620 chip->legacy.cmdfunc = nand_command_lp; in nand_legacy_adjust_cmdfunc()
626 * ->legacy.cmdfunc() is legacy and will only be used if ->exec_op() is in nand_legacy_check_hooks()
633 * Default functions assigned for ->legacy.cmdfunc() and in nand_legacy_check_hooks()
634 * ->legacy.select_chip() both expect ->legacy.cmd_ctrl() to be in nand_legacy_check_hooks()
637 if ((!chip->legacy.cmdfunc || !chip->legacy.select_chip) && in nand_legacy_check_hooks()
638 !chip->legacy.cmd_ctrl) { in nand_legacy_check_hooks()
639 pr_err("->legacy.cmd_ctrl() should be provided\n"); in nand_legacy_check_hooks()
640 return -EINVAL; in nand_legacy_check_hooks()