Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1272078
| From | Wenyou Yang <wenyou.yang@atmel.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 2/2] can: m_can: Add CAN clock generated by UPLLCK support |
| Date | 2015-11-18 11:20 +0100 |
| Message-ID | <qw80i-1y5-15@gated-at.bofh.it> (permalink) |
| References | <qw7QC-1tN-19@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/2] can: m_can: Add CAN clock generated by UPLLCK support Wenyou Yang <wenyou.yang@atmel.com> - 2015-11-18 11:10 +0100
[PATCH 1/2] can: m_can: Increase delay to ensure written INIT accepted Wenyou Yang <wenyou.yang@atmel.com> - 2015-11-18 11:20 +0100
Re: [PATCH 1/2] can: m_can: Increase delay to ensure written INIT accepted Marc Kleine-Budde <mkl@pengutronix.de> - 2015-11-18 11:30 +0100
RE: [PATCH 1/2] can: m_can: Increase delay to ensure written INIT accepted "Yang, Wenyou" <Wenyou.Yang@atmel.com> - 2015-11-19 05:30 +0100
[PATCH 2/2] can: m_can: Add CAN clock generated by UPLLCK support Wenyou Yang <wenyou.yang@atmel.com> - 2015-11-18 11:20 +0100
Re: [PATCH 2/2] can: m_can: Add CAN clock generated by UPLLCK support Marc Kleine-Budde <mkl@pengutronix.de> - 2015-11-18 11:30 +0100
RE: [PATCH 2/2] can: m_can: Add CAN clock generated by UPLLCK support "Yang, Wenyou" <Wenyou.Yang@atmel.com> - 2015-11-19 05:30 +0100
csiph-web