From patchwork Sun Oct 2 21:47:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 9359803 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 9779E608A6 for ; Sun, 2 Oct 2016 21:48:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8EB9928A64 for ; Sun, 2 Oct 2016 21:48:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8394028A66; Sun, 2 Oct 2016 21:48: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.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 5E18328A65 for ; Sun, 2 Oct 2016 21:47:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750822AbcJBVr5 (ORCPT ); Sun, 2 Oct 2016 17:47:57 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:34254 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751501AbcJBVry (ORCPT ); Sun, 2 Oct 2016 17:47:54 -0400 Received: by mail-wm0-f67.google.com with SMTP id b201so6753421wmb.1; Sun, 02 Oct 2016 14:47:53 -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=f/1xE4OLp7QsvwsxDVQEks7hyAERYo36O2ze0rVh6KHNNHsk6VOcdxha+VyR6QzcLk gg/X6b2ZrAcKQYu8laF+YqdIgBe3L3b+5NxhHaF36xQp+CdHIdoHSdyDQYYHL9Uf1+9Q q8tscMpeLjiqIStCq/GKIcvq+KE2jBAeQU2WlSoDZEg/YlJBwpt77Q8qFLpMycDHcLvH Vn3483x2TEuZayJavoDO2/VmiJXrO1RF5J4SkTh0LQJsehsaxPgfyrxdPFeRhqtlxJ+k KEOkzGVVhuFLUdSeFu4+mDLSSEAn9lK8lxp/PmnLAgr61xwOTW2wzbT8d/AMF+F/aIh0 c8yw== 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=EuUb1aKRpKLAeB1UGs7HYAWS746teP9QdUBlrH5/MbP4qkuLEO/Pi/GZT96EnCaNpw OLutPMaBPwejx/WFBE1DbwnbjShZaBMxmAl/q1htnbwMfBnVDSefWjQCBdYyA0xw+wOT cppBi0sFGD53JYJoNXK806tOhuHz2Qe0T+sMXuX6rNasu0QPnN3Xw/LXJApnScdLjrFN YtQ1QnvM9chBgKT7AhtS9Q8w+qMdGSRH+wrcvSHADAuD9MJyyrXfqs6PZXgWxOYHg9D2 +qsY50OgVBKgg3ixYTNVybu1gJ41ipDJ2Tg0GY4VdwMW/iZuoebO1E77bO5d62r6wSHR 3+PQ== X-Gm-Message-State: AA6/9Rmz7yZGUF+gc4oduuAVk/oBo+FiN7VVwqBmZyIHtcEQ/1wKh+mqS0nJNgP/Q8abAA== X-Received: by 10.28.232.84 with SMTP id f81mr7692799wmh.39.1475444872752; Sun, 02 Oct 2016 14:47:52 -0700 (PDT) Received: from blackbox.darklights.net (p200300DCD3D4610440DF0B34A14E22AB.dip0.t-ipconnect.de. [2003:dc:d3d4:6104:40df:b34:a14e:22ab]) by smtp.googlemail.com with ESMTPSA id e187sm15702064wma.21.2016.10.02.14.47.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Oct 2016 14:47:51 -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 v7 3/3] ath9k: parse the device configuration from an OF node Date: Sun, 2 Oct 2016 23:47:43 +0200 Message-Id: <20161002214743.2263-4-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20161002214743.2263-1-martin.blumenstingl@googlemail.com> References: <20160906214623.20424-1-martin.blumenstingl@googlemail.com> <20161002214743.2263-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;