@@ -822,6 +822,48 @@ static int mrf24j40_set_cca_mode(struct ieee802154_hw *hw,
822
822
val << 6 );
823
823
}
824
824
825
+ /* array for representing ed levels */
826
+ static const s32 mrf24j40_ed_levels [] = {
827
+ -9000 , -8900 , -8800 , -8700 , -8600 , -8500 , -8400 , -8300 , -8200 , -8100 ,
828
+ -8000 , -7900 , -7800 , -7700 , -7600 , -7500 , -7400 , -7300 , -7200 , -7100 ,
829
+ -7000 , -6900 , -6800 , -6700 , -6600 , -6500 , -6400 , -6300 , -6200 , -6100 ,
830
+ -6000 , -5900 , -5800 , -5700 , -5600 , -5500 , -5400 , -5300 , -5200 , -5100 ,
831
+ -5000 , -4900 , -4800 , -4700 , -4600 , -4500 , -4400 , -4300 , -4200 , -4100 ,
832
+ -4000 , -3900 , -3800 , -3700 , -3600 , -3500
833
+ };
834
+
835
+ /* map ed levels to register value */
836
+ static const s32 mrf24j40_ed_levels_map [][2 ] = {
837
+ { -9000 , 0 }, { -8900 , 1 }, { -8800 , 2 }, { -8700 , 5 }, { -8600 , 9 },
838
+ { -8500 , 13 }, { -8400 , 18 }, { -8300 , 23 }, { -8200 , 27 },
839
+ { -8100 , 32 }, { -8000 , 37 }, { -7900 , 43 }, { -7800 , 48 },
840
+ { -7700 , 53 }, { -7600 , 58 }, { -7500 , 63 }, { -7400 , 68 },
841
+ { -7300 , 73 }, { -7200 , 78 }, { -7100 , 83 }, { -7000 , 89 },
842
+ { -6900 , 95 }, { -6800 , 100 }, { -6700 , 107 }, { -6600 , 111 },
843
+ { -6500 , 117 }, { -6400 , 121 }, { -6300 , 125 }, { -6200 , 129 },
844
+ { -6100 , 133 }, { -6000 , 138 }, { -5900 , 143 }, { -5800 , 148 },
845
+ { -5700 , 153 }, { -5600 , 159 }, { -5500 , 165 }, { -5400 , 170 },
846
+ { -5300 , 176 }, { -5200 , 183 }, { -5100 , 188 }, { -5000 , 193 },
847
+ { -4900 , 198 }, { -4800 , 203 }, { -4700 , 207 }, { -4600 , 212 },
848
+ { -4500 , 216 }, { -4400 , 221 }, { -4300 , 225 }, { -4200 , 228 },
849
+ { -4100 , 233 }, { -4000 , 239 }, { -3900 , 245 }, { -3800 , 250 },
850
+ { -3700 , 253 }, { -3600 , 254 }, { -3500 , 255 },
851
+ };
852
+
853
+ static int mrf24j40_set_cca_ed_level (struct ieee802154_hw * hw , s32 mbm )
854
+ {
855
+ struct mrf24j40 * devrec = hw -> priv ;
856
+ int i ;
857
+
858
+ for (i = 0 ; i < ARRAY_SIZE (mrf24j40_ed_levels_map ); i ++ ) {
859
+ if (mrf24j40_ed_levels_map [i ][0 ] == mbm )
860
+ return regmap_write (devrec -> regmap_short , REG_CCAEDTH ,
861
+ mrf24j40_ed_levels_map [i ][1 ]);
862
+ }
863
+
864
+ return - EINVAL ;
865
+ }
866
+
825
867
static const struct ieee802154_ops mrf24j40_ops = {
826
868
.owner = THIS_MODULE ,
827
869
.xmit_async = mrf24j40_tx ,
@@ -832,6 +874,7 @@ static const struct ieee802154_ops mrf24j40_ops = {
832
874
.set_hw_addr_filt = mrf24j40_filter ,
833
875
.set_csma_params = mrf24j40_csma_params ,
834
876
.set_cca_mode = mrf24j40_set_cca_mode ,
877
+ .set_cca_ed_level = mrf24j40_set_cca_ed_level ,
835
878
};
836
879
837
880
static void mrf24j40_intstat_complete (void * context )
@@ -1041,6 +1084,10 @@ static void mrf24j40_phy_setup(struct mrf24j40 *devrec)
1041
1084
BIT (NL802154_CCA_CARRIER ) |
1042
1085
BIT (NL802154_CCA_ENERGY_CARRIER );
1043
1086
devrec -> hw -> phy -> supported .cca_opts = BIT (NL802154_CCA_OPT_ENERGY_CARRIER_AND );
1087
+
1088
+ devrec -> hw -> phy -> cca_ed_level = -6900 ;
1089
+ devrec -> hw -> phy -> supported .cca_ed_levels = mrf24j40_ed_levels ;
1090
+ devrec -> hw -> phy -> supported .cca_ed_levels_size = ARRAY_SIZE (mrf24j40_ed_levels );
1044
1091
}
1045
1092
1046
1093
static int mrf24j40_probe (struct spi_device * spi )
@@ -1066,7 +1113,8 @@ static int mrf24j40_probe(struct spi_device *spi)
1066
1113
devrec -> hw -> flags = IEEE802154_HW_TX_OMIT_CKSUM | IEEE802154_HW_AFILT |
1067
1114
IEEE802154_HW_CSMA_PARAMS ;
1068
1115
1069
- devrec -> hw -> phy -> flags = WPAN_PHY_FLAG_CCA_MODE ;
1116
+ devrec -> hw -> phy -> flags = WPAN_PHY_FLAG_CCA_MODE |
1117
+ WPAN_PHY_FLAG_CCA_ED_LEVEL ;
1070
1118
1071
1119
mrf24j40_setup_tx_spi_messages (devrec );
1072
1120
mrf24j40_setup_rx_spi_messages (devrec );
0 commit comments