From patchwork Sun Aug 21 14:49:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 9292197 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9372D600CB for ; Sun, 21 Aug 2016 14:49:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84F6F281D2 for ; Sun, 21 Aug 2016 14:49:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 797DA28657; Sun, 21 Aug 2016 14:49:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B8B0281D2 for ; Sun, 21 Aug 2016 14:49:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753306AbcHUOtf (ORCPT ); Sun, 21 Aug 2016 10:49:35 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:33773 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753290AbcHUOtc (ORCPT ); Sun, 21 Aug 2016 10:49:32 -0400 Received: by mail-wm0-f67.google.com with SMTP id o80so9894330wme.0; Sun, 21 Aug 2016 07:49:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/FIcfrs99hl3ODXzzx1mCOZxnEtIzUJg8lJi48R3lEQ=; b=RWqQNCHSj6yGL53UT7olkBjHMS4bcQKmMZZK7wX29tsxkPGbwQ5mWEljeb29GYaiaq fQGTImDlb23nCNrHBbb2DmEmiW1CrZMmx/ZRlXrLblBQeiKSd3Hl/wvtLb6XeruPsO9y EhcLLGZzfJ2dFMMly9B6gd6dki4NlEeEhUnJ6WeSCqBVePCJCxnuBMtInfWYuZB1RRil cQPBun+/Ss01/L4Tpd8/mcuK1wRZAxORUcfOPY8LOGaQ+dAKs/qm/Rm0kqcZLfZEF/xZ pDJ+sf/vk+kGEkGyI5f+4hrEg+yybfs2sGdAV3InfoVTgE2rV1VVseYjaj2S9YKvVGHI aG6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/FIcfrs99hl3ODXzzx1mCOZxnEtIzUJg8lJi48R3lEQ=; b=HBRgBKfF++5xDaZrT250kmtY3BVxFpP+dau+ClkQ3lPl3mc51WufLSg/gtksF+/nEa nte6aSK8J3W3r2KNAQxdCppjOVnP6NTjizcT84W+kdAr8Yl9hCKAmuP50OabBz9ZaN9u gh8avAZ8AtIo1M4XHGwuqvwdvp8xRkqrBw70tEGmnl574Op8rMcTbX20mLWSsgWwBhxn Rb5RdNKGoG2RekVxE9sNcYoHgOVMjlpBhLXJtZBPwf6Ii353SIkS46+NCm9Mz4iSp0s4 AS2ILCUOgYxw9YWRaLG2Z3tHVJYfjjU0YtqWeb2BUX8BtQp0w+uTzdfyXRqjdD8jV5iC vVAw== X-Gm-Message-State: AEkoouujvCxTK9ak++CJQ/iDKiBRYKzA676fcWHSfZuV+G1aEZ0GX/1/CmahaQNaNeVwSg== X-Received: by 10.194.120.164 with SMTP id ld4mr13846949wjb.81.1471790971118; Sun, 21 Aug 2016 07:49:31 -0700 (PDT) Received: from blackbox.darklights.net (p5DE388BA.dip0.t-ipconnect.de. [93.227.136.186]) by smtp.googlemail.com with ESMTPSA id c16sm15581351wme.4.2016.08.21.07.49.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Aug 2016 07:49:30 -0700 (PDT) From: Martin Blumenstingl To: kvalo@codeaurora.org, ath9k-devel@qca.qualcomm.com, linux-wireless@vger.kernel.org, ath9k-devel@lists.ath9k.org, devicetree@vger.kernel.org Cc: robh+dt@kernel.org, mark.rutland@arm.com, arnd@arndb.de, chunkeey@googlemail.com, nbd@nbd.name, Martin Blumenstingl Subject: [PATCH 5/5] ath9k: Make EEPROM endianness swapping configurable via devicetree Date: Sun, 21 Aug 2016 16:49:06 +0200 Message-Id: <20160821144906.30984-6-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20160821144906.30984-1-martin.blumenstingl@googlemail.com> References: <20160821144906.30984-1-martin.blumenstingl@googlemail.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The endianness swapping is disabled by default since many devices have EEPROMs with incorrect endianness magic bytes (at the beginning). Devices where the EEPROM is known to indicate the correct endianness can enable the new flag to enable swapping when required. This behavior is consistent with ath9k_platform_data where the endian check also has to be enabled explicitly. --- .../devicetree/bindings/net/wireless/qca,ath9k.txt | 16 ++++++++++++++++ drivers/net/wireless/ath/ath9k/init.c | 6 +++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/net/wireless/qca,ath9k.txt b/Documentation/devicetree/bindings/net/wireless/qca,ath9k.txt index 98065ad..05c54c4 100644 --- a/Documentation/devicetree/bindings/net/wireless/qca,ath9k.txt +++ b/Documentation/devicetree/bindings/net/wireless/qca,ath9k.txt @@ -17,6 +17,22 @@ Optional properties: ath9k wireless chip (in this case the calibration / EEPROM data will be loaded from userspace using the kernel firmware loader). +- qca,check-eeprom-endianness: When enabled, the driver checks if the + endianness of the EEPROM (using two checks, + one is based on the two magic bytes at the + start of the EEPROM and a second one which + relies on a flag within the EEPROM data) + matches the host system's native endianness. + The data will be swapped accordingly if there + is a mismatch. + Leaving this disabled means that the EEPROM + data will always be interpreted in the + system's native endianness. + Enable this option only when the EEPROMs + endianness identifiers are known to be + correct, because otherwise the EEPROM data + may be swapped and thus interpreted + incorrectly. - qca,disable-2ghz: Overrides the settings from the EEPROM and disables the 2.4GHz band. Setting this property is only needed when the RF circuit does not support the 2.4GHz band diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c index c123145..d123977 100644 --- a/drivers/net/wireless/ath/ath9k/init.c +++ b/drivers/net/wireless/ath/ath9k/init.c @@ -581,6 +581,11 @@ static int ath9k_of_init(struct ath_softc *sc) if (of_property_read_bool(np, "qca,disable-5ghz")) ah->disable_5ghz = true; + if (of_property_read_bool(np, "qca,check-eeprom-endianness")) + ah->ah_flags &= ~AH_NO_EEP_SWAP; + else + ah->ah_flags |= AH_NO_EEP_SWAP; + if (of_property_read_bool(np, "qca,no-eeprom")) { /* ath9k-eeprom--.bin */ scnprintf(eeprom_name, sizeof(eeprom_name), @@ -597,7 +602,6 @@ static int ath9k_of_init(struct ath_softc *sc) ether_addr_copy(common->macaddr, mac); ah->ah_flags &= ~AH_USE_EEPROM; - ah->ah_flags |= AH_NO_EEP_SWAP; return 0; }