aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/mxc_nand.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/nand/mxc_nand.c')
-rw-r--r--drivers/mtd/nand/mxc_nand.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index c58e6a93f445..6acc790c2fbb 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -273,6 +273,26 @@ static struct nand_ecclayout nandv2_hw_eccoob_4k = {
273 273
274static const char *part_probes[] = { "RedBoot", "cmdlinepart", "ofpart", NULL }; 274static const char *part_probes[] = { "RedBoot", "cmdlinepart", "ofpart", NULL };
275 275
276static void memcpy32_fromio(void *trg, const void __iomem *src, size_t size)
277{
278 int i;
279 u32 *t = trg;
280 const __iomem u32 *s = src;
281
282 for (i = 0; i < (size >> 2); i++)
283 *t++ = __raw_readl(s++);
284}
285
286static void memcpy32_toio(void __iomem *trg, const void *src, int size)
287{
288 int i;
289 u32 __iomem *t = trg;
290 const u32 *s = src;
291
292 for (i = 0; i < (size >> 2); i++)
293 __raw_writel(*s++, t++);
294}
295
276static int check_int_v3(struct mxc_nand_host *host) 296static int check_int_v3(struct mxc_nand_host *host)
277{ 297{
278 uint32_t tmp; 298 uint32_t tmp;
@@ -519,7 +539,7 @@ static void send_read_id_v3(struct mxc_nand_host *host)
519 539
520 wait_op_done(host, true); 540 wait_op_done(host, true);
521 541
522 memcpy_fromio(host->data_buf, host->main_area0, 16); 542 memcpy32_fromio(host->data_buf, host->main_area0, 16);
523} 543}
524 544
525/* Request the NANDFC to perform a read of the NAND device ID. */ 545/* Request the NANDFC to perform a read of the NAND device ID. */
@@ -535,7 +555,7 @@ static void send_read_id_v1_v2(struct mxc_nand_host *host)
535 /* Wait for operation to complete */ 555 /* Wait for operation to complete */
536 wait_op_done(host, true); 556 wait_op_done(host, true);
537 557
538 memcpy_fromio(host->data_buf, host->main_area0, 16); 558 memcpy32_fromio(host->data_buf, host->main_area0, 16);
539 559
540 if (this->options & NAND_BUSWIDTH_16) { 560 if (this->options & NAND_BUSWIDTH_16) {
541 /* compress the ID info */ 561 /* compress the ID info */
@@ -797,16 +817,16 @@ static void copy_spare(struct mtd_info *mtd, bool bfrom)
797 817
798 if (bfrom) { 818 if (bfrom) {
799 for (i = 0; i < n - 1; i++) 819 for (i = 0; i < n - 1; i++)
800 memcpy_fromio(d + i * j, s + i * t, j); 820 memcpy32_fromio(d + i * j, s + i * t, j);
801 821
802 /* the last section */ 822 /* the last section */
803 memcpy_fromio(d + i * j, s + i * t, mtd->oobsize - i * j); 823 memcpy32_fromio(d + i * j, s + i * t, mtd->oobsize - i * j);
804 } else { 824 } else {
805 for (i = 0; i < n - 1; i++) 825 for (i = 0; i < n - 1; i++)
806 memcpy_toio(&s[i * t], &d[i * j], j); 826 memcpy32_toio(&s[i * t], &d[i * j], j);
807 827
808 /* the last section */ 828 /* the last section */
809 memcpy_toio(&s[i * t], &d[i * j], mtd->oobsize - i * j); 829 memcpy32_toio(&s[i * t], &d[i * j], mtd->oobsize - i * j);
810 } 830 }
811} 831}
812 832
@@ -1070,7 +1090,8 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
1070 1090
1071 host->devtype_data->send_page(mtd, NFC_OUTPUT); 1091 host->devtype_data->send_page(mtd, NFC_OUTPUT);
1072 1092
1073 memcpy_fromio(host->data_buf, host->main_area0, mtd->writesize); 1093 memcpy32_fromio(host->data_buf, host->main_area0,
1094 mtd->writesize);
1074 copy_spare(mtd, true); 1095 copy_spare(mtd, true);
1075 break; 1096 break;
1076 1097
@@ -1086,7 +1107,7 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
1086 break; 1107 break;
1087 1108
1088 case NAND_CMD_PAGEPROG: 1109 case NAND_CMD_PAGEPROG:
1089 memcpy_toio(host->main_area0, host->data_buf, mtd->writesize); 1110 memcpy32_toio(host->main_area0, host->data_buf, mtd->writesize);
1090 copy_spare(mtd, false); 1111 copy_spare(mtd, false);
1091 host->devtype_data->send_page(mtd, NFC_INPUT); 1112 host->devtype_data->send_page(mtd, NFC_INPUT);
1092 host->devtype_data->send_cmd(host, command, true); 1113 host->devtype_data->send_cmd(host, command, true);