* [PATCH bluetooth-next 1/3] cc2520: add set transmit power setting support
@ 2015-05-28 6:50 Varka Bhadram
2015-05-28 6:50 ` [PATCH bluetooth-next 2/3] cc2520: update initial transmit power value Varka Bhadram
2015-05-28 6:51 ` [PATCH bluetooth-next 3/3] cc2520: update current channel Varka Bhadram
0 siblings, 2 replies; 6+ messages in thread
From: Varka Bhadram @ 2015-05-28 6:50 UTC (permalink / raw)
To: linux-wpan; +Cc: Varka Bhadram
This patch adds support for seeting tx power value.
Signed-off-by: Varka Bhadram <varkab@cdac.in>
---
drivers/net/ieee802154/cc2520.c | 51 +++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/drivers/net/ieee802154/cc2520.c b/drivers/net/ieee802154/cc2520.c
index 84b28a0..a20e6d4 100644
--- a/drivers/net/ieee802154/cc2520.c
+++ b/drivers/net/ieee802154/cc2520.c
@@ -628,6 +628,52 @@ cc2520_filter(struct ieee802154_hw *hw,
return 0;
}
+#define CC2520_MAX_TX_POWERS 0x8
+static const s32 cc2520_powers[CC2520_MAX_TX_POWERS + 1] = {
+ 500, 300, 200, 100, 0, -200, -400, -700, -1800,
+};
+
+static int
+cc2520_set_txpower(struct ieee802154_hw *hw, s32 mbm)
+{
+ struct cc2520_private *priv = hw->priv;
+ u8 power;
+
+ switch (mbm) {
+ case 500:
+ power = 0xF7;
+ break;
+ case 300:
+ power = 0xF2;
+ break;
+ case 200:
+ power = 0xAB;
+ break;
+ case 100:
+ power = 0x13;
+ break;
+ case 0:
+ power = 0x32;
+ break;
+ case -200:
+ power = 0x81;
+ break;
+ case -400:
+ power = 0x88;
+ break;
+ case -700:
+ power = 0x2C;
+ break;
+ case -1800:
+ power = 0x03;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return cc2520_write_register(priv, CC2520_TXPOWER, power);
+}
+
static const struct ieee802154_ops cc2520_ops = {
.owner = THIS_MODULE,
.start = cc2520_start,
@@ -636,6 +682,7 @@ static const struct ieee802154_ops cc2520_ops = {
.ed = cc2520_ed,
.set_channel = cc2520_set_channel,
.set_hw_addr_filt = cc2520_filter,
+ .set_txpower = cc2520_set_txpower,
};
static int cc2520_register(struct cc2520_private *priv)
@@ -657,6 +704,10 @@ static int cc2520_register(struct cc2520_private *priv)
priv->hw->flags = IEEE802154_HW_OMIT_CKSUM | IEEE802154_HW_AACK |
IEEE802154_HW_AFILT;
+ priv->hw->phy->flags = WPAN_PHY_FLAG_TXPOWER;
+ priv->hw->phy->supported.tx_powers = cc2520_powers;
+ priv->hw->phy->supported.tx_powers_size = ARRAY_SIZE(cc2520_powers);
+
dev_vdbg(&priv->spi->dev, "registered cc2520\n");
ret = ieee802154_register_hw(priv->hw);
if (ret)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH bluetooth-next 2/3] cc2520: update initial transmit power value
2015-05-28 6:50 [PATCH bluetooth-next 1/3] cc2520: add set transmit power setting support Varka Bhadram
@ 2015-05-28 6:50 ` Varka Bhadram
2015-05-28 7:27 ` Varka Bhadram
2015-05-28 6:51 ` [PATCH bluetooth-next 3/3] cc2520: update current channel Varka Bhadram
1 sibling, 1 reply; 6+ messages in thread
From: Varka Bhadram @ 2015-05-28 6:50 UTC (permalink / raw)
To: linux-wpan; +Cc: Varka Bhadram
CC2520 has the default 0dBm transmit power level on reset.
This patch update initial value of transmit power with 0dBm value.
Signed-off-by: Varka Bhadram <varkab@cdac.in>
---
drivers/net/ieee802154/cc2520.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ieee802154/cc2520.c b/drivers/net/ieee802154/cc2520.c
index a20e6d4..94347d4 100644
--- a/drivers/net/ieee802154/cc2520.c
+++ b/drivers/net/ieee802154/cc2520.c
@@ -708,6 +708,8 @@ static int cc2520_register(struct cc2520_private *priv)
priv->hw->phy->supported.tx_powers = cc2520_powers;
priv->hw->phy->supported.tx_powers_size = ARRAY_SIZE(cc2520_powers);
+ priv->hw->phy->transmit_power = priv->hw->phy->supported.tx_powers[4];
+
dev_vdbg(&priv->spi->dev, "registered cc2520\n");
ret = ieee802154_register_hw(priv->hw);
if (ret)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH bluetooth-next 2/3] cc2520: update initial transmit power value
2015-05-28 6:50 ` [PATCH bluetooth-next 2/3] cc2520: update initial transmit power value Varka Bhadram
@ 2015-05-28 7:27 ` Varka Bhadram
2015-05-28 8:17 ` Stefan Schmidt
0 siblings, 1 reply; 6+ messages in thread
From: Varka Bhadram @ 2015-05-28 7:27 UTC (permalink / raw)
To: linux-wpan; +Cc: Varka Bhadram
On 05/28/2015 12:20 PM, Varka Bhadram wrote:
> CC2520 has the default 0dBm transmit power level on reset.
> This patch update initial value of transmit power with 0dBm value.
CC2520 has the 0dBm value on reset, but in the driver we are setting
tx power value to 5dBm.
> Signed-off-by: Varka Bhadram <varkab@cdac.in>
> ---
> drivers/net/ieee802154/cc2520.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/ieee802154/cc2520.c b/drivers/net/ieee802154/cc2520.c
> index a20e6d4..94347d4 100644
> --- a/drivers/net/ieee802154/cc2520.c
> +++ b/drivers/net/ieee802154/cc2520.c
> @@ -708,6 +708,8 @@ static int cc2520_register(struct cc2520_private *priv)
> priv->hw->phy->supported.tx_powers = cc2520_powers;
> priv->hw->phy->supported.tx_powers_size = ARRAY_SIZE(cc2520_powers);
>
> + priv->hw->phy->transmit_power = priv->hw->phy->supported.tx_powers[4];
> +
This has to be:
priv->hw->phy->transmit_power = priv->hw->phy->supported.tx_powers[0];
> dev_vdbg(&priv->spi->dev, "registered cc2520\n");
> ret = ieee802154_register_hw(priv->hw);
> if (ret)
--
Varka Bhadram
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH bluetooth-next 2/3] cc2520: update initial transmit power value
2015-05-28 7:27 ` Varka Bhadram
@ 2015-05-28 8:17 ` Stefan Schmidt
2015-05-28 8:38 ` Varka Bhadram
0 siblings, 1 reply; 6+ messages in thread
From: Stefan Schmidt @ 2015-05-28 8:17 UTC (permalink / raw)
To: Varka Bhadram, linux-wpan; +Cc: Varka Bhadram
Hello.
On 28/05/15 09:27, Varka Bhadram wrote:
> On 05/28/2015 12:20 PM, Varka Bhadram wrote:
>
>> CC2520 has the default 0dBm transmit power level on reset.
>> This patch update initial value of transmit power with 0dBm value.
>
> CC2520 has the 0dBm value on reset, but in the driver we are setting
> tx power value to 5dBm.
Why?
In most cases it makes sense to use the same default values the device
uses as reset values. Why did you decide to use a different value here?
regards
Stefan Schmidt
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH bluetooth-next 2/3] cc2520: update initial transmit power value
2015-05-28 8:17 ` Stefan Schmidt
@ 2015-05-28 8:38 ` Varka Bhadram
0 siblings, 0 replies; 6+ messages in thread
From: Varka Bhadram @ 2015-05-28 8:38 UTC (permalink / raw)
To: Stefan Schmidt, Varka Bhadram, linux-wpan
Hello,
On 05/28/2015 01:47 PM, Stefan Schmidt wrote:
> Hello.
>
> On 28/05/15 09:27, Varka Bhadram wrote:
>> On 05/28/2015 12:20 PM, Varka Bhadram wrote:
>>
>>> CC2520 has the default 0dBm transmit power level on reset.
>>> This patch update initial value of transmit power with 0dBm value.
>>
>> CC2520 has the 0dBm value on reset, but in the driver we are setting
>> tx power value to 5dBm.
>
> Why?
>
> In most cases it makes sense to use the same default values the device
> uses as reset values. Why did you decide to use a different value here?
>
Correct. I need to change that.
Initially we dont have tx power setting from the user-space.
So i just hard coded that value (5dBm) at the time of
hardware initialization.
Now we can set the values from the user-space.
Thanks
--
Varka Bhadram
-------------------------------------------------------------------------------------------------------------------------------
[ C-DAC is on Social-Media too. Kindly follow us at:
Facebook: https://www.facebook.com/CDACINDIA & Twitter: @cdacindia ]
This e-mail is for the sole use of the intended recipient(s) and may
contain confidential and privileged information. If you are not the
intended recipient, please contact the sender by reply e-mail and destroy
all copies and the original message. Any unauthorized review, use,
disclosure, dissemination, forwarding, printing or copying of this email
is strictly prohibited and appropriate legal action will be taken.
-------------------------------------------------------------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH bluetooth-next 3/3] cc2520: update current channel
2015-05-28 6:50 [PATCH bluetooth-next 1/3] cc2520: add set transmit power setting support Varka Bhadram
2015-05-28 6:50 ` [PATCH bluetooth-next 2/3] cc2520: update initial transmit power value Varka Bhadram
@ 2015-05-28 6:51 ` Varka Bhadram
1 sibling, 0 replies; 6+ messages in thread
From: Varka Bhadram @ 2015-05-28 6:51 UTC (permalink / raw)
To: linux-wpan; +Cc: Varka Bhadram
This patch updates the current channel to 11. This is the default
value on reset.
Signed-off-by: Varka Bhadram <varkab@cdac.in>
---
drivers/net/ieee802154/cc2520.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ieee802154/cc2520.c b/drivers/net/ieee802154/cc2520.c
index 94347d4..2bc8e86 100644
--- a/drivers/net/ieee802154/cc2520.c
+++ b/drivers/net/ieee802154/cc2520.c
@@ -709,6 +709,7 @@ static int cc2520_register(struct cc2520_private *priv)
priv->hw->phy->supported.tx_powers_size = ARRAY_SIZE(cc2520_powers);
priv->hw->phy->transmit_power = priv->hw->phy->supported.tx_powers[4];
+ priv->hw->phy->current_channel = 11;
dev_vdbg(&priv->spi->dev, "registered cc2520\n");
ret = ieee802154_register_hw(priv->hw);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-05-28 8:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-28 6:50 [PATCH bluetooth-next 1/3] cc2520: add set transmit power setting support Varka Bhadram
2015-05-28 6:50 ` [PATCH bluetooth-next 2/3] cc2520: update initial transmit power value Varka Bhadram
2015-05-28 7:27 ` Varka Bhadram
2015-05-28 8:17 ` Stefan Schmidt
2015-05-28 8:38 ` Varka Bhadram
2015-05-28 6:51 ` [PATCH bluetooth-next 3/3] cc2520: update current channel Varka Bhadram
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox