aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorEzequiel Garcia <ezequiel.garcia@free-electrons.com>2013-08-12 13:14:55 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2013-08-30 16:34:59 -0400
commit48cf7efa6be22e5ab42c16e2700e401f2e6f8bad (patch)
tree8c42aeee9bbb68cda37e595b99273236036162af /drivers/mtd
parentec82135a011cf657ef02cfa2038331b381e39960 (diff)
mtd: nand: pxa3xx: Move cached registers to info structure
This registers are not per-chip (aka host) but controller-wide, so it's better to store them in the global 'info' structure. Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Tested-by: Daniel Mack <zonque@gmail.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/nand/pxa3xx_nand.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
index ad63e8c02fd8..5e5f5302dd6f 100644
--- a/drivers/mtd/nand/pxa3xx_nand.c
+++ b/drivers/mtd/nand/pxa3xx_nand.c
@@ -144,10 +144,6 @@ struct pxa3xx_nand_host {
144 unsigned int row_addr_cycles; 144 unsigned int row_addr_cycles;
145 size_t read_id_bytes; 145 size_t read_id_bytes;
146 146
147 /* cached register value */
148 uint32_t reg_ndcr;
149 uint32_t ndtr0cs0;
150 uint32_t ndtr1cs0;
151}; 147};
152 148
153struct pxa3xx_nand_info { 149struct pxa3xx_nand_info {
@@ -193,6 +189,11 @@ struct pxa3xx_nand_info {
193 unsigned int oob_size; 189 unsigned int oob_size;
194 int retcode; 190 int retcode;
195 191
192 /* cached register value */
193 uint32_t reg_ndcr;
194 uint32_t ndtr0cs0;
195 uint32_t ndtr1cs0;
196
196 /* generated NDCBx register values */ 197 /* generated NDCBx register values */
197 uint32_t ndcb0; 198 uint32_t ndcb0;
198 uint32_t ndcb1; 199 uint32_t ndcb1;
@@ -258,8 +259,8 @@ static void pxa3xx_nand_set_timing(struct pxa3xx_nand_host *host,
258 NDTR1_tWHR(ns2cycle(t->tWHR, nand_clk)) | 259 NDTR1_tWHR(ns2cycle(t->tWHR, nand_clk)) |
259 NDTR1_tAR(ns2cycle(t->tAR, nand_clk)); 260 NDTR1_tAR(ns2cycle(t->tAR, nand_clk));
260 261
261 host->ndtr0cs0 = ndtr0; 262 info->ndtr0cs0 = ndtr0;
262 host->ndtr1cs0 = ndtr1; 263 info->ndtr1cs0 = ndtr1;
263 nand_writel(info, NDTR0CS0, ndtr0); 264 nand_writel(info, NDTR0CS0, ndtr0);
264 nand_writel(info, NDTR1CS0, ndtr1); 265 nand_writel(info, NDTR1CS0, ndtr1);
265} 266}
@@ -267,7 +268,7 @@ static void pxa3xx_nand_set_timing(struct pxa3xx_nand_host *host,
267static void pxa3xx_set_datasize(struct pxa3xx_nand_info *info) 268static void pxa3xx_set_datasize(struct pxa3xx_nand_info *info)
268{ 269{
269 struct pxa3xx_nand_host *host = info->host[info->cs]; 270 struct pxa3xx_nand_host *host = info->host[info->cs];
270 int oob_enable = host->reg_ndcr & NDCR_SPARE_EN; 271 int oob_enable = info->reg_ndcr & NDCR_SPARE_EN;
271 272
272 info->data_size = host->page_size; 273 info->data_size = host->page_size;
273 if (!oob_enable) { 274 if (!oob_enable) {
@@ -293,10 +294,9 @@ static void pxa3xx_set_datasize(struct pxa3xx_nand_info *info)
293 */ 294 */
294static void pxa3xx_nand_start(struct pxa3xx_nand_info *info) 295static void pxa3xx_nand_start(struct pxa3xx_nand_info *info)
295{ 296{
296 struct pxa3xx_nand_host *host = info->host[info->cs];
297 uint32_t ndcr; 297 uint32_t ndcr;
298 298
299 ndcr = host->reg_ndcr; 299 ndcr = info->reg_ndcr;
300 300
301 if (info->use_ecc) 301 if (info->use_ecc)
302 ndcr |= NDCR_ECC_EN; 302 ndcr |= NDCR_ECC_EN;
@@ -683,7 +683,7 @@ static void pxa3xx_nand_cmdfunc(struct mtd_info *mtd, unsigned command,
683 * "byte" address into a "word" address appropriate 683 * "byte" address into a "word" address appropriate
684 * for indexing a word-oriented device 684 * for indexing a word-oriented device
685 */ 685 */
686 if (host->reg_ndcr & NDCR_DWIDTH_M) 686 if (info->reg_ndcr & NDCR_DWIDTH_M)
687 column /= 2; 687 column /= 2;
688 688
689 /* 689 /*
@@ -693,8 +693,8 @@ static void pxa3xx_nand_cmdfunc(struct mtd_info *mtd, unsigned command,
693 */ 693 */
694 if (info->cs != host->cs) { 694 if (info->cs != host->cs) {
695 info->cs = host->cs; 695 info->cs = host->cs;
696 nand_writel(info, NDTR0CS0, host->ndtr0cs0); 696 nand_writel(info, NDTR0CS0, info->ndtr0cs0);
697 nand_writel(info, NDTR1CS0, host->ndtr1cs0); 697 nand_writel(info, NDTR1CS0, info->ndtr1cs0);
698 } 698 }
699 699
700 info->state = STATE_PREPARED; 700 info->state = STATE_PREPARED;
@@ -870,7 +870,7 @@ static int pxa3xx_nand_config_flash(struct pxa3xx_nand_info *info,
870 ndcr |= NDCR_RD_ID_CNT(host->read_id_bytes); 870 ndcr |= NDCR_RD_ID_CNT(host->read_id_bytes);
871 ndcr |= NDCR_SPARE_EN; /* enable spare by default */ 871 ndcr |= NDCR_SPARE_EN; /* enable spare by default */
872 872
873 host->reg_ndcr = ndcr; 873 info->reg_ndcr = ndcr;
874 874
875 pxa3xx_nand_set_timing(host, f->timing); 875 pxa3xx_nand_set_timing(host, f->timing);
876 return 0; 876 return 0;
@@ -893,11 +893,9 @@ static int pxa3xx_nand_detect_config(struct pxa3xx_nand_info *info)
893 host->read_id_bytes = 2; 893 host->read_id_bytes = 2;
894 } 894 }
895 895
896 host->reg_ndcr = ndcr & ~NDCR_INT_MASK; 896 info->reg_ndcr = ndcr & ~NDCR_INT_MASK;
897 897 info->ndtr0cs0 = nand_readl(info, NDTR0CS0);
898 host->ndtr0cs0 = nand_readl(info, NDTR0CS0); 898 info->ndtr1cs0 = nand_readl(info, NDTR1CS0);
899 host->ndtr1cs0 = nand_readl(info, NDTR1CS0);
900
901 return 0; 899 return 0;
902} 900}
903 901
@@ -1044,7 +1042,7 @@ KEEP_CONFIG:
1044 chip->ecc.size = host->page_size; 1042 chip->ecc.size = host->page_size;
1045 chip->ecc.strength = 1; 1043 chip->ecc.strength = 1;
1046 1044
1047 if (host->reg_ndcr & NDCR_DWIDTH_M) 1045 if (info->reg_ndcr & NDCR_DWIDTH_M)
1048 chip->options |= NAND_BUSWIDTH_16; 1046 chip->options |= NAND_BUSWIDTH_16;
1049 1047
1050 if (nand_scan_ident(mtd, 1, def)) 1048 if (nand_scan_ident(mtd, 1, def))