mirror of
https://github.com/raspberrypi/linux.git
synced 2026-01-03 08:14:12 +00:00
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.de Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
committed by
Marc Kleine-Budde
parent
0ddd83fbeb
commit
74f89cf17e
@@ -2860,7 +2860,7 @@ static int mcp251xfd_probe(struct spi_device *spi)
|
||||
struct gpio_desc *rx_int;
|
||||
struct regulator *reg_vdd, *reg_xceiver;
|
||||
struct clk *clk;
|
||||
u32 freq;
|
||||
u32 freq = 0;
|
||||
int err;
|
||||
|
||||
if (!spi->irq)
|
||||
@@ -2887,11 +2887,19 @@ static int mcp251xfd_probe(struct spi_device *spi)
|
||||
return dev_err_probe(&spi->dev, PTR_ERR(reg_xceiver),
|
||||
"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))
|
||||
return dev_err_probe(&spi->dev, PTR_ERR(clk),
|
||||
"Failed to get Oscillator (clock)!\n");
|
||||
freq = clk_get_rate(clk);
|
||||
if (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 */
|
||||
if (freq < MCP251XFD_SYSCLOCK_HZ_MIN ||
|
||||
|
||||
Reference in New Issue
Block a user