[U-Boot] [PATCH v1 07/15] spi: imx: Add support for 'per' clock enabling via driver model
Lukasz Majewski
lukma at denx.de
Sat Jan 19 09:15:20 UTC 2019
With this commit one can enable ECSPI clock on imx6q without the need to
define direct call to it in the board file (as it is done up to now).
The information regarding proper clocks is provided via DTS description.
Signed-off-by: Lukasz Majewski <lukma at denx.de>
---
drivers/spi/mxc_spi.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/drivers/spi/mxc_spi.c b/drivers/spi/mxc_spi.c
index b2636909ce..371e8d8e44 100644
--- a/drivers/spi/mxc_spi.c
+++ b/drivers/spi/mxc_spi.c
@@ -7,6 +7,7 @@
#include <dm.h>
#include <malloc.h>
#include <spi.h>
+#include <clk.h>
#include <linux/errno.h>
#include <asm/io.h>
#include <asm/gpio.h>
@@ -50,6 +51,9 @@ struct mxc_spi_slave {
unsigned int max_hz;
unsigned int mode;
struct gpio_desc ss;
+#if CONFIG_IS_ENABLED(CLK)
+ struct clk per_clk;
+#endif
};
static inline struct mxc_spi_slave *to_mxc_spi_slave(struct spi_slave *slave)
@@ -494,6 +498,19 @@ static int mxc_spi_probe(struct udevice *bus)
const void *blob = gd->fdt_blob;
int ret;
+#if CONFIG_IS_ENABLED(CLK)
+ ret = clk_get_by_name(bus, "per", &mxcs->per_clk);
+ if (ret) {
+ printf("%s: Failed to get per_clk\n", __func__);
+ return ret;
+ }
+
+ ret = clk_enable(&mxcs->per_clk);
+ if (ret) {
+ printf("%s: Failed to enable per_clk\n", __func__);
+ return ret;
+ }
+#endif
if (gpio_request_by_name(bus, "cs-gpios", 0, &plat->ss,
GPIOD_IS_OUT)) {
dev_err(bus, "No cs-gpios property\n");
--
2.11.0
More information about the U-Boot
mailing list