LKML Archive on lore.kernel.org
 help / Atom feed
* [PATCH v2 00/14] rtc: sun6i: clock rework and pre-H6 SoC support
@ 2018-12-03 14:58 Chen-Yu Tsai
  2018-12-03 14:58 ` [PATCH v2 01/14] dt-bindings: rtc: sun6i-rtc: Rewrite clock outputs as a list Chen-Yu Tsai
                   ` (14 more replies)
  0 siblings, 15 replies; 20+ messages in thread
From: Chen-Yu Tsai @ 2018-12-03 14:58 UTC (permalink / raw)
  To: Maxime Ripard, Alexandre Belloni, Alessandro Zummo,
	Michael Turquette, Stephen Boyd, Rob Herring, Mark Rutland
  Cc: Chen-Yu Tsai, linux-arm-kernel, linux-rtc, linux-clk, devicetree,
	linux-kernel, linux-sunxi

Hi everyone,

This is v2 of my rtc-sun6i clean-up series.

Changes since v1:

  - Collected tags
  - Dropped patch "clk: sunxi-ng: r40: Force LOSC parent to RTC LOSC
    output"; already merged
  - Removed H6 compatible CLK_OF_DECLARE_DRIVER entry that wasn't
    overlooked
  - Only export IOSC clock for A64/H3/H5

Original cover letter, with patch numbers corrected, follows:

This series was started as part of enabling Bluetooth on various
Allwinner SBCs. The bluetooth controller requires a precise 32.768 kHz
clock fed to it to correctly detect the frequency of its main oscillator.
This clock signal is provided by the RTC, either directly from a special
pin on the SoC, or some clock output function from the clock controllers.
I found that the clock-related properties of the RTC on later SoCs were
incorrect or missing.

This series reworks the compatible strings and clock parts of the device
tree bindings for sun6i-rtc. Currently we assume most Allwinner SoCs use
the same sun6i-rtc variant, when in fact they do not. The differences
that matter with regards to clocks are a) the A31 does not have an extra
external output for the RTC 32K clock, while most of the others do;
b) the clock frequency of the internal RC oscillator is different on
some SoCs; c) on the H6 the RTC also handles the 24 MHz DCXO, which
feeds the system HOSC. The last difference, and by extension the H6, are
not covered in this series.

Patch 1 cleans up the clock-related section of the RTC device tree
binding. This would make it easier to read and easier to add additional
clocks.

Patch 2 adds compatible strings for all identified variants introduced
prior to the H6.

Patch 3 deprecates the external clock output for the A31. The A31 does
not have this output, so it's introduction and usage was an error.

Patch 4 adds a clock output for the RTC's internal oscillator to the
device tree binding. This feeds the PRCM in some SoCs.

Patch 5 adds a default clock name for the LOSC to the RTC driver.

Patch 6 adds support for different hardware variants to the RTC driver.

Patch 7 adds support for all known pre-H6 variants.

Patch 8 exposes the RTC's internal oscillator through the device tree.

Patch 9 through 14 adds an RTC node or fixes up the RTC device node
address ranges, clock properties, names of existing clocks, and adds
accuracy properties for the external fixed oscillators.

The clock names require fixing because the sunxi clock driver implicitly
depends on the HOSC and LOSC being named "osc24M" and "osc32k". The
"fixes" to the clock hierarchy introduced in this series means the names
must also be shuffled around or the in kernel representation would be
incorrect. This has been the case since the sunxi-ng drivers were
introduced. There are plans to address this, but the code is still in its
early stages.

Please have a look.

Thanks
ChenYu

Chen-Yu Tsai (14):
  dt-bindings: rtc: sun6i-rtc: Rewrite clock outputs as a list
  dt-bindings: rtc: sun6i-rtc: Add compatible strings for pre-H6
    variants
  dt-bindings: rtc: sun6i-rtc: Deprecate external clock output for A31
  dt-bindings: rtc: sun6i-rtc: Export internal RC oscillator
  rtc: sun6i: Add default clock name for LOSC
  rtc: sun6i: Add support for different variants
  rtc: sun6i: Add support for all known pre-H6 variants
  rtc: sun6i: Expose internal oscillator through device tree
  ARM: dts: sun8i: a23/a33: Fix up RTC device node
  ARM: dts: sunxi: h3/h5: Add clock accuracy for external oscillators
  ARM: dts: sunxi: h3/h5: Fix up RTC device node and clock references
  ARM: dts: sun8i: r40: Add clock accuracy for external oscillators
  ARM: dts: sun8i: r40: Add RTC device node
  arm64: dts: allwinner: a64: Fix up RTC device node and clock
    references

 .../devicetree/bindings/rtc/sun6i-rtc.txt     |  31 ++++-
 arch/arm/boot/dts/sun8i-a23-a33.dtsi          |   6 +-
 arch/arm/boot/dts/sun8i-h3.dtsi               |   4 +
 arch/arm/boot/dts/sun8i-r40.dtsi              |  18 ++-
 arch/arm/boot/dts/sunxi-h3-h5.dtsi            |  28 ++--
 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi |  22 +---
 arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi  |   4 +
 drivers/rtc/rtc-sun6i.c                       | 121 ++++++++++++++++--
 8 files changed, 182 insertions(+), 52 deletions(-)

-- 
2.20.0.rc1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH v2 01/14] dt-bindings: rtc: sun6i-rtc: Rewrite clock outputs as a list
  2018-12-03 14:58 [PATCH v2 00/14] rtc: sun6i: clock rework and pre-H6 SoC support Chen-Yu Tsai
@ 2018-12-03 14:58 ` Chen-Yu Tsai
  2018-12-03 14:58 ` [PATCH v2 02/14] dt-bindings: rtc: sun6i-rtc: Add compatible strings for pre-H6 variants Chen-Yu Tsai
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Chen-Yu Tsai @ 2018-12-03 14:58 UTC (permalink / raw)
  To: Maxime Ripard, Alexandre Belloni, Alessandro Zummo,
	Michael Turquette, Stephen Boyd, Rob Herring, Mark Rutland
  Cc: Chen-Yu Tsai, linux-arm-kernel, linux-rtc, linux-clk, devicetree,
	linux-kernel, linux-sunxi, Corentin Labbe

The clock output section for this binding describes the two outputs in
the descriptions for both the #clock-cells and clock-output-names
properties.

Instead of overlapping information that is hard to read, rewrite the
clock outputs as a list of indices and descriptions. The properies
can reference this list instead. This will also make it easier to
add notes or conditions to the clocks, and also for adding new outputs.

Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 Documentation/devicetree/bindings/rtc/sun6i-rtc.txt | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/rtc/sun6i-rtc.txt b/Documentation/devicetree/bindings/rtc/sun6i-rtc.txt
index cf4177f61ace..fed0d58cbfec 100644
--- a/Documentation/devicetree/bindings/rtc/sun6i-rtc.txt
+++ b/Documentation/devicetree/bindings/rtc/sun6i-rtc.txt
@@ -10,10 +10,12 @@ Required properties:
 
 Required properties for new device trees
 - clocks	: phandle to the 32kHz external oscillator
-- clock-output-names : names of the LOSC and its external output clocks created
-- #clock-cells  : must be equals to 1. The RTC provides two clocks: the
-		  LOSC and its external output, with index 0 and 1
-		  respectively.
+- clock-output-names : names of the two clock outputs. See below.
+- #clock-cells  : must be equal to 1.
+
+The RTC provides the following clocks at the given indices:
+- 0: LOSC
+- 1: LOSC external output, known as X32KFOUT in the datasheet.
 
 Example:
 
