From patchwork Tue Sep 6 21:46:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 9317953 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 A52A060760 for ; Tue, 6 Sep 2016 21:46:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA12A28EF5 for ; Tue, 6 Sep 2016 21:46:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9ED3E28F00; Tue, 6 Sep 2016 21:46:43 +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=-4.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 4891528EF5 for ; Tue, 6 Sep 2016 21:46:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932651AbcIFVqm (ORCPT ); Tue, 6 Sep 2016 17:46:42 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:35043 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933490AbcIFVqh (ORCPT ); Tue, 6 Sep 2016 17:46:37 -0400 Received: by mail-wm0-f65.google.com with SMTP id a6so9522440wmc.2; Tue, 06 Sep 2016 14:46:36 -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=S3FvBSN+tbFlP2D3KPEA9AhhlPu6wT41RAdvmoNbhYxEDDYL85djrbH4hm3ErNZG7q nIUG7n8RuRGRZ8cGOKrJ8JxRk8TLuUN8+0LUHIQgjd1ksRdRbwPDSDznvkCvVz7aGMQq 2MEBZLSnKJXaBzdyH3m/6FbWIfaqPbJd443VSkiCrgmdLFdTTiRlUgJH+fcWuZ/55HG4 fql7JbgmyJIaRYSUW3o7bXP4vdusrgG3pPHZzrLwGg1ri1Vl6W/ZOPhv2tngOANPDhcy NVcWNX+5yxMS6l7mUV3wNjUj9b7nqdgKZwSigr4IQY1dmuCh+sQ+RoQjEfPtQf1fgNkB pYNA== 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=cju1Gv7HGMy+x45jTgJppXPBmYwr/X8MFZOtypIip8LOhuW4hqGBo5WcBfCalWkjpU zhZBTVYlHCxbRHHKlpmBMwCrkvOx6S5xMP++wljTLvC2sFpS14hDfVV+71oiJ7thwg+U BcKgL1jq6GB9ZHv8PoKBsHjQyC+CwG6uxkekBGTtYUcAx3guul0qHAYDn4XcV7BwGqaY wpPvE/OoGNm5uGZmyednGHVQpJUAaTpMiRZJTyhJNrf9oK+R7o1gfAyndPqwh7uxprP5 p8zEdKtxDfp3pcJCZvZVOI7i6+fadegsOnAC7DnPRSAcLA4SVQiZy4fu/xAImwzlmGSh lgMg== X-Gm-Message-State: AE9vXwP6KrWVxYOPemQJsIosJZ+tGoA9Y0qDch3QT3auh8lGk4Jns2y67qKo0Af4PfkWUA== X-Received: by 10.28.214.130 with SMTP id n124mr613638wmg.37.1473198395597; Tue, 06 Sep 2016 14:46:35 -0700 (PDT) Received: from blackbox.darklights.net (p5DE38590.dip0.t-ipconnect.de. [93.227.133.144]) by smtp.googlemail.com with ESMTPSA id ex14sm35451113wjc.30.2016.09.06.14.46.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Sep 2016 14:46:34 -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, nbd@nbd.name, Martin Blumenstingl Subject: [PATCH v6 3/3] ath9k: parse the device configuration from an OF node Date: Tue, 6 Sep 2016 23:46:23 +0200 Message-Id: <20160906214623.20424-4-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20160906214623.20424-1-martin.blumenstingl@googlemail.com> References: <20160821143105.27487-1-martin.blumenstingl@googlemail.com> <20160906214623.20424-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;