From patchwork Sat Oct 12 05:06:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Moon X-Patchwork-Id: 13833297 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 08F1DD1A431 for ; Sat, 12 Oct 2024 05:08:01 +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=HUQDmmXnPyJNVklAJmc+pPn1K3SWUi65w2flFzy6EW4=; b=pwPrOZ+ze+C+ww ezuzNlQri/JtI6jgi5H4j1brGXgGTsunhWuPDhqfNxV26EIkqjYKWgUI5nL14Q9ZzGusvuKg2PTUl 8lQPf/4S+VVHZPiKPxR10sQGQpTC51N5Ub7gSPRNHOsNQTZ0eusDWIO9a+voZ17eYInEub5q6n7mg btD+PQOsgBM7dbdrCo3w/kso+FKgHDi1Fj4SwJqV7ayjQmuX9plLBgBP1nvlFU9gevMI/iZsPqjrp 3PIPYxteynB7C+7coQr3ZYNyrGhlo+f6kyXRd0O2I9vH9tv63v635nNaRzSR8UV3w/oZLuwrTGwL2 CCGomZaPPd8tk40+oHhA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1szUM7-00000000YON-1TNj; Sat, 12 Oct 2024 05:07:55 +0000 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1szUKm-00000000Y9P-3ju9; Sat, 12 Oct 2024 05:06:34 +0000 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-71e0c3e85c5so2230675b3a.2; Fri, 11 Oct 2024 22:06:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728709592; x=1729314392; 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=hVdwZ9INnz1rSSRJAqZ6l2BLOiXSoUY6Jd3SSqJ9fJ0=; b=HTZ1cSO4TUhEYVbfPTNiy5SoXd8apzukIgZFZq75ldgahnBlKJ0jUwgegtXf2GeiO0 pN08lGEc4AZfYkpUVVPC+EHF24KROam0NGAaanBg24rcfwcT0lUC2zqBrkVkqpE8ULib XfZYfsykFE9ETmx4SdPRsCoEmts311/ZfOhVj7hhoZRaT/aM34vwu9FPXEVwBXFGhyHw wAo6b3qtab8nyc/No/14/LzSWRQwJ+y5vqkj/6+xxfXazOVe8CKU4w51I4ri+2x8O2PP g1tIpcMG/IB85gM30qOdLslpJURMAdFT4PwnUe/9zMZA6yi0cFHmkUgtLmJHTmSa5oSO gIqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728709592; x=1729314392; 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=hVdwZ9INnz1rSSRJAqZ6l2BLOiXSoUY6Jd3SSqJ9fJ0=; b=E/r5ZDB0zJECnytWN18kJfNA+PLnfmz4QpzOtwTy1Jz1ur5+4g2tx51e7sd/9TZjmt do0MMQaYAKpDdwHUJig2LsMSpLRSKlkSyCLRM+ORQm+/v3M+JJCS1Or0l+ZruOCinhaN LZ4lsjSZGF+8+zFM2jTtnYKQkDA9GTbcQ7aPUHmRhb6bI2+AemyTmy/2E6fimtU2Yv7/ wGpNNyOd5/mfJf78qrBuvAyBKs0WfKbuxZ3SNjy7FyvZwTyMo90cc3i9sz4j5rELCM6X zmnRa8fOlyYgf7ySpRGpWZnWpcrDF2kTAyB2qkw+WleIWUwqUm+NVR5kx7KmM0fIU2g6 h3/Q== X-Forwarded-Encrypted: i=1; AJvYcCXCF+v8jD4TGPMCRs1T9xa+dAX5+tUxsXrNA7fBA0JN+Ruuoy5OWC/AAzgB0uyq2x/qbH9y5KHwVE6kiRf1Cnzr@lists.infradead.org, AJvYcCXcK+9dtZfHBN+iw/oPWk7+L6xtZeNWkdIo+hpYCLLZqRHbdHpxpTbXsLMkM6csqJ6LJgcQCtivS9BWHiBnlQg=@lists.infradead.org X-Gm-Message-State: AOJu0YyxutmFw7pWqsScu6pGFp8+i0Vqf36yhwv3bDyS6FDO0s37S2Vz VV3Zw4XZcATDxYOl0cKljbNzbrR08t8D6wt/LKF97qGknial/ldv X-Google-Smtp-Source: AGHT+IG6hfffFkqnW00YmxEtnyyslCZ1TgJ6ch7+yc84KUAa5gHmGPezTpWnj8SUYjLC034jL5kBbg== X-Received: by 2002:a05:6a00:3d4b:b0:71d:fbf3:f771 with SMTP id d2e1a72fcca58-71e380bb0dbmr7375679b3a.24.1728709591850; Fri, 11 Oct 2024 22:06:31 -0700 (PDT) Received: from localhost.localdomain ([113.30.217.221]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71e4ad1b9f7sm859809b3a.190.2024.10.11.22.06.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 22:06:31 -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 v7 1/3] PCI: rockchip: Simplify clock handling by using clk_bulk*() function Date: Sat, 12 Oct 2024 10:36:03 +0530 Message-ID: <20241012050611.1908-2-linux.amoon@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241012050611.1908-1-linux.amoon@gmail.com> References: <20241012050611.1908-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-20241011_220632_956732_EE60FA89 X-CRM114-Status: GOOD ( 17.24 ) 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. - Replace devm_clk_get() with devm_clk_bulk_get_all(). - Replace clk_prepare_enable() with clk_bulk_prepare_enable(). - Replace clk_disable_unprepare() with clk_bulk_disable_unprepare(). Signed-off-by: Anand Moon Reviewed-by: Manivannan Sadhasivam --- v7: Update the functional change in commmit message. 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 Sat Oct 12 05:06:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Moon X-Patchwork-Id: 13833298 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 051D3D1A431 for ; Sat, 12 Oct 2024 05:09:20 +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=ZMXqgnk5GsvpIsJtoY0BdvlvnJJi/SuQlwIWiUNWins=; b=apuecry5DgeOPH xWaRNwxMH+y1EHI3px8U3GXCn+girYZDCLJ7suBpOXeAqIL16X+WBMddQy1YlLxSD7g+GtG1+V6fl Wx75XWBCNz+EP6XsDKNiXjR+NeUWLy0lobBCzWzzfeOedQAqhlONIK1fbY+4krNSKGg8TCMvg4eG6 /2kE7Txis4J+JJVM7v4sI5TgKyzexNctu/A+6KAuJ56n8sIgt3oZykp1lWu0Au77mWFND3LIWVJ4s DGwS0VmOGHuI7juqplPfmPfEYIvvtqU1S7QnqOlIm5NXNxIAR4igTny2gDSDcjRRJHZkFwWnwQLs0 RsycPo4x6nUqKgfmSMOg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1szUNR-00000000YX4-1Apb; Sat, 12 Oct 2024 05:09:17 +0000 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1szUKs-00000000YA7-2Hub; Sat, 12 Oct 2024 05:06:39 +0000 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-71e49ad46b1so523627b3a.1; Fri, 11 Oct 2024 22:06:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728709597; x=1729314397; 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=0wpn7B9Wtu3Iag2UMSF/s43VYHpuMNQiv15wMhgNrH0=; b=RuQCZdm1ghsYA3BHeslrz1EC+A/7xx6IjNtM2WIwHLYPA+xu2OD2QCaWdA/S60vt0s 4a1X3aM8Jo3RQ4cd3CQYyUI3QaktmDcaMJSg0fwQBxGlJf3lEv/xbWgnYr7oFDA0cHMe ewY3olBmiz+s2mz4fj4kwAAmloaET9GO6Xtn4pmK4BdruyYWScqAhbz4FE41VDMioRHQ 8BEYQJJMz+c/FldM6lo3a0LmhSBt+mpqJq4ivkEXW0NkleWlQ2dwy+0m4fCQ2VqZYCxj 6c7nJJZm9WEl0JrsP8mAN3NGLbSLl8pHu+bAyLxsi76FKHD4RN+fwv6WO0knRTZBNC7h 2SPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728709597; x=1729314397; 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=0wpn7B9Wtu3Iag2UMSF/s43VYHpuMNQiv15wMhgNrH0=; b=S+LJK5hiFONwWBvDQ73ZFSH4tKheZJ1C+7+0Z+ZLqrxhVqcEqTwaBLCvK85esgQasT aHK56aDBohTKnFxaNl3Q+aoeDWswyQb/Um4dDVQRxoBYFJLC/WL0ds7aEQIqdW8CHL5T 9xT/gg5XgAD4Bp1opnehXyIty2TYAwVy24bQuzalU4wGf8Y5nrB4ZA3uorvxuUSScfjA TYUNQBFGwLBJKjjE4asRMnGCpcEZrKy/9eG3WqgzdEwnMYKp2glxnV4Q7XBF9OKaJoYL 1kCwMUJCuT85nWwWOz6w9EhF9UVnfW93rXPwe+53fy17cN/EB62XtwnOZSxQRdItDAP4 v/gA== X-Forwarded-Encrypted: i=1; AJvYcCVcizz8Omb37G9tFFtKQvbMqi7mp+8zqHJs6uQU7vSaZRfUYHOw8HJ8XaFM9PpPrZokxsHGlEPnpLpptREY56cr@lists.infradead.org, AJvYcCXt0F2dsuFe0/tD5IQhZGjK5cLhfyBnTyygY8qnKQW6dKLnpoNDdzqeA4pM+cYgle8c0TwdPpkIksMKtTi7fCk=@lists.infradead.org X-Gm-Message-State: AOJu0YyVA/rkzWASv109RaAJiKXq16jNhhD5h7zhgz7OGskeyix3LJxs qzMpRVNONs7MNhyt/SOZVwnnTjDYQlpgrlU+/DOV4rsB5NZ70vKv X-Google-Smtp-Source: AGHT+IHdgxQSWB1iZ5ATGcBFggAhGVl31eDwJP8ZSAoh7j+MvFbLYIWYD4qCh22mXfzqB+Gvgd12JQ== X-Received: by 2002:a05:6a00:14c2:b0:71e:989:e714 with SMTP id d2e1a72fcca58-71e37ec58c6mr8669206b3a.11.1728709597460; Fri, 11 Oct 2024 22:06:37 -0700 (PDT) Received: from localhost.localdomain ([113.30.217.221]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71e4ad1b9f7sm859809b3a.190.2024.10.11.22.06.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 22:06:37 -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 v7 2/3] PCI: rockchip: Simplify reset control handling by using reset_control_bulk*() function Date: Sat, 12 Oct 2024 10:36:04 +0530 Message-ID: <20241012050611.1908-3-linux.amoon@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241012050611.1908-1-linux.amoon@gmail.com> References: <20241012050611.1908-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-20241011_220638_614388_66002D54 X-CRM114-Status: GOOD ( 21.17 ) 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 reset simultaneously driver need to De-assert the reset pins simultionaly. PIPE_RESET_N/MGMT_STICKY_RESET_N/MGMT_RESET_N/RESET_N. - replace devm_reset_control_get_exclusive() with devm_reset_control_bulk_get_exclusive(). - replace reset_control_assert with reset_control_bulk_assert(). - replace reset_control_deassert with reset_control_bulk_deassert(). Signed-off-by: Anand Moon --- v7: replace devm_reset_control_bulk_get_optional_exclusive() with devm_reset_control_bulk_get_exclusive() update the functional changes. 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..9a118e2b8cbd 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_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_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 Sat Oct 12 05:06:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Moon X-Patchwork-Id: 13833299 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 D28F5D1A431 for ; Sat, 12 Oct 2024 05:10:42 +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=ei78EL3+TkQN8csxI66UuIsFf3eL4kidVf1ObQfrXeE=; b=cjctAhv5U8s120 VNQ358VUbXoVW6Vrt1fZqZ9qXNU6vIPnOlpPXTMzieQrmYgSW24h9emj+abBHA+C0AjrnQFb0QEqm QONPtjKPA7IW6q/kL+9od0NGjrcN0G2jwWyOq/vzEGVZBcetUrbjPBMC0HMaSVHhakqkX6Dbh79sU QnQRn+Ndl2lQdLgoz5dhJLq7Z2fEQlHLG4rSzJRQIob/SBpCHZypbhFQ/UW6nbaEymucyetZKb1tV ocy7t67YFi2EpAKNY8q/hIuD7IRlKcCZ/xhOMbEgIRjJASB6cXy0lHyka+wnDtMZFInty+z4W58hr u2AGfo404UhbCmeh60+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1szUOl-00000000YeL-2vRe; Sat, 12 Oct 2024 05:10:39 +0000 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1szUL0-00000000YDn-0vCY; Sat, 12 Oct 2024 05:06:47 +0000 Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-7e9e38dd5f1so2183679a12.0; Fri, 11 Oct 2024 22:06:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728709605; x=1729314405; 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=myoEO0ww2czFo+NDaKnAm+OqHSFtr4LH3EKBGNBM3z4=; b=dgCs9+QlFy3F8zSQjx5ucookFHHrXY+JaAAfM1b6Fk0Aa48WIVcGkCH7/I0u9g5qxg iqwroeH/u3GhUYeBG7GddTVt4NSxUAjas2yOrtLTcU1R6kwFZ6ywV1yDrDQgbBD9QYfe +wUCycnSSK7YU6TinklMN0uSNe9c9qerRbGQ0ejxQXL0r7o8vuZGuV5f9HlNH+8bRb42 2uDkY5nTz7l/eE7bLtHZCyAdcdI68PQm1hxZWb5ic9PtG1Y9YmblBDUNSxGLwlJwttF7 +PaRaxYgBB8bczxoaHp12UbvHgY7N+2sgPyuO9No8l0BNc2SNhHFc4rTwbqSjS9Adlkb enVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728709605; x=1729314405; 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=myoEO0ww2czFo+NDaKnAm+OqHSFtr4LH3EKBGNBM3z4=; b=hZ7aTXcLeqk8SSlsORsSGtITbatn/W4xplnkEzIxPdvKgFNVaS3tO5OX+SHo2+t/1F dE2nFISNchRtQai8BoA0MDJMxeGghW80hURv2o3YvmY1IHQYoHWWvrRCqfN+SQX8+au5 0vFMjfAcpkzbQ/9adnSRdINTZUSeM/OPT4xeWFcdENLI/lcwAjEN2gCK4oDcoc85uhCJ AtybJMWpFNwKi3wYc9RBpztJNwhuo6Ryr9+rEw9LaawsGo/u9xXB8oGjIc5r4o6x9mzZ 0/a1y4IP08xpHSMmJVGbaHJk36apYUytfndZZjH5qwOcaRQWWujKghBcKoM+N1fnzGC6 nezw== X-Forwarded-Encrypted: i=1; AJvYcCV9yVXwyfANPGHAuMPbH87jxWLZCqf9BZ9MCMSI1C4rFGemo0i3rhRsHtoC2kWRBqezeVyoA1aYeFwBVK4KVR6T@lists.infradead.org, AJvYcCVsBx6ocqaAj+ApIRTTrPmdsYp5Dey4I52z4RmUqSdlNeIrlHR9ZDwwSFflh0URcm4sIG49yVRujVw/wpHT9RA=@lists.infradead.org X-Gm-Message-State: AOJu0Yw2FQq7CZnMPY8Z0MH6ge+POjrbXpmwIOF5KyqB9ezsT5hzTVwq lXO7+ViAV+D6HfVelIjNBMJJqN+SnxiQ9Y2N4T/wZem4EVV6CWds X-Google-Smtp-Source: AGHT+IHbWnSJOFSlNgJF4OYXyX8KdfVCrRAO9/1mq47VYfOabgDCcVZ58F7Tw4bhokGiBoTcmX26tg== X-Received: by 2002:a05:6a20:c997:b0:1d7:1277:8d22 with SMTP id adf61e73a8af0-1d8bcfb296dmr8295467637.43.1728709605470; Fri, 11 Oct 2024 22:06:45 -0700 (PDT) Received: from localhost.localdomain ([113.30.217.221]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71e4ad1b9f7sm859809b3a.190.2024.10.11.22.06.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 22:06:45 -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 v7 3/3] PCI: rockchip: Refactor rockchip_pcie_disable_clocks() function signature Date: Sat, 12 Oct 2024 10:36:05 +0530 Message-ID: <20241012050611.1908-4-linux.amoon@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20241012050611.1908-1-linux.amoon@gmail.com> References: <20241012050611.1908-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-20241011_220646_276571_2AD44F41 X-CRM114-Status: GOOD ( 14.26 ) 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 --- v7: None 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: No --- 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 9a118e2b8cbd..c3147111f1a7 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);