From: Alexander Aring <alex.aring@gmail.com>
To: linux-wpan@vger.kernel.org
Cc: kernel@pengutronix.de, alan@signal11.us, jonatan@myeden.se,
stefan@osg.samsung.com, Alexander Aring <alex.aring@gmail.com>
Subject: [RFC bluetooth-next 19/21] mrf24j40: add tx power support
Date: Thu, 13 Aug 2015 14:22:46 +0200 [thread overview]
Message-ID: <1439468568-22288-20-git-send-email-alex.aring@gmail.com> (raw)
In-Reply-To: <1439468568-22288-1-git-send-email-alex.aring@gmail.com>
This patch supports setting of transmit power for the mrf24j40ma
transceiver only. The mrf24j40mc has some amplifier to change the
transmit power, I am currently not sure how the mapping for this
amplifier looks like.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
drivers/net/ieee802154/mrf24j40.c | 70 +++++++++++++++++++++++++++++++++++++++
1 file changed, 70 insertions(+)
diff --git a/drivers/net/ieee802154/mrf24j40.c b/drivers/net/ieee802154/mrf24j40.c
index 00fd97e..e9a03fd 100644
--- a/drivers/net/ieee802154/mrf24j40.c
+++ b/drivers/net/ieee802154/mrf24j40.c
@@ -863,6 +863,65 @@ static int mrf24j40_set_cca_ed_level(struct ieee802154_hw *hw, s32 mbm)
return -EINVAL;
}
+static const s32 mrf24j40ma_powers[] = {
+ 0, -50, -120, -190, -280, -370, -490, -630, -1000, -1050, -1120, -1190,
+ -1280, -1370, -1490, -1630, -2000, -2050, -2120, -2190, -2280, -2370,
+ -2490, -2630, -3000, -3050, -3120, -3190, -3280, -3370, -3490, -3630,
+};
+
+static int mrf24j40_set_txpower(struct ieee802154_hw *hw, s32 mbm)
+{
+ struct mrf24j40 *devrec = hw->priv;
+ s32 small_scale;
+ u8 val;
+
+ if (0 >= mbm && mbm > -1000) {
+ val = 0;
+ small_scale = mbm;
+ } else if (-1000 >= mbm && mbm > -2000) {
+ val = 0x40;
+ small_scale = mbm + 1000;
+ } else if (-2000 >= mbm && mbm > -3000) {
+ val = 0x80;
+ small_scale = mbm + 2000;
+ } else if (-3000 >= mbm && mbm > -4000) {
+ val = 0xc0;
+ small_scale = mbm + 3000;
+ } else {
+ return -EINVAL;
+ }
+
+ switch (small_scale) {
+ case 0:
+ break;
+ case -50:
+ val |= 0x08;
+ break;
+ case -120:
+ val |= 0x10;
+ break;
+ case -190:
+ val |= 0x18;
+ break;
+ case -280:
+ val |= 0x20;
+ break;
+ case -370:
+ val |= 0x28;
+ break;
+ case -490:
+ val |= 0x30;
+ break;
+ case -630:
+ val |= 0x38;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return regmap_update_bits(devrec->regmap_long, REG_RFCON3, 0xf8, val);
+}
+
static const struct ieee802154_ops mrf24j40_ops = {
.owner = THIS_MODULE,
.xmit_async = mrf24j40_tx,
@@ -874,6 +933,7 @@ static const struct ieee802154_ops mrf24j40_ops = {
.set_csma_params = mrf24j40_csma_params,
.set_cca_mode = mrf24j40_set_cca_mode,
.set_cca_ed_level = mrf24j40_set_cca_ed_level,
+ .set_txpower = mrf24j40_set_txpower,
};
static void mrf24j40_intstat_complete(void *context)
@@ -1085,6 +1145,16 @@ static void mrf24j40_phy_setup(struct mrf24j40 *devrec)
devrec->hw->phy->cca_ed_level = -6900;
devrec->hw->phy->supported.cca_ed_levels = mrf24j40_ed_levels;
devrec->hw->phy->supported.cca_ed_levels_size = ARRAY_SIZE(mrf24j40_ed_levels);
+
+ switch (spi_get_device_id(devrec->spi)->driver_data) {
+ case MRF24J40MA:
+ devrec->hw->phy->supported.tx_powers = mrf24j40ma_powers;
+ devrec->hw->phy->supported.tx_powers_size = ARRAY_SIZE(mrf24j40ma_powers);
+ devrec->hw->phy->flags |= WPAN_PHY_FLAG_TXPOWER;
+ break;
+ default:
+ break;
+ }
}
static int mrf24j40_probe(struct spi_device *spi)
--
2.5.0
next prev parent reply other threads:[~2015-08-13 12:23 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-13 12:22 [RFC bluetooth-next 00/21] mrf24j40: async rx/tx handling and new features Alexander Aring
2015-08-13 12:22 ` [RFC bluetooth-next 01/21] mrf24j40: cleanup define identation Alexander Aring
2015-08-27 12:59 ` Stefan Schmidt
2015-08-13 12:22 ` [RFC bluetooth-next 02/21] mrf24j40: use ieee802154_alloc_hw for private data Alexander Aring
2015-08-27 13:03 ` Stefan Schmidt
2015-08-13 12:22 ` [RFC bluetooth-next 03/21] mrf24j40: calling ieee802154_register_hw at last Alexander Aring
2015-08-27 13:06 ` Stefan Schmidt
2015-08-13 12:22 ` [RFC bluetooth-next 04/21] mrf24j40: remove spi settings overwrite Alexander Aring
2015-08-27 13:14 ` Stefan Schmidt
2015-08-28 7:50 ` Alexander Aring
2015-08-28 7:58 ` Stefan Schmidt
2015-08-13 12:22 ` [RFC bluetooth-next 05/21] mrf24j40: add device-tree support Alexander Aring
2015-08-27 13:16 ` Stefan Schmidt
2015-08-13 12:22 ` [RFC bluetooth-next 06/21] mrf24j40: add default channel setting Alexander Aring
2015-08-27 13:24 ` Stefan Schmidt
2015-08-13 12:22 ` [RFC bluetooth-next 07/21] mrf24j40: add random extended addr generation Alexander Aring
2015-08-27 13:25 ` Stefan Schmidt
2015-08-13 12:22 ` [RFC bluetooth-next 08/21] mrf24j40: add more register defines Alexander Aring
2015-08-27 13:28 ` Stefan Schmidt
2015-08-13 12:22 ` [RFC bluetooth-next 09/21] mrf24j40: add regmap support Alexander Aring
2015-08-27 17:45 ` Alexander Aring
2015-08-28 8:37 ` Stefan Schmidt
2015-08-13 12:22 ` [RFC bluetooth-next 10/21] mrf24j40: use regmap for register access Alexander Aring
2015-08-28 8:43 ` Stefan Schmidt
2015-08-13 12:22 ` [RFC bluetooth-next 11/21] mrf24j40: change to frame delivery with crc Alexander Aring
2015-08-27 13:30 ` Stefan Schmidt
2015-08-13 12:22 ` [RFC bluetooth-next 12/21] ieee802154: add helpers for frame control checks Alexander Aring
2015-08-13 12:22 ` [RFC bluetooth-next 13/21] mrf24j40: rework tx handling to async tx handling Alexander Aring
2015-08-28 8:50 ` Stefan Schmidt
2015-08-13 12:22 ` [RFC bluetooth-next 14/21] mrf24j40: rework rx handling to async rx handling Alexander Aring
2015-08-28 8:55 ` Stefan Schmidt
2015-08-13 12:22 ` [RFC bluetooth-next 15/21] mrf24j40: async interrupt handling Alexander Aring
2015-08-28 8:57 ` Stefan Schmidt
2015-08-13 12:22 ` [RFC bluetooth-next 16/21] mrf24j40: add csma params support Alexander Aring
2015-08-27 13:46 ` Stefan Schmidt
2015-08-28 7:53 ` Alexander Aring
2015-08-13 12:22 ` [RFC bluetooth-next 17/21] mrf24j40: add cca mode support Alexander Aring
2015-08-27 13:50 ` Stefan Schmidt
2015-08-27 17:49 ` Alexander Aring
2015-08-13 12:22 ` [RFC bluetooth-next 18/21] mrf24j40: add cca ed level support Alexander Aring
2015-08-27 13:52 ` Stefan Schmidt
2015-08-27 17:44 ` Alexander Aring
2015-08-13 12:22 ` Alexander Aring [this message]
2015-08-27 13:59 ` [RFC bluetooth-next 19/21] mrf24j40: add tx power support Stefan Schmidt
2015-08-13 12:22 ` [RFC bluetooth-next 20/21] mrf24j40: add promiscuous mode support Alexander Aring
2015-08-27 14:00 ` Stefan Schmidt
2015-08-13 12:22 ` [RFC bluetooth-next 21/21] mrf24j40: change irq trigger type behaviour Alexander Aring
2015-08-28 8:28 ` Stefan Schmidt
2015-08-18 13:54 ` [RFC bluetooth-next 00/21] mrf24j40: async rx/tx handling and new features Alan Ott
2015-08-27 12:29 ` Stefan Schmidt
2015-08-27 12:33 ` Alan Ott
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1439468568-22288-20-git-send-email-alex.aring@gmail.com \
--to=alex.aring@gmail.com \
--cc=alan@signal11.us \
--cc=jonatan@myeden.se \
--cc=kernel@pengutronix.de \
--cc=linux-wpan@vger.kernel.org \
--cc=stefan@osg.samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.