summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2021-12-06 19:55:40 +0300
committerMarc Kleine-Budde <mkl@pengutronix.de>2021-12-08 12:19:48 +0300
commit3a1ae63a4d218d0d51646380fe406405660b9a5c (patch)
tree396c9213e6ef3d61a23f28049fd33710c744c085 /drivers
parent369cf4e6ac53f1595ef8602a8a984bce9b895ddb (diff)
downloadlinux-3a1ae63a4d218d0d51646380fe406405660b9a5c.tar.xz
can: hi311x: hi3110_can_probe(): try to get crystal clock rate from property
In some configurations, mainly ACPI-based, the clock frequency of the device is supplied by very well established 'clock-frequency' property. Hence, try to get it from the property at last if no other providers are available. Link: https://lore.kernel.org/all/20211206165542.69887-2-andriy.shevchenko@linux.intel.com Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/can/spi/hi311x.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/net/can/spi/hi311x.c b/drivers/net/can/spi/hi311x.c
index 13fb979645cf..c9efdd10d0f8 100644
--- a/drivers/net/can/spi/hi311x.c
+++ b/drivers/net/can/spi/hi311x.c
@@ -830,17 +830,26 @@ static int hi3110_can_probe(struct spi_device *spi)
{
const struct of_device_id *of_id = of_match_device(hi3110_of_match,
&spi->dev);
+ struct device *dev = &spi->dev;
struct net_device *net;
struct hi3110_priv *priv;
struct clk *clk;
- int freq, ret;
+ u32 freq;
+ int ret;
clk = devm_clk_get_optional(&spi->dev, NULL);
if (IS_ERR(clk)) {
dev_err(&spi->dev, "no CAN clock source defined\n");
return PTR_ERR(clk);
}
- freq = clk_get_rate(clk);
+
+ if (clk) {
+ freq = clk_get_rate(clk);
+ } else {
+ ret = device_property_read_u32(dev, "clock-frequency", &freq);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to get clock-frequency!\n");
+ }
/* Sanity check */
if (freq > 40000000)