]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
staging: wilc1000: look for rtc_clk clock in spi mode
authorAdham Abozaeid <adham.abozaeid@microchip.com>
Mon, 16 Sep 2019 19:37:08 +0000 (19:37 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 30 Sep 2019 19:58:03 +0000 (21:58 +0200)
If rtc_clk is provided from DT, use it and enable it.
This is optional.
The signal may be hardcoded and no need to be requested,
but if DT provides it, use it.

Signed-off-by: Adham Abozaeid <adham.abozaeid@microchip.com>
Link: https://lore.kernel.org/r/20190916193701.20755-1-adham.abozaeid@microchip.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wilc1000/wilc_spi.c

index 3c1ae9e9f9aa1a2bcc4688ac007801ccab699faa..166455a969bff17c970fafb34357967cdfe6e738 100644 (file)
@@ -4,6 +4,7 @@
  * All rights reserved.
  */
 
+#include <linux/clk.h>
 #include <linux/spi/spi.h>
 
 #include "wilc_wfi_netdevice.h"
@@ -132,6 +133,12 @@ static int wilc_bus_probe(struct spi_device *spi)
        wilc->bus_data = spi_priv;
        wilc->gpio_irq = gpio;
 
+       wilc->rtc_clk = devm_clk_get(&spi->dev, "rtc_clk");
+       if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER)
+               return -EPROBE_DEFER;
+       else if (!IS_ERR(wilc->rtc_clk))
+               clk_prepare_enable(wilc->rtc_clk);
+
        return 0;
 }
 
@@ -142,6 +149,10 @@ static int wilc_bus_remove(struct spi_device *spi)
        /* free the GPIO in module remove */
        if (wilc->gpio_irq)
                gpiod_put(wilc->gpio_irq);
+
+       if (!IS_ERR(wilc->rtc_clk))
+               clk_disable_unprepare(wilc->rtc_clk);
+
        wilc_netdev_cleanup(wilc);
        return 0;
 }