From patchwork Thu Jul 25 17:47:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 11059505 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9E62A13AC for ; Thu, 25 Jul 2019 17:48:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C67328585 for ; Thu, 25 Jul 2019 17:48:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 80279287A3; Thu, 25 Jul 2019 17:48:10 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 21A28288F8 for ; Thu, 25 Jul 2019 17:48:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=YvbWuIaWD1si74IUwPNy9sgM2UDn0NeTuQgz6JMq08A=; b=WxfmOlsY+OjQmL5nKOT+ME7Mms LmyKUyybKUqIAf8dzmZJW3rDlu1rbOzRXhdPfY8Znit4ZVxjbRMvmmDPtHX0D8Z7V5sFIazjAJq25 e2SFaIW+zupnkrte8FO9HRgkG1ymEQVy9E5Y1hQ5h03yydfcjubB2yzQdJi3QhdW9Zedex962LKZj x4M3ePNi/fsS+U/GToH+O2e/qZB3TG/Uxxq1K4Lhk2z3kaRcTKhoOc3MGlsVWHGmeBIe1e85eXWN7 qZ+vnbRpJnMB6YWIxU6u82/UsPgJttLw5KdzwJC9sM13FNPnKaCRGZpCPXpCr4pLd5pUG9UMo0d6F 860BuYlg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hqhqb-0000SV-4u; Thu, 25 Jul 2019 17:48:09 +0000 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hqhqT-0000Ok-5y for ath10k@lists.infradead.org; Thu, 25 Jul 2019 17:48:02 +0000 Received: by mail-pf1-x443.google.com with SMTP id b13so23123202pfo.1 for ; Thu, 25 Jul 2019 10:48:01 -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=QrMxyVc1zDSi0vs7OhTYgzu3OEGoWgT+T+Dw+YVkahA=; b=FBtNJFdb5Upz2AH4s+VB92FH7J1QWb00rt7yEE+fpBZ5N7S4k8ZAyVn2nUAtgftsP3 BDTdblo7Lrm47RqKVfYOKatWqxVG9lgObs4AZRT5IZKOBP3WnkxxfZuMR1cSliGx++JP vk8V4AOXvhCqOgeUEGQfRVB/u2YZy4IV2JG3tRfoVG0rpklZL1pKH9yB+T8WKZTBHTQj E7mMKW9Y/te4c1uNmW4in2k6DpiZtNrlLa/ybrFJqgMPcPI971iImshozI993OinDJE5 KgzG7OhMfRRBsFnMOCEXVKVe/4CevH/soHHAhxzhlpQh/rpZOVjWqsIiPebdVkwkWjmt GAZg== 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=QrMxyVc1zDSi0vs7OhTYgzu3OEGoWgT+T+Dw+YVkahA=; b=nQGSQqPzLUYLdV4THBTk/GwvfhOUXAYBebfkpIaJwtl+T2rgKRFySmRp3vLw5t7KlB b9gVGd+aNkEy5kIu2z6F441u+3XVq4cVcTar3V6ZKYuR3bNpAq2TMCO2u9pk/rFr+N5X TyKxlN7nF0sw2r7zLpqhEZBJBC8IkOniLeby/X5LXDTz4F1NqaMPIBmIFD2tX3U7K+1T +Mgf4pwooWbaMkc0MZD/SP0ZzoFovUiPkYJw/DUWuyKiZmcD41hajxEfMsm3lZ5Nvu1h o1Lv/vVqxYT+WlP3lJ0gV/KbSyjrI37K/lHgZOjsgnkyiCljUVN/BdD/ecmGzPu4j0or ESSA== X-Gm-Message-State: APjAAAX4VTCyR70WoweM6USPeDMVnuvXYayfK8LiaeYcjXAMASmv9ovq GPulALYjCUNs/M0U1jUmsToKJA== X-Google-Smtp-Source: APXvYqwekoX7JDpQsI3IDTHrGT7s/jfkXzjLB1wd9p4/mqvLcf0bxF1vgF++94o8TYuNevIcvnFKAw== X-Received: by 2002:a65:5a44:: with SMTP id z4mr87590926pgs.41.1564076880400; Thu, 25 Jul 2019 10:48:00 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id r2sm68103389pfl.67.2019.07.25.10.47.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jul 2019 10:47:59 -0700 (PDT) From: Bjorn Andersson To: Kalle Valo , Govind Singh Subject: [PATCH 1/3] ath10k: snoc: skip regulator operations Date: Thu, 25 Jul 2019 10:47:53 -0700 Message-Id: <20190725174755.23432-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190725174755.23432-1-bjorn.andersson@linaro.org> References: <20190725174755.23432-1-bjorn.andersson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190725_104801_221102_4E9FD6B1 X-CRM114-Status: GOOD ( 13.53 ) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, ath10k@lists.infradead.org, linux-arm-msm@vger.kernel.org, "David S. Miller" MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The regulator operations is trying to set a voltage to a fixed value, by giving some wiggle room. But some board designs specifies regulator voltages outside this limited range. One such example is the Lenovo Yoga C630, with vdd-3.3-ch0 in particular specified at 3.1V. But consumers with fixed voltage requirements should just rely on the board configuration to provide the power at the required level, so this code should be removed. Signed-off-by: Bjorn Andersson --- This patch is required for Lenovo Yoga C630 to succeed in power on ath10k, it can be merged independently of the two following cleanup patches. drivers/net/wireless/ath/ath10k/snoc.c | 27 ++++++-------------------- drivers/net/wireless/ath/ath10k/snoc.h | 2 -- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/ath/ath10k/snoc.c index fc15a0037f0e..3d93ab09a298 100644 --- a/drivers/net/wireless/ath/ath10k/snoc.c +++ b/drivers/net/wireless/ath/ath10k/snoc.c @@ -37,10 +37,10 @@ static char *const ce_name[] = { }; static struct ath10k_vreg_info vreg_cfg[] = { - {NULL, "vdd-0.8-cx-mx", 800000, 850000, 0, 0, false}, - {NULL, "vdd-1.8-xo", 1800000, 1850000, 0, 0, false}, - {NULL, "vdd-1.3-rfa", 1300000, 1350000, 0, 0, false}, - {NULL, "vdd-3.3-ch0", 3300000, 3350000, 0, 0, false}, + {NULL, "vdd-0.8-cx-mx", 0, 0, false}, + {NULL, "vdd-1.8-xo", 0, 0, false}, + {NULL, "vdd-1.3-rfa", 0, 0, false}, + {NULL, "vdd-3.3-ch0", 0, 0, false}, }; static struct ath10k_clk_info clk_cfg[] = { @@ -1377,9 +1377,8 @@ static int ath10k_get_vreg_info(struct ath10k *ar, struct device *dev, done: ath10k_dbg(ar, ATH10K_DBG_SNOC, - "snog vreg %s min_v %u max_v %u load_ua %u settle_delay %lu\n", - vreg_info->name, vreg_info->min_v, vreg_info->max_v, - vreg_info->load_ua, vreg_info->settle_delay); + "snog vreg %s load_ua %u settle_delay %lu\n", + vreg_info->name, vreg_info->load_ua, vreg_info->settle_delay); return 0; } @@ -1420,15 +1419,6 @@ static int __ath10k_snoc_vreg_on(struct ath10k *ar, ath10k_dbg(ar, ATH10K_DBG_SNOC, "snoc regulator %s being enabled\n", vreg_info->name); - ret = regulator_set_voltage(vreg_info->reg, vreg_info->min_v, - vreg_info->max_v); - if (ret) { - ath10k_err(ar, - "failed to set regulator %s voltage-min: %d voltage-max: %d\n", - vreg_info->name, vreg_info->min_v, vreg_info->max_v); - return ret; - } - if (vreg_info->load_ua) { ret = regulator_set_load(vreg_info->reg, vreg_info->load_ua); if (ret < 0) { @@ -1453,7 +1443,6 @@ static int __ath10k_snoc_vreg_on(struct ath10k *ar, err_enable: regulator_set_load(vreg_info->reg, 0); err_set_load: - regulator_set_voltage(vreg_info->reg, 0, vreg_info->max_v); return ret; } @@ -1475,10 +1464,6 @@ static int __ath10k_snoc_vreg_off(struct ath10k *ar, if (ret < 0) ath10k_err(ar, "failed to set load %s\n", vreg_info->name); - ret = regulator_set_voltage(vreg_info->reg, 0, vreg_info->max_v); - if (ret) - ath10k_err(ar, "failed to set voltage %s\n", vreg_info->name); - return ret; } diff --git a/drivers/net/wireless/ath/ath10k/snoc.h b/drivers/net/wireless/ath/ath10k/snoc.h index 9db823e46314..1bf7bd4ef2a3 100644 --- a/drivers/net/wireless/ath/ath10k/snoc.h +++ b/drivers/net/wireless/ath/ath10k/snoc.h @@ -45,8 +45,6 @@ struct ath10k_snoc_ce_irq { struct ath10k_vreg_info { struct regulator *reg; const char *name; - u32 min_v; - u32 max_v; u32 load_ua; unsigned long settle_delay; bool required; From patchwork Thu Jul 25 17:47:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 11059511 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3D8EE13AC for ; Thu, 25 Jul 2019 17:48:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A3EB28585 for ; Thu, 25 Jul 2019 17:48:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1CFFF288C3; Thu, 25 Jul 2019 17:48:15 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6C7C628585 for ; Thu, 25 Jul 2019 17:48:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=gj1RdLltBDhoqbeGOev0muJdAtzU7TJSsEe/d92Ed64=; b=EJfZ6uUwCjS9dPH8I58DIpALtf 7I/pnCaYvrXldNvdG1IG2aOOiC8wvYEPruQ/YAQnIMSXWyCyIoIT+xz2iVwkAPdAcLkmLdO62a8ZU cKe7oWpd4ofzIcq/Q6YbWBz/SD8dDdKq/cYbvl7QlK+n8PtzfpkwJmmFidj/HADKhq8Id15AHBWe4 zNpU6FtRP4QRYlGf3/yScDUpqHTf+osYgyp+n8D+Cfm+1+F0Tcx7nNz1et48bVqDbq3WFR9eBwU6K tifw5mh+XZZ66vkCw9rnuMLtoLKU3o5pe/TiRyJPZML0lcVrct4D8mkrFwlkCtRWD/j4WY3M3P+bg RXgSz5yw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hqhqg-0000Wj-1J; Thu, 25 Jul 2019 17:48:14 +0000 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hqhqU-0000P7-Lj for ath10k@lists.infradead.org; Thu, 25 Jul 2019 17:48:04 +0000 Received: by mail-pg1-x543.google.com with SMTP id f5so14578700pgu.5 for ; Thu, 25 Jul 2019 10:48:02 -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=/WrADzYkORlcVtAbPUzYqh5Elc5hN3CelIc55J/0298=; b=FVWZFcscrt7/kkd/XTahq2q0imZzvuv06upviQ083Im6gcDueZXOAG00qH8hASzjbH LKtwM/RJlMEco3N0AFQpFcwGzHgI7gRO03z1VAcvRI5FdpaFirHs44ovFD8jGVwgyOs9 c8LK6bZFk22Wb/VpKq0XOz5IDcAr2pf74TN0W/ipc/m7ZfECNtBFlEqeGeOOj2tp/DYT BZdbEZNq5iDm66ymMMupktoQ1LctDZBYKFNWvSamlHx0N1+BLV7xan7PoiqKzGm83rRa 2RJWR6mQkykgHy1UzqqJSI7WlvGzece53z2h/7H74s96n0IlpocT/oZ0NOV/q5xhyaIb GYSA== 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=/WrADzYkORlcVtAbPUzYqh5Elc5hN3CelIc55J/0298=; b=sbDkXS5X+oSU7d43lYxuZKSAclrKEG2koyx+3P6n8BNYvGuv/lMibQwODEY3rWKidB qHuYM83R8ZmElKFTDHl5WTzWeoa7oYfuOG4s9T4mNKPhF7bQC2vWQq4FXK3p41uhVgiX IsIEKHhy6l5e+QZsNGG6q2l3pET252cv8rl3cLH8/fpjZcGM9jz1lpvPmJxe1GeuhwwM c9QUMYiBtdvg9Y8W9hZgN2AuIdf3I3kzLWZhz5GHMaTVhuF9DbytpYFt2PX+T5t3tU1R 3nBZc5IeIEpdzhou5vjA5Suul0tZrUWU3CAwftCUa7l6p+u1WPn9reOmBAlAgq7RV531 F7qw== X-Gm-Message-State: APjAAAXLMbgzcXJ9IjP3VASiE603MOFTP/30Wn2yzqTfhSGrBidui6rA k9IReGFr14X/EXtYv/dOvYKM1g== X-Google-Smtp-Source: APXvYqy8kMWc+TEDRvzmCGrUiE09xuA8fITK35yCgtcTfwYab7PZLAJuGGJC2dJaAuypitgXX6+IlA== X-Received: by 2002:a63:6888:: with SMTP id d130mr15497258pgc.197.1564076881800; Thu, 25 Jul 2019 10:48:01 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id r2sm68103389pfl.67.2019.07.25.10.48.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jul 2019 10:48:01 -0700 (PDT) From: Bjorn Andersson To: Kalle Valo , Govind Singh Subject: [PATCH 2/3] ath10k: Use standard regulator bulk API in snoc Date: Thu, 25 Jul 2019 10:47:54 -0700 Message-Id: <20190725174755.23432-3-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190725174755.23432-1-bjorn.andersson@linaro.org> References: <20190725174755.23432-1-bjorn.andersson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190725_104802_903353_9992F5C5 X-CRM114-Status: GOOD ( 19.15 ) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, ath10k@lists.infradead.org, linux-arm-msm@vger.kernel.org, "David S. Miller" MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The regulator_get_optional() exists for cases where the driver needs do behave differently depending on some regulator supply being present or not, as we don't use this we can use the standard regulator_get() and rely on its handling of unspecified regulators. While the driver currently doesn't specify any loads the regulator framework was updated last year to only account for load of enabled regulators, so should the need appear it's better to apply load numbers during initialization that dynamically. With this the regulator wrappers have been reduced the become identical to the standard bulk API provided by the regulator framework, so use these instead of rolling our own. Signed-off-by: Bjorn Andersson --- drivers/net/wireless/ath/ath10k/snoc.c | 184 ++++--------------------- drivers/net/wireless/ath/ath10k/snoc.h | 13 +- 2 files changed, 27 insertions(+), 170 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/ath/ath10k/snoc.c index 3d93ab09a298..1c9ff7e53e2f 100644 --- a/drivers/net/wireless/ath/ath10k/snoc.c +++ b/drivers/net/wireless/ath/ath10k/snoc.c @@ -36,11 +36,11 @@ static char *const ce_name[] = { "WLAN_CE_11", }; -static struct ath10k_vreg_info vreg_cfg[] = { - {NULL, "vdd-0.8-cx-mx", 0, 0, false}, - {NULL, "vdd-1.8-xo", 0, 0, false}, - {NULL, "vdd-1.3-rfa", 0, 0, false}, - {NULL, "vdd-3.3-ch0", 0, 0, false}, +static const char * const ath10k_regulators[] = { + "vdd-0.8-cx-mx", + "vdd-1.8-xo", + "vdd-1.3-rfa", + "vdd-3.3-ch0", }; static struct ath10k_clk_info clk_cfg[] = { @@ -1346,43 +1346,6 @@ static void ath10k_snoc_release_resource(struct ath10k *ar) ath10k_ce_free_pipe(ar, i); } -static int ath10k_get_vreg_info(struct ath10k *ar, struct device *dev, - struct ath10k_vreg_info *vreg_info) -{ - struct regulator *reg; - int ret = 0; - - reg = devm_regulator_get_optional(dev, vreg_info->name); - - if (IS_ERR(reg)) { - ret = PTR_ERR(reg); - - if (ret == -EPROBE_DEFER) { - ath10k_err(ar, "EPROBE_DEFER for regulator: %s\n", - vreg_info->name); - return ret; - } - if (vreg_info->required) { - ath10k_err(ar, "Regulator %s doesn't exist: %d\n", - vreg_info->name, ret); - return ret; - } - ath10k_dbg(ar, ATH10K_DBG_SNOC, - "Optional regulator %s doesn't exist: %d\n", - vreg_info->name, ret); - goto done; - } - - vreg_info->reg = reg; - -done: - ath10k_dbg(ar, ATH10K_DBG_SNOC, - "snog vreg %s load_ua %u settle_delay %lu\n", - vreg_info->name, vreg_info->load_ua, vreg_info->settle_delay); - - return 0; -} - static int ath10k_get_clk_info(struct ath10k *ar, struct device *dev, struct ath10k_clk_info *clk_info) { @@ -1411,114 +1374,6 @@ static int ath10k_get_clk_info(struct ath10k *ar, struct device *dev, return ret; } -static int __ath10k_snoc_vreg_on(struct ath10k *ar, - struct ath10k_vreg_info *vreg_info) -{ - int ret; - - ath10k_dbg(ar, ATH10K_DBG_SNOC, "snoc regulator %s being enabled\n", - vreg_info->name); - - if (vreg_info->load_ua) { - ret = regulator_set_load(vreg_info->reg, vreg_info->load_ua); - if (ret < 0) { - ath10k_err(ar, "failed to set regulator %s load: %d\n", - vreg_info->name, vreg_info->load_ua); - goto err_set_load; - } - } - - ret = regulator_enable(vreg_info->reg); - if (ret) { - ath10k_err(ar, "failed to enable regulator %s\n", - vreg_info->name); - goto err_enable; - } - - if (vreg_info->settle_delay) - udelay(vreg_info->settle_delay); - - return 0; - -err_enable: - regulator_set_load(vreg_info->reg, 0); -err_set_load: - - return ret; -} - -static int __ath10k_snoc_vreg_off(struct ath10k *ar, - struct ath10k_vreg_info *vreg_info) -{ - int ret; - - ath10k_dbg(ar, ATH10K_DBG_SNOC, "snoc regulator %s being disabled\n", - vreg_info->name); - - ret = regulator_disable(vreg_info->reg); - if (ret) - ath10k_err(ar, "failed to disable regulator %s\n", - vreg_info->name); - - ret = regulator_set_load(vreg_info->reg, 0); - if (ret < 0) - ath10k_err(ar, "failed to set load %s\n", vreg_info->name); - - return ret; -} - -static int ath10k_snoc_vreg_on(struct ath10k *ar) -{ - struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar); - struct ath10k_vreg_info *vreg_info; - int ret = 0; - int i; - - for (i = 0; i < ARRAY_SIZE(vreg_cfg); i++) { - vreg_info = &ar_snoc->vreg[i]; - - if (!vreg_info->reg) - continue; - - ret = __ath10k_snoc_vreg_on(ar, vreg_info); - if (ret) - goto err_reg_config; - } - - return 0; - -err_reg_config: - for (i = i - 1; i >= 0; i--) { - vreg_info = &ar_snoc->vreg[i]; - - if (!vreg_info->reg) - continue; - - __ath10k_snoc_vreg_off(ar, vreg_info); - } - - return ret; -} - -static int ath10k_snoc_vreg_off(struct ath10k *ar) -{ - struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar); - struct ath10k_vreg_info *vreg_info; - int ret = 0; - int i; - - for (i = ARRAY_SIZE(vreg_cfg) - 1; i >= 0; i--) { - vreg_info = &ar_snoc->vreg[i]; - - if (!vreg_info->reg) - continue; - - ret = __ath10k_snoc_vreg_off(ar, vreg_info); - } - - return ret; -} - static int ath10k_snoc_clk_init(struct ath10k *ar) { struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar); @@ -1591,11 +1446,12 @@ static int ath10k_snoc_clk_deinit(struct ath10k *ar) static int ath10k_hw_power_on(struct ath10k *ar) { + struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar); int ret; ath10k_dbg(ar, ATH10K_DBG_SNOC, "soc power on\n"); - ret = ath10k_snoc_vreg_on(ar); + ret = regulator_bulk_enable(ar_snoc->num_vregs, ar_snoc->vregs); if (ret) return ret; @@ -1606,21 +1462,19 @@ static int ath10k_hw_power_on(struct ath10k *ar) return ret; vreg_off: - ath10k_snoc_vreg_off(ar); + regulator_bulk_disable(ar_snoc->num_vregs, ar_snoc->vregs); return ret; } static int ath10k_hw_power_off(struct ath10k *ar) { - int ret; + struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar); ath10k_dbg(ar, ATH10K_DBG_SNOC, "soc power off\n"); ath10k_snoc_clk_deinit(ar); - ret = ath10k_snoc_vreg_off(ar); - - return ret; + return regulator_bulk_disable(ar_snoc->num_vregs, ar_snoc->vregs); } static const struct of_device_id ath10k_snoc_dt_match[] = { @@ -1691,12 +1545,20 @@ static int ath10k_snoc_probe(struct platform_device *pdev) goto err_release_resource; } - ar_snoc->vreg = vreg_cfg; - for (i = 0; i < ARRAY_SIZE(vreg_cfg); i++) { - ret = ath10k_get_vreg_info(ar, dev, &ar_snoc->vreg[i]); - if (ret) - goto err_free_irq; + ar_snoc->num_vregs = ARRAY_SIZE(ath10k_regulators); + ar_snoc->vregs = devm_kcalloc(&pdev->dev, ar_snoc->num_vregs, + sizeof(*ar_snoc->vregs), GFP_KERNEL); + if (!ar_snoc->vregs) { + ret = -ENOMEM; + goto err_free_irq; } + for (i = 0; i < ar_snoc->num_vregs; i++) + ar_snoc->vregs[i].supply = ath10k_regulators[i]; + + ret = devm_regulator_bulk_get(&pdev->dev, ar_snoc->num_vregs, + ar_snoc->vregs); + if (ret < 0) + goto err_free_irq; ar_snoc->clk = clk_cfg; for (i = 0; i < ARRAY_SIZE(clk_cfg); i++) { diff --git a/drivers/net/wireless/ath/ath10k/snoc.h b/drivers/net/wireless/ath/ath10k/snoc.h index 1bf7bd4ef2a3..3965ddf66d74 100644 --- a/drivers/net/wireless/ath/ath10k/snoc.h +++ b/drivers/net/wireless/ath/ath10k/snoc.h @@ -42,14 +42,6 @@ struct ath10k_snoc_ce_irq { u32 irq_line; }; -struct ath10k_vreg_info { - struct regulator *reg; - const char *name; - u32 load_ua; - unsigned long settle_delay; - bool required; -}; - struct ath10k_clk_info { struct clk *handle; const char *name; @@ -64,6 +56,8 @@ enum ath10k_snoc_flags { ATH10K_SNOC_FLAG_8BIT_HOST_CAP_QUIRK, }; +struct regulator_bulk_data; + struct ath10k_snoc { struct platform_device *dev; struct ath10k *ar; @@ -75,7 +69,8 @@ struct ath10k_snoc { struct ath10k_snoc_ce_irq ce_irqs[CE_COUNT_MAX]; struct ath10k_ce ce; struct timer_list rx_post_retry; - struct ath10k_vreg_info *vreg; + struct regulator_bulk_data *vregs; + size_t num_vregs; struct ath10k_clk_info *clk; struct ath10k_qmi *qmi; unsigned long flags; From patchwork Thu Jul 25 17:47:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 11059513 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3B4A014DB for ; Thu, 25 Jul 2019 17:48:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 252A428585 for ; Thu, 25 Jul 2019 17:48:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 153C8288C3; Thu, 25 Jul 2019 17:48:22 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9823C28585 for ; Thu, 25 Jul 2019 17:48:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Y1GUYr+d3Qnl6rQUqeVTTOmyqbbPCuNKXJOiTTCiMdI=; b=NGuMi9uab4V3manlKfAARSnnye ePxj7UyAroc2pq3DmkKigvKJBYgs7oxKet1SBjyAX7Lsw5DKmpK8fbCEDg3cRbZPouawiyBQF9oCS KYKdqbSheWST/OBKdSTB7UTKOy3auJrZSRc0vHJ5CPTLRh/yPfs8KH77hSzbBcvwZsKjndlDdCdIv wsZp4rmIkXx6Z7sb8Y0F+6knQs3AX0vWlrReEW4ph76fKVnCMz8MScAqnCJoCuH/THXeDd/1fl9Hc DIollcKmesHamPG8aJkguZ0ymFntaAjODKzBIMiCLGSsvsT0HmQg8LClpvylv5C1FNTClyzBkAm3u Piydk3+g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hqhqm-0000d8-LP; Thu, 25 Jul 2019 17:48:20 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hqhqV-0000Pk-No for ath10k@lists.infradead.org; Thu, 25 Jul 2019 17:48:05 +0000 Received: by mail-pf1-x441.google.com with SMTP id y15so23123496pfn.5 for ; Thu, 25 Jul 2019 10:48:03 -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=GovT0wzh5qxyqV9OneNnQImH0OsXKl2tN6pFF75ONIw=; b=s/bw04vkMYnY+EKtQQO95I+PcZHokjnqpIQJmgnjVt0v3kddjrHkXiNVmJ49oyKvG7 3mVtuJBY+seXVwEwQOWcnPe8OKRqBcoduh3YytdhvYO5doi0ioq3ZhQMMmZl6OpEvcd1 LyGCE91q6aFZDepZVSpp4Sv6KqnXlvP9366iKr7WrqSAkZnkIo7EkKruobECtB9Bzlob Lb7UGj25ZI2ojkvJtcFJASgDwM6cmgHdJt2QqgDBL+j9YG9mp2lqVL3nPjGpVWnlnCA/ BzqSwm7A6+9TfAk9Lu6j64hFiGrUYMk92Dj1Kz7Gwxvid1m57ct78IYzuvria/LNcO6w /5yg== 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=GovT0wzh5qxyqV9OneNnQImH0OsXKl2tN6pFF75ONIw=; b=WhTEWRBNdRotuqVymy8ho+5QySh/d2XowRboHk38A/b8leFLeV60VotlolMSyLdcfz lltU9aAFD36Chq6xuciUDm1NxT75VtYoWeNjJghXSJW6XOEzR10nr1aUs/UvbZnpZ5Q4 pIz3qpxiCPY7tHvOGDjNpbUO0JGdUKu/zEBqlPCV8qdyf8hYkXXRvkDV0DAr9vbZ4spn pQpjmery1/3G2q8EIcJCNx6UzzTwxq47zTylGe/O5lvPyQIiu5SieoNS9CHtXv7pH6I3 VjW9+XdxgiA2yPUtHNv4+JpfOMNYdRB/fJGpa7gglDBKcERctNBlM1OukLowmmpwH8wy UrcA== X-Gm-Message-State: APjAAAVlk9CbdNNMJGdzKBhOuV3BUHPwozUlR5pftjWpDbaEtlPBeLXR 4sYahpu+T0E9hKlvu53WGyQ9rw== X-Google-Smtp-Source: APXvYqzPS2oBXex2AyU84xtOTnQkkSqQOJSpkxMxiuqCZBz7N5HtlPIK62mIcgu6+zmZeEvsY5Cqmw== X-Received: by 2002:a17:90b:28f:: with SMTP id az15mr92664666pjb.18.1564076883064; Thu, 25 Jul 2019 10:48:03 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id r2sm68103389pfl.67.2019.07.25.10.48.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jul 2019 10:48:02 -0700 (PDT) From: Bjorn Andersson To: Kalle Valo , Govind Singh Subject: [PATCH 3/3] ath10k: Use standard bulk clock API in snoc Date: Thu, 25 Jul 2019 10:47:55 -0700 Message-Id: <20190725174755.23432-4-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190725174755.23432-1-bjorn.andersson@linaro.org> References: <20190725174755.23432-1-bjorn.andersson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190725_104804_080725_6BEA08D1 X-CRM114-Status: GOOD ( 17.38 ) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, ath10k@lists.infradead.org, linux-arm-msm@vger.kernel.org, "David S. Miller" MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP No frequency is currently specified for the single clock defined in the snoc driver, so the clock wrappers reimplements the standard bulk API provided by the clock framework. Change to this. The single clock defined is marked as optional so this version of the get API is used, but might need to be reconsidered in the future. Signed-off-by: Bjorn Andersson --- drivers/net/wireless/ath/ath10k/snoc.c | 125 ++++--------------------- drivers/net/wireless/ath/ath10k/snoc.h | 11 +-- 2 files changed, 21 insertions(+), 115 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/ath/ath10k/snoc.c index 1c9ff7e53e2f..80ce68c0f75e 100644 --- a/drivers/net/wireless/ath/ath10k/snoc.c +++ b/drivers/net/wireless/ath/ath10k/snoc.c @@ -43,8 +43,8 @@ static const char * const ath10k_regulators[] = { "vdd-3.3-ch0", }; -static struct ath10k_clk_info clk_cfg[] = { - {NULL, "cxo_ref_clk_pin", 0, false}, +static const char * const ath10k_clocks[] = { + "cxo_ref_clk_pin", }; static void ath10k_snoc_htc_tx_cb(struct ath10k_ce_pipe *ce_state); @@ -1346,104 +1346,6 @@ static void ath10k_snoc_release_resource(struct ath10k *ar) ath10k_ce_free_pipe(ar, i); } -static int ath10k_get_clk_info(struct ath10k *ar, struct device *dev, - struct ath10k_clk_info *clk_info) -{ - struct clk *handle; - int ret = 0; - - handle = devm_clk_get(dev, clk_info->name); - if (IS_ERR(handle)) { - ret = PTR_ERR(handle); - if (clk_info->required) { - ath10k_err(ar, "snoc clock %s isn't available: %d\n", - clk_info->name, ret); - return ret; - } - ath10k_dbg(ar, ATH10K_DBG_SNOC, "snoc ignoring clock %s: %d\n", - clk_info->name, - ret); - return 0; - } - - ath10k_dbg(ar, ATH10K_DBG_SNOC, "snoc clock %s freq %u\n", - clk_info->name, clk_info->freq); - - clk_info->handle = handle; - - return ret; -} - -static int ath10k_snoc_clk_init(struct ath10k *ar) -{ - struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar); - struct ath10k_clk_info *clk_info; - int ret = 0; - int i; - - for (i = 0; i < ARRAY_SIZE(clk_cfg); i++) { - clk_info = &ar_snoc->clk[i]; - - if (!clk_info->handle) - continue; - - ath10k_dbg(ar, ATH10K_DBG_SNOC, "snoc clock %s being enabled\n", - clk_info->name); - - if (clk_info->freq) { - ret = clk_set_rate(clk_info->handle, clk_info->freq); - - if (ret) { - ath10k_err(ar, "failed to set clock %s freq %u\n", - clk_info->name, clk_info->freq); - goto err_clock_config; - } - } - - ret = clk_prepare_enable(clk_info->handle); - if (ret) { - ath10k_err(ar, "failed to enable clock %s\n", - clk_info->name); - goto err_clock_config; - } - } - - return 0; - -err_clock_config: - for (i = i - 1; i >= 0; i--) { - clk_info = &ar_snoc->clk[i]; - - if (!clk_info->handle) - continue; - - clk_disable_unprepare(clk_info->handle); - } - - return ret; -} - -static int ath10k_snoc_clk_deinit(struct ath10k *ar) -{ - struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar); - struct ath10k_clk_info *clk_info; - int i; - - for (i = 0; i < ARRAY_SIZE(clk_cfg); i++) { - clk_info = &ar_snoc->clk[i]; - - if (!clk_info->handle) - continue; - - ath10k_dbg(ar, ATH10K_DBG_SNOC, "snoc clock %s being disabled\n", - clk_info->name); - - clk_disable_unprepare(clk_info->handle); - } - - return 0; -} - static int ath10k_hw_power_on(struct ath10k *ar) { struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar); @@ -1455,7 +1357,7 @@ static int ath10k_hw_power_on(struct ath10k *ar) if (ret) return ret; - ret = ath10k_snoc_clk_init(ar); + ret = clk_bulk_prepare_enable(ar_snoc->num_clks, ar_snoc->clks); if (ret) goto vreg_off; @@ -1472,7 +1374,7 @@ static int ath10k_hw_power_off(struct ath10k *ar) ath10k_dbg(ar, ATH10K_DBG_SNOC, "soc power off\n"); - ath10k_snoc_clk_deinit(ar); + clk_bulk_disable_unprepare(ar_snoc->num_clks, ar_snoc->clks); return regulator_bulk_disable(ar_snoc->num_vregs, ar_snoc->vregs); } @@ -1560,13 +1462,22 @@ static int ath10k_snoc_probe(struct platform_device *pdev) if (ret < 0) goto err_free_irq; - ar_snoc->clk = clk_cfg; - for (i = 0; i < ARRAY_SIZE(clk_cfg); i++) { - ret = ath10k_get_clk_info(ar, dev, &ar_snoc->clk[i]); - if (ret) - goto err_free_irq; + ar_snoc->num_clks = ARRAY_SIZE(ath10k_clocks); + ar_snoc->clks = devm_kcalloc(&pdev->dev, ar_snoc->num_clks, + sizeof(*ar_snoc->clks), GFP_KERNEL); + if (!ar_snoc->clks) { + ret = -ENOMEM; + goto err_free_irq; } + for (i = 0; i < ar_snoc->num_clks; i++) + ar_snoc->clks[i].id = ath10k_clocks[i]; + + ret = devm_clk_bulk_get_optional(&pdev->dev, ar_snoc->num_clks, + ar_snoc->clks); + if (ret) + goto err_free_irq; + ret = ath10k_hw_power_on(ar); if (ret) { ath10k_err(ar, "failed to power on device: %d\n", ret); diff --git a/drivers/net/wireless/ath/ath10k/snoc.h b/drivers/net/wireless/ath/ath10k/snoc.h index 3965ddf66d74..d2449a3b4a8f 100644 --- a/drivers/net/wireless/ath/ath10k/snoc.h +++ b/drivers/net/wireless/ath/ath10k/snoc.h @@ -42,13 +42,6 @@ struct ath10k_snoc_ce_irq { u32 irq_line; }; -struct ath10k_clk_info { - struct clk *handle; - const char *name; - u32 freq; - bool required; -}; - enum ath10k_snoc_flags { ATH10K_SNOC_FLAG_REGISTERED, ATH10K_SNOC_FLAG_UNREGISTERING, @@ -56,6 +49,7 @@ enum ath10k_snoc_flags { ATH10K_SNOC_FLAG_8BIT_HOST_CAP_QUIRK, }; +struct clk_bulk_data; struct regulator_bulk_data; struct ath10k_snoc { @@ -71,7 +65,8 @@ struct ath10k_snoc { struct timer_list rx_post_retry; struct regulator_bulk_data *vregs; size_t num_vregs; - struct ath10k_clk_info *clk; + struct clk_bulk_data *clks; + size_t num_clks; struct ath10k_qmi *qmi; unsigned long flags; };