aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2010-08-06 09:53:07 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2010-08-06 11:37:22 -0400
commit7aaf28ac02ff01f4202fc2e8a71ea33775da0f6f (patch)
tree1edf8478c5cc57e86bc93f0945dc68003636d6b4 /drivers/mtd/nand
parent5f97304ef12b79f1a466971eefdf93ea3b2d341f (diff)
mxc_nand: factor out a check_int function
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r--drivers/mtd/nand/mxc_nand.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index 5130a853102..ea491140e55 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -122,6 +122,7 @@ struct mxc_nand_host {
122 void (*send_page)(struct mtd_info *, unsigned int); 122 void (*send_page)(struct mtd_info *, unsigned int);
123 void (*send_read_id)(struct mxc_nand_host *); 123 void (*send_read_id)(struct mxc_nand_host *);
124 uint16_t (*get_dev_status)(struct mxc_nand_host *); 124 uint16_t (*get_dev_status)(struct mxc_nand_host *);
125 int (*check_int)(struct mxc_nand_host *);
125}; 126};
126 127
127/* OOB placement block for use with hardware ecc generation */ 128/* OOB placement block for use with hardware ecc generation */
@@ -181,34 +182,38 @@ static irqreturn_t mxc_nfc_irq(int irq, void *dev_id)
181 return IRQ_HANDLED; 182 return IRQ_HANDLED;
182} 183}
183 184
185static int check_int_v1_v2(struct mxc_nand_host *host)
186{
187 uint32_t tmp;
188
189 tmp = readw(host->regs + NFC_CONFIG2);
190 if (!(tmp & NFC_INT))
191 return 0;
192
193 writew(tmp & ~NFC_INT, NFC_CONFIG2);
194
195 return 1;
196}
197
184/* This function polls the NANDFC to wait for the basic operation to 198/* This function polls the NANDFC to wait for the basic operation to
185 * complete by checking the INT bit of config2 register. 199 * complete by checking the INT bit of config2 register.
186 */ 200 */
187static void wait_op_done(struct mxc_nand_host *host, int useirq) 201static void wait_op_done(struct mxc_nand_host *host, int useirq)
188{ 202{
189 uint16_t tmp;
190 int max_retries = 8000; 203 int max_retries = 8000;
191 204
192 if (useirq) { 205 if (useirq) {
193 if ((readw(host->regs + NFC_CONFIG2) & NFC_INT) == 0) { 206 if (!host->check_int(host)) {
194 207
195 enable_irq(host->irq); 208 enable_irq(host->irq);
196 209
197 wait_event(host->irq_waitq, 210 wait_event(host->irq_waitq, host->check_int(host));
198 readw(host->regs + NFC_CONFIG2) & NFC_INT);
199
200 tmp = readw(host->regs + NFC_CONFIG2);
201 tmp &= ~NFC_INT;
202 writew(tmp, host->regs + NFC_CONFIG2);
203 } 211 }
204 } else { 212 } else {
205 while (max_retries-- > 0) { 213 while (max_retries-- > 0) {
206 if (readw(host->regs + NFC_CONFIG2) & NFC_INT) { 214 if (host->check_int(host))
207 tmp = readw(host->regs + NFC_CONFIG2);
208 tmp &= ~NFC_INT;
209 writew(tmp, host->regs + NFC_CONFIG2);
210 break; 215 break;
211 } 216
212 udelay(1); 217 udelay(1);
213 } 218 }
214 if (max_retries < 0) 219 if (max_retries < 0)
@@ -774,6 +779,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)
774 host->send_page = send_page_v1_v2; 779 host->send_page = send_page_v1_v2;
775 host->send_read_id = send_read_id_v1_v2; 780 host->send_read_id = send_read_id_v1_v2;
776 host->get_dev_status = get_dev_status_v1_v2; 781 host->get_dev_status = get_dev_status_v1_v2;
782 host->check_int = check_int_v1_v2;
777 } 783 }
778 784
779 if (nfc_is_v21()) { 785 if (nfc_is_v21()) {