All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gerhard Sittig <gsi@denx.de>
To: linuxppc-dev@lists.ozlabs.org,
	linux-arm-kernel@lists.infradead.org,
	Anatolij Gustschin <agust@denx.de>,
	Mike Turquette <mturquette@linaro.org>
Cc: Scott Wood <scottwood@freescale.com>, Detlev Zundel <dzu@denx.de>,
	Gerhard Sittig <gsi@denx.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jslaby@suse.cz>,
	linux-serial@vger.kernel.org
Subject: [PATCH v5 09/17] serial: mpc512x: adjust for OF based clock lookup
Date: Mon, 18 Nov 2013 00:06:09 +0100	[thread overview]
Message-ID: <1384729577-7336-10-git-send-email-gsi@denx.de> (raw)
In-Reply-To: <1384729577-7336-1-git-send-email-gsi@denx.de>

after device tree based clock lookup became available, the peripheral
driver need no longer construct clock names which include the PSC index,
remove the "psc%d_mclk" template and unconditionally use 'mclk'

acquire and release the "ipg" clock item for register access as well

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: linux-serial@vger.kernel.org
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> # for v4
Signed-off-by: Gerhard Sittig <gsi@denx.de>
---
Greg, the difference between v4 and v5 of this patch is that v4
took the 'mclk' and 'ipg' clock items in reverse order, and thus
potentially obfuscated the adjusted name for 'mclk' -- v5 of the
patch is identical in content but cleaner diff-wise

---
 drivers/tty/serial/mpc52xx_uart.c |   40 ++++++++++++++++++++++++++++++++-----
 1 file changed, 35 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/serial/mpc52xx_uart.c b/drivers/tty/serial/mpc52xx_uart.c
index 5be1df39f9f5..1d1dbe9d5af2 100644
--- a/drivers/tty/serial/mpc52xx_uart.c
+++ b/drivers/tty/serial/mpc52xx_uart.c
@@ -619,29 +619,55 @@ static irqreturn_t mpc512x_psc_handle_irq(struct uart_port *port)
 }
 
 static struct clk *psc_mclk_clk[MPC52xx_PSC_MAXNUM];
+static struct clk *psc_ipg_clk[MPC52xx_PSC_MAXNUM];
 
 /* called from within the .request_port() callback (allocation) */
 static int mpc512x_psc_alloc_clock(struct uart_port *port)
 {
 	int psc_num;
-	char clk_name[16];
 	struct clk *clk;
 	int err;
 
 	psc_num = (port->mapbase & 0xf00) >> 8;
-	snprintf(clk_name, sizeof(clk_name), "psc%d_mclk", psc_num);
-	clk = devm_clk_get(port->dev, clk_name);
+
+	clk = devm_clk_get(port->dev, "mclk");
 	if (IS_ERR(clk)) {
 		dev_err(port->dev, "Failed to get MCLK!\n");
-		return PTR_ERR(clk);
+		err = PTR_ERR(clk);
+		goto out_err;
 	}
 	err = clk_prepare_enable(clk);
 	if (err) {
 		dev_err(port->dev, "Failed to enable MCLK!\n");
-		return err;
+		goto out_err;
 	}
 	psc_mclk_clk[psc_num] = clk;
+
+	clk = devm_clk_get(port->dev, "ipg");
+	if (IS_ERR(clk)) {
+		dev_err(port->dev, "Failed to get IPG clock!\n");
+		err = PTR_ERR(clk);
+		goto out_err;
+	}
+	err = clk_prepare_enable(clk);
+	if (err) {
+		dev_err(port->dev, "Failed to enable IPG clock!\n");
+		goto out_err;
+	}
+	psc_ipg_clk[psc_num] = clk;
+
 	return 0;
+
+out_err:
+	if (psc_mclk_clk[psc_num]) {
+		clk_disable_unprepare(psc_mclk_clk[psc_num]);
+		psc_mclk_clk[psc_num] = NULL;
+	}
+	if (psc_ipg_clk[psc_num]) {
+		clk_disable_unprepare(psc_ipg_clk[psc_num]);
+		psc_ipg_clk[psc_num] = NULL;
+	}
+	return err;
 }
 
 /* called from within the .release_port() callback (release) */
