summaryrefslogtreecommitdiffstats
path: root/drivers/net/ieee802154/at86rf230.c
diff options
context:
space:
mode:
authorAlexander Aring2014-12-10 15:33:12 +0100
committerMarcel Holtmann2014-12-19 00:19:23 +0100
commit7fe9a3882bb37195c41ab125a0f2852398d2646a (patch)
tree2575090079228f59a93466eaf2d1b69524b97e8a /drivers/net/ieee802154/at86rf230.c
parentnl802154: introduce cca mode enums (diff)
downloadkernel-qcow2-linux-7fe9a3882bb37195c41ab125a0f2852398d2646a.tar.gz
kernel-qcow2-linux-7fe9a3882bb37195c41ab125a0f2852398d2646a.tar.xz
kernel-qcow2-linux-7fe9a3882bb37195c41ab125a0f2852398d2646a.zip
ieee802154: rework cca setting
The current cca setting handle is a driver specific call. We need to introduce some 802.15.4 specific layer and mapping 802.15.4 cca modes to driver specific ones inside the 802.15.4 driver. This patch will add such 802.15.4 layer and mapping the cca settings to driver specific ones. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'drivers/net/ieee802154/at86rf230.c')
-rw-r--r--drivers/net/ieee802154/at86rf230.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index 1c0135620c62..1ac46ba41fd8 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -1146,11 +1146,37 @@ at86rf230_set_lbt(struct ieee802154_hw *hw, bool on)
}
static int
-at86rf230_set_cca_mode(struct ieee802154_hw *hw, u8 mode)
+at86rf230_set_cca_mode(struct ieee802154_hw *hw,
+ const struct wpan_phy_cca *cca)
{
struct at86rf230_local *lp = hw->priv;
+ u8 val;
- return at86rf230_write_subreg(lp, SR_CCA_MODE, mode);
+ /* mapping 802.15.4 to driver spec */
+ switch (cca->mode) {
+ case NL802154_CCA_ENERGY:
+ val = 1;
+ break;
+ case NL802154_CCA_CARRIER:
+ val = 2;
+ break;
+ case NL802154_CCA_ENERGY_CARRIER:
+ switch (cca->opt) {
+ case NL802154_CCA_OPT_ENERGY_CARRIER_AND:
+ val = 3;
+ break;
+ case NL802154_CCA_OPT_ENERGY_CARRIER_OR:
+ val = 0;
+ break;
+ default:
+ return -EINVAL;
+ }
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return at86rf230_write_subreg(lp, SR_CCA_MODE, val);
}
static int