aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGertjan van Wingerde <gwingerde@gmail.com>2010-04-11 08:31:10 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-04-12 15:22:11 -0400
commit8d0c9b65c904c6943566ccd2919c6a5ee6292c6b (patch)
tree39bec7664e3bc8bf9664cb987581a2ba4d869c3e
parente148b4c82a6269aa19476e4865afe8aa84360c8f (diff)
rt2x00: Refactor rt2800 version constants.
The rt2800 version constants are inconsistent, and the version number don't mean a lot of things anyway. Refactor the constants to have some more meaningful names, and introduce and use some new helpers to check these chipset revisions. At the same time rename to revision, as they are more revision numbers rather than version numbers. Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com> Acked-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/rt2x00/rt2800.h18
-rw-r--r--drivers/net/wireless/rt2x00/rt2800lib.c30
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h22
3 files changed, 41 insertions, 29 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h
index 4d5871b01cac..ec893721cc80 100644
--- a/drivers/net/wireless/rt2x00/rt2800.h
+++ b/drivers/net/wireless/rt2x00/rt2800.h
@@ -59,13 +59,17 @@
59#define RF3320 0x000b 59#define RF3320 0x000b
60 60
61/* 61/*
62 * Chipset version. 62 * Chipset revisions.
63 */ 63 */
64#define RT2860C_VERSION 0x0100 64#define REV_RT2860C 0x0100
65#define RT2860D_VERSION 0x0101 65#define REV_RT2860D 0x0101
66#define RT2880E_VERSION 0x0200 66#define REV_RT2870D 0x0101
67#define RT2883_VERSION 0x0300 67#define REV_RT2872E 0x0200
68#define RT3070_VERSION 0x0200 68#define REV_RT3070E 0x0200
69#define REV_RT3070F 0x0201
70#define REV_RT3071E 0x0211
71#define REV_RT3090E 0x0211
72#define REV_RT3390E 0x0211
69 73
70/* 74/*
71 * Signal information. 75 * Signal information.
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 2ab88840a3e5..8a4ed7642bcf 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -896,8 +896,7 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,
896 rt2x00_set_field8(&bbp, BBP3_HT40_PLUS, conf_is_ht40_plus(conf)); 896 rt2x00_set_field8(&bbp, BBP3_HT40_PLUS, conf_is_ht40_plus(conf));
897 rt2800_bbp_write(rt2x00dev, 3, bbp); 897 rt2800_bbp_write(rt2x00dev, 3, bbp);
898 898
899 if (rt2x00_rt(rt2x00dev, RT2860) && 899 if (rt2x00_rt_rev(rt2x00dev, RT2860, REV_RT2860C)) {
900 (rt2x00_rev(rt2x00dev) == RT2860C_VERSION)) {
901 if (conf_is_ht40(conf)) { 900 if (conf_is_ht40(conf)) {
902 rt2800_bbp_write(rt2x00dev, 69, 0x1a); 901 rt2800_bbp_write(rt2x00dev, 69, 0x1a);
903 rt2800_bbp_write(rt2x00dev, 70, 0x0a); 902 rt2800_bbp_write(rt2x00dev, 70, 0x0a);
@@ -1060,8 +1059,7 @@ static u8 rt2800_get_default_vgc(struct rt2x00_dev *rt2x00dev)
1060{ 1059{
1061 if (rt2x00dev->curr_band == IEEE80211_BAND_2GHZ) { 1060 if (rt2x00dev->curr_band == IEEE80211_BAND_2GHZ) {
1062 if (rt2x00_is_usb(rt2x00dev) && 1061 if (rt2x00_is_usb(rt2x00dev) &&
1063 rt2x00_rt(rt2x00dev, RT3070) && 1062 rt2x00_rt_rev(rt2x00dev, RT3070, REV_RT3070E))
1064 (rt2x00_rev(rt2x00dev) == RT3070_VERSION))
1065 return 0x1c + (2 * rt2x00dev->lna_gain); 1063 return 0x1c + (2 * rt2x00dev->lna_gain);
1066 else 1064 else
1067 return 0x2e + rt2x00dev->lna_gain; 1065 return 0x2e + rt2x00dev->lna_gain;
@@ -1092,8 +1090,7 @@ EXPORT_SYMBOL_GPL(rt2800_reset_tuner);
1092void rt2800_link_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual, 1090void rt2800_link_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual,
1093 const u32 count) 1091 const u32 count)
1094{ 1092{
1095 if (rt2x00_rt(rt2x00dev, RT2860) && 1093 if (rt2x00_rt_rev(rt2x00dev, RT2860, REV_RT2860C))
1096 (rt2x00_rev(rt2x00dev) == RT2860C_VERSION))
1097 return; 1094 return;
1098 1095
1099 /* 1096 /*
@@ -1179,8 +1176,7 @@ int rt2800_init_registers(struct rt2x00_dev *rt2x00dev)
1179 rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg); 1176 rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg);
1180 1177
1181 if (rt2x00_is_usb(rt2x00dev) && 1178 if (rt2x00_is_usb(rt2x00dev) &&
1182 rt2x00_rt(rt2x00dev, RT3070) && 1179 rt2x00_rt_rev(rt2x00dev, RT3070, REV_RT3070E)) {
1183 (rt2x00_rev(rt2x00dev) == RT3070_VERSION)) {
1184 rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000400); 1180 rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000400);
1185 rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x00000000); 1181 rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x00000000);
1186 rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x00000000); 1182 rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x00000000);
@@ -1207,11 +1203,9 @@ int rt2800_init_registers(struct rt2x00_dev *rt2x00dev)
1207 1203
1208 rt2800_register_read(rt2x00dev, MAX_LEN_CFG, &reg); 1204 rt2800_register_read(rt2x00dev, MAX_LEN_CFG, &reg);
1209 rt2x00_set_field32(&reg, MAX_LEN_CFG_MAX_MPDU, AGGREGATION_SIZE); 1205 rt2x00_set_field32(&reg, MAX_LEN_CFG_MAX_MPDU, AGGREGATION_SIZE);
1210 if ((rt2x00_rt(rt2x00dev, RT2872) && 1206 if (rt2x00_rt_rev_gte(rt2x00dev, RT2872, REV_RT2872E) ||
1211 (rt2x00_rev(rt2x00dev) >= RT2880E_VERSION)) ||
1212 rt2x00_rt(rt2x00dev, RT2883) || 1207 rt2x00_rt(rt2x00dev, RT2883) ||
1213 (rt2x00_rt(rt2x00dev, RT3070) && 1208 rt2x00_rt_rev_lt(rt2x00dev, RT3070, REV_RT3070E))
1214 (rt2x00_rev(rt2x00dev) < RT3070_VERSION)))
1215 rt2x00_set_field32(&reg, MAX_LEN_CFG_MAX_PSDU, 2); 1209 rt2x00_set_field32(&reg, MAX_LEN_CFG_MAX_PSDU, 2);
1216 else 1210 else
1217 rt2x00_set_field32(&reg, MAX_LEN_CFG_MAX_PSDU, 1); 1211 rt2x00_set_field32(&reg, MAX_LEN_CFG_MAX_PSDU, 1);
@@ -1490,14 +1484,12 @@ int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev)
1490 rt2800_bbp_write(rt2x00dev, 103, 0x00); 1484 rt2800_bbp_write(rt2x00dev, 103, 0x00);
1491 rt2800_bbp_write(rt2x00dev, 105, 0x05); 1485 rt2800_bbp_write(rt2x00dev, 105, 0x05);
1492 1486
1493 if (rt2x00_rt(rt2x00dev, RT2860) && 1487 if (rt2x00_rt_rev(rt2x00dev, RT2860, REV_RT2860C)) {
1494 (rt2x00_rev(rt2x00dev) == RT2860C_VERSION)) {
1495 rt2800_bbp_write(rt2x00dev, 69, 0x16); 1488 rt2800_bbp_write(rt2x00dev, 69, 0x16);
1496 rt2800_bbp_write(rt2x00dev, 73, 0x12); 1489 rt2800_bbp_write(rt2x00dev, 73, 0x12);
1497 } 1490 }
1498 1491
1499 if (rt2x00_rt(rt2x00dev, RT2860) && 1492 if (rt2x00_rt_rev_gte(rt2x00dev, RT2860, REV_RT2860D))
1500 (rt2x00_rev(rt2x00dev) > RT2860D_VERSION))
1501 rt2800_bbp_write(rt2x00dev, 84, 0x19); 1493 rt2800_bbp_write(rt2x00dev, 84, 0x19);
1502 1494
1503 if (rt2x00_rt(rt2x00dev, RT2872)) { 1495 if (rt2x00_rt(rt2x00dev, RT2872)) {
@@ -1507,8 +1499,7 @@ int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev)
1507 } 1499 }
1508 1500
1509 if (rt2x00_is_usb(rt2x00dev) && 1501 if (rt2x00_is_usb(rt2x00dev) &&
1510 rt2x00_rt(rt2x00dev, RT3070) && 1502 rt2x00_rt_rev(rt2x00dev, RT3070, REV_RT3070E)) {
1511 (rt2x00_rev(rt2x00dev) == RT3070_VERSION)) {
1512 rt2800_bbp_write(rt2x00dev, 70, 0x0a); 1503 rt2800_bbp_write(rt2x00dev, 70, 0x0a);
1513 rt2800_bbp_write(rt2x00dev, 84, 0x99); 1504 rt2800_bbp_write(rt2x00dev, 84, 0x99);
1514 rt2800_bbp_write(rt2x00dev, 105, 0x05); 1505 rt2800_bbp_write(rt2x00dev, 105, 0x05);
@@ -1594,8 +1585,7 @@ int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
1594 u8 bbp; 1585 u8 bbp;
1595 1586
1596 if (rt2x00_is_usb(rt2x00dev) && 1587 if (rt2x00_is_usb(rt2x00dev) &&
1597 rt2x00_rt(rt2x00dev, RT3070) && 1588 !rt2x00_rt_rev(rt2x00dev, RT3070, REV_RT3070E))
1598 (rt2x00_rev(rt2x00dev) != RT3070_VERSION))
1599 return 0; 1589 return 0;
1600 1590
1601 if (rt2x00_is_pci(rt2x00dev) || rt2x00_is_soc(rt2x00dev)) { 1591 if (rt2x00_is_pci(rt2x00dev) || rt2x00_is_soc(rt2x00dev)) {
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index 16aa850d3700..4de505b98331 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -929,12 +929,12 @@ static inline void rt2x00_set_chip(struct rt2x00_dev *rt2x00dev,
929 rt2x00dev->chip.rt, rt2x00dev->chip.rf, rt2x00dev->chip.rev); 929 rt2x00dev->chip.rt, rt2x00dev->chip.rf, rt2x00dev->chip.rev);
930} 930}
931 931
932static inline char rt2x00_rt(struct rt2x00_dev *rt2x00dev, const u16 rt) 932static inline bool rt2x00_rt(struct rt2x00_dev *rt2x00dev, const u16 rt)
933{ 933{
934 return (rt2x00dev->chip.rt == rt); 934 return (rt2x00dev->chip.rt == rt);
935} 935}
936 936
937static inline char rt2x00_rf(struct rt2x00_dev *rt2x00dev, const u16 rf) 937static inline bool rt2x00_rf(struct rt2x00_dev *rt2x00dev, const u16 rf)
938{ 938{
939 return (rt2x00dev->chip.rf == rf); 939 return (rt2x00dev->chip.rf == rf);
940} 940}
@@ -944,6 +944,24 @@ static inline u16 rt2x00_rev(struct rt2x00_dev *rt2x00dev)
944 return rt2x00dev->chip.rev; 944 return rt2x00dev->chip.rev;
945} 945}
946 946
947static inline bool rt2x00_rt_rev(struct rt2x00_dev *rt2x00dev,
948 const u16 rt, const u16 rev)
949{
950 return (rt2x00_rt(rt2x00dev, rt) && rt2x00_rev(rt2x00dev) == rev);
951}
952
953static inline bool rt2x00_rt_rev_lt(struct rt2x00_dev *rt2x00dev,
954 const u16 rt, const u16 rev)
955{
956 return (rt2x00_rt(rt2x00dev, rt) && rt2x00_rev(rt2x00dev) < rev);
957}
958
959static inline bool rt2x00_rt_rev_gte(struct rt2x00_dev *rt2x00dev,
960 const u16 rt, const u16 rev)
961{
962 return (rt2x00_rt(rt2x00dev, rt) && rt2x00_rev(rt2x00dev) >= rev);
963}
964
947static inline void rt2x00_set_chip_intf(struct rt2x00_dev *rt2x00dev, 965static inline void rt2x00_set_chip_intf(struct rt2x00_dev *rt2x00dev,
948 enum rt2x00_chip_intf intf) 966 enum rt2x00_chip_intf intf)
949{ 967{