Commit 74f89cf1 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Marc Kleine-Budde

can: mcp251xfd: mcp251xfd_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/r/20210531084444.1785397-1-mkl@pengutronix.deSigned-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent 0ddd83fb
...@@ -2860,7 +2860,7 @@ static int mcp251xfd_probe(struct spi_device *spi) ...@@ -2860,7 +2860,7 @@ static int mcp251xfd_probe(struct spi_device *spi)
struct gpio_desc *rx_int; struct gpio_desc *rx_int;
struct regulator *reg_vdd, *reg_xceiver; struct regulator *reg_vdd, *reg_xceiver;
struct clk *clk; struct clk *clk;
u32 freq; u32 freq = 0;
int err; int err;
if (!spi->irq) if (!spi->irq)
...@@ -2887,11 +2887,19 @@ static int mcp251xfd_probe(struct spi_device *spi) ...@@ -2887,11 +2887,19 @@ static int mcp251xfd_probe(struct spi_device *spi)
return dev_err_probe(&spi->dev, PTR_ERR(reg_xceiver), return dev_err_probe(&spi->dev, PTR_ERR(reg_xceiver),
"Failed to get Transceiver regulator!\n"); "Failed to get Transceiver regulator!\n");
clk = devm_clk_get(&spi->dev, NULL); clk = devm_clk_get_optional(&spi->dev, NULL);
if (IS_ERR(clk)) if (IS_ERR(clk))
return dev_err_probe(&spi->dev, PTR_ERR(clk), return dev_err_probe(&spi->dev, PTR_ERR(clk),
"Failed to get Oscillator (clock)!\n"); "Failed to get Oscillator (clock)!\n");
if (clk) {
freq = clk_get_rate(clk); freq = clk_get_rate(clk);
} else {
err = device_property_read_u32(&spi->dev, "clock-frequency",
&freq);
if (err)
return dev_err_probe(&spi->dev, err,
"Failed to get clock-frequency!\n");
}
/* Sanity check */ /* Sanity check */
if (freq < MCP251XFD_SYSCLOCK_HZ_MIN || if (freq < MCP251XFD_SYSCLOCK_HZ_MIN ||
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment