From patchwork Tue Jun 25 10:40:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Moon X-Patchwork-Id: 13710854 X-Patchwork-Delegate: kw@linux.com Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E938D11CBD; Tue, 25 Jun 2024 10:40:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719312057; cv=none; b=IbxTngdRHu4PY73MVSuO3zLsz25oz4QLLnBp8NYrSUOOrLJNXGsONl+raztfgeCmbU2psk8ox/DtXIPGvuKyIvF/NL3Pai9matDFvNH/Xs4YhSoYt4pYIm0JDo0jswCPax0y3ELdNfKzyhqqeEwa6G7X01cMR6jgYWuPeP1Y8Zk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719312057; c=relaxed/simple; bh=jXbOYxGHu4Vbc9kz7XDfhcIX81LMwxCNM5pvQ+M1knQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=NJw79i89UoYD7wdEMS2JSmjjFm9+z7eIeWtAB+EIAVlyjX5yPyNVpNWrNsGeyPX3xhTxd4+hOIflDz2nsZBxXuzV3SCa5mEFlbiRWnNVYiWw8RHVrsU9g66OYW8uakzM7PqUxWExS3XEm5BFvGE4wQvst64qCb14dB8c5ubUxug= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=I/CPY5oy; arc=none smtp.client-ip=209.85.210.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="I/CPY5oy" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-7067108f2cdso2109436b3a.1; Tue, 25 Jun 2024 03:40:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719312055; x=1719916855; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=il3Ey5Gsm4oBBZ02CLeVI03mpmEtmmFpL868Qx4qwFI=; b=I/CPY5oyoGP3HxjUHqJIK6RiQuS2ybTcBK+C0xEVj4mWPwjBDD1C9eVwha8p6PcFLK +tToQH/StjkdoT7YKU2nU8Dau7J0qY3BKVwljiVcdi1C2xzUuf8TaZpSjXK986fNdNEv GOEkqRKAQQ00p+XL4y1qEt1uaqWGUlrW9ts6Dj+yJlcdlv+if2AXxyWx9f8p8i78JWXv ia0UjTo/lyDlyBYJWo9DZVSfvcekduAVtZ+MhLUc55TIW5bqATHh3aTPv5Q43awIfBXM mIUg7l1oReohoaxA0G2fQg8ovI7k6E+AZYCZAPTKiy8CnoLEfOVBFywhwhRHAYd/U9L7 zRyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719312055; x=1719916855; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=il3Ey5Gsm4oBBZ02CLeVI03mpmEtmmFpL868Qx4qwFI=; b=VzO2vV0/iDMJkAYPRiLbpaxjDUows2VDSM9uNL07uMN9GCnIvLcnAftNqpkDCqx6P/ tDdnEoccTrc2xPDni/VExWH1easI3PJhm6FAZ72L3LCwsYB/tvW2HNC8lY3XxkqJZfay VQy304fJIphOmKT9SecFALIxVMcp0IATqlAxYr4oCN+2oSbqZ/VUL593hUgK4FrWPlYK zYXQ7zqJ/WZeFQ/RZghMtYAFrCKtmVuwdze4VUX6QgRl3D4abGGauc2cclLj3kLyC6DI 4AyCqN7JTlexUEWgXoASs7tXjWNV/Dk566ps5V5rG6gpMeXbq/MW1tanZsv9ZcuhwFbG 6siA== X-Forwarded-Encrypted: i=1; AJvYcCUS+c4mhZwy9pJRmXbRTnoMZCNDdNaGsaASLT+sw1V3JOE32/esaf5f+XfQSi0pTcxniHMUc1ENzKFdxc8Ptq9QGWT+OS+hY0SVC4CrCiebkq5grNtjAdmF0rGNc9NHp9494mM5mVgm X-Gm-Message-State: AOJu0YzH13qJL9subF7LXrlFBxFr8zd6/y+9pddqAp/GUEefBlXvoIXW fN/tWKFA0MQ0occNmhiuOpooZHBrKlF26FNxMT/GrUDHJkijtbf2 X-Google-Smtp-Source: AGHT+IG5jMBJIUjR09xa4CpVgIEtsG2aJEYqUh5bHUayd+mBtoMCOI7oMvAVeuXfekdaoIvcE10DfA== X-Received: by 2002:a05:6a00:80ca:b0:705:e773:f8da with SMTP id d2e1a72fcca58-70670ee781dmr6251744b3a.15.1719312054989; Tue, 25 Jun 2024 03:40:54 -0700 (PDT) Received: from localhost.localdomain ([113.30.217.222]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7065e2c103bsm6943684b3a.92.2024.06.25.03.40.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jun 2024 03:40:54 -0700 (PDT) From: Anand Moon To: Shawn Lin , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas , Heiko Stuebner Cc: Anand Moon , linux-pci@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 1/3] PCI: rockchip: Simplify clock handling by using clk_bulk*() function Date: Tue, 25 Jun 2024 16:10:32 +0530 Message-ID: <20240625104039.48311-1-linux.amoon@gmail.com> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Refactor the clock handling in the Rockchip PCIe driver, introducing a more robust and efficient method for enabling and disabling clocks using clk_bulk*() API. Using the clk_bulk APIs, the clock handling for the core clocks becomes much simpler. Signed-off-by: Anand Moon --- v4: use dev_err_probe for error patch. v3: Fix typo in commit message, dropped reported by. v2: Fix compilation error reported by Intel test robot. --- drivers/pci/controller/pcie-rockchip.c | 68 ++++---------------------- drivers/pci/controller/pcie-rockchip.h | 15 ++++-- 2 files changed, 21 insertions(+), 62 deletions(-) base-commit: 35bb670d65fc0f80c62383ab4f2544cec85ac57a diff --git a/drivers/pci/controller/pcie-rockchip.c b/drivers/pci/controller/pcie-rockchip.c index 0ef2e622d36e..804135511528 100644 --- a/drivers/pci/controller/pcie-rockchip.c +++ b/drivers/pci/controller/pcie-rockchip.c @@ -30,7 +30,7 @@ int rockchip_pcie_parse_dt(struct rockchip_pcie *rockchip) struct platform_device *pdev = to_platform_device(dev); struct device_node *node = dev->of_node; struct resource *regs; - int err; + int err, i; if (rockchip->is_rc) { regs = platform_get_resource_byname(pdev, @@ -127,29 +127,12 @@ int rockchip_pcie_parse_dt(struct rockchip_pcie *rockchip) "failed to get ep GPIO\n"); } - rockchip->aclk_pcie = devm_clk_get(dev, "aclk"); - if (IS_ERR(rockchip->aclk_pcie)) { - dev_err(dev, "aclk clock not found\n"); - return PTR_ERR(rockchip->aclk_pcie); - } - - rockchip->aclk_perf_pcie = devm_clk_get(dev, "aclk-perf"); - if (IS_ERR(rockchip->aclk_perf_pcie)) { - dev_err(dev, "aclk_perf clock not found\n"); - return PTR_ERR(rockchip->aclk_perf_pcie); - } - - rockchip->hclk_pcie = devm_clk_get(dev, "hclk"); - if (IS_ERR(rockchip->hclk_pcie)) { - dev_err(dev, "hclk clock not found\n"); - return PTR_ERR(rockchip->hclk_pcie); - } + for (i = 0; i < ROCKCHIP_NUM_CLKS; i++) + rockchip->clks[i].id = rockchip_pci_clks[i]; - rockchip->clk_pcie_pm = devm_clk_get(dev, "pm"); - if (IS_ERR(rockchip->clk_pcie_pm)) { - dev_err(dev, "pm clock not found\n"); - return PTR_ERR(rockchip->clk_pcie_pm); - } + err = devm_clk_bulk_get(dev, ROCKCHIP_NUM_CLKS, rockchip->clks); + if (err) + return dev_err_probe(dev, err, "failed to get clocks\n"); return 0; } @@ -372,39 +355,11 @@ int rockchip_pcie_enable_clocks(struct rockchip_pcie *rockchip) struct device *dev = rockchip->dev; int err; - err = clk_prepare_enable(rockchip->aclk_pcie); - if (err) { - dev_err(dev, "unable to enable aclk_pcie clock\n"); - return err; - } - - err = clk_prepare_enable(rockchip->aclk_perf_pcie); - if (err) { - dev_err(dev, "unable to enable aclk_perf_pcie clock\n"); - goto err_aclk_perf_pcie; - } - - err = clk_prepare_enable(rockchip->hclk_pcie); - if (err) { - dev_err(dev, "unable to enable hclk_pcie clock\n"); - goto err_hclk_pcie; - } - - err = clk_prepare_enable(rockchip->clk_pcie_pm); - if (err) { - dev_err(dev, "unable to enable clk_pcie_pm clock\n"); - goto err_clk_pcie_pm; - } + err = clk_bulk_prepare_enable(ROCKCHIP_NUM_CLKS, rockchip->clks); + if (err) + return dev_err_probe(dev, err, "failed to enable clocks\n"); return 0; - -err_clk_pcie_pm: - clk_disable_unprepare(rockchip->hclk_pcie); -err_hclk_pcie: - clk_disable_unprepare(rockchip->aclk_perf_pcie); -err_aclk_perf_pcie: - clk_disable_unprepare(rockchip->aclk_pcie); - return err; } EXPORT_SYMBOL_GPL(rockchip_pcie_enable_clocks); @@ -412,10 +367,7 @@ void rockchip_pcie_disable_clocks(void *data) { struct rockchip_pcie *rockchip = data; - clk_disable_unprepare(rockchip->clk_pcie_pm); - clk_disable_unprepare(rockchip->hclk_pcie); - clk_disable_unprepare(rockchip->aclk_perf_pcie); - clk_disable_unprepare(rockchip->aclk_pcie); + clk_bulk_disable_unprepare(ROCKCHIP_NUM_CLKS, rockchip->clks); } EXPORT_SYMBOL_GPL(rockchip_pcie_disable_clocks); diff --git a/drivers/pci/controller/pcie-rockchip.h b/drivers/pci/controller/pcie-rockchip.h index 6111de35f84c..72346e17e45e 100644 --- a/drivers/pci/controller/pcie-rockchip.h +++ b/drivers/pci/controller/pcie-rockchip.h @@ -11,6 +11,7 @@ #ifndef _PCIE_ROCKCHIP_H #define _PCIE_ROCKCHIP_H +#include #include #include #include @@ -287,6 +288,15 @@ (((c) << ((b) * 8 + 5)) & \ ROCKCHIP_PCIE_CORE_EP_FUNC_BAR_CFG_BAR_CTRL_MASK(b)) +#define ROCKCHIP_NUM_CLKS ARRAY_SIZE(rockchip_pci_clks) + +static const char * const rockchip_pci_clks[] = { + "aclk", + "aclk-perf", + "hclk", + "pm", +}; + struct rockchip_pcie { void __iomem *reg_base; /* DT axi-base */ void __iomem *apb_base; /* DT apb-base */ @@ -299,10 +309,7 @@ struct rockchip_pcie { struct reset_control *pm_rst; struct reset_control *aclk_rst; struct reset_control *pclk_rst; - struct clk *aclk_pcie; - struct clk *aclk_perf_pcie; - struct clk *hclk_pcie; - struct clk *clk_pcie_pm; + struct clk_bulk_data clks[ROCKCHIP_NUM_CLKS]; struct regulator *vpcie12v; /* 12V power supply */ struct regulator *vpcie3v3; /* 3.3V power supply */ struct regulator *vpcie1v8; /* 1.8V power supply */ From patchwork Tue Jun 25 10:40:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Moon X-Patchwork-Id: 13710855 X-Patchwork-Delegate: kw@linux.com Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E791314A4D9; Tue, 25 Jun 2024 10:41:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719312063; cv=none; b=PcEm2sBIjVM38wmr++0OXe5oS6CZ1DdBCiNs7uWx/wsrN+pZUcscG2H1E4zto4+J98lZlRD87SMBzY7qiZCOAcaWLMGVNpdygl7IQ4XEv2+E7mXMOBzc4tRmtgTYOq/T7KjSyu/+Xsxu8JRfL2FbPrd+EryTpdi3FWPCwYxknvQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719312063; c=relaxed/simple; bh=vcIRUlY7HNFjEWkiwJIkXujpOLSc35LWB0A471Xaeb8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W118/SL92d1wSxpCBXEdzOg5kNLEVwlKMqAiGnmZ9BgbLf/hfIJreziSjTo4WkOEtSEFLSAMdntM4yCoSgNurw+MVot6oGZbohWFmNol6LV8ZIPuro80pogiBQziZFWxwppGPtZdOXMo9y9vWJTq62klytxzUNkdmIQIbePYrZ4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=aKf9W+I9; arc=none smtp.client-ip=209.85.210.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aKf9W+I9" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-706642b4403so2109536b3a.1; Tue, 25 Jun 2024 03:41:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719312061; x=1719916861; darn=vger.kernel.org; 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=CmT4s3ayNwWOKvzaOoNhVLRC8FbeY8Nt59145arso+U=; b=aKf9W+I9Qpc8ji+ohoPVjn/lIwBfvmyM2gQLpmHw6KCf/vZ6MJm18uFFrYyxFxqDJq HqHOwxNDUzu6Ukn3HsF16MfWRoFwclCbNmRHlipnP8CE0kDXS5VxBHpMr2gBqlnHHgLb AVsMDsVMpEJJiwi62c2Ea/hbNXoxSgJR9ubUBupHAtWelOUwLxnbV5NduWkamTLRMRx6 94UJWD5iHBNzFrcdxynzn12Fht5Jq9u38B1CJ22TPljZS/qzTI/qMd2Lo3lDvcEmpsiM jNyvkqAnEXdG5UWdTgJJuXTRh16KcHjaMkd2iXYLKdU+Qf1tie1KeLiFGErJtEv8nc6q eW9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719312061; x=1719916861; 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=CmT4s3ayNwWOKvzaOoNhVLRC8FbeY8Nt59145arso+U=; b=B+nsecFMyFA9C3SGfISK4QYB9V5SPXqwUux2D6WKw1vUzJfWpVpJPy3UCvfeoNd7Ks vPH95ofyE3SMW+Z9N4ynSR2WiLE15FY0jxJsBEUis0RAUsl/uFToKvekjlU8mfGepXKD N7TI14Ga4LHaX0Odl6f3egOeXxIZON2piUfKd5mUwPXGZio5T2kkXOTzb30c6WRMXNb7 RWXxF68g3eYKsB/VjIY5X/+h9buzrSd0+vRbSvc0RegUaI23gdGbzwiQBhL9fIosMc+3 sDQcbZuUspKgtlxRcNupFuLpcVlD9fUYZSZnY2Nr9JBoqHggSimGyBR/H6saHSoER64K rQhQ== X-Forwarded-Encrypted: i=1; AJvYcCXoVrwjU+flR3ohGq/9ohwUtwJFEuSWxMavCeTP40e/2Zj83FmvO4ltXVh/+5eIy2Hos5zs9rsxI3sFI8emaWfERvy0YSnWmmf7vgoM7hho8fJ86ZAw+MdcpclZtnZt6kupG7gz8ajb X-Gm-Message-State: AOJu0YxOtcuHTw0XLLRV1Nlvk8VFTJTHASHScZt6BZX/CvREhtrSsshL +LP8Em/8NA1FMrWRlAWx1QCS7Xfd6WpLAMKZGvoOY9zuo+kVO6E7 X-Google-Smtp-Source: AGHT+IE6y1UGsfoPQbvwH23h18XrNUiwIrKD5i4O22Usux9OMnjY9jxvnw0zcyP5S2M45MwutORDhg== X-Received: by 2002:a05:6a00:7011:b0:705:d6ad:2495 with SMTP id d2e1a72fcca58-70669de6591mr9847511b3a.12.1719312061109; Tue, 25 Jun 2024 03:41:01 -0700 (PDT) Received: from localhost.localdomain ([113.30.217.222]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7065e2c103bsm6943684b3a.92.2024.06.25.03.40.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jun 2024 03:41:00 -0700 (PDT) From: Anand Moon To: Shawn Lin , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas , Heiko Stuebner , Philipp Zabel Cc: Anand Moon , linux-pci@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 2/3] PCI: rockchip: Simplify reset control handling by using reset_control_bulk*() function Date: Tue, 25 Jun 2024 16:10:33 +0530 Message-ID: <20240625104039.48311-2-linux.amoon@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240625104039.48311-1-linux.amoon@gmail.com> References: <20240625104039.48311-1-linux.amoon@gmail.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Refactor the reset control handling in the Rockchip PCIe driver, introducing a more robust and efficient method for assert and deassert reset controller using reset_control_bulk*() API. Using the reset_control_bulk APIs, the reset handling for the core clocks reset unit becomes much simpler. As per rockchip rk3399 TRM SOFTRST_CON8 soft reset controller have clock reset unit value set to 0x1 for example "pcie_pipe", "pcie_mgmt_sticky", "pcie_mgmt" and "pci_core", hence group then under one reset bulk controller. Where as "pcie_pm", "presetn_pcie", "aresetn_pcie" have reset value set to 0x0, hence group them under reset control bulk controller. Signed-off-by: Anand Moon --- v4: use dev_err_probe in error path. v3: Fix typo in commit message, dropped reported by. v2: Fix compilation error reported by Intel test robot fixed checkpatch warning --- drivers/pci/controller/pcie-rockchip.c | 149 +++++-------------------- drivers/pci/controller/pcie-rockchip.h | 25 +++-- 2 files changed, 47 insertions(+), 127 deletions(-) diff --git a/drivers/pci/controller/pcie-rockchip.c b/drivers/pci/controller/pcie-rockchip.c index 804135511528..024308bb6ac8 100644 --- a/drivers/pci/controller/pcie-rockchip.c +++ b/drivers/pci/controller/pcie-rockchip.c @@ -69,55 +69,23 @@ int rockchip_pcie_parse_dt(struct rockchip_pcie *rockchip) if (rockchip->link_gen < 0 || rockchip->link_gen > 2) rockchip->link_gen = 2; - rockchip->core_rst = devm_reset_control_get_exclusive(dev, "core"); - if (IS_ERR(rockchip->core_rst)) { - if (PTR_ERR(rockchip->core_rst) != -EPROBE_DEFER) - dev_err(dev, "missing core reset property in node\n"); - return PTR_ERR(rockchip->core_rst); - } - - rockchip->mgmt_rst = devm_reset_control_get_exclusive(dev, "mgmt"); - if (IS_ERR(rockchip->mgmt_rst)) { - if (PTR_ERR(rockchip->mgmt_rst) != -EPROBE_DEFER) - dev_err(dev, "missing mgmt reset property in node\n"); - return PTR_ERR(rockchip->mgmt_rst); - } - - rockchip->mgmt_sticky_rst = devm_reset_control_get_exclusive(dev, - "mgmt-sticky"); - if (IS_ERR(rockchip->mgmt_sticky_rst)) { - if (PTR_ERR(rockchip->mgmt_sticky_rst) != -EPROBE_DEFER) - dev_err(dev, "missing mgmt-sticky reset property in node\n"); - return PTR_ERR(rockchip->mgmt_sticky_rst); - } - - rockchip->pipe_rst = devm_reset_control_get_exclusive(dev, "pipe"); - if (IS_ERR(rockchip->pipe_rst)) { - if (PTR_ERR(rockchip->pipe_rst) != -EPROBE_DEFER) - dev_err(dev, "missing pipe reset property in node\n"); - return PTR_ERR(rockchip->pipe_rst); - } + for (i = 0; i < ROCKCHIP_NUM_PM_RSTS; i++) + rockchip->pm_rsts[i].id = rockchip_pci_pm_rsts[i]; - rockchip->pm_rst = devm_reset_control_get_exclusive(dev, "pm"); - if (IS_ERR(rockchip->pm_rst)) { - if (PTR_ERR(rockchip->pm_rst) != -EPROBE_DEFER) - dev_err(dev, "missing pm reset property in node\n"); - return PTR_ERR(rockchip->pm_rst); - } + err = devm_reset_control_bulk_get_optional_exclusive(dev, + ROCKCHIP_NUM_PM_RSTS, + rockchip->pm_rsts); + if (err) + return dev_err_probe(dev, err, "cannot get the reset control\n"); - rockchip->pclk_rst = devm_reset_control_get_exclusive(dev, "pclk"); - if (IS_ERR(rockchip->pclk_rst)) { - if (PTR_ERR(rockchip->pclk_rst) != -EPROBE_DEFER) - dev_err(dev, "missing pclk reset property in node\n"); - return PTR_ERR(rockchip->pclk_rst); - } + for (i = 0; i < ROCKCHIP_NUM_CORE_RSTS; i++) + rockchip->core_rsts[i].id = rockchip_pci_core_rsts[i]; - rockchip->aclk_rst = devm_reset_control_get_exclusive(dev, "aclk"); - if (IS_ERR(rockchip->aclk_rst)) { - if (PTR_ERR(rockchip->aclk_rst) != -EPROBE_DEFER) - dev_err(dev, "missing aclk reset property in node\n"); - return PTR_ERR(rockchip->aclk_rst); - } + err = devm_reset_control_bulk_get_optional_exclusive(dev, + ROCKCHIP_NUM_CORE_RSTS, + rockchip->core_rsts); + if (err) + return dev_err_probe(dev, err, "cannot get the reset control\n"); if (rockchip->is_rc) { rockchip->ep_gpio = devm_gpiod_get_optional(dev, "ep", @@ -150,23 +118,10 @@ int rockchip_pcie_init_port(struct rockchip_pcie *rockchip) int err, i; u32 regs; - err = reset_control_assert(rockchip->aclk_rst); - if (err) { - dev_err(dev, "assert aclk_rst err %d\n", err); - return err; - } - - err = reset_control_assert(rockchip->pclk_rst); - if (err) { - dev_err(dev, "assert pclk_rst err %d\n", err); - return err; - } - - err = reset_control_assert(rockchip->pm_rst); - if (err) { - dev_err(dev, "assert pm_rst err %d\n", err); - return err; - } + err = reset_control_bulk_assert(ROCKCHIP_NUM_PM_RSTS, + rockchip->pm_rsts); + if (err) + return dev_err_probe(dev, err, "reset bulk assert pm reset\n"); for (i = 0; i < MAX_LANE_NUM; i++) { err = phy_init(rockchip->phys[i]); @@ -176,47 +131,17 @@ int rockchip_pcie_init_port(struct rockchip_pcie *rockchip) } } - err = reset_control_assert(rockchip->core_rst); - if (err) { - dev_err(dev, "assert core_rst err %d\n", err); - goto err_exit_phy; - } - - err = reset_control_assert(rockchip->mgmt_rst); - if (err) { - dev_err(dev, "assert mgmt_rst err %d\n", err); - goto err_exit_phy; - } - - err = reset_control_assert(rockchip->mgmt_sticky_rst); - if (err) { - dev_err(dev, "assert mgmt_sticky_rst err %d\n", err); - goto err_exit_phy; - } - - err = reset_control_assert(rockchip->pipe_rst); - if (err) { - dev_err(dev, "assert pipe_rst err %d\n", err); - goto err_exit_phy; - } + err = reset_control_bulk_assert(ROCKCHIP_NUM_CORE_RSTS, + rockchip->core_rsts); + if (err) + return dev_err_probe(dev, err, "reset bulk assert core reset\n"); udelay(10); - err = reset_control_deassert(rockchip->pm_rst); - if (err) { - dev_err(dev, "deassert pm_rst err %d\n", err); - goto err_exit_phy; - } - - err = reset_control_deassert(rockchip->aclk_rst); - if (err) { - dev_err(dev, "deassert aclk_rst err %d\n", err); - goto err_exit_phy; - } - - err = reset_control_deassert(rockchip->pclk_rst); + err = reset_control_bulk_deassert(ROCKCHIP_NUM_PM_RSTS, + rockchip->pm_rsts); if (err) { - dev_err(dev, "deassert pclk_rst err %d\n", err); + dev_err(dev, "reset bulk deassert pm err %d\n", err); goto err_exit_phy; } @@ -259,31 +184,15 @@ int rockchip_pcie_init_port(struct rockchip_pcie *rockchip) * Please don't reorder the deassert sequence of the following * four reset pins. */ - err = reset_control_deassert(rockchip->mgmt_sticky_rst); - if (err) { - dev_err(dev, "deassert mgmt_sticky_rst err %d\n", err); - goto err_power_off_phy; - } - - err = reset_control_deassert(rockchip->core_rst); + err = reset_control_bulk_deassert(ROCKCHIP_NUM_CORE_RSTS, + rockchip->core_rsts); if (err) { - dev_err(dev, "deassert core_rst err %d\n", err); - goto err_power_off_phy; - } - - err = reset_control_deassert(rockchip->mgmt_rst); - if (err) { - dev_err(dev, "deassert mgmt_rst err %d\n", err); - goto err_power_off_phy; - } - - err = reset_control_deassert(rockchip->pipe_rst); - if (err) { - dev_err(dev, "deassert pipe_rst err %d\n", err); + dev_err(dev, "reset bulk deassert core err %d\n", err); goto err_power_off_phy; } return 0; + err_power_off_phy: while (i--) phy_power_off(rockchip->phys[i]); diff --git a/drivers/pci/controller/pcie-rockchip.h b/drivers/pci/controller/pcie-rockchip.h index 72346e17e45e..27e951b41b80 100644 --- a/drivers/pci/controller/pcie-rockchip.h +++ b/drivers/pci/controller/pcie-rockchip.h @@ -15,6 +15,7 @@ #include #include #include +#include /* * The upper 16 bits of PCIE_CLIENT_CONFIG are a write mask for the lower 16 @@ -289,6 +290,8 @@ ROCKCHIP_PCIE_CORE_EP_FUNC_BAR_CFG_BAR_CTRL_MASK(b)) #define ROCKCHIP_NUM_CLKS ARRAY_SIZE(rockchip_pci_clks) +#define ROCKCHIP_NUM_PM_RSTS ARRAY_SIZE(rockchip_pci_pm_rsts) +#define ROCKCHIP_NUM_CORE_RSTS ARRAY_SIZE(rockchip_pci_core_rsts) static const char * const rockchip_pci_clks[] = { "aclk", @@ -297,18 +300,26 @@ static const char * const rockchip_pci_clks[] = { "pm", }; +static const char * const rockchip_pci_pm_rsts[] = { + "pm", + "pclk", + "aclk", +}; + +static const char * const rockchip_pci_core_rsts[] = { + "core", + "mgmt", + "mgmt-sticky", + "pipe", +}; + struct rockchip_pcie { void __iomem *reg_base; /* DT axi-base */ void __iomem *apb_base; /* DT apb-base */ bool legacy_phy; struct phy *phys[MAX_LANE_NUM]; - struct reset_control *core_rst; - struct reset_control *mgmt_rst; - struct reset_control *mgmt_sticky_rst; - struct reset_control *pipe_rst; - struct reset_control *pm_rst; - struct reset_control *aclk_rst; - struct reset_control *pclk_rst; + struct reset_control_bulk_data pm_rsts[ROCKCHIP_NUM_PM_RSTS]; + struct reset_control_bulk_data core_rsts[ROCKCHIP_NUM_CORE_RSTS]; struct clk_bulk_data clks[ROCKCHIP_NUM_CLKS]; struct regulator *vpcie12v; /* 12V power supply */ struct regulator *vpcie3v3; /* 3.3V power supply */ From patchwork Tue Jun 25 10:40:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Moon X-Patchwork-Id: 13710856 X-Patchwork-Delegate: kw@linux.com Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6EA714AD0C; Tue, 25 Jun 2024 10:41:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719312068; cv=none; b=qbujJjYnO35hgKhQXNaD3qZzM0oX8Irul5boG+BApaLXfhlJ2w37XYREv0aF+BBQrAkroQ1wvVNwflK6TzF1HNhmFrPa0cNnCknsomJcKHOHO3iwi4TTCIYWyRnDvjLgdsjbAwCFH8IJ3bZ6urq92YRx3Mxj92h77qACmKa8QlU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719312068; c=relaxed/simple; bh=+3l1EDb9sJoLixksS4zGGZe4ffLwSNKoEZ69qIeFqxk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ibc/VQSh3UNIbrRH9HKmAs5ZXVc/9dRFxcYbrGzNS+VpxUO/EtFAAJVrUe9S6k0FefEOlIpo2gjH/rmH1Y5IgDSfMc0mi5UExbMfdrBBv/FKjyKwMdMbHlUrnH8dWw5+WCMAHO89z+FxI0gYiuz+wAVXWAshIysjP5Hh+johtJs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=IrSiOsWv; arc=none smtp.client-ip=209.85.215.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IrSiOsWv" Received: by mail-pg1-f171.google.com with SMTP id 41be03b00d2f7-71816f36d4dso2418281a12.2; Tue, 25 Jun 2024 03:41:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719312066; x=1719916866; darn=vger.kernel.org; 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=DLjqg6PN+pm75Wv6a0EOHeiThsk5WjokRwaAIzJCByg=; b=IrSiOsWvhAPw/WGCdjNLRFWEDzXO5L4rtHEEexV1lRfPZ8YIEgb/lj/ZXrwFuSbRtx bH7QmNcJd9jGJTbv5HFV+XRnTuxwzZwooDloRF0ikLSs9OZmlamCLT8mTZDfVuoj/xnX i9yLjX0GI9dypWxTEH8N1RuQU1TLyiOE9ctKOpX1naPgodETft5DsldHVTKmmfNcymAh RGxCGegpBb9ADybsa9s64NJU+esauA7EAsqAsoBWK/kRvOrnkx4LZzeWR3sPcCrTlxUO PgBd16f7HVmmOx9NtHMyHu0d4z8F6mX3tViuPPBoqY3WS9lx/lsdOhJfSQJfd+rqV8FO 4pMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719312066; x=1719916866; 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=DLjqg6PN+pm75Wv6a0EOHeiThsk5WjokRwaAIzJCByg=; b=jXcqYwex753DJ9FZSWuAvRIWUexwMrNTuT2utDskzqwseZOE5PZki9Vio43BSlhTvR mXK0HZHaPr7HYOJqOKV7InvExoSsYXXZcc7RwTohiJ4RdWuUH5YAt4eVcNKzBPjqjQ9e btGVurDEORxXw3w0L/KTN+0aURBBdLeJcwt6D9YKIGNSVjFhk5iq6C2bL2932mxDNTx3 +Eex/ZIbxyb3XzaoPU0XDCDh6CpDptbSH9hhr8KU8519fN7QbhQtTV+9U/aKmESDtOYs CoE8Hn5Gjky3njBTm+e+Onv7SiWLGHbJN2NpOErZ/7U25XBOLYsb3rLvnyVl0amPi73s 6WbQ== X-Forwarded-Encrypted: i=1; AJvYcCUwuadlHGgiHQ0y8sygF10HJSnvAiPu1q/BtrkVVuLMNiCG2yNjHeNjRL/Wh2JmTnEUhskVdcMo9P87VLo+GL7EZC99DtPpiDbKxrooert94Fe528rUlH+m26D07dV53EunxTYk1wI8 X-Gm-Message-State: AOJu0YweEBAKo6vLQInOkY/mDMEsG/oD2e1NrSFqd+jXfdtOP3NInYAu GS9609lbmJaObj3zeLRRbjTeqJ4Ne3QmudxjNkEB6sUdbmKS3k+H X-Google-Smtp-Source: AGHT+IFYqQAjhwv2qL8UMHq2EMQeLwd7dv1oCSDvlSzxNm5PLh3wAj2R2zDMEP7eB9VfYrxJy3yGBA== X-Received: by 2002:a05:6a20:da90:b0:1b4:da55:e1be with SMTP id adf61e73a8af0-1bcf7e75050mr9502228637.14.1719312065906; Tue, 25 Jun 2024 03:41:05 -0700 (PDT) Received: from localhost.localdomain ([113.30.217.222]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7065e2c103bsm6943684b3a.92.2024.06.25.03.41.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jun 2024 03:41:05 -0700 (PDT) From: Anand Moon To: Shawn Lin , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas , Heiko Stuebner Cc: Anand Moon , linux-pci@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 3/3] PCI: rockchip: Refactor rockchip_pcie_disable_clocks function signature Date: Tue, 25 Jun 2024 16:10:34 +0530 Message-ID: <20240625104039.48311-3-linux.amoon@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240625104039.48311-1-linux.amoon@gmail.com> References: <20240625104039.48311-1-linux.amoon@gmail.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Updated rockchip_pcie_disable_clocks function to accept a struct rockchip pointer instead of a void pointer. Signed-off-by: Anand Moon Reviewed-by: Manivannan Sadhasivam --- v4: None v3: None v2: None --- drivers/pci/controller/pcie-rockchip.c | 4 +--- drivers/pci/controller/pcie-rockchip.h | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/pcie-rockchip.c b/drivers/pci/controller/pcie-rockchip.c index 024308bb6ac8..81deb7fc6882 100644 --- a/drivers/pci/controller/pcie-rockchip.c +++ b/drivers/pci/controller/pcie-rockchip.c @@ -272,10 +272,8 @@ int rockchip_pcie_enable_clocks(struct rockchip_pcie *rockchip) } EXPORT_SYMBOL_GPL(rockchip_pcie_enable_clocks); -void rockchip_pcie_disable_clocks(void *data) +void rockchip_pcie_disable_clocks(struct rockchip_pcie *rockchip) { - struct rockchip_pcie *rockchip = data; - clk_bulk_disable_unprepare(ROCKCHIP_NUM_CLKS, rockchip->clks); } EXPORT_SYMBOL_GPL(rockchip_pcie_disable_clocks); diff --git a/drivers/pci/controller/pcie-rockchip.h b/drivers/pci/controller/pcie-rockchip.h index 27e951b41b80..3330b1e55dcd 100644 --- a/drivers/pci/controller/pcie-rockchip.h +++ b/drivers/pci/controller/pcie-rockchip.h @@ -354,7 +354,7 @@ int rockchip_pcie_init_port(struct rockchip_pcie *rockchip); int rockchip_pcie_get_phys(struct rockchip_pcie *rockchip); void rockchip_pcie_deinit_phys(struct rockchip_pcie *rockchip); int rockchip_pcie_enable_clocks(struct rockchip_pcie *rockchip); -void rockchip_pcie_disable_clocks(void *data); +void rockchip_pcie_disable_clocks(struct rockchip_pcie *rockchip); void rockchip_pcie_cfg_configuration_accesses( struct rockchip_pcie *rockchip, u32 type);