mirror of
https://github.com/armbian/linux-cix.git
synced 2026-01-06 12:30:45 -08:00
mtd: rawnand: Pass a nand_chip object to chip->read_xxx() hooks
Let's make the raw NAND API consistent by patching all helpers and hooks to take a nand_chip object instead of an mtd_info one or remove the mtd_info object when both are passed. Let's tackle all chip->read_xxx() hooks at once. Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
This commit is contained in:
committed by
Miquel Raynal
parent
767eb6fbde
commit
7e534323c4
@@ -75,10 +75,9 @@ static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte)
|
||||
gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NWE, 1);
|
||||
}
|
||||
|
||||
static u_char ams_delta_read_byte(struct mtd_info *mtd)
|
||||
static u_char ams_delta_read_byte(struct nand_chip *this)
|
||||
{
|
||||
u_char res;
|
||||
struct nand_chip *this = mtd_to_nand(mtd);
|
||||
void __iomem *io_base = (void __iomem *)nand_get_controller_data(this);
|
||||
|
||||
gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NRE, 0);
|
||||
@@ -99,12 +98,12 @@ static void ams_delta_write_buf(struct mtd_info *mtd, const u_char *buf,
|
||||
ams_delta_write_byte(mtd, buf[i]);
|
||||
}
|
||||
|
||||
static void ams_delta_read_buf(struct mtd_info *mtd, u_char *buf, int len)
|
||||
static void ams_delta_read_buf(struct nand_chip *this, u_char *buf, int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<len; i++)
|
||||
buf[i] = ams_delta_read_byte(mtd);
|
||||
buf[i] = ams_delta_read_byte(this);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -410,9 +410,8 @@ err:
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static u8 atmel_nand_read_byte(struct mtd_info *mtd)
|
||||
static u8 atmel_nand_read_byte(struct nand_chip *chip)
|
||||
{
|
||||
struct nand_chip *chip = mtd_to_nand(mtd);
|
||||
struct atmel_nand *nand = to_atmel_nand(chip);
|
||||
|
||||
return ioread8(nand->activecs->io.virt);
|
||||
@@ -429,9 +428,8 @@ static void atmel_nand_write_byte(struct mtd_info *mtd, u8 byte)
|
||||
iowrite8(byte, nand->activecs->io.virt);
|
||||
}
|
||||
|
||||
static void atmel_nand_read_buf(struct mtd_info *mtd, u8 *buf, int len)
|
||||
static void atmel_nand_read_buf(struct nand_chip *chip, u8 *buf, int len)
|
||||
{
|
||||
struct nand_chip *chip = mtd_to_nand(mtd);
|
||||
struct atmel_nand *nand = to_atmel_nand(chip);
|
||||
struct atmel_nand_controller *nc;
|
||||
|
||||
@@ -883,8 +881,8 @@ static int atmel_nand_pmecc_read_pg(struct nand_chip *chip, u8 *buf,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
atmel_nand_read_buf(mtd, buf, mtd->writesize);
|
||||
atmel_nand_read_buf(mtd, chip->oob_poi, mtd->oobsize);
|
||||
atmel_nand_read_buf(chip, buf, mtd->writesize);
|
||||
atmel_nand_read_buf(chip, chip->oob_poi, mtd->oobsize);
|
||||
|
||||
ret = atmel_nand_pmecc_correct_data(chip, buf, raw);
|
||||
|
||||
|
||||
@@ -29,13 +29,12 @@ struct au1550nd_ctx {
|
||||
|
||||
/**
|
||||
* au_read_byte - read one byte from the chip
|
||||
* @mtd: MTD device structure
|
||||
* @this: NAND chip object
|
||||
*
|
||||
* read function for 8bit buswidth
|
||||
*/
|
||||
static u_char au_read_byte(struct mtd_info *mtd)
|
||||
static u_char au_read_byte(struct nand_chip *this)
|
||||
{
|
||||
struct nand_chip *this = mtd_to_nand(mtd);
|
||||
u_char ret = readb(this->IO_ADDR_R);
|
||||
wmb(); /* drain writebuffer */
|
||||
return ret;
|
||||
@@ -57,13 +56,12 @@ static void au_write_byte(struct mtd_info *mtd, u_char byte)
|
||||
|
||||
/**
|
||||
* au_read_byte16 - read one byte endianness aware from the chip
|
||||
* @mtd: MTD device structure
|
||||
* @this: NAND chip object
|
||||
*
|
||||
* read function for 16bit buswidth with endianness conversion
|
||||
*/
|
||||
static u_char au_read_byte16(struct mtd_info *mtd)
|
||||
static u_char au_read_byte16(struct nand_chip *this)
|
||||
{
|
||||
struct nand_chip *this = mtd_to_nand(mtd);
|
||||
u_char ret = (u_char) cpu_to_le16(readw(this->IO_ADDR_R));
|
||||
wmb(); /* drain writebuffer */
|
||||
return ret;
|
||||
@@ -104,16 +102,15 @@ static void au_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
|
||||
|
||||
/**
|
||||
* au_read_buf - read chip data into buffer
|
||||
* @mtd: MTD device structure
|
||||
* @this: NAND chip object
|
||||
* @buf: buffer to store date
|
||||
* @len: number of bytes to read
|
||||
*
|
||||
* read function for 8bit buswidth
|
||||
*/
|
||||
static void au_read_buf(struct mtd_info *mtd, u_char *buf, int len)
|
||||
static void au_read_buf(struct nand_chip *this, u_char *buf, int len)
|
||||
{
|
||||
int i;
|
||||
struct nand_chip *this = mtd_to_nand(mtd);
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
buf[i] = readb(this->IO_ADDR_R);
|
||||
|
||||
@@ -310,9 +310,9 @@ static void bcm47xxnflash_ops_bcm4706_cmdfunc(struct mtd_info *mtd,
|
||||
b47n->curr_command = command;
|
||||
}
|
||||
|
||||
static u8 bcm47xxnflash_ops_bcm4706_read_byte(struct mtd_info *mtd)
|
||||
static u8 bcm47xxnflash_ops_bcm4706_read_byte(struct nand_chip *nand_chip)
|
||||
{
|
||||
struct nand_chip *nand_chip = mtd_to_nand(mtd);
|
||||
struct mtd_info *mtd = nand_to_mtd(nand_chip);
|
||||
struct bcm47xxnflash *b47n = nand_get_controller_data(nand_chip);
|
||||
struct bcma_drv_cc *cc = b47n->cc;
|
||||
u32 tmp = 0;
|
||||
@@ -338,16 +338,16 @@ static u8 bcm47xxnflash_ops_bcm4706_read_byte(struct mtd_info *mtd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void bcm47xxnflash_ops_bcm4706_read_buf(struct mtd_info *mtd,
|
||||
static void bcm47xxnflash_ops_bcm4706_read_buf(struct nand_chip *nand_chip,
|
||||
uint8_t *buf, int len)
|
||||
{
|
||||
struct nand_chip *nand_chip = mtd_to_nand(mtd);
|
||||
struct bcm47xxnflash *b47n = nand_get_controller_data(nand_chip);
|
||||
|
||||
switch (b47n->curr_command) {
|
||||
case NAND_CMD_READ0:
|
||||
case NAND_CMD_READOOB:
|
||||
bcm47xxnflash_ops_bcm4706_read(mtd, buf, len);
|
||||
bcm47xxnflash_ops_bcm4706_read(nand_to_mtd(nand_chip), buf,
|
||||
len);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1417,9 +1417,8 @@ static void brcmnand_cmdfunc(struct mtd_info *mtd, unsigned command,
|
||||
brcmnand_wp(mtd, 1);
|
||||
}
|
||||
|
||||
static uint8_t brcmnand_read_byte(struct mtd_info *mtd)
|
||||
static uint8_t brcmnand_read_byte(struct nand_chip *chip)
|
||||
{
|
||||
struct nand_chip *chip = mtd_to_nand(mtd);
|
||||
struct brcmnand_host *host = nand_get_controller_data(chip);
|
||||
struct brcmnand_controller *ctrl = host->ctrl;
|
||||
uint8_t ret = 0;
|
||||
@@ -1474,12 +1473,12 @@ static uint8_t brcmnand_read_byte(struct mtd_info *mtd)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void brcmnand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
|
||||
static void brcmnand_read_buf(struct nand_chip *chip, uint8_t *buf, int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < len; i++, buf++)
|
||||
*buf = brcmnand_read_byte(mtd);
|
||||
*buf = brcmnand_read_byte(chip);
|
||||
}
|
||||
|
||||
static void brcmnand_write_buf(struct mtd_info *mtd, const uint8_t *buf,
|
||||
|
||||
@@ -133,9 +133,8 @@ static void cafe_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
|
||||
len, cafe->datalen);
|
||||
}
|
||||
|
||||
static void cafe_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
|
||||
static void cafe_read_buf(struct nand_chip *chip, uint8_t *buf, int len)
|
||||
{
|
||||
struct nand_chip *chip = mtd_to_nand(mtd);
|
||||
struct cafe_priv *cafe = nand_get_controller_data(chip);
|
||||
|
||||
if (cafe->usedma)
|
||||
@@ -148,13 +147,12 @@ static void cafe_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
|
||||
cafe->datalen += len;
|
||||
}
|
||||
|
||||
static uint8_t cafe_read_byte(struct mtd_info *mtd)
|
||||
static uint8_t cafe_read_byte(struct nand_chip *chip)
|
||||
{
|
||||
struct nand_chip *chip = mtd_to_nand(mtd);
|
||||
struct cafe_priv *cafe = nand_get_controller_data(chip);
|
||||
uint8_t d;
|
||||
|
||||
cafe_read_buf(mtd, &d, 1);
|
||||
cafe_read_buf(chip, &d, 1);
|
||||
cafe_dev_dbg(&cafe->pdev->dev, "Read %02x\n", d);
|
||||
|
||||
return d;
|
||||
@@ -383,7 +381,7 @@ static int cafe_nand_read_page(struct nand_chip *chip, uint8_t *buf,
|
||||
cafe_readl(cafe, NAND_ECC_SYN01));
|
||||
|
||||
nand_read_page_op(chip, page, 0, buf, mtd->writesize);
|
||||
chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
|
||||
chip->read_buf(chip, chip->oob_poi, mtd->oobsize);
|
||||
|
||||
if (checkecc && cafe_readl(cafe, NAND_ECC_RESULT) & (1<<18)) {
|
||||
unsigned short syn[8], pat[4];
|
||||
|
||||
@@ -49,10 +49,8 @@ static const struct mtd_partition partition_info[] = {
|
||||
};
|
||||
#define NUM_PARTITIONS (ARRAY_SIZE(partition_info))
|
||||
|
||||
static u_char cmx270_read_byte(struct mtd_info *mtd)
|
||||
static u_char cmx270_read_byte(struct nand_chip *this)
|
||||
{
|
||||
struct nand_chip *this = mtd_to_nand(mtd);
|
||||
|
||||
return (readl(this->IO_ADDR_R) >> 16);
|
||||
}
|
||||
|
||||
@@ -65,10 +63,9 @@ static void cmx270_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
|
||||
writel((*buf++ << 16), this->IO_ADDR_W);
|
||||
}
|
||||
|
||||
static void cmx270_read_buf(struct mtd_info *mtd, u_char *buf, int len)
|
||||
static void cmx270_read_buf(struct nand_chip *this, u_char *buf, int len)
|
||||
{
|
||||
int i;
|
||||
struct nand_chip *this = mtd_to_nand(mtd);
|
||||
|
||||
for (i=0; i<len; i++)
|
||||
*buf++ = readl(this->IO_ADDR_R) >> 16;
|
||||
|
||||
@@ -93,10 +93,8 @@
|
||||
#define CS_NAND_ECC_CLRECC (1<<1)
|
||||
#define CS_NAND_ECC_ENECC (1<<0)
|
||||
|
||||
static void cs553x_read_buf(struct mtd_info *mtd, u_char *buf, int len)
|
||||
static void cs553x_read_buf(struct nand_chip *this, u_char *buf, int len)
|
||||
{
|
||||
struct nand_chip *this = mtd_to_nand(mtd);
|
||||
|
||||
while (unlikely(len > 0x800)) {
|
||||
memcpy_fromio(buf, this->IO_ADDR_R, 0x800);
|
||||
buf += 0x800;
|
||||
@@ -117,9 +115,8 @@ static void cs553x_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
|
||||
memcpy_toio(this->IO_ADDR_R, buf, len);
|
||||
}
|
||||
|
||||
static unsigned char cs553x_read_byte(struct mtd_info *mtd)
|
||||
static unsigned char cs553x_read_byte(struct nand_chip *this)
|
||||
{
|
||||
struct nand_chip *this = mtd_to_nand(mtd);
|
||||
return readb(this->IO_ADDR_R);
|
||||
}
|
||||
|
||||
|
||||
@@ -435,10 +435,9 @@ correct:
|
||||
* the two LSBs for NAND access ... so we can issue 32-bit reads/writes
|
||||
* and have that transparently morphed into multiple NAND operations.
|
||||
*/
|
||||
static void nand_davinci_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
|
||||
static void nand_davinci_read_buf(struct nand_chip *chip, uint8_t *buf,
|
||||
int len)
|
||||
{
|
||||
struct nand_chip *chip = mtd_to_nand(mtd);
|
||||
|
||||
if ((0x03 & ((uintptr_t)buf)) == 0 && (0x03 & len) == 0)
|
||||
ioread32_rep(chip->IO_ADDR_R, buf, len >> 2);
|
||||
else if ((0x01 & ((uintptr_t)buf)) == 0 && (0x01 & len) == 0)
|
||||
|
||||
@@ -215,8 +215,9 @@ static uint32_t denali_check_irq(struct denali_nand_info *denali)
|
||||
return irq_status;
|
||||
}
|
||||
|
||||
static void denali_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
|
||||
static void denali_read_buf(struct nand_chip *chip, uint8_t *buf, int len)
|
||||
{
|
||||
struct mtd_info *mtd = nand_to_mtd(chip);
|
||||
struct denali_nand_info *denali = mtd_to_denali(mtd);
|
||||
u32 addr = DENALI_MAP11_DATA | DENALI_BANK(denali);
|
||||
int i;
|
||||
@@ -235,9 +236,9 @@ static void denali_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
|
||||
denali->host_write(denali, addr, buf[i]);
|
||||
}
|
||||
|
||||
static void denali_read_buf16(struct mtd_info *mtd, uint8_t *buf, int len)
|
||||
static void denali_read_buf16(struct nand_chip *chip, uint8_t *buf, int len)
|
||||
{
|
||||
struct denali_nand_info *denali = mtd_to_denali(mtd);
|
||||
struct denali_nand_info *denali = mtd_to_denali(nand_to_mtd(chip));
|
||||
u32 addr = DENALI_MAP11_DATA | DENALI_BANK(denali);
|
||||
uint16_t *buf16 = (uint16_t *)buf;
|
||||
int i;
|
||||
@@ -258,11 +259,11 @@ static void denali_write_buf16(struct mtd_info *mtd, const uint8_t *buf,
|
||||
denali->host_write(denali, addr, buf16[i]);
|
||||
}
|
||||
|
||||
static uint8_t denali_read_byte(struct mtd_info *mtd)
|
||||
static uint8_t denali_read_byte(struct nand_chip *chip)
|
||||
{
|
||||
uint8_t byte;
|
||||
|
||||
denali_read_buf(mtd, &byte, 1);
|
||||
denali_read_buf(chip, &byte, 1);
|
||||
|
||||
return byte;
|
||||
}
|
||||
|
||||
@@ -302,9 +302,8 @@ static void doc2000_write_byte(struct mtd_info *mtd, u_char datum)
|
||||
WriteDOC(datum, docptr, 2k_CDSN_IO);
|
||||
}
|
||||
|
||||
static u_char doc2000_read_byte(struct mtd_info *mtd)
|
||||
static u_char doc2000_read_byte(struct nand_chip *this)
|
||||
{
|
||||
struct nand_chip *this = mtd_to_nand(mtd);
|
||||
struct doc_priv *doc = nand_get_controller_data(this);
|
||||
void __iomem *docptr = doc->virtadr;
|
||||
u_char ret;
|
||||
@@ -334,9 +333,8 @@ static void doc2000_writebuf(struct mtd_info *mtd, const u_char *buf, int len)
|
||||
printk("\n");
|
||||
}
|
||||
|
||||
static void doc2000_readbuf(struct mtd_info *mtd, u_char *buf, int len)
|
||||
static void doc2000_readbuf(struct nand_chip *this, u_char *buf, int len)
|
||||
{
|
||||
struct nand_chip *this = mtd_to_nand(mtd);
|
||||
struct doc_priv *doc = nand_get_controller_data(this);
|
||||
void __iomem *docptr = doc->virtadr;
|
||||
int i;
|
||||
@@ -344,14 +342,12 @@ static void doc2000_readbuf(struct mtd_info *mtd, u_char *buf, int len)
|
||||
if (debug)
|
||||
printk("readbuf of %d bytes: ", len);
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
for (i = 0; i < len; i++)
|
||||
buf[i] = ReadDOC(docptr, 2k_CDSN_IO + i);
|
||||
}
|
||||
}
|
||||
|
||||
static void doc2000_readbuf_dword(struct mtd_info *mtd, u_char *buf, int len)
|
||||
static void doc2000_readbuf_dword(struct nand_chip *this, u_char *buf, int len)
|
||||
{
|
||||
struct nand_chip *this = mtd_to_nand(mtd);
|
||||
struct doc_priv *doc = nand_get_controller_data(this);
|
||||
void __iomem *docptr = doc->virtadr;
|
||||
int i;
|
||||
@@ -387,8 +383,8 @@ static uint16_t __init doc200x_ident_chip(struct mtd_info *mtd, int nr)
|
||||
*/
|
||||
udelay(50);
|
||||
|
||||
ret = this->read_byte(mtd) << 8;
|
||||
ret |= this->read_byte(mtd);
|
||||
ret = this->read_byte(this) << 8;
|
||||
ret |= this->read_byte(this);
|
||||
|
||||
if (doc->ChipID == DOC_ChipID_Doc2k && try_dword && !nr) {
|
||||
/* First chip probe. See if we get same results by 32-bit access */
|
||||
@@ -447,7 +443,7 @@ static int doc200x_wait(struct mtd_info *mtd, struct nand_chip *this)
|
||||
DoC_WaitReady(doc);
|
||||
nand_status_op(this, NULL);
|
||||
DoC_WaitReady(doc);
|
||||
status = (int)this->read_byte(mtd);
|
||||
status = (int)this->read_byte(this);
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -463,9 +459,8 @@ static void doc2001_write_byte(struct mtd_info *mtd, u_char datum)
|
||||
WriteDOC(datum, docptr, WritePipeTerm);
|
||||
}
|
||||
|
||||
static u_char doc2001_read_byte(struct mtd_info *mtd)
|
||||
static u_char doc2001_read_byte(struct nand_chip *this)
|
||||
{
|
||||
struct nand_chip *this = mtd_to_nand(mtd);
|
||||
struct doc_priv *doc = nand_get_controller_data(this);
|
||||
void __iomem *docptr = doc->virtadr;
|
||||
|
||||
@@ -490,9 +485,8 @@ static void doc2001_writebuf(struct mtd_info *mtd, const u_char *buf, int len)
|
||||
WriteDOC(0x00, docptr, WritePipeTerm);
|
||||
}
|
||||
|
||||
static void doc2001_readbuf(struct mtd_info *mtd, u_char *buf, int len)
|
||||
static void doc2001_readbuf(struct nand_chip *this, u_char *buf, int len)
|
||||
{
|
||||
struct nand_chip *this = mtd_to_nand(mtd);
|
||||
struct doc_priv *doc = nand_get_controller_data(this);
|
||||
void __iomem *docptr = doc->virtadr;
|
||||
int i;
|
||||
@@ -507,9 +501,8 @@ static void doc2001_readbuf(struct mtd_info *mtd, u_char *buf, int len)
|
||||
buf[i] = ReadDOC(docptr, LastDataRead);
|
||||
}
|
||||
|
||||
static u_char doc2001plus_read_byte(struct mtd_info *mtd)
|
||||
static u_char doc2001plus_read_byte(struct nand_chip *this)
|
||||
{
|
||||
struct nand_chip *this = mtd_to_nand(mtd);
|
||||
struct doc_priv *doc = nand_get_controller_data(this);
|
||||
void __iomem *docptr = doc->virtadr;
|
||||
u_char ret;
|
||||
@@ -540,9 +533,8 @@ static void doc2001plus_writebuf(struct mtd_info *mtd, const u_char *buf, int le
|
||||
printk("\n");
|
||||
}
|
||||
|
||||
static void doc2001plus_readbuf(struct mtd_info *mtd, u_char *buf, int len)
|
||||
static void doc2001plus_readbuf(struct nand_chip *this, u_char *buf, int len)
|
||||
{
|
||||
struct nand_chip *this = mtd_to_nand(mtd);
|
||||
struct doc_priv *doc = nand_get_controller_data(this);
|
||||
void __iomem *docptr = doc->virtadr;
|
||||
int i;
|
||||
@@ -735,7 +727,7 @@ static void doc2001plus_command(struct mtd_info *mtd, unsigned command, int colu
|
||||
WriteDOC(NAND_CMD_STATUS, docptr, Mplus_FlashCmd);
|
||||
WriteDOC(0, docptr, Mplus_WritePipeTerm);
|
||||
WriteDOC(0, docptr, Mplus_WritePipeTerm);
|
||||
while (!(this->read_byte(mtd) & 0x40)) ;
|
||||
while (!(this->read_byte(this) & 0x40)) ;
|
||||
return;
|
||||
|
||||
/* This applies to read commands */
|
||||
|
||||
@@ -261,10 +261,9 @@ static inline void write_nop(void __iomem *docptr)
|
||||
writew(0, docptr + DOC_NOP);
|
||||
}
|
||||
|
||||
static void docg4_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
|
||||
static void docg4_read_buf(struct nand_chip *nand, uint8_t *buf, int len)
|
||||
{
|
||||
int i;
|
||||
struct nand_chip *nand = mtd_to_nand(mtd);
|
||||
uint16_t *p = (uint16_t *) buf;
|
||||
len >>= 1;
|
||||
|
||||
@@ -484,9 +483,8 @@ static int correct_data(struct mtd_info *mtd, uint8_t *buf, int page)
|
||||
return numerrs;
|
||||
}
|
||||
|
||||
static uint8_t docg4_read_byte(struct mtd_info *mtd)
|
||||
static uint8_t docg4_read_byte(struct nand_chip *nand)
|
||||
{
|
||||
struct nand_chip *nand = mtd_to_nand(mtd);
|
||||
struct docg4_priv *doc = nand_get_controller_data(nand);
|
||||
|
||||
dev_dbg(doc->dev, "%s\n", __func__);
|
||||
@@ -809,11 +807,11 @@ static int read_page(struct mtd_info *mtd, struct nand_chip *nand,
|
||||
|
||||
dev_dbg(doc->dev, "%s: status = 0x%x\n", __func__, status);
|
||||
|
||||
docg4_read_buf(mtd, buf, DOCG4_PAGE_SIZE); /* read the page data */
|
||||
docg4_read_buf(nand, buf, DOCG4_PAGE_SIZE); /* read the page data */
|
||||
|
||||
/* this device always reads oob after page data */
|
||||
/* first 14 oob bytes read from I/O reg */
|
||||
docg4_read_buf(mtd, nand->oob_poi, 14);
|
||||
docg4_read_buf(nand, nand->oob_poi, 14);
|
||||
|
||||
/* last 2 read from another reg */
|
||||
buf16 = (uint16_t *)(nand->oob_poi + 14);
|
||||
@@ -859,7 +857,6 @@ static int docg4_read_page(struct nand_chip *nand, uint8_t *buf,
|
||||
|
||||
static int docg4_read_oob(struct nand_chip *nand, int page)
|
||||
{
|
||||
struct mtd_info *mtd = nand_to_mtd(nand);
|
||||
struct docg4_priv *doc = nand_get_controller_data(nand);
|
||||
void __iomem *docptr = doc->virtadr;
|
||||
uint16_t status;
|
||||
@@ -885,7 +882,7 @@ static int docg4_read_oob(struct nand_chip *nand, int page)
|
||||
|
||||
dev_dbg(doc->dev, "%s: status = 0x%x\n", __func__, status);
|
||||
|
||||
docg4_read_buf(mtd, nand->oob_poi, 16);
|
||||
docg4_read_buf(nand, nand->oob_poi, 16);
|
||||
|
||||
write_nop(docptr);
|
||||
write_nop(docptr);
|
||||
|
||||
@@ -581,9 +581,8 @@ static void fsl_elbc_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
|
||||
* read a byte from either the FCM hardware buffer if it has any data left
|
||||
* otherwise issue a command to read a single byte.
|
||||
*/
|
||||
static u8 fsl_elbc_read_byte(struct mtd_info *mtd)
|
||||
static u8 fsl_elbc_read_byte(struct nand_chip *chip)
|
||||
{
|
||||
struct nand_chip *chip = mtd_to_nand(mtd);
|
||||
struct fsl_elbc_mtd *priv = nand_get_controller_data(chip);
|
||||
struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = priv->ctrl->nand;
|
||||
|
||||
@@ -598,9 +597,8 @@ static u8 fsl_elbc_read_byte(struct mtd_info *mtd)
|
||||
/*
|
||||
* Read from the FCM Controller Data Buffer
|
||||
*/
|
||||
static void fsl_elbc_read_buf(struct mtd_info *mtd, u8 *buf, int len)
|
||||
static void fsl_elbc_read_buf(struct nand_chip *chip, u8 *buf, int len)
|
||||
{
|
||||
struct nand_chip *chip = mtd_to_nand(mtd);
|
||||
struct fsl_elbc_mtd *priv = nand_get_controller_data(chip);
|
||||
struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = priv->ctrl->nand;
|
||||
int avail;
|
||||
@@ -720,7 +718,7 @@ static int fsl_elbc_read_page(struct nand_chip *chip, uint8_t *buf,
|
||||
|
||||
nand_read_page_op(chip, page, 0, buf, mtd->writesize);
|
||||
if (oob_required)
|
||||
fsl_elbc_read_buf(mtd, chip->oob_poi, mtd->oobsize);
|
||||
fsl_elbc_read_buf(chip, chip->oob_poi, mtd->oobsize);
|
||||
|
||||
if (fsl_elbc_wait(mtd, chip) & NAND_STATUS_FAIL)
|
||||
mtd->ecc_stats.failed++;
|
||||
|
||||
@@ -545,9 +545,8 @@ static void fsl_ifc_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
|
||||
* Read a byte from either the IFC hardware buffer
|
||||
* read function for 8-bit buswidth
|
||||
*/
|
||||
static uint8_t fsl_ifc_read_byte(struct mtd_info *mtd)
|
||||
static uint8_t fsl_ifc_read_byte(struct nand_chip *chip)
|
||||
{
|
||||
struct nand_chip *chip = mtd_to_nand(mtd);
|
||||
struct fsl_ifc_mtd *priv = nand_get_controller_data(chip);
|
||||
unsigned int offset;
|
||||
|
||||
@@ -568,9 +567,8 @@ static uint8_t fsl_ifc_read_byte(struct mtd_info *mtd)
|
||||
* Read two bytes from the IFC hardware buffer
|
||||
* read function for 16-bit buswith
|
||||
*/
|
||||
static uint8_t fsl_ifc_read_byte16(struct mtd_info *mtd)
|
||||
static uint8_t fsl_ifc_read_byte16(struct nand_chip *chip)
|
||||
{
|
||||
struct nand_chip *chip = mtd_to_nand(mtd);
|
||||
struct fsl_ifc_mtd *priv = nand_get_controller_data(chip);
|
||||
uint16_t data;
|
||||
|
||||
@@ -591,9 +589,8 @@ static uint8_t fsl_ifc_read_byte16(struct mtd_info *mtd)
|
||||
/*
|
||||
* Read from the IFC Controller Data Buffer
|
||||
*/
|
||||
static void fsl_ifc_read_buf(struct mtd_info *mtd, u8 *buf, int len)
|
||||
static void fsl_ifc_read_buf(struct nand_chip *chip, u8 *buf, int len)
|
||||
{
|
||||
struct nand_chip *chip = mtd_to_nand(mtd);
|
||||
struct fsl_ifc_mtd *priv = nand_get_controller_data(chip);
|
||||
int avail;
|
||||
|
||||
@@ -689,11 +686,11 @@ static int fsl_ifc_read_page(struct nand_chip *chip, uint8_t *buf,
|
||||
|
||||
nand_read_page_op(chip, page, 0, buf, mtd->writesize);
|
||||
if (oob_required)
|
||||
fsl_ifc_read_buf(mtd, chip->oob_poi, mtd->oobsize);
|
||||
fsl_ifc_read_buf(chip, chip->oob_poi, mtd->oobsize);
|
||||
|
||||
if (ctrl->nand_stat & IFC_NAND_EVTER_STAT_ECCER) {
|
||||
if (!oob_required)
|
||||
fsl_ifc_read_buf(mtd, chip->oob_poi, mtd->oobsize);
|
||||
fsl_ifc_read_buf(chip, chip->oob_poi, mtd->oobsize);
|
||||
|
||||
return check_erased_page(chip, buf);
|
||||
}
|
||||
|
||||
@@ -124,16 +124,16 @@ static void fun_select_chip(struct mtd_info *mtd, int mchip_nr)
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t fun_read_byte(struct mtd_info *mtd)
|
||||
static uint8_t fun_read_byte(struct nand_chip *chip)
|
||||
{
|
||||
struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd);
|
||||
struct fsl_upm_nand *fun = to_fsl_upm_nand(nand_to_mtd(chip));
|
||||
|
||||
return in_8(fun->chip.IO_ADDR_R);
|
||||
}
|
||||
|
||||
static void fun_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
|
||||
static void fun_read_buf(struct nand_chip *chip, uint8_t *buf, int len)
|
||||
{
|
||||
struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd);
|
||||
struct fsl_upm_nand *fun = to_fsl_upm_nand(nand_to_mtd(chip));
|
||||
int i;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
|
||||
@@ -859,9 +859,8 @@ static void gpmi_select_chip(struct mtd_info *mtd, int chipnr)
|
||||
this->current_chip = chipnr;
|
||||
}
|
||||
|
||||
static void gpmi_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
|
||||
static void gpmi_read_buf(struct nand_chip *chip, uint8_t *buf, int len)
|
||||
{
|
||||
struct nand_chip *chip = mtd_to_nand(mtd);
|
||||
struct gpmi_nand_data *this = nand_get_controller_data(chip);
|
||||
|
||||
dev_dbg(this->dev, "len is %d\n", len);
|
||||
@@ -879,13 +878,12 @@ static void gpmi_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
|
||||
gpmi_send_data(this, buf, len);
|
||||
}
|
||||
|
||||
static uint8_t gpmi_read_byte(struct mtd_info *mtd)
|
||||
static uint8_t gpmi_read_byte(struct nand_chip *chip)
|
||||
{
|
||||
struct nand_chip *chip = mtd_to_nand(mtd);
|
||||
struct gpmi_nand_data *this = nand_get_controller_data(chip);
|
||||
uint8_t *buf = this->data_buffer_dma;
|
||||
|
||||
gpmi_read_buf(mtd, buf, 1);
|
||||
gpmi_read_buf(chip, buf, 1);
|
||||
return buf[0];
|
||||
}
|
||||
|
||||
@@ -1336,7 +1334,7 @@ static int gpmi_ecc_read_oob(struct nand_chip *chip, int page)
|
||||
|
||||
/* Read out the conventional OOB. */
|
||||
nand_read_page_op(chip, page, mtd->writesize, NULL, 0);
|
||||
chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
|
||||
chip->read_buf(chip, chip->oob_poi, mtd->oobsize);
|
||||
|
||||
/*
|
||||
* Now, we want to make sure the block mark is correct. In the
|
||||
@@ -1346,7 +1344,7 @@ static int gpmi_ecc_read_oob(struct nand_chip *chip, int page)
|
||||
if (GPMI_IS_MX23(this)) {
|
||||
/* Read the block mark into the first byte of the OOB buffer. */
|
||||
nand_read_page_op(chip, page, 0, NULL, 0);
|
||||
chip->oob_poi[0] = chip->read_byte(mtd);
|
||||
chip->oob_poi[0] = chip->read_byte(chip);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -1635,7 +1633,7 @@ static int mx23_check_transcription_stamp(struct gpmi_nand_data *this)
|
||||
* and starts in the 12th byte of the page.
|
||||
*/
|
||||
nand_read_page_op(chip, page, 12, NULL, 0);
|
||||
chip->read_buf(mtd, buffer, strlen(fingerprint));
|
||||
chip->read_buf(chip, buffer, strlen(fingerprint));
|
||||
|
||||
/* Look for the fingerprint. */
|
||||
if (!memcmp(buffer, fingerprint, strlen(fingerprint))) {
|
||||
@@ -1771,7 +1769,7 @@ static int mx23_boot_init(struct gpmi_nand_data *this)
|
||||
/* Send the command to read the conventional block mark. */
|
||||
chip->select_chip(mtd, chipnr);
|
||||
nand_read_page_op(chip, page, mtd->writesize, NULL, 0);
|
||||
block_mark = chip->read_byte(mtd);
|
||||
block_mark = chip->read_byte(chip);
|
||||
chip->select_chip(mtd, -1);
|
||||
|
||||
/*
|
||||
|
||||
@@ -364,9 +364,8 @@ static void hisi_nfc_select_chip(struct mtd_info *mtd, int chipselect)
|
||||
host->chipselect = chipselect;
|
||||
}
|
||||
|
||||
static uint8_t hisi_nfc_read_byte(struct mtd_info *mtd)
|
||||
static uint8_t hisi_nfc_read_byte(struct nand_chip *chip)
|
||||
{
|
||||
struct nand_chip *chip = mtd_to_nand(mtd);
|
||||
struct hinfc_host *host = nand_get_controller_data(chip);
|
||||
|
||||
if (host->command == NAND_CMD_STATUS)
|
||||
@@ -390,9 +389,8 @@ hisi_nfc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
|
||||
host->offset += len;
|
||||
}
|
||||
|
||||
static void hisi_nfc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
|
||||
static void hisi_nfc_read_buf(struct nand_chip *chip, uint8_t *buf, int len)
|
||||
{
|
||||
struct nand_chip *chip = mtd_to_nand(mtd);
|
||||
struct hinfc_host *host = nand_get_controller_data(chip);
|
||||
|
||||
memcpy(buf, host->buffer + host->offset, len);
|
||||
@@ -537,7 +535,7 @@ static int hisi_nand_read_page_hwecc(struct nand_chip *chip, uint8_t *buf,
|
||||
int stat_1, stat_2;
|
||||
|
||||
nand_read_page_op(chip, page, 0, buf, mtd->writesize);
|
||||
chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
|
||||
chip->read_buf(chip, chip->oob_poi, mtd->oobsize);
|
||||
|
||||
/* errors which can not be corrected by ECC */
|
||||
if (host->irq_status & HINFC504_INTS_UE) {
|
||||
|
||||
@@ -359,9 +359,8 @@ static int lpc32xx_nand_ecc_calculate(struct nand_chip *chip,
|
||||
/*
|
||||
* Read a single byte from NAND device
|
||||
*/
|
||||
static uint8_t lpc32xx_nand_read_byte(struct mtd_info *mtd)
|
||||
static uint8_t lpc32xx_nand_read_byte(struct nand_chip *chip)
|
||||
{
|
||||
struct nand_chip *chip = mtd_to_nand(mtd);
|
||||
struct lpc32xx_nand_host *host = nand_get_controller_data(chip);
|
||||
|
||||
return (uint8_t)readl(SLC_DATA(host->io_base));
|
||||
@@ -370,9 +369,8 @@ static uint8_t lpc32xx_nand_read_byte(struct mtd_info *mtd)
|
||||
/*
|
||||
* Simple device read without ECC
|
||||
*/
|
||||
static void lpc32xx_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
|
||||
static void lpc32xx_nand_read_buf(struct nand_chip *chip, u_char *buf, int len)
|
||||
{
|
||||
struct nand_chip *chip = mtd_to_nand(mtd);
|
||||
struct lpc32xx_nand_host *host = nand_get_controller_data(chip);
|
||||
|
||||
/* Direct device read with no ECC */
|
||||
@@ -628,7 +626,7 @@ static int lpc32xx_nand_read_page_syndrome(struct nand_chip *chip, uint8_t *buf,
|
||||
status = lpc32xx_xfer(mtd, buf, chip->ecc.steps, 1);
|
||||
|
||||
/* Get OOB data */
|
||||
chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
|
||||
chip->read_buf(chip, chip->oob_poi, mtd->oobsize);
|
||||
|
||||
/* Convert to stored ECC format */
|
||||
lpc32xx_slc_ecc_copy(tmpecc, (uint32_t *) host->ecc_buf, chip->ecc.steps);
|
||||
@@ -669,8 +667,8 @@ static int lpc32xx_nand_read_page_raw_syndrome(struct nand_chip *chip,
|
||||
nand_read_page_op(chip, page, 0, NULL, 0);
|
||||
|
||||
/* Raw reads can just use the FIFO interface */
|
||||
chip->read_buf(mtd, buf, chip->ecc.size * chip->ecc.steps);
|
||||
chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
|
||||
chip->read_buf(chip, buf, chip->ecc.size * chip->ecc.steps);
|
||||
chip->read_buf(chip, chip->oob_poi, mtd->oobsize);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -493,9 +493,9 @@ static void mpc5121_nfc_buf_copy(struct mtd_info *mtd, u_char *buf, int len,
|
||||
}
|
||||
|
||||
/* Read data from NFC buffers */
|
||||
static void mpc5121_nfc_read_buf(struct mtd_info *mtd, u_char *buf, int len)
|
||||
static void mpc5121_nfc_read_buf(struct nand_chip *chip, u_char *buf, int len)
|
||||
{
|
||||
mpc5121_nfc_buf_copy(mtd, buf, len, 0);
|
||||
mpc5121_nfc_buf_copy(nand_to_mtd(chip), buf, len, 0);
|
||||
}
|
||||
|
||||
/* Write data to NFC buffers */
|
||||
@@ -506,11 +506,11 @@ static void mpc5121_nfc_write_buf(struct mtd_info *mtd,
|
||||
}
|
||||
|
||||
/* Read byte from NFC buffers */
|
||||
static u8 mpc5121_nfc_read_byte(struct mtd_info *mtd)
|
||||
static u8 mpc5121_nfc_read_byte(struct nand_chip *chip)
|
||||
{
|
||||
u8 tmp;
|
||||
|
||||
mpc5121_nfc_read_buf(mtd, &tmp, sizeof(tmp));
|
||||
mpc5121_nfc_read_buf(chip, &tmp, sizeof(tmp));
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
@@ -438,9 +438,8 @@ static inline void mtk_nfc_wait_ioready(struct mtk_nfc *nfc)
|
||||
dev_err(nfc->dev, "data not ready\n");
|
||||
}
|
||||
|
||||
static inline u8 mtk_nfc_read_byte(struct mtd_info *mtd)
|
||||
static inline u8 mtk_nfc_read_byte(struct nand_chip *chip)
|
||||
{
|
||||
struct nand_chip *chip = mtd_to_nand(mtd);
|
||||
struct mtk_nfc *nfc = nand_get_controller_data(chip);
|
||||
u32 reg;
|
||||
|
||||
@@ -467,12 +466,12 @@ static inline u8 mtk_nfc_read_byte(struct mtd_info *mtd)
|
||||
return nfi_readb(nfc, NFI_DATAR);
|
||||
}
|
||||
|
||||
static void mtk_nfc_read_buf(struct mtd_info *mtd, u8 *buf, int len)
|
||||
static void mtk_nfc_read_buf(struct nand_chip *chip, u8 *buf, int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
buf[i] = mtk_nfc_read_byte(mtd);
|
||||
buf[i] = mtk_nfc_read_byte(chip);
|
||||
}
|
||||
|
||||
static void mtk_nfc_write_byte(struct mtd_info *mtd, u8 byte)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user