From patchwork Fri Mar 10 04:08:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 67211 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp679500wrd; Thu, 9 Mar 2023 20:25:15 -0800 (PST) X-Google-Smtp-Source: AK7set8DK5eVR6wqlCbhLPSE4Bz25XcrBGE11auiAmB/TrEcYbJUuhI1aruUin2FWLYVG933LTr6 X-Received: by 2002:a05:6a20:a111:b0:cc:7967:8a71 with SMTP id q17-20020a056a20a11100b000cc79678a71mr25588776pzk.59.1678422315692; Thu, 09 Mar 2023 20:25:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678422315; cv=none; d=google.com; s=arc-20160816; b=wVvLqtlTOYvTs3OY+xmDUWOPZxEp90QKWcp+TGSKyusOZnouyYTfjpgz2Rxn8ocF70 g4tuSwSIKj8w/gG7rYq2vi+NEEvTFmICljKxQW4mB9S6jGe4I8/g3thOVRab0e3fkYLA 3X2gJB3eT5pLpbVzl6tCasBtrR+e3Pta4Tf0vmIBB0apTpsWI1RZlDiYOCwNRRXjHd2L 418Ry1TO5QLDr3Sj9+ni/E55c/zFh9uzMXiViu8zRgGPRYtAiNEEsr5wkbitdiOq7waZ Hg+j4PMpIEwtVgdXF31auq8WYMD6Nvkh6L84pjZb698IbkrYjt8S/1cUBOgM//pHcl8p MbQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KBoZXs7oWaG22XZASLiUsiWHjHyRIoI/eDEhjgIXc7Q=; b=n21HTvWlXZw8+c1igtD+TLvLqEfIfiNSjF4EbS+CyLIuGofnHXPYAR8/EtiVAtB9y1 iGNehtCIngU3vG+mueyBME5r2TE/uJRoxtl5BhfQy9YF9Ss2s+J5M66qTsTBpG5tiVk7 9DLPsE4fDfcwvoXooK7dJnM2NE9J2QsHhBSatTLLfEunWuFFH+pUhRyfgyHkzSYqUYKw /vYv3z/MKv27BIk9rRhY/jGWV68YDNAcBU6Z9zqYidWtJv+8HTGCJXatnwKHhrMCoUlM 8kN8cSWM4PwQe/NDLHPsj9JeAQZO0rDvkbG2Qf2ONaaNWUD7tpboCKVdHyw2Ua8j9YAs ifRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="m+C/YrwH"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c20-20020a634e14000000b005034a4830cbsi952260pgb.181.2023.03.09.20.25.03; Thu, 09 Mar 2023 20:25:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="m+C/YrwH"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S230242AbjCJEKs (ORCPT + 99 others); Thu, 9 Mar 2023 23:10:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230305AbjCJEJm (ORCPT ); Thu, 9 Mar 2023 23:09:42 -0500 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 715B0F5D29 for ; Thu, 9 Mar 2023 20:09:16 -0800 (PST) Received: by mail-pf1-x430.google.com with SMTP id bd34so2875137pfb.3 for ; Thu, 09 Mar 2023 20:09:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678421354; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KBoZXs7oWaG22XZASLiUsiWHjHyRIoI/eDEhjgIXc7Q=; b=m+C/YrwHwt2i9/sGEdK99+vcNqF83EGmJ0/z8OiTYb6lKp60bIz/sMYHQCqg5FNrbJ iSmESv8doN6a3D2ie0bXRPD76AD78QJLwNXsGzuXp7UA+XHooI4aFObllYc0LpLc9SVy jTXrF2/Ziz3ZdSJ6KZK0GQO5ia05ylEgJyx8cpO4ndxSsj0VPkHqVd7JPigEgGEw5RYc Iu27AP/FFtrxv4WOdfCpTy1Ps2f4WecyAfm6UJEkISFEJs5O1XTiRc09I14LoTXZRM+x 7HXfKPkzL4yHSIuWsVCevdXUbW+LCCfYej8orKO4hqi7lj6rC6zkc5OQOmBAQ3gWN4H+ lxPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678421354; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KBoZXs7oWaG22XZASLiUsiWHjHyRIoI/eDEhjgIXc7Q=; b=7tT46BDU/YhxeBdlllok3W9ew12chKbInviFx8nv+2xC9Px4q4tCPZhDAbpSQ0PyPn J88NADHO5Ms0zBYWy2syQwRzI9lWROOMPZnjHour2MQuEUeMBMr8xECHqV7j7jocUdwF ae31jnHfonNK5lorBidlHukZLtE086DwoCog9YpM+mw3yDwDeyKLpU2DoJXFwkxFD6eV DBos+PWXv1cD2Hr+O4csRp58iMIja4tQlwi3n50/vzjyyTqjPkO+C3fVCPBPaI3jd4Cb +jS+yCgRQsOyIxTbzobp5k1V5Svm11qsbHiqH+k6Rr9C06pfSBa5enpvnLK1y2QSKian 9TYg== X-Gm-Message-State: AO0yUKVvj5fWmOnUK/kkY8ICIX/P8w/sXfoa1/4gouJ9LAHT6gJM80Fb G8e/lGw66dmCTir4BSIDnzlh X-Received: by 2002:aa7:942a:0:b0:5e0:1073:1f25 with SMTP id y10-20020aa7942a000000b005e010731f25mr20028021pfo.7.1678421354009; Thu, 09 Mar 2023 20:09:14 -0800 (PST) Received: from localhost.localdomain ([27.111.75.67]) by smtp.gmail.com with ESMTPSA id y26-20020aa7855a000000b0058d92d6e4ddsm361846pfn.5.2023.03.09.20.09.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 20:09:13 -0800 (PST) From: Manivannan Sadhasivam To: andersson@kernel.org, lpieralisi@kernel.org, kw@linux.com, krzysztof.kozlowski+dt@linaro.org, robh@kernel.org Cc: konrad.dybcio@linaro.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, quic_srichara@quicinc.com, Manivannan Sadhasivam Subject: [PATCH v3 10/19] PCI: qcom: Use bulk reset APIs for handling resets for IP rev 2.3.3 Date: Fri, 10 Mar 2023 09:38:07 +0530 Message-Id: <20230310040816.22094-11-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230310040816.22094-1-manivannan.sadhasivam@linaro.org> References: <20230310040816.22094-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759953358204763645?= X-GMAIL-MSGID: =?utf-8?q?1759953358204763645?= All the resets are asserted and deasserted at the same time. So the bulk reset APIs can be used to handle them together. This simplifies the code a lot. Signed-off-by: Manivannan Sadhasivam --- drivers/pci/controller/dwc/pcie-qcom.c | 49 ++++++++++++-------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c index 6b83e3627336..8c39fc554a89 100644 --- a/drivers/pci/controller/dwc/pcie-qcom.c +++ b/drivers/pci/controller/dwc/pcie-qcom.c @@ -170,9 +170,10 @@ struct qcom_pcie_resources_2_3_2 { }; #define QCOM_PCIE_2_3_3_MAX_CLOCKS 5 +#define QCOM_PCIE_2_3_3_MAX_RESETS 7 struct qcom_pcie_resources_2_3_3 { struct clk_bulk_data clks[QCOM_PCIE_2_3_3_MAX_CLOCKS]; - struct reset_control *rst[7]; + struct reset_control_bulk_data rst[QCOM_PCIE_2_3_3_MAX_RESETS]; }; #define QCOM_PCIE_2_4_0_MAX_CLOCKS 4 @@ -889,10 +890,6 @@ static int qcom_pcie_get_resources_2_3_3(struct qcom_pcie *pcie) struct qcom_pcie_resources_2_3_3 *res = &pcie->res.v2_3_3; struct dw_pcie *pci = pcie->pci; struct device *dev = pci->dev; - int i; - const char *rst_names[] = { "axi_m", "axi_s", "pipe", - "axi_m_sticky", "sticky", - "ahb", "sleep", }; int ret; res->clks[0].id = "iface"; @@ -905,11 +902,17 @@ static int qcom_pcie_get_resources_2_3_3(struct qcom_pcie *pcie) if (ret < 0) return ret; - for (i = 0; i < ARRAY_SIZE(rst_names); i++) { - res->rst[i] = devm_reset_control_get(dev, rst_names[i]); - if (IS_ERR(res->rst[i])) - return PTR_ERR(res->rst[i]); - } + res->rst[0].id = "axi_m"; + res->rst[1].id = "axi_s"; + res->rst[2].id = "pipe"; + res->rst[3].id = "axi_m_sticky"; + res->rst[4].id = "sticky"; + res->rst[5].id = "ahb"; + res->rst[6].id = "sleep"; + + ret = devm_reset_control_bulk_get_exclusive(dev, ARRAY_SIZE(res->rst), res->rst); + if (ret < 0) + return ret; return 0; } @@ -926,25 +929,20 @@ static int qcom_pcie_init_2_3_3(struct qcom_pcie *pcie) struct qcom_pcie_resources_2_3_3 *res = &pcie->res.v2_3_3; struct dw_pcie *pci = pcie->pci; struct device *dev = pci->dev; - int i, ret; + int ret; - for (i = 0; i < ARRAY_SIZE(res->rst); i++) { - ret = reset_control_assert(res->rst[i]); - if (ret) { - dev_err(dev, "reset #%d assert failed (%d)\n", i, ret); - return ret; - } + ret = reset_control_bulk_assert(ARRAY_SIZE(res->rst), res->rst); + if (ret < 0) { + dev_err(dev, "cannot assert resets\n"); + return ret; } usleep_range(2000, 2500); - for (i = 0; i < ARRAY_SIZE(res->rst); i++) { - ret = reset_control_deassert(res->rst[i]); - if (ret) { - dev_err(dev, "reset #%d deassert failed (%d)\n", i, - ret); - return ret; - } + ret = reset_control_bulk_deassert(ARRAY_SIZE(res->rst), res->rst); + if (ret < 0) { + dev_err(dev, "cannot deassert resets\n"); + return ret; } /* @@ -966,8 +964,7 @@ static int qcom_pcie_init_2_3_3(struct qcom_pcie *pcie) * Not checking for failure, will anyway return * the original failure in 'ret'. */ - for (i = 0; i < ARRAY_SIZE(res->rst); i++) - reset_control_assert(res->rst[i]); + reset_control_bulk_assert(ARRAY_SIZE(res->rst), res->rst); return ret; }