From mboxrd@z Thu Jan 1 00:00:00 1970 From: Subject: [PATCH v3 11/13] spi: atmel-quadspi: add support for named peripheral clock Date: Sat, 2 Feb 2019 04:07:41 +0000 Message-ID: <20190202040653.1217-12-tudor.ambarus@microchip.com> References: <20190202040653.1217-1-tudor.ambarus@microchip.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <20190202040653.1217-1-tudor.ambarus@microchip.com> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org To: broonie@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, Nicolas.Ferre@microchip.com, alexandre.belloni@bootlin.com, Ludovic.Desroches@microchip.com, bbrezillon@kernel.org, Cyrille.Pitchen@microchip.com, bugalski.piotr@gmail.com Cc: linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, Tudor.Ambarus@microchip.com List-Id: devicetree@vger.kernel.org From: Tudor Ambarus Naming clocks is a good practice. Keep supporting unnamed peripheral clock, to be backward compatible with old DTs. While here, rename clk to pclk, to indicate that it is a peripheral clock. Suggested-by: Boris Brezillon Signed-off-by: Tudor Ambarus --- v3: new patch drivers/spi/atmel-quadspi.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/drivers/spi/atmel-quadspi.c b/drivers/spi/atmel-quadspi.c index bfa5f5e92d96..c9548942535a 100644 --- a/drivers/spi/atmel-quadspi.c +++ b/drivers/spi/atmel-quadspi.c @@ -136,7 +136,7 @@ struct atmel_qspi { void __iomem *regs; void __iomem *mem; - struct clk *clk; + struct clk *pclk; struct platform_device *pdev; u32 pending; u32 smm; @@ -338,7 +338,7 @@ static int atmel_qspi_setup(struct spi_device *spi) if (!spi->max_speed_hz) return -EINVAL; =20 - src_rate =3D clk_get_rate(aq->clk); + src_rate =3D clk_get_rate(aq->pclk); if (!src_rate) return -EINVAL; =20 @@ -429,15 +429,18 @@ static int atmel_qspi_probe(struct platform_device *p= dev) } =20 /* Get the peripheral clock */ - aq->clk =3D devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(aq->clk)) { + aq->pclk =3D devm_clk_get(&pdev->dev, "pclk"); + if (IS_ERR(aq->pclk)) + aq->pclk =3D devm_clk_get(&pdev->dev, NULL); + + if (IS_ERR(aq->pclk)) { dev_err(&pdev->dev, "missing peripheral clock\n"); - err =3D PTR_ERR(aq->clk); + err =3D PTR_ERR(aq->pclk); goto exit; } =20 /* Enable the peripheral clock */ - err =3D clk_prepare_enable(aq->clk); + err =3D clk_prepare_enable(aq->pclk); if (err) { dev_err(&pdev->dev, "failed to enable the peripheral clock\n"); goto exit; @@ -448,25 +451,25 @@ static int atmel_qspi_probe(struct platform_device *p= dev) if (irq < 0) { dev_err(&pdev->dev, "missing IRQ\n"); err =3D irq; - goto disable_clk; + goto disable_pclk; } err =3D devm_request_irq(&pdev->dev, irq, atmel_qspi_interrupt, 0, dev_name(&pdev->dev), aq); if (err) - goto disable_clk; + goto disable_pclk; =20 err =3D atmel_qspi_init(aq); if (err) - goto disable_clk; + goto disable_pclk; =20 err =3D spi_register_controller(ctrl); if (err) - goto disable_clk; + goto disable_pclk; =20 return 0; =20 -disable_clk: - clk_disable_unprepare(aq->clk); +disable_pclk: + clk_disable_unprepare(aq->pclk); exit: spi_controller_put(ctrl); =20 @@ -480,7 +483,7 @@ static int atmel_qspi_remove(struct platform_device *pd= ev) =20 spi_unregister_controller(ctrl); writel_relaxed(QSPI_CR_QSPIDIS, aq->regs + QSPI_CR); - clk_disable_unprepare(aq->clk); + clk_disable_unprepare(aq->pclk); return 0; } =20 @@ -488,7 +491,7 @@ static int __maybe_unused atmel_qspi_suspend(struct dev= ice *dev) { struct atmel_qspi *aq =3D dev_get_drvdata(dev); =20 - clk_disable_unprepare(aq->clk); + clk_disable_unprepare(aq->pclk); =20 return 0; } @@ -497,7 +500,7 @@ static int __maybe_unused atmel_qspi_resume(struct devi= ce *dev) { struct atmel_qspi *aq =3D dev_get_drvdata(dev); =20 - clk_prepare_enable(aq->clk); + clk_prepare_enable(aq->pclk); =20 return atmel_qspi_init(aq); } --=20 2.9.5