From patchwork Thu Apr 8 11:30:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 417413 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp468083jai; Thu, 8 Apr 2021 04:30:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/NgPEkxY89oYJ7DYnqfbMr48FJu+Cix8ydV5vibRM+ZFEvCde+8nrXUJ+ilB10akQAjj8 X-Received: by 2002:a17:906:af09:: with SMTP id lx9mr9952017ejb.58.1617881444966; Thu, 08 Apr 2021 04:30:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617881444; cv=none; d=google.com; s=arc-20160816; b=FmhZ0KrK6h1KB0qxx4IwiLULaTfHLiC2+i4TwukmjNrevhI75oJx0AbrAPIE3lbt/j Q8iafVdXgCQF0xdM1LE3yYoRyvDlFj+ukwcCPJ2+vX9MZYKEdlCuEfq9CIrnQ+kIfVoT 0APUNT6Jr8dAXczgMmXP0YWOkoFj5XCaczgswXOi+gR4uLWlOBw0ee9ucW2QEQCfqPMm RmrfpryQygLxGU0TV+HsB/FrjkQpgWjmeMCtDValOtjTiEvwxy+/hWg9LEtNs1bASL83 ZBjZOOJBxINIgXq3yiC2zKQ6F12wfRjz5K3vjmQoMywxackh5Iaa+8h52X0XQunBu6eR fmfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=HFkQVg2sWZMIrKtGQV1AJb0w7icp+ZqdTBHv4nvPanw=; b=I/acEgCUOFk9jzw3ke9OmYFlM+F4gPFUlM2LW3bAzP77iIonm0HglPygCXCeonNbjt NhghtjWiZvLBmjMgNFPsNB1McITbASGVD0aOkckhp+rrFiqqYUxz+PiKioHWh5cue1aH 2zOcCNsYAbrFblSCE8JWk9iGNeY3xqCYJLnfl3jWjHI6ieCDtvBOgDmu1M8pV2h7YR8P yC31rGiP1AY1x1WbXblIG7GX+Xlbvh8CRdkXB2OYVZKksAsIm/RRq1vvfSYcCmNy77QV vfq26uUrZd9AKkRAGCS7+LGYIGE+dFgalw11Td415MxVdWTthI3XS07Mulzs/XVgVhsH nKew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="LmuFVG/w"; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y13si2466524edp.165.2021.04.08.04.30.44; Thu, 08 Apr 2021 04:30:44 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="LmuFVG/w"; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230443AbhDHLaz (ORCPT + 6 others); Thu, 8 Apr 2021 07:30:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231152AbhDHLay (ORCPT ); Thu, 8 Apr 2021 07:30:54 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CABBBC061761 for ; Thu, 8 Apr 2021 04:30:43 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id d8so871268plh.11 for ; Thu, 08 Apr 2021 04:30:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HFkQVg2sWZMIrKtGQV1AJb0w7icp+ZqdTBHv4nvPanw=; b=LmuFVG/w9xpRWNtvDT4ojWVfUpuqmOetuIzsLuSAtFySN347ImRJYrGZQ4fZQP1u25 ikG5+5xtkCZa8AN9TNVUPlRbXhDbqxL/T086wcXYBDrxG1pw69oJTPPUkK2PgJ22m82T yoH+XPxmYm33F3EaRQcwgw0s7tu3xHSA+I4P4GQTwebvkEQlVg2esh0Asvp8x5ZZlRHs ZefwCd5BCMqLYBzoW+ExsD7hK9TYDkpz+lurhr3k3oMenWfdtGy47YHHPjmTHCuQ/f9q 6p3WY9Bo5wLQ7yKzvHstUw3vRFTAqzB3OueUNendvaocTBjLsaP2mzzIWQPgosFKAzHr 7mgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HFkQVg2sWZMIrKtGQV1AJb0w7icp+ZqdTBHv4nvPanw=; b=nu4D0xAc/4agev8a0aIMXlr1FLN9nzctJKpcRu2N9rFVJszDCrLsM+/b3pfKTICRzV ik35gAfeqCyrnwcTZmaDoawNatVGzjCpKdpw5Dwn3RMXSTgUF5dnAEyzUvrHNK3YrnhD QojIV+UTAioso6pzyNXzBFadlbJsx/D+M82jg0qs6aEtLTO3W42LDt7E9uqkXhcr4TGz oKTqSlvzaBg/hB3LGqArEM/4s8DDGe3KmJTRzLP6jPUFykDFGf7KIPjykDS7fMq3/QkH 6jZCVO9pRCUrrqCohwKCQgxiYq+kwHPvGoYCJJ0sO396MHP0PYLX7bJmaZVi0Bnz4E1a 45HA== X-Gm-Message-State: AOAM531NtXdH6hjZWMR6sXyotLwOl1Z8wONEoCdNT/Cf1Z7LxI85b7o1 tubeCfOsinb6FN59dBI682r+Zg== X-Received: by 2002:a17:902:904b:b029:e5:5cc5:877d with SMTP id w11-20020a170902904bb02900e55cc5877dmr7556967plz.50.1617881443425; Thu, 08 Apr 2021 04:30:43 -0700 (PDT) Received: from localhost.localdomain (80.251.214.228.16clouds.com. [80.251.214.228]) by smtp.gmail.com with ESMTPSA id x18sm7753267pfi.105.2021.04.08.04.30.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 04:30:43 -0700 (PDT) From: Shawn Guo To: Kalle Valo Cc: Rob Herring , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Arend van Spriel , Franky Lin , Hante Meuleman , Chi-hsien Lin , Wright Feng , Chung-hsien Hsu , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, SHA-cyfmac-dev-list@infineon.com, Shawn Guo Subject: [PATCH 1/2] dt-binding: bcm43xx-fmac: add optional brcm,ccode-map Date: Thu, 8 Apr 2021 19:30:21 +0800 Message-Id: <20210408113022.18180-2-shawn.guo@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210408113022.18180-1-shawn.guo@linaro.org> References: <20210408113022.18180-1-shawn.guo@linaro.org> Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add optional brcm,ccode-map property to support translation from ISO3166 country code to brcmfmac firmware country code and revision. Signed-off-by: Shawn Guo --- .../devicetree/bindings/net/wireless/brcm,bcm43xx-fmac.txt | 7 +++++++ 1 file changed, 7 insertions(+) -- 2.17.1 Reviewed-by: Arend van Spriel diff --git a/Documentation/devicetree/bindings/net/wireless/brcm,bcm43xx-fmac.txt b/Documentation/devicetree/bindings/net/wireless/brcm,bcm43xx-fmac.txt index cffb2d6876e3..a65ac4384c04 100644 --- a/Documentation/devicetree/bindings/net/wireless/brcm,bcm43xx-fmac.txt +++ b/Documentation/devicetree/bindings/net/wireless/brcm,bcm43xx-fmac.txt @@ -15,6 +15,12 @@ Optional properties: When not specified the device will use in-band SDIO interrupts. - interrupt-names : name of the out-of-band interrupt, which must be set to "host-wake". + - brcm,ccode-map : multiple strings for translating ISO3166 country code to + brcmfmac firmware country code and revision. Each string must be in + format "AA-BB-num" where: + AA is the ISO3166 country code which must be 2 characters. + BB is the firmware country code which must be 2 characters. + num is the revision number which must fit into signed integer. Example: @@ -34,5 +40,6 @@ mmc3: mmc@1c12000 { interrupt-parent = <&pio>; interrupts = <10 8>; /* PH10 / EINT10 */ interrupt-names = "host-wake"; + brcm,ccode-map = "JP-JP-78", "US-Q2-86"; }; }; From patchwork Thu Apr 8 11:30:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 417414 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp468158jai; Thu, 8 Apr 2021 04:30:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNHH4VEHdmkhHwc5EDe2XcOQjrn4+NA0QFtXrAFinPnt4VdAFeS2TMRBcgCA+9gpwuoBu8 X-Received: by 2002:a17:906:3e97:: with SMTP id a23mr9774667ejj.440.1617881451204; Thu, 08 Apr 2021 04:30:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617881451; cv=none; d=google.com; s=arc-20160816; b=EVgG/jYKmnQt3GBZBHF4QSQ5b9ac2zjt51zf/3p7+4d9QdDjIweJ2qf/fTTP0S9lUi An1jzkVD6bHALhCzO2dLP4NJ8A2Oa1qsP8uanI8CPOuPWX/CTrFzV+OgK8/237l+JdnO aSx0j0Y9bXW4H8aooU1mZ3ajkWiadIkKGVws5oM1umgF1BHXxDunFsMRRSafp3o9qtnG IXubGV9xuuo7zXIHme9hw51F3bAazbXeiyb/p/GmsmiFIzVF6aQvw2WXTtwIzWxE8Q2F 93w/5mKnzuS6KEF6m6Zpc6SAE+V7yAT9HHP7ksuG7HyKpL1jvkTEPrfVoB8zDKE8j1IF Z9ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=whg5uvgIxjBQi611PiDallF8tjAml5Jz5ytoZKbEBgI=; b=kY5L/TiYbDRlwQULYl/ic/Z4EXxq2fuvHy1axpZEHb7CUOSv78vnYS5Sv5Ct9Iq8hV djlap49AiFx/NfWlNn0zXkOhEjnTGu3ZTgl2YNPkVH7vCY/RNlgFnDWqWNNOSlA6ZTMi didpNYRwtC9EH51v2OD3ERt3HuiHsDuT1WkDaJVX1Twu7zsT4c4ghBXvMl3s7KZZLJpN 5h9I/9JDnJv0lrHUSyDnLnxufjuDElp5ZQvCuuL6Y0q/aB9nmPzduiU9GTmEwc/3wR/T GLuHdFRKJLRHugfFKKlQ4imRlmjYkBnvenJz90GkJp0wWHz5G3J9yXAIsS2m4HE7tEey d7lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=z15WyVNW; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r3si454342edx.603.2021.04.08.04.30.51; Thu, 08 Apr 2021 04:30:51 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=z15WyVNW; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229964AbhDHLa7 (ORCPT + 6 others); Thu, 8 Apr 2021 07:30:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231352AbhDHLa6 (ORCPT ); Thu, 8 Apr 2021 07:30:58 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A294EC061761 for ; Thu, 8 Apr 2021 04:30:47 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id x21-20020a17090a5315b029012c4a622e4aso1179762pjh.2 for ; Thu, 08 Apr 2021 04:30:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=whg5uvgIxjBQi611PiDallF8tjAml5Jz5ytoZKbEBgI=; b=z15WyVNWMuOFLu9lTNFRL8UtMgUPlrJRlSdO6RtMUQhZnqJ4YKyXFHrtKo0xUCMzqU aIcxyvcAHaRhVgE25Zmdwvj+r2GsuP5+BPI6rkoxuT6WrRYSFhQpV5IDFxqXaiJyvoQq BkLaslzdgXUSqO3UBUz2mJlSAedDsHjk8BDX9r1u+/g2yqdOhqMjVt0V17e05QbKt1td 4hfaktJC3DMAEPc+v3DZ5zJihDvaDW4Dx37PCDzhBbhxVjmbMAdF37RPBQIKc27MYdJD /r+NAlmp2gz7Fxee6/xW4L7yAQ/Xpeh6VCpm8TeDmf+rhv6CJ7AvgihbQpIYhv/1wpE9 QwfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=whg5uvgIxjBQi611PiDallF8tjAml5Jz5ytoZKbEBgI=; b=hAam45+N4lfR3o0pe9zsfffiOZqypf4RQekAfQDabXX7Yu0wJJKlUN3GTcZqwvOEVS idyQ+j80HV4wZrc5dvc0tNIiK2VYU3zobFtYi4FeOhUr6aDEqmEQ7C/CwZ1LiqTHACq2 tJ47QlhWBB7b3wkxS0quLQlbYSudpMI2Em3WZ7zxYlcau1SgbStoAYs4NA22DWYMGFxp ss/yyT3MSkvrIz+0Fr4NaPHSqS05Gt9dv61hzAImX4UEWw+wTh0PlckcCbkJE3ZlFfbd zA7jvEZ6hYUa9N8C/M3ChUJxGvN5fuY7+Q8OPWbVgtLe0nsdAjVYk1kgHkmIYDAHf1gI 4/Gg== X-Gm-Message-State: AOAM532tnNtxRG31xV+lQZNZFBtjoXheLj3uAGIaK5nxGDnvnaEUCmMH YWYwbWRsxGBDc3tIHxovjUwp4NOvqTGpenw/ X-Received: by 2002:a17:902:ea89:b029:e9:2813:2db9 with SMTP id x9-20020a170902ea89b02900e928132db9mr7250665plb.61.1617881447259; Thu, 08 Apr 2021 04:30:47 -0700 (PDT) Received: from localhost.localdomain (80.251.214.228.16clouds.com. [80.251.214.228]) by smtp.gmail.com with ESMTPSA id x18sm7753267pfi.105.2021.04.08.04.30.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 04:30:46 -0700 (PDT) From: Shawn Guo To: Kalle Valo Cc: Rob Herring , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Arend van Spriel , Franky Lin , Hante Meuleman , Chi-hsien Lin , Wright Feng , Chung-hsien Hsu , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, SHA-cyfmac-dev-list@infineon.com, Shawn Guo Subject: [PATCH 2/2] brcmfmac: support parse country code map from DT Date: Thu, 8 Apr 2021 19:30:22 +0800 Message-Id: <20210408113022.18180-3-shawn.guo@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210408113022.18180-1-shawn.guo@linaro.org> References: <20210408113022.18180-1-shawn.guo@linaro.org> Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org With any regulatory domain requests coming from either user space or 802.11 IE (Information Element), the country is coded in ISO3166 standard. It needs to be translated to firmware country code and revision with the mapping info in settings->country_codes table. Support populate country_codes table by parsing the mapping from DT. Signed-off-by: Shawn Guo --- .../wireless/broadcom/brcm80211/brcmfmac/of.c | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) -- 2.17.1 Reviewed-by: Arend van Spriel diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c index a7554265f95f..ea5c7f434c2c 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c @@ -12,12 +12,61 @@ #include "common.h" #include "of.h" +static int brcmf_of_get_country_codes(struct device *dev, + struct brcmf_mp_device *settings) +{ + struct device_node *np = dev->of_node; + struct brcmfmac_pd_cc_entry *cce; + struct brcmfmac_pd_cc *cc; + int count; + int i; + + count = of_property_count_strings(np, "brcm,ccode-map"); + if (count < 0) { + /* The property is optional, so return success if it doesn't + * exist. Otherwise propagate the error code. + */ + return (count == -EINVAL) ? 0 : count; + } + + cc = devm_kzalloc(dev, sizeof(*cc) + count * sizeof(*cce), GFP_KERNEL); + if (!cc) + return -ENOMEM; + + cc->table_size = count; + + for (i = 0; i < count; i++) { + const char *map; + int ret; + + cce = &cc->table[i]; + + if (of_property_read_string_index(np, "brcm,ccode-map", + i, &map)) + continue; + + /* String format e.g. US-Q2-86 */ + strncpy(cce->iso3166, map, 2); + strncpy(cce->cc, map + 3, 2); + + ret = kstrtos32(map + 6, 10, &cce->rev); + if (ret < 0) + dev_warn(dev, "failed to read rev of map %s: %d", + cce->iso3166, ret); + } + + settings->country_codes = cc; + + return 0; +} + void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type, struct brcmf_mp_device *settings) { struct brcmfmac_sdio_pd *sdio = &settings->bus.sdio; struct device_node *root, *np = dev->of_node; int irq; + int ret; u32 irqf; u32 val; @@ -47,6 +96,10 @@ void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type, !of_device_is_compatible(np, "brcm,bcm4329-fmac")) return; + ret = brcmf_of_get_country_codes(dev, settings); + if (ret) + dev_warn(dev, "failed to get OF country code map\n"); + if (of_property_read_u32(np, "brcm,drive-strength", &val) == 0) sdio->drive_strength = val;