aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBastian Hecht <hechtb@googlemail.com>2012-03-01 04:48:39 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2012-03-26 19:42:57 -0400
commit0b3f0d12eff1ed23496fcf4cf468e1d317516e53 (patch)
treee84337479fd27342f617707819f7af27729409c1
parentdd5ab248329edab4b16b70e4d9920f162d181d90 (diff)
mtd: sh_flctl: Use cached register value for FLCMNCR
Instead of reading out the register, use a cached value. This will make way for a proper runtime power management implementation. Signed-off-by: Bastian Hecht <hechtb@gmail.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
-rw-r--r--drivers/mtd/nand/sh_flctl.c22
-rw-r--r--include/linux/mtd/sh_flctl.h1
2 files changed, 8 insertions, 15 deletions
diff --git a/drivers/mtd/nand/sh_flctl.c b/drivers/mtd/nand/sh_flctl.c
index 61e41c065db..48d5da0ec75 100644
--- a/drivers/mtd/nand/sh_flctl.c
+++ b/drivers/mtd/nand/sh_flctl.c
@@ -283,7 +283,7 @@ static void write_fiforeg(struct sh_flctl *flctl, int rlen, int offset)
283static void set_cmd_regs(struct mtd_info *mtd, uint32_t cmd, uint32_t flcmcdr_val) 283static void set_cmd_regs(struct mtd_info *mtd, uint32_t cmd, uint32_t flcmcdr_val)
284{ 284{
285 struct sh_flctl *flctl = mtd_to_flctl(mtd); 285 struct sh_flctl *flctl = mtd_to_flctl(mtd);
286 uint32_t flcmncr_val = readl(FLCMNCR(flctl)) & ~SEL_16BIT; 286 uint32_t flcmncr_val = flctl->flcmncr_base & ~SEL_16BIT;
287 uint32_t flcmdcr_val, addr_len_bytes = 0; 287 uint32_t flcmdcr_val, addr_len_bytes = 0;
288 288
289 /* Set SNAND bit if page size is 2048byte */ 289 /* Set SNAND bit if page size is 2048byte */
@@ -684,16 +684,15 @@ read_normal_exit:
684static void flctl_select_chip(struct mtd_info *mtd, int chipnr) 684static void flctl_select_chip(struct mtd_info *mtd, int chipnr)
685{ 685{
686 struct sh_flctl *flctl = mtd_to_flctl(mtd); 686 struct sh_flctl *flctl = mtd_to_flctl(mtd);
687 uint32_t flcmncr_val = readl(FLCMNCR(flctl));
688 687
689 switch (chipnr) { 688 switch (chipnr) {
690 case -1: 689 case -1:
691 flcmncr_val &= ~CE0_ENABLE; 690 flctl->flcmncr_base &= ~CE0_ENABLE;
692 writel(flcmncr_val, FLCMNCR(flctl)); 691 writel(flctl->flcmncr_base, FLCMNCR(flctl));
693 break; 692 break;
694 case 0: 693 case 0:
695 flcmncr_val |= CE0_ENABLE; 694 flctl->flcmncr_base |= CE0_ENABLE;
696 writel(flcmncr_val, FLCMNCR(flctl)); 695 writel(flctl->flcmncr_base, FLCMNCR(flctl));
697 break; 696 break;
698 default: 697 default:
699 BUG(); 698 BUG();
@@ -751,11 +750,6 @@ static int flctl_verify_buf(struct mtd_info *mtd, const u_char *buf, int len)
751 return 0; 750 return 0;
752} 751}
753 752
754static void flctl_register_init(struct sh_flctl *flctl, unsigned long val)
755{
756 writel(val, FLCMNCR(flctl));
757}
758
759static int flctl_chip_init_tail(struct mtd_info *mtd) 753static int flctl_chip_init_tail(struct mtd_info *mtd)
760{ 754{
761 struct sh_flctl *flctl = mtd_to_flctl(mtd); 755 struct sh_flctl *flctl = mtd_to_flctl(mtd);
@@ -807,8 +801,7 @@ static int flctl_chip_init_tail(struct mtd_info *mtd)
807 chip->ecc.mode = NAND_ECC_HW; 801 chip->ecc.mode = NAND_ECC_HW;
808 802
809 /* 4 symbols ECC enabled */ 803 /* 4 symbols ECC enabled */
810 writel(readl(FLCMNCR(flctl)) | _4ECCEN | ECCPOS2 | ECCPOS_02, 804 flctl->flcmncr_base |= _4ECCEN | ECCPOS2 | ECCPOS_02;
811 FLCMNCR(flctl));
812 } else { 805 } else {
813 chip->ecc.mode = NAND_ECC_SOFT; 806 chip->ecc.mode = NAND_ECC_SOFT;
814 } 807 }
@@ -854,10 +847,9 @@ static int __devinit flctl_probe(struct platform_device *pdev)
854 nand = &flctl->chip; 847 nand = &flctl->chip;
855 flctl_mtd->priv = nand; 848 flctl_mtd->priv = nand;
856 flctl->pdev = pdev; 849 flctl->pdev = pdev;
850 flctl->flcmncr_base = pdata->flcmncr_val;
857 flctl->hwecc = pdata->has_hwecc; 851 flctl->hwecc = pdata->has_hwecc;
858 852
859 flctl_register_init(flctl, pdata->flcmncr_val);
860
861 nand->options = NAND_NO_AUTOINCR; 853 nand->options = NAND_NO_AUTOINCR;
862 854
863 /* Set address of hardware control function */ 855 /* Set address of hardware control function */
diff --git a/include/linux/mtd/sh_flctl.h b/include/linux/mtd/sh_flctl.h
index b66940593c8..c7082820703 100644
--- a/include/linux/mtd/sh_flctl.h
+++ b/include/linux/mtd/sh_flctl.h
@@ -132,6 +132,7 @@ struct sh_flctl {
132 int erase1_page_addr; /* page_addr in ERASE1 cmd */ 132 int erase1_page_addr; /* page_addr in ERASE1 cmd */
133 uint32_t erase_ADRCNT; /* bits of FLCMDCR in ERASE1 cmd */ 133 uint32_t erase_ADRCNT; /* bits of FLCMDCR in ERASE1 cmd */
134 uint32_t rw_ADRCNT; /* bits of FLCMDCR in READ WRITE cmd */ 134 uint32_t rw_ADRCNT; /* bits of FLCMDCR in READ WRITE cmd */
135 uint32_t flcmncr_base; /* base value of FLCMNCR */
135 136
136 int hwecc_cant_correct[4]; 137 int hwecc_cant_correct[4];
137 138