summaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorStefan Schmidt <s.schmidt@samsung.com>2015-05-29 04:51:26 -0400
committerMarcel Holtmann <marcel@holtmann.org>2015-05-31 07:40:53 -0400
commit8702cb0f21905a2a96f61c5106a2c42d41c17999 (patch)
treefd0c68d6e0f4bbbdb7d9342ca5a06ea15c00d445 /drivers/net
parentbdc78737278ee77fdcbccaee5b6f7eda4e0e7602 (diff)
ieee802154/atusb: Add .set_txpower operation to the driver
Atusb uses the at86rf231 transceiver so we can use the same calculation for txpower settings for it. Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com> Reviewed-by: Varka Bhadram <varkabhadram@gmail.com> Acked-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/ieee802154/atusb.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/net/ieee802154/atusb.c b/drivers/net/ieee802154/atusb.c
index 95d42205fd53..9805ebeccd75 100644
--- a/drivers/net/ieee802154/atusb.c
+++ b/drivers/net/ieee802154/atusb.c
@@ -453,6 +453,26 @@ static void atusb_stop(struct ieee802154_hw *hw)
453 atusb_get_and_clear_error(atusb); 453 atusb_get_and_clear_error(atusb);
454} 454}
455 455
456#define ATUSB_MAX_TX_POWERS 0xF
457static const s32 atusb_powers[ATUSB_MAX_TX_POWERS + 1] = {
458 300, 280, 230, 180, 130, 70, 0, -100, -200, -300, -400, -500, -700,
459 -900, -1200, -1700,
460};
461
462static int
463atusb_set_txpower(struct ieee802154_hw *hw, s32 mbm)
464{
465 struct atusb *atusb = hw->priv;
466 u32 i;
467
468 for (i = 0; i < hw->phy->supported.tx_powers_size; i++) {
469 if (hw->phy->supported.tx_powers[i] == mbm)
470 return atusb_write_subreg(atusb, SR_TX_PWR_23X, i);
471 }
472
473 return -EINVAL;
474}
475
456static struct ieee802154_ops atusb_ops = { 476static struct ieee802154_ops atusb_ops = {
457 .owner = THIS_MODULE, 477 .owner = THIS_MODULE,
458 .xmit_async = atusb_xmit, 478 .xmit_async = atusb_xmit,
@@ -461,6 +481,7 @@ static struct ieee802154_ops atusb_ops = {
461 .start = atusb_start, 481 .start = atusb_start,
462 .stop = atusb_stop, 482 .stop = atusb_stop,
463 .set_hw_addr_filt = atusb_set_hw_addr_filt, 483 .set_hw_addr_filt = atusb_set_hw_addr_filt,
484 .set_txpower = atusb_set_txpower,
464}; 485};
465 486
466/* ----- Firmware and chip version information ----------------------------- */ 487/* ----- Firmware and chip version information ----------------------------- */
@@ -581,9 +602,14 @@ static int atusb_probe(struct usb_interface *interface,
581 hw->flags = IEEE802154_HW_TX_OMIT_CKSUM | IEEE802154_HW_AFILT | 602 hw->flags = IEEE802154_HW_TX_OMIT_CKSUM | IEEE802154_HW_AFILT |
582 IEEE802154_HW_AACK; 603 IEEE802154_HW_AACK;
583 604
605 hw->phy->flags = WPAN_PHY_FLAG_TXPOWER;
606
584 hw->phy->current_page = 0; 607 hw->phy->current_page = 0;
585 hw->phy->current_channel = 11; /* reset default */ 608 hw->phy->current_channel = 11; /* reset default */
586 hw->phy->supported.channels[0] = 0x7FFF800; 609 hw->phy->supported.channels[0] = 0x7FFF800;
610 hw->phy->supported.tx_powers = atusb_powers;
611 hw->phy->supported.tx_powers_size = ARRAY_SIZE(atusb_powers);
612 hw->phy->transmit_power = hw->phy->supported.tx_powers[0];
587 ieee802154_random_extended_addr(&hw->phy->perm_extended_addr); 613 ieee802154_random_extended_addr(&hw->phy->perm_extended_addr);
588 614
589 atusb_command(atusb, ATUSB_RF_RESET, 0); 615 atusb_command(atusb, ATUSB_RF_RESET, 0);