aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-hw.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-csr.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.c23
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.h7
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c31
5 files changed, 27 insertions, 37 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-hw.h b/drivers/net/wireless/iwlwifi/iwl-3945-hw.h
index 15570e68303a..94ea0e60c410 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-hw.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-hw.h
@@ -103,7 +103,6 @@
103 * Driver reads 16-bit value from bits 31-16 of CSR_EEPROM_REG. 103 * Driver reads 16-bit value from bits 31-16 of CSR_EEPROM_REG.
104 */ 104 */
105#define IWL_EEPROM_ACCESS_TIMEOUT 5000 /* uSec */ 105#define IWL_EEPROM_ACCESS_TIMEOUT 5000 /* uSec */
106#define IWL_EEPROM_ACCESS_DELAY 10 /* uSec */
107 106
108/* 107/*
109 * Regulatory channel usage flags in EEPROM struct iwl_eeprom_channel.flags. 108 * Regulatory channel usage flags in EEPROM struct iwl_eeprom_channel.flags.
diff --git a/drivers/net/wireless/iwlwifi/iwl-csr.h b/drivers/net/wireless/iwlwifi/iwl-csr.h
index b834e21ee451..f34ede44ed10 100644
--- a/drivers/net/wireless/iwlwifi/iwl-csr.h
+++ b/drivers/net/wireless/iwlwifi/iwl-csr.h
@@ -216,6 +216,8 @@
216/* EEPROM REG */ 216/* EEPROM REG */
217#define CSR_EEPROM_REG_READ_VALID_MSK (0x00000001) 217#define CSR_EEPROM_REG_READ_VALID_MSK (0x00000001)
218#define CSR_EEPROM_REG_BIT_CMD (0x00000002) 218#define CSR_EEPROM_REG_BIT_CMD (0x00000002)
219#define CSR_EEPROM_REG_MSK_ADDR (0x0000FFFC)
220#define CSR_EEPROM_REG_MSK_DATA (0xFFFF0000)
219 221
220/* EEPROM GP */ 222/* EEPROM GP */
221#define CSR_EEPROM_GP_VALID_MSK (0x00000006) 223#define CSR_EEPROM_GP_VALID_MSK (0x00000006)
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
index a47fa38e52f0..ce2f47306cea 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
@@ -209,10 +209,8 @@ int iwl_eeprom_init(struct iwl_priv *priv)
209{ 209{
210 u16 *e; 210 u16 *e;
211 u32 gp = iwl_read32(priv, CSR_EEPROM_GP); 211 u32 gp = iwl_read32(priv, CSR_EEPROM_GP);
212 u32 r;
213 int sz = priv->cfg->eeprom_size; 212 int sz = priv->cfg->eeprom_size;
214 int ret; 213 int ret;
215 int i;
216 u16 addr; 214 u16 addr;
217 215
218 /* allocate eeprom */ 216 /* allocate eeprom */
@@ -240,22 +238,19 @@ int iwl_eeprom_init(struct iwl_priv *priv)
240 238
241 /* eeprom is an array of 16bit values */ 239 /* eeprom is an array of 16bit values */
242 for (addr = 0; addr < sz; addr += sizeof(u16)) { 240 for (addr = 0; addr < sz; addr += sizeof(u16)) {
243 _iwl_write32(priv, CSR_EEPROM_REG, addr << 1); 241 u32 r;
244 _iwl_clear_bit(priv, CSR_EEPROM_REG, CSR_EEPROM_REG_BIT_CMD); 242
245 243 _iwl_write32(priv, CSR_EEPROM_REG,
246 for (i = 0; i < IWL_EEPROM_ACCESS_TIMEOUT; 244 CSR_EEPROM_REG_MSK_ADDR & (addr << 1));
247 i += IWL_EEPROM_ACCESS_DELAY) {
248 r = _iwl_read_direct32(priv, CSR_EEPROM_REG);
249 if (r & CSR_EEPROM_REG_READ_VALID_MSK)
250 break;
251 udelay(IWL_EEPROM_ACCESS_DELAY);
252 }
253 245
254 if (!(r & CSR_EEPROM_REG_READ_VALID_MSK)) { 246 ret = iwl_poll_direct_bit(priv, CSR_EEPROM_REG,
247 CSR_EEPROM_REG_READ_VALID_MSK,
248 IWL_EEPROM_ACCESS_TIMEOUT);
249 if (ret < 0) {
255 IWL_ERROR("Time out reading EEPROM[%d]\n", addr); 250 IWL_ERROR("Time out reading EEPROM[%d]\n", addr);
256 ret = -ETIMEDOUT;
257 goto done; 251 goto done;
258 } 252 }
253 r = _iwl_read_direct32(priv, CSR_EEPROM_REG);
259 e[addr / 2] = le16_to_cpu((__force __le16)(r >> 16)); 254 e[addr / 2] = le16_to_cpu((__force __le16)(r >> 16));
260 } 255 }
261 ret = 0; 256 ret = 0;
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
index 4b9de7a8537b..603c84bed630 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.h
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
@@ -68,17 +68,14 @@ struct iwl_priv;
68/* 68/*
69 * EEPROM access time values: 69 * EEPROM access time values:
70 * 70 *
71 * Driver initiates EEPROM read by writing byte address << 1 to CSR_EEPROM_REG, 71 * Driver initiates EEPROM read by writing byte address << 1 to CSR_EEPROM_REG.
72 * then clearing (with subsequent read/modify/write) CSR_EEPROM_REG bit
73 * CSR_EEPROM_REG_BIT_CMD (0x2).
74 * Driver then polls CSR_EEPROM_REG for CSR_EEPROM_REG_READ_VALID_MSK (0x1). 72 * Driver then polls CSR_EEPROM_REG for CSR_EEPROM_REG_READ_VALID_MSK (0x1).
75 * When polling, wait 10 uSec between polling loops, up to a maximum 5000 uSec. 73 * When polling, wait 10 uSec between polling loops, up to a maximum 5000 uSec.
76 * Driver reads 16-bit value from bits 31-16 of CSR_EEPROM_REG. 74 * Driver reads 16-bit value from bits 31-16 of CSR_EEPROM_REG.
77 */ 75 */
78#define IWL_EEPROM_ACCESS_TIMEOUT 5000 /* uSec */ 76#define IWL_EEPROM_ACCESS_TIMEOUT 5000 /* uSec */
79#define IWL_EEPROM_ACCESS_DELAY 10 /* uSec */
80 77
81#define IWL_EEPROM_SEM_TIMEOUT 10 /* milliseconds */ 78#define IWL_EEPROM_SEM_TIMEOUT 10 /* microseconds */
82#define IWL_EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */ 79#define IWL_EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */
83 80
84 81
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index f88300683879..9f0db4f577ea 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -1504,10 +1504,8 @@ int iwl3945_eeprom_init(struct iwl3945_priv *priv)
1504{ 1504{
1505 u16 *e = (u16 *)&priv->eeprom; 1505 u16 *e = (u16 *)&priv->eeprom;
1506 u32 gp = iwl3945_read32(priv, CSR_EEPROM_GP); 1506 u32 gp = iwl3945_read32(priv, CSR_EEPROM_GP);
1507 u32 r;
1508 int sz = sizeof(priv->eeprom); 1507 int sz = sizeof(priv->eeprom);
1509 int rc; 1508 int ret;
1510 int i;
1511 u16 addr; 1509 u16 addr;
1512 1510
1513 /* The EEPROM structure has several padding buffers within it 1511 /* The EEPROM structure has several padding buffers within it
@@ -1522,29 +1520,28 @@ int iwl3945_eeprom_init(struct iwl3945_priv *priv)
1522 } 1520 }
1523 1521
1524 /* Make sure driver (instead of uCode) is allowed to read EEPROM */ 1522 /* Make sure driver (instead of uCode) is allowed to read EEPROM */
1525 rc = iwl3945_eeprom_acquire_semaphore(priv); 1523 ret = iwl3945_eeprom_acquire_semaphore(priv);
1526 if (rc < 0) { 1524 if (ret < 0) {
1527 IWL_ERROR("Failed to acquire EEPROM semaphore.\n"); 1525 IWL_ERROR("Failed to acquire EEPROM semaphore.\n");
1528 return -ENOENT; 1526 return -ENOENT;
1529 } 1527 }
1530 1528
1531 /* eeprom is an array of 16bit values */ 1529 /* eeprom is an array of 16bit values */
1532 for (addr = 0; addr < sz; addr += sizeof(u16)) { 1530 for (addr = 0; addr < sz; addr += sizeof(u16)) {
1533 _iwl3945_write32(priv, CSR_EEPROM_REG, addr << 1); 1531 u32 r;
1534 _iwl3945_clear_bit(priv, CSR_EEPROM_REG, CSR_EEPROM_REG_BIT_CMD);
1535 1532
1536 for (i = 0; i < IWL_EEPROM_ACCESS_TIMEOUT; 1533 _iwl3945_write32(priv, CSR_EEPROM_REG,
1537 i += IWL_EEPROM_ACCESS_DELAY) { 1534 CSR_EEPROM_REG_MSK_ADDR & (addr << 1));
1538 r = _iwl3945_read_direct32(priv, CSR_EEPROM_REG); 1535 _iwl3945_clear_bit(priv, CSR_EEPROM_REG, CSR_EEPROM_REG_BIT_CMD);
1539 if (r & CSR_EEPROM_REG_READ_VALID_MSK) 1536 ret = iwl3945_poll_direct_bit(priv, CSR_EEPROM_REG,
1540 break; 1537 CSR_EEPROM_REG_READ_VALID_MSK,
1541 udelay(IWL_EEPROM_ACCESS_DELAY); 1538 IWL_EEPROM_ACCESS_TIMEOUT);
1542 } 1539 if (ret < 0) {
1543
1544 if (!(r & CSR_EEPROM_REG_READ_VALID_MSK)) {
1545 IWL_ERROR("Time out reading EEPROM[%d]\n", addr); 1540 IWL_ERROR("Time out reading EEPROM[%d]\n", addr);
1546 return -ETIMEDOUT; 1541 return ret;
1547 } 1542 }
1543
1544 r = _iwl3945_read_direct32(priv, CSR_EEPROM_REG);
1548 e[addr / 2] = le16_to_cpu((__force __le16)(r >> 16)); 1545 e[addr / 2] = le16_to_cpu((__force __le16)(r >> 16));
1549 } 1546 }
1550 1547