mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wenyou Yang <wenyou.yang@atmel.com>
To: Wolfgang Grandegger <wg@grandegger.com>,
	Marc Kleine-Budde <mkl@pengutronix.de>
Cc: <linux-can@vger.kernel.org>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	Nicolas Ferre <nicolas.ferre@atmel.com>,
	Wenyou Yang <wenyou.yang@atmel.com>
Subject: [PATCH 2/2] can: m_can: Add CAN clock generated by UPLLCK support
Date: Wed, 18 Nov 2015 18:04:09 +0800	[thread overview]
Message-ID: <1447841049-5010-3-git-send-email-wenyou.yang@atmel.com> (raw)
In-Reply-To: <1447841049-5010-1-git-send-email-wenyou.yang@atmel.com>

As said SAMA5D2 datasheet, it is recommended to use the CAN clock
at frequencies of 20, 40 or 80 MHz. To achieve these frequencies,
PMC GCK3 must select the UPLLCK(480 MHz) as source clock and
divide by 24, 12 or 6. In this patch the CAN clock at 20 MHz.

As it is configured through DT, it doesn't affect the M_CAN
without configuring CAN clock and its generated clock.

Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
---

 drivers/net/can/m_can/m_can.c |   16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index fd1caa0..2ca47db 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -269,6 +269,8 @@ enum m_can_mram_cfg {
 #define TX_BUF_XTD		BIT(30)
 #define TX_BUF_RTR		BIT(29)
 
+#define AT91_CAN_CLK_FREQ	20000000
+
 /* address offset and element number for each FIFO/Buffer in the Message RAM */
 struct mram_cfg {
 	u16 off;
@@ -1188,7 +1190,7 @@ static int m_can_plat_probe(struct platform_device *pdev)
 	struct m_can_priv *priv;
 	struct resource *res;
 	void __iomem *addr;
-	struct clk *hclk, *cclk;
+	struct clk *hclk, *cclk, *upll_clk;
 	int irq, ret;
 
 	hclk = devm_clk_get(&pdev->dev, "hclk");
@@ -1198,6 +1200,18 @@ static int m_can_plat_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
+	upll_clk = devm_clk_get(&pdev->dev, "upllclk");
+	if (!IS_ERR(upll_clk)) {
+		ret = clk_set_parent(cclk, upll_clk);
+		if (!ret) {
+			ret = clk_set_rate(cclk, AT91_CAN_CLK_FREQ);
+			if (ret) {
+				dev_err(&pdev->dev, "failed to set gck\n");
+				return -ENODEV;
+			}
+		}
+	}
+
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "m_can");
 	addr = devm_ioremap_resource(&pdev->dev, res);
 	irq = platform_get_irq_byname(pdev, "int0");
-- 
1.7.9.5


  parent reply	other threads:[~2015-11-18 10:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-18 10:04 [PATCH 0/2] " Wenyou Yang
2015-11-18 10:04 ` [PATCH 1/2] can: m_can: Increase delay to ensure written INIT accepted Wenyou Yang
2015-11-18 10:25   ` Marc Kleine-Budde
2015-11-19  4:25     ` Yang, Wenyou
2015-11-18 10:04 ` Wenyou Yang [this message]
2015-11-18 10:23   ` [PATCH 2/2] can: m_can: Add CAN clock generated by UPLLCK support Marc Kleine-Budde
2015-11-19  4:24     ` Yang, Wenyou

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=1447841049-5010-3-git-send-email-wenyou.yang@atmel.com \
    --to=wenyou.yang@atmel.com \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.ferre@atmel.com \
    --cc=wg@grandegger.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

all inboxes | Powered by JetHome®