Commit 7aaf28ac02ff01f4202fc2e8a71ea33775da0f6f

Authored by Sascha Hauer
Committed by David Woodhouse
1 parent 5f97304ef1

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>

Showing 1 changed file with 19 additions and 13 deletions Side-by-side Diff

drivers/mtd/nand/mxc_nand.c
... ... @@ -122,6 +122,7 @@
122 122 void (*send_page)(struct mtd_info *, unsigned int);
123 123 void (*send_read_id)(struct mxc_nand_host *);
124 124 uint16_t (*get_dev_status)(struct mxc_nand_host *);
  125 + int (*check_int)(struct mxc_nand_host *);
125 126 };
126 127  
127 128 /* OOB placement block for use with hardware ecc generation */
128 129  
129 130  
130 131  
131 132  
132 133  
... ... @@ -181,34 +182,38 @@
181 182 return IRQ_HANDLED;
182 183 }
183 184  
  185 +static 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 198 /* This function polls the NANDFC to wait for the basic operation to
185 199 * complete by checking the INT bit of config2 register.
186 200 */
187 201 static void wait_op_done(struct mxc_nand_host *host, int useirq)
188 202 {
189   - uint16_t tmp;
190 203 int max_retries = 8000;
191 204  
192 205 if (useirq) {
193   - if ((readw(host->regs + NFC_CONFIG2) & NFC_INT) == 0) {
  206 + if (!host->check_int(host)) {
194 207  
195 208 enable_irq(host->irq);
196 209  
197   - wait_event(host->irq_waitq,
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);
  210 + wait_event(host->irq_waitq, host->check_int(host));
203 211 }
204 212 } else {
205 213 while (max_retries-- > 0) {
206   - if (readw(host->regs + NFC_CONFIG2) & NFC_INT) {
207   - tmp = readw(host->regs + NFC_CONFIG2);
208   - tmp &= ~NFC_INT;
209   - writew(tmp, host->regs + NFC_CONFIG2);
  214 + if (host->check_int(host))
210 215 break;
211   - }
  216 +
212 217 udelay(1);
213 218 }
214 219 if (max_retries < 0)
... ... @@ -774,6 +779,7 @@
774 779 host->send_page = send_page_v1_v2;
775 780 host->send_read_id = send_read_id_v1_v2;
776 781 host->get_dev_status = get_dev_status_v1_v2;
  782 + host->check_int = check_int_v1_v2;
777 783 }
778 784  
779 785 if (nfc_is_v21()) {