diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-11-08 08:39:48 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-11-11 17:09:16 -0500 |
commit | 30e840346c516ad4e36f710fa485933ccc7afa66 (patch) | |
tree | a8489add516573512e64ebd534c07963e5ba3c05 /drivers/net/wireless | |
parent | 4116cb483ec148e30f70408ad0600304a5de2a3c (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.h | 29 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800lib.c | 43 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800lib.h | 2 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800pci.c | 38 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800pci.h | 29 |
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 | } |
1660 | EXPORT_SYMBOL_GPL(rt2800_init_rfcsr); | 1660 | EXPORT_SYMBOL_GPL(rt2800_init_rfcsr); |
1661 | 1661 | ||
1662 | int rt2800_efuse_detect(struct rt2x00_dev *rt2x00dev) | ||
1663 | { | ||
1664 | u32 reg; | ||
1665 | |||
1666 | rt2800_register_read(rt2x00dev, EFUSE_CTRL, ®); | ||
1667 | |||
1668 | return rt2x00_get_field32(reg, EFUSE_CTRL_PRESENT); | ||
1669 | } | ||
1670 | EXPORT_SYMBOL_GPL(rt2800_efuse_detect); | ||
1671 | |||
1672 | static void rt2800_efuse_read(struct rt2x00_dev *rt2x00dev, unsigned int i) | ||
1673 | { | ||
1674 | u32 reg; | ||
1675 | |||
1676 | rt2800_register_read(rt2x00dev, EFUSE_CTRL, ®); | ||
1677 | rt2x00_set_field32(®, EFUSE_CTRL_ADDRESS_IN, i); | ||
1678 | rt2x00_set_field32(®, EFUSE_CTRL_MODE, 0); | ||
1679 | rt2x00_set_field32(®, 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, ®); | ||
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 | |||
1696 | void 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 | } | ||
1703 | EXPORT_SYMBOL_GPL(rt2800_read_eeprom_efuse); | ||
1704 | |||
1662 | int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev) | 1705 | int 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); | |||
129 | int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev); | 129 | int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev); |
130 | int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev); | 130 | int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev); |
131 | 131 | ||
132 | int rt2800_efuse_detect(struct rt2x00_dev *rt2x00dev); | ||
133 | void rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev); | ||
132 | int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev); | 134 | int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev); |
133 | int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev); | 135 | int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev); |
134 | int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev); | 136 | int 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 | ||
148 | static int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev) | 148 | static 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, ®); | ||
153 | |||
154 | return rt2x00_get_field32(reg, EFUSE_CTRL_PRESENT); | ||
155 | } | 151 | } |
156 | 152 | ||
157 | static void rt2800pci_efuse_read(struct rt2x00_dev *rt2x00dev, | 153 | static 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, ®); | ||
163 | rt2x00_set_field32(®, EFUSE_CTRL_ADDRESS_IN, i); | ||
164 | rt2x00_set_field32(®, EFUSE_CTRL_MODE, 0); | ||
165 | rt2x00_set_field32(®, 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, ®); | ||
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 | |||
182 | static 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 |
190 | static inline void rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev) | 158 | static 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" |