From patchwork Sat Jul 9 23:28:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 9222193 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 C74DC6089D for ; Sat, 9 Jul 2016 23:29:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B647C28466 for ; Sat, 9 Jul 2016 23:29:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AAE1B28471; Sat, 9 Jul 2016 23:29:00 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 4CC0B28466 for ; Sat, 9 Jul 2016 23:29:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933238AbcGIX27 (ORCPT ); Sat, 9 Jul 2016 19:28:59 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:34836 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933099AbcGIX2z (ORCPT ); Sat, 9 Jul 2016 19:28:55 -0400 Received: by mail-wm0-f67.google.com with SMTP id k123so12148945wme.2; Sat, 09 Jul 2016 16:28:55 -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=YDDeV2DCP5Hqg4aNk1J7l+fmZ7SsywCH8u2xArcZI6E=; b=U+xZa/1K2m/KWOA5FamJZG8Dyex7QJd21qDr5Q5+QCZXtKWFsB34frthXE0GKmRMYE 3ky05+7ELTu4wG9IRMANjFt7meK+dCzcH1f8EfaOXrEVihG045BXWYILurmOlQ5z7hHV Y0Lid77G/37U88t+sCOhBHPZm0pYxoDVIg5o2n2n0qiaWsQcGWjI8aJsBR+E/dsDMa/T w4mR8uhcqIrNN8XKI0i7g0aju/kTx9ASxhqeDN/fWiVKUUskkSFRmpeCim2jWVmY4Shl bcdKi3UTgCmW/iTEmGw4cGN0oy1uJXN8JSzHWzRa9JbYnRhJbsIdhBHNUX0FD4QsVpab sUAQ== 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=YDDeV2DCP5Hqg4aNk1J7l+fmZ7SsywCH8u2xArcZI6E=; b=SU16IltmjVGEtQcPmUAiTcaj1D9CgFqXy1D7OZcUgH+l8HJslaiVI33OmdP/F8izhq pIjn2aBwnbtxpmYRi0/N8Ji1jeIbB//Hk82KRQTAWx5xq/DG094HPDzdOX3YFTa9vlBD 6nbmJRuLvggBKWaT/DKeirfP8sd+DNsnA+d8NBQSB38btf2BTE9SLDz2Ch+V5+UL1gby xO15/m8+ztZ/qdigU63dtcBVZa0nBn+9PBKp5K097BYbViBdHCh9Fr9908yzHGCfJAKR h7Ye8L+j4bhoASn4DbubTiCZfTfBvBRwe9hLuRFbC+XPiJRBmMg4aQQx6KjXGjK0yAkp 6Z4A== X-Gm-Message-State: ALyK8tL2t7ZDqmyDpYPTM4gLd74vNrExNfmFJ0jaAK0XNnlljZ6pv0G1GawcxPXblkiVMQ== X-Received: by 10.28.113.151 with SMTP id d23mr4812575wmi.89.1468106934329; Sat, 09 Jul 2016 16:28:54 -0700 (PDT) Received: from blackbox.darklights.net (p5DE38945.dip0.t-ipconnect.de. [93.227.137.69]) by smtp.googlemail.com with ESMTPSA id r127sm10009891wmf.21.2016.07.09.16.28.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Jul 2016 16:28:53 -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, galak@codeaurora.org, ijc+devicetree@hellion.org.uk, mark.rutland@arm.com, pawel.moll@arm.com, robh+dt@kernel.org, kvalo@codeaurora.org, chunkeey@googlemail.com, arend.vanspriel@broadcom.com, julian.calaby@gmail.com, Martin Blumenstingl Subject: [PATCH v4 3/3] ath9k: parse the device configuration from an OF node Date: Sun, 10 Jul 2016 01:28:34 +0200 Message-Id: <20160709232834.31654-4-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160709232834.31654-1-martin.blumenstingl@googlemail.com> References: <20160624123430.4097-1-martin.blumenstingl@googlemail.com> <20160709232834.31654-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 makes it possible to configure ath9k based devices using devicetree. That makes some out-of-tree "convert devicetree to ath9k_platform_data glue"-code obsolete. Signed-off-by: Martin Blumenstingl --- drivers/net/wireless/ath/ath9k/init.c | 55 +++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c index edc74fc..9dd7ed5 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,55 @@ 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,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), + "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; + + return 0; +} + static int ath9k_init_softc(u16 devid, struct ath_softc *sc, const struct ath_bus_ops *bus_ops) { @@ -611,6 +662,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;