aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ieee802154/at86rf230.c
diff options
context:
space:
mode:
authorAlexander Aring <alex.aring@gmail.com>2014-07-02 18:20:47 -0400
committerDavid S. Miller <davem@davemloft.net>2014-07-08 00:29:24 -0400
commita7d7eda9054450320d5f7144ff8a0767ab619da3 (patch)
tree545fc2d4ab0e6d25c4711b8aa2c8cb6fed142c13 /drivers/net/ieee802154/at86rf230.c
parenta53d1f7c3d53353f68b2355a19cd5d5c7e4c7b34 (diff)
at86rf230: add support for at86rf23x desense
To set the CCA_ED_THRES register the calculation for at86rf23x is different than for at86rf212. This patch adds a new callback for this calculation in chip data struct. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ieee802154/at86rf230.c')
-rw-r--r--drivers/net/ieee802154/at86rf230.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index 694f5cf339e3..6556fecec5e2 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -46,6 +46,7 @@ struct at86rf2xx_chip_data {
46 int rssi_base_val; 46 int rssi_base_val;
47 47
48 int (*set_channel)(struct at86rf230_local *, int, int); 48 int (*set_channel)(struct at86rf230_local *, int, int);
49 int (*get_desense_steps)(struct at86rf230_local *, s32);
49}; 50};
50 51
51struct at86rf230_local { 52struct at86rf230_local {
@@ -819,17 +820,27 @@ at86rf230_set_cca_mode(struct ieee802154_dev *dev, u8 mode)
819} 820}
820 821
821static int 822static int
823at86rf212_get_desens_steps(struct at86rf230_local *lp, s32 level)
824{
825 return (level - lp->data->rssi_base_val) * 100 / 207;
826}
827
828static int
829at86rf23x_get_desens_steps(struct at86rf230_local *lp, s32 level)
830{
831 return (level - lp->data->rssi_base_val) / 2;
832}
833
834static int
822at86rf230_set_cca_ed_level(struct ieee802154_dev *dev, s32 level) 835at86rf230_set_cca_ed_level(struct ieee802154_dev *dev, s32 level)
823{ 836{
824 struct at86rf230_local *lp = dev->priv; 837 struct at86rf230_local *lp = dev->priv;
825 int desens_steps;
826 838
827 if (level < lp->data->rssi_base_val || level > 30) 839 if (level < lp->data->rssi_base_val || level > 30)
828 return -EINVAL; 840 return -EINVAL;
829 841
830 desens_steps = (level - lp->data->rssi_base_val) * 100 / 207; 842 return at86rf230_write_subreg(lp, SR_CCA_ED_THRES,
831 843 lp->data->get_desense_steps(lp, level));
832 return at86rf230_write_subreg(lp, SR_CCA_ED_THRES, desens_steps);
833} 844}
834 845
835static int 846static int
@@ -889,16 +900,19 @@ static struct ieee802154_ops at86rf230_ops = {
889static struct at86rf2xx_chip_data at86rf233_data = { 900static struct at86rf2xx_chip_data at86rf233_data = {
890 .rssi_base_val = -91, 901 .rssi_base_val = -91,
891 .set_channel = at86rf23x_set_channel, 902 .set_channel = at86rf23x_set_channel,
903 .get_desense_steps = at86rf23x_get_desens_steps
892}; 904};
893 905
894static struct at86rf2xx_chip_data at86rf231_data = { 906static struct at86rf2xx_chip_data at86rf231_data = {
895 .rssi_base_val = -91, 907 .rssi_base_val = -91,
896 .set_channel = at86rf23x_set_channel, 908 .set_channel = at86rf23x_set_channel,
909 .get_desense_steps = at86rf23x_get_desens_steps
897}; 910};
898 911
899static struct at86rf2xx_chip_data at86rf212_data = { 912static struct at86rf2xx_chip_data at86rf212_data = {
900 .rssi_base_val = -100, 913 .rssi_base_val = -100,
901 .set_channel = at86rf212_set_channel, 914 .set_channel = at86rf212_set_channel,
915 .get_desense_steps = at86rf212_get_desens_steps
902}; 916};
903 917
904static void at86rf230_irqwork(struct work_struct *work) 918static void at86rf230_irqwork(struct work_struct *work)