mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Boris BREZILLON <linux-arm@overkiz.com>
To: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Grant Likely <grant.likely@secretlab.ca>,
	Rob Herring <rob.herring@calxeda.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Andrew Victor <linux@maxim.org.za>,
	Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>,
	Boris BREZILLON <linux-arm@overkiz.com>
Subject: [PATCH] ARM: at91/tc: fix clock source id for tc block > 1
Date: Tue,  2 Apr 2013 18:46:51 +0200	[thread overview]
Message-ID: <1364921211-15756-1-git-send-email-linux-arm@overkiz.com> (raw)

This patch fixes wrong clock request for TC block 2.
The second block was using t0_clk, t1_clk and t2_clk clks instead of
t3_clk, t4_clk and t5_clk clks.


Signed-off-by: Boris BREZILLON <linux-arm@overkiz.com>
---
 drivers/misc/atmel_tclib.c |   24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/misc/atmel_tclib.c b/drivers/misc/atmel_tclib.c
index c8d8e38..768a988 100644
--- a/drivers/misc/atmel_tclib.c
+++ b/drivers/misc/atmel_tclib.c
@@ -142,6 +142,8 @@ static int __init tc_probe(struct platform_device *pdev)
 	struct atmel_tc *tc;
 	struct clk	*clk;
 	int		irq;
+	char		clk_id[7];
+	int		clk_offset;
 
 	if (!platform_get_resource(pdev, IORESOURCE_MEM, 0))
 		return -EINVAL;
@@ -156,25 +158,31 @@ static int __init tc_probe(struct platform_device *pdev)
 
 	tc->pdev = pdev;
 
-	clk = clk_get(&pdev->dev, "t0_clk");
-	if (IS_ERR(clk)) {
-		kfree(tc);
-		return -EINVAL;
-	}
-
 	/* Now take SoC information if available */
 	if (pdev->dev.of_node) {
 		const struct of_device_id *match;
 		match = of_match_node(atmel_tcb_dt_ids, pdev->dev.of_node);
 		if (match)
 			tc->tcb_config = match->data;
+		clk_offset = of_alias_get_id(tc->pdev->dev.of_node, "tcb");
+	} else
+		clk_offset = pdev->id;
+	clk_offset *= 3;
+
+	snprintf(clk_id, sizeof(clk_id), "t%d_clk", clk_offset++);
+	clk = clk_get(&pdev->dev, clk_id);
+	if (IS_ERR(clk)) {
+		kfree(tc);
+		return -EINVAL;
 	}
 
 	tc->clk[0] = clk;
-	tc->clk[1] = clk_get(&pdev->dev, "t1_clk");
+	snprintf(clk_id, sizeof(clk_id), "t%d_clk", clk_offset++);
+	tc->clk[1] = clk_get(&pdev->dev, clk_id);
 	if (IS_ERR(tc->clk[1]))
 		tc->clk[1] = clk;
-	tc->clk[2] = clk_get(&pdev->dev, "t2_clk");
+	snprintf(clk_id, sizeof(clk_id), "t%d_clk", clk_offset++);
+	tc->clk[2] = clk_get(&pdev->dev, clk_id);
 	if (IS_ERR(tc->clk[2]))
 		tc->clk[2] = clk;
 
-- 
1.7.9.5


             reply	other threads:[~2013-04-02 19:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-02 16:46 Boris BREZILLON [this message]
2013-04-03  4:45 ` Jean-Christophe PLAGNIOL-VILLARD
2013-04-03  7:26   ` Nicolas Ferre
2013-04-03  7:59     ` Boris BREZILLON
2013-04-03  8:32       ` Nicolas Ferre

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=1364921211-15756-1-git-send-email-linux-arm@overkiz.com \
    --to=linux-arm@overkiz.com \
    --cc=arnd@arndb.de \
    --cc=grant.likely@secretlab.ca \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@maxim.org.za \
    --cc=nicolas.ferre@atmel.com \
    --cc=plagnioj@jcrosoft.com \
    --cc=rob.herring@calxeda.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome