aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-11-08 08:39:48 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-11-11 17:09:16 -0500
commit30e840346c516ad4e36f710fa485933ccc7afa66 (patch)
treea8489add516573512e64ebd534c07963e5ba3c05 /drivers/net/wireless
parent4116cb483ec148e30f70408ad0600304a5de2a3c (diff)
rt2800: add eFuse EEPROM support code to rt2800lib
eFuse EEPROM is used also by USB chips (i.e. RT3070) so move the needed code from rt2800pci to rt2800lib. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> Acked-by: Gertjan van Wingerde <gwingerde@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r--drivers/net/wireless/rt2x00/rt2800.h29
-rw-r--r--drivers/net/wireless/rt2x00/rt2800lib.c43
-rw-r--r--drivers/net/wireless/rt2x00/rt2800lib.h2
-rw-r--r--drivers/net/wireless/rt2x00/rt2800pci.c38
-rw-r--r--drivers/net/wireless/rt2x00/rt2800pci.h29
5 files changed, 77 insertions, 64 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h
index d9b6a72e6d27..74fb5253ee23 100644
--- a/drivers/net/wireless/rt2x00/rt2800.h
+++ b/drivers/net/wireless/rt2x00/rt2800.h
@@ -362,6 +362,35 @@
362#define RF_CSR_CFG_BUSY FIELD32(0x00020000) 362#define RF_CSR_CFG_BUSY FIELD32(0x00020000)
363 363
364/* 364/*
365 * EFUSE_CSR: RT30x0 EEPROM
366 */
367#define EFUSE_CTRL 0x0580
368#define EFUSE_CTRL_ADDRESS_IN FIELD32(0x03fe0000)
369#define EFUSE_CTRL_MODE FIELD32(0x000000c0)
370#define EFUSE_CTRL_KICK FIELD32(0x40000000)
371#define EFUSE_CTRL_PRESENT FIELD32(0x80000000)
372
373/*
374 * EFUSE_DATA0
375 */
376#define EFUSE_DATA0 0x0590
377
378/*
379 * EFUSE_DATA1
380 */
381#define EFUSE_DATA1 0x0594
382
383/*
384 * EFUSE_DATA2
385 */
386#define EFUSE_DATA2 0x0598
387
388/*
389 * EFUSE_DATA3
390 */
391#define EFUSE_DATA3 0x059c
392
393/*
365 * MAC Control/Status Registers(CSR). 394 * MAC Control/Status Registers(CSR).
366 * Some values are set in TU, whereas 1 TU == 1024 us. 395 * Some values are set in TU, whereas 1 TU == 1024 us.
367 */ 396 */
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index d7771eaee049..f207e9fa5b98 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -1659,6 +1659,49 @@ int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
1659} 1659}
1660EXPORT_SYMBOL_GPL(rt2800_init_rfcsr); 1660EXPORT_SYMBOL_GPL(rt2800_init_rfcsr);
1661 1661
1662int rt2800_efuse_detect(struct rt2x00_dev *rt2x00dev)
1663{
1664 u32 reg;
1665
1666 rt2800_register_read(rt2x00dev, EFUSE_CTRL, &reg);
1667
1668 return rt2x00_get_field32(reg, EFUSE_CTRL_PRESENT);
1669}
1670EXPORT_SYMBOL_GPL(rt2800_efuse_detect);
1671
1672static void rt2800_efuse_read(struct rt2x00_dev *rt2x00dev, unsigned int i)
1673{
1674 u32 reg;
1675
1676 rt2800_register_read(rt2x00dev, EFUSE_CTRL, &reg);
1677 rt2x00_set_field32(&reg, EFUSE_CTRL_ADDRESS_IN, i);
1678 rt2x00_set_field32(&reg, EFUSE_CTRL_MODE, 0);
1679 rt2x00_set_field32(&reg, EFUSE_CTRL_KICK, 1);
1680 rt2800_register_write(rt2x00dev, EFUSE_CTRL, reg);
1681
1682 /* Wait until the EEPROM has been loaded */
1683 rt2800_regbusy_read(rt2x00dev, EFUSE_CTRL, EFUSE_CTRL_KICK, &reg);
1684
1685 /* Apparently the data is read from end to start */
1686 rt2800_register_read(rt2x00dev, EFUSE_DATA3,
1687 (u32 *)&rt2x00dev->eeprom[i]);
1688 rt2800_register_read(rt2x00dev, EFUSE_DATA2,
1689 (u32 *)&rt2x00dev->eeprom[i + 2]);
1690 rt2800_register_read(rt2x00dev, EFUSE_DATA1,
1691 (u32 *)&rt2x00dev->eeprom[i + 4]);
1692 rt2800_register_read(rt2x00dev, EFUSE_DATA0,
1693 (u32 *)&rt2x00dev->eeprom[i + 6]);
1694}
1695
1696void rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
1697{
1698 unsigned int i;
1699
1700 for (i = 0; i < EEPROM_SIZE / sizeof(u16); i += 8)
1701 rt2800_efuse_read(rt2x00dev, i);
1702}
1703EXPORT_SYMBOL_GPL(rt2800_read_eeprom_efuse);
1704
1662int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev) 1705int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
1663{ 1706{
1664 u16 word; 1707 u16 word;
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.h b/drivers/net/wireless/rt2x00/rt2800lib.h
index 2aa15f2b2c5d..7c790118999b 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.h
+++ b/drivers/net/wireless/rt2x00/rt2800lib.h
@@ -129,6 +129,8 @@ int rt2800_init_registers(struct rt2x00_dev *rt2x00dev);
129int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev); 129int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev);
130int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev); 130int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev);
131 131
132int rt2800_efuse_detect(struct rt2x00_dev *rt2x00dev);
133void rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev);
132int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev); 134int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev);
133int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev); 135int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev);
134int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev); 136int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev);
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c
index e8fe2eabebbd..6f151d0c6b02 100644
--- a/drivers/net/wireless/rt2x00/rt2800pci.c
+++ b/drivers/net/wireless/rt2x00/rt2800pci.c
@@ -147,44 +147,12 @@ static void rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev)
147 147
148static int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev) 148static int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev)
149{ 149{
150 u32 reg; 150 return rt2800_efuse_detect(rt2x00dev);
151
152 rt2800_register_read(rt2x00dev, EFUSE_CTRL, &reg);
153
154 return rt2x00_get_field32(reg, EFUSE_CTRL_PRESENT);
155} 151}
156 152
157static void rt2800pci_efuse_read(struct rt2x00_dev *rt2x00dev, 153static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
158 unsigned int i)
159{
160 u32 reg;
161
162 rt2800_register_read(rt2x00dev, EFUSE_CTRL, &reg);
163 rt2x00_set_field32(&reg, EFUSE_CTRL_ADDRESS_IN, i);
164 rt2x00_set_field32(&reg, EFUSE_CTRL_MODE, 0);
165 rt2x00_set_field32(&reg, EFUSE_CTRL_KICK, 1);
166 rt2800_register_write(rt2x00dev, EFUSE_CTRL, reg);
167
168 /* Wait until the EEPROM has been loaded */
169 rt2800_regbusy_read(rt2x00dev, EFUSE_CTRL, EFUSE_CTRL_KICK, &reg);
170
171 /* Apparently the data is read from end to start */
172 rt2800_register_read(rt2x00dev, EFUSE_DATA3,
173 (u32 *)&rt2x00dev->eeprom[i]);
174 rt2800_register_read(rt2x00dev, EFUSE_DATA2,
175 (u32 *)&rt2x00dev->eeprom[i + 2]);
176 rt2800_register_read(rt2x00dev, EFUSE_DATA1,
177 (u32 *)&rt2x00dev->eeprom[i + 4]);
178 rt2800_register_read(rt2x00dev, EFUSE_DATA0,
179 (u32 *)&rt2x00dev->eeprom[i + 6]);
180}
181
182static void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
183{ 154{
184 unsigned int i; 155 rt2800_read_eeprom_efuse(rt2x00dev);
185
186 for (i = 0; i < EEPROM_SIZE / sizeof(u16); i += 8)
187 rt2800pci_efuse_read(rt2x00dev, i);
188} 156}
189#else 157#else
190static inline void rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev) 158static inline void rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev)
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.h b/drivers/net/wireless/rt2x00/rt2800pci.h
index 8f944ee8a970..b866dd01f286 100644
--- a/drivers/net/wireless/rt2x00/rt2800pci.h
+++ b/drivers/net/wireless/rt2x00/rt2800pci.h
@@ -56,35 +56,6 @@
56#define TX_DTX_IDX(__x) TX_DTX_IDX0 + ((__x) * TX_QUEUE_REG_OFFSET) 56#define TX_DTX_IDX(__x) TX_DTX_IDX0 + ((__x) * TX_QUEUE_REG_OFFSET)
57 57
58/* 58/*
59 * EFUSE_CSR: RT3090 EEPROM
60 */
61#define EFUSE_CTRL 0x0580
62#define EFUSE_CTRL_ADDRESS_IN FIELD32(0x03fe0000)
63#define EFUSE_CTRL_MODE FIELD32(0x000000c0)
64#define EFUSE_CTRL_KICK FIELD32(0x40000000)
65#define EFUSE_CTRL_PRESENT FIELD32(0x80000000)
66
67/*
68 * EFUSE_DATA0
69 */
70#define EFUSE_DATA0 0x0590
71
72/*
73 * EFUSE_DATA1
74 */
75#define EFUSE_DATA1 0x0594
76
77/*
78 * EFUSE_DATA2
79 */
80#define EFUSE_DATA2 0x0598
81
82/*
83 * EFUSE_DATA3
84 */
85#define EFUSE_DATA3 0x059c
86
87/*
88 * 8051 firmware image. 59 * 8051 firmware image.
89 */ 60 */
90#define FIRMWARE_RT2860 "rt2860.bin" 61#define FIRMWARE_RT2860 "rt2860.bin"