summaryrefslogtreecommitdiff
path: root/target/linux/ar71xx/files/drivers
diff options
context:
space:
mode:
authorjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-12-10 10:38:07 +0000
committerjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-12-10 10:38:07 +0000
commitc586ec0f293f11996e442886b5767c697b87f728 (patch)
tree86d51c817eeda7e208ecfd65f62ee39d87c3058a /target/linux/ar71xx/files/drivers
parente333d81785a82a61cb6c2d7a761ddb4c9486842d (diff)
ar71xx: ar934x_nfc: allow to control DMA data swap via platform data
Signed-off-by: Gabor Juhos <juhosg@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@34588 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/ar71xx/files/drivers')
-rw-r--r--target/linux/ar71xx/files/drivers/mtd/nand/ar934x_nfc.c45
1 files changed, 35 insertions, 10 deletions
diff --git a/target/linux/ar71xx/files/drivers/mtd/nand/ar934x_nfc.c b/target/linux/ar71xx/files/drivers/mtd/nand/ar934x_nfc.c
index 7fd04ca621..7939f9218c 100644
--- a/target/linux/ar71xx/files/drivers/mtd/nand/ar934x_nfc.c
+++ b/target/linux/ar71xx/files/drivers/mtd/nand/ar934x_nfc.c
@@ -174,6 +174,7 @@ struct ar934x_nfc {
struct device *parent;
void __iomem *base;
void (*select_chip)(int chip_no);
+ bool swap_dma;
int irq;
wait_queue_head_t irq_waitq;
@@ -190,6 +191,8 @@ struct ar934x_nfc {
unsigned int buf_size;
int buf_index;
+ bool read_id;
+
int erase1_page_addr;
int rndout_page_addr;
@@ -591,7 +594,10 @@ ar934x_nfc_read_status(struct ar934x_nfc *nfc)
nfc_dbg(nfc, "read status, cmd:%08x status:%02x\n",
cmd_reg, (status & 0xff));
- nfc->buf[0 ^ 3] = status;
+ if (nfc->swap_dma)
+ nfc->buf[0 ^ 3] = status;
+ else
+ nfc->buf[0] = status;
}
static void
@@ -600,6 +606,7 @@ ar934x_nfc_cmdfunc(struct mtd_info *mtd, unsigned int command, int column,
{
struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
+ nfc->read_id = false;
if (command != NAND_CMD_PAGEPROG)
nfc->buf_index = 0;
@@ -609,6 +616,7 @@ ar934x_nfc_cmdfunc(struct mtd_info *mtd, unsigned int command, int column,
break;
case NAND_CMD_READID:
+ nfc->read_id = true;
ar934x_nfc_send_readid(nfc, command);
break;
@@ -717,13 +725,15 @@ static u8
ar934x_nfc_read_byte(struct mtd_info *mtd)
{
struct ar934x_nfc *nfc = mtd_to_ar934x_nfc(mtd);
- unsigned int buf_index;
u8 data;
WARN_ON(nfc->buf_index >= nfc->buf_size);
- buf_index = nfc->buf_index ^ 3;
- data = nfc->buf[buf_index];
+ if (nfc->swap_dma || nfc->read_id)
+ data = nfc->buf[nfc->buf_index ^ 3];
+ else
+ data = nfc->buf[nfc->buf_index];
+
nfc->buf_index++;
return data;
@@ -737,9 +747,16 @@ ar934x_nfc_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
WARN_ON(nfc->buf_index + len > nfc->buf_size);
- for (i = 0; i < len; i++) {
- nfc->buf[nfc->buf_index ^ 3] = buf[i];
- nfc->buf_index++;
+ if (nfc->swap_dma) {
+ for (i = 0; i < len; i++) {
+ nfc->buf[nfc->buf_index ^ 3] = buf[i];
+ nfc->buf_index++;
+ }
+ } else {
+ for (i = 0; i < len; i++) {
+ nfc->buf[nfc->buf_index] = buf[i];
+ nfc->buf_index++;
+ }
}
}
@@ -754,9 +771,16 @@ ar934x_nfc_read_buf(struct mtd_info *mtd, u8 *buf, int len)
buf_index = nfc->buf_index;
- for (i = 0; i < len; i++) {
- buf[i] = nfc->buf[buf_index ^ 3];
- buf_index++;
+ if (nfc->swap_dma || nfc->read_id) {
+ for (i = 0; i < len; i++) {
+ buf[i] = nfc->buf[buf_index ^ 3];
+ buf_index++;
+ }
+ } else {
+ for (i = 0; i < len; i++) {
+ buf[i] = nfc->buf[buf_index];
+ buf_index++;
+ }
}
nfc->buf_index = buf_index;
@@ -1028,6 +1052,7 @@ ar934x_nfc_probe(struct platform_device *pdev)
nfc->parent = &pdev->dev;
nfc->select_chip = pdata->select_chip;
+ nfc->swap_dma = pdata->swap_dma;
nand = &nfc->nand_chip;
mtd = &nfc->mtd;