From patchwork Mon Dec 2 15:11:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Moon X-Patchwork-Id: 13890921 X-Patchwork-Delegate: kw@linux.com Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 8BC221D545; Mon, 2 Dec 2024 15:12:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733152334; cv=none; b=bKHqqh30G52DfjZ6qNG2EYyj+pxkcJqLLfFH1HA9r18/oPQ9m+894QeSw6aINwLvNJfR93gN8XAR+QQdFddfPyO+CTPRBE3CVHTmCiz0zIB7jBz/EXTSQv5bdxk8qpyjcpc/fJ2GBSQVbHm60Mfl/0qB1gONM4Ja/pnNeN1E4HU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733152334; c=relaxed/simple; bh=SRYFXxrW4YznYwcW9FUcExbIpXBDmP/q9nh/Pa9GfEk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ernHUsuFYUqYQ44GNko5htDrMdGA3zEOe6XKeqiNpRhVY7yCfhsdz+5p5BKA+Nj2bX82VyKWo6H7Qtbqd8xvWPAnuZrnBJvk6jk31C0tH6z7VF2eG3YbOZA1SHR8Jz4nwBPqMV4E12pj5ete2jhHogNq7UtzGxayOgeavN2GOJM= 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=KlP7mxwd; arc=none smtp.client-ip=209.85.214.176 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="KlP7mxwd" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2154e3af730so21804905ad.3; Mon, 02 Dec 2024 07:12:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733152332; x=1733757132; 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=aSE1oYmswp4nZQvrKL5VAYP4YbLQSL+PfB27DrayTI4=; b=KlP7mxwdmV3f0+meIsbfb/Q8DPBJ2Pc8zJibTX/wPEsPbWA9HspqCJ0oRqYaOuzUhM l+/C/yOnYPy6u8jEdEpP0pMWEG8BOzkWJcaw94sw+h9dKe18k3NH/BvsRmkziKn4T9tA 8JjwYJy1zSVd6X/1iwJ2XaJWvXXDGtPmujhuSYZ7xACzCRqz37I5OOhGmmGRHEVL/66J aZIWHmbZqJqI/hRjSwG3o2ZvWUO+Mp0cwzEFw5ecYTuJHLdoqvKzUqQLzBs61T53uSaO KbmGTcKWog6Q/EiylkCHnyGTEohvt5+GYsjk/1PuZZksCLUB0RFr7Ajp+uWH111d4P86 s8aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733152332; x=1733757132; 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=aSE1oYmswp4nZQvrKL5VAYP4YbLQSL+PfB27DrayTI4=; b=GdPZJl2C74x/6c68zvry6hN3972rbzbEWAx8fP0kSQRq8lRjtcchGveH4sgp8VNBKb LH8/Q3gzttLTf3hSsWqqgcItbgsmjpA6kVbc2zUwTJe8PvfeGlT3jLbTr4mLKYE43XhA 7kAjHzU2Ow9VWZ5fH6rQezFbw+RXGNb3XS5QB8Trm99v9sRx/J7nBhENAy/sByXOTi8g WbrNMno4lV6NrHLuZpJb0dyq+taaC7CxO6Ch8cDdS6WgpHtU/aFL2fhwbVtWaBMleSl7 bbswo/IZ8bMzKilBJagjaXGYkcT5ksp0VThoHDoZbZQ0rc9/bnFqzshaH6rND4wx+Uqj IS0Q== X-Forwarded-Encrypted: i=1; AJvYcCURG7Wp1Ho91vjR0GEiKqLMPluOPA0DDBfRZKYLxNpgoFkQjXnrFlYoL5GReniwbuLrGRsTiXvUHmZlGPo=@vger.kernel.org, AJvYcCWDycN35bgHVNo0OlucXBF8j/yKniYmumOtEUoACcq01OK/Lg8tUsVEOr9r3DWzuOnYBCPeU3DyTSK/@vger.kernel.org X-Gm-Message-State: AOJu0YxWjHCaHnoUoAppg0Z301IIaL6BHep8SehMYoQrSbU5Vxovinnk QvtPXwd2q2xcvHEFM4pPS7ukLd+PzVK5Atx+0ELk5Oe3LrH0fHQE X-Gm-Gg: ASbGncvAJJjV/sMjFd+r2kipoF5wkEyzOe/+iYzn21aYcYB9j8jJevIxa+n0xLLt4Fg 0vIJJ/6puQopWhh4+rNkGvQKYss6sdJDJiMp2iIuD7oTh3xiZTsH+l5C1sC6/+FngQCEqkdOzT5 6Fu7pH3lXecA7MelPtm5QNxI2uD2qkHX0l99/llsD1AeCb1Ecg1rj6N3SmW901QknZIqFo52V9s dq1yZ6nqTQTEjZU8PzvjBiaRuufJUKxSetPtj7KF2IzSuOH7ZkpB6qYqgdp5UECVQ== X-Google-Smtp-Source: AGHT+IGJGsBN5Bz9z/jmVRFG5EPn8EbineRclxV2mlzSvVxPBgKVWQ30c1kjlQPr/eERQsBmU2EONA== X-Received: by 2002:a17:903:440f:b0:215:a7e4:8475 with SMTP id d9443c01a7336-215a7e48795mr33777685ad.24.1733152331602; Mon, 02 Dec 2024 07:12:11 -0800 (PST) Received: from localhost.localdomain ([113.30.217.223]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215218f1da4sm78524955ad.12.2024.12.02.07.12.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 07:12:10 -0800 (PST) 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 Cc: Anand Moon , Philipp Zabel , linux-pci@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v11 1/3] PCI: rockchip: Simplify clock handling by using clk_bulk*() function Date: Mon, 2 Dec 2024 20:41:42 +0530 Message-ID: <20241202151150.7393-2-linux.amoon@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241202151150.7393-1-linux.amoon@gmail.com> References: <20241202151150.7393-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 Currently, the driver acquires clks and prepare enable/disable unprepare the clks individually thereby making the driver complex to read. But this can be simplified by using the clk_bulk*() APIs. Use devm_clk_bulk_get_all() API to acquire all the clks and use clk_bulk_prepare_enable() to prepare enable clks and clk_bulk_disable_unprepare() APIs disable unprepare them in bulk. Reviewed-by: Manivannan Sadhasivam Signed-off-by: Anand Moon --- V11: None V10: None v9: Re write the commmit message. v8: Improve the description of the code changes in commit messagee. Add Rb: Manivannan 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 b9ade7632e11..53aaba03aca6 100644 --- a/drivers/pci/controller/pcie-rockchip.c +++ b/drivers/pci/controller/pcie-rockchip.c @@ -129,29 +129,9 @@ int rockchip_pcie_parse_dt(struct rockchip_pcie *rockchip) return dev_err_probe(dev, PTR_ERR(rockchip->perst_gpio), "failed to get PERST# 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; } @@ -375,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); @@ -415,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 a51b087ce878..f79c0a1cbbd0 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 @@ -321,10 +322,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 Mon Dec 2 15:11:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Moon X-Patchwork-Id: 13890922 X-Patchwork-Delegate: kw@linux.com Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 1374C1D545; Mon, 2 Dec 2024 15:12:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733152340; cv=none; b=MLtFqjd6CBkCTcAF/88186fs5Ze47T0whjxJh6ygHgJHB1su5VSKTFETp6/kgpkvQBmY1q16gjfXwqcIFHnc8e3dGzVQMYY5Y+qRymAUatG4JWKrPpnNvCJSn46eS4MhtmgZa+zTpflNXfWd72QZ9bD6PCVcLKXxpL1IfkIL96I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733152340; c=relaxed/simple; bh=+qV5viiJQWwZcaEk8+kcyyQYNyU4DvJZVUH7veCds6o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UX5Cl76PSItRhoe1q7tN0cHt56RMlZBrzE0nN6BHGGjbSM6u2+1oTxUv9ZKA53aQAqwzPfsEbiePd8k96HmnSSZhp7JSdki4yzzSEdjI5/byUvqfa6xT/s0w+RIXqczDgqWkDZR0AsYK5/X4lGQ1ODvSKS2KLuF0yPymEz3wFfs= 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=fR1JsSuH; arc=none smtp.client-ip=209.85.214.174 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="fR1JsSuH" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-21145812538so35176375ad.0; Mon, 02 Dec 2024 07:12:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733152338; x=1733757138; 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=SvWsh4CHPQbPeCk10iBSDzAk8FSASDg2ROsws9NAfLg=; b=fR1JsSuHfpX47PeXDtK3bQ7jWEa2515B/OA3Vq6oxWwKEFieiTVbOv7mqkQpt06msk fhT4tvLBCcRbDBxcWxoP9f4IJAzgGy664NfOUuZaccmSQYbx5TaYgLqULWo0v/8X2Y1l ZcFxSSlkjC+y6xaq7KY6/zMdoWDKGx2vtKLZWLP2SLjtiRL/B2ePeHpC2nDJj2kFAtoM Mz8hdG/RP8uistbeLoALcZKdohBKaljGNKz2Vtqc7OxRxLoM371ItSMr3mq/AEjFwfb5 P42NEDt5LcI1NfBwgjzch7iZa3FRzg5zKWtEZBoUtnVYOGQ6dthilanwgeIzMj88G5Bz 6VSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733152338; x=1733757138; 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=SvWsh4CHPQbPeCk10iBSDzAk8FSASDg2ROsws9NAfLg=; b=CccRAIiSuTAAsux4wnJ6yQb1P82kkLXi9fXKLpN0ROIeTlcNw/jWknn1cIGWbZM3Zo LPUhr4RePPQsua6CBZAyCI3ODlzgBz+9W8BaO0a7LrcxcxroIh/vEOJyLlHDf2gUaAc7 2nnmhsM3n+38q/6YyHeFCVScxWkHFghalJpDHy9mPCZ+MFfHu38uW4Da49Fb4Gk/Z0tF hMGhHM86IVNb1z5vqp670FMbMP+GX/5+4J3pa60zKK82AQPgScxUyRSbVR4ZQdV6aLT2 8kzL1jQs/iSqIf4O4Xe40lZ8aOjC4ORYWqot77XCeFeCDHX7A8iGMN1FJjL1NLvNRea1 HfNw== X-Forwarded-Encrypted: i=1; AJvYcCWiPfQ1hDQvjHUaVkBmTNxm84pjOqrOOeeM12tsR+Dh7NGORJMOJflMoA46b2oe08LuAP8eLsHMASAd@vger.kernel.org, AJvYcCXl9TPs8EGFwnhsRvzY0TqXQVN5eJR1DtwAuJx//BsiUobs6j/eXnHVKhLES7DwjYdKXgaN0SKAZXO50Yw=@vger.kernel.org X-Gm-Message-State: AOJu0Yz7PD5nl5/jggSxiY3BA4F0u7AlIttMPcSP4fPaKZB0Muyiz/8g sPoc7KrCiMJjkhYQVrqlqpP3DNji5DbOKTf+L9aVDA1vrePJwVegywlMOaS3 X-Gm-Gg: ASbGncsT/xWQoq/rl+63CxdIa9WoMg/E+xcdY2vjoh8EBlomjG/NcZQMrKGw9rlHl0T E6ysDI+iD32g7QkoeiyTvp0ftquarIwju2mrJ5KlNFJkCcKnZ8kjc0XySV8+4VHRapJJuMvCSWR LBlivVt4EJtNz9o1n+UPWwVmRpaqyQLaF2olfhJ+feOursAPdymW9an3Miyzhp8TYDRTyfnsCN6 PNTkKUWthQ0OYBZACFUDa5y/xKrmPslu36Iv4BoaS1GiAo9L1FDZXqyXx9ts4OGLA== X-Google-Smtp-Source: AGHT+IGUskdQ6lyBzZGudv4RLzzi+Ppyu1aUugRi+lBecZa0uN8Qri5vpCuGP0RNCylYJKkcAeb9uA== X-Received: by 2002:a17:902:e844:b0:212:88cc:d57b with SMTP id d9443c01a7336-2150107d129mr299675765ad.11.1733152338228; Mon, 02 Dec 2024 07:12:18 -0800 (PST) Received: from localhost.localdomain ([113.30.217.223]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215218f1da4sm78524955ad.12.2024.12.02.07.12.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 07:12:17 -0800 (PST) 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 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 v11 2/3] PCI: rockchip: Simplify reset control handling by using reset_control_bulk*() function Date: Mon, 2 Dec 2024 20:41:43 +0530 Message-ID: <20241202151150.7393-3-linux.amoon@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241202151150.7393-1-linux.amoon@gmail.com> References: <20241202151150.7393-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 Currently, the driver acquires and asserts/deasserts the resets individually thereby making the driver complex to read. But this can be simplified by using the reset_control_bulk APIs. Use devm_reset_control_bulk_get_exclusive() API to acquire all the resets and use reset_control_bulk_{assert/deassert}() APIs to assert/deassert them in bulk. Following the recommendations in 'Rockchip RK3399 TRM v1.3 Part2': 1. Split the reset controls into two groups as per section '17.5.8.1.1 PCIe as Root Complex'. 2. Deassert the 'Pipe, MGMT Sticky, MGMT, Core' resets in groups as per section '17.5.8.1.1 PCIe as Root Complex'. This is accomplished using the reset_control_bulk APIs. Reviewed-by: Manivannan Sadhasivam Signed-off-by: Anand Moon --- V11: added R-B Manivannan, Fix small typo. v10: Fix some typo v9: Improved the commit message and try to fix few review comments. v8: I tried to address reviews and comments from Mani. Follow the sequence of De-assert as per the driver code. Drop the comment in the driver. Improve the commit message with the description of the TMP section. Improve the reason for the core functional changes in the commit description. Improve the error handling messages of the code. 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 | 154 +++++-------------------- drivers/pci/controller/pcie-rockchip.h | 26 +++-- 2 files changed, 48 insertions(+), 132 deletions(-) diff --git a/drivers/pci/controller/pcie-rockchip.c b/drivers/pci/controller/pcie-rockchip.c index 53aaba03aca6..693aadc99d6c 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 PM reset\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 Core resets\n"); if (rockchip->is_rc) rockchip->perst_gpio = devm_gpiod_get_optional(dev, "ep", @@ -149,23 +117,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, "Couldn't assert PM resets\n"); for (i = 0; i < MAX_LANE_NUM; i++) { err = phy_init(rockchip->phys[i]); @@ -175,47 +130,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, "Couldn't assert Core resets\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, "Couldn't deassert PM resets %d\n", err); goto err_exit_phy; } @@ -255,31 +180,10 @@ int rockchip_pcie_init_port(struct rockchip_pcie *rockchip) goto err_power_off_phy; } - /* - * 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); - 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); + err = reset_control_bulk_deassert(ROCKCHIP_NUM_CORE_RSTS, + rockchip->core_rsts); if (err) { - dev_err(dev, "deassert pipe_rst err %d\n", err); + dev_err(dev, "Couldn't deassert Core reset %d\n", err); goto err_power_off_phy; } diff --git a/drivers/pci/controller/pcie-rockchip.h b/drivers/pci/controller/pcie-rockchip.h index f79c0a1cbbd0..87041ed88b38 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 @@ -310,18 +311,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", + "core", + "mgmt", + "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 Mon Dec 2 15:11:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Moon X-Patchwork-Id: 13890923 X-Patchwork-Delegate: kw@linux.com Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (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 9A5ED20C001; Mon, 2 Dec 2024 15:12:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733152350; cv=none; b=VnS8j6ew6FwN5xHRYKbC+/8EWXj+Lh0CKxIdJkF6N3PK7o9hFNKKCchw1vuU+Iqxefu4w3bTle9YnIE2nSi9uALYIpJwCTGDmqXo/1uWMvfOEpp1umJLFJWh4fwYRg7CFEM3xV7hAMo9ZsnTogIEXDVNl+kPjYsZhgPsmxq2IA0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733152350; c=relaxed/simple; bh=5TRmdjaRKkU3cQw2wdH+BT1y6ZhhlwxgglF0P2Me4uk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AhCwx62pag42SV81NyUtg3tZulVV7RcX0r0hvuBcg8yGXsuc1TN9N8OvNKFbZFZ25ZCGcT7mvY69YCcvqAZq0omzhJA4JjkhbPfKjgagpIMaUej/L/kThGG7lNQbRdaKfnRm69C7YnAQ3wA87Eu7PagACtF4C3EyvKlZfhbFF7Y= 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=NDmVS80Z; arc=none smtp.client-ip=209.85.210.173 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="NDmVS80Z" Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-7251abe0e69so3720193b3a.0; Mon, 02 Dec 2024 07:12:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733152346; x=1733757146; 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=HvFldH2UE7l++lKguJ5UKXHzEK7JVjP2Z1XY9Om0QMI=; b=NDmVS80ZdL0tIW9omYTUwLkI3Kvq3dyDCxbOSI6lvKKpyxnuGcQVjbOEiypBfWm11E tG/GZdNrsDq31EiVYzASUOJK0uUWPOjMxpL2YgRzISLgYDdbZXhhyhKQxvPBQJ+v+xfY WUuzelYgfTE+IwTtuo6SmOImuDi5912QwtKze3f5Oqdo9Qvno8KCNwPXuNKrRktFHYx4 hQupBq7B4xuL1BZ8PwF5aohCXyZOmfRKWw5lmc/REFs+HJw6sbka9sn+1z8hz41GlTTX xCLmdyKB5arZNqwxA94a3sP/D8ywhPrifc+hO5cW7NuheuF5aczQD9jG22qStK0vZBzG cc2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733152346; x=1733757146; 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=HvFldH2UE7l++lKguJ5UKXHzEK7JVjP2Z1XY9Om0QMI=; b=XSJ5pfiY8W4uwR+dwmlRjijgIo7IGPTcNsoekCxteSn5ZnZfU2yJ346JZIl12jEa08 FMN8Jax046uoK2B/j+ixZ9avG7BmMlr9ADYilu8xIrvNp8RWGixWi8QToAw9kfRfIojO zgxN72cPCjC7QkTdNcqugV29dPzQZRb2QMh6LKfQXiXxQdNQIIO3bWJE1sOMyzFDVc1e kT1c7dzpbK7qh2oA6Pl9W/qy2aL+C3iRw4WJ5D0gT+WKcCh1ISnGnw+W4h4MfR3zdFo9 c1IXpsyFzWJpoNkeyGmC9H2yo6K6hBtLE3SB1ci/wdWj/ZdLu9oqJ+/hajfDpAEGznVY i7PQ== X-Forwarded-Encrypted: i=1; AJvYcCX3zYrAWIOpZc6mUdhBbjCymOAmJ1LcdFuS9cuGKcZTNrfO6O2MQFKcBxdlPHwcD/q/z+MRaRHYHEA4@vger.kernel.org, AJvYcCXmqlFdrBv1s447s/hgcNQo4UKjdnBSrNavTMF2EVkI74kphK5DnopeDY/aNoxXkDbgG4NRv3+1SqJzFwQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxlR3m54xSprj01fJ9B9VM0sWpEaaXV2dhj3quFdWiNm70gKKOT 9fTC5xRm6xWw6wWui6WGUQfYodkWJcIvNEaElbW1FwS3Mvz4V73H X-Gm-Gg: ASbGncvl/7R+GeN9fUp2JTKLbpEwgrMbvNiI+tpQB33eYLC6fXPZ5i1mMyqmYt7S5v3 7U/q9dwMoZwZOuh2jfPOjBye3R5Pk6RA/81RDf4MzwVEYQlSu1wVxPo4Gb/3khB1bxN15IQHsu5 J/43WzHrGyAO4on1ATuU5SqXkS4gnOeu+AtAsG3K1T+NWkvqHcBa9HtPzOXYJXd6nPrpw9PGGm+ F4Pml5Jwmj+TDE1g1oHqcDE/aa+fKEmnmr3mS+Twwah8AZGRd3fmcFFdbCNbt+pCA== X-Google-Smtp-Source: AGHT+IHTR2hBzTrmzTq4eocYsWa/4g+gtB/KL9P+ADubc0lgHB1LE2z0JA3Lf2Omsp9qmYl7/gxbIw== X-Received: by 2002:a17:903:1c9:b0:215:8af7:eff8 with SMTP id d9443c01a7336-2158af7f30bmr61814845ad.52.1733152344118; Mon, 02 Dec 2024 07:12:24 -0800 (PST) Received: from localhost.localdomain ([113.30.217.223]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215218f1da4sm78524955ad.12.2024.12.02.07.12.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 07:12:23 -0800 (PST) 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 Cc: Anand Moon , Philipp Zabel , linux-pci@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v11 3/3] PCI: rockchip: Refactor rockchip_pcie_disable_clocks() function signature Date: Mon, 2 Dec 2024 20:41:44 +0530 Message-ID: <20241202151150.7393-4-linux.amoon@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241202151150.7393-1-linux.amoon@gmail.com> References: <20241202151150.7393-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 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 --- v11: None v10: None v9: None v8: add add the missing () in the function name. 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 693aadc99d6c..fea867c24f75 100644 --- a/drivers/pci/controller/pcie-rockchip.c +++ b/drivers/pci/controller/pcie-rockchip.c @@ -267,9 +267,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 87041ed88b38..11def598534b 100644 --- a/drivers/pci/controller/pcie-rockchip.h +++ b/drivers/pci/controller/pcie-rockchip.h @@ -369,7 +369,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);