@@ -656,6 +682,10 @@ static void mpc512x_psc_relse_clock(struct uart_port *port)
 		clk_disable_unprepare(clk);
 		psc_mclk_clk[psc_num] = NULL;
 	}
+	if (psc_ipg_clk[psc_num]) {
+		clk_disable_unprepare(psc_ipg_clk[psc_num]);
+		psc_ipg_clk[psc_num] = NULL;
+	}
 }
 
 /* implementation of the .clock() callback (enable/disable) */
-- 
1.7.10.4


WARNING: multiple messages have this Message-ID (diff)
From: Gerhard Sittig <gsi@denx.de>
To: linuxppc-dev@lists.ozlabs.org,
	linux-arm-kernel@lists.infradead.org,
	Anatolij Gustschin <agust@denx.de>,
	Mike Turquette <mturquette@linaro.org>
Cc: Detlev Zundel <dzu@denx.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Gerhard Sittig <gsi@denx.de>,
	linux-serial@vger.kernel.org,
	Scott Wood <scottwood@freescale.com>, Jiri Slaby <jslaby@suse.cz>
Subject: [PATCH v5 09/17] serial: mpc512x: adjust for OF based clock lookup
Date: Mon, 18 Nov 2013 00:06:09 +0100	[thread overview]
Message-ID: <1384729577-7336-10-git-send-email-gsi@denx.de> (raw)
In-Reply-To: <1384729577-7336-1-git-send-email-gsi@denx.de>

after device tree based clock lookup became available, the peripheral
driver need no longer construct clock names which include the PSC index,
remove the "psc%d_mclk" template and unconditionally use 'mclk'

acquire and release the "ipg" clock item for register access as well

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: linux-serial@vger.kernel.org
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> # for v4
Signed-off-by: Gerhard Sittig <gsi@denx.de>
---
Greg, the difference between v4 and v5 of this patch is that v4
took the 'mclk' and 'ipg' clock items in reverse order, and thus
potentially obfuscated the adjusted name for 'mclk' -- v5 of the
patch is identical in content but cleaner diff-wise

---
 drivers/tty/serial/mpc52xx_uart.c |   40 ++++++++++++++++++++++++++++++++-----
 1 file changed, 35 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/serial/mpc52xx_uart.c b/drivers/tty/serial/mpc52xx_uart.c
index 5be1df39f9f5..1d1dbe9d5af2 100644
--- a/drivers/tty/serial/mpc52xx_uart.c
+++ b/drivers/tty/serial/mpc52xx_uart.c
@@ -619,29 +619,55 @@ static irqreturn_t mpc512x_psc_handle_irq(struct uart_port *port)
 }
 
 static struct clk *psc_mclk_clk[MPC52xx_PSC_MAXNUM];
+static struct clk *psc_ipg_clk[MPC52xx_PSC_MAXNUM];
 
 /* called from within the .request_port() callback (allocation) */
 static int mpc512x_psc_alloc_clock(struct uart_port *port)
 {
 	int psc_num;
-	char clk_name[16];
 	struct clk *clk;
 	int err;
 
 	psc_num = (port->mapbase & 0xf00) >> 8;
-	snprintf(clk_name, sizeof(clk_name), "psc%d_mclk", psc_num);
-	clk = devm_clk_get(port->dev, clk_name);
+
+	clk = devm_clk_get(port->dev, "mclk");
 	if (IS_ERR(clk)) {
 		dev_err(port->dev, "Failed to get MCLK!\n");
-		return PTR_ERR(clk);
+		err = PTR_ERR(clk);
+		goto out_err;
 	}
 	err = clk_prepare_enable(clk);
 	if (err) {
 		dev_err(port->dev, "Failed to enable MCLK!\n");
-		return err;
+		goto out_err;
 	}
 	psc_mclk_clk[psc_num] = clk;
+
+	clk = devm_clk_get(port->dev, "ipg");
+	if (IS_ERR(clk)) {
+		dev_err(port->dev, "Failed to get IPG clock!\n");
+		err = PTR_ERR(clk);
+		goto out_err;
+	}
+	err = clk_prepare_enable(clk);
+	if (err) {
+		dev_err(port->dev, "Failed to enable IPG clock!\n");
+		goto out_err;
+	}
+	psc_ipg_clk[psc_num] = clk;
+
 	return 0;
+
+out_err:
+	if (psc_mclk_clk[psc_num]) {
+		clk_disable_unprepare(psc_mclk_clk[psc_num]);
+		psc_mclk_clk[psc_num] = NULL;
+	}
+	if (psc_ipg_clk[psc_num]) {
+		clk_disable_unprepare(psc_ipg_clk[psc_num]);
+		psc_ipg_clk[psc_num] = NULL;
+	}
+	return err;
 }
 
 /* called from within the .release_port() callback (release) */
@@ -656,6 +682,10 @@ static void mpc512x_psc_relse_clock(struct uart_port *port)
 		clk_disable_unprepare(clk);
 		psc_mclk_clk[psc_num] = NULL;
 	}
+	if (psc_ipg_clk[psc_num]) {
+		clk_disable_unprepare(psc_ipg_clk[psc_num]);
+		psc_ipg_clk[psc_num] = NULL;
+	}
 }
 
 /* implementation of the .clock() callback (enable/disable) */
-- 
1.7.10.4

WARNING: multiple messages have this Message-ID (diff)
From: gsi@denx.de (Gerhard Sittig)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v5 09/17] serial: mpc512x: adjust for OF based clock lookup
Date: Mon, 18 Nov 2013 00:06:09 +0100	[thread overview]
Message-ID: <1384729577-7336-10-git-send-email-gsi@denx.de> (raw)
In-Reply-To: <1384729577-7336-1-git-send-email-gsi@denx.de>

after device tree based clock lookup became available, the peripheral
driver need no longer construct clock names which include the PSC index,
remove the "psc%d_mclk" template and unconditionally use 'mclk'

acquire and release the "ipg" clock item for register access as well

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: linux-serial at vger.kernel.org
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> # for v4
Signed-off-by: Gerhard Sittig <gsi@denx.de>
---
Greg, the difference between v4 and v5 of this patch is that v4
took the 'mclk' and 'ipg' clock items in reverse order, and thus
potentially obfuscated the adjusted name for 'mclk' -- v5 of the
patch is identical in content but cleaner diff-wise

---
 drivers/tty/serial/mpc52xx_uart.c |   40 ++++++++++++++++++++++++++++++++-----
 1 file changed, 35 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/serial/mpc52xx_uart.c b/drivers/tty/serial/mpc52xx_uart.c
index 5be1df39f9f5..1d1dbe9d5af2 100644
--- a/drivers/tty/serial/mpc52xx_uart.c
+++ b/drivers/tty/serial/mpc52xx_uart.c
@@ -619,29 +619,55 @@ static irqreturn_t mpc512x_psc_handle_irq(struct uart_port *port)
 }
 
 static struct clk *psc_mclk_clk[MPC52xx_PSC_MAXNUM];
