Commit a7d7eda9 authored by Alexander Aring's avatar Alexander Aring Committed by David S. Miller

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: default avatarAlexander Aring <alex.aring@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a53d1f7c
...@@ -46,6 +46,7 @@ struct at86rf2xx_chip_data { ...@@ -46,6 +46,7 @@ struct at86rf2xx_chip_data {
int rssi_base_val; int rssi_base_val;
int (*set_channel)(struct at86rf230_local *, int, int); int (*set_channel)(struct at86rf230_local *, int, int);
int (*get_desense_steps)(struct at86rf230_local *, s32);
}; };
struct at86rf230_local { struct at86rf230_local {
...@@ -818,18 +819,28 @@ at86rf230_set_cca_mode(struct ieee802154_dev *dev, u8 mode) ...@@ -818,18 +819,28 @@ at86rf230_set_cca_mode(struct ieee802154_dev *dev, u8 mode)
return at86rf230_write_subreg(lp, SR_CCA_MODE, mode); return at86rf230_write_subreg(lp, SR_CCA_MODE, mode);
} }
static int
at86rf212_get_desens_steps(struct at86rf230_local *lp, s32 level)
{
return (level - lp->data->rssi_base_val) * 100 / 207;
}
static int
at86rf23x_get_desens_steps(struct at86rf230_local *lp, s32 level)
{
return (level - lp->data->rssi_base_val) / 2;
}
static int static int
at86rf230_set_cca_ed_level(struct ieee802154_dev *dev, s32 level) at86rf230_set_cca_ed_level(struct ieee802154_dev *dev, s32 level)
{ {
struct at86rf230_local *lp = dev->priv; struct at86rf230_local *lp = dev->priv;
int desens_steps;
if (level < lp->data->rssi_base_val || level > 30) if (level < lp->data->rssi_base_val || level > 30)
return -EINVAL; return -EINVAL;
desens_steps = (level - lp->data->rssi_base_val) * 100 / 207; return at86rf230_write_subreg(lp, SR_CCA_ED_THRES,
lp->data->get_desense_steps(lp, level));
return at86rf230_write_subreg(lp, SR_CCA_ED_THRES, desens_steps);
} }
static int static int
...@@ -889,16 +900,19 @@ static struct ieee802154_ops at86rf230_ops = { ...@@ -889,16 +900,19 @@ static struct ieee802154_ops at86rf230_ops = {
static struct at86rf2xx_chip_data at86rf233_data = { static struct at86rf2xx_chip_data at86rf233_data = {
.rssi_base_val = -91, .rssi_base_val = -91,
.set_channel = at86rf23x_set_channel, .set_channel = at86rf23x_set_channel,
.get_desense_steps = at86rf23x_get_desens_steps
}; };
static struct at86rf2xx_chip_data at86rf231_data = { static struct at86rf2xx_chip_data at86rf231_data = {
.rssi_base_val = -91, .rssi_base_val = -91,
.set_channel = at86rf23x_set_channel, .set_channel = at86rf23x_set_channel,
.get_desense_steps = at86rf23x_get_desens_steps
}; };
static struct at86rf2xx_chip_data at86rf212_data = { static struct at86rf2xx_chip_data at86rf212_data = {
.rssi_base_val = -100, .rssi_base_val = -100,
.set_channel = at86rf212_set_channel, .set_channel = at86rf212_set_channel,
.get_desense_steps = at86rf212_get_desens_steps
}; };
static void at86rf230_irqwork(struct work_struct *work) static void at86rf230_irqwork(struct work_struct *work)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment