linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] PCI: armada8k: Fix clock resource for Armada 7K/8K
@ 2018-02-28 16:35 Gregory CLEMENT
  2018-02-28 16:35 ` [PATCH v2 1/2] PCI: armada8k: Remove useless test before clk_disable_unprepare Gregory CLEMENT
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Gregory CLEMENT @ 2018-02-28 16:35 UTC (permalink / raw)
  To: Bjorn Helgaas, Lorenzo Pieralisi, Thomas Petazzoni, linux-pci
  Cc: Jason Cooper, Andrew Lunn, Sebastian Hesselbarth,
	Gregory CLEMENT, linux-arm-kernel, Antoine Tenart,
	Miquèl Raynal, Nadav Haklai, Shadi Ammouri, Omri Itach,
	Hanna Hawa, Igal Liberman, Marcin Wojtas

Hi,

This short series fixes the way the clocks are used for the PCIe host
controller embedded in the Marvell Armada 7K/8K SoCs. On these SoCs a
second one is needed in order to clock the registers. It was not
noticed until now because we relied on the bootloader and also because
the clock driver was wrong.

Thanks to this fix, it would be possible to fix the clock driver
without introducing a regression.

The first patch is just a small cleanup found when I wrote the main
patch.

Changelog:
v1 -> v2:

 - Removed a unneeded new line in the binding documentation, pointed
   by Thomas Petazzoni.

 - Added a new line in driver code, pointed by Thomas Petazzoni.

 - Managed the failure of clk_prepare_enable for the clk_reg in a
   separate case, pointed by Thomas Petazzoni.

 - Simplified the -EPROBE_DEFER case for the clk_reg, suggested by
   Russell King

 - Added backed the line getting the reg clock that disappeared in the
   first version.

Gregory CLEMENT (2):
  PCI: armada8k: Remove useless test before clk_disable_unprepare
  PCI: armada8k: Fix clock resource by adding a register clock

 .../devicetree/bindings/pci/pci-armada8k.txt        |  5 ++++-
 drivers/pci/dwc/pcie-armada8k.c                     | 21 +++++++++++++++++----
 2 files changed, 21 insertions(+), 5 deletions(-)

-- 
2.16.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] PCI: armada8k: Remove useless test before clk_disable_unprepare
  2018-02-28 16:35 [PATCH v2 0/2] PCI: armada8k: Fix clock resource for Armada 7K/8K Gregory CLEMENT
@ 2018-02-28 16:35 ` Gregory CLEMENT
  2018-02-28 16:35 ` [PATCH v2 2/2] PCI: armada8k: Fix clock resource by adding a register clock Gregory CLEMENT
  2018-03-08 15:34 ` [PATCH v2 0/2] PCI: armada8k: Fix clock resource for Armada 7K/8K Lorenzo Pieralisi
  2 siblings, 0 replies; 4+ messages in thread
From: Gregory CLEMENT @ 2018-02-28 16:35 UTC (permalink / raw)
  To: Bjorn Helgaas, Lorenzo Pieralisi, Thomas Petazzoni, linux-pci
  Cc: Jason Cooper, Andrew Lunn, Sebastian Hesselbarth,
	Gregory CLEMENT, linux-arm-kernel, Antoine Tenart,
	Miquèl Raynal, Nadav Haklai, Shadi Ammouri, Omri Itach,
	Hanna Hawa, Igal Liberman, Marcin Wojtas

clk_disable_unprepare() already checks that the clock pointer is valid.
No need to test it before calling it.

Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
---
 drivers/pci/dwc/pcie-armada8k.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/pci/dwc/pcie-armada8k.c b/drivers/pci/dwc/pcie-armada8k.c
index b587352f8b9f..f9b1aec25c5c 100644
--- a/drivers/pci/dwc/pcie-armada8k.c
+++ b/drivers/pci/dwc/pcie-armada8k.c
@@ -247,8 +247,7 @@ static int armada8k_pcie_probe(struct platform_device *pdev)
 	return 0;
 
 fail:
-	if (!IS_ERR(pcie->clk))
-		clk_disable_unprepare(pcie->clk);
+	clk_disable_unprepare(pcie->clk);
 
 	return ret;
 }
-- 
2.16.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] PCI: armada8k: Fix clock resource by adding a register clock
  2018-02-28 16:35 [PATCH v2 0/2] PCI: armada8k: Fix clock resource for Armada 7K/8K Gregory CLEMENT
  2018-02-28 16:35 ` [PATCH v2 1/2] PCI: armada8k: Remove useless test before clk_disable_unprepare Gregory CLEMENT
@ 2018-02-28 16:35 ` Gregory CLEMENT
  2018-03-08 15:34 ` [PATCH v2 0/2] PCI: armada8k: Fix clock resource for Armada 7K/8K Lorenzo Pieralisi
  2 siblings, 0 replies; 4+ messages in thread
From: Gregory CLEMENT @ 2018-02-28 16:35 UTC (permalink / raw)
  To: Bjorn Helgaas, Lorenzo Pieralisi, Thomas Petazzoni, linux-pci
  Cc: Jason Cooper, Andrew Lunn, Sebastian Hesselbarth,
	Gregory CLEMENT, linux-arm-kernel, Antoine Tenart,
	Miquèl Raynal, Nadav Haklai, Shadi Ammouri, Omri Itach,
	Hanna Hawa, Igal Liberman, Marcin Wojtas

On Armada 7K/8K we need to explicitly enable the register clock. This
clock is optional because not all the SoCs using this IP need it but at
least for Armada 7K/8K it is actually mandatory.

The binding documentation is updated accordingly.

Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
---
 Documentation/devicetree/bindings/pci/pci-armada8k.txt |  5 ++++-
 drivers/pci/dwc/pcie-armada8k.c                        | 18 ++++++++++++++++--
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/pci/pci-armada8k.txt b/Documentation/devicetree/bindings/pci/pci-armada8k.txt
index c1e4c3d10a74..9e3fc15e1af8 100644
--- a/Documentation/devicetree/bindings/pci/pci-armada8k.txt
+++ b/Documentation/devicetree/bindings/pci/pci-armada8k.txt
@@ -12,7 +12,10 @@ Required properties:
    - "ctrl" for the control register region
    - "config" for the config space region
 - interrupts: Interrupt specifier for the PCIe controler
-- clocks: reference to the PCIe controller clock
+- clocks: reference to the PCIe controller clocks
+- clock-names: mandatory if there is a second clock, in this case the
+   name must be "core" for the first clock and "reg" for the second
+   one
 
 Example:
 
diff --git a/drivers/pci/dwc/pcie-armada8k.c b/drivers/pci/dwc/pcie-armada8k.c
index f9b1aec25c5c..072fd7ecc29f 100644
--- a/drivers/pci/dwc/pcie-armada8k.c
+++ b/drivers/pci/dwc/pcie-armada8k.c
@@ -28,6 +28,7 @@
 struct armada8k_pcie {
 	struct dw_pcie *pci;
 	struct clk *clk;
+	struct clk *clk_reg;
 };
 
 #define PCIE_VENDOR_REGS_OFFSET		0x8000
@@ -229,23 +230,36 @@ static int armada8k_pcie_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
+	pcie->clk_reg = devm_clk_get(dev, "reg");
+	if (pcie->clk_reg == ERR_PTR(-EPROBE_DEFER)) {
+		ret = -EPROBE_DEFER;
+		goto fail;
+	}
+	if (!IS_ERR(pcie->clk_reg)) {
+		ret = clk_prepare_enable(pcie->clk_reg);
+		if (ret)
+			goto fail_clkreg;
+	}
+
 	/* Get the dw-pcie unit configuration/control registers base. */
 	base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ctrl");
 	pci->dbi_base = devm_pci_remap_cfg_resource(dev, base);
 	if (IS_ERR(pci->dbi_base)) {
 		dev_err(dev, "couldn't remap regs base %p\n", base);
 		ret = PTR_ERR(pci->dbi_base);
-		goto fail;
+		goto fail_clkreg;
 	}
 
 	platform_set_drvdata(pdev, pcie);
 
 	ret = armada8k_add_pcie_port(pcie, pdev);
 	if (ret)
-		goto fail;
+		goto fail_clkreg;
 
 	return 0;
 
+fail_clkreg:
+	clk_disable_unprepare(pcie->clk_reg);
 fail:
 	clk_disable_unprepare(pcie->clk);
 
-- 
2.16.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 0/2] PCI: armada8k: Fix clock resource for Armada 7K/8K
  2018-02-28 16:35 [PATCH v2 0/2] PCI: armada8k: Fix clock resource for Armada 7K/8K Gregory CLEMENT
  2018-02-28 16:35 ` [PATCH v2 1/2] PCI: armada8k: Remove useless test before clk_disable_unprepare Gregory CLEMENT
  2018-02-28 16:35 ` [PATCH v2 2/2] PCI: armada8k: Fix clock resource by adding a register clock Gregory CLEMENT
@ 2018-03-08 15:34 ` Lorenzo Pieralisi
  2 siblings, 0 replies; 4+ messages in thread
From: Lorenzo Pieralisi @ 2018-03-08 15:34 UTC (permalink / raw)
  To: Gregory CLEMENT
  Cc: Andrew Lunn, Jason Cooper, Antoine Tenart, linux-pci, Hanna Hawa,
	Omri Itach, Nadav Haklai, Shadi Ammouri, Igal Liberman,
	Thomas Petazzoni, Miqu??l Raynal, Bjorn Helgaas, Marcin Wojtas,
	linux-arm-kernel, Sebastian Hesselbarth

On Wed, Feb 28, 2018 at 05:35:28PM +0100, Gregory CLEMENT wrote:
> Hi,
> 
> This short series fixes the way the clocks are used for the PCIe host
> controller embedded in the Marvell Armada 7K/8K SoCs. On these SoCs a
> second one is needed in order to clock the registers. It was not
> noticed until now because we relied on the bootloader and also because
> the clock driver was wrong.
> 
> Thanks to this fix, it would be possible to fix the clock driver
> without introducing a regression.
> 
> The first patch is just a small cleanup found when I wrote the main
> patch.
> 
> Changelog:
> v1 -> v2:
> 
>  - Removed a unneeded new line in the binding documentation, pointed
>    by Thomas Petazzoni.
> 
>  - Added a new line in driver code, pointed by Thomas Petazzoni.
> 
>  - Managed the failure of clk_prepare_enable for the clk_reg in a
>    separate case, pointed by Thomas Petazzoni.
> 
>  - Simplified the -EPROBE_DEFER case for the clk_reg, suggested by
>    Russell King
> 
>  - Added backed the line getting the reg clock that disappeared in the
>    first version.
> 
> Gregory CLEMENT (2):
>   PCI: armada8k: Remove useless test before clk_disable_unprepare
>   PCI: armada8k: Fix clock resource by adding a register clock
> 
>  .../devicetree/bindings/pci/pci-armada8k.txt        |  5 ++++-
>  drivers/pci/dwc/pcie-armada8k.c                     | 21 +++++++++++++++++----
>  2 files changed, 21 insertions(+), 5 deletions(-)

Applied to pci/armada8k for v4.17, thank you.

Lorenzo

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-08 15:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-28 16:35 [PATCH v2 0/2] PCI: armada8k: Fix clock resource for Armada 7K/8K Gregory CLEMENT
2018-02-28 16:35 ` [PATCH v2 1/2] PCI: armada8k: Remove useless test before clk_disable_unprepare Gregory CLEMENT
2018-02-28 16:35 ` [PATCH v2 2/2] PCI: armada8k: Fix clock resource by adding a register clock Gregory CLEMENT
2018-03-08 15:34 ` [PATCH v2 0/2] PCI: armada8k: Fix clock resource for Armada 7K/8K Lorenzo Pieralisi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).