From patchwork Sun Oct 16 20:59:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 9378321 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 DF73E608A7 for ; Sun, 16 Oct 2016 20:59:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C964C28BAE for ; Sun, 16 Oct 2016 20:59:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BDD3C28BAF; Sun, 16 Oct 2016 20:59:56 +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.5 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 496BE28BB0 for ; Sun, 16 Oct 2016 20:59:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932209AbcJPU7y (ORCPT ); Sun, 16 Oct 2016 16:59:54 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:35675 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756855AbcJPU7s (ORCPT ); Sun, 16 Oct 2016 16:59:48 -0400 Received: by mail-lf0-f66.google.com with SMTP id x79so23226186lff.2; Sun, 16 Oct 2016 13:59:47 -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=jRzl+iPVp7fhg+PxBuCDWFIuKmqKX7nJRXvj1CW2pUs=; b=lONmTxsdWSeOxZ8yt4T8+3uGn8K5ylMr3KiFykW4DATfk2UgvRX+X23N/mayPA7+uS VtvKMTWDEfXARu6bQv9mOOCcFxyfRyU2+0pgxPlR6A7dFfkiA328EQEGsX1BGX2fA2Zf fodQvO+yKVFSfYVSyfrwhM0lWSWnA0NFY3bNuFaGiIchHvlFDihTZNtgltOTCaphoRxR QRoc/gJgHI3Ib4gSYv+ihE9dXUbZ98hnm7vLBtBgkXcaGxpSwPCVBBQMssdSIMabpm7d QgZkfq9C0PP9SlHpBB+egBFX+3kb1D3UoRrv1CKbHMZ9Iu+GqB8mr8Un3fvMysthQPkT enRA== 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=jRzl+iPVp7fhg+PxBuCDWFIuKmqKX7nJRXvj1CW2pUs=; b=EbJ5Humu6lXQaeDq070gW1ewoWXIjddRPVy1XJOoGRXddSgtfB0/XhmGms2JU+mLtW HYJeq3ukvmQ0+fm0ZThX4ztziS7xGlPjzPS2O0pg8zPqg/hhBYCOmgz/GXH60M95igmT 0jgXvagOTafkvImBaW1IuYRFuCyA8+OmwWLay080Z7KKRrRIxy4seRo3nt9ZETANYJnH zbOxbACs4YUmDjnYjJaNRDWNAGIFN6hxyuG4Ym+nwetPLld6OuXdIreR2rCrmRL+Gz5o 5pckbfoWZB7vrjv2ieMvbBJcC2PdPfAjEi1VDheNPAZYqWOwmfIFoEX3t2lfQxW0+cii jg4g== X-Gm-Message-State: AA6/9RkWkq6iAqhA4rbGjMQQP41IlwrySeqfm/iCvhxcxC4VI7NY1NH4345X5URuVqNkww== X-Received: by 10.28.175.2 with SMTP id y2mr6502358wme.106.1476651586653; Sun, 16 Oct 2016 13:59:46 -0700 (PDT) Received: from blackbox.darklights.net (p5DE38391.dip0.t-ipconnect.de. [93.227.131.145]) by smtp.googlemail.com with ESMTPSA id a1sm46106784wju.41.2016.10.16.13.59.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 16 Oct 2016 13:59:45 -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, robh+dt@kernel.org Cc: mcgrof@do-not-panic.com, mark.rutland@arm.com, 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 v8 3/3] ath9k: parse the device configuration from an OF node Date: Sun, 16 Oct 2016 22:59:07 +0200 Message-Id: <20161016205907.19927-4-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20161016205907.19927-1-martin.blumenstingl@googlemail.com> References: <20161002214743.2263-1-martin.blumenstingl@googlemail.com> <20161016205907.19927-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 setting the MAC address and specifying that the firmware will be requested from userspace (because there might not be a hardware EEPROM connected to the chip) for ath9k based PCI devices using the device tree. 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 | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c index cfa3fe8..b7c8ff9 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,42 @@ 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,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 +649,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;