phy.c (e981b060767b3c4ac9393ad8d2558d648e35dfcb) phy.c (a180a13081708b78d42232c6d922ce3de63f12e0)
1/*
2 * PHY functions
3 *
4 * Copyright (c) 2004-2007 Reyk Floeter <reyk@openbsd.org>
5 * Copyright (c) 2006-2009 Nick Kossifidis <mickflemm@gmail.com>
6 * Copyright (c) 2007-2008 Jiri Slaby <jirislaby@gmail.com>
7 * Copyright (c) 2008-2009 Felix Fietkau <nbd@openwrt.org>
8 *

--- 101 unchanged lines hidden (view full) ---

110 return data;
111}
112
113/**********************\
114* RF Gain optimization *
115\**********************/
116
117/*
1/*
2 * PHY functions
3 *
4 * Copyright (c) 2004-2007 Reyk Floeter <reyk@openbsd.org>
5 * Copyright (c) 2006-2009 Nick Kossifidis <mickflemm@gmail.com>
6 * Copyright (c) 2007-2008 Jiri Slaby <jirislaby@gmail.com>
7 * Copyright (c) 2008-2009 Felix Fietkau <nbd@openwrt.org>
8 *

--- 101 unchanged lines hidden (view full) ---

110 return data;
111}
112
113/**********************\
114* RF Gain optimization *
115\**********************/
116
117/*
118 * This code is used to optimize rf gain on different environments
118 * This code is used to optimize RF gain on different environments
119 * (temperature mostly) based on feedback from a power detector.
120 *
121 * It's only used on RF5111 and RF5112, later RF chips seem to have
122 * auto adjustment on hw -notice they have a much smaller BANK 7 and
123 * no gain optimization ladder-.
124 *
125 * For more infos check out this patent doc
126 * http://www.freepatentsonline.com/7400691.html

--- 170 unchanged lines hidden (view full) ---

297
298 return (ah->ah_gain.g_current >= level[0] &&
299 ah->ah_gain.g_current <= level[1]) ||
300 (ah->ah_gain.g_current >= level[2] &&
301 ah->ah_gain.g_current <= level[3]);
302}
303
304/* Perform gain_F adjustment by choosing the right set
119 * (temperature mostly) based on feedback from a power detector.
120 *
121 * It's only used on RF5111 and RF5112, later RF chips seem to have
122 * auto adjustment on hw -notice they have a much smaller BANK 7 and
123 * no gain optimization ladder-.
124 *
125 * For more infos check out this patent doc
126 * http://www.freepatentsonline.com/7400691.html

--- 170 unchanged lines hidden (view full) ---

297
298 return (ah->ah_gain.g_current >= level[0] &&
299 ah->ah_gain.g_current <= level[1]) ||
300 (ah->ah_gain.g_current >= level[2] &&
301 ah->ah_gain.g_current <= level[3]);
302}
303
304/* Perform gain_F adjustment by choosing the right set
305 * of parameters from rf gain optimization ladder */
305 * of parameters from RF gain optimization ladder */
306static s8 ath5k_hw_rf_gainf_adjust(struct ath5k_hw *ah)
307{
308 const struct ath5k_gain_opt *go;
309 const struct ath5k_gain_opt_step *g_step;
310 int ret = 0;
311
312 switch (ah->ah_radio) {
313 case AR5K_RF5111:

--- 48 unchanged lines hidden (view full) ---

362 ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_CALIBRATE,
363 "ret %d, gain step %u, current gain %u, target gain %u\n",
364 ret, ah->ah_gain.g_step_idx, ah->ah_gain.g_current,
365 ah->ah_gain.g_target);
366
367 return ret;
368}
369
306static s8 ath5k_hw_rf_gainf_adjust(struct ath5k_hw *ah)
307{
308 const struct ath5k_gain_opt *go;
309 const struct ath5k_gain_opt_step *g_step;
310 int ret = 0;
311
312 switch (ah->ah_radio) {
313 case AR5K_RF5111:

--- 48 unchanged lines hidden (view full) ---

362 ATH5K_DBG(ah->ah_sc, ATH5K_DEBUG_CALIBRATE,
363 "ret %d, gain step %u, current gain %u, target gain %u\n",
364 ret, ah->ah_gain.g_step_idx, ah->ah_gain.g_current,
365 ah->ah_gain.g_target);
366
367 return ret;
368}
369
370/* Main callback for thermal rf gain calibration engine
370/* Main callback for thermal RF gain calibration engine
371 * Check for a new gain reading and schedule an adjustment
372 * if needed.
373 *
374 * TODO: Use sw interrupt to schedule reset if gain_F needs
375 * adjustment */
376enum ath5k_rfgain ath5k_hw_gainf_calibrate(struct ath5k_hw *ah)
377{
378 u32 data, type;

--- 49 unchanged lines hidden (view full) ---

428 ah->ah_gain.g_state = AR5K_RFGAIN_ACTIVE;
429 }
430 }
431
432done:
433 return ah->ah_gain.g_state;
434}
435
371 * Check for a new gain reading and schedule an adjustment
372 * if needed.
373 *
374 * TODO: Use sw interrupt to schedule reset if gain_F needs
375 * adjustment */
376enum ath5k_rfgain ath5k_hw_gainf_calibrate(struct ath5k_hw *ah)
377{
378 u32 data, type;

--- 49 unchanged lines hidden (view full) ---

428 ah->ah_gain.g_state = AR5K_RFGAIN_ACTIVE;
429 }
430 }
431
432done:
433 return ah->ah_gain.g_state;
434}
435
436/* Write initial rf gain table to set the RF sensitivity
436/* Write initial RF gain table to set the RF sensitivity
437 * this one works on all RF chips and has nothing to do
438 * with gain_F calibration */
439int ath5k_hw_rfgain_init(struct ath5k_hw *ah, unsigned int freq)
440{
441 const struct ath5k_ini_rfgain *ath5k_rfg;
442 unsigned int i, size;
443
444 switch (ah->ah_radio) {

--- 46 unchanged lines hidden (view full) ---

491
492
493/********************\
494* RF Registers setup *
495\********************/
496
497
498/*
437 * this one works on all RF chips and has nothing to do
438 * with gain_F calibration */
439int ath5k_hw_rfgain_init(struct ath5k_hw *ah, unsigned int freq)
440{
441 const struct ath5k_ini_rfgain *ath5k_rfg;
442 unsigned int i, size;
443
444 switch (ah->ah_radio) {

--- 46 unchanged lines hidden (view full) ---

491
492
493/********************\
494* RF Registers setup *
495\********************/
496
497
498/*
499 * Setup RF registers by writing rf buffer on hw
499 * Setup RF registers by writing RF buffer on hw
500 */
501int ath5k_hw_rfregs_init(struct ath5k_hw *ah, struct ieee80211_channel *channel,
502 unsigned int mode)
503{
504 const struct ath5k_rf_reg *rf_regs;
505 const struct ath5k_ini_rfbuffer *ini_rfb;
506 const struct ath5k_gain_opt *go = NULL;
507 const struct ath5k_gain_opt_step *g_step;

--- 58 unchanged lines hidden (view full) ---

566 ini_rfb = rfb_2417;
567 ah->ah_rf_banks_size = ARRAY_SIZE(rfb_2417);
568 }
569 break;
570 default:
571 return -EINVAL;
572 }
573
500 */
501int ath5k_hw_rfregs_init(struct ath5k_hw *ah, struct ieee80211_channel *channel,
502 unsigned int mode)
503{
504 const struct ath5k_rf_reg *rf_regs;
505 const struct ath5k_ini_rfbuffer *ini_rfb;
506 const struct ath5k_gain_opt *go = NULL;
507 const struct ath5k_gain_opt_step *g_step;

--- 58 unchanged lines hidden (view full) ---

566 ini_rfb = rfb_2417;
567 ah->ah_rf_banks_size = ARRAY_SIZE(rfb_2417);
568 }
569 break;
570 default:
571 return -EINVAL;
572 }
573
574 /* If it's the first time we set rf buffer, allocate
574 /* If it's the first time we set RF buffer, allocate
575 * ah->ah_rf_banks based on ah->ah_rf_banks_size
576 * we set above */
577 if (ah->ah_rf_banks == NULL) {
578 ah->ah_rf_banks = kmalloc(sizeof(u32) * ah->ah_rf_banks_size,
579 GFP_KERNEL);
580 if (ah->ah_rf_banks == NULL) {
581 ATH5K_ERR(ah->ah_sc, "out of memory\n");
582 return -ENOMEM;

--- 2447 unchanged lines hidden (view full) ---

3030 /* FIXME: Only on channel/mode change */
3031 ret = ath5k_setup_channel_powertable(ah, channel, ee_mode, type);
3032 if (ret)
3033 return ret;
3034
3035 /* Limit max power if we have a CTL available */
3036 ath5k_get_max_ctl_power(ah, channel);
3037
575 * ah->ah_rf_banks based on ah->ah_rf_banks_size
576 * we set above */
577 if (ah->ah_rf_banks == NULL) {
578 ah->ah_rf_banks = kmalloc(sizeof(u32) * ah->ah_rf_banks_size,
579 GFP_KERNEL);
580 if (ah->ah_rf_banks == NULL) {
581 ATH5K_ERR(ah->ah_sc, "out of memory\n");
582 return -ENOMEM;

--- 2447 unchanged lines hidden (view full) ---

3030 /* FIXME: Only on channel/mode change */
3031 ret = ath5k_setup_channel_powertable(ah, channel, ee_mode, type);
3032 if (ret)
3033 return ret;
3034
3035 /* Limit max power if we have a CTL available */
3036 ath5k_get_max_ctl_power(ah, channel);
3037
3038 /* FIXME: Tx power limit for this regdomain
3039 * XXX: Mac80211/CRDA will do that anyway ? */
3040
3041 /* FIXME: Antenna reduction stuff */
3042
3043 /* FIXME: Limit power on turbo modes */
3044
3045 /* FIXME: TPC scale reduction */
3046
3047 /* Get surounding channels for per-rate power table
3048 * calibration */

--- 70 unchanged lines hidden ---
3038 /* FIXME: Antenna reduction stuff */
3039
3040 /* FIXME: Limit power on turbo modes */
3041
3042 /* FIXME: TPC scale reduction */
3043
3044 /* Get surounding channels for per-rate power table
3045 * calibration */

--- 70 unchanged lines hidden ---