-- 
2.20.0.rc1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH v2 02/14] dt-bindings: rtc: sun6i-rtc: Add compatible strings for pre-H6 variants
  2018-12-03 14:58 [PATCH v2 00/14] rtc: sun6i: clock rework and pre-H6 SoC support Chen-Yu Tsai
  2018-12-03 14:58 ` [PATCH v2 01/14] dt-bindings: rtc: sun6i-rtc: Rewrite clock outputs as a list Chen-Yu Tsai
@ 2018-12-03 14:58 ` Chen-Yu Tsai
  2018-12-03 14:58 ` [PATCH v2 03/14] dt-bindings: rtc: sun6i-rtc: Deprecate external clock output for A31 Chen-Yu Tsai
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Chen-Yu Tsai @ 2018-12-03 14:58 UTC (permalink / raw)
  To: Maxime Ripard, Alexandre Belloni, Alessandro Zummo,
	Michael Turquette, Stephen Boyd, Rob Herring, Mark Rutland
  Cc: Chen-Yu Tsai, linux-arm-kernel, linux-rtc, linux-clk, devicetree,
	linux-kernel, linux-sunxi, Corentin Labbe

While doing Bluetooth enablement for various boards based on various
Allwinner SoCs, minor differences in the RTC modules were found. These
include a lack of an external clock output (A31), different internal
oscillator frequencies (H3/H5/A64/V3/V3s), different regulator voltage
settings (H5/H6), and the presence of miscellaneous registers unrelated
to the RTC (A64/R40/H5/H6). The datasheet also describes different number
of registers for non-volatile storage, though based on actual experiments
the actual number is the same across the board.

This patch adds a list of all pre-H6 variants, grouped by the internal
oscillator's clock rate, regulator settings, and the presence of the
external clock output. Combinations are introduced for the variants that
have miscellaneous registers.

The RTC block in the H6 also handles the 24 MHz DCXO. This will require
more device tree binding changes and will be done later.

Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 .../devicetree/bindings/rtc/sun6i-rtc.txt        | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/rtc/sun6i-rtc.txt b/Documentation/devicetree/bindings/rtc/sun6i-rtc.txt
index fed0d58cbfec..037ec475f412 100644
--- a/Documentation/devicetree/bindings/rtc/sun6i-rtc.txt
+++ b/Documentation/devicetree/bindings/rtc/sun6i-rtc.txt
@@ -3,7 +3,21 @@
 RTC controller for the Allwinner A31
 
 Required properties:
-- compatible	: Should be "allwinner,sun6i-a31-rtc"
+- compatible	: Should be one of the following combinations:
+		    - "allwinner,sun6i-a31-rtc"
+		    - "allwinner,sun8i-a23-rtc"
+		    - "allwinner,sun8i-h3-rtc"
+		    - "allwinner,sun8i-r40-rtc", "allwinner,sun8i-h3-rtc"
+		    - "allwinner,sun8i-v3-rtc"
+		    - "allwinner,sun50i-a64-rtc", "allwinner,sun8i-h3-rtc"
+		    - "allwinner,sun50i-h5-rtc"
+
+		  Where there are two or more compatible strings, this
+		  denotes the hardware covered by the most specific one
+		  is backward-compatible with the latter ones, and the
+		  implementation for the latter ones can be used, albeit
+		  with reduced functionality.
+
 - reg		: physical base address of the controller and length of
 		  memory mapped region.
 - interrupts	: IRQ lines for the RTC alarm 0 and alarm 1, in that order.
-- 
2.20.0.rc1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH v2 03/14] dt-bindings: rtc: sun6i-rtc: Deprecate external clock output for A31
  2018-12-03 14:58 [PATCH v2 00/14] rtc: sun6i: clock rework and pre-H6 SoC support Chen-Yu Tsai
  2018-12-03 14:58 ` [PATCH v2 01/14] dt-bindings: rtc: sun6i-rtc: Rewrite clock outputs as a list Chen-Yu Tsai
  2018-12-03 14:58 ` [PATCH v2 02/14] dt-bindings: rtc: sun6i-rtc: Add compatible strings for pre-H6 variants Chen-Yu Tsai
@ 2018-12-03 14:58 ` Chen-Yu Tsai
  2018-12-03 14:58 ` [PATCH v2 04/14] dt-bindings: rtc: sun6i-rtc: Export internal RC oscillator Chen-Yu Tsai
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Chen-Yu Tsai @ 2018-12-03 14:58 UTC (permalink / raw)
  To: Maxime Ripard, Alexandre Belloni, Alessandro Zummo,
	Michael Turquette, Stephen Boyd, Rob Herring, Mark Rutland
  Cc: Chen-Yu Tsai, linux-arm-kernel, linux-rtc, linux-clk, devicetree,
	linux-kernel, linux-sunxi, Corentin Labbe

The A31 does not have an external clock output directly from the RTC.
Instead, it has four muxable clock outputs: three (A, B, C) are
controlled from the CCU, and the last (D) is controlled from the PRCM.

Deprecate the usage of the external clock output for the A31 compatible.

Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 Documentation/devicetree/bindings/rtc/sun6i-rtc.txt | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/rtc/sun6i-rtc.txt b/Documentation/devicetree/bindings/rtc/sun6i-rtc.txt
index 037ec475f412..c7aed31210bc 100644
--- a/Documentation/devicetree/bindings/rtc/sun6i-rtc.txt
+++ b/Documentation/devicetree/bindings/rtc/sun6i-rtc.txt
@@ -24,12 +24,14 @@ Required properties:
 
 Required properties for new device trees
 - clocks	: phandle to the 32kHz external oscillator
-- clock-output-names : names of the two clock outputs. See below.
+- clock-output-names : names of up to two clock outputs. See below.
 - #clock-cells  : must be equal to 1.
 
 The RTC provides the following clocks at the given indices:
 - 0: LOSC
 - 1: LOSC external output, known as X32KFOUT in the datasheet.
+     This clock is not available on the A31 and is deprecated for old
+     device trees still using the "allwinner,sun6i-a31-rtc" compatible.
 
 Example:
 
@@ -37,7 +39,7 @@ rtc: rtc@1f00000 {
 	compatible = "allwinner,sun6i-a31-rtc";
 	reg = <0x01f00000 0x400>;
 	interrupts = <0 40 4>, <0 41 4>;
-	clock-output-names = "osc32k", "osc32k-out";
+	clock-output-names = "osc32k";
 	clocks = <&ext_osc32k>;
 	#clock-cells = <1>;
 };
-- 
2.20.0.rc1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH v2 04/14] dt-bindings: rtc: sun6i-rtc: Export internal RC oscillator
  2018-12-03 14:58 [PATCH v2 00/14] rtc: sun6i: clock rework and pre-H6 SoC support Chen-Yu Tsai
                   ` (2 preceding siblings ...)
  2018-12-03 14:58 ` [PATCH v2 03/14] dt-bindings: rtc: sun6i-rtc: Deprecate external clock output for A31 Chen-Yu Tsai
@ 2018-12-03 14:58 ` Chen-Yu Tsai
  2018-12-04  9:17   ` Maxime Ripard
  2018-12-03 14:58 ` [PATCH v2 05/14] rtc: sun6i: Add default clock name for LOSC Chen-Yu Tsai
                   ` (10 subsequent siblings)
  14 siblings, 1 reply; 20+ messages in thread
From: Chen-Yu Tsai @ 2018-12-03 14:58 UTC (permalink / raw)
  To: Maxime Ripard, Alexandre Belloni, Alessandro Zummo,
	Michael Turquette, Stephen Boyd, Rob Herring, Mark Rutland
  Cc: Chen-Yu Tsai, linux-arm-kernel, linux-rtc, linux-clk, devicetree,
	linux-kernel, linux-sunxi, Corentin Labbe

Experiments showed that on at least the H3/H5/A64 the RTC's internal
oscillator also feeds the CPUS mux in the PRCM.

Export this clock through the device tree, instead of having to use
a dummy fixed-clock device node, for the PRCM to consume. This will
properly describe the relationship between the clocks.

Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 Documentation/devicetree/bindings/rtc/sun6i-rtc.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/rtc/sun6i-rtc.txt b/Documentation/devicetree/bindings/rtc/sun6i-rtc.txt
index c7aed31210bc..6b732c41392b 100644
--- a/Documentation/devicetree/bindings/rtc/sun6i-rtc.txt
+++ b/Documentation/devicetree/bindings/rtc/sun6i-rtc.txt
@@ -24,7 +24,7 @@ Required properties:
 
 Required properties for new device trees
 - clocks	: phandle to the 32kHz external oscillator
-- clock-output-names : names of up to two clock outputs. See below.
+- clock-output-names : names of up to three clock outputs. See below.
 - #clock-cells  : must be equal to 1.
 
 The RTC provides the following clocks at the given indices:
@@ -32,6 +32,7 @@ The RTC provides the following clocks at the given indices:
 - 1: LOSC external output, known as X32KFOUT in the datasheet.
      This clock is not available on the A31 and is deprecated for old
      device trees still using the "allwinner,sun6i-a31-rtc" compatible.
+- 2: InternalOSC, or internal RC oscillator (A64/H3/H5 only)
 
 Example:
 
-- 
2.20.0.rc1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH v2 05/14] rtc: sun6i: Add default clock name for LOSC
  2018-12-03 14:58 [PATCH v2 00/14] rtc: sun6i: clock rework and pre-H6 SoC support Chen-Yu Tsai
                   ` (3 preceding siblings ...)
  2018-12-03 14:58 ` [PATCH v2 04/14] dt-bindings: rtc: sun6i-rtc: Export internal RC oscillator Chen-Yu Tsai
@ 2018-12-03 14:58 ` Chen-Yu Tsai
  2018-12-03 14:58 ` [PATCH v2 06/14] rtc: sun6i: Add support for different variants Chen-Yu Tsai
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Chen-Yu Tsai @ 2018-12-03 14:58 UTC (permalink / raw)
  To: Maxime Ripard, Alexandre Belloni, Alessandro Zummo,
	Michael Turquette, Stephen Boyd, Rob Herring, Mark Rutland
  Cc: Chen-Yu Tsai, linux-arm-kernel, linux-rtc, linux-clk, devicetree,
	linux-kernel, linux-sunxi, Corentin Labbe

The RTC's main clock, used internally and exported to the rest of the
SoC, is called "LOSC" (low speed oscillator) through the hardware
documentation.

This patch adds a default name for this clock, in case the device tree
does not provide one. This shouldn't happen, but lets play it safe.

Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 drivers/rtc/rtc-sun6i.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c
index fe07310952df..8edd9e1ec007 100644
--- a/drivers/rtc/rtc-sun6i.c
+++ b/drivers/rtc/rtc-sun6i.c
@@ -191,6 +191,7 @@ static void __init sun6i_rtc_clk_init(struct device_node *node)
 	struct sun6i_rtc_dev *rtc;
 	struct clk_init_data init = {
 		.ops		= &sun6i_rtc_osc_ops,
+		.name		= "losc",
 	};
 	const char *clkout_name = "osc32k-out";
 	const char *parents[2];
-- 
2.20.0.rc1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH v2 06/14] rtc: sun6i: Add support for different variants
  2018-12-03 14:58 [PATCH v2 00/14] rtc: sun6i: clock rework and pre-H6 SoC support Chen-Yu Tsai
                   ` (4 preceding siblings ...)
  2018-12-03 14:58 ` [PATCH v2 05/14] rtc: sun6i: Add default clock name for LOSC Chen-Yu Tsai
@ 2018-12-03 14:58 ` Chen-Yu Tsai
  2018-12-03 14:58 ` [PATCH v2 07/14] rtc: sun6i: Add support for all known pre-H6 variants Chen-Yu Tsai
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Chen-Yu Tsai @ 2018-12-03 14:58 UTC (permalink / raw)
  To: Maxime Ripard, Alexandre Belloni, Alessandro Zummo,
	Michael Turquette, Stephen Boyd, Rob Herring, Mark Rutland
  Cc: Chen-Yu Tsai, linux-arm-kernel, linux-rtc, linux-clk, devicetree,
	linux-kernel, linux-sunxi, Corentin Labbe

Amongst the Allwinner SoCs that have seen some kind of coverage by the
linux-sunxi community, whether it be mainline Linux or U-boot support,
or just available datasheets, most newer chips use the RTC design first
seen in the A31 (sun6i).

Overall there have been some minor differences. This patch covers the
following:

  - average clock rate of the internal RC oscillator
    + presence of fixed and adjustable prescaler for this clock
  - availability of an external (to the SoC) clock output

One major difference regarding the H6 is the 24 MHz crystal is now
routed through the RTC, as a digitally compensated oscillator (DCXO).
This is not covered in this patch and will be supported later.

Other differences are either unrelated to RTC or clock functionality,
such as boot or crypto related registers, or the driver simply doesn't
use the feature in question. One example of the latter is the
calibration function for the RC oscillator. We consider this clock to
be very bad and avoid using it.

Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 drivers/rtc/rtc-sun6i.c | 58 ++++++++++++++++++++++++++++++++++++-----
 1 file changed, 51 insertions(+), 7 deletions(-)

diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c
index 8edd9e1ec007..d1866d90b9ef 100644
--- a/drivers/rtc/rtc-sun6i.c
+++ b/drivers/rtc/rtc-sun6i.c
@@ -118,9 +118,30 @@
 #define SUN6I_YEAR_MAX				2033
 #define SUN6I_YEAR_OFF				(SUN6I_YEAR_MIN - 1900)
 
+/*
+ * There are other differences between models, including:
+ *
+ *   - number of GPIO pins that can be configured to hold a certain level
+ *   - crypto-key related registers (H5, H6)
+ *   - boot process related (super standby, secondary processor entry address)
+ *     registers (R40, H6)
+ *   - SYS power domain controls (R40)
+ *   - DCXO controls (H6)
+ *   - RC oscillator calibration (H6)
+ *
+ * These functions are not covered by this driver.
+ */
+struct sun6i_rtc_clk_data {
+	unsigned long rc_osc_rate;
+	unsigned int fixed_prescaler : 16;
+	unsigned int has_prescaler : 1;
+	unsigned int has_out_clk : 1;
+};
+
 struct sun6i_rtc_dev {
 	struct rtc_device *rtc;
 	struct device *dev;
+	const struct sun6i_rtc_clk_data *data;
 	void __iomem *base;
 	int irq;
 	unsigned long alarm;
@@ -139,14 +160,19 @@ static unsigned long sun6i_rtc_osc_recalc_rate(struct clk_hw *hw,
 					       unsigned long parent_rate)
 {
 	struct sun6i_rtc_dev *rtc = container_of(hw, struct sun6i_rtc_dev, hw);
-	u32 val;
+	u32 val = 0;
 
 	val = readl(rtc->base + SUN6I_LOSC_CTRL);
 	if (val & SUN6I_LOSC_CTRL_EXT_OSC)
 		return parent_rate;
 
-	val = readl(rtc->base + SUN6I_LOSC_CLK_PRESCAL);
-	val &= GENMASK(4, 0);
+	if (rtc->data->fixed_prescaler)
+		parent_rate /= rtc->data->fixed_prescaler;
+
+	if (rtc->data->has_prescaler) {
+		val = readl(rtc->base + SUN6I_LOSC_CLK_PRESCAL);
+		val &= GENMASK(4, 0);
+	}
 
 	return parent_rate / (val + 1);
 }
@@ -185,7 +211,8 @@ static const struct clk_ops sun6i_rtc_osc_ops = {
 	.set_parent	= sun6i_rtc_osc_set_parent,
 };
 
-static void __init sun6i_rtc_clk_init(struct device_node *node)
+static void __init sun6i_rtc_clk_init(struct device_node *node,
+				      const struct sun6i_rtc_clk_data *data)
 {
 	struct clk_hw_onecell_data *clk_data;
 	struct sun6i_rtc_dev *rtc;
@@ -200,6 +227,7 @@ static void __init sun6i_rtc_clk_init(struct device_node *node)
 	if (!rtc)
 		return;
 
+	rtc->data = data;
 	clk_data = kzalloc(struct_size(clk_data, hws, 2), GFP_KERNEL);
 	if (!clk_data) {
 		kfree(rtc);
@@ -228,7 +256,7 @@ static void __init sun6i_rtc_clk_init(struct device_node *node)
 	rtc->int_osc = clk_hw_register_fixed_rate_with_accuracy(NULL,
 								"rtc-int-osc",
 								NULL, 0,
-								667000,
+								rtc->data->rc_osc_rate,
 								300000000);
 	if (IS_ERR(rtc->int_osc)) {
 		pr_crit("Couldn't register the internal oscillator\n");
@@ -271,8 +299,18 @@ static void __init sun6i_rtc_clk_init(struct device_node *node)
 err:
 	kfree(clk_data);
 }
-CLK_OF_DECLARE_DRIVER(sun6i_rtc_clk, "allwinner,sun6i-a31-rtc",
-		      sun6i_rtc_clk_init);
+
+static const struct sun6i_rtc_clk_data sun6i_a31_rtc_data = {
+	.rc_osc_rate = 667000, /* datasheet says 600 ~ 700 KHz */
+	.has_prescaler = 1,
+};
+
+static void __init sun6i_a31_rtc_clk_init(struct device_node *node)
+{
+	sun6i_rtc_clk_init(node, &sun6i_a31_rtc_data);
+}
+CLK_OF_DECLARE_DRIVER(sun6i_a31_rtc_clk, "allwinner,sun6i-a31-rtc",
+		      sun6i_a31_rtc_clk_init);
 
 static irqreturn_t sun6i_rtc_alarmirq(int irq, void *id)
 {
@@ -579,6 +617,12 @@ static int sun6i_rtc_probe(struct platform_device *pdev)
 	return 0;
 }
 
+/*
+ * As far as RTC functionality goes, all models are the same. The
+ * datasheets claim that different models have different number of
+ * registers available for non-volatile storage, but experiments show
+ * that all SoCs have 16 registers available for this purpose.
+ */
 static const struct of_device_id sun6i_rtc_dt_ids[] = {
 	{ .compatible = "allwinner,sun6i-a31-rtc" },
 	{ /* sentinel */ },
-- 
2.20.0.rc1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH v2 07/14] rtc: sun6i: Add support for all known pre-H6 variants
  2018-12-03 14:58 [PATCH v2 00/14] rtc: sun6i: clock rework and pre-H6 SoC support Chen-Yu Tsai
                   ` (5 preceding siblings ...)
  2018-12-03 14:58 ` [PATCH v2 06/14] rtc: sun6i: Add support for different variants Chen-Yu Tsai
@ 2018-12-03 14:58 ` Chen-Yu Tsai
  2018-12-03 14:58 ` [PATCH v2 08/14] rtc: sun6i: Expose internal oscillator through device tree Chen-Yu Tsai
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Chen-Yu Tsai @ 2018-12-03 14:58 UTC (permalink / raw)
  To: Maxime Ripard, Alexandre Belloni, Alessandro Zummo,
	Michael Turquette, Stephen Boyd, Rob Herring, Mark Rutland
  Cc: Chen-Yu Tsai, linux-arm-kernel, linux-rtc, linux-clk, devicetree,
	linux-kernel, linux-sunxi, Corentin Labbe

There are different variants to the RTC hardware first seen on sun6i
(A31). The differences we care about in this driver are the clock rate
for the internal oscillator, prescalers, and the presence of an external
clock output.

This patch adds support for all the known pre-H6 base compatibles using
the variants data structure previously introduced.

Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 drivers/rtc/rtc-sun6i.c | 46 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c
index d1866d90b9ef..46609ae56ffd 100644
--- a/drivers/rtc/rtc-sun6i.c
+++ b/drivers/rtc/rtc-sun6i.c
@@ -312,6 +312,48 @@ static void __init sun6i_a31_rtc_clk_init(struct device_node *node)
 CLK_OF_DECLARE_DRIVER(sun6i_a31_rtc_clk, "allwinner,sun6i-a31-rtc",
 		      sun6i_a31_rtc_clk_init);
 
+static const struct sun6i_rtc_clk_data sun8i_a23_rtc_data = {
+	.rc_osc_rate = 667000, /* datasheet says 600 ~ 700 KHz */
+	.has_prescaler = 1,
+	.has_out_clk = 1,
+};
+
+static void __init sun8i_a23_rtc_clk_init(struct device_node *node)
+{
+	sun6i_rtc_clk_init(node, &sun8i_a23_rtc_data);
+}
+CLK_OF_DECLARE_DRIVER(sun8i_a23_rtc_clk, "allwinner,sun8i-a23-rtc",
+		      sun8i_a23_rtc_clk_init);
+
+static const struct sun6i_rtc_clk_data sun8i_h3_rtc_data = {
+	.rc_osc_rate = 16000000,
+	.fixed_prescaler = 32,
+	.has_prescaler = 1,
+	.has_out_clk = 1,
+};
+
+static void __init sun8i_h3_rtc_clk_init(struct device_node *node)
+{
+	sun6i_rtc_clk_init(node, &sun8i_h3_rtc_data);
+}
+CLK_OF_DECLARE_DRIVER(sun8i_h3_rtc_clk, "allwinner,sun8i-h3-rtc",
+		      sun8i_h3_rtc_clk_init);
+/* As far as we are concerned, clocks for H5 are the same as H3 */
+CLK_OF_DECLARE_DRIVER(sun50i_h5_rtc_clk, "allwinner,sun50i-h5-rtc",
+		      sun8i_h3_rtc_clk_init);
+
+static const struct sun6i_rtc_clk_data sun8i_v3_rtc_data = {
+	.rc_osc_rate = 32000,
+	.has_out_clk = 1,
+};
+
+static void __init sun8i_v3_rtc_clk_init(struct device_node *node)
+{
+	sun6i_rtc_clk_init(node, &sun8i_v3_rtc_data);
+}
+CLK_OF_DECLARE_DRIVER(sun8i_v3_rtc_clk, "allwinner,sun8i-v3-rtc",
+		      sun8i_v3_rtc_clk_init);
+
 static irqreturn_t sun6i_rtc_alarmirq(int irq, void *id)
 {
 	struct sun6i_rtc_dev *chip = (struct sun6i_rtc_dev *) id;
@@ -625,6 +667,10 @@ static int sun6i_rtc_probe(struct platform_device *pdev)
  */
 static const struct of_device_id sun6i_rtc_dt_ids[] = {
 	{ .compatible = "allwinner,sun6i-a31-rtc" },
+	{ .compatible = "allwinner,sun8i-a23-rtc" },
+	{ .compatible = "allwinner,sun8i-h3-rtc" },
+	{ .compatible = "allwinner,sun8i-v3-rtc" },
+	{ .compatible = "allwinner,sun50i-h5-rtc" },
 	{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, sun6i_rtc_dt_ids);
-- 
2.20.0.rc1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH v2 08/14] rtc: sun6i: Expose internal oscillator through device tree
  2018-12-03 14:58 [PATCH v2 00/14] rtc: sun6i: clock rework and pre-H6 SoC support Chen-Yu Tsai
                   ` (6 preceding siblings ...)
  2018-12-03 14:58 ` [PATCH v2 07/14] rtc: sun6i: Add support for all known pre-H6 variants Chen-Yu Tsai
@ 2018-12-03 14:58 ` Chen-Yu Tsai
  2018-12-04  9:17   ` Maxime Ripard
  2018-12-03 14:58 ` [PATCH v2 09/14] ARM: dts: sun8i: a23/a33: Fix up RTC device node Chen-Yu Tsai
                   ` (6 subsequent siblings)
  14 siblings, 1 reply; 20+ messages in thread
From: Chen-Yu Tsai @ 2018-12-03 14:58 UTC (permalink / raw)
  To: Maxime Ripard, Alexandre Belloni, Alessandro Zummo,
	Michael Turquette, Stephen Boyd, Rob Herring, Mark Rutland
  Cc: Chen-Yu Tsai, linux-arm-kernel, linux-rtc, linux-clk, devicetree,
	linux-kernel, linux-sunxi, Corentin Labbe

The bindings have been updated to expose the RTC's internal oscillator,
for some SoCs that have it directly feeding the PRCM block. The changes
include the index 2 for the clock outputs, as well as the clock output
names.

This patch adds the internal oscillator to the list of clocks exposed
through of_clk_add_hw_provider(), and also have the driver optionally
fetch the name of the clock from the device tree if it's available.

Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 drivers/rtc/rtc-sun6i.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c
index 46609ae56ffd..11f56de52179 100644
--- a/drivers/rtc/rtc-sun6i.c
+++ b/drivers/rtc/rtc-sun6i.c
@@ -136,6 +136,7 @@ struct sun6i_rtc_clk_data {
 	unsigned int fixed_prescaler : 16;
 	unsigned int has_prescaler : 1;
 	unsigned int has_out_clk : 1;
+	unsigned int export_iosc : 1;
 };
 
 struct sun6i_rtc_dev {
@@ -220,6 +221,7 @@ static void __init sun6i_rtc_clk_init(struct device_node *node,
 		.ops		= &sun6i_rtc_osc_ops,
 		.name		= "losc",
 	};
+	const char *iosc_name = "rtc-int-osc";
 	const char *clkout_name = "osc32k-out";
 	const char *parents[2];
 
@@ -228,7 +230,7 @@ static void __init sun6i_rtc_clk_init(struct device_node *node,
 		return;
 
 	rtc->data = data;
-	clk_data = kzalloc(struct_size(clk_data, hws, 2), GFP_KERNEL);
+	clk_data = kzalloc(struct_size(clk_data, hws, 3), GFP_KERNEL);
 	if (!clk_data) {
 		kfree(rtc);
 		return;
@@ -253,8 +255,13 @@ static void __init sun6i_rtc_clk_init(struct device_node *node,
 	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,
+					      &iosc_name);
+
 	rtc->int_osc = clk_hw_register_fixed_rate_with_accuracy(NULL,
-								"rtc-int-osc",
+								iosc_name,
 								NULL, 0,
 								rtc->data->rc_osc_rate,
 								300000000);
@@ -293,6 +300,10 @@ static void __init sun6i_rtc_clk_init(struct device_node *node,
 	clk_data->num = 2;
 	clk_data->hws[0] = &rtc->hw;
 	clk_data->hws[1] = __clk_get_hw(rtc->ext_losc);
+	if (rtc->data->export_iosc) {
+		clk_data->hws[2] = rtc->int_osc;
+		clk_data->num = 3;
+	}
 	of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
 	return;
 
@@ -330,6 +341,7 @@ static const struct sun6i_rtc_clk_data sun8i_h3_rtc_data = {
 	.fixed_prescaler = 32,
 	.has_prescaler = 1,
 	.has_out_clk = 1,
+	.export_iosc = 1,
 };
 
 static void __init sun8i_h3_rtc_clk_init(struct device_node *node)
-- 
2.20.0.rc1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH v2 09/14] ARM: dts: sun8i: a23/a33: Fix up RTC device node
  2018-12-03 14:58 [PATCH v2 00/14] rtc: sun6i: clock rework and pre-H6 SoC support Chen-Yu Tsai
                   ` (7 preceding siblings ...)
  2018-12-03 14:58 ` [PATCH v2 08/14] rtc: sun6i: Expose internal oscillator through device tree Chen-Yu Tsai
@ 2018-12-03 14:58 ` Chen-Yu Tsai
  2018-12-03 14:58 ` [PATCH v2 10/14] ARM: dts: sunxi: h3/h5: Add clock accuracy for external oscillators Chen-Yu Tsai
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Chen-Yu Tsai @ 2018-12-03 14:58 UTC (permalink / raw)
  To: Maxime Ripard, Alexandre Belloni, Alessandro Zummo,
	Michael Turquette, Stephen Boyd, Rob Herring, Mark Rutland
  Cc: Chen-Yu Tsai, linux-arm-kernel, linux-rtc, linux-clk, devicetree,
	linux-kernel, linux-sunxi

The RTC module on the A23 was claimed to be the same as on the A31, when
in fact it is not. The A31 does not have an RTC external clock output,
and its internal RC oscillator's average clock rate is not in the same
range. The A33's RTC is the same as the A23.

This patch fixes the compatible string and clock properties to conform
to the updated bindings. The register range is also fixed.

Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 arch/arm/boot/dts/sun8i-a23-a33.dtsi | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/sun8i-a23-a33.dtsi b/arch/arm/boot/dts/sun8i-a23-a33.dtsi
index c2ff8975ac60..a9c123de5d2c 100644
--- a/arch/arm/boot/dts/sun8i-a23-a33.dtsi
+++ b/arch/arm/boot/dts/sun8i-a23-a33.dtsi
@@ -573,11 +573,11 @@
 		};
 
 		rtc: rtc@1f00000 {
-			compatible = "allwinner,sun6i-a31-rtc";
-			reg = <0x01f00000 0x54>;
+			compatible = "allwinner,sun8i-a23-rtc";
+			reg = <0x01f00000 0x400>;
 			interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>,
 				     <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>;
-			clock-output-names = "osc32k";
+			clock-output-names = "osc32k", "osc32k-out";
 			clocks = <&ext_osc32k>;
 			#clock-cells = <1>;
 		};
-- 
2.20.0.rc1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH v2 10/14] ARM: dts: sunxi: h3/h5: Add clock accuracy for external oscillators
  2018-12-03 14:58 [PATCH v2 00/14] rtc: sun6i: clock rework and pre-H6 SoC support Chen-Yu Tsai
                   ` (8 preceding siblings ...)
  2018-12-03 14:58 ` [PATCH v2 09/14] ARM: dts: sun8i: a23/a33: Fix up RTC device node Chen-Yu Tsai
@ 2018-12-03 14:58 ` Chen-Yu Tsai
  2018-12-03 14:58 ` [PATCH v2 11/14] ARM: dts: sunxi: h3/h5: Fix up RTC device node and clock references Chen-Yu Tsai
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Chen-Yu Tsai @ 2018-12-03 14:58 UTC (permalink / raw)
  To: Maxime Ripard, Alexandre Belloni, Alessandro Zummo,
	Michael Turquette, Stephen Boyd, Rob Herring, Mark Rutland
  Cc: Chen-Yu Tsai, linux-arm-kernel, linux-rtc, linux-clk, devicetree,
	linux-kernel, linux-sunxi, Corentin Labbe

The H3 datasheet specifies a tolerance range for the external
oscillators used. Add them to the device tree as the clock accuracy.
The internal oscillator is left unchanged, as it will be removed later.

Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 arch/arm/boot/dts/sunxi-h3-h5.dtsi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/boot/dts/sunxi-h3-h5.dtsi b/arch/arm/boot/dts/sunxi-h3-h5.dtsi
index 0d9e9eac518c..bce3bf1d6ae5 100644
--- a/arch/arm/boot/dts/sunxi-h3-h5.dtsi
+++ b/arch/arm/boot/dts/sunxi-h3-h5.dtsi
@@ -86,6 +86,7 @@
 			#clock-cells = <0>;
 			compatible = "fixed-clock";
 			clock-frequency = <24000000>;
+			clock-accuracy = <50000>;
 			clock-output-names = "osc24M";
 		};
 
@@ -93,6 +94,7 @@
 			#clock-cells = <0>;
 			compatible = "fixed-clock";
 			clock-frequency = <32768>;
+			clock-accuracy = <50000>;
 			clock-output-names = "osc32k";
 		};
 
-- 
2.20.0.rc1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH v2 11/14] ARM: dts: sunxi: h3/h5: Fix up RTC device node and clock references
  2018-12-03 14:58 [PATCH v2 00/14] rtc: sun6i: clock rework and pre-H6 SoC support Chen-Yu Tsai
                   ` (9 preceding siblings ...)
  2018-12-03 14:58 ` [PATCH v2 10/14] ARM: dts: sunxi: h3/h5: Add clock accuracy for external oscillators Chen-Yu Tsai
@ 2018-12-03 14:58 ` Chen-Yu Tsai
  2018-12-03 14:58 ` [PATCH v2 12/14] ARM: dts: sun8i: r40: Add clock accuracy for external oscillators Chen-Yu Tsai
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Chen-Yu Tsai @ 2018-12-03 14:58 UTC (permalink / raw)
  To: Maxime Ripard, Alexandre Belloni, Alessandro Zummo,
	Michael Turquette, Stephen Boyd, Rob Herring, Mark Rutland
  Cc: Chen-Yu Tsai, linux-arm-kernel, linux-rtc, linux-clk, devicetree,
	linux-kernel, linux-sunxi, Corentin Labbe

The RTC module on the H3 was claimed to be the same as on the A31, when
in fact it is not. The A31 does not have an RTC external clock output,
and its internal RC oscillator's average clock rate is not in the same
range. The H5's RTC has some extra crypto-related registers compared to
the H3. Their exact functions are not clear. Also the RTC-VIO regulator
has different settings.

This patch fixes the compatible string and clock properties to conform
to the updated bindings. The device node for the internal oscillator is
removed, as it is internalized into the RTC device. Clock references to
the IOSC and LOSC are also fixed.

Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 arch/arm/boot/dts/sun8i-h3.dtsi              |  4 +++
 arch/arm/boot/dts/sunxi-h3-h5.dtsi           | 26 ++++++++------------
 arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi |  4 +++
 3 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/arch/arm/boot/dts/sun8i-h3.dtsi b/arch/arm/boot/dts/sun8i-h3.dtsi
index c2da3a3d373a..743c1dbaf147 100644
--- a/arch/arm/boot/dts/sun8i-h3.dtsi
+++ b/arch/arm/boot/dts/sun8i-h3.dtsi
@@ -241,3 +241,7 @@
 &pio {
 	compatible = "allwinner,sun8i-h3-pinctrl";
 };
+
+&rtc {
+	compatible = "allwinner,sun8i-h3-rtc";
+};
diff --git a/arch/arm/boot/dts/sunxi-h3-h5.dtsi b/arch/arm/boot/dts/sunxi-h3-h5.dtsi
index bce3bf1d6ae5..3cc4366c07fd 100644
--- a/arch/arm/boot/dts/sunxi-h3-h5.dtsi
+++ b/arch/arm/boot/dts/sunxi-h3-h5.dtsi
@@ -95,15 +95,7 @@
 			compatible = "fixed-clock";
 			clock-frequency = <32768>;
 			clock-accuracy = <50000>;
-			clock-output-names = "osc32k";
-		};
-
-		iosc: internal-osc-clk {
-			#clock-cells = <0>;
-			compatible = "fixed-clock";
-			clock-frequency = <16000000>;
-			clock-accuracy = <300000000>;
-			clock-output-names = "iosc";
+			clock-output-names = "ext_osc32k";
 		};
 	};
 
@@ -377,7 +369,7 @@
 		ccu: clock@1c20000 {
 			/* compatible is in per SoC .dtsi file */
 			reg = <0x01c20000 0x400>;
-			clocks = <&osc24M>, <&osc32k>;
+			clocks = <&osc24M>, <&rtc 0>;
 			clock-names = "hosc", "losc";
 			#clock-cells = <1>;
 			#reset-cells = <1>;
@@ -388,7 +380,7 @@
 			reg = <0x01c20800 0x400>;
 			interrupts = <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>,
 				     <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&ccu CLK_BUS_PIO>, <&osc24M>, <&osc32k>;
+			clocks = <&ccu CLK_BUS_PIO>, <&osc24M>, <&rtc 0>;
 			clock-names = "apb", "hosc", "losc";
 			gpio-controller;
 			#gpio-cells = <3>;
@@ -813,17 +805,19 @@
 		};
 
 		rtc: rtc@1f00000 {
-			compatible = "allwinner,sun6i-a31-rtc";
-			reg = <0x01f00000 0x54>;
+			/* compatible is in per SoC .dtsi file */
+			reg = <0x01f00000 0x400>;
 			interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>,
 				     <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>;
+			clock-output-names = "osc32k", "osc32k-out", "iosc";
+			clocks = <&osc32k>;
+			#clock-cells = <1>;
 		};
 
 		r_ccu: clock@1f01400 {
 			compatible = "allwinner,sun8i-h3-r-ccu";
 			reg = <0x01f01400 0x100>;
-			clocks = <&osc24M>, <&osc32k>, <&iosc>,
-				 <&ccu 9>;
+			clocks = <&osc24M>, <&rtc 0>, <&rtc 2>, <&ccu 9>;
 			clock-names = "hosc", "losc", "iosc", "pll-periph";
 			#clock-cells = <1>;
 			#reset-cells = <1>;
@@ -861,7 +855,7 @@
 			compatible = "allwinner,sun8i-h3-r-pinctrl";
 			reg = <0x01f02c00 0x400>;
 			interrupts = <GIC_SPI 45 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&r_ccu CLK_APB0_PIO>, <&osc24M>, <&osc32k>;
+			clocks = <&r_ccu CLK_APB0_PIO>, <&osc24M>, <&rtc 0>;
 			clock-names = "apb", "hosc", "losc";
 			gpio-controller;
 			#gpio-cells = <3>;
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi
index b41dc1aab67d..fe731b35f761 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi
+++ b/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi
@@ -172,3 +172,7 @@
 		     <GIC_SPI 23 IRQ_TYPE_LEVEL_HIGH>;
 	compatible = "allwinner,sun50i-h5-pinctrl";
 };
+
+&rtc {
+	compatible = "allwinner,sun50i-h5-rtc";
+};
-- 
2.20.0.rc1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH v2 12/14] ARM: dts: sun8i: r40: Add clock accuracy for external oscillators
  2018-12-03 14:58 [PATCH v2 00/14] rtc: sun6i: clock rework and pre-H6 SoC support Chen-Yu Tsai
                   ` (10 preceding siblings ...)
  2018-12-03 14:58 ` [PATCH v2 11/14] ARM: dts: sunxi: h3/h5: Fix up RTC device node and clock references Chen-Yu Tsai
@ 2018-12-03 14:58 ` Chen-Yu Tsai
  2018-12-03 14:58 ` [PATCH v2 13/14] ARM: dts: sun8i: r40: Add RTC device node Chen-Yu Tsai
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Chen-Yu Tsai @ 2018-12-03 14:58 UTC (permalink / raw)
  To: Maxime Ripard, Alexandre Belloni, Alessandro Zummo,
	Michael Turquette, Stephen Boyd, Rob Herring, Mark Rutland
  Cc: Chen-Yu Tsai, linux-arm-kernel, linux-rtc, linux-clk, devicetree,
	linux-kernel, linux-sunxi, Corentin Labbe

The R40 datasheet specifies a tolerance range for the external
oscillators used. Add them to the device tree as the clock accuracy.

Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 arch/arm/boot/dts/sun8i-r40.dtsi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-r40.dtsi b/arch/arm/boot/dts/sun8i-r40.dtsi
index 6f4c9ca5a3ee..a8917f8b1c80 100644
--- a/arch/arm/boot/dts/sun8i-r40.dtsi
+++ b/arch/arm/boot/dts/sun8i-r40.dtsi
@@ -61,6 +61,7 @@
 			#clock-cells = <0>;
 			compatible = "fixed-clock";
 			clock-frequency = <24000000>;
+			clock-accuracy = <50000>;
 			clock-output-names = "osc24M";
 		};
 
@@ -68,6 +69,7 @@
 			#clock-cells = <0>;
 			compatible = "fixed-clock";
 			clock-frequency = <32768>;
+			clock-accuracy = <20000>;
 			clock-output-names = "osc32k";
 		};
 	};
-- 
2.20.0.rc1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH v2 13/14] ARM: dts: sun8i: r40: Add RTC device node
  2018-12-03 14:58 [PATCH v2 00/14] rtc: sun6i: clock rework and pre-H6 SoC support Chen-Yu Tsai
                   ` (11 preceding siblings ...)
  2018-12-03 14:58 ` [PATCH v2 12/14] ARM: dts: sun8i: r40: Add clock accuracy for external oscillators Chen-Yu Tsai
@ 2018-12-03 14:58 ` Chen-Yu Tsai
  2018-12-03 14:58 ` [PATCH v2 14/14] arm64: dts: allwinner: a64: Fix up RTC device node and clock references Chen-Yu Tsai
  2018-12-06  5:49 ` [PATCH v2 00/14] rtc: sun6i: clock rework and pre-H6 SoC support Chen-Yu Tsai
  14 siblings, 0 replies; 20+ messages in thread
From: Chen-Yu Tsai @ 2018-12-03 14:58 UTC (permalink / raw)
  To: Maxime Ripard, Alexandre Belloni, Alessandro Zummo,
	Michael Turquette, Stephen Boyd, Rob Herring, Mark Rutland
  Cc: Chen-Yu Tsai, linux-arm-kernel, linux-rtc, linux-clk, devicetree,
	linux-kernel, linux-sunxi, Corentin Labbe

The R40 has an RTC hardware block, which has additional registers
that are not related to RTC or clock functions, and is otherwise
compatible with the H3's RTC.

Add a device node for it, and fix up any references to the LOSC.

Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 arch/arm/boot/dts/sun8i-r40.dtsi | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/sun8i-r40.dtsi b/arch/arm/boot/dts/sun8i-r40.dtsi
index a8917f8b1c80..89762dbefe42 100644
--- a/arch/arm/boot/dts/sun8i-r40.dtsi
+++ b/arch/arm/boot/dts/sun8i-r40.dtsi
@@ -70,7 +70,7 @@
 			compatible = "fixed-clock";
 			clock-frequency = <32768>;
 			clock-accuracy = <20000>;
-			clock-output-names = "osc32k";
+			clock-output-names = "ext-osc32k";
 		};
 	};
 
@@ -315,17 +315,27 @@
 		ccu: clock@1c20000 {
 			compatible = "allwinner,sun8i-r40-ccu";
 			reg = <0x01c20000 0x400>;
-			clocks = <&osc24M>, <&osc32k>;
+			clocks = <&osc24M>, <&rtc 0>;
 			clock-names = "hosc", "losc";
 			#clock-cells = <1>;
 			#reset-cells = <1>;
 		};
 
+		rtc: rtc@1c20400 {
+			compatible = "allwinner,sun8i-r40-rtc",
+				     "allwinner,sun8i-h3-rtc";
+			reg = <0x01c20400 0x400>;
+			interrupts = <GIC_SPI 24 IRQ_TYPE_LEVEL_HIGH>;
+			clock-output-names = "osc32k", "osc32k-out";
+			clocks = <&osc32k>;
+			#clock-cells = <1>;
+		};
+
 		pio: pinctrl@1c20800 {
 			compatible = "allwinner,sun8i-r40-pinctrl";
 			reg = <0x01c20800 0x400>;
 			interrupts = <GIC_SPI 28 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&ccu CLK_BUS_PIO>, <&osc24M>, <&osc32k>;
+			clocks = <&ccu CLK_BUS_PIO>, <&osc24M>, <&rtc 0>;
 			clock-names = "apb", "hosc", "losc";
 			gpio-controller;
 			interrupt-controller;
-- 
2.20.0.rc1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH v2 14/14] arm64: dts: allwinner: a64: Fix up RTC device node and clock references
  2018-12-03 14:58 [PATCH v2 00/14] rtc: sun6i: clock rework and pre-H6 SoC support Chen-Yu Tsai
                   ` (12 preceding siblings ...)
  2018-12-03 14:58 ` [PATCH v2 13/14] ARM: dts: sun8i: r40: Add RTC device node Chen-Yu Tsai
@ 2018-12-03 14:58 ` Chen-Yu Tsai
  2018-12-06  5:49 ` [PATCH v2 00/14] rtc: sun6i: clock rework and pre-H6 SoC support Chen-Yu Tsai
  14 siblings, 0 replies; 20+ messages in thread
From: Chen-Yu Tsai @ 2018-12-03 14:58 UTC (permalink / raw)
  To: Maxime Ripard, Alexandre Belloni, Alessandro Zummo,
	Michael Turquette, Stephen Boyd, Rob Herring, Mark Rutland
  Cc: Chen-Yu Tsai, linux-arm-kernel, linux-rtc, linux-clk, devicetree,
	linux-kernel, linux-sunxi

The RTC module on the A64 was claimed to be the same as on the A31, when
in fact it is not. It is actually compatible to the H3's RTC. The A64's
RTC has some extra crypto-related registers which the H3's does not, but
the exact function of these is not clear.

This patch fixes the compatible string and clock properties to conform
to the updated bindings. The device node for the internal oscillator is
removed, as it is internalized into the RTC device. Clock references to
the IOSC and LOSC are also fixed.

Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 22 ++++++-------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
index 384c417cb7a2..a729dcc63038 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
@@ -139,15 +139,7 @@
 		#clock-cells = <0>;
 		compatible = "fixed-clock";
 		clock-frequency = <32768>;
