Hello,
I reckon that better initialization procedure for the clock instances is
unconditional initialization and attached patch serves for this purpose.
--
Pozdrawiam / Best Regards / Freundliche Grüße
Krzysztof Błaszkowski
Projektant / Elektronik
Ekoenergetyka-Polska Sp. z o.o.
ul.Nowy Kisielin - Wysockiego 8,
66-002 Zielona Góra
Tel./Fax +48 68 328 20 68
/
/www.ekoenergetyka.com.pl <http://www.ekoenergetyka.com.pl/>
_Dane do faktury*:*_
Ekoenergetyka - Polska sp. z o.o.
ul. Nowy Kisielin - A. Wysockiego 8
66-002 Zielona Góra
NIP: 973-101-39-38
Regon: 081115852
BDO: 000014716
Sąd Rejonowy w Zielonej Górze, VIII Wydział Gospodarczy KRS
KRS: 0000452958
Kapitał zakładowy: 133.300,00 zł
>From 0e845a71afa6bf928af75f94fb40d1109bf5751b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Krzysztof=20B=C5=82aszkowski?=
<krzysztof.blaszkowski@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 26 Sep 2018 09:04:48 +0200
Subject: [PATCH 1/2] Changed initialization policy of struct clk
*priv::clk_per and priv::clk_ipg These abstract clock instances (clock gates
according to CCM section of imx6 RM) should always be initialiazed even when
the dts property "clock-frequency" was set. Otherwise these hardware clock
gates may not be enabled. If the "clock-frequency" is specified then the
driver will attempt to set clock rate, ie. modify imx6's multiplexer and
divider, with regard to requested settings.
---
drivers/net/can/flexcan.c | 36 +++++++++++++++++++++++++-----------
1 file changed, 25 insertions(+), 11 deletions(-)
diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 27958bb..353b4a3 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -1271,19 +1271,33 @@ static int flexcan_probe(struct platform_device *pdev)
of_property_read_u32(pdev->dev.of_node,
"clock-frequency", &clock_freq);
- if (!clock_freq) {
- clk_ipg = devm_clk_get(&pdev->dev, "ipg");
- if (IS_ERR(clk_ipg)) {
- dev_err(&pdev->dev, "no ipg clock defined\n");
- return PTR_ERR(clk_ipg);
- }
+ clk_ipg = devm_clk_get(&pdev->dev, "ipg");
+ if (IS_ERR(clk_ipg)) {
+ dev_err(&pdev->dev, "no ipg clock defined."
+ " invalid dts likely\n");
+ return PTR_ERR(clk_ipg);
+ }
- clk_per = devm_clk_get(&pdev->dev, "per");
- if (IS_ERR(clk_per)) {
- dev_err(&pdev->dev, "no per clock defined\n");
- return PTR_ERR(clk_per);
- }
+ clk_per = devm_clk_get(&pdev->dev, "per");
+ if (IS_ERR(clk_per)) {
+ dev_err(&pdev->dev, "no peripherial clock defined."
+ " invalid dts likely\n");
+ return PTR_ERR(clk_per);
+ }
+
+ if (!clock_freq)
+ clock_freq = clk_get_rate(clk_per);
+ else {
+ u32 tmp_clk_frq = clock_freq;
+
+ clk_set_rate(clk_per, clock_freq);
clock_freq = clk_get_rate(clk_per);
+ dev_dbg(&pdev->dev, "flexcan clk %u. "
+ "This may alter operation of previous can instance\n",
+ clock_freq);
+ if (tmp_clk_frq != clock_freq)
+ dev_info(&pdev->dev, "clock rate is %u. "
+ "Requested rate was not set\n", clock_freq);
}
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
--
2.11.0