+static struct clk *psc_ipg_clk[MPC52xx_PSC_MAXNUM];
 
 /* called from within the .request_port() callback (allocation) */
 static int mpc512x_psc_alloc_clock(struct uart_port *port)
 {
 	int psc_num;
-	char clk_name[16];
 	struct clk *clk;
 	int err;
 
 	psc_num = (port->mapbase & 0xf00) >> 8;
-	snprintf(clk_name, sizeof(clk_name), "psc%d_mclk", psc_num);
-	clk = devm_clk_get(port->dev, clk_name);
+
+	clk = devm_clk_get(port->dev, "mclk");
 	if (IS_ERR(clk)) {
 		dev_err(port->dev, "Failed to get MCLK!\n");
-		return PTR_ERR(clk);
+		err = PTR_ERR(clk);
+		goto out_err;
 	}
 	err = clk_prepare_enable(clk);
 	if (err) {
 		dev_err(port->dev, "Failed to enable MCLK!\n");
-		return err;
+		goto out_err;
 	}
 	psc_mclk_clk[psc_num] = clk;
+
+	clk = devm_clk_get(port->dev, "ipg");
+	if (IS_ERR(clk)) {
+		dev_err(port->dev, "Failed to get IPG clock!\n");
+		err = PTR_ERR(clk);
+		goto out_err;
+	}
+	err = clk_prepare_enable(clk);
+	if (err) {
+		dev_err(port->dev, "Failed to enable IPG clock!\n");
+		goto out_err;
+	}
+	psc_ipg_clk[psc_num] = clk;
+
 	return 0;
+
+out_err:
+	if (psc_mclk_clk[psc_num]) {
+		clk_disable_unprepare(psc_mclk_clk[psc_num]);
+		psc_mclk_clk[psc_num] = NULL;
+	}
+	if (psc_ipg_clk[psc_num]) {
+		clk_disable_unprepare(psc_ipg_clk[psc_num]);
+		psc_ipg_clk[psc_num] = NULL;
+	}
+	return err;
 }
 
 /* called from within the .release_port() callback (release) */
@@ -656,6 +682,10 @@ static void mpc512x_psc_relse_clock(struct uart_port *port)
 		clk_disable_unprepare(clk);
 		psc_mclk_clk[psc_num] = NULL;
 	}
+	if (psc_ipg_clk[psc_num]) {
+		clk_disable_unprepare(psc_ipg_clk[psc_num]);
+		psc_ipg_clk[psc_num] = NULL;
+	}
 }
 
 /* implementation of the .clock() callback (enable/disable) */