-		clock-output-names = "osc32k";
-	};
-
-	iosc: internal-osc-clk {
-		#clock-cells = <0>;
-		compatible = "fixed-clock";
-		clock-frequency = <16000000>;
-		clock-accuracy = <300000000>;
-		clock-output-names = "iosc";
+		clock-output-names = "ext-osc32k";
 	};
 
 	psci {
@@ -514,7 +506,7 @@
 		ccu: clock@1c20000 {
 			compatible = "allwinner,sun50i-a64-ccu";
 			reg = <0x01c20000 0x400>;
-			clocks = <&osc24M>, <&osc32k>;
+			clocks = <&osc24M>, <&rtc 0>;
 			clock-names = "hosc", "losc";
 			#clock-cells = <1>;
 			#reset-cells = <1>;
@@ -944,11 +936,12 @@
 		};
 
 		rtc: rtc@1f00000 {
-			compatible = "allwinner,sun6i-a31-rtc";
-			reg = <0x01f00000 0x54>;
+			compatible = "allwinner,sun50i-a64-rtc",
+				     "allwinner,sun8i-h3-rtc";
+			reg = <0x01f00000 0x400>;
 			interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>,
 				     <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>;
-			clock-output-names = "rtc-osc32k", "rtc-osc32k-out";
+			clock-output-names = "osc32k", "osc32k-out", "iosc";
 			clocks = <&osc32k>;
 			#clock-cells = <1>;
 		};
@@ -965,8 +958,7 @@
 		r_ccu: clock@1f01400 {
 			compatible = "allwinner,sun50i-a64-r-ccu";
 			reg = <0x01f01400 0x100>;
-			clocks = <&osc24M>, <&osc32k>, <&iosc>,
-				 <&ccu 11>;
+			clocks = <&osc24M>, <&rtc 0>, <&rtc 2>, <&ccu 11>;
 			clock-names = "hosc", "losc", "iosc", "pll-periph";
 			#clock-cells = <1>;
 			#reset-cells = <1>;
-- 
2.20.0.rc1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 04/14] dt-bindings: rtc: sun6i-rtc: Export internal RC oscillator
  2018-12-03 14:58 ` [PATCH v2 04/14] dt-bindings: rtc: sun6i-rtc: Export internal RC oscillator Chen-Yu Tsai
@ 2018-12-04  9:17   ` Maxime Ripard
  0 siblings, 0 replies; 20+ messages in thread
From: Maxime Ripard @ 2018-12-04  9:17 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Alexandre Belloni, Alessandro Zummo, Michael Turquette,
	Stephen Boyd, Rob Herring, Mark Rutland, linux-arm-kernel,
	linux-rtc, linux-clk, devicetree, linux-kernel, linux-sunxi,
	Corentin Labbe

[-- Attachment #1: Type: text/plain, Size: 654 bytes --]

On Mon, Dec 03, 2018 at 10:58:15PM +0800, Chen-Yu Tsai wrote:
> Experiments showed that on at least the H3/H5/A64 the RTC's internal
> oscillator also feeds the CPUS mux in the PRCM.
> 
> Export this clock through the device tree, instead of having to use
> a dummy fixed-clock device node, for the PRCM to consume. This will
> properly describe the relationship between the clocks.
> 
> Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>

Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>

Maxime

-- 
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 08/14] rtc: sun6i: Expose internal oscillator through device tree
  2018-12-03 14:58 ` [PATCH v2 08/14] rtc: sun6i: Expose internal oscillator through device tree Chen-Yu Tsai
@ 2018-12-04  9:17   ` Maxime Ripard
  0 siblings, 0 replies; 20+ messages in thread
From: Maxime Ripard @ 2018-12-04  9:17 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Alexandre Belloni, Alessandro Zummo, Michael Turquette,
	Stephen Boyd, Rob Herring, Mark Rutland, linux-arm-kernel,
	linux-rtc, linux-clk, devicetree, linux-kernel, linux-sunxi,
	Corentin Labbe

[-- Attachment #1: Type: text/plain, Size: 782 bytes --]

On Mon, Dec 03, 2018 at 10:58:19PM +0800, Chen-Yu Tsai wrote:
> The bindings have been updated to expose the RTC's internal oscillator,
> for some SoCs that have it directly feeding the PRCM block. The changes
> include the index 2 for the clock outputs, as well as the clock output
> names.
> 
> This patch adds the internal oscillator to the list of clocks exposed
> through of_clk_add_hw_provider(), and also have the driver optionally
> fetch the name of the clock from the device tree if it's available.
> 
> Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>

Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>

Maxime

-- 
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 00/14] rtc: sun6i: clock rework and pre-H6 SoC support
  2018-12-03 14:58 [PATCH v2 00/14] rtc: sun6i: clock rework and pre-H6 SoC support Chen-Yu Tsai
                   ` (13 preceding siblings ...)
  2018-12-03 14:58 ` [PATCH v2 14/14] arm64: dts: allwinner: a64: Fix up RTC device node and clock references Chen-Yu Tsai
@ 2018-12-06  5:49 ` Chen-Yu Tsai
  2018-12-06 20:34   ` Alexandre Belloni
  14 siblings, 1 reply; 20+ messages in thread
From: Chen-Yu Tsai @ 2018-12-06  5:49 UTC (permalink / raw)
  To: Maxime Ripard, alexandre.belloni, Alessandro Zummo
  Cc: linux-arm-kernel, linux-rtc, linux-clk, devicetree, linux-kernel,
	linux-sunxi, Stephen Boyd, Mike Turquette, Rob Herring,
	Mark Rutland

Hi,

On Mon, Dec 3, 2018 at 10:58 PM Chen-Yu Tsai <wens@csie.org> wrote:
>
> Hi everyone,
>
> This is v2 of my rtc-sun6i clean-up series.
>
> Changes since v1:
>
>   - Collected tags
>   - Dropped patch "clk: sunxi-ng: r40: Force LOSC parent to RTC LOSC
>     output"; already merged
>   - Removed H6 compatible CLK_OF_DECLARE_DRIVER entry that wasn't
>     overlooked
>   - Only export IOSC clock for A64/H3/H5
>
> Original cover letter, with patch numbers corrected, follows:
>
> This series was started as part of enabling Bluetooth on various
> Allwinner SBCs. The bluetooth controller requires a precise 32.768 kHz
> clock fed to it to correctly detect the frequency of its main oscillator.
> This clock signal is provided by the RTC, either directly from a special
> pin on the SoC, or some clock output function from the clock controllers.
> I found that the clock-related properties of the RTC on later SoCs were
> incorrect or missing.
>
> This series reworks the compatible strings and clock parts of the device
> tree bindings for sun6i-rtc. Currently we assume most Allwinner SoCs use
> the same sun6i-rtc variant, when in fact they do not. The differences
> that matter with regards to clocks are a) the A31 does not have an extra
> external output for the RTC 32K clock, while most of the others do;
> b) the clock frequency of the internal RC oscillator is different on
> some SoCs; c) on the H6 the RTC also handles the 24 MHz DCXO, which
> feeds the system HOSC. The last difference, and by extension the H6, are
> not covered in this series.
>
> Patch 1 cleans up the clock-related section of the RTC device tree
> binding. This would make it easier to read and easier to add additional
> clocks.
>
> Patch 2 adds compatible strings for all identified variants introduced
> prior to the H6.
>
> Patch 3 deprecates the external clock output for the A31. The A31 does
> not have this output, so it's introduction and usage was an error.
>
> Patch 4 adds a clock output for the RTC's internal oscillator to the
> device tree binding. This feeds the PRCM in some SoCs.
>
> Patch 5 adds a default clock name for the LOSC to the RTC driver.
>
> Patch 6 adds support for different hardware variants to the RTC driver.
>
> Patch 7 adds support for all known pre-H6 variants.
>
> Patch 8 exposes the RTC's internal oscillator through the device tree.
>
> Patch 9 through 14 adds an RTC node or fixes up the RTC device node
> address ranges, clock properties, names of existing clocks, and adds
> accuracy properties for the external fixed oscillators.
>
> The clock names require fixing because the sunxi clock driver implicitly
> depends on the HOSC and LOSC being named "osc24M" and "osc32k". The
> "fixes" to the clock hierarchy introduced in this series means the names
> must also be shuffled around or the in kernel representation would be
> incorrect. This has been the case since the sunxi-ng drivers were
> introduced. There are plans to address this, but the code is still in its
> early stages.
>
> Please have a look.
>
> Thanks
> ChenYu
>
> Chen-Yu Tsai (14):
>   dt-bindings: rtc: sun6i-rtc: Rewrite clock outputs as a list
>   dt-bindings: rtc: sun6i-rtc: Add compatible strings for pre-H6
>     variants
>   dt-bindings: rtc: sun6i-rtc: Deprecate external clock output for A31
>   dt-bindings: rtc: sun6i-rtc: Export internal RC oscillator
>   rtc: sun6i: Add default clock name for LOSC
>   rtc: sun6i: Add support for different variants
>   rtc: sun6i: Add support for all known pre-H6 variants
>   rtc: sun6i: Expose internal oscillator through device tree
>   ARM: dts: sun8i: a23/a33: Fix up RTC device node
>   ARM: dts: sunxi: h3/h5: Add clock accuracy for external oscillators
>   ARM: dts: sunxi: h3/h5: Fix up RTC device node and clock references
>   ARM: dts: sun8i: r40: Add clock accuracy for external oscillators
>   ARM: dts: sun8i: r40: Add RTC device node
>   arm64: dts: allwinner: a64: Fix up RTC device node and clock
>     references

I merged patches 10 and 12 for now. These don't depend on any driver changes.

If Alex manages to get the driver bits merged for 4.21, I suppose we could do
a late PR for the dts bits? It would be nice to have both in the same release,
though I don't think anything would break if the dts bits are delayed.

ChenYu

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 00/14] rtc: sun6i: clock rework and pre-H6 SoC support
  2018-12-06  5:49 ` [PATCH v2 00/14] rtc: sun6i: clock rework and pre-H6 SoC support Chen-Yu Tsai
@ 2018-12-06 20:34   ` Alexandre Belloni
  2018-12-07  2:25     ` Chen-Yu Tsai
  0 siblings, 1 reply; 20+ messages in thread
From: Alexandre Belloni @ 2018-12-06 20:34 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Maxime Ripard, Alessandro Zummo, linux-arm-kernel, linux-rtc,
	linux-clk, devicetree, linux-kernel, linux-sunxi, Stephen Boyd,
	Mike Turquette, Rob Herring, Mark Rutland

On 06/12/2018 13:49:10+0800, Chen-Yu Tsai wrote:
> Hi,
> 
> On Mon, Dec 3, 2018 at 10:58 PM Chen-Yu Tsai <wens@csie.org> wrote:
> >
> > Hi everyone,
> >
> > This is v2 of my rtc-sun6i clean-up series.
> >
> > Changes since v1:
> >
> >   - Collected tags
> >   - Dropped patch "clk: sunxi-ng: r40: Force LOSC parent to RTC LOSC
> >     output"; already merged
> >   - Removed H6 compatible CLK_OF_DECLARE_DRIVER entry that wasn't
> >     overlooked
> >   - Only export IOSC clock for A64/H3/H5
> >
> > Original cover letter, with patch numbers corrected, follows:
> >
> > This series was started as part of enabling Bluetooth on various
> > Allwinner SBCs. The bluetooth controller requires a precise 32.768 kHz
> > clock fed to it to correctly detect the frequency of its main oscillator.
> > This clock signal is provided by the RTC, either directly from a special
> > pin on the SoC, or some clock output function from the clock controllers.
> > I found that the clock-related properties of the RTC on later SoCs were
> > incorrect or missing.
> >
> > This series reworks the compatible strings and clock parts of the device
> > tree bindings for sun6i-rtc. Currently we assume most Allwinner SoCs use
> > the same sun6i-rtc variant, when in fact they do not. The differences
> > that matter with regards to clocks are a) the A31 does not have an extra
> > external output for the RTC 32K clock, while most of the others do;
> > b) the clock frequency of the internal RC oscillator is different on
> > some SoCs; c) on the H6 the RTC also handles the 24 MHz DCXO, which
> > feeds the system HOSC. The last difference, and by extension the H6, are
> > not covered in this series.
> >
> > Patch 1 cleans up the clock-related section of the RTC device tree
> > binding. This would make it easier to read and easier to add additional
> > clocks.
> >
> > Patch 2 adds compatible strings for all identified variants introduced
> > prior to the H6.
> >
> > Patch 3 deprecates the external clock output for the A31. The A31 does
> > not have this output, so it's introduction and usage was an error.
> >
> > Patch 4 adds a clock output for the RTC's internal oscillator to the
> > device tree binding. This feeds the PRCM in some SoCs.
> >
> > Patch 5 adds a default clock name for the LOSC to the RTC driver.
> >
> > Patch 6 adds support for different hardware variants to the RTC driver.
> >
> > Patch 7 adds support for all known pre-H6 variants.
> >
> > Patch 8 exposes the RTC's internal oscillator through the device tree.
> >
> > Patch 9 through 14 adds an RTC node or fixes up the RTC device node
> > address ranges, clock properties, names of existing clocks, and adds
> > accuracy properties for the external fixed oscillators.
> >
> > The clock names require fixing because the sunxi clock driver implicitly
> > depends on the HOSC and LOSC being named "osc24M" and "osc32k". The
> > "fixes" to the clock hierarchy introduced in this series means the names
> > must also be shuffled around or the in kernel representation would be
> > incorrect. This has been the case since the sunxi-ng drivers were
> > introduced. There are plans to address this, but the code is still in its
> > early stages.
> >
> > Please have a look.
> >
> > Thanks
> > ChenYu
> >
> > Chen-Yu Tsai (14):
> >   dt-bindings: rtc: sun6i-rtc: Rewrite clock outputs as a list
> >   dt-bindings: rtc: sun6i-rtc: Add compatible strings for pre-H6
> >     variants
> >   dt-bindings: rtc: sun6i-rtc: Deprecate external clock output for A31
> >   dt-bindings: rtc: sun6i-rtc: Export internal RC oscillator
> >   rtc: sun6i: Add default clock name for LOSC
> >   rtc: sun6i: Add support for different variants
> >   rtc: sun6i: Add support for all known pre-H6 variants
> >   rtc: sun6i: Expose internal oscillator through device tree

I've applied the above patches. However, for whatever reason, patch 3
didn't apply without some fuzz, please check.


-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 00/14] rtc: sun6i: clock rework and pre-H6 SoC support
  2018-12-06 20:34   ` Alexandre Belloni
