Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4048175ybi; Mon, 10 Jun 2019 23:41:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqy0teyE5ZodfAb5y9fclN57Tj9TEojTpeYII+4s/bDbUQTMPcWTD4LneS+F5w2vw5uhO0Id X-Received: by 2002:a17:902:30a3:: with SMTP id v32mr75142306plb.6.1560235274398; Mon, 10 Jun 2019 23:41:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560235274; cv=none; d=google.com; s=arc-20160816; b=gTq9oYUWWOajFNZoFqSmsA+bEbGw4YgPRcjCuff6lNC1Bz+j26xz2SFQSQz3KPGXdU O+XCjUrmFdSZNZM9uDtTrbNoi9b5CMdxMdWyRNyDdtqCnCxZ+NgHpNXIGMfSwMMtwZ+W BFiTpjFygkYlS9+szPejCstC4WYU6fDhGPYvs1HLXDgFzvbisPkBa1h232ZkDcqAVsll LBTV5OJwO+lJT1W0/sfu8StXhdtbnV74LWI/y+jHTOKJKFxohpRDG6gDWU/LFw/J6KW9 3JWUx7uWy5P6y/q2iERcRCH0Dxpmsjt0sPbqogdMBxvuS6PxwGojaih23l+vk/7dm9q1 9jJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=F0e9G5GXoXh4vidsOQoDbgEb1hkVH9yCB8g/mX87jTE=; b=sIJR6xhbeENbCjMv3Xk0U5sgDODyM4AWo4RitjvloGSuysbLB/riJln5+6nxoPHApa 09c3dO24nAsDHJiiSfxrsgtgBgyyiQnyQA49Q5mrzP3mgO9u+VYLPKs38WS+P2NqPStQ esLLAfiqWQdtiVvs17HMKWx39j9iB3/minGOjssRkhqGEKhU6FSkZFsijVDXofhhs8st YT7inGqaNuJz/A9Vh5eKIu5jYQWeWBGU8JoF2rGe6URAvm1iNyqxvrFlmwdO8Cl7mcSz 4jGGFIZaRuwKjMwSVWZxt1HkX+O7rRV5KmPfJj4TLLdNf3FX1lOSSZayvp+uP26e4bah bXog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nb3AhmHQ; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b26si11806358pgl.407.2019.06.10.23.40.59; Mon, 10 Jun 2019 23:41:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nb3AhmHQ; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403786AbfFKGjD (ORCPT + 99 others); Tue, 11 Jun 2019 02:39:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:37030 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390485AbfFKGjD (ORCPT ); Tue, 11 Jun 2019 02:39:03 -0400 Received: from localhost.localdomain (unknown [151.66.40.206]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BCC1E2089E; Tue, 11 Jun 2019 06:39:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560235142; bh=NnEMS8VZvTXWr/rwMscqIAAkFrGcBY6jyD5d5phAZFU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nb3AhmHQlFWveS+b9391H4SSKMzCJhNy91ZDVu8ow+npUHfS+drhE9j+AIxP+DXxe BjEZ5cIafGvqp06dYBaAtWbQwh2OdIoDKWgu4rqQTrQkOCjkr23Ir7kNjruWLwaPuD NiNDwi7FiricAWBqBLr6GIr+ErJLH54nh6dJtwW0= From: Lorenzo Bianconi To: nbd@nbd.name Cc: lorenzo.bianconi@redhat.com, linux-wireless@vger.kernel.org, ryder.lee@mediatek.com, royluo@google.com Subject: [PATCH 1/2] mt76: mt7615: init per-channel target power Date: Tue, 11 Jun 2019 08:38:52 +0200 Message-Id: X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Set per-channel target power as the minimum between the regulatory tx power and the value configured in the eeprom Signed-off-by: Lorenzo Bianconi --- .../net/wireless/mediatek/mt76/mt7615/init.c | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/init.c b/drivers/net/wireless/mediatek/mt76/mt7615/init.c index 693e597a3230..3f826e4f1cd6 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/init.c @@ -165,6 +165,46 @@ static int mt7615_init_debugfs(struct mt7615_dev *dev) return 0; } +static void +mt7615_init_txpower(struct mt7615_dev *dev, + struct ieee80211_supported_band *sband) +{ + int i, n_chains = hweight8(dev->mt76.antenna_mask); + u8 *eep = (u8 *)dev->mt76.eeprom.data; + + for (i = 0; i < sband->n_channels; i++) { + struct ieee80211_channel *chan = &sband->channels[i]; + u8 target_power = 0; + int j; + + for (j = 0; j < n_chains; j++) { + int index; + + index = mt7615_eeprom_get_power_index(chan, j); + target_power = max(target_power, eep[index]); + } + + target_power = DIV_ROUND_UP(target_power, 2); + switch (n_chains) { + case 4: + target_power += 6; + break; + case 3: + target_power += 4; + break; + case 2: + target_power += 3; + break; + default: + break; + } + + chan->max_power = min_t(int, chan->max_reg_power, + target_power); + chan->orig_mpwr = target_power; + } +} + int mt7615_register_device(struct mt7615_dev *dev) { struct ieee80211_hw *hw = mt76_hw(dev); @@ -212,6 +252,9 @@ int mt7615_register_device(struct mt7615_dev *dev) if (ret) return ret; + mt7615_init_txpower(dev, &dev->mt76.sband_2g.sband); + mt7615_init_txpower(dev, &dev->mt76.sband_5g.sband); + hw->max_tx_fragments = MT_TXP_MAX_BUF_NUM; return mt7615_init_debugfs(dev); -- 2.21.0