-- 
1.7.10.4

  parent reply	other threads:[~2013-11-17 23:08 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-17 23:06 [PATCH v5 00/17] add COMMON_CLK support for PowerPC MPC512x Gerhard Sittig
2013-11-17 23:06 ` Gerhard Sittig
2013-11-17 23:06 ` Gerhard Sittig
2013-11-17 23:06 ` Gerhard Sittig
2013-11-17 23:06 ` Gerhard Sittig
2013-11-17 23:06 ` Gerhard Sittig
2013-11-17 23:06 ` [PATCH v5 01/17] powerpc/fsl-pci: improve clock API use Gerhard Sittig
2013-11-17 23:06   ` Gerhard Sittig
2013-11-19 22:41   ` Scott Wood
2013-11-19 22:41     ` Scott Wood
2013-11-21  9:21     ` Gerhard Sittig
2013-11-21  9:21       ` Gerhard Sittig
2013-11-17 23:06 ` [PATCH v5 04/17] clk: mpc512x: introduce COMMON_CLK for MPC512x (disabled) Gerhard Sittig
2013-11-17 23:06   ` Gerhard Sittig
2013-11-17 23:06 ` [PATCH v5 05/17] clk: mpc512x: add backwards compat to the CCF code Gerhard Sittig
2013-11-17 23:06   ` Gerhard Sittig
2013-11-17 23:06 ` [PATCH v5 07/17] clk: mpc5xxx: switch to COMMON_CLK, retire PPC_CLOCK Gerhard Sittig
2013-11-17 23:06   ` Gerhard Sittig
     [not found] ` <1384729577-7336-1-git-send-email-gsi-ynQEQJNshbs@public.gmane.org>
2013-11-17 23:06   ` [PATCH v5 02/17] dts: mpc512x: introduce dt-bindings/clock/ header Gerhard Sittig
2013-11-17 23:06     ` Gerhard Sittig
2013-11-17 23:06     ` Gerhard Sittig
2013-11-17 23:06   ` [PATCH v5 03/17] dts: mpc512x: add clock related device tree specs Gerhard Sittig
2013-11-17 23:06     ` Gerhard Sittig
2013-11-17 23:06     ` Gerhard Sittig
2013-11-17 23:06   ` [PATCH v5 06/17] dts: mpc512x: add clock specs for client lookups Gerhard Sittig
2013-11-17 23:06     ` Gerhard Sittig
2013-11-17 23:06     ` Gerhard Sittig
2013-11-17 23:06   ` [PATCH v5 08/17] spi: mpc512x: adjust to OF based clock lookup Gerhard Sittig
2013-11-17 23:06     ` Gerhard Sittig
2013-11-17 23:06     ` Gerhard Sittig
2013-11-25 17:30     ` Mark Brown
2013-11-25 17:30       ` Mark Brown
2013-11-25 17:30       ` Mark Brown
     [not found]       ` <20131125173008.GQ14725-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-11-25 19:06         ` Gerhard Sittig
2013-11-25 19:06           ` Gerhard Sittig
2013-11-25 19:06           ` Gerhard Sittig
2013-11-17 23:06 ` Gerhard Sittig [this message]
2013-11-17 23:06   ` [PATCH v5 09/17] serial: mpc512x: adjust for " Gerhard Sittig
2013-11-17 23:06   ` Gerhard Sittig
2013-11-17 23:06 ` [PATCH v5 10/17] serial: mpc512x: setup the PSC FIFO clock as well Gerhard Sittig
2013-11-17 23:06   ` Gerhard Sittig
2013-11-17 23:06   ` Gerhard Sittig
2013-11-17 23:06 ` [PATCH v5 11/17] USB: fsl-mph-dr-of: adjust for OF based clock lookup Gerhard Sittig
2013-11-17 23:06   ` Gerhard Sittig
2013-11-17 23:06 ` [PATCH v5 12/17] mtd: mpc5121_nfc: " Gerhard Sittig
2013-11-17 23:06   ` Gerhard Sittig
2013-11-17 23:06 ` [PATCH v5 13/17] [media] fsl-viu: " Gerhard Sittig
2013-11-17 23:06   ` Gerhard Sittig
2013-11-17 23:06   ` Gerhard Sittig
2013-11-17 23:06 ` [PATCH v5 14/17] net: can: mscan: adjust to common clock support for mpc512x Gerhard Sittig
2013-11-17 23:06   ` Gerhard Sittig
2013-11-17 23:06   ` Gerhard Sittig
2013-11-17 23:06 ` [PATCH v5 15/17] net: can: mscan: remove non-CCF code for MPC512x Gerhard Sittig
2013-11-17 23:06   ` Gerhard Sittig
2013-11-17 23:06   ` Gerhard Sittig
2013-11-17 23:06 ` [PATCH v5 16/17] powerpc/mpc512x: improve DIU related clock setup Gerhard Sittig
2013-11-17 23:06   ` Gerhard Sittig
2013-11-17 23:06 ` [PATCH v5 17/17] clk: mpc512x: remove migration support workarounds Gerhard Sittig
2013-11-17 23:06   ` Gerhard Sittig
2013-11-24 18:39 ` [PATCH v5 00/17] add COMMON_CLK support for PowerPC MPC512x Gerhard Sittig
2013-11-24 18:39   ` Gerhard Sittig
2013-11-24 18:39   ` Gerhard Sittig
2013-11-24 18:39   ` Gerhard Sittig
2013-11-24 18:39   ` Gerhard Sittig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1384729577-7336-10-git-send-email-gsi@denx.de \
    --to=gsi@denx.de \
    --cc=agust@denx.de \
    --cc=dzu@denx.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.cz \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mturquette@linaro.org \
    --cc=scottwood@freescale.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.