diff options
author | Alexander Aring <alex.aring@gmail.com> | 2014-07-02 18:20:47 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-07-08 00:29:24 -0400 |
commit | a7d7eda9054450320d5f7144ff8a0767ab619da3 (patch) | |
tree | 545fc2d4ab0e6d25c4711b8aa2c8cb6fed142c13 /drivers/net/ieee802154/at86rf230.c | |
parent | a53d1f7c3d53353f68b2355a19cd5d5c7e4c7b34 (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.c | 22 |
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 | ||
51 | struct at86rf230_local { | 52 | struct at86rf230_local { |
@@ -819,17 +820,27 @@ at86rf230_set_cca_mode(struct ieee802154_dev *dev, u8 mode) | |||
819 | } | 820 | } |
820 | 821 | ||
821 | static int | 822 | static int |
823 | at86rf212_get_desens_steps(struct at86rf230_local *lp, s32 level) | ||
824 | { | ||
825 | return (level - lp->data->rssi_base_val) * 100 / 207; | ||
826 | } | ||
827 | |||
828 | static int | ||
829 | at86rf23x_get_desens_steps(struct at86rf230_local *lp, s32 level) | ||
830 | { | ||
831 | return (level - lp->data->rssi_base_val) / 2; | ||
832 | } | ||
833 | |||
834 | static int | ||
822 | at86rf230_set_cca_ed_level(struct ieee802154_dev *dev, s32 level) | 835 | at86rf230_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 | ||
835 | static int | 846 | static int |
@@ -889,16 +900,19 @@ static struct ieee802154_ops at86rf230_ops = { | |||
889 | static struct at86rf2xx_chip_data at86rf233_data = { | 900 | static 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 | ||
894 | static struct at86rf2xx_chip_data at86rf231_data = { | 906 | static 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 | ||
899 | static struct at86rf2xx_chip_data at86rf212_data = { | 912 | static 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 | ||
904 | static void at86rf230_irqwork(struct work_struct *work) | 918 | static void at86rf230_irqwork(struct work_struct *work) |