Patch "rtc: sun6i: Make external 32k oscillator optional" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    rtc: sun6i: Make external 32k oscillator optional

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     rtc-sun6i-make-external-32k-oscillator-optional.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 53ad9df0bb63547ffed19d1caa75e9f35b06d7d9
Author: Jernej Skrabec <jernej.skrabec@xxxxxxxxx>
Date:   Sun Mar 8 14:58:48 2020 +0100

    rtc: sun6i: Make external 32k oscillator optional
    
    [ Upstream commit ec98a87509f40324807dc179a7e3163d40709eba ]
    
    Some boards, like OrangePi PC2 (H5), OrangePi Plus 2E (H3) and Tanix TX6
    (H6) don't have external 32kHz oscillator. Till H6, it didn't really
    matter if external oscillator was enabled because HW detected error and
    fall back to internal one. H6 has same functionality but it's the first
    SoC which have "auto switch bypass" bit documented and always enabled in
    driver. This prevents RTC to work correctly if external crystal is not
    present on board. There are other side effects - all peripherals which
    depends on this clock also don't work (HDMI CEC for example).
    
    Make clocks property optional. If it is present, select external
    oscillator. If not, stay on internal.
    
    Signed-off-by: Jernej Skrabec <jernej.skrabec@xxxxxxxx>
    Acked-by: Maxime Ripard <mripard@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20200308135849.106333-2-jernej.skrabec@xxxxxxxx
    Signed-off-by: Alexandre Belloni <alexandre.belloni@xxxxxxxxxxx>
    Stable-dep-of: 344f4030f6c5 ("rtc: sun6i: Always export the internal oscillator")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c
index c41bc8084d7cc..b13af0368ef61 100644
--- a/drivers/rtc/rtc-sun6i.c
+++ b/drivers/rtc/rtc-sun6i.c
@@ -251,19 +251,17 @@ static void __init sun6i_rtc_clk_init(struct device_node *node,
 		writel(reg, rtc->base + SUN6I_LOSC_CTRL);
 	}
 
-	/* Switch to the external, more precise, oscillator */
-	reg |= SUN6I_LOSC_CTRL_EXT_OSC;
-	if (rtc->data->has_losc_en)
-		reg |= SUN6I_LOSC_CTRL_EXT_LOSC_EN;
+	/* Switch to the external, more precise, oscillator, if present */
+	if (of_get_property(node, "clocks", NULL)) {
+		reg |= SUN6I_LOSC_CTRL_EXT_OSC;
+		if (rtc->data->has_losc_en)
+			reg |= SUN6I_LOSC_CTRL_EXT_LOSC_EN;
+	}
 	writel(reg, rtc->base + SUN6I_LOSC_CTRL);
 
 	/* Yes, I know, this is ugly. */
 	sun6i_rtc = rtc;
 
-	/* Deal with old DTs */
-	if (!of_get_property(node, "clocks", NULL))
-		goto err;
-
 	/* Only read IOSC name from device tree if it is exported */
 	if (rtc->data->export_iosc)
 		of_property_read_string_index(node, "clock-output-names", 2,
@@ -280,11 +278,13 @@ static void __init sun6i_rtc_clk_init(struct device_node *node,
 	}
 
 	parents[0] = clk_hw_get_name(rtc->int_osc);
+	/* If there is no external oscillator, this will be NULL and ... */
 	parents[1] = of_clk_get_parent_name(node, 0);
 
 	rtc->hw.init = &init;
 
 	init.parent_names = parents;
+	/* ... number of clock parents will be 1. */
 	init.num_parents = of_clk_get_parent_count(node) + 1;
 	of_property_read_string_index(node, "clock-output-names", 0,
 				      &init.name);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux