Add watchdog DT nodes and parse it to read PMU registers addresses
Subsystems (3)
cover Add watchdog DT nodes and parse it to read PMU registers addresses
This patchset does the following things
- Fixes the watchdog DT node name to follow convention
- Adds watchdog DT node to Exynos5420 SoC
- parse the watchdog device node to read pmu wdt sys registers addresses and do mask/unmask enable/disable of WDT in probe and s2r scenarios.
This patch set is rebased on Kgene's for-next branch and tested on SMDK5420
Leela Krishna Amudala (4):
ARM: dts: Fix the watchdog DT node name for Exynos5
ARM: dts: add watchdog device tree node for exynos5420
watchdog: s3c2410_wdt: parse watchdog dt node to read PMU registers
adresses
ARM: dts: exynos: add PMU registers addresses and mask bit to
watchdog node
.../devicetree/bindings/watchdog/samsung-wdt.txt | 14 ++++- arch/arm/boot/dts/exynos5.dtsi | 4 +- arch/arm/boot/dts/exynos5250.dtsi | 4 +- arch/arm/boot/dts/exynos5420.dtsi | 7 +++ drivers/watchdog/s3c2410_wdt.c | 56 ++++++++++++++++++++ 5 files changed, 81 insertions(+), 4 deletions(-)
Signature · 1 line
1.7.9.5
PATCH 1/4 ARM: dts: Fix the watchdog DT node name for Exynos5
Fixes the watchdog DT node name for Exynos5 as per the DT node naming convention also update "status" property for Exynos5250 SoC.
--- arch/arm/boot/dts/exynos5.dtsi | 2 +- arch/arm/boot/dts/exynos5250.dtsi | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
arch/arm/boot/dts/exynos5.dtsi +1 -1
@@ -102,7 +102,7 @@ status = "disabled"; }; - watchdog { + watchdog@101D0000 { compatible = "samsung,s3c2410-wdt"; reg = <0x101D0000 0x100>; interrupts = <0 42 0>;
arch/arm/boot/dts/exynos5250.dtsi +2 -1
@@ -158,9 +158,10 @@ interrupts = <0 47 0>; }; - watchdog { + watchdog@101D0000 { clocks = <&clock 336>; clock-names = "watchdog"; + status = "okay"; }; g2d@10850000 {
Signature · 1 line
1.7.9.5
A message that is not in the archive (sent off-list or not yet received): 1379414623-26329-1-git-send-email-l.krishna-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org
PATCH 2/4 ARM: dts: add watchdog device tree node for exynos5420
Add watchdog device tree node for exynos5420
--- arch/arm/boot/dts/exynos5420.dtsi | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm/boot/dts/exynos5420.dtsi +6 -0
@@ -186,6 +186,12 @@ status = "okay"; }; + watchdog@101D0000 { + clocks = <&clock 316>; + clock-names = "watchdog"; + status = "okay"; + }; + serial@12C00000 { clocks = <&clock 257>, <&clock 128>; clock-names = "uart", "clk_uart_baud0";
Signature · 1 line
1.7.9.5
PATCH 3/4 watchdog: s3c2410_wdt: parse watchdog dt node to read PMU registers adresses
In reply to a message not in the archiveThis patch parses the watchdog node to read pmu wdt sys registers addresses and do mask/unmask enable/disable of WDT in probe and s2r scenarios.
--- .../devicetree/bindings/watchdog/samsung-wdt.txt | 14 ++++- drivers/watchdog/s3c2410_wdt.c | 56 ++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/watchdog/samsung-wdt.txt +13 -1
@@ -7,8 +7,20 @@ occurred. Required properties: - compatible : should be "samsung,s3c2410-wdt" - reg : base physical address of the controller and length of memory mapped - region. + region and the optional (addresses and length of memory mapped regions + of) PMU registers for masking/unmasking WDT. - interrupts : interrupt number to the cpu. Optional properties: - timeout-sec : contains the watchdog timeout in seconds. +- reset-mask-bit: bit number in the PMU registers to program mask/unmask WDT. + +Example: + +watchdog { + compatible = "samsung,s3c2410-wdt"; + reg = <0x101D0000 0x100>, <0x10040408 0x4>, <0x1004040c 0x4>; + interrupts = <0 42 0>; + status = "disabled"; + reset-mask-bit = <0>; +};
drivers/watchdog/s3c2410_wdt.c +56 -0
110 lines not on this page · raw message
Signature · 1 line
1.7.9.5
A message that is not in the archive (sent off-list or not yet received): 1379414623-26329-4-git-send-email-l.krishna-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org
Re: [PATCH 3/4] watchdog: s3c2410_wdt: parse watchdog dt node to read PMU registers adresses
Hi Leela,
Please see my comments below.
Quoted 17 lines · On Tuesday 17 of September 2013 16:13:42 Leela Krishna Amudala wrote:
This patch parses the watchdog node to read pmu wdt sys registers addresses and do mask/unmask enable/disable of WDT in probe and s2r scenarios.
Reviewed-by Doug Anderson <[email protected]>Signed-off-by Leela Krishna Amudala <[email protected]>--- .../devicetree/bindings/watchdog/samsung-wdt.txt | 14 ++++- drivers/watchdog/s3c2410_wdt.c | 56++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-)
(quoted diff) +0
-0
b/Documentation/devicetree/bindings/watchdog/samsung-wdt.txtindex 2aa486c..4c798e3 100644
Documentation/devicetree/bindings/watchdog/samsung-wdt.txt occurred. · line 8
Quoted 2 lines
Documentation/devicetree/bindings/watchdog/samsung-wdt.txt +0
-0@@ -7,8 +7,20 @@ occurred. Required properties: - compatible : should be "samsung,s3c2410-wdt"
Since the WDT block of Exynos 5420 needs some extra configuration in PMU registers, it is no longer compatible with samsung.s3c2410-wdt. Please introduce separate compatible ("samsung,exynos5420-wdt") and make the driver handle the additional configuration only if running on a device with this compatible value.
I'd suggest introducing quirk system to the driver and adding a NEEDS_PMU_CONFIG quirk selected by DT match entry with "samsung,exynos5420- wdt" compatible.
Quoted 10 lines
Documentation/devicetree/bindings/watchdog/samsung-wdt.txt +0
-0- reg : base physical address of the controller and length of memorymapped - region.
Documentation/devicetree/bindings/watchdog/samsung-wdt.txt +3
-0+ region and the optional (addresses and length of memory mapped regions + of) PMU registers for masking/unmasking WDT. - interrupts : interrupt number to the cpu. Optional properties: - timeout-sec : contains the watchdog timeout in seconds. +- reset-mask-bit: bit number in the PMU registers to program mask/unmaskWDT. +
I believe this is mandatory on Exynos 5420 and unused on previous SoCs. It should be handled depending on compatible value.
Quoted 1 line
[...]
Documentation/devicetree/bindings/watchdog/samsung-wdt.txt
Quoted 7 lines
+static void
s3c2410wdt_mask_and_disable_reset(int mask, struct s3c2410_wdt *wdt)+{Documentation/devicetree/bindings/watchdog/samsung-wdt.txt +5
-0+ unsigned int value; + + if (IS_ERR(wdt->pmu_disable_reg) || IS_ERR(wdt->pmu_mask_reset_reg) + || (wdt->pmu_mask_bit < 0)) + return;
This function could be called only if respective quirk is active and the check above could be dropped.
Quoted 8 lines
Documentation/devicetree/bindings/watchdog/samsung-wdt.txt +8
-0+ + if (mask) { + value = readl(wdt->pmu_disable_reg); + value |= (1 << wdt->pmu_mask_bit); + writel(value, wdt->pmu_disable_reg); + + value = readl(wdt->pmu_mask_reset_reg); + value |= (1 << wdt->pmu_mask_bit);
Documentation/devicetree/bindings/watchdog/samsung-wdt.txt
Quoted 10 lines
Documentation/devicetree/bindings/watchdog/samsung-wdt.txt +10
-0+ writel(value, wdt->pmu_mask_reset_reg); + } else { + value = readl(wdt->pmu_disable_reg); + value &= ~(1 << wdt->pmu_mask_bit); + writel(value, wdt->pmu_disable_reg); + + value = readl(wdt->pmu_mask_reset_reg); + value &= ~(1 << wdt->pmu_mask_bit); + writel(value, wdt->pmu_mask_reset_reg); + }
This can be greatly simplified by moving readl and writel outside the conditional block, i.e.
u32 disable, mask_reset;
disable = readl(wdt->pmu_disable_reg);
mask_reset = readl(wdt->pmu_mask_reset_reg);
if (mask) {
disable |= (1 << wdt->pmu_mask_bit);
mask_reset |= (1 << wdt->pmu_mask_bit);
} else {
disable &= ~(1 << wdt->pmu_mask_bit);
mask_reset &= ~(1 << wdt->pmu_mask_bit);
}
writel(disable, wdt->pmu_disable_reg);
writel(mask_reset, wdt->pmu_mask_reset_reg);Quoted 15 lines
Documentation/devicetree/bindings/watchdog/samsung-wdt.txt +4
-0+} + static int s3c2410wdt_keepalive(struct watchdog_device *wdd) { struct s3c2410_wdt *wdt = watchdog_get_drvdata(wdd);@@ -341,6 +371,8 @@ static int s3c2410wdt_probe(struct platform_device *pdev) unsigned int wtcon; int started = 0; int ret; + struct resource *res; + unsigned int mask_bit; DBG("%s: probe=%p\n", __func__, pdev);
Documentation/devicetree/bindings/watchdog/samsung-wdt.txt static int s3c2410wdt_probe(struct platform_device · line 402
Quoted 2 lines
Documentation/devicetree/bindings/watchdog/samsung-wdt.txt +0
-0@@ -369,6 +401,25 @@ static int s3c2410wdt_probe(struct platform_device *pdev) goto err; }
The code added below could be handled conditionally and missing PMU registers could simply trigger an error.
Quoted 23 lines
Documentation/devicetree/bindings/watchdog/samsung-wdt.txt +18
-0+ res = platform_get_resource(pdev, IORESOURCE_MEM, 1); + wdt->pmu_disable_reg = devm_ioremap_resource(&pdev->dev, res); + + res = platform_get_resource(pdev, IORESOURCE_MEM, 2); + wdt->pmu_mask_reset_reg = devm_ioremap_resource(&pdev->dev, res); + + if (!IS_ERR(wdt->pmu_disable_reg) && !IS_ERR(wdt->pmu_mask_reset_reg)) { + if (pdev->dev.of_node) { + if (of_property_read_u32(pdev->dev.of_node, + "reset-mask-bit", + &mask_bit)) { + dev_warn(dev, "reset-mask-bit not specified\n"); + wdt->pmu_mask_bit = -EINVAL; + } else { + wdt->pmu_mask_bit = mask_bit; + } + } + } + DBG("probe: mapped reg_base=%p\n", wdt->reg_base); wdt->clock = devm_clk_get(dev, "watchdog");
Documentation/devicetree/bindings/watchdog/samsung-wdt.txt static int s3c2410wdt_probe(struct platform_device · line 498
Quoted 4 lines
Documentation/devicetree/bindings/watchdog/samsung-wdt.txt +1
-0@@ -444,6 +495,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev) (wtcon & S3C2410_WTCON_RSTEN) ? "en" : "dis", (wtcon & S3C2410_WTCON_INTEN) ? "en" : "dis"); + s3c2410wdt_mask_and_disable_reset(0, wdt);
The call above (and further call to this function bellow) could happen conditionally.
Best regards,
Tomasz
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/4] watchdog: s3c2410_wdt: parse watchdog dt node to read PMU registers adresses
Tomasz,
Quoted 22 lines · Tomasz Figa
Documentation/devicetree/bindings/watchdog/samsung-wdt.txt occurred. · line 8
Quoted 5 lines
Documentation/devicetree/bindings/watchdog/samsung-wdt.txt +0
-0@@ -7,8 +7,20 @@ occurred. Required properties: - compatible : should be "samsung,s3c2410-wdt"Since the WDT block of Exynos 5420 needs some extra configuration in PMU registers, it is no longer compatible with samsung.s3c2410-wdt. Please introduce separate compatible ("samsung,exynos5420-wdt") and make the driver handle the additional configuration only if running on a device with this compatible value.
I'd suggest introducing quirk system to the driver and adding a
NEEDS_PMU_CONFIGquirk selected by DT match entry with "samsung,exynos5420- wdt" compatible.Quoted 6 lines
Documentation/devicetree/bindings/watchdog/samsung-wdt.txt +0
-0- reg : base physical address of the controller and length of memorymapped - region.
Documentation/devicetree/bindings/watchdog/samsung-wdt.txt +2
-0+ region and the optional (addresses and length of memory mapped regions + of) PMU registers for masking/unmasking WDT. - interrupts : interrupt number to the cpu.
Quoted 7 lines
Quoted 4 lines
Optional properties:
- timeout-sec : contains the watchdog timeout in seconds.
+- reset-mask-bit: bit number in the PMU registers to program mask/unmask WDT. +I believe this is mandatory on Exynos 5420 and unused on previous SoCs. It should be handled depending on compatible value.
I think at least 5250 needs something similar. I believe we got away with it in the past since other (non-WDT) code was tweaking with this bit, but that was a little bit gross. Leela Krishna can correct me if I'm wrong.
-Doug
A message that is not in the archive (sent off-list or not yet received): CAD=FV=XQSLULsYanJCCFehxrs9LESZ=KO8XgyzZaacL4GNeXPA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 3/4] watchdog: s3c2410_wdt: parse watchdog dt node to read PMU registers adresses
Tomasz,
Quoted 30 lines · Doug Anderson
Tomasz,
Quoted 27 lines · Tomasz Figa
Documentation/devicetree/bindings/watchdog/samsung-wdt.txt occurred. · line 8
Quoted 5 lines
Documentation/devicetree/bindings/watchdog/samsung-wdt.txt +0
-0@@ -7,8 +7,20 @@ occurred. Required properties: - compatible : should be "samsung,s3c2410-wdt"Since the WDT block of Exynos 5420 needs some extra configuration in PMU registers, it is no longer compatible with samsung.s3c2410-wdt. Please introduce separate compatible ("samsung,exynos5420-wdt") and make the driver handle the additional configuration only if running on a device with this compatible value.
I'd suggest introducing quirk system to the driver and adding a
NEEDS_PMU_CONFIGquirk selected by DT match entry with "samsung,exynos5420- wdt" compatible.Quoted 10 lines
Documentation/devicetree/bindings/watchdog/samsung-wdt.txt +0
-0- reg : base physical address of the controller and length of memorymapped - region.
Documentation/devicetree/bindings/watchdog/samsung-wdt.txt +3
-0+ region and the optional (addresses and length of memory mapped regions + of) PMU registers for masking/unmasking WDT. - interrupts : interrupt number to the cpu. Optional properties: - timeout-sec : contains the watchdog timeout in seconds. +- reset-mask-bit: bit number in the PMU registers to program mask/unmaskWDT. +
Quoted 8 lines
Quoted 2 lines
I believe this is mandatory on Exynos 5420 and unused on previous SoCs. It should be handled depending on compatible value.
I think at least 5250 needs something similar. I believe we got away with it in the past since other (non-WDT) code was tweaking with this bit, but that was a little bit gross. Leela Krishna can correct me if I'm wrong.
Yes, 5250 also needs this reset-mask-bit, but not required by SoCs other than Exynos5xxx.
Hence I kept it as optional parameter.
I took care of this code such that it won't break on older SoCs.
If you notice the code in probe function, I used the check condition
if (!IS_ERR(wdt->pmu_disable_reg) && !IS_ERR(wdt->pmu_mask_reset_reg)) { }
i.e., if any of the PMU register address is not mentioned in the DT node it simply skips reading reset-mask-bit
and continues execution (which may happen in older SoC DT node).
..also, in s3c2410wdt_mask_and_disable_reset() function, below condition check is happening
if (IS_ERR(wdt->pmu_disable_reg) || IS_ERR(wdt->pmu_mask_reset_reg)
|| (wdt->pmu_mask_bit < 0))
return;i.e., if any of the registers is not specified in DT node simply return without programming
PMU registers(which is true in case of older SoCs).
If you think this doesn't sounds good way of handling older SoCs. I'll add new compatible string for Exynos5xxx and do like what you said. :)
Best Wishes,
Leela Krishna Amudala
Quoted 5 lines
-Doug
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/4] watchdog: s3c2410_wdt: parse watchdog dt node to read PMU registers adresses
Hi,
Quoted 64 lines · Leela Krishna Amudala
Tomasz,
Quoted 30 lines · Doug Anderson
Tomasz,
Quoted 27 lines · Tomasz Figa
Documentation/devicetree/bindings/watchdog/samsung-wdt.txt occurred. · line 8
Quoted 5 lines
Documentation/devicetree/bindings/watchdog/samsung-wdt.txt +0
-0@@ -7,8 +7,20 @@ occurred. Required properties: - compatible : should be "samsung,s3c2410-wdt"Since the WDT block of Exynos 5420 needs some extra configuration in PMU registers, it is no longer compatible with samsung.s3c2410-wdt. Please introduce separate compatible ("samsung,exynos5420-wdt") and make the driver handle the additional configuration only if running on a device with this compatible value.
I'd suggest introducing quirk system to the driver and adding a
NEEDS_PMU_CONFIGquirk selected by DT match entry with "samsung,exynos5420- wdt" compatible.Quoted 10 lines
Documentation/devicetree/bindings/watchdog/samsung-wdt.txt +0
-0- reg : base physical address of the controller and length of memorymapped - region.
Documentation/devicetree/bindings/watchdog/samsung-wdt.txt +3
-0+ region and the optional (addresses and length of memory mapped regions + of) PMU registers for masking/unmasking WDT. - interrupts : interrupt number to the cpu. Optional properties: - timeout-sec : contains the watchdog timeout in seconds. +- reset-mask-bit: bit number in the PMU registers to program mask/unmaskWDT. +
Quoted 8 lines
Quoted 2 lines
I believe this is mandatory on Exynos 5420 and unused on previous SoCs. It should be handled depending on compatible value.
I think at least 5250 needs something similar. I believe we got away with it in the past since other (non-WDT) code was tweaking with this bit, but that was a little bit gross. Leela Krishna can correct me if I'm wrong.
Yes, 5250 also needs this reset-mask-bit, but not required by SoCs other than Exynos5xxx.
Hence I kept it as optional parameter.I took care of this code such that it won't break on older SoCs.
If you notice the code in probe function, I used the check condition
if (!IS_ERR(wdt->pmu_disable_reg) && !IS_ERR(wdt->pmu_mask_reset_reg)) { }
i.e., if any of the PMU register address is not mentioned in the DT node it simply skips reading reset-mask-bit
and continues execution (which may happen in older SoC DT node)...also, in
s3c2410wdt_mask_and_disable_reset()function, below condition check is happeningif (
IS_ERR(wdt->pmu_disable_reg)||IS_ERR(wdt->pmu_mask_reset_reg)|| (wdt->pmu_mask_bit < 0)) return;
Quoted 6 lines
i.e., if any of the registers is not specified in DT node simply return without programming
PMU registers(which is true in case of older SoCs).If you think this doesn't sounds good way of handling older SoCs. I'll add new compatible string for Exynos5xxx and do like what you said. :)
Yes, please re-do the code per Tomasz's suggestions.
This would also allow you to check return values of devm_ioremap_resource() calls in the probe method and require them to succeed in order to register watchdog device (which is unfortunately not what happens currently).
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
Re: [PATCH 3/4] watchdog: s3c2410_wdt: parse watchdog dt node to read PMU registers adresses
Quoted 45 lines · On Monday 23 of September 2013 19:03:10 Bartlomiej Zolnierkiewicz wrote:
Hi,
Quoted 41 lines · Leela Krishna Amudala
Tomasz,
Quoted 11 lines · Doug Anderson
Tomasz,
Quoted 2 lines · Tomasz Figa
I believe this is mandatory on Exynos 5420 and unused on previous SoCs. It should be handled depending on compatible value.
I think at least 5250 needs something similar. I believe we got away with it in the past since other (non-WDT) code was tweaking with this bit, but that was a little bit gross. Leela Krishna can correct me if I'm wrong.
Yes, 5250 also needs this reset-mask-bit, but not required by SoCs other than Exynos5xxx.
Hence I kept it as optional parameter.I took care of this code such that it won't break on older SoCs.
If you notice the code in probe function, I used the check condition
if (!IS_ERR(wdt->pmu_disable_reg) && !IS_ERR(wdt->pmu_mask_reset_reg)) { }
i.e., if any of the PMU register address is not mentioned in the DT node it simply skips reading reset-mask-bit
and continues execution (which may happen in older SoC DT node)...also, in
s3c2410wdt_mask_and_disable_reset()function, below condition check is happeningif (
IS_ERR(wdt->pmu_disable_reg)||IS_ERR(wdt->pmu_mask_reset_reg)|| (wdt->pmu_mask_bit < 0)) return;i.e., if any of the registers is not specified in DT node simply return without programming
PMU registers(which is true in case of older SoCs).
Quoted 8 lines
Quoted 2 lines
If you think this doesn't sounds good way of handling older SoCs. I'll add new compatible string for Exynos5xxx and do like what you said. :)
Yes, please re-do the code per Tomasz's suggestions.
This would also allow you to check return values of
devm_ioremap_resource()calls in the probe method and require them to succeed in order to register watchdog device (which is unfortunately not what happens currently).
Now as I think of it, the driver doesn't seem to reconfigure those PMU registers in any watchdog API callback, only in probe, remove, suspend and resume.
Since we already have PMU "driver" in mach-exynos, which already has suspend/resume syscore ops, what about placing such configuration there instead?
Best regards,
Tomasz
Re: [PATCH 3/4] watchdog: s3c2410_wdt: parse watchdog dt node to read PMU registers adresses
Quoted 55 lines · On Monday 23 of September 2013 19:11:11 Tomasz Figa wrote:
Quoted 45 lines · On Monday 23 of September 2013 19:03:10 Bartlomiej Zolnierkiewicz wrote:
Hi,
Quoted 41 lines · Leela Krishna Amudala
Tomasz,
Quoted 11 lines · Doug Anderson
Tomasz,
Quoted 2 lines · Tomasz Figa
I believe this is mandatory on Exynos 5420 and unused on previous SoCs. It should be handled depending on compatible value.
I think at least 5250 needs something similar. I believe we got away with it in the past since other (non-WDT) code was tweaking with this bit, but that was a little bit gross. Leela Krishna can correct me if I'm wrong.
Yes, 5250 also needs this reset-mask-bit, but not required by SoCs other than Exynos5xxx.
Hence I kept it as optional parameter.I took care of this code such that it won't break on older SoCs.
If you notice the code in probe function, I used the check condition
if (!IS_ERR(wdt->pmu_disable_reg) && !IS_ERR(wdt->pmu_mask_reset_reg)) { }
i.e., if any of the PMU register address is not mentioned in the DT node it simply skips reading reset-mask-bit
and continues execution (which may happen in older SoC DT node)...also, in
s3c2410wdt_mask_and_disable_reset()function, below condition check is happeningif (
IS_ERR(wdt->pmu_disable_reg)||IS_ERR(wdt->pmu_mask_reset_reg)|| (wdt->pmu_mask_bit < 0)) return;i.e., if any of the registers is not specified in DT node simply return without programming
PMU registers(which is true in case of older SoCs).Quoted 8 lines
Quoted 2 lines
If you think this doesn't sounds good way of handling older SoCs. I'll add new compatible string for Exynos5xxx and do like what you said. :)
Yes, please re-do the code per Tomasz's suggestions.
This would also allow you to check return values of
devm_ioremap_resource()calls in the probe method and require them to succeed in order to register watchdog device (which is unfortunately not what happens currently).
Quoted 7 lines
Now as I think of it, the driver doesn't seem to reconfigure those PMU registers in any watchdog API callback, only in probe, remove, suspend and resume.
Since we already have PMU "driver" in mach-exynos, which already has suspend/resume syscore ops, what about placing such configuration there instead?
Any opinions on this?
Best regards,
Tomasz
Re: [PATCH 3/4] watchdog: s3c2410_wdt: parse watchdog dt node to read PMU registers adresses
Tomasz,
Quoted 60 lines · Tomasz Figa
Quoted 59 lines · On Monday 23 of September 2013 19:11:11 Tomasz Figa wrote:
Quoted 45 lines · On Monday 23 of September 2013 19:03:10 Bartlomiej Zolnierkiewicz wrote:
Hi,
Quoted 41 lines · Leela Krishna Amudala
Tomasz,
Quoted 11 lines · Doug Anderson
Tomasz,
Quoted 2 lines · Tomasz Figa
I believe this is mandatory on Exynos 5420 and unused on previous SoCs. It should be handled depending on compatible value.
I think at least 5250 needs something similar. I believe we got away with it in the past since other (non-WDT) code was tweaking with this bit, but that was a little bit gross. Leela Krishna can correct me if I'm wrong.
Yes, 5250 also needs this reset-mask-bit, but not required by SoCs other than Exynos5xxx.
Hence I kept it as optional parameter.I took care of this code such that it won't break on older SoCs.
If you notice the code in probe function, I used the check condition
if (!IS_ERR(wdt->pmu_disable_reg) && !IS_ERR(wdt->pmu_mask_reset_reg)) { }
i.e., if any of the PMU register address is not mentioned in the DT node it simply skips reading reset-mask-bit
and continues execution (which may happen in older SoC DT node)...also, in
s3c2410wdt_mask_and_disable_reset()function, below condition check is happeningif (
IS_ERR(wdt->pmu_disable_reg)||IS_ERR(wdt->pmu_mask_reset_reg)|| (wdt->pmu_mask_bit < 0)) return;i.e., if any of the registers is not specified in DT node simply return without programming
PMU registers(which is true in case of older SoCs).Quoted 8 lines
Quoted 2 lines
If you think this doesn't sounds good way of handling older SoCs. I'll add new compatible string for Exynos5xxx and do like what you said. :)
Yes, please re-do the code per Tomasz's suggestions.
This would also allow you to check return values of
devm_ioremap_resource()calls in the probe method and require them to succeed in order to register watchdog device (which is unfortunately not what happens currently).Now as I think of it, the driver doesn't seem to reconfigure those PMU registers in any watchdog API callback, only in probe, remove, suspend and resume.
Quoted 6 lines
Quoted 3 lines
Since we already have PMU "driver" in mach-exynos, which already has suspend/resume syscore ops, what about placing such configuration there instead?
Any opinions on this?
In PMU we have control registers for other IPs (like USB, MIPI etc.,) also and I'm not sure where those registers are getting configured. If we want to configure WDT register in PMU driver then we have to consider configuring control regs for other IPs also and the DT node has to have all these control bit numbers. So instead of that I feel configuring it in WDT driver looks fine.
Best Wishes,
Leela Krishna.
Quoted 7 lines
Best regards,
Tomasz--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): CAL1wa8cDAui8AJXvmYPpPEWtUum-ZNpW2hQWjwKLpzXBFLv=eA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 3/4] watchdog: s3c2410_wdt: parse watchdog dt node to read PMU registers adresses
Quoted 70 lines · On Friday 27 of September 2013 16:48:34 Leela Krishna Amudala wrote:
Tomasz,
Quoted 60 lines · Tomasz Figa
Quoted 59 lines · On Monday 23 of September 2013 19:11:11 Tomasz Figa wrote:
Quoted 45 lines · On Monday 23 of September 2013 19:03:10 Bartlomiej Zolnierkiewicz wrote:
Hi,
Quoted 41 lines · Leela Krishna Amudala
Tomasz,
Quoted 11 lines · Doug Anderson
Tomasz,
Quoted 2 lines · Tomasz Figa
I believe this is mandatory on Exynos 5420 and unused on previous SoCs. It should be handled depending on compatible value.
I think at least 5250 needs something similar. I believe we got away with it in the past since other (non-WDT) code was tweaking with this bit, but that was a little bit gross. Leela Krishna can correct me if I'm wrong.
Yes, 5250 also needs this reset-mask-bit, but not required by SoCs other than Exynos5xxx.
Hence I kept it as optional parameter.I took care of this code such that it won't break on older SoCs.
If you notice the code in probe function, I used the check condition
if (!IS_ERR(wdt->pmu_disable_reg) && !IS_ERR(wdt->pmu_mask_reset_reg)) { }
i.e., if any of the PMU register address is not mentioned in the DT node it simply skips reading reset-mask-bit
and continues execution (which may happen in older SoC DT node)...also, in
s3c2410wdt_mask_and_disable_reset()function, below condition check is happeningif (
IS_ERR(wdt->pmu_disable_reg)||IS_ERR(wdt->pmu_mask_reset_reg)|| (wdt->pmu_mask_bit < 0)) return;i.e., if any of the registers is not specified in DT node simply return without programming
PMU registers(which is true in case of older SoCs).Quoted 8 lines
Quoted 2 lines
If you think this doesn't sounds good way of handling older SoCs. I'll add new compatible string for Exynos5xxx and do like what you said. :)
Yes, please re-do the code per Tomasz's suggestions.
This would also allow you to check return values of
devm_ioremap_resource()calls in the probe method and require them to succeed in order to register watchdog device (which is unfortunately not what happens currently).Now as I think of it, the driver doesn't seem to reconfigure those PMU registers in any watchdog API callback, only in probe, remove, suspend and resume.
Quoted 6 lines
Quoted 3 lines
Since we already have PMU "driver" in mach-exynos, which already has suspend/resume syscore ops, what about placing such configuration there instead?
Any opinions on this?
Quoted 6 lines
In PMU we have control registers for other IPs (like USB, MIPI etc.,) also and I'm not sure where those registers are getting configured. If we want to configure WDT register in PMU driver then we have to consider configuring control regs for other IPs also and the DT node has to have all these control bit numbers. So instead of that I feel configuring it in WDT driver looks fine.
I believe this depends on possible use cases, not the IP block itself. If this is just a low level initial (and SoC specific) initialization that doesn't require any co-operation with high level kernel/userspace APIs, then I think there is no need to entangle the driver for watchdog IP with SoC specific details outside the IP itself.
[Adding more people on Cc for further discussion.]
Best regards,
Tomasz
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/4] watchdog: s3c2410_wdt: parse watchdog dt node to read PMU registers adresses
Tomasz
Quoted 14 lines · Tomasz Figa
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
Since we already have PMU "driver" in mach-exynos, which already has suspend/resume syscore ops, what about placing such configuration there instead?
Any opinions on this?
Quoted 6 lines
In PMU we have control registers for other IPs (like USB, MIPI etc.,) also and I'm not sure where those registers are getting configured. If we want to configure WDT register in PMU driver then we have to consider configuring control regs for other IPs also and the DT node has to have all these control bit numbers. So instead of that I feel configuring it in WDT driver looks fine.
Quoted 7 lines
I believe this depends on possible use cases, not the IP block itself. If this is just a low level initial (and SoC specific) initialization that doesn't require any co-operation with high level kernel/userspace APIs, then I think there is no need to entangle the driver for watchdog IP with SoC specific details outside the IP itself.
[Adding more people on Cc for further discussion.]
So isn't the register in the PMU there to save power in the case that the watchdog timer isn't being used? How is the PMU "driver" to know whether the watchdog is being used? Better IMHO that the watchdog driver knows to enable and disable itself as needed, right?
-Doug
A message that is not in the archive (sent off-list or not yet received): CAD=FV=WZBrJ5Qhky6VQqfu59LVQcKMTdLa+gJwnnFM85bEzzNQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 3/4] watchdog: s3c2410_wdt: parse watchdog dt node to read PMU registers adresses
Quoted 25 lines · On Friday 27 of September 2013 08:20:25 Doug Anderson wrote:
Tomasz
Quoted 22 lines · Tomasz Figa
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Since we already have PMU "driver" in mach-exynos, which already has
suspend/resume syscore ops, what about placing such configuration there
instead?Quoted 8 lines
Quoted 1 line
Any opinions on this?
In PMU we have control registers for other IPs (like USB, MIPI etc.,) also and I'm not sure where those registers are getting configured. If we want to configure WDT register in PMU driver then we have to consider configuring control regs for other IPs also and the DT node has to have all these control bit numbers. So instead of that I feel configuring it in WDT driver looks fine.
I believe this depends on possible use cases, not the IP block itself. If this is just a low level initial (and SoC specific) initialization that doesn't require any co-operation with high level kernel/userspace APIs, then I think there is no need to entangle the driver for watchdog
IP with SoC specific details outside the IP itself.
Quoted 6 lines
Quoted 1 line
[Adding more people on Cc for further discussion.]
So isn't the register in the PMU there to save power in the case that the watchdog timer isn't being used? How is the PMU "driver" to know whether the watchdog is being used? Better IMHO that the watchdog driver knows to enable and disable itself as needed, right?
How much power can you save on one low frequency counter? Anyway, those bits look more like reset signal masks to me, unrelated to any power saving and even if, this driver switches them on at probe regardless of whether the watchdog is actually used or not.
Best regards,
Tomasz
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/4] watchdog: s3c2410_wdt: parse watchdog dt node to read PMU registers adresses
Tomasz,
Quoted 9 lines · Tomasz Figa
Quoted 4 lines
So isn't the register in the PMU there to save power in the case that the watchdog timer isn't being used? How is the PMU "driver" to know whether the watchdog is being used? Better IMHO that the watchdog driver knows to enable and disable itself as needed, right?
How much power can you save on one low frequency counter? Anyway, those bits look more like reset signal masks to me, unrelated to any power saving and even if, this driver switches them on at probe regardless of whether the watchdog is actually used or not.
I don't know for sure how much power it saves if any. The description I have of those fields is also definitely a little on the confusing side. The fact that they are in the PMU leads me to believe that they save power, but perhaps that's not the case here.
It still does seem nice to keep watchdog related code in the watchdog driver, though... I guess I could also imagine ordering problems if we tweaked this bit in the PMU driver, though I don't have actual evidence of this. Maybe cases where enabling at the wrong time could cause spurious watchdog resets depending on how the BIOS left the state of things. It would be unfortunate if we found we needed to reach into the watchdog register bank from the PMU driver to "pet" the watchdog before enabling it.
-Doug
A message that is not in the archive (sent off-list or not yet received): CAD=FV=Wa0BpmE7mQoAk-RC_g9QCCz2T_7=Pd46CDSN8Z9KQ8jg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 3/4] watchdog: s3c2410_wdt: parse watchdog dt node to read PMU registers adresses
Quoted 3 lines · On Friday 27 of September 2013 11:48:53 Doug Anderson wrote:
Tomasz,
On Fri, Sep 27, 2013 at 11:14 AM, Tomasz Figa <[email protected]>
Quoted 12 lines · wrote:
Quoted 11 lines
Quoted 4 lines
So isn't the register in the PMU there to save power in the case that the watchdog timer isn't being used? How is the PMU "driver" to know whether the watchdog is being used? Better IMHO that the watchdog driver knows to enable and disable itself as needed, right?
How much power can you save on one low frequency counter? Anyway, those
bits look more like reset signal masks to me, unrelated to any power saving and even if, this driver switches them on at probe regardless of
whether the watchdog is actually used or not.
Quoted 7 lines
I don't know for sure how much power it saves if any. The description I have of those fields is also definitely a little on the confusing side. The fact that they are in the PMU leads me to believe that they save power, but perhaps that's not the case here.
It still does seem nice to keep watchdog related code in the watchdog driver, though...
For me, this thing looks more related to PMU than watchdog, since the code writes to PMU registers and does this only on system power state transitions, i.e. once per boot, suspend, resume and shutdown.
Quoted 5 lines
I guess I could also imagine ordering problems if
we tweaked this bit in the PMU driver, though I don't have actual evidence of this. Maybe cases where enabling at the wrong time could cause spurious watchdog resets depending on how the BIOS left the state of things.
Even if you put this code in watchdog driver you don't have any warranties that the firmware leaves both the watchdog and PMU bits sets correctly. I'm not sure what would be the point of firmware existence if you can't trust it to set up at least the basic working environment for you and I consider watchdog to be part of such.
Quoted 3 lines
It would be unfortunate if we found we needed to
reach into the watchdog register bank from the PMU driver to "pet" the watchdog before enabling it.
If you find any such need in future, then with the solution I proposed there will be no problem in changing things to be done as you and Leela propose. The other way around would not be that simple, because the introduced binding would still have to be supported and the code touching PMU would have to be kept in watchdog code...
However, if you really insist on handling this in watchdog driver, please consider using something smarter to access the PMU. I believe that device node of watchdog should not represent parts of PMU, which should be represented as a separate node instead.
Could you use the syscon driver instead to handle PMU register accesses in a centralized way, put the PMU register offset and respective bit masks inside the watchdog driver (preferrably in a struct bound to respective OF match entry) and access the registers using the regmap API?
Best regards,
Tomasz
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/4] watchdog: s3c2410_wdt: parse watchdog dt node to read PMU registers adresses
Tomasz,
Quoted 19 lines · Tomasz Figa
Quoted 1 line
On Fri, Sep 27, 2013 at 11:14 AM, Tomasz Figa <[email protected]>
Quoted 17 lines · wrote:
Quoted 11 lines
Quoted 4 lines
So isn't the register in the PMU there to save power in the case that the watchdog timer isn't being used? How is the PMU "driver" to know whether the watchdog is being used? Better IMHO that the watchdog driver knows to enable and disable itself as needed, right?
How much power can you save on one low frequency counter? Anyway, those
bits look more like reset signal masks to me, unrelated to any power saving and even if, this driver switches them on at probe regardless of
whether the watchdog is actually used or not.I don't know for sure how much power it saves if any. The description I have of those fields is also definitely a little on the confusing side. The fact that they are in the PMU leads me to believe that they save power, but perhaps that's not the case here.
Quoted 6 lines
Quoted 2 lines
It still does seem nice to keep watchdog related code in the watchdog driver, though...
For me, this thing looks more related to PMU than watchdog, since the code writes to PMU registers and does this only on system power state transitions, i.e. once per boot, suspend, resume and shutdown.
I wonder if there is any reason that it shouldn't be put in the s3c2410wdt_start() and s3c2410wdt_stop() functions?
Quoted 11 lines
Quoted 5 lines
I guess I could also imagine ordering problems if
we tweaked this bit in the PMU driver, though I don't have actual evidence of this. Maybe cases where enabling at the wrong time could cause spurious watchdog resets depending on how the BIOS left the state of things.Even if you put this code in watchdog driver you don't have any warranties that the firmware leaves both the watchdog and PMU bits sets correctly. I'm not sure what would be the point of firmware existence if you can't trust it to set up at least the basic working environment for you and I consider watchdog to be part of such.
I trust it to leave the system in some state that is safe. ...but I don't trust the firmware of all exynos-based products to have the same idea of what "safe" is. I could imagine some of them disabling the watchdog before booting linux by tweaking the settings in the PMU (and leaving the reset of the watchdog configured and running) and some of them disabling the watchdog by leaving the PMU settings alone and turning off the enable bit. I could also imagine some of them actually leaving the watchdog fully configured and running to try to catch the case where the kernel crashes at bootup. I don't know of any official rules here, which means that the kernel needs to be flexible enough.
Quoted 11 lines
Quoted 3 lines
It would be unfortunate if we found we needed to
reach into the watchdog register bank from the PMU driver to "pet" the watchdog before enabling it.If you find any such need in future, then with the solution I proposed there will be no problem in changing things to be done as you and Leela propose. The other way around would not be that simple, because the introduced binding would still have to be supported and the code touching PMU would have to be kept in watchdog code...
However, if you really insist on handling this in watchdog driver,
I certainly don't insist. I have not contributed nearly enough to the community to insist on anything. At this point I'm merely stating my opinion. Feel free to take it into consideration or ignore it. I will not be offended if you choose to ignore my opinion here. It is really up to Leela Krishna and the maintainer of the subsystem if I understand correctly.
Quoted 4 lines
please
consider using something smarter to access the PMU. I believe that device node of watchdog should not represent parts of PMU, which should be represented as a separate node instead.
We've already had this discussion before. Assuming I'm understanding him correctly, Olof weighed in and suggested that he preferred to do the simpler thing in this case (AKA: what Leela Krishna is doing):
http://www.spinics.net/lists/devicetree/msg00812.html
-Doug
Re: [PATCH 3/4] watchdog: s3c2410_wdt: parse watchdog dt node to read PMU registers adresses
Doug,
Quoted 25 lines · On Monday 30 of September 2013 09:54:33 Doug Anderson wrote:
Tomasz,
Quoted 22 lines · Tomasz Figa
Quoted 1 line
On Fri, Sep 27, 2013 at 11:14 AM, Tomasz Figa <[email protected]>
Quoted 19 lines · wrote:
Quoted 11 lines
Quoted 4 lines
So isn't the register in the PMU there to save power in the case that the watchdog timer isn't being used? How is the PMU "driver" to know whether the watchdog is being used? Better IMHO that the watchdog driver knows to enable and disable itself as needed, right?
How much power can you save on one low frequency counter? Anyway, those
bits look more like reset signal masks to me, unrelated to any power saving and even if, this driver switches them on at probe regardless of
whether the watchdog is actually used or not.I don't know for sure how much power it saves if any. The description I have of those fields is also definitely a little on the confusing side. The fact that they are in the PMU leads me to believe that they save power, but perhaps that's not the case here.
It still does seem nice to keep watchdog related code in the watchdog driver, though...
Quoted 6 lines
Quoted 3 lines
For me, this thing looks more related to PMU than watchdog, since the code writes to PMU registers and does this only on system power state transitions, i.e. once per boot, suspend, resume and shutdown.
I wonder if there is any reason that it shouldn't be put in the
s3c2410wdt_start()ands3c2410wdt_stop()functions?
Well, this could actually make some sense, assuming that there would be any use case for it and any advantages of doing so. According to user's manual those masks are only masking the reset signal, but there are no use scenarios described.
Quoted 12 lines
Quoted 11 lines
Quoted 5 lines
I guess I could also imagine ordering problems if
we tweaked this bit in the PMU driver, though I don't have actual evidence of this. Maybe cases where enabling at the wrong time could cause spurious watchdog resets depending on how the BIOS left the state of things.Even if you put this code in watchdog driver you don't have any warranties that the firmware leaves both the watchdog and PMU bits sets correctly. I'm not sure what would be the point of firmware existence if you can't trust it to set up at least the basic working environment for you and I consider watchdog to be part of such.
Quoted 11 lines
I trust it to leave the system in some state that is safe. ...but I don't trust the firmware of all exynos-based products to have the same idea of what "safe" is. I could imagine some of them disabling the watchdog before booting linux by tweaking the settings in the PMU (and leaving the reset of the watchdog configured and running) and some of them disabling the watchdog by leaving the PMU settings alone and turning off the enable bit. I could also imagine some of them actually leaving the watchdog fully configured and running to try to catch the case where the kernel crashes at bootup. I don't know of any official rules here, which means that the kernel needs to be flexible enough.
Nothing stops the kernel from simply disabling the watchdog by watchdog (not PMU registers), but still, what about kernels compiled without the watchdog driver?
Quoted 10 lines
Quoted 10 lines
Quoted 3 lines
It would be unfortunate if we found we needed to
reach into the watchdog register bank from the PMU driver to "pet" the watchdog before enabling it.If you find any such need in future, then with the solution I proposed there will be no problem in changing things to be done as you and Leela propose. The other way around would not be that simple, because the introduced binding would still have to be supported and the code touching PMU would have to be kept in watchdog code...
Quoted 8 lines
Quoted 1 line
However, if you really insist on handling this in watchdog driver,
I certainly don't insist. I have not contributed nearly enough to the community to insist on anything. At this point I'm merely stating my opinion. Feel free to take it into consideration or ignore it. I will not be offended if you choose to ignore my opinion here. It is really up to Leela Krishna and the maintainer of the subsystem if I understand correctly.
Well, everyone has their right to insist on something. Since you're writing to this mailing list, you're part of the community and you're free to suggest the superiority of your preferred solution :).
Quoted 10 lines
Quoted 4 lines
please
consider using something smarter to access the PMU. I believe that device node of watchdog should not represent parts of PMU, which should be represented as a separate node instead.We've already had this discussion before. Assuming I'm understanding him correctly, Olof weighed in and suggested that he preferred to do the simpler thing in this case (AKA: what Leela Krishna is doing):
Well, the patches themselves in their last version looks fine to me, however this solution has several issues:
- a full page of virtual address space is being mapped for just 4 bytes, for every such register,
- the MASK_WDT_RESET_REQUEST register (0x1004040c) contains multiple fields, not just SYS_WDT_RESET, so to be future proof, access to it must be somehow synchronized,
- register area of multiple IPs are being specified in device tree node of one IP,
- every driver that accesses PMU will have to contain such extra reg parsing and mapping, instead of just requesting a named regmap.
In addition, on the contrary to keeping this in PMU:
- the driver must be taught some SoC specific details, even if the IPs are identical, without any real need to do so.
I don't insist on keeping this in PMU driver, but at least having a common regmap for all PMU registers that could be accessed by all drivers that need to do something in PMU registers would be much more elegant and future-proof.
Best regards,
Tomasz
PATCH 4/4 ARM: dts: exynos: add PMU registers addresses and mask bit to watchdog node
In reply to a message not in the archiveThis patch adds support for specifying the pmu registers and masking bit for watchdog to enable/disable and mask/unmask the watchdog reset request.
--- arch/arm/boot/dts/exynos5.dtsi | 2 +- arch/arm/boot/dts/exynos5250.dtsi | 1 + arch/arm/boot/dts/exynos5420.dtsi | 1 + 3 files changed, 3 insertions(+), 1 deletion(-)
arch/arm/boot/dts/exynos5.dtsi +1 -1
@@ -104,7 +104,7 @@ watchdog@101D0000 { compatible = "samsung,s3c2410-wdt"; - reg = <0x101D0000 0x100>; + reg = <0x101D0000 0x100>, <0x10040408 0x4>, <0x1004040c 0x4>; interrupts = <0 42 0>; status = "disabled"; };
arch/arm/boot/dts/exynos5250.dtsi +1 -0
@@ -161,6 +161,7 @@ watchdog@101D0000 { clocks = <&clock 336>; clock-names = "watchdog"; + reset-mask-bit = <20>; status = "okay"; };
arch/arm/boot/dts/exynos5420.dtsi +1 -0
@@ -189,6 +189,7 @@ watchdog@101D0000 { clocks = <&clock 316>; clock-names = "watchdog"; + reset-mask-bit = <0>; status = "okay"; };
Signature · 1 line
1.7.9.5