From patchwork Thu Aug 27 18:19:20 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?G=C3=A1bor_Stefanik?= X-Patchwork-Id: 44310 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n7RIJRbr025074 for ; Thu, 27 Aug 2009 18:19:27 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752365AbZH0STY (ORCPT ); Thu, 27 Aug 2009 14:19:24 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752403AbZH0STY (ORCPT ); Thu, 27 Aug 2009 14:19:24 -0400 Received: from mail-ew0-f206.google.com ([209.85.219.206]:65358 "EHLO mail-ew0-f206.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752207AbZH0STX (ORCPT ); Thu, 27 Aug 2009 14:19:23 -0400 Received: by ewy2 with SMTP id 2so1467812ewy.17 for ; Thu, 27 Aug 2009 11:19:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:content-type :content-transfer-encoding; bh=rvRT5+h+6sdNMTZ6wGkH5RFu3lQAw8mhbEo1Vq0q2L4=; b=pquJXf3gTEHgmFL6HO0qXtMfMZAuG7ZxRHnD7bSvFxeaEEUu54GjY6dWHj+1HpJNCH 4mbNdd0T7KVI9gpvs42zX+GKR503VSSRvzCXt4uVW9lYRwt4nv4nLx6+cR+g1SeaFycx tHKCqepCge8GolioA052zLTp1DZZbt2L/iRpA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; b=TV4TABLQU7crznsnyEDs44J1fZufHRaRNEtRmpg1pVUzNXLaQ2kmC/F9plZBPbWtvU PslUM9/DnEtdOB6UQ6JYJc0s9UkP5wDLOtN208O/4xzYBTUvtOitNSyrJ6pgsN65R1k7 TmSaeCCnWu9nYQBgoifU5Ul133W/Ethd1SV2I= Received: by 10.211.146.17 with SMTP id y17mr7514ebn.43.1251397161442; Thu, 27 Aug 2009 11:19:21 -0700 (PDT) Received: from ?192.168.1.3? (pool-04a14.externet.hu [88.209.246.19]) by mx.google.com with ESMTPS id 24sm74710eyx.44.2009.08.27.11.19.19 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 27 Aug 2009 11:19:21 -0700 (PDT) Message-ID: <4A96CE28.3040800@gmail.com> Date: Thu, 27 Aug 2009 20:19:20 +0200 From: =?UTF-8?B?R8OhYm9yIFN0ZWZhbmlr?= User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: John Linville , Michael Buesch , Larry Finger , Mark Huijgen CC: Broadcom Wireless , linux-wireless Subject: [RFC/RFT] b43: Implement antenna diversity support for LP-PHY Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Signed-off-by: Gábor Stefanik --- This intentionally deviates slightly from the spec (writing the antenna ID in one pass instead of two) - please test if this works. (I don't have the tools to test if it actually selects the right antenna.) The A/G-PHY changes are fallout fixes from the enum change, which in turn allows the LP-PHY code to be much simpler. The antenna_to_phyctl change is a fix for a potential existing bug that this patch may otherwise trigger. drivers/net/wireless/b43/main.c | 3 ++- drivers/net/wireless/b43/phy_a.c | 2 +- drivers/net/wireless/b43/phy_common.h | 10 +++++----- drivers/net/wireless/b43/phy_g.c | 2 +- drivers/net/wireless/b43/phy_lp.c | 11 ++++++++++- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c index 289e06c..3b038c9 100644 --- a/drivers/net/wireless/b43/main.c +++ b/drivers/net/wireless/b43/main.c @@ -1456,7 +1456,8 @@ static u16 b43_antenna_to_phyctl(int antenna) return B43_TXH_PHY_ANT2; case B43_ANTENNA3: return B43_TXH_PHY_ANT3; - case B43_ANTENNA_AUTO: + case B43_ANTENNA_AUTO0: + case B43_ANTENNA_AUTO1: return B43_TXH_PHY_ANT01AUTO; } B43_WARN_ON(1); diff --git a/drivers/net/wireless/b43/phy_a.c b/drivers/net/wireless/b43/phy_a.c index 816e028..809ec97 100644 --- a/drivers/net/wireless/b43/phy_a.c +++ b/drivers/net/wireless/b43/phy_a.c @@ -531,7 +531,7 @@ static void b43_aphy_op_set_rx_antenna(struct b43_wldev *dev, int antenna) tmp = b43_phy_read(dev, B43_PHY_BBANDCFG); tmp &= ~B43_PHY_BBANDCFG_RXANT; - tmp |= (autodiv ? B43_ANTENNA_AUTO0 : antenna) + tmp |= (autodiv ? B43_ANTENNA_AUTO1 : antenna) << B43_PHY_BBANDCFG_RXANT_SHIFT; b43_phy_write(dev, B43_PHY_BBANDCFG, tmp); diff --git a/drivers/net/wireless/b43/phy_common.h b/drivers/net/wireless/b43/phy_common.h index b47a0f5..a6a90df 100644 --- a/drivers/net/wireless/b43/phy_common.h +++ b/drivers/net/wireless/b43/phy_common.h @@ -49,11 +49,11 @@ enum b43_interference_mitigation { /* Antenna identifiers */ enum { - B43_ANTENNA0, /* Antenna 0 */ - B43_ANTENNA1, /* Antenna 0 */ - B43_ANTENNA_AUTO1, /* Automatic, starting with antenna 1 */ - B43_ANTENNA_AUTO0, /* Automatic, starting with antenna 0 */ - B43_ANTENNA2, + B43_ANTENNA0 = 0, /* Antenna 0 */ + B43_ANTENNA1 = 1, /* Antenna 1 */ + B43_ANTENNA_AUTO0 = 2, /* Automatic, starting with antenna 0 */ + B43_ANTENNA_AUTO1 = 3, /* Automatic, starting with antenna 1 */ + B43_ANTENNA2 = 4, B43_ANTENNA3 = 8, B43_ANTENNA_AUTO = B43_ANTENNA_AUTO0, diff --git a/drivers/net/wireless/b43/phy_g.c b/drivers/net/wireless/b43/phy_g.c index c6c9d2f..c6d639d 100644 --- a/drivers/net/wireless/b43/phy_g.c +++ b/drivers/net/wireless/b43/phy_g.c @@ -2651,7 +2651,7 @@ static void b43_gphy_op_set_rx_antenna(struct b43_wldev *dev, int antenna) tmp = b43_phy_read(dev, B43_PHY_BBANDCFG); tmp &= ~B43_PHY_BBANDCFG_RXANT; - tmp |= (autodiv ? B43_ANTENNA_AUTO0 : antenna) + tmp |= (autodiv ? B43_ANTENNA_AUTO1 : antenna) << B43_PHY_BBANDCFG_RXANT_SHIFT; b43_phy_write(dev, B43_PHY_BBANDCFG, tmp); diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c index 837d952..457357a 100644 --- a/drivers/net/wireless/b43/phy_lp.c +++ b/drivers/net/wireless/b43/phy_lp.c @@ -2204,7 +2204,16 @@ static int b43_lpphy_op_init(struct b43_wldev *dev) static void b43_lpphy_op_set_rx_antenna(struct b43_wldev *dev, int antenna) { - //TODO + int autodiv = ; + + if (dev->phy.rev >= 2) + return; // rev2+ doesn't support antenna diversity + + if (B43_WARN_ON(antenna > B43_ANTENNA_AUTO1)) + return; + + /* NOTE: The spec breaks this up into 2 writes - please test */ + b43_phy_maskset(dev, B43_LPPHY_CRSGAIN_CTL, 0xFFFC, antenna); } static void b43_lpphy_op_adjust_txpower(struct b43_wldev *dev)