Merge branch 'for-next/mtd'
This commit is contained in:
commit
9524e7d0d7
|
@ -2768,14 +2768,9 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
|
|||
int *busw)
|
||||
{
|
||||
struct nand_onfi_params *p = &chip->onfi_params;
|
||||
int i;
|
||||
int i, j;
|
||||
int val;
|
||||
|
||||
/* ONFI need to be probed in 8 bits mode, and 16 bits should be selected with NAND_BUSWIDTH_AUTO */
|
||||
if (chip->options & NAND_BUSWIDTH_16) {
|
||||
pr_err("Trying ONFI probe in 16 bits mode, aborting !\n");
|
||||
return 0;
|
||||
}
|
||||
/* Try ONFI for unknown chip or LP */
|
||||
chip->cmdfunc(mtd, NAND_CMD_READID, 0x20, -1);
|
||||
if (chip->read_byte(mtd) != 'O' || chip->read_byte(mtd) != 'N' ||
|
||||
|
@ -2784,16 +2779,18 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
|
|||
|
||||
chip->cmdfunc(mtd, NAND_CMD_PARAM, 0, -1);
|
||||
for (i = 0; i < 3; i++) {
|
||||
chip->read_buf(mtd, (uint8_t *)p, sizeof(*p));
|
||||
for (j = 0; j < sizeof(*p); j++)
|
||||
((uint8_t *)p)[j] = chip->read_byte(mtd);
|
||||
if (onfi_crc16(ONFI_CRC_BASE, (uint8_t *)p, 254) ==
|
||||
le16_to_cpu(p->crc)) {
|
||||
pr_info("ONFI param page %d valid\n", i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 3)
|
||||
if (i == 3) {
|
||||
pr_err("Could not find valid ONFI parameter page; aborting\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Check version */
|
||||
val = le16_to_cpu(p->revision);
|
||||
|
|
|
@ -362,7 +362,11 @@ static void send_read_id_v3(struct imx_nand_host *host)
|
|||
|
||||
wait_op_done(host);
|
||||
|
||||
memcpy(host->data_buf, host->main_area0, 16);
|
||||
/*
|
||||
* NFC_ID results in reading 6 bytes or words (depending on data width),
|
||||
* so copying 3 32-bit values is just fine.
|
||||
*/
|
||||
memcpy(host->data_buf, host->main_area0, 12);
|
||||
}
|
||||
|
||||
static void send_read_param_v3(struct imx_nand_host *host)
|
||||
|
@ -377,8 +381,6 @@ static void send_read_param_v3(struct imx_nand_host *host)
|
|||
|
||||
static void send_read_id_v1_v2(struct imx_nand_host *host)
|
||||
{
|
||||
struct nand_chip *this = &host->nand;
|
||||
|
||||
/* NANDFC buffer 0 is used for device ID output */
|
||||
writew(0x0, host->regs + NFC_V1_V2_BUF_ADDR);
|
||||
|
||||
|
@ -387,20 +389,11 @@ static void send_read_id_v1_v2(struct imx_nand_host *host)
|
|||
/* Wait for operation to complete */
|
||||
wait_op_done(host);
|
||||
|
||||
if (this->options & NAND_BUSWIDTH_16) {
|
||||
volatile u16 *mainbuf = host->main_area0;
|
||||
|
||||
/*
|
||||
* Pack the every-other-byte result for 16-bit ID reads
|
||||
* into every-byte as the generic code expects and various
|
||||
* chips implement.
|
||||
*/
|
||||
|
||||
mainbuf[0] = (mainbuf[0] & 0xff) | ((mainbuf[1] & 0xff) << 8);
|
||||
mainbuf[1] = (mainbuf[2] & 0xff) | ((mainbuf[3] & 0xff) << 8);
|
||||
mainbuf[2] = (mainbuf[4] & 0xff) | ((mainbuf[5] & 0xff) << 8);
|
||||
}
|
||||
memcpy32(host->data_buf, host->main_area0, 16);
|
||||
/*
|
||||
* NFC_ID results in reading 6 bytes or words (depending on data width),
|
||||
* so copying 3 32-bit values is just fine.
|
||||
*/
|
||||
memcpy32(host->data_buf, host->main_area0, 12);
|
||||
}
|
||||
|
||||
static void send_read_param_v1_v2(struct imx_nand_host *host)
|
||||
|
@ -572,8 +565,16 @@ static u_char imx_nand_read_byte(struct mtd_info *mtd)
|
|||
if (host->status_request)
|
||||
return host->get_dev_status(host) & 0xFF;
|
||||
|
||||
ret = *(uint8_t *)(host->data_buf + host->buf_start);
|
||||
host->buf_start++;
|
||||
if (nand_chip->options & NAND_BUSWIDTH_16) {
|
||||
/* only take the lower byte of each word */
|
||||
BUG_ON(host->buf_start & 1);
|
||||
ret = *(uint16_t *)(host->data_buf + host->buf_start);
|
||||
|
||||
host->buf_start += 2;
|
||||
} else {
|
||||
ret = *(uint8_t *)(host->data_buf + host->buf_start);
|
||||
host->buf_start++;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue