aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/wireless/ath/ath9k/ar5008_phy.c55
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9002_phy.c31
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c64
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.h4
4 files changed, 97 insertions, 57 deletions
diff --git a/drivers/net/wireless/ath/ath9k/ar5008_phy.c b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
index 982b0d3877f..9685f4c6fc9 100644
--- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
@@ -967,6 +967,54 @@ static void ar5008_set_diversity(struct ath_hw *ah, bool value)
967 REG_WRITE(ah, AR_PHY_CCK_DETECT, v); 967 REG_WRITE(ah, AR_PHY_CCK_DETECT, v);
968} 968}
969 969
970static u32 ar9100_hw_compute_pll_control(struct ath_hw *ah,
971 struct ath9k_channel *chan)
972{
973 if (chan && IS_CHAN_5GHZ(chan))
974 return 0x1450;
975 return 0x1458;
976}
977
978static u32 ar9160_hw_compute_pll_control(struct ath_hw *ah,
979 struct ath9k_channel *chan)
980{
981 u32 pll;
982
983 pll = SM(0x5, AR_RTC_9160_PLL_REFDIV);
984
985 if (chan && IS_CHAN_HALF_RATE(chan))
986 pll |= SM(0x1, AR_RTC_9160_PLL_CLKSEL);
987 else if (chan && IS_CHAN_QUARTER_RATE(chan))
988 pll |= SM(0x2, AR_RTC_9160_PLL_CLKSEL);
989
990 if (chan && IS_CHAN_5GHZ(chan))
991 pll |= SM(0x50, AR_RTC_9160_PLL_DIV);
992 else
993 pll |= SM(0x58, AR_RTC_9160_PLL_DIV);
994
995 return pll;
996}
997
998static u32 ar5008_hw_compute_pll_control(struct ath_hw *ah,
999 struct ath9k_channel *chan)
1000{
1001 u32 pll;
1002
1003 pll = AR_RTC_PLL_REFDIV_5 | AR_RTC_PLL_DIV2;
1004
1005 if (chan && IS_CHAN_HALF_RATE(chan))
1006 pll |= SM(0x1, AR_RTC_PLL_CLKSEL);
1007 else if (chan && IS_CHAN_QUARTER_RATE(chan))
1008 pll |= SM(0x2, AR_RTC_PLL_CLKSEL);
1009
1010 if (chan && IS_CHAN_5GHZ(chan))
1011 pll |= SM(0xa, AR_RTC_PLL_DIV);
1012 else
1013 pll |= SM(0xb, AR_RTC_PLL_DIV);
1014
1015 return pll;
1016}
1017
970void ar5008_hw_attach_phy_ops(struct ath_hw *ah) 1018void ar5008_hw_attach_phy_ops(struct ath_hw *ah)
971{ 1019{
972 struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah); 1020 struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
@@ -988,4 +1036,11 @@ void ar5008_hw_attach_phy_ops(struct ath_hw *ah)
988 priv_ops->enable_rfkill = ar5008_hw_enable_rfkill; 1036 priv_ops->enable_rfkill = ar5008_hw_enable_rfkill;
989 priv_ops->restore_chainmask = ar5008_restore_chainmask; 1037 priv_ops->restore_chainmask = ar5008_restore_chainmask;
990 priv_ops->set_diversity = ar5008_set_diversity; 1038 priv_ops->set_diversity = ar5008_set_diversity;
1039
1040 if (AR_SREV_9100(ah))
1041 priv_ops->compute_pll_control = ar9100_hw_compute_pll_control;
1042 else if (AR_SREV_9160_10_OR_LATER(ah))
1043 priv_ops->compute_pll_control = ar9160_hw_compute_pll_control;
1044 else
1045 priv_ops->compute_pll_control = ar5008_hw_compute_pll_control;
991} 1046}
diff --git a/drivers/net/wireless/ath/ath9k/ar9002_phy.c b/drivers/net/wireless/ath/ath9k/ar9002_phy.c
index 29b50ca0a0c..87541a8440c 100644
--- a/drivers/net/wireless/ath/ath9k/ar9002_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar9002_phy.c
@@ -437,6 +437,36 @@ static void ar9002_olc_init(struct ath_hw *ah)
437 } 437 }
438} 438}
439 439
440static u32 ar9002_hw_compute_pll_control(struct ath_hw *ah,
441 struct ath9k_channel *chan)
442{
443 u32 pll;
444
445 pll = SM(0x5, AR_RTC_9160_PLL_REFDIV);
446
447 if (chan && IS_CHAN_HALF_RATE(chan))
448 pll |= SM(0x1, AR_RTC_9160_PLL_CLKSEL);
449 else if (chan && IS_CHAN_QUARTER_RATE(chan))
450 pll |= SM(0x2, AR_RTC_9160_PLL_CLKSEL);
451
452 if (chan && IS_CHAN_5GHZ(chan)) {
453 pll |= SM(0x28, AR_RTC_9160_PLL_DIV);
454
455
456 if (AR_SREV_9280_20(ah)) {
457 if (((chan->channel % 20) == 0)
458 || ((chan->channel % 10) == 0))
459 pll = 0x2850;
460 else
461 pll = 0x142c;
462 }
463 } else {
464 pll |= SM(0x2c, AR_RTC_9160_PLL_DIV);
465 }
466
467 return pll;
468}
469
440void ar9002_hw_attach_phy_ops(struct ath_hw *ah) 470void ar9002_hw_attach_phy_ops(struct ath_hw *ah)
441{ 471{
442 struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah); 472 struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
@@ -447,4 +477,5 @@ void ar9002_hw_attach_phy_ops(struct ath_hw *ah)
447 priv_ops->rf_set_freq = ar9002_hw_set_channel; 477 priv_ops->rf_set_freq = ar9002_hw_set_channel;
448 priv_ops->spur_mitigate_freq = ar9002_hw_spur_mitigate; 478 priv_ops->spur_mitigate_freq = ar9002_hw_spur_mitigate;
449 priv_ops->olc_init = ar9002_olc_init; 479 priv_ops->olc_init = ar9002_olc_init;
480 priv_ops->compute_pll_control = ar9002_hw_compute_pll_control;
450} 481}
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index ea831f575a9..349cffdbdea 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -66,6 +66,12 @@ static bool ath9k_hw_macversion_supported(struct ath_hw *ah)
66 return priv_ops->macversion_supported(ah->hw_version.macVersion); 66 return priv_ops->macversion_supported(ah->hw_version.macVersion);
67} 67}
68 68
69static u32 ath9k_hw_compute_pll_control(struct ath_hw *ah,
70 struct ath9k_channel *chan)
71{
72 return ath9k_hw_private_ops(ah)->compute_pll_control(ah, chan);
73}
74
69/********************/ 75/********************/
70/* Helper Functions */ 76/* Helper Functions */
71/********************/ 77/********************/
@@ -1023,64 +1029,8 @@ static void ath9k_hw_init_qos(struct ath_hw *ah)
1023static void ath9k_hw_init_pll(struct ath_hw *ah, 1029static void ath9k_hw_init_pll(struct ath_hw *ah,
1024 struct ath9k_channel *chan) 1030 struct ath9k_channel *chan)
1025{ 1031{
1026 u32 pll; 1032 u32 pll = ath9k_hw_compute_pll_control(ah, chan);
1027
1028 if (AR_SREV_9100(ah)) {
1029 if (chan && IS_CHAN_5GHZ(chan))
1030 pll = 0x1450;
1031 else
1032 pll = 0x1458;
1033 } else {
1034 if (AR_SREV_9280_10_OR_LATER(ah)) {
1035 pll = SM(0x5, AR_RTC_9160_PLL_REFDIV);
1036
1037 if (chan && IS_CHAN_HALF_RATE(chan))
1038 pll |= SM(0x1, AR_RTC_9160_PLL_CLKSEL);
1039 else if (chan && IS_CHAN_QUARTER_RATE(chan))
1040 pll |= SM(0x2, AR_RTC_9160_PLL_CLKSEL);
1041
1042 if (chan && IS_CHAN_5GHZ(chan)) {
1043 pll |= SM(0x28, AR_RTC_9160_PLL_DIV);
1044
1045
1046 if (AR_SREV_9280_20(ah)) {
1047 if (((chan->channel % 20) == 0)
1048 || ((chan->channel % 10) == 0))
1049 pll = 0x2850;
1050 else
1051 pll = 0x142c;
1052 }
1053 } else {
1054 pll |= SM(0x2c, AR_RTC_9160_PLL_DIV);
1055 }
1056
1057 } else if (AR_SREV_9160_10_OR_LATER(ah)) {
1058
1059 pll = SM(0x5, AR_RTC_9160_PLL_REFDIV);
1060
1061 if (chan && IS_CHAN_HALF_RATE(chan))
1062 pll |= SM(0x1, AR_RTC_9160_PLL_CLKSEL);
1063 else if (chan && IS_CHAN_QUARTER_RATE(chan))
1064 pll |= SM(0x2, AR_RTC_9160_PLL_CLKSEL);
1065
1066 if (chan && IS_CHAN_5GHZ(chan))
1067 pll |= SM(0x50, AR_RTC_9160_PLL_DIV);
1068 else
1069 pll |= SM(0x58, AR_RTC_9160_PLL_DIV);
1070 } else {
1071 pll = AR_RTC_PLL_REFDIV_5 | AR_RTC_PLL_DIV2;
1072
1073 if (chan && IS_CHAN_HALF_RATE(chan))
1074 pll |= SM(0x1, AR_RTC_PLL_CLKSEL);
1075 else if (chan && IS_CHAN_QUARTER_RATE(chan))
1076 pll |= SM(0x2, AR_RTC_PLL_CLKSEL);
1077 1033
1078 if (chan && IS_CHAN_5GHZ(chan))
1079 pll |= SM(0xa, AR_RTC_PLL_DIV);
1080 else
1081 pll |= SM(0xb, AR_RTC_PLL_DIV);
1082 }
1083 }
1084 REG_WRITE(ah, AR_RTC_PLL_CONTROL, pll); 1034 REG_WRITE(ah, AR_RTC_PLL_CONTROL, pll);
1085 1035
1086 /* Switch the core clock for ar9271 to 117Mhz */ 1036 /* Switch the core clock for ar9271 to 117Mhz */
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index d740e9cc721..79b938b9305 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -454,6 +454,8 @@ struct ath_gen_timer_table {
454 * @rf_alloc_ext_banks: 454 * @rf_alloc_ext_banks:
455 * @rf_free_ext_banks: 455 * @rf_free_ext_banks:
456 * @set_rf_regs: 456 * @set_rf_regs:
457 * @compute_pll_control: compute the PLL control value to use for
458 * AR_RTC_PLL_CONTROL for a given channel
457 */ 459 */
458struct ath_hw_private_ops { 460struct ath_hw_private_ops {
459 void (*init_cal_settings)(struct ath_hw *ah); 461 void (*init_cal_settings)(struct ath_hw *ah);
@@ -483,6 +485,8 @@ struct ath_hw_private_ops {
483 void (*enable_rfkill)(struct ath_hw *ah); 485 void (*enable_rfkill)(struct ath_hw *ah);
484 void (*restore_chainmask)(struct ath_hw *ah); 486 void (*restore_chainmask)(struct ath_hw *ah);
485 void (*set_diversity)(struct ath_hw *ah, bool value); 487 void (*set_diversity)(struct ath_hw *ah, bool value);
488 u32 (*compute_pll_control)(struct ath_hw *ah,
489 struct ath9k_channel *chan);
486}; 490};
487 491
488/** 492/**