aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2800lib.c
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/rt2x00/rt2800lib.c
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/rt2x00/rt2800lib.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2800lib.c43
1 files changed, 43 insertions, 0 deletions
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;