This source file includes following definitions.
- write_max2820
- max2820_write_phy_antenna
- max2820_rf_calc_rssi
- max2820_rf_set_channel
- max2820_rf_stop
- max2820_rf_init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 #include <linux/pci.h>
19 #include <linux/delay.h>
20 #include <net/mac80211.h>
21
22 #include "rtl8180.h"
23 #include "max2820.h"
24
25 static const u32 max2820_chan[] = {
26 12,
27 17,
28 22,
29 27,
30 32,
31 37,
32 42,
33 47,
34 52,
35 57,
36 62,
37 67,
38 72,
39 84,
40 };
41
42 static void write_max2820(struct ieee80211_hw *dev, u8 addr, u32 data)
43 {
44 struct rtl8180_priv *priv = dev->priv;
45 u32 phy_config;
46
47 phy_config = 0x90 + (data & 0xf);
48 phy_config <<= 16;
49 phy_config += addr;
50 phy_config <<= 8;
51 phy_config += (data >> 4) & 0xff;
52
53 rtl818x_iowrite32(priv,
54 (__le32 __iomem *) &priv->map->RFPinsOutput, phy_config);
55
56 msleep(1);
57 }
58
59 static void max2820_write_phy_antenna(struct ieee80211_hw *dev, short chan)
60 {
61 struct rtl8180_priv *priv = dev->priv;
62 u8 ant;
63
64 ant = MAXIM_ANTENNA;
65 if (priv->rfparam & RF_PARAM_ANTBDEFAULT)
66 ant |= BB_ANTENNA_B;
67 if (chan == 14)
68 ant |= BB_ANTATTEN_CHAN14;
69
70 rtl8180_write_phy(dev, 0x10, ant);
71 }
72
73 static u8 max2820_rf_calc_rssi(u8 agc, u8 sq)
74 {
75 bool odd;
76
77 odd = !!(agc & 1);
78
79 agc >>= 1;
80 if (odd)
81 agc += 76;
82 else
83 agc += 66;
84
85
86 return 65 * agc / 100;
87 }
88
89 static void max2820_rf_set_channel(struct ieee80211_hw *dev,
90 struct ieee80211_conf *conf)
91 {
92 struct rtl8180_priv *priv = dev->priv;
93 int channel = conf ?
94 ieee80211_frequency_to_channel(conf->chandef.chan->center_freq) : 1;
95 unsigned int chan_idx = channel - 1;
96 u32 txpw = priv->channels[chan_idx].hw_value & 0xFF;
97 u32 chan = max2820_chan[chan_idx];
98
99
100
101 rtl8180_write_phy(dev, 3, txpw);
102
103 max2820_write_phy_antenna(dev, channel);
104 write_max2820(dev, 3, chan);
105 }
106
107 static void max2820_rf_stop(struct ieee80211_hw *dev)
108 {
109 rtl8180_write_phy(dev, 3, 0x8);
110 write_max2820(dev, 1, 0);
111 }
112
113
114 static void max2820_rf_init(struct ieee80211_hw *dev)
115 {
116 struct rtl8180_priv *priv = dev->priv;
117
118
119 write_max2820(dev, 0, 0x007);
120 write_max2820(dev, 1, 0x01e);
121 write_max2820(dev, 2, 0x001);
122
123 max2820_rf_set_channel(dev, NULL);
124
125 write_max2820(dev, 4, 0x313);
126
127
128
129
130
131 write_max2820(dev, 5, 0x00f);
132
133
134 rtl8180_write_phy(dev, 0, 0x88);
135 rtl8180_write_phy(dev, 3, 0x08);
136 rtl8180_write_phy(dev, 4, 0xf8);
137 rtl8180_write_phy(dev, 5, 0x90);
138 rtl8180_write_phy(dev, 6, 0x1a);
139 rtl8180_write_phy(dev, 7, 0x64);
140
141 max2820_write_phy_antenna(dev, 1);
142
143 rtl8180_write_phy(dev, 0x11, 0x88);
144
145 if (rtl818x_ioread8(priv, &priv->map->CONFIG2) &
146 RTL818X_CONFIG2_ANTENNA_DIV)
147 rtl8180_write_phy(dev, 0x12, 0xc7);
148 else
149 rtl8180_write_phy(dev, 0x12, 0x47);
150
151 rtl8180_write_phy(dev, 0x13, 0x9b);
152
153 rtl8180_write_phy(dev, 0x19, 0x0);
154 rtl8180_write_phy(dev, 0x1a, 0x9f);
155
156 max2820_rf_set_channel(dev, NULL);
157 }
158
159 const struct rtl818x_rf_ops max2820_rf_ops = {
160 .name = "Maxim",
161 .init = max2820_rf_init,
162 .stop = max2820_rf_stop,
163 .set_chan = max2820_rf_set_channel,
164 .calc_rssi = max2820_rf_calc_rssi,
165 };