All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V8 1/3] dt-bindings: rtc: zynqmp: Add clock information
@ 2022-06-13 12:58 ` Srinivas Neeli
  0 siblings, 0 replies; 18+ messages in thread
From: Srinivas Neeli @ 2022-06-13 12:58 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni, robh+dt, krzysztof.kozlowski+dt,
	michal.simek, sgoud, shubhraj, srinivas.neeli, neelisrinivas18
  Cc: devicetree, linux-rtc, linux-arm-kernel, linux-kernel, git,
	Srinivas Neeli

Added clock information and deprecated calibration support.

Signed-off-by: Srinivas Neeli <srinivas.neeli@xilinx.com>
---
Changes in V8:
-None
Changes in V7:
-None
Changes in V6:
-Removed dtc warnings.
Changes in V5:
-Removed quotes and _clk suffix from clocknames.
Changes in V4:
- Deprecated calibrtion support
Changes in V3:
- New patch
---
 .../devicetree/bindings/rtc/xlnx,zynqmp-rtc.yaml     | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/rtc/xlnx,zynqmp-rtc.yaml b/Documentation/devicetree/bindings/rtc/xlnx,zynqmp-rtc.yaml
index bdb72d3ddf2a..638dd1d8bb26 100644
--- a/Documentation/devicetree/bindings/rtc/xlnx,zynqmp-rtc.yaml
+++ b/Documentation/devicetree/bindings/rtc/xlnx,zynqmp-rtc.yaml
@@ -23,8 +23,15 @@ properties:
   reg:
     maxItems: 1
 
+  clocks:
+    items:
+      - description: rtc_clk is the operating frequency of crystal.
+
+  clock-names:
+    maxItems: 1
+
   interrupts:
-    minItems: 2
+    maxItems: 2
 
   interrupt-names:
     items:
@@ -39,6 +46,7 @@ properties:
     minimum: 0x1
     maximum: 0x1FFFFF
     default: 0x198233
+    deprecated: true
 
 required:
   - compatible
@@ -61,5 +69,7 @@ examples:
         interrupts = <0 26 4>, <0 27 4>;
         interrupt-names = "alarm", "sec";
         calibration = <0x198233>;
+        clock-names = "rtc_clk";
+        clocks = <&rtc_clk>;
       };
     };
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH V8 1/3] dt-bindings: rtc: zynqmp: Add clock information
@ 2022-06-13 12:58 ` Srinivas Neeli
  0 siblings, 0 replies; 18+ messages in thread
From: Srinivas Neeli @ 2022-06-13 12:58 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni, robh+dt, krzysztof.kozlowski+dt,
	michal.simek, sgoud, shubhraj, srinivas.neeli, neelisrinivas18
  Cc: devicetree, linux-rtc, linux-arm-kernel, linux-kernel, git,
	Srinivas Neeli

Added clock information and deprecated calibration support.

Signed-off-by: Srinivas Neeli <srinivas.neeli@xilinx.com>
---
Changes in V8:
-None
Changes in V7:
-None
Changes in V6:
-Removed dtc warnings.
Changes in V5:
-Removed quotes and _clk suffix from clocknames.
Changes in V4:
- Deprecated calibrtion support
Changes in V3:
- New patch
---
 .../devicetree/bindings/rtc/xlnx,zynqmp-rtc.yaml     | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/rtc/xlnx,zynqmp-rtc.yaml b/Documentation/devicetree/bindings/rtc/xlnx,zynqmp-rtc.yaml
index bdb72d3ddf2a..638dd1d8bb26 100644
--- a/Documentation/devicetree/bindings/rtc/xlnx,zynqmp-rtc.yaml
+++ b/Documentation/devicetree/bindings/rtc/xlnx,zynqmp-rtc.yaml
@@ -23,8 +23,15 @@ properties:
   reg:
     maxItems: 1
 
+  clocks:
+    items:
+      - description: rtc_clk is the operating frequency of crystal.
+
+  clock-names:
+    maxItems: 1
+
   interrupts:
-    minItems: 2
+    maxItems: 2
 
   interrupt-names:
     items:
@@ -39,6 +46,7 @@ properties:
     minimum: 0x1
     maximum: 0x1FFFFF
     default: 0x198233
+    deprecated: true
 
 required:
   - compatible
@@ -61,5 +69,7 @@ examples:
         interrupts = <0 26 4>, <0 27 4>;
         interrupt-names = "alarm", "sec";
         calibration = <0x198233>;
+        clock-names = "rtc_clk";
+        clocks = <&rtc_clk>;
       };
     };
-- 
2.25.1


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

* [PATCH V8 2/3] rtc: zynqmp: Updated calibration value
  2022-06-13 12:58 ` Srinivas Neeli
@ 2022-06-13 12:58   ` Srinivas Neeli
  -1 siblings, 0 replies; 18+ messages in thread
From: Srinivas Neeli @ 2022-06-13 12:58 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni, robh+dt, krzysztof.kozlowski+dt,
	michal.simek, sgoud, shubhraj, srinivas.neeli, neelisrinivas18
  Cc: devicetree, linux-rtc, linux-arm-kernel, linux-kernel, git,
	Srinivas Neeli

As per RTC spec default calibration value is 0x7FFF.

Signed-off-by: Srinivas Neeli <srinivas.neeli@xilinx.com>
---
Changes in V8
-None, just swapped 2/3 and 3/3 patches from V7.
Changes in V7:
-New patch
-TRM not updated yet, Internal design document contains 0x7FFF as
 default value. TRM Will update in next release.
---
 drivers/rtc/rtc-zynqmp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c
index f440bb52be92..5da33d760419 100644
--- a/drivers/rtc/rtc-zynqmp.c
+++ b/drivers/rtc/rtc-zynqmp.c
@@ -36,7 +36,7 @@
 #define RTC_OSC_EN		BIT(24)
 #define RTC_BATT_EN		BIT(31)
 
-#define RTC_CALIB_DEF		0x198233
+#define RTC_CALIB_DEF		0x7FFF
 #define RTC_CALIB_MASK		0x1FFFFF
 #define RTC_ALRM_MASK          BIT(1)
 #define RTC_MSEC               1000
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH V8 2/3] rtc: zynqmp: Updated calibration value
@ 2022-06-13 12:58   ` Srinivas Neeli
  0 siblings, 0 replies; 18+ messages in thread
From: Srinivas Neeli @ 2022-06-13 12:58 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni, robh+dt, krzysztof.kozlowski+dt,
	michal.simek, sgoud, shubhraj, srinivas.neeli, neelisrinivas18
  Cc: devicetree, linux-rtc, linux-arm-kernel, linux-kernel, git,
	Srinivas Neeli

As per RTC spec default calibration value is 0x7FFF.

Signed-off-by: Srinivas Neeli <srinivas.neeli@xilinx.com>
---
Changes in V8
-None, just swapped 2/3 and 3/3 patches from V7.
Changes in V7:
-New patch
-TRM not updated yet, Internal design document contains 0x7FFF as
 default value. TRM Will update in next release.
---
 drivers/rtc/rtc-zynqmp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c
index f440bb52be92..5da33d760419 100644
--- a/drivers/rtc/rtc-zynqmp.c
+++ b/drivers/rtc/rtc-zynqmp.c
@@ -36,7 +36,7 @@
 #define RTC_OSC_EN		BIT(24)
 #define RTC_BATT_EN		BIT(31)
 
-#define RTC_CALIB_DEF		0x198233
+#define RTC_CALIB_DEF		0x7FFF
 #define RTC_CALIB_MASK		0x1FFFFF
 #define RTC_ALRM_MASK          BIT(1)
 #define RTC_MSEC               1000
-- 
2.25.1


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

* [PATCH V8 3/3] rtc: zynqmp: Add calibration set and get support
  2022-06-13 12:58 ` Srinivas Neeli
@ 2022-06-13 12:58   ` Srinivas Neeli
  -1 siblings, 0 replies; 18+ messages in thread
From: Srinivas Neeli @ 2022-06-13 12:58 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni, robh+dt, krzysztof.kozlowski+dt,
	michal.simek, sgoud, shubhraj, srinivas.neeli, neelisrinivas18
  Cc: devicetree, linux-rtc, linux-arm-kernel, linux-kernel, git,
	Srinivas Neeli

Zynqmp RTC controller has a calibration feature to compensate
time deviation due to input clock inaccuracy.
Set and get calibration API's are used for setting and getting
calibration value from the controller calibration register.

Signed-off-by: Srinivas Neeli <srinivas.neeli@xilinx.com>
---
Changes in V7:
-Removed calibration default value update from this patch.
Changes in V6:
-None
Changes in V5:
-None
Changes in V4:
-Updated MIN and MAX calibration values.
Changes in V3:
-Calculated tick_mult using crystal frequency.
-Calibration register updating based on crystal frequency in probe.
-Supressed MIN an MAX calibration values,Will send separate patch in future.
Changes in V2:
-Removed unused macro.
-Updated code with review comments.
---
 drivers/rtc/rtc-zynqmp.c | 113 ++++++++++++++++++++++++++++++++-------
 1 file changed, 94 insertions(+), 19 deletions(-)

diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c
index 5da33d760419..1dd389b891fe 100644
--- a/drivers/rtc/rtc-zynqmp.c
+++ b/drivers/rtc/rtc-zynqmp.c
@@ -6,6 +6,7 @@
  *
  */
 
+#include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/io.h>
@@ -40,13 +41,19 @@
 #define RTC_CALIB_MASK		0x1FFFFF
 #define RTC_ALRM_MASK          BIT(1)
 #define RTC_MSEC               1000
+#define RTC_FR_MASK		0xF0000
+#define RTC_FR_MAX_TICKS	16
+#define RTC_PPB			1000000000LL
+#define RTC_MIN_OFFSET		-32768000
+#define RTC_MAX_OFFSET		32767000
 
 struct xlnx_rtc_dev {
 	struct rtc_device	*rtc;
 	void __iomem		*reg_base;
 	int			alarm_irq;
 	int			sec_irq;
-	unsigned int		calibval;
+	struct clk		*rtc_clk;
+	unsigned int		freq;
 };
 
 static int xlnx_rtc_set_time(struct device *dev, struct rtc_time *tm)
@@ -61,13 +68,6 @@ static int xlnx_rtc_set_time(struct device *dev, struct rtc_time *tm)
 	 */
 	new_time = rtc_tm_to_time64(tm) + 1;
 
-	/*
-	 * Writing into calibration register will clear the Tick Counter and
-	 * force the next second to be signaled exactly in 1 second period
-	 */
-	xrtcdev->calibval &= RTC_CALIB_MASK;
-	writel(xrtcdev->calibval, (xrtcdev->reg_base + RTC_CALIB_WR));
-
 	writel(new_time, xrtcdev->reg_base + RTC_SET_TM_WR);
 
 	/*
@@ -173,15 +173,76 @@ static void xlnx_init_rtc(struct xlnx_rtc_dev *xrtcdev)
 	rtc_ctrl = readl(xrtcdev->reg_base + RTC_CTRL);
 	rtc_ctrl |= RTC_BATT_EN;
 	writel(rtc_ctrl, xrtcdev->reg_base + RTC_CTRL);
+}
 
-	/*
-	 * Based on crystal freq of 33.330 KHz
-	 * set the seconds counter and enable, set fractions counter
-	 * to default value suggested as per design spec
-	 * to correct RTC delay in frequency over period of time.
+static int xlnx_rtc_read_offset(struct device *dev, long *offset)
+{
+	struct xlnx_rtc_dev *xrtcdev = dev_get_drvdata(dev);
+	unsigned long long rtc_ppb = RTC_PPB;
+	unsigned int tick_mult = do_div(rtc_ppb, xrtcdev->freq);
+	unsigned int calibval;
+	long offset_val;
+
+	calibval = readl(xrtcdev->reg_base + RTC_CALIB_RD);
+	/* Offset with seconds ticks */
+	offset_val = calibval & RTC_TICK_MASK;
+	offset_val = offset_val - RTC_CALIB_DEF;
+	offset_val = offset_val * tick_mult;
+
+	/* Offset with fractional ticks */
+	if (calibval & RTC_FR_EN)
+		offset_val += ((calibval & RTC_FR_MASK) >> RTC_FR_DATSHIFT)
+			* (tick_mult / RTC_FR_MAX_TICKS);
+	*offset = offset_val;
+
+	return 0;
+}
+
+static int xlnx_rtc_set_offset(struct device *dev, long offset)
+{
+	struct xlnx_rtc_dev *xrtcdev = dev_get_drvdata(dev);
+	unsigned long long rtc_ppb = RTC_PPB;
+	unsigned int tick_mult = do_div(rtc_ppb, xrtcdev->freq);
+	unsigned char fract_tick;
+	unsigned int calibval;
+	short int  max_tick;
+	int fract_offset;
+
+	if (offset < RTC_MIN_OFFSET || offset > RTC_MAX_OFFSET)
+		return -ERANGE;
+
+	/* Number ticks for given offset */
+	max_tick = div_s64_rem(offset, tick_mult, &fract_offset);
+
+	/* Number fractional ticks for given offset */
+	if (fract_offset) {
+		if (fract_offset < 0) {
+			fract_offset = fract_offset + tick_mult;
+			max_tick--;
+		}
+		if (fract_offset > (tick_mult / RTC_FR_MAX_TICKS)) {
+			for (fract_tick = 1; fract_tick < 16; fract_tick++) {
+				if (fract_offset <=
+				    (fract_tick *
+				     (tick_mult / RTC_FR_MAX_TICKS)))
+					break;
+			}
+		}
+	}
+
+	/* Zynqmp RTC uses second and fractional tick
+	 * counters for compensation
 	 */
-	xrtcdev->calibval &= RTC_CALIB_MASK;
-	writel(xrtcdev->calibval, (xrtcdev->reg_base + RTC_CALIB_WR));
+	calibval = max_tick + RTC_CALIB_DEF;
+
+	if (fract_tick)
+		calibval |= RTC_FR_EN;
+
+	calibval |= (fract_tick << RTC_FR_DATSHIFT);
+
+	writel(calibval, (xrtcdev->reg_base + RTC_CALIB_WR));
+
+	return 0;
 }
 
 static const struct rtc_class_ops xlnx_rtc_ops = {
@@ -190,6 +251,8 @@ static const struct rtc_class_ops xlnx_rtc_ops = {
 	.read_alarm	  = xlnx_rtc_read_alarm,
 	.set_alarm	  = xlnx_rtc_set_alarm,
 	.alarm_irq_enable = xlnx_rtc_alarm_irq_enable,
+	.read_offset	  = xlnx_rtc_read_offset,
+	.set_offset	  = xlnx_rtc_set_offset,
 };
 
 static irqreturn_t xlnx_rtc_interrupt(int irq, void *id)
@@ -255,10 +318,22 @@ static int xlnx_rtc_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	ret = of_property_read_u32(pdev->dev.of_node, "calibration",
-				   &xrtcdev->calibval);
-	if (ret)
-		xrtcdev->calibval = RTC_CALIB_DEF;
+	/* Getting the rtc_clk info */
+	xrtcdev->rtc_clk = devm_clk_get_optional(&pdev->dev, "rtc_clk");
+	if (IS_ERR(xrtcdev->rtc_clk)) {
+		if (PTR_ERR(xrtcdev->rtc_clk) != -EPROBE_DEFER)
+			dev_warn(&pdev->dev, "Device clock not found.\n");
+	}
+	xrtcdev->freq = clk_get_rate(xrtcdev->rtc_clk);
+	if (!xrtcdev->freq) {
+		ret = of_property_read_u32(pdev->dev.of_node, "calibration",
+					   &xrtcdev->freq);
+		if (ret)
+			xrtcdev->freq = RTC_CALIB_DEF;
+	}
+	ret = readl(xrtcdev->reg_base + RTC_CALIB_RD);
+	if (!ret)
+		writel(xrtcdev->freq, (xrtcdev->reg_base + RTC_CALIB_WR));
 
 	xlnx_init_rtc(xrtcdev);
 
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH V8 3/3] rtc: zynqmp: Add calibration set and get support
@ 2022-06-13 12:58   ` Srinivas Neeli
  0 siblings, 0 replies; 18+ messages in thread
From: Srinivas Neeli @ 2022-06-13 12:58 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni, robh+dt, krzysztof.kozlowski+dt,
	michal.simek, sgoud, shubhraj, srinivas.neeli, neelisrinivas18
  Cc: devicetree, linux-rtc, linux-arm-kernel, linux-kernel, git,
	Srinivas Neeli

Zynqmp RTC controller has a calibration feature to compensate
time deviation due to input clock inaccuracy.
Set and get calibration API's are used for setting and getting
calibration value from the controller calibration register.

Signed-off-by: Srinivas Neeli <srinivas.neeli@xilinx.com>
---
Changes in V7:
-Removed calibration default value update from this patch.
Changes in V6:
-None
Changes in V5:
-None
Changes in V4:
-Updated MIN and MAX calibration values.
Changes in V3:
-Calculated tick_mult using crystal frequency.
-Calibration register updating based on crystal frequency in probe.
-Supressed MIN an MAX calibration values,Will send separate patch in future.
Changes in V2:
-Removed unused macro.
-Updated code with review comments.
---
 drivers/rtc/rtc-zynqmp.c | 113 ++++++++++++++++++++++++++++++++-------
 1 file changed, 94 insertions(+), 19 deletions(-)

diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c
index 5da33d760419..1dd389b891fe 100644
--- a/drivers/rtc/rtc-zynqmp.c
+++ b/drivers/rtc/rtc-zynqmp.c
@@ -6,6 +6,7 @@
  *
  */
 
+#include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/io.h>
@@ -40,13 +41,19 @@
 #define RTC_CALIB_MASK		0x1FFFFF
 #define RTC_ALRM_MASK          BIT(1)
 #define RTC_MSEC               1000
+#define RTC_FR_MASK		0xF0000
+#define RTC_FR_MAX_TICKS	16
+#define RTC_PPB			1000000000LL
+#define RTC_MIN_OFFSET		-32768000
+#define RTC_MAX_OFFSET		32767000
 
 struct xlnx_rtc_dev {
 	struct rtc_device	*rtc;
 	void __iomem		*reg_base;
 	int			alarm_irq;
 	int			sec_irq;
-	unsigned int		calibval;
+	struct clk		*rtc_clk;
+	unsigned int		freq;
 };
 
 static int xlnx_rtc_set_time(struct device *dev, struct rtc_time *tm)
@@ -61,13 +68,6 @@ static int xlnx_rtc_set_time(struct device *dev, struct rtc_time *tm)
 	 */
 	new_time = rtc_tm_to_time64(tm) + 1;
 
-	/*
-	 * Writing into calibration register will clear the Tick Counter and
-	 * force the next second to be signaled exactly in 1 second period
-	 */
-	xrtcdev->calibval &= RTC_CALIB_MASK;
-	writel(xrtcdev->calibval, (xrtcdev->reg_base + RTC_CALIB_WR));
-
 	writel(new_time, xrtcdev->reg_base + RTC_SET_TM_WR);
 
 	/*
@@ -173,15 +173,76 @@ static void xlnx_init_rtc(struct xlnx_rtc_dev *xrtcdev)
 	rtc_ctrl = readl(xrtcdev->reg_base + RTC_CTRL);
 	rtc_ctrl |= RTC_BATT_EN;
 	writel(rtc_ctrl, xrtcdev->reg_base + RTC_CTRL);
+}
 
-	/*
-	 * Based on crystal freq of 33.330 KHz
-	 * set the seconds counter and enable, set fractions counter
-	 * to default value suggested as per design spec
-	 * to correct RTC delay in frequency over period of time.
+static int xlnx_rtc_read_offset(struct device *dev, long *offset)
+{
+	struct xlnx_rtc_dev *xrtcdev = dev_get_drvdata(dev);
+	unsigned long long rtc_ppb = RTC_PPB;
+	unsigned int tick_mult = do_div(rtc_ppb, xrtcdev->freq);
+	unsigned int calibval;
+	long offset_val;
+
+	calibval = readl(xrtcdev->reg_base + RTC_CALIB_RD);
+	/* Offset with seconds ticks */
+	offset_val = calibval & RTC_TICK_MASK;
+	offset_val = offset_val - RTC_CALIB_DEF;
+	offset_val = offset_val * tick_mult;
+
+	/* Offset with fractional ticks */
+	if (calibval & RTC_FR_EN)
+		offset_val += ((calibval & RTC_FR_MASK) >> RTC_FR_DATSHIFT)
+			* (tick_mult / RTC_FR_MAX_TICKS);
+	*offset = offset_val;
+
+	return 0;
+}
+
+static int xlnx_rtc_set_offset(struct device *dev, long offset)
+{
+	struct xlnx_rtc_dev *xrtcdev = dev_get_drvdata(dev);
+	unsigned long long rtc_ppb = RTC_PPB;
+	unsigned int tick_mult = do_div(rtc_ppb, xrtcdev->freq);
+	unsigned char fract_tick;
+	unsigned int calibval;
+	short int  max_tick;
+	int fract_offset;
+
+	if (offset < RTC_MIN_OFFSET || offset > RTC_MAX_OFFSET)
+		return -ERANGE;
+
+	/* Number ticks for given offset */
+	max_tick = div_s64_rem(offset, tick_mult, &fract_offset);
+
+	/* Number fractional ticks for given offset */
+	if (fract_offset) {
+		if (fract_offset < 0) {
+			fract_offset = fract_offset + tick_mult;
+			max_tick--;
+		}
+		if (fract_offset > (tick_mult / RTC_FR_MAX_TICKS)) {
+			for (fract_tick = 1; fract_tick < 16; fract_tick++) {
+				if (fract_offset <=
+				    (fract_tick *
+				     (tick_mult / RTC_FR_MAX_TICKS)))
+					break;
+			}
+		}
+	}
+
+	/* Zynqmp RTC uses second and fractional tick
+	 * counters for compensation
 	 */
-	xrtcdev->calibval &= RTC_CALIB_MASK;
-	writel(xrtcdev->calibval, (xrtcdev->reg_base + RTC_CALIB_WR));
+	calibval = max_tick + RTC_CALIB_DEF;
+
+	if (fract_tick)
+		calibval |= RTC_FR_EN;
+
+	calibval |= (fract_tick << RTC_FR_DATSHIFT);
+
+	writel(calibval, (xrtcdev->reg_base + RTC_CALIB_WR));
+
+	return 0;
 }
 
 static const struct rtc_class_ops xlnx_rtc_ops = {
@@ -190,6 +251,8 @@ static const struct rtc_class_ops xlnx_rtc_ops = {
 	.read_alarm	  = xlnx_rtc_read_alarm,
 	.set_alarm	  = xlnx_rtc_set_alarm,
 	.alarm_irq_enable = xlnx_rtc_alarm_irq_enable,
+	.read_offset	  = xlnx_rtc_read_offset,
+	.set_offset	  = xlnx_rtc_set_offset,
 };
 
 static irqreturn_t xlnx_rtc_interrupt(int irq, void *id)
@@ -255,10 +318,22 @@ static int xlnx_rtc_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	ret = of_property_read_u32(pdev->dev.of_node, "calibration",
-				   &xrtcdev->calibval);
-	if (ret)
-		xrtcdev->calibval = RTC_CALIB_DEF;
+	/* Getting the rtc_clk info */
+	xrtcdev->rtc_clk = devm_clk_get_optional(&pdev->dev, "rtc_clk");
+	if (IS_ERR(xrtcdev->rtc_clk)) {
+		if (PTR_ERR(xrtcdev->rtc_clk) != -EPROBE_DEFER)
+			dev_warn(&pdev->dev, "Device clock not found.\n");
+	}
+	xrtcdev->freq = clk_get_rate(xrtcdev->rtc_clk);
+	if (!xrtcdev->freq) {
+		ret = of_property_read_u32(pdev->dev.of_node, "calibration",
+					   &xrtcdev->freq);
+		if (ret)
+			xrtcdev->freq = RTC_CALIB_DEF;
+	}
+	ret = readl(xrtcdev->reg_base + RTC_CALIB_RD);
+	if (!ret)
+		writel(xrtcdev->freq, (xrtcdev->reg_base + RTC_CALIB_WR));
 
 	xlnx_init_rtc(xrtcdev);
 
-- 
2.25.1


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

* Re: [PATCH V8 3/3] rtc: zynqmp: Add calibration set and get support
  2022-06-13 12:58   ` Srinivas Neeli
  (?)
@ 2022-06-14  4:04   ` kernel test robot
  -1 siblings, 0 replies; 18+ messages in thread
From: kernel test robot @ 2022-06-14  4:04 UTC (permalink / raw)
  To: Srinivas Neeli; +Cc: llvm, kbuild-all

Hi Srinivas,

I love your patch! Perhaps something to improve:

[auto build test WARNING on abelloni/rtc-next]
[also build test WARNING on v5.19-rc2 next-20220610]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Srinivas-Neeli/dt-bindings-rtc-zynqmp-Add-clock-information/20220614-013701
base:   https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git rtc-next
config: i386-randconfig-a006-20220613 (https://download.01.org/0day-ci/archive/20220614/202206141140.xDnN0yu1-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project c97436f8b6e2718286e8496faf53a2c800e281cf)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/2781fd75583878d86f256113b19bb005dc83fb70
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Srinivas-Neeli/dt-bindings-rtc-zynqmp-Add-clock-information/20220614-013701
        git checkout 2781fd75583878d86f256113b19bb005dc83fb70
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/rtc/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/rtc/rtc-zynqmp.c:223:7: warning: variable 'fract_tick' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
                   if (fract_offset > (tick_mult / RTC_FR_MAX_TICKS)) {
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/rtc/rtc-zynqmp.c:238:6: note: uninitialized use occurs here
           if (fract_tick)
               ^~~~~~~~~~
   drivers/rtc/rtc-zynqmp.c:223:3: note: remove the 'if' if its condition is always true
                   if (fract_offset > (tick_mult / RTC_FR_MAX_TICKS)) {
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/rtc/rtc-zynqmp.c:218:6: warning: variable 'fract_tick' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
           if (fract_offset) {
               ^~~~~~~~~~~~
   drivers/rtc/rtc-zynqmp.c:238:6: note: uninitialized use occurs here
           if (fract_tick)
               ^~~~~~~~~~
   drivers/rtc/rtc-zynqmp.c:218:2: note: remove the 'if' if its condition is always true
           if (fract_offset) {
           ^~~~~~~~~~~~~~~~~~
   drivers/rtc/rtc-zynqmp.c:206:26: note: initialize the variable 'fract_tick' to silence this warning
           unsigned char fract_tick;
                                   ^
                                    = '\0'
   2 warnings generated.


vim +223 drivers/rtc/rtc-zynqmp.c

   200	
   201	static int xlnx_rtc_set_offset(struct device *dev, long offset)
   202	{
   203		struct xlnx_rtc_dev *xrtcdev = dev_get_drvdata(dev);
   204		unsigned long long rtc_ppb = RTC_PPB;
   205		unsigned int tick_mult = do_div(rtc_ppb, xrtcdev->freq);
   206		unsigned char fract_tick;
   207		unsigned int calibval;
   208		short int  max_tick;
   209		int fract_offset;
   210	
   211		if (offset < RTC_MIN_OFFSET || offset > RTC_MAX_OFFSET)
   212			return -ERANGE;
   213	
   214		/* Number ticks for given offset */
   215		max_tick = div_s64_rem(offset, tick_mult, &fract_offset);
   216	
   217		/* Number fractional ticks for given offset */
   218		if (fract_offset) {
   219			if (fract_offset < 0) {
   220				fract_offset = fract_offset + tick_mult;
   221				max_tick--;
   222			}
 > 223			if (fract_offset > (tick_mult / RTC_FR_MAX_TICKS)) {
   224				for (fract_tick = 1; fract_tick < 16; fract_tick++) {
   225					if (fract_offset <=
   226					    (fract_tick *
   227					     (tick_mult / RTC_FR_MAX_TICKS)))
   228						break;
   229				}
   230			}
   231		}
   232	
   233		/* Zynqmp RTC uses second and fractional tick
   234		 * counters for compensation
   235		 */
   236		calibval = max_tick + RTC_CALIB_DEF;
   237	
   238		if (fract_tick)
   239			calibval |= RTC_FR_EN;
   240	
   241		calibval |= (fract_tick << RTC_FR_DATSHIFT);
   242	
   243		writel(calibval, (xrtcdev->reg_base + RTC_CALIB_WR));
   244	
   245		return 0;
   246	}
   247	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

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

* Re: [PATCH V8 3/3] rtc: zynqmp: Add calibration set and get support
  2022-06-13 12:58   ` Srinivas Neeli
  (?)
  (?)
@ 2022-06-14  4:24   ` kernel test robot
  -1 siblings, 0 replies; 18+ messages in thread
From: kernel test robot @ 2022-06-14  4:24 UTC (permalink / raw)
  To: Srinivas Neeli; +Cc: llvm, kbuild-all

Hi Srinivas,

I love your patch! Perhaps something to improve:

[auto build test WARNING on abelloni/rtc-next]
[also build test WARNING on v5.19-rc2 next-20220610]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Srinivas-Neeli/dt-bindings-rtc-zynqmp-Add-clock-information/20220614-013701
base:   https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git rtc-next
config: arm-randconfig-r035-20220612 (https://download.01.org/0day-ci/archive/20220614/202206141232.8nBAsby4-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project c97436f8b6e2718286e8496faf53a2c800e281cf)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # https://github.com/intel-lab-lkp/linux/commit/2781fd75583878d86f256113b19bb005dc83fb70
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Srinivas-Neeli/dt-bindings-rtc-zynqmp-Add-clock-information/20220614-013701
        git checkout 2781fd75583878d86f256113b19bb005dc83fb70
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash drivers/rtc/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/rtc/rtc-zynqmp.c:223:7: warning: variable 'fract_tick' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
                   if (fract_offset > (tick_mult / RTC_FR_MAX_TICKS)) {
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/rtc/rtc-zynqmp.c:238:6: note: uninitialized use occurs here
           if (fract_tick)
               ^~~~~~~~~~
   drivers/rtc/rtc-zynqmp.c:223:3: note: remove the 'if' if its condition is always true
                   if (fract_offset > (tick_mult / RTC_FR_MAX_TICKS)) {
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/rtc/rtc-zynqmp.c:218:6: warning: variable 'fract_tick' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
           if (fract_offset) {
               ^~~~~~~~~~~~
   drivers/rtc/rtc-zynqmp.c:238:6: note: uninitialized use occurs here
           if (fract_tick)
               ^~~~~~~~~~
   drivers/rtc/rtc-zynqmp.c:218:2: note: remove the 'if' if its condition is always true
           if (fract_offset) {
           ^~~~~~~~~~~~~~~~~~
   drivers/rtc/rtc-zynqmp.c:206:26: note: initialize the variable 'fract_tick' to silence this warning
           unsigned char fract_tick;
                                   ^
                                    = '\0'
   2 warnings generated.


vim +223 drivers/rtc/rtc-zynqmp.c

   200	
   201	static int xlnx_rtc_set_offset(struct device *dev, long offset)
   202	{
   203		struct xlnx_rtc_dev *xrtcdev = dev_get_drvdata(dev);
   204		unsigned long long rtc_ppb = RTC_PPB;
   205		unsigned int tick_mult = do_div(rtc_ppb, xrtcdev->freq);
   206		unsigned char fract_tick;
   207		unsigned int calibval;
   208		short int  max_tick;
   209		int fract_offset;
   210	
   211		if (offset < RTC_MIN_OFFSET || offset > RTC_MAX_OFFSET)
   212			return -ERANGE;
   213	
   214		/* Number ticks for given offset */
   215		max_tick = div_s64_rem(offset, tick_mult, &fract_offset);
   216	
   217		/* Number fractional ticks for given offset */
   218		if (fract_offset) {
   219			if (fract_offset < 0) {
   220				fract_offset = fract_offset + tick_mult;
   221				max_tick--;
   222			}
 > 223			if (fract_offset > (tick_mult / RTC_FR_MAX_TICKS)) {
   224				for (fract_tick = 1; fract_tick < 16; fract_tick++) {
   225					if (fract_offset <=
   226					    (fract_tick *
   227					     (tick_mult / RTC_FR_MAX_TICKS)))
   228						break;
   229				}
   230			}
   231		}
   232	
   233		/* Zynqmp RTC uses second and fractional tick
   234		 * counters for compensation
   235		 */
   236		calibval = max_tick + RTC_CALIB_DEF;
   237	
   238		if (fract_tick)
   239			calibval |= RTC_FR_EN;
   240	
   241		calibval |= (fract_tick << RTC_FR_DATSHIFT);
   242	
   243		writel(calibval, (xrtcdev->reg_base + RTC_CALIB_WR));
   244	
   245		return 0;
   246	}
   247	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

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

* Re: [PATCH V8 2/3] rtc: zynqmp: Updated calibration value
  2022-06-13 12:58   ` Srinivas Neeli
@ 2022-06-14 11:39     ` Peter Korsgaard
  -1 siblings, 0 replies; 18+ messages in thread
From: Peter Korsgaard @ 2022-06-14 11:39 UTC (permalink / raw)
  To: Srinivas Neeli
  Cc: a.zummo, alexandre.belloni, robh+dt, krzysztof.kozlowski+dt,
	michal.simek, sgoud, shubhraj, srinivas.neeli, neelisrinivas18,
	devicetree, linux-rtc, linux-arm-kernel, linux-kernel, git

>>>>> "Srinivas" == Srinivas Neeli <srinivas.neeli@xilinx.com> writes:

 > As per RTC spec default calibration value is 0x7FFF.
 > Signed-off-by: Srinivas Neeli <srinivas.neeli@xilinx.com>

> ---
 > Changes in V8
 > -None, just swapped 2/3 and 3/3 patches from V7.
 > Changes in V7:
 > -New patch
 > -TRM not updated yet, Internal design document contains 0x7FFF as
 >  default value. TRM Will update in next release.

Maybe add this to the commit message so it is clear where this comes
from. If possible specific the TRM version number that will contain the
fix.

Other than that:

Acked-by: Peter Korsgaard <peter@korsgaard.com>

-- 
Bye, Peter Korsgaard

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

* Re: [PATCH V8 2/3] rtc: zynqmp: Updated calibration value
@ 2022-06-14 11:39     ` Peter Korsgaard
  0 siblings, 0 replies; 18+ messages in thread
From: Peter Korsgaard @ 2022-06-14 11:39 UTC (permalink / raw)
  To: Srinivas Neeli
  Cc: a.zummo, alexandre.belloni, robh+dt, krzysztof.kozlowski+dt,
	michal.simek, sgoud, shubhraj, srinivas.neeli, neelisrinivas18,
	devicetree, linux-rtc, linux-arm-kernel, linux-kernel, git

>>>>> "Srinivas" == Srinivas Neeli <srinivas.neeli@xilinx.com> writes:

 > As per RTC spec default calibration value is 0x7FFF.
 > Signed-off-by: Srinivas Neeli <srinivas.neeli@xilinx.com>

> ---
 > Changes in V8
 > -None, just swapped 2/3 and 3/3 patches from V7.
 > Changes in V7:
 > -New patch
 > -TRM not updated yet, Internal design document contains 0x7FFF as
 >  default value. TRM Will update in next release.

Maybe add this to the commit message so it is clear where this comes
from. If possible specific the TRM version number that will contain the
fix.

Other than that:

Acked-by: Peter Korsgaard <peter@korsgaard.com>

-- 
Bye, Peter Korsgaard

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH V8 1/3] dt-bindings: rtc: zynqmp: Add clock information
  2022-06-13 12:58 ` Srinivas Neeli
@ 2022-06-14 20:51   ` Rob Herring
  -1 siblings, 0 replies; 18+ messages in thread
From: Rob Herring @ 2022-06-14 20:51 UTC (permalink / raw)
  To: Srinivas Neeli
  Cc: git, sgoud, linux-kernel, devicetree, linux-arm-kernel, robh+dt,
	srinivas.neeli, michal.simek, neelisrinivas18, shubhraj, a.zummo,
	alexandre.belloni, linux-rtc, krzysztof.kozlowski+dt

On Mon, 13 Jun 2022 18:28:34 +0530, Srinivas Neeli wrote:
> Added clock information and deprecated calibration support.
> 
> Signed-off-by: Srinivas Neeli <srinivas.neeli@xilinx.com>
> ---
> Changes in V8:
> -None
> Changes in V7:
> -None
> Changes in V6:
> -Removed dtc warnings.
> Changes in V5:
> -Removed quotes and _clk suffix from clocknames.
> Changes in V4:
> - Deprecated calibrtion support
> Changes in V3:
> - New patch
> ---
>  .../devicetree/bindings/rtc/xlnx,zynqmp-rtc.yaml     | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 

Reviewed-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH V8 1/3] dt-bindings: rtc: zynqmp: Add clock information
@ 2022-06-14 20:51   ` Rob Herring
  0 siblings, 0 replies; 18+ messages in thread
From: Rob Herring @ 2022-06-14 20:51 UTC (permalink / raw)
  To: Srinivas Neeli
  Cc: git, sgoud, linux-kernel, devicetree, linux-arm-kernel, robh+dt,
	srinivas.neeli, michal.simek, neelisrinivas18, shubhraj, a.zummo,
	alexandre.belloni, linux-rtc, krzysztof.kozlowski+dt

On Mon, 13 Jun 2022 18:28:34 +0530, Srinivas Neeli wrote:
> Added clock information and deprecated calibration support.
> 
> Signed-off-by: Srinivas Neeli <srinivas.neeli@xilinx.com>
> ---
> Changes in V8:
> -None
> Changes in V7:
> -None
> Changes in V6:
> -Removed dtc warnings.
> Changes in V5:
> -Removed quotes and _clk suffix from clocknames.
> Changes in V4:
> - Deprecated calibrtion support
> Changes in V3:
> - New patch
> ---
>  .../devicetree/bindings/rtc/xlnx,zynqmp-rtc.yaml     | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 

Reviewed-by: Rob Herring <robh@kernel.org>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH V8 1/3] dt-bindings: rtc: zynqmp: Add clock information
  2022-06-13 12:58 ` Srinivas Neeli
@ 2022-06-18  0:38   ` Krzysztof Kozlowski
  -1 siblings, 0 replies; 18+ messages in thread
From: Krzysztof Kozlowski @ 2022-06-18  0:38 UTC (permalink / raw)
  To: Srinivas Neeli, a.zummo, alexandre.belloni, robh+dt,
	krzysztof.kozlowski+dt, michal.simek, sgoud, shubhraj,
	srinivas.neeli, neelisrinivas18
  Cc: devicetree, linux-rtc, linux-arm-kernel, linux-kernel, git

On 13/06/2022 05:58, Srinivas Neeli wrote:
> Added clock information and deprecated calibration support.
> 
> Signed-off-by: Srinivas Neeli <srinivas.neeli@xilinx.com>
> ---
> Changes in V8:
> -None
> Changes in V7:
> -None
> Changes in V6:
> -Removed dtc warnings.
> Changes in V5:
> -Removed quotes and _clk suffix from clocknames.
> Changes in V4:
> - Deprecated calibrtion support
> Changes in V3:
> - New patch
> ---
>  .../devicetree/bindings/rtc/xlnx,zynqmp-rtc.yaml     | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/rtc/xlnx,zynqmp-rtc.yaml b/Documentation/devicetree/bindings/rtc/xlnx,zynqmp-rtc.yaml
> index bdb72d3ddf2a..638dd1d8bb26 100644
> --- a/Documentation/devicetree/bindings/rtc/xlnx,zynqmp-rtc.yaml
> +++ b/Documentation/devicetree/bindings/rtc/xlnx,zynqmp-rtc.yaml
> @@ -23,8 +23,15 @@ properties:
>    reg:
>      maxItems: 1
>  
> +  clocks:
> +    items:
> +      - description: rtc_clk is the operating frequency of crystal.
> +
> +  clock-names:
> +    maxItems: 1

You need to specify the name instead of maxItems.

> +
>    interrupts:
> -    minItems: 2
> +    maxItems: 2
>  
>    interrupt-names:
>      items:
> @@ -39,6 +46,7 @@ properties:
>      minimum: 0x1
>      maximum: 0x1FFFFF
>      default: 0x198233
> +    deprecated: true
>  
>  required:
>    - compatible
> @@ -61,5 +69,7 @@ examples:
>          interrupts = <0 26 4>, <0 27 4>;
>          interrupt-names = "alarm", "sec";
>          calibration = <0x198233>;
> +        clock-names = "rtc_clk";
> +        clocks = <&rtc_clk>;
>        };
>      };


Best regards,
Krzysztof

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

* Re: [PATCH V8 1/3] dt-bindings: rtc: zynqmp: Add clock information
@ 2022-06-18  0:38   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 18+ messages in thread
From: Krzysztof Kozlowski @ 2022-06-18  0:38 UTC (permalink / raw)
  To: Srinivas Neeli, a.zummo, alexandre.belloni, robh+dt,
	krzysztof.kozlowski+dt, michal.simek, sgoud, shubhraj,
	srinivas.neeli, neelisrinivas18
  Cc: devicetree, linux-rtc, linux-arm-kernel, linux-kernel, git

On 13/06/2022 05:58, Srinivas Neeli wrote:
> Added clock information and deprecated calibration support.
> 
> Signed-off-by: Srinivas Neeli <srinivas.neeli@xilinx.com>
> ---
> Changes in V8:
> -None
> Changes in V7:
> -None
> Changes in V6:
> -Removed dtc warnings.
> Changes in V5:
> -Removed quotes and _clk suffix from clocknames.
> Changes in V4:
> - Deprecated calibrtion support
> Changes in V3:
> - New patch
> ---
>  .../devicetree/bindings/rtc/xlnx,zynqmp-rtc.yaml     | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/rtc/xlnx,zynqmp-rtc.yaml b/Documentation/devicetree/bindings/rtc/xlnx,zynqmp-rtc.yaml
> index bdb72d3ddf2a..638dd1d8bb26 100644
> --- a/Documentation/devicetree/bindings/rtc/xlnx,zynqmp-rtc.yaml
> +++ b/Documentation/devicetree/bindings/rtc/xlnx,zynqmp-rtc.yaml
> @@ -23,8 +23,15 @@ properties:
>    reg:
>      maxItems: 1
>  
> +  clocks:
> +    items:
> +      - description: rtc_clk is the operating frequency of crystal.
> +
> +  clock-names:
> +    maxItems: 1

You need to specify the name instead of maxItems.

> +
>    interrupts:
> -    minItems: 2
> +    maxItems: 2
>  
>    interrupt-names:
>      items:
> @@ -39,6 +46,7 @@ properties:
>      minimum: 0x1
>      maximum: 0x1FFFFF
>      default: 0x198233
> +    deprecated: true
>  
>  required:
>    - compatible
> @@ -61,5 +69,7 @@ examples:
>          interrupts = <0 26 4>, <0 27 4>;
>          interrupt-names = "alarm", "sec";
>          calibration = <0x198233>;
> +        clock-names = "rtc_clk";
> +        clocks = <&rtc_clk>;
>        };
>      };


Best regards,
Krzysztof

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH V8 3/3] rtc: zynqmp: Add calibration set and get support
  2022-06-13 12:58   ` Srinivas Neeli
@ 2022-06-27  7:39 ` Dan Carpenter
  -1 siblings, 0 replies; 18+ messages in thread
From: kernel test robot @ 2022-06-27  3:04 UTC (permalink / raw)
  To: kbuild

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

CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
In-Reply-To: <20220613125836.523449-3-srinivas.neeli@xilinx.com>
References: <20220613125836.523449-3-srinivas.neeli@xilinx.com>
TO: Srinivas Neeli <srinivas.neeli@xilinx.com>

Hi Srinivas,

I love your patch! Perhaps something to improve:

[auto build test WARNING on abelloni/rtc-next]
[also build test WARNING on v5.19-rc3 next-20220624]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Srinivas-Neeli/dt-bindings-rtc-zynqmp-Add-clock-information/20220614-013701
base:   https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git rtc-next
:::::: branch date: 12 days ago
:::::: commit date: 12 days ago
config: arc-randconfig-m031-20220622
compiler: arceb-elf-gcc (GCC) 11.3.0

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/rtc/rtc-zynqmp.c:238 xlnx_rtc_set_offset() error: uninitialized symbol 'fract_tick'.

vim +/fract_tick +238 drivers/rtc/rtc-zynqmp.c

2781fd75583878 Srinivas Neeli  2022-06-13  200  
2781fd75583878 Srinivas Neeli  2022-06-13  201  static int xlnx_rtc_set_offset(struct device *dev, long offset)
2781fd75583878 Srinivas Neeli  2022-06-13  202  {
2781fd75583878 Srinivas Neeli  2022-06-13  203  	struct xlnx_rtc_dev *xrtcdev = dev_get_drvdata(dev);
2781fd75583878 Srinivas Neeli  2022-06-13  204  	unsigned long long rtc_ppb = RTC_PPB;
2781fd75583878 Srinivas Neeli  2022-06-13  205  	unsigned int tick_mult = do_div(rtc_ppb, xrtcdev->freq);
2781fd75583878 Srinivas Neeli  2022-06-13  206  	unsigned char fract_tick;
2781fd75583878 Srinivas Neeli  2022-06-13  207  	unsigned int calibval;
2781fd75583878 Srinivas Neeli  2022-06-13  208  	short int  max_tick;
2781fd75583878 Srinivas Neeli  2022-06-13  209  	int fract_offset;
2781fd75583878 Srinivas Neeli  2022-06-13  210  
2781fd75583878 Srinivas Neeli  2022-06-13  211  	if (offset < RTC_MIN_OFFSET || offset > RTC_MAX_OFFSET)
2781fd75583878 Srinivas Neeli  2022-06-13  212  		return -ERANGE;
2781fd75583878 Srinivas Neeli  2022-06-13  213  
2781fd75583878 Srinivas Neeli  2022-06-13  214  	/* Number ticks for given offset */
2781fd75583878 Srinivas Neeli  2022-06-13  215  	max_tick = div_s64_rem(offset, tick_mult, &fract_offset);
2781fd75583878 Srinivas Neeli  2022-06-13  216  
2781fd75583878 Srinivas Neeli  2022-06-13  217  	/* Number fractional ticks for given offset */
2781fd75583878 Srinivas Neeli  2022-06-13  218  	if (fract_offset) {
2781fd75583878 Srinivas Neeli  2022-06-13  219  		if (fract_offset < 0) {
2781fd75583878 Srinivas Neeli  2022-06-13  220  			fract_offset = fract_offset + tick_mult;
2781fd75583878 Srinivas Neeli  2022-06-13  221  			max_tick--;
2781fd75583878 Srinivas Neeli  2022-06-13  222  		}
2781fd75583878 Srinivas Neeli  2022-06-13  223  		if (fract_offset > (tick_mult / RTC_FR_MAX_TICKS)) {
2781fd75583878 Srinivas Neeli  2022-06-13  224  			for (fract_tick = 1; fract_tick < 16; fract_tick++) {
2781fd75583878 Srinivas Neeli  2022-06-13  225  				if (fract_offset <=
2781fd75583878 Srinivas Neeli  2022-06-13  226  				    (fract_tick *
2781fd75583878 Srinivas Neeli  2022-06-13  227  				     (tick_mult / RTC_FR_MAX_TICKS)))
2781fd75583878 Srinivas Neeli  2022-06-13  228  					break;
2781fd75583878 Srinivas Neeli  2022-06-13  229  			}
2781fd75583878 Srinivas Neeli  2022-06-13  230  		}
2781fd75583878 Srinivas Neeli  2022-06-13  231  	}
2781fd75583878 Srinivas Neeli  2022-06-13  232  
2781fd75583878 Srinivas Neeli  2022-06-13  233  	/* Zynqmp RTC uses second and fractional tick
2781fd75583878 Srinivas Neeli  2022-06-13  234  	 * counters for compensation
11143c19eb57a8 Suneel Garapati 2015-08-19  235  	 */
2781fd75583878 Srinivas Neeli  2022-06-13  236  	calibval = max_tick + RTC_CALIB_DEF;
2781fd75583878 Srinivas Neeli  2022-06-13  237  
2781fd75583878 Srinivas Neeli  2022-06-13 @238  	if (fract_tick)
2781fd75583878 Srinivas Neeli  2022-06-13  239  		calibval |= RTC_FR_EN;
2781fd75583878 Srinivas Neeli  2022-06-13  240  
2781fd75583878 Srinivas Neeli  2022-06-13  241  	calibval |= (fract_tick << RTC_FR_DATSHIFT);
2781fd75583878 Srinivas Neeli  2022-06-13  242  
2781fd75583878 Srinivas Neeli  2022-06-13  243  	writel(calibval, (xrtcdev->reg_base + RTC_CALIB_WR));
2781fd75583878 Srinivas Neeli  2022-06-13  244  
2781fd75583878 Srinivas Neeli  2022-06-13  245  	return 0;
11143c19eb57a8 Suneel Garapati 2015-08-19  246  }
11143c19eb57a8 Suneel Garapati 2015-08-19  247  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

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

* Re: [PATCH V8 3/3] rtc: zynqmp: Add calibration set and get support
@ 2022-06-27  7:39 ` Dan Carpenter
  0 siblings, 0 replies; 18+ messages in thread
From: Dan Carpenter @ 2022-06-27  7:39 UTC (permalink / raw)
  To: kbuild-all

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

Hi Srinivas,

url:    https://github.com/intel-lab-lkp/linux/commits/Srinivas-Neeli/dt-bindings-rtc-zynqmp-Add-clock-information/20220614-013701
base:   https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git rtc-next
config: arc-randconfig-m031-20220622
compiler: arceb-elf-gcc (GCC) 11.3.0

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/rtc/rtc-zynqmp.c:238 xlnx_rtc_set_offset() error: uninitialized symbol 'fract_tick'.

vim +/fract_tick +238 drivers/rtc/rtc-zynqmp.c

2781fd75583878 Srinivas Neeli  2022-06-13  201  static int xlnx_rtc_set_offset(struct device *dev, long offset)
2781fd75583878 Srinivas Neeli  2022-06-13  202  {
2781fd75583878 Srinivas Neeli  2022-06-13  203  	struct xlnx_rtc_dev *xrtcdev = dev_get_drvdata(dev);
2781fd75583878 Srinivas Neeli  2022-06-13  204  	unsigned long long rtc_ppb = RTC_PPB;
2781fd75583878 Srinivas Neeli  2022-06-13  205  	unsigned int tick_mult = do_div(rtc_ppb, xrtcdev->freq);
2781fd75583878 Srinivas Neeli  2022-06-13  206  	unsigned char fract_tick;
2781fd75583878 Srinivas Neeli  2022-06-13  207  	unsigned int calibval;
2781fd75583878 Srinivas Neeli  2022-06-13  208  	short int  max_tick;
2781fd75583878 Srinivas Neeli  2022-06-13  209  	int fract_offset;
2781fd75583878 Srinivas Neeli  2022-06-13  210  
2781fd75583878 Srinivas Neeli  2022-06-13  211  	if (offset < RTC_MIN_OFFSET || offset > RTC_MAX_OFFSET)
2781fd75583878 Srinivas Neeli  2022-06-13  212  		return -ERANGE;
2781fd75583878 Srinivas Neeli  2022-06-13  213  
2781fd75583878 Srinivas Neeli  2022-06-13  214  	/* Number ticks for given offset */
2781fd75583878 Srinivas Neeli  2022-06-13  215  	max_tick = div_s64_rem(offset, tick_mult, &fract_offset);
2781fd75583878 Srinivas Neeli  2022-06-13  216  
2781fd75583878 Srinivas Neeli  2022-06-13  217  	/* Number fractional ticks for given offset */
2781fd75583878 Srinivas Neeli  2022-06-13  218  	if (fract_offset) {
2781fd75583878 Srinivas Neeli  2022-06-13  219  		if (fract_offset < 0) {
2781fd75583878 Srinivas Neeli  2022-06-13  220  			fract_offset = fract_offset + tick_mult;
2781fd75583878 Srinivas Neeli  2022-06-13  221  			max_tick--;
2781fd75583878 Srinivas Neeli  2022-06-13  222  		}
2781fd75583878 Srinivas Neeli  2022-06-13  223  		if (fract_offset > (tick_mult / RTC_FR_MAX_TICKS)) {
2781fd75583878 Srinivas Neeli  2022-06-13  224  			for (fract_tick = 1; fract_tick < 16; fract_tick++) {
2781fd75583878 Srinivas Neeli  2022-06-13  225  				if (fract_offset <=
2781fd75583878 Srinivas Neeli  2022-06-13  226  				    (fract_tick *
2781fd75583878 Srinivas Neeli  2022-06-13  227  				     (tick_mult / RTC_FR_MAX_TICKS)))
2781fd75583878 Srinivas Neeli  2022-06-13  228  					break;
2781fd75583878 Srinivas Neeli  2022-06-13  229  			}
2781fd75583878 Srinivas Neeli  2022-06-13  230  		}

"fract_tick" is non-zero on this path so probably it was supposed to be
set to zero@the start.


2781fd75583878 Srinivas Neeli  2022-06-13  231  	}
2781fd75583878 Srinivas Neeli  2022-06-13  232  
2781fd75583878 Srinivas Neeli  2022-06-13  233  	/* Zynqmp RTC uses second and fractional tick
2781fd75583878 Srinivas Neeli  2022-06-13  234  	 * counters for compensation
11143c19eb57a8 Suneel Garapati 2015-08-19  235  	 */
2781fd75583878 Srinivas Neeli  2022-06-13  236  	calibval = max_tick + RTC_CALIB_DEF;
2781fd75583878 Srinivas Neeli  2022-06-13  237  
2781fd75583878 Srinivas Neeli  2022-06-13 @238  	if (fract_tick)

Uninitialized.

2781fd75583878 Srinivas Neeli  2022-06-13  239  		calibval |= RTC_FR_EN;
2781fd75583878 Srinivas Neeli  2022-06-13  240  
2781fd75583878 Srinivas Neeli  2022-06-13  241  	calibval |= (fract_tick << RTC_FR_DATSHIFT);
2781fd75583878 Srinivas Neeli  2022-06-13  242  
2781fd75583878 Srinivas Neeli  2022-06-13  243  	writel(calibval, (xrtcdev->reg_base + RTC_CALIB_WR));
2781fd75583878 Srinivas Neeli  2022-06-13  244  
2781fd75583878 Srinivas Neeli  2022-06-13  245  	return 0;
11143c19eb57a8 Suneel Garapati 2015-08-19  246  }

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

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

* Re: [PATCH V8 3/3] rtc: zynqmp: Add calibration set and get support
  2022-07-01 13:52 kernel test robot
@ 2022-07-07  8:04 ` kernel test robot
  0 siblings, 0 replies; 18+ messages in thread
From: kernel test robot @ 2022-07-07  8:04 UTC (permalink / raw)
  To: Srinivas Neeli; +Cc: llvm, kbuild-all

Hi Srinivas,

Thanks for your patch! Perhaps something to improve:

[auto build test WARNING on abelloni/rtc-next]
[also build test WARNING on v5.19-rc4 next-20220701]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Srinivas-Neeli/dt-bindings-rtc-zynqmp-Add-clock-information/20220614-013701
base:   https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git rtc-next
config: arm-randconfig-c002-20220629 (https://download.01.org/0day-ci/archive/20220701/202207012151.nYCjgJqj-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project a774ba7f60d1fef403b5507b1b1a7475d3684d71)
reproduce (this is a W=1 build):
         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
         chmod +x ~/bin/make.cross
         # install arm cross compiling tool for clang build
         # apt-get install binutils-arm-linux-gnueabi
         # https://github.com/intel-lab-lkp/linux/commit/2781fd75583878d86f256113b19bb005dc83fb70
         git remote add linux-review https://github.com/intel-lab-lkp/linux
         git fetch --no-tags linux-review Srinivas-Neeli/dt-bindings-rtc-zynqmp-Add-clock-information/20220614-013701
         git checkout 2781fd75583878d86f256113b19bb005dc83fb70
         # save the config file
         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm clang-analyzer

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <yujie.liu@intel.com>


clang-analyzer warnings: (new ones prefixed by >>)

 >> drivers/rtc/rtc-zynqmp.c:238:6: warning: Branch condition evaluates to a garbage value [clang-analyzer-core.uninitialized.Branch]
            if (fract_tick)
                ^~~~~~~~~~
    drivers/rtc/rtc-zynqmp.c:206:2: note: 'fract_tick' declared without an initial value
            unsigned char fract_tick;
            ^~~~~~~~~~~~~~~~~~~~~~~~
    drivers/rtc/rtc-zynqmp.c:211:6: note: Assuming the condition is false
            if (offset < RTC_MIN_OFFSET || offset > RTC_MAX_OFFSET)
                ^~~~~~~~~~~~~~~~~~~~~~~
    drivers/rtc/rtc-zynqmp.c:211:6: note: Left side of '||' is false
    drivers/rtc/rtc-zynqmp.c:211:33: note: Assuming 'offset' is <= RTC_MAX_OFFSET
            if (offset < RTC_MIN_OFFSET || offset > RTC_MAX_OFFSET)
                                           ^~~~~~~~~~~~~~~~~~~~~~~
    drivers/rtc/rtc-zynqmp.c:211:2: note: Taking false branch
            if (offset < RTC_MIN_OFFSET || offset > RTC_MAX_OFFSET)
            ^
    drivers/rtc/rtc-zynqmp.c:218:6: note: Assuming 'fract_offset' is 0
            if (fract_offset) {
                ^~~~~~~~~~~~
    drivers/rtc/rtc-zynqmp.c:218:2: note: Taking false branch
            if (fract_offset) {
            ^
    drivers/rtc/rtc-zynqmp.c:238:6: note: Branch condition evaluates to a garbage value
            if (fract_tick)
                ^~~~~~~~~~

vim +238 drivers/rtc/rtc-zynqmp.c

2781fd75583878 Srinivas Neeli  2022-06-13  200
2781fd75583878 Srinivas Neeli  2022-06-13  201  static int xlnx_rtc_set_offset(struct device *dev, long offset)
2781fd75583878 Srinivas Neeli  2022-06-13  202  {
2781fd75583878 Srinivas Neeli  2022-06-13  203  	struct xlnx_rtc_dev *xrtcdev = dev_get_drvdata(dev);
2781fd75583878 Srinivas Neeli  2022-06-13  204  	unsigned long long rtc_ppb = RTC_PPB;
2781fd75583878 Srinivas Neeli  2022-06-13  205  	unsigned int tick_mult = do_div(rtc_ppb, xrtcdev->freq);
2781fd75583878 Srinivas Neeli  2022-06-13 @206  	unsigned char fract_tick;
2781fd75583878 Srinivas Neeli  2022-06-13  207  	unsigned int calibval;
2781fd75583878 Srinivas Neeli  2022-06-13  208  	short int  max_tick;
2781fd75583878 Srinivas Neeli  2022-06-13  209  	int fract_offset;
2781fd75583878 Srinivas Neeli  2022-06-13  210
2781fd75583878 Srinivas Neeli  2022-06-13  211  	if (offset < RTC_MIN_OFFSET || offset > RTC_MAX_OFFSET)
2781fd75583878 Srinivas Neeli  2022-06-13  212  		return -ERANGE;
2781fd75583878 Srinivas Neeli  2022-06-13  213
2781fd75583878 Srinivas Neeli  2022-06-13  214  	/* Number ticks for given offset */
2781fd75583878 Srinivas Neeli  2022-06-13  215  	max_tick = div_s64_rem(offset, tick_mult, &fract_offset);
2781fd75583878 Srinivas Neeli  2022-06-13  216
2781fd75583878 Srinivas Neeli  2022-06-13  217  	/* Number fractional ticks for given offset */
2781fd75583878 Srinivas Neeli  2022-06-13  218  	if (fract_offset) {
2781fd75583878 Srinivas Neeli  2022-06-13  219  		if (fract_offset < 0) {
2781fd75583878 Srinivas Neeli  2022-06-13  220  			fract_offset = fract_offset + tick_mult;
2781fd75583878 Srinivas Neeli  2022-06-13  221  			max_tick--;
2781fd75583878 Srinivas Neeli  2022-06-13  222  		}
2781fd75583878 Srinivas Neeli  2022-06-13  223  		if (fract_offset > (tick_mult / RTC_FR_MAX_TICKS)) {
2781fd75583878 Srinivas Neeli  2022-06-13  224  			for (fract_tick = 1; fract_tick < 16; fract_tick++) {
2781fd75583878 Srinivas Neeli  2022-06-13  225  				if (fract_offset <=
2781fd75583878 Srinivas Neeli  2022-06-13  226  				    (fract_tick *
2781fd75583878 Srinivas Neeli  2022-06-13  227  				     (tick_mult / RTC_FR_MAX_TICKS)))
2781fd75583878 Srinivas Neeli  2022-06-13  228  					break;
2781fd75583878 Srinivas Neeli  2022-06-13  229  			}
2781fd75583878 Srinivas Neeli  2022-06-13  230  		}
2781fd75583878 Srinivas Neeli  2022-06-13  231  	}
2781fd75583878 Srinivas Neeli  2022-06-13  232
2781fd75583878 Srinivas Neeli  2022-06-13  233  	/* Zynqmp RTC uses second and fractional tick
2781fd75583878 Srinivas Neeli  2022-06-13  234  	 * counters for compensation
11143c19eb57a8 Suneel Garapati 2015-08-19  235  	 */
2781fd75583878 Srinivas Neeli  2022-06-13  236  	calibval = max_tick + RTC_CALIB_DEF;
2781fd75583878 Srinivas Neeli  2022-06-13  237
2781fd75583878 Srinivas Neeli  2022-06-13 @238  	if (fract_tick)
2781fd75583878 Srinivas Neeli  2022-06-13  239  		calibval |= RTC_FR_EN;
2781fd75583878 Srinivas Neeli  2022-06-13  240
2781fd75583878 Srinivas Neeli  2022-06-13  241  	calibval |= (fract_tick << RTC_FR_DATSHIFT);
2781fd75583878 Srinivas Neeli  2022-06-13  242
2781fd75583878 Srinivas Neeli  2022-06-13  243  	writel(calibval, (xrtcdev->reg_base + RTC_CALIB_WR));
2781fd75583878 Srinivas Neeli  2022-06-13  244
2781fd75583878 Srinivas Neeli  2022-06-13  245  	return 0;
11143c19eb57a8 Suneel Garapati 2015-08-19  246  }
11143c19eb57a8 Suneel Garapati 2015-08-19  247

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

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

* Re: [PATCH V8 3/3] rtc: zynqmp: Add calibration set and get support
@ 2022-07-01 13:52 kernel test robot
  2022-07-07  8:04 ` kernel test robot
  0 siblings, 1 reply; 18+ messages in thread
From: kernel test robot @ 2022-07-01 13:52 UTC (permalink / raw)
  To: kbuild

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

:::::: 
:::::: Manual check reason: "low confidence static check warning: drivers/rtc/rtc-zynqmp.c:238:6: warning: Branch condition evaluates to a garbage value [clang-analyzer-core.uninitialized.Branch]"
:::::: 

CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
In-Reply-To: <20220613125836.523449-3-srinivas.neeli@xilinx.com>
References: <20220613125836.523449-3-srinivas.neeli@xilinx.com>
TO: Srinivas Neeli <srinivas.neeli@xilinx.com>

Hi Srinivas,

I love your patch! Perhaps something to improve:

[auto build test WARNING on abelloni/rtc-next]
[also build test WARNING on v5.19-rc4 next-20220701]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Srinivas-Neeli/dt-bindings-rtc-zynqmp-Add-clock-information/20220614-013701
base:   https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git rtc-next
:::::: branch date: 3 weeks ago
:::::: commit date: 3 weeks ago
config: arm-randconfig-c002-20220629 (https://download.01.org/0day-ci/archive/20220701/202207012151.nYCjgJqj-lkp(a)intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project a774ba7f60d1fef403b5507b1b1a7475d3684d71)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # https://github.com/intel-lab-lkp/linux/commit/2781fd75583878d86f256113b19bb005dc83fb70
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Srinivas-Neeli/dt-bindings-rtc-zynqmp-Add-clock-information/20220614-013701
        git checkout 2781fd75583878d86f256113b19bb005dc83fb70
        # save the config file
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm clang-analyzer 

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>


clang-analyzer warnings: (new ones prefixed by >>)
           ^
   drivers/usb/gadget/function/f_fs.c:1884:2: note: Taking true branch
           if (!WARN_ON(!ffs->gadget)) {
           ^
   drivers/usb/gadget/function/f_fs.c:1888:3: note: '?' condition is true
                   clear_bit(FFS_FL_BOUND, &ffs->flags);
                   ^
   arch/arm/include/asm/bitops.h:190:27: note: expanded from macro 'clear_bit'
   #define clear_bit(nr,p)                 ATOMIC_BITOP(clear_bit,nr,p)
                                           ^
   arch/arm/include/asm/bitops.h:181:3: note: expanded from macro 'ATOMIC_BITOP'
           (__builtin_constant_p(nr) ? ____atomic_##name(nr, p) : _##name(nr,p))
            ^
   drivers/usb/gadget/function/f_fs.c:1889:3: note: Calling 'ffs_data_put'
                   ffs_data_put(ffs);
                   ^~~~~~~~~~~~~~~~~
   drivers/usb/gadget/function/f_fs.c:1697:2: note: Loop condition is false.  Exiting loop
           ENTER();
           ^
   drivers/usb/gadget/function/u_fs.h:35:20: note: expanded from macro 'ENTER'
   #define ENTER()    pr_vdebug("%s()\n", __func__)
                      ^
   drivers/usb/gadget/function/u_fs.h:30:42: note: expanded from macro 'pr_vdebug'
   #  define pr_vdebug(...)                 do { } while (0)
                                            ^
   drivers/usb/gadget/function/f_fs.c:1699:2: note: Taking true branch
           if (refcount_dec_and_test(&ffs->ref)) {
           ^
   drivers/usb/gadget/function/f_fs.c:1700:3: note: Loop condition is false.  Exiting loop
                   pr_info("%s(): freeing\n", __func__);
                   ^
   include/linux/printk.h:548:2: note: expanded from macro 'pr_info'
           printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
           ^
   include/linux/printk.h:475:26: note: expanded from macro 'printk'
   #define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__)
                            ^
   include/linux/printk.h:446:3: note: expanded from macro 'printk_index_wrap'
                   __printk_index_emit(_fmt, NULL, NULL);                  \
                   ^
   include/linux/printk.h:421:34: note: expanded from macro '__printk_index_emit'
   #define __printk_index_emit(...) do {} while (0)
                                    ^
   drivers/usb/gadget/function/f_fs.c:1703:10: note: Assuming the condition is true
                   BUG_ON(waitqueue_active(&ffs->ev.waitq) ||
                          ^
   include/asm-generic/bug.h:71:45: note: expanded from macro 'BUG_ON'
   #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
                                               ^~~~~~~~~
   include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
   # define unlikely(x)    __builtin_expect(!!(x), 0)
                                               ^
   drivers/usb/gadget/function/f_fs.c:1703:43: note: Left side of '||' is true
                   BUG_ON(waitqueue_active(&ffs->ev.waitq) ||
                                                           ^
   drivers/usb/gadget/function/f_fs.c:1703:3: note: Assuming the condition is false
                   BUG_ON(waitqueue_active(&ffs->ev.waitq) ||
                   ^
   include/asm-generic/bug.h:71:36: note: expanded from macro 'BUG_ON'
   #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
                                      ^~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:78:22: note: expanded from macro 'unlikely'
   # define unlikely(x)    __builtin_expect(!!(x), 0)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/usb/gadget/function/f_fs.c:1703:3: note: Taking false branch
                   BUG_ON(waitqueue_active(&ffs->ev.waitq) ||
                   ^
   include/asm-generic/bug.h:71:32: note: expanded from macro 'BUG_ON'
   #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
                                  ^
   drivers/usb/gadget/function/f_fs.c:1703:3: note: Loop condition is false.  Exiting loop
                   BUG_ON(waitqueue_active(&ffs->ev.waitq) ||
                   ^
   include/asm-generic/bug.h:71:27: note: expanded from macro 'BUG_ON'
   #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
                             ^
   drivers/usb/gadget/function/f_fs.c:1708:3: note: Memory is released
                   kfree(ffs);
                   ^~~~~~~~~~
   drivers/usb/gadget/function/f_fs.c:1889:3: note: Returning; memory was released via 1st parameter
                   ffs_data_put(ffs);
                   ^~~~~~~~~~~~~~~~~
   drivers/usb/gadget/function/f_fs.c:3605:3: note: Returning; memory was released via 1st parameter
                   functionfs_unbind(ffs);
                   ^~~~~~~~~~~~~~~~~~~~~~
   drivers/usb/gadget/function/f_fs.c:3608:2: note: Calling 'spinlock_check'
           spin_lock_irqsave(&func->ffs->eps_lock, flags);
           ^
   include/linux/spinlock.h:379:24: note: expanded from macro 'spin_lock_irqsave'
           raw_spin_lock_irqsave(spinlock_check(lock), flags);     \
           ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/spinlock.h:242:34: note: expanded from macro 'raw_spin_lock_irqsave'
                   flags = _raw_spin_lock_irqsave(lock);   \
                                                  ^~~~
   include/linux/spinlock.h:324:2: note: Use of memory after it is freed
           return &lock->rlock;
           ^      ~~~~~~~~~~~~
   Suppressed 44 warnings (43 in non-user code, 1 with check filters).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   32 warnings generated.
>> drivers/rtc/rtc-zynqmp.c:238:6: warning: Branch condition evaluates to a garbage value [clang-analyzer-core.uninitialized.Branch]
           if (fract_tick)
               ^~~~~~~~~~
   drivers/rtc/rtc-zynqmp.c:205:27: note: Left side of '&&' is false
           unsigned int tick_mult = do_div(rtc_ppb, xrtcdev->freq);
                                    ^
   include/asm-generic/div64.h:223:35: note: expanded from macro 'do_div'
           if (__builtin_constant_p(__base) &&             \
                                            ^
   drivers/rtc/rtc-zynqmp.c:205:27: note: Left side of '&&' is false
           unsigned int tick_mult = do_div(rtc_ppb, xrtcdev->freq);
                                    ^
   include/asm-generic/div64.h:227:42: note: expanded from macro 'do_div'
           } else if (__builtin_constant_p(__base) &&      \
                                                   ^
   drivers/rtc/rtc-zynqmp.c:205:27: note: Taking true branch
           unsigned int tick_mult = do_div(rtc_ppb, xrtcdev->freq);
                                    ^
   include/asm-generic/div64.h:234:9: note: expanded from macro 'do_div'
           } else if (likely(((n) >> 32) == 0)) {          \
                  ^
   drivers/rtc/rtc-zynqmp.c:206:2: note: 'fract_tick' declared without an initial value
           unsigned char fract_tick;
           ^~~~~~~~~~~~~~~~~~~~~~~~
   drivers/rtc/rtc-zynqmp.c:211:6: note: Assuming the condition is false
           if (offset < RTC_MIN_OFFSET || offset > RTC_MAX_OFFSET)
               ^~~~~~~~~~~~~~~~~~~~~~~
   drivers/rtc/rtc-zynqmp.c:211:6: note: Left side of '||' is false
   drivers/rtc/rtc-zynqmp.c:211:33: note: Assuming 'offset' is <= RTC_MAX_OFFSET
           if (offset < RTC_MIN_OFFSET || offset > RTC_MAX_OFFSET)
                                          ^~~~~~~~~~~~~~~~~~~~~~~
   drivers/rtc/rtc-zynqmp.c:211:2: note: Taking false branch
           if (offset < RTC_MIN_OFFSET || offset > RTC_MAX_OFFSET)
           ^
   drivers/rtc/rtc-zynqmp.c:218:6: note: Assuming 'fract_offset' is 0
           if (fract_offset) {
               ^~~~~~~~~~~~
   drivers/rtc/rtc-zynqmp.c:218:2: note: Taking false branch
           if (fract_offset) {
           ^
   drivers/rtc/rtc-zynqmp.c:238:6: note: Branch condition evaluates to a garbage value
           if (fract_tick)
               ^~~~~~~~~~
   Suppressed 31 warnings (29 in non-user code, 2 with check filters).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   42 warnings generated.
   Suppressed 42 warnings (42 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   51 warnings generated.
   drivers/i2c/i2c-core-base.c:645:9: warning: Call to function 'sprintf' is insecure as it does not provide bounding of the memory buffer or security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           return sprintf(buf, "%s\n", dev->type == &i2c_client_type ?
                  ^~~~~~~
   drivers/i2c/i2c-core-base.c:645:9: note: Call to function 'sprintf' is insecure as it does not provide bounding of the memory buffer or security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11
           return sprintf(buf, "%s\n", dev->type == &i2c_client_type ?
                  ^~~~~~~
   drivers/i2c/i2c-core-base.c:664:9: warning: Call to function 'sprintf' is insecure as it does not provide bounding of the memory buffer or security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           return sprintf(buf, "%s%s\n", I2C_MODULE_PREFIX, client->name);
                  ^~~~~~~
   drivers/i2c/i2c-core-base.c:664:9: note: Call to function 'sprintf' is insecure as it does not provide bounding of the memory buffer or security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11
           return sprintf(buf, "%s%s\n", I2C_MODULE_PREFIX, client->name);
                  ^~~~~~~
   drivers/i2c/i2c-core-base.c:1185:2: warning: Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           memset(&info, 0, sizeof(struct i2c_board_info));
           ^~~~~~
   drivers/i2c/i2c-core-base.c:1185:2: note: Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11
           memset(&info, 0, sizeof(struct i2c_board_info));
           ^~~~~~
   drivers/i2c/i2c-core-base.c:1196:2: warning: Call to function 'memcpy' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memcpy_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           memcpy(info.type, buf, blank - buf);
           ^~~~~~
   drivers/i2c/i2c-core-base.c:1196:2: note: Call to function 'memcpy' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memcpy_s' in case of C11
           memcpy(info.type, buf, blank - buf);
           ^~~~~~
   drivers/i2c/i2c-core-base.c:1199:8: warning: Call to function 'sscanf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sscanf_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           res = sscanf(++blank, "%hi%c", &info.addr, &end);
                 ^~~~~~
   drivers/i2c/i2c-core-base.c:1199:8: note: Call to function 'sscanf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sscanf_s' in case of C11
           res = sscanf(++blank, "%hi%c", &info.addr, &end);
                 ^~~~~~
   drivers/i2c/i2c-core-base.c:1254:8: warning: Call to function 'sscanf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sscanf_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           res = sscanf(buf, "%hi%c", &addr, &end);
                 ^~~~~~
   drivers/i2c/i2c-core-base.c:1254:8: note: Call to function 'sscanf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sscanf_s' in case of C11
           res = sscanf(buf, "%hi%c", &addr, &end);
                 ^~~~~~
   drivers/i2c/i2c-core-base.c:1740:2: warning: Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           memset(&adap->dev, 0, sizeof(adap->dev));
           ^~~~~~
   drivers/i2c/i2c-core-base.c:1740:2: note: Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11
           memset(&adap->dev, 0, sizeof(adap->dev));
           ^~~~~~
   drivers/i2c/i2c-core-base.c:2316:2: warning: Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           memset(&info, 0, sizeof(struct i2c_board_info));
           ^~~~~~
   drivers/i2c/i2c-core-base.c:2316:2: note: Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11
           memset(&info, 0, sizeof(struct i2c_board_info));
           ^~~~~~
   drivers/i2c/i2c-core-base.c:2521:3: warning: Call to function 'memcpy' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memcpy_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
                   memcpy(msg->buf, buf, msg->len);
                   ^~~~~~
   drivers/i2c/i2c-core-base.c:2521:3: note: Call to function 'memcpy' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memcpy_s' in case of C11

vim +238 drivers/rtc/rtc-zynqmp.c

2781fd75583878 Srinivas Neeli  2022-06-13  200  
2781fd75583878 Srinivas Neeli  2022-06-13  201  static int xlnx_rtc_set_offset(struct device *dev, long offset)
2781fd75583878 Srinivas Neeli  2022-06-13  202  {
2781fd75583878 Srinivas Neeli  2022-06-13  203  	struct xlnx_rtc_dev *xrtcdev = dev_get_drvdata(dev);
2781fd75583878 Srinivas Neeli  2022-06-13  204  	unsigned long long rtc_ppb = RTC_PPB;
2781fd75583878 Srinivas Neeli  2022-06-13  205  	unsigned int tick_mult = do_div(rtc_ppb, xrtcdev->freq);
2781fd75583878 Srinivas Neeli  2022-06-13  206  	unsigned char fract_tick;
2781fd75583878 Srinivas Neeli  2022-06-13  207  	unsigned int calibval;
2781fd75583878 Srinivas Neeli  2022-06-13  208  	short int  max_tick;
2781fd75583878 Srinivas Neeli  2022-06-13  209  	int fract_offset;
2781fd75583878 Srinivas Neeli  2022-06-13  210  
2781fd75583878 Srinivas Neeli  2022-06-13  211  	if (offset < RTC_MIN_OFFSET || offset > RTC_MAX_OFFSET)
2781fd75583878 Srinivas Neeli  2022-06-13  212  		return -ERANGE;
2781fd75583878 Srinivas Neeli  2022-06-13  213  
2781fd75583878 Srinivas Neeli  2022-06-13  214  	/* Number ticks for given offset */
2781fd75583878 Srinivas Neeli  2022-06-13  215  	max_tick = div_s64_rem(offset, tick_mult, &fract_offset);
2781fd75583878 Srinivas Neeli  2022-06-13  216  
2781fd75583878 Srinivas Neeli  2022-06-13  217  	/* Number fractional ticks for given offset */
2781fd75583878 Srinivas Neeli  2022-06-13  218  	if (fract_offset) {
2781fd75583878 Srinivas Neeli  2022-06-13  219  		if (fract_offset < 0) {
2781fd75583878 Srinivas Neeli  2022-06-13  220  			fract_offset = fract_offset + tick_mult;
2781fd75583878 Srinivas Neeli  2022-06-13  221  			max_tick--;
2781fd75583878 Srinivas Neeli  2022-06-13  222  		}
2781fd75583878 Srinivas Neeli  2022-06-13  223  		if (fract_offset > (tick_mult / RTC_FR_MAX_TICKS)) {
2781fd75583878 Srinivas Neeli  2022-06-13  224  			for (fract_tick = 1; fract_tick < 16; fract_tick++) {
2781fd75583878 Srinivas Neeli  2022-06-13  225  				if (fract_offset <=
2781fd75583878 Srinivas Neeli  2022-06-13  226  				    (fract_tick *
2781fd75583878 Srinivas Neeli  2022-06-13  227  				     (tick_mult / RTC_FR_MAX_TICKS)))
2781fd75583878 Srinivas Neeli  2022-06-13  228  					break;
2781fd75583878 Srinivas Neeli  2022-06-13  229  			}
2781fd75583878 Srinivas Neeli  2022-06-13  230  		}
2781fd75583878 Srinivas Neeli  2022-06-13  231  	}
2781fd75583878 Srinivas Neeli  2022-06-13  232  
2781fd75583878 Srinivas Neeli  2022-06-13  233  	/* Zynqmp RTC uses second and fractional tick
2781fd75583878 Srinivas Neeli  2022-06-13  234  	 * counters for compensation
11143c19eb57a8 Suneel Garapati 2015-08-19  235  	 */
2781fd75583878 Srinivas Neeli  2022-06-13  236  	calibval = max_tick + RTC_CALIB_DEF;
2781fd75583878 Srinivas Neeli  2022-06-13  237  
2781fd75583878 Srinivas Neeli  2022-06-13 @238  	if (fract_tick)
2781fd75583878 Srinivas Neeli  2022-06-13  239  		calibval |= RTC_FR_EN;
2781fd75583878 Srinivas Neeli  2022-06-13  240  
2781fd75583878 Srinivas Neeli  2022-06-13  241  	calibval |= (fract_tick << RTC_FR_DATSHIFT);
2781fd75583878 Srinivas Neeli  2022-06-13  242  
2781fd75583878 Srinivas Neeli  2022-06-13  243  	writel(calibval, (xrtcdev->reg_base + RTC_CALIB_WR));
2781fd75583878 Srinivas Neeli  2022-06-13  244  
2781fd75583878 Srinivas Neeli  2022-06-13  245  	return 0;
11143c19eb57a8 Suneel Garapati 2015-08-19  246  }
11143c19eb57a8 Suneel Garapati 2015-08-19  247  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

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

end of thread, other threads:[~2022-07-07  8:04 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-27  3:04 [PATCH V8 3/3] rtc: zynqmp: Add calibration set and get support kernel test robot
2022-06-27  7:39 ` Dan Carpenter
  -- strict thread matches above, loose matches on Subject: below --
2022-07-01 13:52 kernel test robot
2022-07-07  8:04 ` kernel test robot
2022-06-13 12:58 [PATCH V8 1/3] dt-bindings: rtc: zynqmp: Add clock information Srinivas Neeli
2022-06-13 12:58 ` Srinivas Neeli
2022-06-13 12:58 ` [PATCH V8 2/3] rtc: zynqmp: Updated calibration value Srinivas Neeli
2022-06-13 12:58   ` Srinivas Neeli
2022-06-14 11:39   ` Peter Korsgaard
2022-06-14 11:39     ` Peter Korsgaard
2022-06-13 12:58 ` [PATCH V8 3/3] rtc: zynqmp: Add calibration set and get support Srinivas Neeli
2022-06-13 12:58   ` Srinivas Neeli
2022-06-14  4:04   ` kernel test robot
2022-06-14  4:24   ` kernel test robot
2022-06-14 20:51 ` [PATCH V8 1/3] dt-bindings: rtc: zynqmp: Add clock information Rob Herring
2022-06-14 20:51   ` Rob Herring
2022-06-18  0:38 ` Krzysztof Kozlowski
2022-06-18  0:38   ` Krzysztof Kozlowski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.