From patchwork Sun Aug 21 14:31:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 9292183 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 A4B0660574 for ; Sun, 21 Aug 2016 14:31:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9653628851 for ; Sun, 21 Aug 2016 14:31:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8AE952887C; Sun, 21 Aug 2016 14:31:32 +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 3278828851 for ; Sun, 21 Aug 2016 14:31:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753245AbcHUObb (ORCPT ); Sun, 21 Aug 2016 10:31:31 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:34665 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752464AbcHUOb3 (ORCPT ); Sun, 21 Aug 2016 10:31:29 -0400 Received: by mail-wm0-f67.google.com with SMTP id q128so9852669wma.1; Sun, 21 Aug 2016 07:31:28 -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=pXzNynTLyaXKIT4ZbAT75tGRWZbsSY+XmTf1eM2F9UQ=; b=WA+yWHd8YaDLymJc/xGThCOU/BQDRLJVCNvBdtrD08XKFG3H2prv2641s/pErOGp3E KNV+1vIxamJ73+hqa0v51BAqWX5AXjc7v6lBga86201cJTzUN7BmOBQp2tOAuaocM/yc F7AxUzljQGlgfNZkLNpPfCLdRzMVV3B4CU6OtbqN6nKqUUMwhg/i5OoB24tlzKzx2jEN 5S4UJev1ehBSA/mTP5CGzgCfT/9IaC1Gp9fpsjIprmZ97VFoa7IgED6RsFGuH+Sv/ojw i4BSwdZYUcYWjQNzNgg9oCYVa3MxmKk+hVdJtg3FSz+QwafzTUpbbRGyrvHSyfOrOT5Y S+aA== 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=pXzNynTLyaXKIT4ZbAT75tGRWZbsSY+XmTf1eM2F9UQ=; b=kVoLm0owUHzDU2e/qc3NhhjHktFzP3md1goUpdiEZOHBuFj5C0e1W7Z2KcgcLAyaF/ Z2bgDEZWRtlgb6WdYkD6aZs7Tx47XPKKrISPHWEpFXwkgq8OlZuqLfmn8WV32G2CqBF1 PDwOglBO0/nXsJzf6COo5yVbG0XlOAC7tQEes06i6sE+vtUWP4ZStaIl3l0cuwuSHOrE MliNO928Nwb2kmDiNitB507kLlYmNslFWp+T2FGHfurrXlcFrTRrvU2yhH6qcSy6B5G6 M2SzeuKtJ/hISaQrXsm5nvdjZKfnJUnmefiykj9WZYy7Ur8zPttOBtONODtyjoQMkxRL 2YZg== X-Gm-Message-State: AEkoouvpR9qoUqsySc58oGmbAjxqD6x3r/tTtwRk57S5RsBDG/o0kQiEBTv5mcaUuR99KQ== X-Received: by 10.28.134.14 with SMTP id i14mr11011781wmd.59.1471789887615; Sun, 21 Aug 2016 07:31:27 -0700 (PDT) Received: from blackbox.darklights.net (p5DE388BA.dip0.t-ipconnect.de. [93.227.136.186]) by smtp.googlemail.com with ESMTPSA id d7sm18119527wjg.13.2016.08.21.07.31.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Aug 2016 07:31:26 -0700 (PDT) From: Martin Blumenstingl To: ath9k-devel@lists.ath9k.org, devicetree@vger.kernel.org, linux-wireless@vger.kernel.org, ath9k-devel@qca.qualcomm.com Cc: mcgrof@do-not-panic.com, mark.rutland@arm.com, robh+dt@kernel.org, kvalo@codeaurora.org, chunkeey@googlemail.com, arend.vanspriel@broadcom.com, julian.calaby@gmail.com, bjorn@mork.no, linux@rempel-privat.de, Martin Blumenstingl Subject: [PATCH v5 3/3] ath9k: parse the device configuration from an OF node Date: Sun, 21 Aug 2016 16:31:05 +0200 Message-Id: <20160821143105.27487-4-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20160821143105.27487-1-martin.blumenstingl@googlemail.com> References: <20160709232834.31654-1-martin.blumenstingl@googlemail.com> <20160821143105.27487-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 This allows configuring ath9k based PCI devices using devicetree. There is some out-of-tree code to "convert devicetree to ath9k_platform_data" (for example in OpenWrt and LEDE) which becomes obsolete with this patch. Signed-off-by: Martin Blumenstingl --- drivers/net/wireless/ath/ath9k/init.c | 51 +++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c index cfa3fe8..c123145 100644 --- a/drivers/net/wireless/ath/ath9k/init.c +++ b/drivers/net/wireless/ath/ath9k/init.c @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include #include @@ -555,6 +557,51 @@ static int ath9k_init_platform(struct ath_softc *sc) return 0; } +static int ath9k_of_init(struct ath_softc *sc) +{ + struct device_node *np = sc->dev->of_node; + struct ath_hw *ah = sc->sc_ah; + struct ath_common *common = ath9k_hw_common(ah); + enum ath_bus_type bus_type = common->bus_ops->ath_bus_type; + const char *mac; + char eeprom_name[100]; + int ret; + + if (!of_device_is_available(np)) + return 0; + + ath_dbg(common, CONFIG, "parsing configuration from OF node\n"); + + if (of_property_read_bool(np, "qca,clk-25mhz")) + ah->is_clk_25mhz = true; + + if (of_property_read_bool(np, "qca,disable-2ghz")) + ah->disable_2ghz = true; + + if (of_property_read_bool(np, "qca,disable-5ghz")) + ah->disable_5ghz = true; + + if (of_property_read_bool(np, "qca,no-eeprom")) { + /* ath9k-eeprom--.bin */ + scnprintf(eeprom_name, sizeof(eeprom_name), + "ath9k-eeprom-%s-%s.bin", + ath_bus_type_to_string(bus_type), dev_name(ah->dev)); + + ret = ath9k_eeprom_request(sc, eeprom_name); + if (ret) + return ret; + } + + mac = of_get_mac_address(np); + if (mac) + ether_addr_copy(common->macaddr, mac); + + ah->ah_flags &= ~AH_USE_EEPROM; + ah->ah_flags |= AH_NO_EEP_SWAP; + + return 0; +} + static int ath9k_init_softc(u16 devid, struct ath_softc *sc, const struct ath_bus_ops *bus_ops) { @@ -611,6 +658,10 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc, if (ret) return ret; + ret = ath9k_of_init(sc); + if (ret) + return ret; + if (ath9k_led_active_high != -1) ah->config.led_active_high = ath9k_led_active_high == 1;