@ 2018-12-07  2:25     ` Chen-Yu Tsai
  0 siblings, 0 replies; 20+ messages in thread
From: Chen-Yu Tsai @ 2018-12-07  2:25 UTC (permalink / raw)
  To: alexandre.belloni
  Cc: Maxime Ripard, Alessandro Zummo, linux-arm-kernel, linux-rtc,
	linux-clk, devicetree, linux-kernel, linux-sunxi, Stephen Boyd,
	Mike Turquette, Rob Herring, Mark Rutland

On Fri, Dec 7, 2018 at 4:34 AM Alexandre Belloni
<alexandre.belloni@bootlin.com> wrote:
>
> On 06/12/2018 13:49:10+0800, Chen-Yu Tsai wrote:
> > Hi,
> >
> > On Mon, Dec 3, 2018 at 10:58 PM Chen-Yu Tsai <wens@csie.org> wrote:
> > >
> > > Hi everyone,
> > >
> > > This is v2 of my rtc-sun6i clean-up series.
> > >
> > > Changes since v1:
> > >
> > >   - Collected tags
> > >   - Dropped patch "clk: sunxi-ng: r40: Force LOSC parent to RTC LOSC
> > >     output"; already merged
> > >   - Removed H6 compatible CLK_OF_DECLARE_DRIVER entry that wasn't
> > >     overlooked
> > >   - Only export IOSC clock for A64/H3/H5
> > >
> > > Original cover letter, with patch numbers corrected, follows:
> > >
> > > This series was started as part of enabling Bluetooth on various
> > > Allwinner SBCs. The bluetooth controller requires a precise 32.768 kHz
> > > clock fed to it to correctly detect the frequency of its main oscillator.
> > > This clock signal is provided by the RTC, either directly from a special
> > > pin on the SoC, or some clock output function from the clock controllers.
> > > I found that the clock-related properties of the RTC on later SoCs were
> > > incorrect or missing.
> > >
> > > This series reworks the compatible strings and clock parts of the device
> > > tree bindings for sun6i-rtc. Currently we assume most Allwinner SoCs use
> > > the same sun6i-rtc variant, when in fact they do not. The differences
> > > that matter with regards to clocks are a) the A31 does not have an extra
> > > external output for the RTC 32K clock, while most of the others do;
> > > b) the clock frequency of the internal RC oscillator is different on
> > > some SoCs; c) on the H6 the RTC also handles the 24 MHz DCXO, which
> > > feeds the system HOSC. The last difference, and by extension the H6, are
> > > not covered in this series.
> > >
> > > Patch 1 cleans up the clock-related section of the RTC device tree
> > > binding. This would make it easier to read and easier to add additional
> > > clocks.
> > >
> > > Patch 2 adds compatible strings for all identified variants introduced
> > > prior to the H6.
> > >
> > > Patch 3 deprecates the external clock output for the A31. The A31 does
> > > not have this output, so it's introduction and usage was an error.
> > >
> > > Patch 4 adds a clock output for the RTC's internal oscillator to the
> > > device tree binding. This feeds the PRCM in some SoCs.
> > >
> > > Patch 5 adds a default clock name for the LOSC to the RTC driver.
> > >
> > > Patch 6 adds support for different hardware variants to the RTC driver.
> > >
> > > Patch 7 adds support for all known pre-H6 variants.
> > >
> > > Patch 8 exposes the RTC's internal oscillator through the device tree.
> > >
> > > Patch 9 through 14 adds an RTC node or fixes up the RTC device node
> > > address ranges, clock properties, names of existing clocks, and adds
> > > accuracy properties for the external fixed oscillators.
> > >
> > > The clock names require fixing because the sunxi clock driver implicitly
> > > depends on the HOSC and LOSC being named "osc24M" and "osc32k". The
> > > "fixes" to the clock hierarchy introduced in this series means the names
> > > must also be shuffled around or the in kernel representation would be
> > > incorrect. This has been the case since the sunxi-ng drivers were
> > > introduced. There are plans to address this, but the code is still in its
> > > early stages.
> > >
> > > Please have a look.
> > >
> > > Thanks
> > > ChenYu
> > >
> > > Chen-Yu Tsai (14):
> > >   dt-bindings: rtc: sun6i-rtc: Rewrite clock outputs as a list
> > >   dt-bindings: rtc: sun6i-rtc: Add compatible strings for pre-H6
> > >     variants
> > >   dt-bindings: rtc: sun6i-rtc: Deprecate external clock output for A31
> > >   dt-bindings: rtc: sun6i-rtc: Export internal RC oscillator
> > >   rtc: sun6i: Add default clock name for LOSC
> > >   rtc: sun6i: Add support for different variants
> > >   rtc: sun6i: Add support for all known pre-H6 variants
> > >   rtc: sun6i: Expose internal oscillator through device tree
>
> I've applied the above patches. However, for whatever reason, patch 3
> didn't apply without some fuzz, please check.

Sorry about that. The fuzz was due to a patch that I forgot to send out.
The fixup looks good.

I applied the remaining device tree patches. I'll send out the missing
patch, which fixes the register range in the binding example, later.

Thanks!
ChenYu

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, back to index

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-03 14:58 [PATCH v2 00/14] rtc: sun6i: clock rework and pre-H6 SoC support Chen-Yu Tsai
2018-12-03 14:58 ` [PATCH v2 01/14] dt-bindings: rtc: sun6i-rtc: Rewrite clock outputs as a list Chen-Yu Tsai
2018-12-03 14:58 ` [PATCH v2 02/14] dt-bindings: rtc: sun6i-rtc: Add compatible strings for pre-H6 variants Chen-Yu Tsai
2018-12-03 14:58 ` [PATCH v2 03/14] dt-bindings: rtc: sun6i-rtc: Deprecate external clock output for A31 Chen-Yu Tsai
2018-12-03 14:58 ` [PATCH v2 04/14] dt-bindings: rtc: sun6i-rtc: Export internal RC oscillator Chen-Yu Tsai
2018-12-04  9:17   ` Maxime Ripard
2018-12-03 14:58 ` [PATCH v2 05/14] rtc: sun6i: Add default clock name for LOSC Chen-Yu Tsai
2018-12-03 14:58 ` [PATCH v2 06/14] rtc: sun6i: Add support for different variants Chen-Yu Tsai
2018-12-03 14:58 ` [PATCH v2 07/14] rtc: sun6i: Add support for all known pre-H6 variants Chen-Yu Tsai
2018-12-03 14:58 ` [PATCH v2 08/14] rtc: sun6i: Expose internal oscillator through device tree Chen-Yu Tsai
2018-12-04  9:17   ` Maxime Ripard
2018-12-03 14:58 ` [PATCH v2 09/14] ARM: dts: sun8i: a23/a33: Fix up RTC device node Chen-Yu Tsai
2018-12-03 14:58 ` [PATCH v2 10/14] ARM: dts: sunxi: h3/h5: Add clock accuracy for external oscillators Chen-Yu Tsai
2018-12-03 14:58 ` [PATCH v2 11/14] ARM: dts: sunxi: h3/h5: Fix up RTC device node and clock references Chen-Yu Tsai
2018-12-03 14:58 ` [PATCH v2 12/14] ARM: dts: sun8i: r40: Add clock accuracy for external oscillators Chen-Yu Tsai
2018-12-03 14:58 ` [PATCH v2 13/14] ARM: dts: sun8i: r40: Add RTC device node Chen-Yu Tsai
2018-12-03 14:58 ` [PATCH v2 14/14] arm64: dts: allwinner: a64: Fix up RTC device node and clock references Chen-Yu Tsai
2018-12-06  5:49 ` [PATCH v2 00/14] rtc: sun6i: clock rework and pre-H6 SoC support Chen-Yu Tsai
2018-12-06 20:34   ` Alexandre Belloni
2018-12-07  2:25     ` Chen-Yu Tsai

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org linux-kernel@archiver.kernel.org
	public-inbox-index lkml


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox