From patchwork Sun Oct 6 18:24:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Moon X-Patchwork-Id: 13823834 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 77D83CFB424 for ; Sun, 6 Oct 2024 18:27:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+yeBRzaPloJQ7KeU2VK3yi3IxNiQW6k/JsJ/McG6lig=; b=GIfigjjuL9LNvJ ieCWbi0Wxq+fPQo4dR/68/1htXARengjog6JnuMtTWw0XMDY3zz4EjWymYdsN0SGRSWjOmNVsUQQA c3sW1vM2eotjS9R4RBIqhQ4r2JQwoe5EGv3AzwLtZS/f3FvMDiInsrVdn2p6qh3XHKNCTKqk1Ez1r lX45cR3lil3dTF4nmacU1q7W0U6P5gZm7ThyctOtDEoLsHZiqozmM5FWJX7FUEJNV+i+oEQ3XvMq8 JkALnPgeZKtobzg13G3ec8GhpetV9KNZ7OnnhzOH2IdMnEOsSUEcJ8e299+X/2530ICBq1lpr67z/ hIE9GXUzYG+83A4qz8jQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sxVya-00000000QBo-3FlE; Sun, 06 Oct 2024 18:27:28 +0000 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sxVwJ-00000000PqI-0WMI; Sun, 06 Oct 2024 18:25:08 +0000 Received: by mail-pj1-x102a.google.com with SMTP id 98e67ed59e1d1-2e0a5088777so2942631a91.2; Sun, 06 Oct 2024 11:25:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728239106; x=1728843906; darn=lists.infradead.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=BIiaV4Ox+gLOn9Mc+aj8cfaNVwn8b8YJ5I4FANpYiac=; b=J/V0h/BhsyQ5Da8DHbG1Ta3fTrSDLxULEFpJwQ7I4oXz8oxwgwYXJyhWj/cvOh1YuA 2bqEP2+LhYkyOrrto9Xk6wntpeJ99pAiHgjz6TtIyAbB3Q/szVMbT17llw/I5LmMNhI7 7fmQjhFZIp09IrSiltpHVkQGkFCkDVhzKmgdtOSM1IGhSmGF8pcHcTD7dZ6HSSWrErY9 gd1Kr28RYocofJB/cOYfe09bgfalG1yzDjY1zuUv4xYWKEQFhGnZJUMU5xfWS3/cQfQR uTb52NPQaN8mubLuqYliGk0UkpYKbjCsSTL4l8wW96iKQ80cA1ZM7SXKIjRr6MsHOqM6 KECg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728239106; x=1728843906; 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=BIiaV4Ox+gLOn9Mc+aj8cfaNVwn8b8YJ5I4FANpYiac=; b=Bs0TOtPHt9GnApZpOfkLP9rDhxyhs1Q82RE+p3hw5NeNM9O7/t/mdihOMhm+U1UzWy pEnST4cU8XA9mpByNME+QRApg9mqzUkakA2GmkrW0UldCguFJ4jJKK3vSrODP31nHx2Q 0jokSujoCWYb5xuWVvwbkbFDYY54qnacaAojXPVPMQrdh3jvmyBwfFt4Qc4GGgYe26qL W3cnYI57wqZkWkUpqxugsoXemnfOwycFK48MXJqkXXp+BlbwxEDJlYBV6hFg9r24NXMU UxNbppw0U1RZUwmxGYATjOi/oiclPmRJXAy24hoROOxwv1Z8kplH90HJaks98iouPAS5 BSUA== X-Forwarded-Encrypted: i=1; AJvYcCX+n0X0fpXfBrq91dL6ho07B2ndbPNXhtRsuUIPbnxFzqK6eLJMjKIz+VJolKKWnzsd+3e6f5EtWFv564LRNZY=@lists.infradead.org, AJvYcCXy1o+DNSLuNruZu5iBIVT0DmGaLGZLb/EBqJIoaWO2212FJUyoc8TVO7E9HXbVTQazaPKFSozmLftKn8VE2SkW@lists.infradead.org X-Gm-Message-State: AOJu0YyOpjOdcGqGhNsfFiFU9FthmTjhWzdKF5L9pQj16MJQ5n6OLIqk UlE9qfevkp1c+fZfGNqD/eKwtfRFWyDCZwM4GEZCx6ewlYZt0Y28 X-Google-Smtp-Source: AGHT+IFUey3b+n+xgvsk3A3QkIQivs73Fk+cCDp0br0nrKsufgy8h7LMMcoUdhX14sv9BvrRhEbW3g== X-Received: by 2002:a17:90b:4a4a:b0:2e0:b741:cdbe with SMTP id 98e67ed59e1d1-2e1e631e2d4mr11196672a91.26.1728239106336; Sun, 06 Oct 2024 11:25:06 -0700 (PDT) Received: from localhost.localdomain ([113.30.217.221]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e1e85c905esm5458471a91.17.2024.10.06.11.25.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Oct 2024 11:25:06 -0700 (PDT) From: Anand Moon To: Shawn Lin , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Manivannan Sadhasivam , Rob Herring , Bjorn Helgaas , Heiko Stuebner , Philipp Zabel , linux-pci@vger.kernel.org (open list:PCIE DRIVER FOR ROCKCHIP), linux-rockchip@lists.infradead.org (open list:PCIE DRIVER FOR ROCKCHIP), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Rockchip SoC support), linux-kernel@vger.kernel.org (open list) Cc: Anand Moon Subject: [PATCH v6 RESET 1/3] PCI: rockchip: Simplify clock handling by using clk_bulk*() function Date: Sun, 6 Oct 2024 23:54:36 +0530 Message-ID: <20241006182445.3713-2-linux.amoon@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241006182445.3713-1-linux.amoon@gmail.com> References: <20241006182445.3713-1-linux.amoon@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241006_112507_175901_235EB0C9 X-CRM114-Status: GOOD ( 16.82 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org 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 --- v6: None. v5: switch to use use devm_clk_bulk_get_all()? gets rid of hardcoding the clock names in driver. 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 | 65 +++----------------------- drivers/pci/controller/pcie-rockchip.h | 7 ++- 2 files changed, 10 insertions(+), 62 deletions(-) diff --git a/drivers/pci/controller/pcie-rockchip.c b/drivers/pci/controller/pcie-rockchip.c index c07d7129f1c7..2777ef0cb599 100644 --- a/drivers/pci/controller/pcie-rockchip.c +++ b/drivers/pci/controller/pcie-rockchip.c @@ -127,29 +127,9 @@ 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); - } - - 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); - } + rockchip->num_clks = devm_clk_bulk_get_all(dev, &rockchip->clks); + if (rockchip->num_clks < 0) + return dev_err_probe(dev, err, "failed to get clocks\n"); return 0; } @@ -372,39 +352,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 +364,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..bebab80c9553 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 @@ -299,10 +300,8 @@ 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; + int num_clks; struct regulator *vpcie12v; /* 12V power supply */ struct regulator *vpcie3v3; /* 3.3V power supply */ struct regulator *vpcie1v8; /* 1.8V power supply */ From patchwork Sun Oct 6 18:24:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Moon X-Patchwork-Id: 13823835 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DD1C5CFB424 for ; Sun, 6 Oct 2024 18:28:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QSbERuFVGSZpu3UzuKILaTi9loNBA7fWQgqaMITAb08=; b=cNS02xVsz4eo41 CxClpRbjrTV/XSIEq7rfWC3kFWFZ0EepErO86tR9NS7TYHgK5JoAQFvSM2BQk8ITqWvyincojGffo pCrYP0JztbAOu/B4ovwp4Bbg2LVL9o45Ejk/S/MMP5FD+DIUb7/9CMPXXzKoTUyl0V0WdlDioltAU +nvQVTrLOF8UFzEVp4Af1oNDqo8dU/Gl5M9iuCyz3WZ4IKVR9UnNw1xNkmMQGjZWlzejCFBqhm6YK gn9RjT1Iedg4HQ2DJosiJ9VqqW73d/J8Cme61hZ4inWM3FzqAWk1vTvvYW4v8ytyc/JNbGrxH5pQv KU//S8NpmRXJwNDs75Tg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sxVzo-00000000QJH-1izX; Sun, 06 Oct 2024 18:28:44 +0000 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sxVwO-00000000PrU-1wKf; Sun, 06 Oct 2024 18:25:13 +0000 Received: by mail-pj1-x102a.google.com with SMTP id 98e67ed59e1d1-2e1bfa9ddb3so2786761a91.0; Sun, 06 Oct 2024 11:25:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728239112; x=1728843912; darn=lists.infradead.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=gQRL+4jvUJ2X96lE02r1r/21Z5HTm+wYNZIRn3wtob0=; b=PSaYq6zbZveBbtsBCBY0dYIKjKHICrJ/uRmF34HYF2CBlSJuli6SOX75J2zjHQoo9f u3h7bLWRXGY/pc3IXnCwrDkYEFBdNeT2ZkSTa0AFiYnZ4ziebwG7qmn634KVVnV8kGVf j2H9sx28jPLRtQr7bLuyOEBEexVbb68JTHSLmfkZdKr79VSmgRBlej3QFGrB1OrTMPCH IsWRcBETvWddEWw8iXVIEmIAAPuC0G7O8YAE+7YM/kNudmVY51BNfysFtFLsx6/ARkmx 7FpQ93XAxLNneotKf4KlnXmi5rS+VDHNEzG+phxEdmIOgORyM4dl0J1g56Fb8qHh/Mmm q1oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728239112; x=1728843912; 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=gQRL+4jvUJ2X96lE02r1r/21Z5HTm+wYNZIRn3wtob0=; b=V1ZQAR+FY4AT9v+YQXjumjphiR5Xm+M/hFBpmG1vAKBWJY9GskKFtpsElwGl1LiL8x IFFaHreEk1rLoc1T73RDFY73+eAH6LbiFUwHiYG5q9aTHzM7L8X2QwhCm6DgOm6DTl84 4pI/39iGjdceuPSXi5fGqR8AQIARwXznBnfgmn2FmqkC1uezvoA4CiMTlb2wyB64Ptd0 6yofLVCzndhPUWLoVjcNC9BxbFpLkRlyir6CqbpGeFHZZoq7XbmdCrqP9h8D7AOC3nt/ kytnDQ4KPVaN/rGDoc0NVDh+WsouCL1Nxg0BYuYI6B3JZF5Bz+LVRKamzrX6AM07Vqzf FbiA== X-Forwarded-Encrypted: i=1; AJvYcCUSHqW2AdMfgJnGK+FqkQH9snlDenDYdwYzJCGTWeMmpx1P1lnAgx44M0tnueZxMLO2A9xdMIELTBKLXQrwR4g=@lists.infradead.org, AJvYcCX62YtwJb3EusoITgd7veaBhzuxf/9nLdZu+2ln2gdBTIimEMMqwSXLsvJ8oLFtAP7aZFUBg8AcI/Wlk5+X/c7O@lists.infradead.org X-Gm-Message-State: AOJu0YwoEmNf+GeZlaPjYPZHJnoNYFZ8az3v7JhqLhI4MTANJmYQyNfx 8tg7ybXGFJO1INB7JrYASEJvSHYS23OdrtRU2HUYJvitAVmNJeDi X-Google-Smtp-Source: AGHT+IHw+i7zpIxo+CiZnR50Iq3xrLuxAzukfqMvhnnJWZoaBLZi8+XZrGU1JLjE84NQMYd46Fp3wA== X-Received: by 2002:a17:90a:4bc6:b0:2d3:ca3f:7f2a with SMTP id 98e67ed59e1d1-2e1e62674damr10044487a91.22.1728239111839; Sun, 06 Oct 2024 11:25:11 -0700 (PDT) Received: from localhost.localdomain ([113.30.217.221]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e1e85c905esm5458471a91.17.2024.10.06.11.25.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Oct 2024 11:25:11 -0700 (PDT) From: Anand Moon To: Shawn Lin , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Manivannan Sadhasivam , Rob Herring , Bjorn Helgaas , Heiko Stuebner , Philipp Zabel , linux-pci@vger.kernel.org (open list:PCIE DRIVER FOR ROCKCHIP), linux-rockchip@lists.infradead.org (open list:PCIE DRIVER FOR ROCKCHIP), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Rockchip SoC support), linux-kernel@vger.kernel.org (open list) Cc: Anand Moon Subject: [PATCH v6 RESET 2/3] PCI: rockchip: Simplify reset control handling by using reset_control_bulk*() function Date: Sun, 6 Oct 2024 23:54:37 +0530 Message-ID: <20241006182445.3713-3-linux.amoon@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241006182445.3713-1-linux.amoon@gmail.com> References: <20241006182445.3713-1-linux.amoon@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241006_112512_526109_8AB2431D X-CRM114-Status: GOOD ( 20.90 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org 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. Spilt the reset controller in two groups as pre the RK3399 TRM. After power up, the software driver should de-assert the reset of PCIe PHY, then wait the PLL locked by polling the status, if PLL has locked, then can de-assert the rest reset simultaneously driver need to De-assert the reset pins simultionaly. PIPE_RESET_N/MGMT_STICKY_RESET_N/MGMT_RESET_N/RESET_N. Signed-off-by: Anand Moon --- V6: Add reason for the split of the RESET pins. v5: Fix the De-assert reset core as per the TRM De-assert the PIPE_RESET_N/MGMT_STICKY_RESET_N/MGMT_RESET_N/RESET_N simultaneously. 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 | 151 +++++-------------------- drivers/pci/controller/pcie-rockchip.h | 26 +++-- 2 files changed, 49 insertions(+), 128 deletions(-) diff --git a/drivers/pci/controller/pcie-rockchip.c b/drivers/pci/controller/pcie-rockchip.c index 2777ef0cb599..87daa3288a01 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, @@ -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", @@ -147,23 +115,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]); @@ -173,47 +128,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); + err = reset_control_bulk_deassert(ROCKCHIP_NUM_PM_RSTS, + rockchip->pm_rsts); if (err) { - dev_err(dev, "deassert aclk_rst err %d\n", err); - goto err_exit_phy; - } - - err = reset_control_deassert(rockchip->pclk_rst); - 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; } @@ -256,31 +181,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 bebab80c9553..2761699f670b 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 @@ -288,18 +289,29 @@ (((c) << ((b) * 8 + 5)) & \ ROCKCHIP_PCIE_CORE_EP_FUNC_BAR_CFG_BAR_CTRL_MASK(b)) +#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_pm_rsts[] = { + "pm", + "pclk", + "aclk", +}; + +static const char * const rockchip_pci_core_rsts[] = { + "mgmt-sticky", + "mgmt", + "core", + "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; int num_clks; struct regulator *vpcie12v; /* 12V power supply */ From patchwork Sun Oct 6 18:24:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Moon X-Patchwork-Id: 13823842 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 17E63CFB424 for ; Sun, 6 Oct 2024 18:30:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ary7eHPz9n4mPdxgbrAA7k+uVyqZPVsy+QliznMRGwY=; b=HDSvOTRo+yxvee 3IbRH4eZPkXUXk2x4krRT+B/8r6oKql0E8KqMCSyRfR6meHLNxnvthuR0Wq2SDYM78GHeDKc0EqH7 Rsl6J/X83bPWKPVth1y67b0ypUGNVlIhhsOpR266dWAKG6FvM+XDlwRdT/9T8/VLjX8WU4Cbu8dKa tov849jJsHtetjjUJEoS/MskZOTjGhFzxHuxIBTy4Oxq8z5wc34n7xWxo9adHofQGvcnYyptCaOyL jLQ+C1PN9YGkCQArdHqB4p3PwPKp8lRft4lCL2w88ZwxVALj4roPthje5rCaAy/SjEpP5lm5StU09 ROK0ncrTWbPnyYRtz7nQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sxW13-00000000QPz-3hmx; Sun, 06 Oct 2024 18:30:01 +0000 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sxVwW-00000000PuC-3BQP; Sun, 06 Oct 2024 18:25:22 +0000 Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-2e199b1d157so2691528a91.2; Sun, 06 Oct 2024 11:25:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728239120; x=1728843920; darn=lists.infradead.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=0r5PI5Fsr/AroJKeUAO8bkOP6c9YME9rlzxUNbudK/0=; b=SQY3udGcG3imh1TlNrI3R4yz/C0lGHbv1ISpThmL7yBMWOOq1QPa1kgkTH2E/PhgU3 TV26tn/YTtCrB5YY53rosJGfRLI4HD7yIAVmh1m+gEq1oGJ0BbJveERAxvkOP7KCUU5w 2aBKYagAlFXVHm5TnDW3wmlmnf0NpFQsExT+fZzflycS8oIpoRRATF70cIs5HoXS8Pnl SqnZF0DKQV73A0lkBre4PsSYO//6sJL3koBN5i4Dp8mQl/swEt/KyG4SGL6yURqoxLVS 8XF4oL466mSxk3IWMqbRlEUreq5l3715fISAVHrOKORJn5fCxka0AmD2oUWaRSkxLApp Bgdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728239120; x=1728843920; 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=0r5PI5Fsr/AroJKeUAO8bkOP6c9YME9rlzxUNbudK/0=; b=CSdO9No+bHBjo77KEnqbJGKlRKFBHDGgYXtZLmF5ind0CZ3i/XzVIrHybIGMwJyA2r t9M+N0dCFqR4lq+U+9g9RJLqQ+bGVMQOPzrzCBHs8X+lxWZTbzZusrrK4y/k2+S/InsF BwWPL3agCIXATOeRijkQda+O8cGKXjDVkGCtPu9foQU5fF83Tlfi97nPBCYGeSXvjRxs pItmGz7wUIjeZEBEO/21RBfsAstxSmQEH8IYyGdxZrMPdG4YM2A223QS3/67b+Qyine/ pgNuofH7Z9k5LsQt1lB5ByTmVc7ujFktNAptoKw4yb/HsVOPW7+xzIMaxPZvc8vW4viC 6Iug== X-Forwarded-Encrypted: i=1; AJvYcCW9TqPG3LShRaNU2oLaGnJRd71twZH8zPBWtyBrA1yxuV9BjNorIMvUO7QvVuPaL+Rid4W0QXKYfb00fDHRJqM=@lists.infradead.org, AJvYcCXmOdcpzM/wFeyxFliUNW/sFWV5wZo4cW2qj3JrjGtxJrH0DPk2PQMt10L0tlQRZMiQpH2AtmJ+A/ikK2UtQr/K@lists.infradead.org X-Gm-Message-State: AOJu0YxuraOxGZC2JiHssUAMwNVYsKt/2Tnhcs8k+dmmmMBNSsh//Fxw 1piLFFrgDzy932dQEb07hy310HnaS12j8gyg0yvVXJMsH7CJ/qfF X-Google-Smtp-Source: AGHT+IFtOoTTIfseZL/AtxCGULgp8rsMErzM23/LafWsSPdU3aoQM3dDxgKn7TbBiyBWhpWUoSB38Q== X-Received: by 2002:a17:90b:4ac7:b0:2e1:cda1:12c6 with SMTP id 98e67ed59e1d1-2e1e63c58c8mr9370758a91.40.1728239119736; Sun, 06 Oct 2024 11:25:19 -0700 (PDT) Received: from localhost.localdomain ([113.30.217.221]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e1e85c905esm5458471a91.17.2024.10.06.11.25.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Oct 2024 11:25:19 -0700 (PDT) From: Anand Moon To: Shawn Lin , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Manivannan Sadhasivam , Rob Herring , Bjorn Helgaas , Heiko Stuebner , Philipp Zabel , linux-pci@vger.kernel.org (open list:PCIE DRIVER FOR ROCKCHIP), linux-rockchip@lists.infradead.org (open list:PCIE DRIVER FOR ROCKCHIP), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Rockchip SoC support), linux-kernel@vger.kernel.org (open list) Cc: Anand Moon Subject: [PATCH v6 RESET 3/3] PCI: rockchip: Refactor rockchip_pcie_disable_clocks() function signature Date: Sun, 6 Oct 2024 23:54:38 +0530 Message-ID: <20241006182445.3713-4-linux.amoon@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241006182445.3713-1-linux.amoon@gmail.com> References: <20241006182445.3713-1-linux.amoon@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241006_112520_819027_8FF36EE4 X-CRM114-Status: GOOD ( 14.12 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Refactor the rockchip_pcie_disable_clocks function to accept a struct rockchip_pcie pointer instead of a void pointer. This change improves type safety and code readability by explicitly specifying the expected data type. Reviewed-by: Manivannan Sadhasivam Signed-off-by: Anand Moon --- v6: Fix the subject, add the missing () in the function name. v5: Fix the commit message and add r-b Manivannan. v4: None v3: None v2: None --- drivers/pci/controller/pcie-rockchip.c | 3 +-- drivers/pci/controller/pcie-rockchip.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/pci/controller/pcie-rockchip.c b/drivers/pci/controller/pcie-rockchip.c index 87daa3288a01..b528d561b2de 100644 --- a/drivers/pci/controller/pcie-rockchip.c +++ b/drivers/pci/controller/pcie-rockchip.c @@ -269,9 +269,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); } diff --git a/drivers/pci/controller/pcie-rockchip.h b/drivers/pci/controller/pcie-rockchip.h index 2761699f670b..7f0f938e9195 100644 --- a/drivers/pci/controller/pcie-rockchip.h +++ b/drivers/pci/controller/pcie-rockchip.h @@ -347,7 +347,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);