@@ -16,9 +16,13 @@
#include "bcm47xxnflash.h"
-/* Broadcom uses 1'000'000 but it seems to be too many. Tests on WNDR4500 has
- * shown 164 retries as maxiumum. */
-#define NFLASH_READY_RETRIES 1000
+/* Broadcom uses 1'000'000 for both without any delay.
+ * Tests on WNDR4500 have shown that in can take:
+ * 1) 0-5 retries for ctl_cmd with ndelay(1)
+ * 2) 0-800 retries for poll with ndelay(1)
+ */
+#define NFLASH_CTL_CMD_RETRIES 100
+#define NFLASH_POLL_RETRIES 10000
#define NFLASH_SECTOR_SIZE 512
@@ -45,11 +49,12 @@ static int bcm47xxnflash_ops_bcm4706_ctl_cmd(struct bcma_drv_cc *cc, u32 code)
int i = 0;
bcma_cc_write32(cc, BCMA_CC_NFLASH_CTL, NCTL_START | code);
- for (i = 0; i < NFLASH_READY_RETRIES; i++) {
+ for (i = 0; i < NFLASH_CTL_CMD_RETRIES; i++) {
if (!(bcma_cc_read32(cc, BCMA_CC_NFLASH_CTL) & NCTL_START)) {
i = 0;
break;
}
+ ndelay(1);
}
if (i) {
pr_err("NFLASH control command not ready!\n");
@@ -62,7 +67,7 @@ static int bcm47xxnflash_ops_bcm4706_poll(struct bcma_drv_cc *cc)
{
int i;
- for (i = 0; i < NFLASH_READY_RETRIES; i++) {
+ for (i = 0; i < NFLASH_POLL_RETRIES; i++) {
if (bcma_cc_read32(cc, BCMA_CC_NFLASH_CTL) & NCTL_READY) {
if (bcma_cc_read32(cc, BCMA_CC_NFLASH_CTL) &
BCMA_CC_NFLASH_CTL_ERR) {
@@ -72,6 +77,7 @@ static int bcm47xxnflash_ops_bcm4706_poll(struct bcma_drv_cc *cc)
return 0;
}
}
+ ndelay(1);
}
pr_err("Polling timeout!\n");