0001
0002
0003
0004
0005
0006
0007
0008 #include "baseband.h"
0009 #include "channel.h"
0010 #include "device.h"
0011 #include "rf.h"
0012
0013 static struct ieee80211_rate vnt_rates_bg[] = {
0014 { .bitrate = 10, .hw_value = RATE_1M },
0015 { .bitrate = 20, .hw_value = RATE_2M },
0016 { .bitrate = 55, .hw_value = RATE_5M },
0017 { .bitrate = 110, .hw_value = RATE_11M },
0018 { .bitrate = 60, .hw_value = RATE_6M },
0019 { .bitrate = 90, .hw_value = RATE_9M },
0020 { .bitrate = 120, .hw_value = RATE_12M },
0021 { .bitrate = 180, .hw_value = RATE_18M },
0022 { .bitrate = 240, .hw_value = RATE_24M },
0023 { .bitrate = 360, .hw_value = RATE_36M },
0024 { .bitrate = 480, .hw_value = RATE_48M },
0025 { .bitrate = 540, .hw_value = RATE_54M },
0026 };
0027
0028 static struct ieee80211_channel vnt_channels_2ghz[] = {
0029 { .center_freq = 2412, .hw_value = 1 },
0030 { .center_freq = 2417, .hw_value = 2 },
0031 { .center_freq = 2422, .hw_value = 3 },
0032 { .center_freq = 2427, .hw_value = 4 },
0033 { .center_freq = 2432, .hw_value = 5 },
0034 { .center_freq = 2437, .hw_value = 6 },
0035 { .center_freq = 2442, .hw_value = 7 },
0036 { .center_freq = 2447, .hw_value = 8 },
0037 { .center_freq = 2452, .hw_value = 9 },
0038 { .center_freq = 2457, .hw_value = 10 },
0039 { .center_freq = 2462, .hw_value = 11 },
0040 { .center_freq = 2467, .hw_value = 12 },
0041 { .center_freq = 2472, .hw_value = 13 },
0042 { .center_freq = 2484, .hw_value = 14 }
0043 };
0044
0045 static struct ieee80211_supported_band vnt_supported_2ghz_band = {
0046 .channels = vnt_channels_2ghz,
0047 .n_channels = ARRAY_SIZE(vnt_channels_2ghz),
0048 .bitrates = vnt_rates_bg,
0049 .n_bitrates = ARRAY_SIZE(vnt_rates_bg),
0050 };
0051
0052 static void vnt_init_band(struct vnt_private *priv,
0053 struct ieee80211_supported_band *supported_band,
0054 enum nl80211_band band)
0055 {
0056 int i;
0057
0058 for (i = 0; i < supported_band->n_channels; i++) {
0059 supported_band->channels[i].max_power = 0x3f;
0060 supported_band->channels[i].flags =
0061 IEEE80211_CHAN_NO_HT40;
0062 }
0063
0064 priv->hw->wiphy->bands[band] = supported_band;
0065 }
0066
0067 void vnt_init_bands(struct vnt_private *priv)
0068 {
0069 vnt_init_band(priv, &vnt_supported_2ghz_band, NL80211_BAND_2GHZ);
0070 }
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081 bool set_channel(struct vnt_private *priv, struct ieee80211_channel *ch)
0082 {
0083 bool ret = true;
0084
0085 if (priv->byCurrentCh == ch->hw_value)
0086 return ret;
0087
0088
0089 if (priv->bUpdateBBVGA &&
0090 priv->byBBVGACurrent != priv->abyBBVGA[0]) {
0091 priv->byBBVGACurrent = priv->abyBBVGA[0];
0092
0093 bb_set_vga_gain_offset(priv, priv->byBBVGACurrent);
0094 }
0095
0096
0097 vt6655_mac_reg_bits_on(priv->port_offset, MAC_REG_MACCR, MACCR_CLRNAV);
0098
0099
0100
0101
0102
0103 priv->byCurrentCh = ch->hw_value;
0104 ret &= RFbSelectChannel(priv, priv->byRFType,
0105 ch->hw_value);
0106
0107
0108 if (priv->bEnablePSMode)
0109 rf_write_wake_prog_syn(priv, priv->byRFType, ch->hw_value);
0110
0111 bb_software_reset(priv);
0112
0113 if (priv->local_id > REV_ID_VT3253_B1) {
0114 unsigned long flags;
0115
0116 spin_lock_irqsave(&priv->lock, flags);
0117
0118
0119 MACvSelectPage1(priv->port_offset);
0120 RFbSetPower(priv, RATE_1M, priv->byCurrentCh);
0121 iowrite8(priv->byCurPwr, priv->port_offset + MAC_REG_PWRCCK);
0122 RFbSetPower(priv, RATE_6M, priv->byCurrentCh);
0123 iowrite8(priv->byCurPwr, priv->port_offset + MAC_REG_PWROFDM);
0124 MACvSelectPage0(priv->port_offset);
0125
0126 spin_unlock_irqrestore(&priv->lock, flags);
0127 }
0128
0129 if (priv->byBBType == BB_TYPE_11B)
0130 RFbSetPower(priv, RATE_1M, priv->byCurrentCh);
0131 else
0132 RFbSetPower(priv, RATE_6M, priv->byCurrentCh);
0133
0134 return ret;
0135 }