summaryrefslogtreecommitdiff
path: root/drivers/net/ieee802154
diff options
context:
space:
mode:
authorPhoebe Buckheister <phoebe.buckheister@itwm.fraunhofer.de>2014-02-17 14:34:12 +0400
committerDavid S. Miller <davem@davemloft.net>2014-02-18 01:42:38 +0400
commit6ca001978dce0d50ebac01a38d6287f241a520c6 (patch)
tree2ed75aadbfb16ca006a2cd94bc30ebf614783ffc /drivers/net/ieee802154
parentba08fea53a43e02b590d89224afdad976dece841 (diff)
downloadlinux-6ca001978dce0d50ebac01a38d6287f241a520c6.tar.xz
ieee802154: add support for setting CCA energy detection levels
Since three of the four clear channel assesment modes make use of energy detection, provide an API to set the energy detection threshold. Driver support for this is available in at86rf230 for the RF212 chips. Since for these chips the minimal energy detection threshold depends on page and channel used, add a field to struct at86rf230_local that stores the minimal threshold. Actual ED thresholds are configured as offsets from this value. For RF212, setting the ED threshold will not work before a channel/page has been set due to the dependency of energy detection in the chip and the actual channel/page selected. Signed-off-by: Phoebe Buckheister <phoebe.buckheister@itwm.fraunhofer.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ieee802154')
-rw-r--r--drivers/net/ieee802154/at86rf230.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index c60871aff333..20596be61028 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -52,6 +52,8 @@ struct at86rf230_local {
spinlock_t lock;
bool irq_busy;
bool is_tx;
+
+ int rssi_base_val;
};
static inline int is_rf212(struct at86rf230_local *local)
@@ -580,6 +582,8 @@ at86rf230_stop(struct ieee802154_dev *dev)
static int
at86rf230_set_channel(struct at86rf230_local *lp, int page, int channel)
{
+ lp->rssi_base_val = -91;
+
return at86rf230_write_subreg(lp, SR_CHANNEL, channel);
}
@@ -595,10 +599,13 @@ at86rf212_set_channel(struct at86rf230_local *lp, int page, int channel)
if (rc < 0)
return rc;
- if (page == 0)
+ if (page == 0) {
rc = at86rf230_write_subreg(lp, SR_BPSK_QPSK, 0);
- else
+ lp->rssi_base_val = -100;
+ } else {
rc = at86rf230_write_subreg(lp, SR_BPSK_QPSK, 1);
+ lp->rssi_base_val = -98;
+ }
if (rc < 0)
return rc;
@@ -802,6 +809,20 @@ at86rf212_set_cca_mode(struct ieee802154_dev *dev, u8 mode)
return at86rf230_write_subreg(lp, SR_CCA_MODE, mode);
}
+static int
+at86rf212_set_cca_ed_level(struct ieee802154_dev *dev, s32 level)
+{
+ struct at86rf230_local *lp = dev->priv;
+ int desens_steps;
+
+ if (level < lp->rssi_base_val || level > 30)
+ return -EINVAL;
+
+ desens_steps = (level - lp->rssi_base_val) * 100 / 207;
+
+ return at86rf230_write_subreg(lp, SR_CCA_ED_THRES, desens_steps);
+}
+
static struct ieee802154_ops at86rf230_ops = {
.owner = THIS_MODULE,
.xmit = at86rf230_xmit,
@@ -823,6 +844,7 @@ static struct ieee802154_ops at86rf212_ops = {
.set_txpower = at86rf212_set_txpower,
.set_lbt = at86rf212_set_lbt,
.set_cca_mode = at86rf212_set_cca_mode,
+ .set_cca_ed_level = at86rf212_set_cca_ed_level,
};
static void at86rf230_irqwork(struct work_struct *work)