/** * socrates_nand_write_buf - write buffer to chip * @this: NAND chip object * @buf: data buffer * @len: number of bytes to write
*/ staticvoid socrates_nand_write_buf(struct nand_chip *this, const uint8_t *buf, int len)
{ int i; struct socrates_nand_host *host = nand_get_controller_data(this);
for (i = 0; i < len; i++) {
out_be32(host->io_base, FPGA_NAND_ENABLE |
FPGA_NAND_CMD_WRITE |
(buf[i] << FPGA_NAND_DATA_SHIFT));
}
}
/** * socrates_nand_read_buf - read chip data into buffer * @this: NAND chip object * @buf: buffer to store date * @len: number of bytes to read
*/ staticvoid socrates_nand_read_buf(struct nand_chip *this, uint8_t *buf, int len)
{ int i; struct socrates_nand_host *host = nand_get_controller_data(this);
uint32_t val;
val = FPGA_NAND_ENABLE | FPGA_NAND_CMD_READ;
out_be32(host->io_base, val); for (i = 0; i < len; i++) {
buf[i] = (in_be32(host->io_base) >>
FPGA_NAND_DATA_SHIFT) & 0xff;
}
}
/** * socrates_nand_read_byte - read one byte from the chip * @mtd: MTD device structure
*/ static uint8_t socrates_nand_read_byte(struct nand_chip *this)
{
uint8_t byte;
socrates_nand_read_buf(this, &byte, sizeof(byte)); return byte;
}
/* * Hardware specific access to control-lines
*/ staticvoid socrates_nand_cmd_ctrl(struct nand_chip *nand_chip, int cmd, unsignedint ctrl)
{ struct socrates_nand_host *host = nand_get_controller_data(nand_chip);
uint32_t val;
if (cmd == NAND_CMD_NONE) return;
if (ctrl & NAND_CLE)
val = FPGA_NAND_CMD_COMMAND; else
val = FPGA_NAND_CMD_ADDR;
/* TODO: I have no idea what real delay is. */
nand_chip->legacy.chip_delay = 20; /* 20us command delay time */
/* * This driver assumes that the default ECC engine should be TYPE_SOFT. * Set ->engine_type before registering the NAND devices in order to * provide a driver specific default value.
*/
nand_chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
dev_set_drvdata(&ofdev->dev, host);
res = nand_scan(nand_chip, 1); if (res) goto out;
res = mtd_device_register(mtd, NULL, 0); if (!res) return res;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.