Add support to MT6323 RTC and its power device
Subsystems (6)
[email protected]
maintainercover Add support to MT6323 RTC and its power device
From: Sean Wang <[email protected]>
Hi,
The series keeps to extend the capability of BPI-R2 board with MT7623 and the result can as well bring benefits into the other MediaTek PMICs such as MT6397 or SoCs.
The series sent across mfd, rtc, pm, dt-binding sub-system is for hoping to let people have a simple cross-reference to know the exact dependency and why those patches are being split in that way between each one.
Patch 1-3: Add dt-binding to the related devices newly or already
supported.
Patch 4-5: Extend driver with the functionality of MT6323 RTC device. Patch 6-9 and 12-13: Add a few of trivial fixups, cleanups and
improvements.
Patch 10-11: It's a preparation for Patch 14 adding a new driver. Patch 14: Add a new driver for a power-off driver.
Patch 15-16: Update MAINTAINERS with these new files being added.
Sean
Sean Wang (16):
dt-bindings: power: reset: mediatek: add bindings for power device
dt-bindings: rtc: mediatek: add bindings for PMIC RTC
dt-bindings: mfd: mediatek: add a description for MT6323 RTC
mfd: mt6397: add MT6323 RTC support into MT6397 driver
rtc: mediatek: add MT6323 support to RTC driver
rtc: mediatek: remove unnecessary parentheses
rtc: mediatek: replace a poll with regmap_read_poll_timeout
rtc: mediatek: remove unnecessary irq_dispose_mapping
rtc: mediatek: convert to use device managed functions
rtc: mediatek: add devm_of_platform_populate
rtc: mediatek: move the declaration into a globally visible header
file
rtc: mediatek: cleanup header files to include
rtc: mediatek: update license converting to using SPDX identifiers
power: reset: mediatek: add a power-off driver using PMIC RTC device
MAINTAINERS: update entry for ARM/Mediatek RTC DRIVER
MAINTAINERS: add an entry for MediaTek board level shutdown driver
Documentation/devicetree/bindings/mfd/mt6397.txt | 4 +- .../bindings/power/reset/mt6397-rtc-poweroff.txt | 24 ++++ .../devicetree/bindings/rtc/rtc-mt6397.txt | 39 ++++++ MAINTAINERS | 9 ++ drivers/mfd/mt6397-core.c | 23 +++- drivers/power/reset/Kconfig | 9 ++ drivers/power/reset/Makefile | 1 + drivers/power/reset/mt6397-rtc-poweroff.c | 100 ++++++++++++++ drivers/rtc/rtc-mt6397.c | 145 +++++---------------- include/linux/rtc/mt6397.h | 73 +++++++++++ 10 files changed, 314 insertions(+), 113 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/reset/mt6397-rtc-poweroff.txt create mode 100644 Documentation/devicetree/bindings/rtc/rtc-mt6397.txt create mode 100644 drivers/power/reset/mt6397-rtc-poweroff.c create mode 100644 include/linux/rtc/mt6397.h
Signature · 1 line
2.7.4
[email protected]
maintainerPATCH 1/16 dt-bindings: power: reset: mediatek: add bindings for power device
From: Sean Wang <[email protected]>
Add device-tree binding for the power device responsible for shutdown a remote SoC, which is a tiny circuit block present on MediaTek PMIC based RTC.
--- .../bindings/power/reset/mt6397-rtc-poweroff.txt | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/reset/mt6397-rtc-poweroff.txt
Documentation/devicetree/bindings/power/reset/mt6397-rtc-poweroff.txt new file +24 -0
@@ -0,0 +1,24 @@ +Device-Tree bindings for Power Device on MediaTek PMIC RTC + +The power device is responsible for externally power off or on the remote +MediaTek SoC through the a tiny circuit block BBPU inside PMIC RTC. + +Required parent node: +- rtc + For MediaTek PMIC RTC bindings, see: + Documentation/devicetree/bindings/mfd/mt6397.txt + +Required properties: +- compatible: Should be one of follows + "mediatek,mt6323-rtc-poweroff": for MT6323 PMIC + "mediatek,mt6397-rtc-poweroff": for MT6397 PMIC + +Example: + + rtc { + compatible = "mediatek,mt6323-rtc"; + + power-off { + compatible = "mediatek,mt6323-rtc-poweroff"; + }; + };
Signature · 1 line
2.7.4
Rob Herring
maintainerRe: [PATCH v1 01/16] dt-bindings: power: reset: mediatek: add bindings for power device
Quoted 31 lines · On Fri, Mar 23, 2018 at 05:14:58PM +0800, [email protected] wrote:
From: Sean Wang <[email protected]>
Add device-tree binding for the power device responsible for shutdown a remote SoC, which is a tiny circuit block present on MediaTek PMIC based RTC.
Signed-off-by Sean Wang <[email protected]>--- .../bindings/power/reset/mt6397-rtc-poweroff.txt | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/reset/mt6397-rtc-poweroff.txtDocumentation/devicetree/bindings/power/reset/mt6397-rtc-poweroff.txt new file +13
-0@@ -0,0 +1,24 @@ +Device-Tree bindings for Power Device on MediaTek PMIC RTC + +The power device is responsible for externally power off or on the remote +MediaTek SoC through the a tiny circuit block BBPU inside PMIC RTC. + +Required parent node: +- rtc + For MediaTek PMIC RTC bindings, see: + Documentation/devicetree/bindings/mfd/mt6397.txt + +Required properties: +- compatible: Should be one of follows + "mediatek,mt6323-rtc-poweroff": for MT6323 PMIC
Documentation/devicetree/bindings/power/reset/mt6397-rtc-poweroff.txt line 23
Quoted 10 lines
Documentation/devicetree/bindings/power/reset/mt6397-rtc-poweroff.txt new file +10
-0+ "mediatek,mt6397-rtc-poweroff": for MT6397 PMIC + +Example: + + rtc { + compatible = "mediatek,mt6323-rtc"; + + power-off { + compatible = "mediatek,mt6323-rtc-poweroff"; + };
There's no need for this node. The OS can register a device in the rtc driver.
Quoted 4 lines
Documentation/devicetree/bindings/power/reset/mt6397-rtc-poweroff.txt new file +1
-0+ };Signature · 1 line
2.7.4
Sean Wang
maintainerRe: [PATCH v1 01/16] dt-bindings: power: reset: mediatek: add bindings for power device
Quoted 37 lines · Rob Herring
Quoted 36 lines · On Fri, Mar 23, 2018 at 05:14:58PM +0800, [email protected] wrote:
From: Sean Wang <[email protected]>
Add device-tree binding for the power device responsible for shutdown a remote SoC, which is a tiny circuit block present on MediaTek PMIC based RTC.
Signed-off-by Sean Wang <[email protected]>--- .../bindings/power/reset/mt6397-rtc-poweroff.txt | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/reset/mt6397-rtc-poweroff.txtDocumentation/devicetree/bindings/power/reset/mt6397-rtc-poweroff.txt new file +18
-0@@ -0,0 +1,24 @@ +Device-Tree bindings for Power Device on MediaTek PMIC RTC + +The power device is responsible for externally power off or on the remote +MediaTek SoC through the a tiny circuit block BBPU inside PMIC RTC. + +Required parent node: +- rtc + For MediaTek PMIC RTC bindings, see: + Documentation/devicetree/bindings/mfd/mt6397.txt + +Required properties: +- compatible: Should be one of follows + "mediatek,mt6323-rtc-poweroff": for MT6323 PMIC + "mediatek,mt6397-rtc-poweroff": for MT6397 PMIC + +Example: + + rtc {
Quoted 9 lines
Documentation/devicetree/bindings/power/reset/mt6397-rtc-poweroff.txt line 23
Quoted 5 lines
Documentation/devicetree/bindings/power/reset/mt6397-rtc-poweroff.txt new file +5
-0+ compatible = "mediatek,mt6323-rtc"; + + power-off { + compatible = "mediatek,mt6323-rtc-poweroff"; + };There's no need for this node. The OS can register a device in the rtc driver.
It seems a good way.
I will remove the really simple dt-binding and use a platform_device_register_simple api embedded in rtc driver to register the power-off device.
Hope I do not misconception your points addressed here.
Quoted 4 lines
Quoted 4 lines
Documentation/devicetree/bindings/power/reset/mt6397-rtc-poweroff.txt new file +1
-0+ };Signature · 1 line
2.7.4
[email protected]
maintainerPATCH 2/16 dt-bindings: rtc: mediatek: add bindings for PMIC RTC
In reply to [email protected]From: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected]>
Add device-tree binding for MediaTek PMIC based RTC.
--- .../devicetree/bindings/rtc/rtc-mt6397.txt | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Documentation/devicetree/bindings/rtc/rtc-mt6397.txt
Documentation/devicetree/bindings/rtc/rtc-mt6397.txt new file +39 -0
@@ -0,0 +1,39 @@ +Device-Tree bindings for MediaTek PMIC based RTC + +MediaTek PMIC based RTC is an independent function of MediaTek PMIC which +is working as a multi-function device (MFD). And the RTC can be configured and +set up via PMIC wrapper bus. Which is also common resource shared among the +other functions present on the PMIC. + +For MediaTek PMIC wrapper bus bindings, see: +Documentation/devicetree/bindings/soc/mediatek/pwrap.txt + +Required parent node: +- pmic + For MediaTek PMIC MFD bindings, see: + Documentation/devicetree/bindings/mfd/mt6397.txt + +Required properties: +- compatible: Should be one of follows + "mediatek,mt6323-rtc": for MT6323 PMIC + "mediatek,mt6397-rtc": for MT6397 PMIC + +Optional child node: +- power-off + For Power-Off Device for MediaTek PMIC RTC bindings, see: + Documentation/devicetree/bindings/power/reset/mt6397-rtc-poweroff.txt + +Example: + + pmic { + compatible = "mediatek,mt6323"; + + ... + rtc { + compatible = "mediatek,mt6323-rtc"; + + power-off { + compatible = "mediatek,mt6323-rtc-poweroff"; + }; + }; +};
Signature · 1 line
2.7.4
Re: [PATCH v1 02/16] dt-bindings: rtc: mediatek: add bindings for PMIC RTC
Hi,
Quoted 43 lines · On 23/03/2018 at 17:14:59 +0800, [email protected] wrote:
From: Sean Wang <[email protected]>
Add device-tree binding for MediaTek PMIC based RTC.
Signed-off-by Sean Wang <[email protected]>--- .../devicetree/bindings/rtc/rtc-mt6397.txt | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Documentation/devicetree/bindings/rtc/rtc-mt6397.txtDocumentation/devicetree/bindings/rtc/rtc-mt6397.txt new file +27
-0@@ -0,0 +1,39 @@ +Device-Tree bindings for MediaTek PMIC based RTC + +MediaTek PMIC based RTC is an independent function of MediaTek PMIC which +is working as a multi-function device (MFD). And the RTC can be configured and +set up via PMIC wrapper bus. Which is also common resource shared among the +other functions present on the PMIC. + +For MediaTek PMIC wrapper bus bindings, see: +Documentation/devicetree/bindings/soc/mediatek/pwrap.txt + +Required parent node: +- pmic + For MediaTek PMIC MFD bindings, see: + Documentation/devicetree/bindings/mfd/mt6397.txt + +Required properties: +- compatible: Should be one of follows + "mediatek,mt6323-rtc": for MT6323 PMIC + "mediatek,mt6397-rtc": for MT6397 PMIC + +Optional child node: +- power-off + For Power-Off Device for MediaTek PMIC RTC bindings, see: + Documentation/devicetree/bindings/power/reset/mt6397-rtc-poweroff.txt + +Example: +
Documentation/devicetree/bindings/rtc/rtc-mt6397.txt line 37
Quoted 10 lines
Documentation/devicetree/bindings/rtc/rtc-mt6397.txt new file +10
-0+ pmic { + compatible = "mediatek,mt6323"; + + ... + rtc { + compatible = "mediatek,mt6323-rtc"; + + power-off { + compatible = "mediatek,mt6323-rtc-poweroff"; + };
I'm pretty sure the whole point of mfd is to avoid having the poweroff controller under the rtc
Signature · 3 lines
Alexandre Belloni, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
Re: [PATCH v1 02/16] dt-bindings: rtc: mediatek: add bindings for PMIC RTC
Quoted 51 lines · Alexandre Belloni
Hi,
Quoted 48 lines · On 23/03/2018 at 17:14:59 +0800, sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected].…
From: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected]>
Add device-tree binding for MediaTek PMIC based RTC.
--- .../devicetree/bindings/rtc/rtc-mt6397.txt | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Documentation/devicetree/bindings/rtc/rtc-mt6397.txtDocumentation/devicetree/bindings/rtc/rtc-mt6397.txt new file +32
-0@@ -0,0 +1,39 @@ +Device-Tree bindings for MediaTek PMIC based RTC + +MediaTek PMIC based RTC is an independent function of MediaTek PMIC which +is working as a multi-function device (MFD). And the RTC can be configured and +set up via PMIC wrapper bus. Which is also common resource shared among the +other functions present on the PMIC. + +For MediaTek PMIC wrapper bus bindings, see: +Documentation/devicetree/bindings/soc/mediatek/pwrap.txt + +Required parent node: +- pmic + For MediaTek PMIC MFD bindings, see: + Documentation/devicetree/bindings/mfd/mt6397.txt + +Required properties: +- compatible: Should be one of follows + "mediatek,mt6323-rtc": for MT6323 PMIC + "mediatek,mt6397-rtc": for MT6397 PMIC + +Optional child node: +- power-off + For Power-Off Device for MediaTek PMIC RTC bindings, see: + Documentation/devicetree/bindings/power/reset/mt6397-rtc-poweroff.txt + +Example: + + pmic { + compatible = "mediatek,mt6323"; + + ... + rtc {
Quoted 9 lines
Documentation/devicetree/bindings/rtc/rtc-mt6397.txt line 37
Quoted 5 lines
Documentation/devicetree/bindings/rtc/rtc-mt6397.txt new file +5
-0+ compatible = "mediatek,mt6323-rtc"; + + power-off { + compatible = "mediatek,mt6323-rtc-poweroff"; + };I'm pretty sure the whole point of mfd is to avoid having the poweroff controller under the rtc
BTW, I think it is enough to have that documented in only one file (the MFD one is enough)
Quoted 5 lines
Signature · 4 lines
-- Alexandre Belloni, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
Signature · 3 lines
Alexandre Belloni, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
Sean Wang
maintainerRe: [PATCH v1 02/16] dt-bindings: rtc: mediatek: add bindings for PMIC RTC
Quoted 62 lines · Alexandre Belloni
Quoted 51 lines · Alexandre Belloni
Hi,
Quoted 48 lines · On 23/03/2018 at 17:14:59 +0800, [email protected] wrote:
From: Sean Wang <[email protected]>
Add device-tree binding for MediaTek PMIC based RTC.
Signed-off-by Sean Wang <[email protected]>--- .../devicetree/bindings/rtc/rtc-mt6397.txt | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Documentation/devicetree/bindings/rtc/rtc-mt6397.txtDocumentation/devicetree/bindings/rtc/rtc-mt6397.txt new file +32
-0@@ -0,0 +1,39 @@ +Device-Tree bindings for MediaTek PMIC based RTC + +MediaTek PMIC based RTC is an independent function of MediaTek PMIC which +is working as a multi-function device (MFD). And the RTC can be configured and +set up via PMIC wrapper bus. Which is also common resource shared among the +other functions present on the PMIC. + +For MediaTek PMIC wrapper bus bindings, see: +Documentation/devicetree/bindings/soc/mediatek/pwrap.txt + +Required parent node: +- pmic + For MediaTek PMIC MFD bindings, see: + Documentation/devicetree/bindings/mfd/mt6397.txt + +Required properties: +- compatible: Should be one of follows + "mediatek,mt6323-rtc": for MT6323 PMIC + "mediatek,mt6397-rtc": for MT6397 PMIC + +Optional child node: +- power-off + For Power-Off Device for MediaTek PMIC RTC bindings, see: + Documentation/devicetree/bindings/power/reset/mt6397-rtc-poweroff.txt + +Example: + + pmic { + compatible = "mediatek,mt6323"; + + ... + rtc {Quoted 9 lines
Documentation/devicetree/bindings/rtc/rtc-mt6397.txt line 37
Quoted 5 lines
Documentation/devicetree/bindings/rtc/rtc-mt6397.txt new file +5
-0+ compatible = "mediatek,mt6323-rtc"; + + power-off { + compatible = "mediatek,mt6323-rtc-poweroff"; + };I'm pretty sure the whole point of mfd is to avoid having the poweroff controller under the rtc
Quoted 3 lines
BTW, I think it is enough to have that documented in only one file (the MFD one is enough)
just reply both replies in the same mail
1.) the power-off device is a part of rtc, use the same registers rtc has and thus it is put as child nodes under the node rtc to reflect the reality of characteristics the rtc has.
Or am I wrong for a certain aspect in these opinions?
2) the other sub-functions for the same pmic already created its own dt-binding document belonged to its corresponding subsystem. Don't we really want to follow it them all?
Quoted 6 lines
Quoted 5 lines
Signature · 4 lines
-- Alexandre Belloni, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
Re: [PATCH v1 02/16] dt-bindings: rtc: mediatek: add bindings for PMIC RTC
Quoted 8 lines · Sean Wang
just reply both replies in the same mail
1.) the power-off device is a part of rtc, use the same registers rtc has and thus it is put as child nodes under the node rtc to reflect the reality of characteristics the rtc has.
Or am I wrong for a certain aspect in these opinions?
My point is that it is also part of the PMIC so it may as well be registers from the mfd driver which already registers a bunch of devices instead of doing unusual stuff from the rtc driver.
mt6397_rtc->regmap is mt6397_chip->regmap anyway. You have the added benefit that if the RTC driver probe fails for some reason, you may still be able to probe the reset driver.
I don't tink there is any benefit having it as a child of the rtc device.
Quoted 4 lines
2) the other sub-functions for the same pmic already created its own dt-binding document belonged to its corresponding subsystem. Don't we really want to follow it them all?
Ok, that's fine.
Signature · 3 lines
Alexandre Belloni, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
Sean Wang
maintainerRe: [PATCH v1 02/16] dt-bindings: rtc: mediatek: add bindings for PMIC RTC
Quoted 14 lines · Alexandre Belloni
Quoted 8 lines · Sean Wang
just reply both replies in the same mail
1.) the power-off device is a part of rtc, use the same registers rtc has and thus it is put as child nodes under the node rtc to reflect the reality of characteristics the rtc has.
Or am I wrong for a certain aspect in these opinions?
My point is that it is also part of the PMIC so it may as well be registers from the mfd driver which already registers a bunch of devices instead of doing unusual stuff from the rtc driver.
Quoted 7 lines
mt6397_rtc->regmapismt6397_chip->regmapanyway. You have the added benefit that if the RTC driver probe fails for some reason, you may still be able to probe the reset driver.I don't tink there is any benefit having it as a child of the rtc device.
really thanks! it's an optional solution I thought it 's fine and worth doing
but so far I cannot fully make sure of whether mfd can accept two devices holding overlay IORESOURCE_MEM.
Or do you like Rob's suggestion in [1] ? By which, I tend to embed a sub-device with platform_device_register_data api in the rtc probe() instead of treating it as a dt node under rtc node, but which seems something a bit violates your preferences :(
Just confirm to know which way I should step into before I produce next version.
[1]
http://lists.infradead.org/pipermail/linux-mediatek/2018-March/012576.html
Quoted 7 lines
Quoted 4 lines
2) the other sub-functions for the same pmic already created its own dt-binding document belonged to its corresponding subsystem. Don't we really want to follow it them all?
Ok, that's fine.
Re: [PATCH v1 02/16] dt-bindings: rtc: mediatek: add bindings for PMIC RTC
Quoted 24 lines · Sean Wang
Quoted 14 lines · Alexandre Belloni
Quoted 8 lines · Sean Wang
just reply both replies in the same mail
1.) the power-off device is a part of rtc, use the same registers rtc has and thus it is put as child nodes under the node rtc to reflect the reality of characteristics the rtc has.
Or am I wrong for a certain aspect in these opinions?
My point is that it is also part of the PMIC so it may as well be registers from the mfd driver which already registers a bunch of devices instead of doing unusual stuff from the rtc driver.
Quoted 7 lines
mt6397_rtc->regmapismt6397_chip->regmapanyway. You have the added benefit that if the RTC driver probe fails for some reason, you may still be able to probe the reset driver.I don't tink there is any benefit having it as a child of the rtc device.
Quoted 6 lines
really thanks! it's an optional solution I thought it 's fine and worth doing
but so far I cannot fully make sure of whether mfd can accept two devices holding overlay
IORESOURCE_MEM.
There is no overlay because you are using a regmap which handles concurrency for you.
What your patch is doing is:
struct mt6397_rtc *rtc = dev_get_drvdata(pdev->dev.parent);
then you use rtc->regmap
But in the rtc driver, you have:
struct mt6397_chip *mt6397_chip = dev_get_drvdata(pdev->dev.parent); struct mt6397_rtc *rtc;
rtc->regmap = mt6397_chip->regmap;
So there is no benefit from being the child of the rtc, you could just do the following in your reset driver:
struct mt6397_chip *mt6397_chip = dev_get_drvdata(pdev->dev.parent);
and then use mt6397_chip->regmap.
Signature · 3 lines
Alexandre Belloni, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
[email protected]
maintainerPATCH 3/16 dt-bindings: mfd: mediatek: add a description for MT6323 RTC
In reply to [email protected]From: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected]>
Add a description for MT6323 RTC and link it to the detailed binding documentation.
--- Documentation/devicetree/bindings/mfd/mt6397.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/mfd/mt6397.txt +3 -1
@@ -22,8 +22,10 @@ compatible: "mediatek,mt6397" or "mediatek,mt6323" Optional subnodes: - rtc - Required properties: + Required properties: Should be one of follows + - compatible: "mediatek,mt6323-rtc" - compatible: "mediatek,mt6397-rtc" + For details, see Documentation/devicetree/bindings/rtc/rtc-mt6397.txt - regulators Required properties: - compatible: "mediatek,mt6397-regulator"
Signature · 1 line
2.7.4
Re: [PATCH v1 03/16] dt-bindings: mfd: mediatek: add a description for MT6323 RTC
Quoted 9 lines · On Fri, Mar 23, 2018 at 05:15:00PM +0800, [email protected] wrote:
From: Sean Wang <[email protected]>
Add a description for MT6323 RTC and link it to the detailed binding documentation.
Signed-off-by Sean Wang <[email protected]>--- Documentation/devicetree/bindings/mfd/mt6397.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Re: [PATCH v1 03/16] dt-bindings: mfd: mediatek: add a description for MT6323 RTC
In reply to [email protected]Quoted 9 lines · On Fri, 23 Mar 2018, [email protected] wrote:
From: Sean Wang <[email protected]>
Add a description for MT6323 RTC and link it to the detailed binding documentation.
Signed-off-by Sean Wang <[email protected]>--- Documentation/devicetree/bindings/mfd/mt6397.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Signature · 4 lines
Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
[email protected]
maintainerPATCH 4/16 mfd: mt6397: add MT6323 RTC support into MT6397 driver
In reply to [email protected]From: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected]>
Add compatible string as "mt6323-rtc" that will make the OF core spawn child devices for the RTC subnode of that MT6323 MFD node.
--- drivers/mfd/mt6397-core.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
drivers/mfd/mt6397-core.c +22 -1
@@ -1,5 +1,5 @@/* -* Copyright (c) 2014 MediaTek Inc. +* Copyright (c) 2014-2018 MediaTek Inc. * Author: Flora Fu, MediaTek * * This program is free software; you can redistribute it and/or modify
@@ -23,6 +23,9 @@#include <linux/mfd/mt6397/registers.h> #include <linux/mfd/mt6323/registers.h> +#define MT6323_RTC_BASE 0x8000 +#define MT6323_RTC_SIZE 0x3e +#define MT6397_RTC_BASE 0xe000#define MT6397_RTC_SIZE 0x3e
@@ -30,6 +33,19 @@#define MT6391_CID_CODE 0x91#define MT6397_CID_CODE 0x97 +static const struct resource mt6323_rtc_resources[] = { + { + .start =MT6323_RTC_BASE , + .end =MT6323_RTC_BASE +MT6323_RTC_SIZE , + .flags =IORESOURCE_MEM , + }, + { + .start =MT6323_IRQ_STATUS_RTC , + .end =MT6323_IRQ_STATUS_RTC , + .flags =IORESOURCE_IRQ , + }, +}; +static const struct resource mt6397_rtc_resources[] = { { .start =MT6397_RTC_BASE ,
@@ -55,6 +71,11 @@ static const struct resource mt6397_keys_resources[] = {static const struct mfd_cell mt6323_devs[] = { { + .name ="mt6323-rtc" , + .num_resources =ARRAY_SIZE (mt6323_rtc_resources), + .resources = mt6323_rtc_resources, + .of_compatible ="mediatek,mt6323-rtc" , + }, { .name ="mt6323-regulator" , .of_compatible ="mediatek,mt6323-regulator" }, {
Signature · 1 line
2.7.4
Re: [PATCH v1 04/16] mfd: mt6397: add MT6323 RTC support into MT6397 driver
Quoted 37 lines · On Fri, 23 Mar 2018, [email protected] wrote:
From: Sean Wang <[email protected]>
Add compatible string as "mt6323-rtc" that will make the OF core spawn child devices for the RTC subnode of that MT6323 MFD node.
Signed-off-by Sean Wang <[email protected]>--- drivers/mfd/mt6397-core.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)drivers/mfd/mt6397-core.c +6
-1@@ -1,5 +1,5 @@/* -* Copyright (c) 2014 MediaTek Inc. +* Copyright (c) 2014-2018 MediaTek Inc. * Author: Flora Fu, MediaTek * * This program is free software; you can redistribute it and/or modify @@ -23,6 +23,9 @@#include <linux/mfd/mt6397/registers.h> #include <linux/mfd/mt6323/registers.h> +#define MT6323_RTC_BASE 0x8000 +#define MT6323_RTC_SIZE 0x3e +#define MT6397_RTC_BASE 0xe000#define MT6397_RTC_SIZE 0x3e@@ -30,6 +33,19 @@#define MT6391_CID_CODE 0x91#define MT6397_CID_CODE 0x97 +static const struct resource mt6323_rtc_resources[] = { + {
drivers/mfd/mt6397-core.c line 47
Quoted 10 lines
drivers/mfd/mt6397-core.c +10
-0+ .start = MT6323_RTC_BASE, + .end = MT6323_RTC_BASE + MT6323_RTC_SIZE, + .flags = IORESOURCE_MEM, + }, + { + .start = MT6323_IRQ_STATUS_RTC, + .end = MT6323_IRQ_STATUS_RTC, + .flags = IORESOURCE_IRQ, + }, +};
Please use the DEFINE_RES_* helpers instead.
Defined in: include/linux/ioport.h
Quoted 15 lines
drivers/mfd/mt6397-core.c +5
-0static const struct resource mt6397_rtc_resources[] = { { .start =MT6397_RTC_BASE ,@@ -55,6 +71,11 @@ static const struct resource mt6397_keys_resources[] = {static const struct mfd_cell mt6323_devs[] = { { + .name ="mt6323-rtc" , + .num_resources =ARRAY_SIZE (mt6323_rtc_resources), + .resources = mt6323_rtc_resources, + .of_compatible ="mediatek,mt6323-rtc" , + }, { .name ="mt6323-regulator" , .of_compatible ="mediatek,mt6323-regulator" }, {
Signature · 9 lines
Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
[email protected]
maintainerPATCH 5/16 rtc: mediatek: add MT6323 support to RTC driver
In reply to [email protected]From: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected]>
Just to add MT6323 support to the existent RTC driver.
--- drivers/rtc/rtc-mt6397.c | 1 + 1 file changed, 1 insertion(+)
drivers/rtc/rtc-mt6397.c +1 -0
@@ -398,6 +398,7 @@ static SIMPLE_DEV_PM_OPS(mt6397_pm_ops, mt6397_rtc_suspend, mt6397_rtc_resume);static const struct of_device_id mt6397_rtc_of_match[] = { + { .compatible ="mediatek,mt6323-rtc" , }, { .compatible ="mediatek,mt6397-rtc" , }, { } };
Signature · 1 line
2.7.4
Re: [PATCH v1 05/16] rtc: mediatek: add MT6323 support to RTC driver
Hi,
The subject line should be rtc: mt6397: (to differentiate with rtc-mt7622)
Quoted 24 lines · On 23/03/2018 at 17:15:02 +0800, [email protected] wrote:
From: Sean Wang <[email protected]>
Just to add MT6323 support to the existent RTC driver.
Signed-off-by Sean Wang <[email protected]>--- drivers/rtc/rtc-mt6397.c | 1 + 1 file changed, 1 insertion(+)drivers/rtc/rtc-mt6397.c +1
-0@@ -398,6 +398,7 @@ static SIMPLE_DEV_PM_OPS(mt6397_pm_ops, mt6397_rtc_suspend, mt6397_rtc_resume);static const struct of_device_id mt6397_rtc_of_match[] = { + { .compatible ="mediatek,mt6323-rtc" , }, { .compatible ="mediatek,mt6397-rtc" , }, { } };Signature · 1 line
2.7.4
Signature · 3 lines
Alexandre Belloni, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
Sean Wang
maintainerRe: [PATCH v1 05/16] rtc: mediatek: add MT6323 support to RTC driver
Quoted 4 lines · Alexandre Belloni
Hi,
The subject line should be rtc: mt6397: (to differentiate with rtc-mt7622)
Sure, I will change subject line into rtc: mt6397: along with the other related patches.
Quoted 26 lines · On 23/03/2018 at 17:15:02 +0800, [email protected] wrote:
Quoted 24 lines
From: Sean Wang <[email protected]>
Just to add MT6323 support to the existent RTC driver.
Signed-off-by Sean Wang <[email protected]>--- drivers/rtc/rtc-mt6397.c | 1 + 1 file changed, 1 insertion(+)drivers/rtc/rtc-mt6397.c +1
-0@@ -398,6 +398,7 @@ static SIMPLE_DEV_PM_OPS(mt6397_pm_ops, mt6397_rtc_suspend, mt6397_rtc_resume);static const struct of_device_id mt6397_rtc_of_match[] = { + { .compatible ="mediatek,mt6323-rtc" , }, { .compatible ="mediatek,mt6397-rtc" , }, { } };Signature · 1 line
2.7.4
[email protected]
maintainerPATCH 6/16 rtc: mediatek: remove unnecessary parentheses
In reply to [email protected]From: Sean Wang <[email protected]>
Remove unnecessary parentheses due to explicit C operator precedence.
--- drivers/rtc/rtc-mt6397.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-mt6397.c +1 -1
@@ -106,7 +106,7 @@ static irqreturn_t mtk_rtc_irq_handler_thread(int irq, void *data)int ret; ret =regmap_read (rtc->regmap, rtc->addr_base +RTC_IRQ_STA , &irqsta); -if ((ret >=0 ) && (irqsta &RTC_IRQ_STA_AL )) { +if (ret >=0 && irqsta &RTC_IRQ_STA_AL ) {rtc_update_irq (rtc->rtc_dev,1 ,RTC_IRQF |RTC_AF ); irqen = irqsta & ~RTC_IRQ_EN_AL ;mutex_lock (&rtc->lock);
Signature · 1 line
2.7.4
Re: [PATCH v1 06/16] rtc: mediatek: remove unnecessary parentheses
Quoted 14 lines · On 23/03/2018 at 17:15:03 +0800, [email protected] wrote:
From: Sean Wang <[email protected]>
Remove unnecessary parentheses due to explicit C operator precedence.
Signed-off-by Sean Wang <[email protected]>--- drivers/rtc/rtc-mt6397.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/rtc/rtc-mt6397.c +0
-0
drivers/rtc/rtc-mt6397.c static irqreturn_t mtk_rtc_irq_handler_thread(int irq, void *data) · line 109
Quoted 5 lines
drivers/rtc/rtc-mt6397.c +1
-1@@ -106,7 +106,7 @@ static irqreturn_t mtk_rtc_irq_handler_thread(int irq, void *data)int ret; ret =regmap_read (rtc->regmap, rtc->addr_base +RTC_IRQ_STA , &irqsta); -if ((ret >=0 ) && (irqsta &RTC_IRQ_STA_AL )) { +if (ret >=0 && irqsta &RTC_IRQ_STA_AL ) {
I don't think this makes the code particularly clearer.
Quoted 6 lines
drivers/rtc/rtc-mt6397.c +0
-0rtc_update_irq (rtc->rtc_dev,1 ,RTC_IRQF |RTC_AF ); irqen = irqsta & ~RTC_IRQ_EN_AL ;mutex_lock (&rtc->lock);Signature · 1 line
2.7.4
Signature · 3 lines
Alexandre Belloni, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
Sean Wang
maintainerRe: [PATCH v1 06/16] rtc: mediatek: remove unnecessary parentheses
Quoted 17 lines · Alexandre Belloni
Quoted 16 lines · On 23/03/2018 at 17:15:03 +0800, [email protected] wrote:
From: Sean Wang <[email protected]>
Remove unnecessary parentheses due to explicit C operator precedence.
Signed-off-by Sean Wang <[email protected]>--- drivers/rtc/rtc-mt6397.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/rtc/rtc-mt6397.c +0
-0@@ -106,7 +106,7 @@ static irqreturn_t mtk_rtc_irq_handler_thread(int irq, void *data)int ret;
Quoted 6 lines
drivers/rtc/rtc-mt6397.c static irqreturn_t mtk_rtc_irq_handler_thread(int irq, void *data) · line 109
Quoted 3 lines
drivers/rtc/rtc-mt6397.c +1
-1ret =regmap_read (rtc->regmap, rtc->addr_base +RTC_IRQ_STA , &irqsta); -if ((ret >=0 ) && (irqsta &RTC_IRQ_STA_AL )) { +if (ret >=0 && irqsta &RTC_IRQ_STA_AL ) {I don't think this makes the code particularly clearer.
But it is still a one of check items in checkpatch
CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around 'ret >= 0' #126: FILE: drivers/rtc/rtc-xxx.c:109:
+ if ((ret >= 0) && (irqsta & RTC_IRQ_STA_AL)) {
or we still want to keep it in parentheses around here?
Quoted 7 lines
Quoted 6 lines
drivers/rtc/rtc-mt6397.c +0
-0rtc_update_irq (rtc->rtc_dev,1 ,RTC_IRQF |RTC_AF ); irqen = irqsta & ~RTC_IRQ_EN_AL ;mutex_lock (&rtc->lock);Signature · 1 line
2.7.4
Re: [PATCH v1 06/16] rtc: mediatek: remove unnecessary parentheses
Quoted 25 lines · Sean Wang
Quoted 17 lines · Alexandre Belloni
Quoted 16 lines · On 23/03/2018 at 17:15:03 +0800, [email protected] wrote:
From: Sean Wang <[email protected]>
Remove unnecessary parentheses due to explicit C operator precedence.
Signed-off-by Sean Wang <[email protected]>--- drivers/rtc/rtc-mt6397.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/rtc/rtc-mt6397.c +0
-0@@ -106,7 +106,7 @@ static irqreturn_t mtk_rtc_irq_handler_thread(int irq, void *data)int ret;Quoted 6 lines
drivers/rtc/rtc-mt6397.c static irqreturn_t mtk_rtc_irq_handler_thread(int irq, void *data) · line 109
Quoted 3 lines
drivers/rtc/rtc-mt6397.c +1
-1ret =regmap_read (rtc->regmap, rtc->addr_base +RTC_IRQ_STA , &irqsta); -if ((ret >=0 ) && (irqsta &RTC_IRQ_STA_AL )) { +if (ret >=0 && irqsta &RTC_IRQ_STA_AL ) {I don't think this makes the code particularly clearer.
Quoted 9 lines
But it is still a one of check items in checkpatch
CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around 'ret >= 0' #126: FILE:
drivers/rtc/rtc-xxx.c:109:
+ if ((ret >= 0) && (irqsta &RTC_IRQ_STA_AL)) {or we still want to keep it in parentheses around here?
Yeah, this is a matter of taste, I would keep the parentheses.
Signature · 3 lines
Alexandre Belloni, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
Sean Wang
maintainerRe: [PATCH v1 06/16] rtc: mediatek: remove unnecessary parentheses
Quoted 33 lines · Alexandre Belloni
Quoted 32 lines · Sean Wang
Quoted 17 lines · Alexandre Belloni
Quoted 16 lines · On 23/03/2018 at 17:15:03 +0800, [email protected] wrote:
From: Sean Wang <[email protected]>
Remove unnecessary parentheses due to explicit C operator precedence.
Signed-off-by Sean Wang <[email protected]>--- drivers/rtc/rtc-mt6397.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/rtc/rtc-mt6397.c +0
-0@@ -106,7 +106,7 @@ static irqreturn_t mtk_rtc_irq_handler_thread(int irq, void *data)int ret;Quoted 6 lines
drivers/rtc/rtc-mt6397.c static irqreturn_t mtk_rtc_irq_handler_thread(int irq, void *data) · line 109
Quoted 3 lines
drivers/rtc/rtc-mt6397.c +1
-1ret =regmap_read (rtc->regmap, rtc->addr_base +RTC_IRQ_STA , &irqsta); -if ((ret >=0 ) && (irqsta &RTC_IRQ_STA_AL )) { +if (ret >=0 && irqsta &RTC_IRQ_STA_AL ) {I don't think this makes the code particularly clearer.
But it is still a one of check items in checkpatch
CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around 'ret >= 0' #126: FILE:
drivers/rtc/rtc-xxx.c:109:
+ if ((ret >= 0) && (irqsta &RTC_IRQ_STA_AL)) {
Quoted 4 lines
Quoted 2 lines
or we still want to keep it in parentheses around here?
Yeah, this is a matter of taste, I would keep the parentheses.
okay, lets keep the parentheses
Quoted 2 lines
[email protected]
maintainerPATCH 7/16 rtc: mediatek: replace a poll with regmap_read_poll_timeout
In reply to [email protected]From: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected]>
Reuse the helper regmap_read_poll_timeout instead to simpify the logic.
Furthermore, the time for a wait in each iteration changed from cpu_relax to 20us is for matching the usage of the helper, but it wouldn't acctually break any the existent functionality according to a good test on MT6323 PMIC.
--- drivers/rtc/rtc-mt6397.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-)
drivers/rtc/rtc-mt6397.c +11 -14
@@ -18,6 +18,7 @@#include <linux/regmap.h> #include <linux/rtc.h> #include <linux/irqdomain.h> +#include <linux/jiffies.h> #include <linux/platform_device.h> #include <linux/of_address.h> #include <linux/of_irq.h>
@@ -63,6 +64,9 @@#define RTC_NUM_YEARS 128#define RTC_MIN_YEAR_OFFSET (RTC_MIN_YEAR - RTC_BASE_YEAR) +#define MTK_RTC_POLL_DELAY_US 10 +#define MTK_RTC_POLL_TIMEOUT (jiffies_to_usecs(HZ)) +struct mt6397_rtc {struct device *dev;struct rtc_device *rtc_dev;
@@ -74,7 +78,6 @@ struct mt6397_rtc {static int mtk_rtc_write_trigger (struct mt6397_rtc *rtc) { -unsigned long timeout = jiffies +HZ ;int ret;u32 data;
@@ -82,19 +85,13 @@ static int mtk_rtc_write_trigger(struct mt6397_rtc *rtc)if (ret <0 )return ret; -while (1 ) { - ret =regmap_read (rtc->regmap, rtc->addr_base +RTC_BBPU , - &data); -if (ret <0 ) -break ; -if (!(data &RTC_BBPU_CBUSY )) -break ; -if (time_after (jiffies, timeout)) { - ret = -ETIMEDOUT ; -break ; - } -cpu_relax (); - } + ret =regmap_read_poll_timeout (rtc->regmap, + rtc->addr_base +RTC_BBPU , data, + !(data &RTC_BBPU_CBUSY ), +MTK_RTC_POLL_DELAY_US , +MTK_RTC_POLL_TIMEOUT ); +if (ret) +dev_err (rtc->dev,"failed to write WRTGE: %d\n" , ret);return ret; }
Signature · 1 line
2.7.4
[email protected]
maintainerPATCH 8/16 rtc: mediatek: remove unnecessary irq_dispose_mapping
In reply to [email protected]From: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected]>
It's unnecessary doing irq_dispose_mapping as a reverse operation for platform_get_irq.
Ususally, irq_dispose_mapping should be called in error path or module removal to release the resources for irq_of_parse_and_map requested.
--- drivers/rtc/rtc-mt6397.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/rtc/rtc-mt6397.c +2 -5
@@ -17,7 +17,6 @@#include <linux/module.h> #include <linux/regmap.h> #include <linux/rtc.h> -#include <linux/irqdomain.h> #include <linux/jiffies.h> #include <linux/platform_device.h> #include <linux/of_address.h>
@@ -336,7 +335,7 @@ static int mtk_rtc_probe(struct platform_device *pdev)if (ret) {dev_err (&pdev->dev,"Failed to request alarm IRQ: %d: %d\n" , rtc->irq, ret); - goto out_dispose_irq; +return ret; }device_init_wakeup (&pdev->dev,1 );
@@ -353,8 +352,7 @@ static int mtk_rtc_probe(struct platform_device *pdev) out_free_irq:free_irq (rtc->irq, rtc->rtc_dev); -out_dispose_irq: -irq_dispose_mapping (rtc->irq); +return ret; }
@@ -364,7 +362,6 @@ static int mtk_rtc_remove(struct platform_device *pdev)rtc_device_unregister (rtc->rtc_dev);free_irq (rtc->irq, rtc->rtc_dev); -irq_dispose_mapping (rtc->irq);return 0 ; }
Signature · 1 line
2.7.4
Re: [PATCH v1 08/16] rtc: mediatek: remove unnecessary irq_dispose_mapping
Quoted 35 lines · On 23/03/2018 at 17:15:05 +0800, [email protected] wrote:
From: Sean Wang <[email protected]>
It's unnecessary doing
irq_dispose_mappingas a reverse operation forplatform_get_irq.Ususally,
irq_dispose_mappingshould be called in error path or module removal to release the resources forirq_of_parse_and_maprequested.Signed-off-by Sean Wang <[email protected]>--- drivers/rtc/rtc-mt6397.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/rtc/rtc-mt6397.c +1
-2@@ -17,7 +17,6 @@#include <linux/module.h> #include <linux/regmap.h> #include <linux/rtc.h> -#include <linux/irqdomain.h> #include <linux/jiffies.h> #include <linux/platform_device.h> #include <linux/of_address.h> @@ -336,7 +335,7 @@ static int mtk_rtc_probe(struct platform_device *pdev)if (ret) {dev_err (&pdev->dev,"Failed to request alarm IRQ: %d: %d\n" , rtc->irq, ret); - goto out_dispose_irq; +return ret; }device_init_wakeup (&pdev->dev,1 );
drivers/rtc/rtc-mt6397.c static int mtk_rtc_probe(struct platform_device *pdev) · line 355
Quoted 6 lines
drivers/rtc/rtc-mt6397.c +1
-2@@ -353,8 +352,7 @@ static int mtk_rtc_probe(struct platform_device *pdev) out_free_irq:free_irq (rtc->irq, rtc->rtc_dev); -out_dispose_irq: -irq_dispose_mapping (rtc->irq); +
Don't you still have a irq_create_mapping?
Quoted 14 lines
drivers/rtc/rtc-mt6397.c +0
-1return ret; }@@ -364,7 +362,6 @@ static int mtk_rtc_remove(struct platform_device *pdev)rtc_device_unregister (rtc->rtc_dev);free_irq (rtc->irq, rtc->rtc_dev); -irq_dispose_mapping (rtc->irq);return 0 ; }Signature · 1 line
2.7.4
Signature · 3 lines
Alexandre Belloni, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
Sean Wang
maintainerRe: [PATCH v1 08/16] rtc: mediatek: remove unnecessary irq_dispose_mapping
Quoted 37 lines · Alexandre Belloni
Quoted 36 lines · On 23/03/2018 at 17:15:05 +0800, [email protected] wrote:
From: Sean Wang <[email protected]>
It's unnecessary doing
irq_dispose_mappingas a reverse operation forplatform_get_irq.Ususally,
irq_dispose_mappingshould be called in error path or module removal to release the resources forirq_of_parse_and_maprequested.Signed-off-by Sean Wang <[email protected]>--- drivers/rtc/rtc-mt6397.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/rtc/rtc-mt6397.c +1
-2@@ -17,7 +17,6 @@#include <linux/module.h> #include <linux/regmap.h> #include <linux/rtc.h> -#include <linux/irqdomain.h> #include <linux/jiffies.h> #include <linux/platform_device.h> #include <linux/of_address.h> @@ -336,7 +335,7 @@ static int mtk_rtc_probe(struct platform_device *pdev)if (ret) {dev_err (&pdev->dev,"Failed to request alarm IRQ: %d: %d\n" , rtc->irq, ret); - goto out_dispose_irq; +return ret; }device_init_wakeup (&pdev->dev,1 );@@ -353,8 +352,7 @@ static int mtk_rtc_probe(struct platform_device *pdev)
Quoted 8 lines
drivers/rtc/rtc-mt6397.c static int mtk_rtc_probe(struct platform_device *pdev) · line 355
Quoted 5 lines
drivers/rtc/rtc-mt6397.c +1
-2out_free_irq:free_irq (rtc->irq, rtc->rtc_dev); -out_dispose_irq: -irq_dispose_mapping (rtc->irq); +Don't you still have a
irq_create_mapping?
Sorry for that I didn't mention in the beginning that the series must depend on another patch [1]. With the patch, the job irq_create_mapping had been moved from rtc to mfd, so here it should be better to cleanup up irq_dispose_mapping in all paths.
[1] https://patchwork.kernel.org/patch/9954643/
Quoted 15 lines
Quoted 14 lines
drivers/rtc/rtc-mt6397.c +0
-1return ret; }@@ -364,7 +362,6 @@ static int mtk_rtc_remove(struct platform_device *pdev)rtc_device_unregister (rtc->rtc_dev);free_irq (rtc->irq, rtc->rtc_dev); -irq_dispose_mapping (rtc->irq);return 0 ; }Signature · 1 line
2.7.4
[email protected]
maintainerPATCH 9/16 rtc: mediatek: convert to use device managed functions
In reply to [email protected]From: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected]>
Use device managed operation to simplify error handling, reduce source code size, and reduce the likelyhood of bugs, and remove our removal callback which contains anything already done by device managed functions.
--- drivers/rtc/rtc-mt6397.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-)
drivers/rtc/rtc-mt6397.c +8 -23
@@ -14,6 +14,7 @@#include <linux/delay.h> #include <linux/init.h> +#include <linux/interrupt.h> #include <linux/module.h> #include <linux/regmap.h> #include <linux/rtc.h>
@@ -328,10 +329,10 @@ static int mtk_rtc_probe(struct platform_device *pdev)platform_set_drvdata (pdev, rtc); - ret =request_threaded_irq (rtc->irq,NULL , - mtk_rtc_irq_handler_thread, -IRQF_ONESHOT |IRQF_TRIGGER_HIGH , -"mt6397-rtc" , rtc); + ret =devm_request_threaded_irq (&pdev->dev, rtc->irq,NULL , + mtk_rtc_irq_handler_thread, +IRQF_ONESHOT |IRQF_TRIGGER_HIGH , +"mt6397-rtc" , rtc);if (ret) {dev_err (&pdev->dev,"Failed to request alarm IRQ: %d: %d\n" , rtc->irq, ret);
@@ -340,30 +341,15 @@ static int mtk_rtc_probe(struct platform_device *pdev)device_init_wakeup (&pdev->dev,1 ); - rtc->rtc_dev =rtc_device_register ("mt6397-rtc" , &pdev->dev, - &mtk_rtc_ops,THIS_MODULE ); + rtc->rtc_dev =devm_rtc_device_register (&pdev->dev,"mt6397-rtc" , + &mtk_rtc_ops,THIS_MODULE );if (IS_ERR (rtc->rtc_dev)) {dev_err (&pdev->dev,"register rtc device failed\n" ); ret =PTR_ERR (rtc->rtc_dev); - goto out_free_irq; +return ret; }return 0 ; - -out_free_irq: -free_irq (rtc->irq, rtc->rtc_dev); - -return ret; -} - -static int mtk_rtc_remove (struct platform_device *pdev) -{ -struct mt6397_rtc *rtc =platform_get_drvdata (pdev); - -rtc_device_unregister (rtc->rtc_dev); -free_irq (rtc->irq, rtc->rtc_dev); - -return 0 ; }#ifdef CONFIG_PM_SLEEP
@@ -405,7 +391,6 @@ static struct platform_driver mtk_rtc_driver = { .pm = &mt6397_pm_ops, }, .probe = mtk_rtc_probe, - .remove = mtk_rtc_remove, };module_platform_driver (mtk_rtc_driver);
Signature · 1 line
2.7.4
Re: [PATCH v1 09/16] rtc: mediatek: convert to use device managed functions
Quoted 39 lines · On 23/03/2018 at 17:15:06 +0800, [email protected] wrote:
From: Sean Wang <[email protected]>
Use device managed operation to simplify error handling, reduce source code size, and reduce the likelyhood of bugs, and remove our removal callback which contains anything already done by device managed functions.
Signed-off-by Sean Wang <[email protected]>--- drivers/rtc/rtc-mt6397.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-)drivers/rtc/rtc-mt6397.c +5
-4@@ -14,6 +14,7 @@#include <linux/delay.h> #include <linux/init.h> +#include <linux/interrupt.h> #include <linux/module.h> #include <linux/regmap.h> #include <linux/rtc.h> @@ -328,10 +329,10 @@ static int mtk_rtc_probe(struct platform_device *pdev)platform_set_drvdata (pdev, rtc); - ret =request_threaded_irq (rtc->irq,NULL , - mtk_rtc_irq_handler_thread, -IRQF_ONESHOT |IRQF_TRIGGER_HIGH , -"mt6397-rtc" , rtc); + ret =devm_request_threaded_irq (&pdev->dev, rtc->irq,NULL , + mtk_rtc_irq_handler_thread, +IRQF_ONESHOT |IRQF_TRIGGER_HIGH , +"mt6397-rtc" , rtc);if (ret) {dev_err (&pdev->dev,"Failed to request alarm IRQ: %d: %d\n" , rtc->irq, ret);
drivers/rtc/rtc-mt6397.c static int mtk_rtc_probe(struct platform_device *pdev) · line 345
Quoted 7 lines
drivers/rtc/rtc-mt6397.c +2
-2@@ -340,30 +341,15 @@ static int mtk_rtc_probe(struct platform_device *pdev)device_init_wakeup (&pdev->dev,1 ); - rtc->rtc_dev =rtc_device_register ("mt6397-rtc" , &pdev->dev, - &mtk_rtc_ops,THIS_MODULE ); + rtc->rtc_dev =devm_rtc_device_register (&pdev->dev,"mt6397-rtc" , + &mtk_rtc_ops,THIS_MODULE );
You should probably switch to devm_rtc_allocate_device() and rtc_register_device instead of devm_rtc_device_register.
drivers/rtc/rtc-mt6397.c static int mtk_rtc_probe(struct platform_device *pdev) · line 349
Quoted 5 lines
drivers/rtc/rtc-mt6397.c +1
-1if (IS_ERR (rtc->rtc_dev)) {dev_err (&pdev->dev,"register rtc device failed\n" ); ret =PTR_ERR (rtc->rtc_dev); - goto out_free_irq; +return ret;
ret doesn't seem necessary anymore here.
Signature · 3 lines
Alexandre Belloni, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
Sean Wang
maintainerRe: [PATCH v1 09/16] rtc: mediatek: convert to use device managed functions
Quoted 43 lines · Alexandre Belloni
Quoted 42 lines · On 23/03/2018 at 17:15:06 +0800, [email protected] wrote:
From: Sean Wang <[email protected]>
Use device managed operation to simplify error handling, reduce source code size, and reduce the likelyhood of bugs, and remove our removal callback which contains anything already done by device managed functions.
Signed-off-by Sean Wang <[email protected]>--- drivers/rtc/rtc-mt6397.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-)drivers/rtc/rtc-mt6397.c +5
-4@@ -14,6 +14,7 @@#include <linux/delay.h> #include <linux/init.h> +#include <linux/interrupt.h> #include <linux/module.h> #include <linux/regmap.h> #include <linux/rtc.h> @@ -328,10 +329,10 @@ static int mtk_rtc_probe(struct platform_device *pdev)platform_set_drvdata (pdev, rtc); - ret =request_threaded_irq (rtc->irq,NULL , - mtk_rtc_irq_handler_thread, -IRQF_ONESHOT |IRQF_TRIGGER_HIGH , -"mt6397-rtc" , rtc); + ret =devm_request_threaded_irq (&pdev->dev, rtc->irq,NULL , + mtk_rtc_irq_handler_thread, +IRQF_ONESHOT |IRQF_TRIGGER_HIGH , +"mt6397-rtc" , rtc);if (ret) {dev_err (&pdev->dev,"Failed to request alarm IRQ: %d: %d\n" , rtc->irq, ret);@@ -340,30 +341,15 @@ static int mtk_rtc_probe(struct platform_device *pdev)device_init_wakeup (&pdev->dev,1 );
Quoted 8 lines
drivers/rtc/rtc-mt6397.c static int mtk_rtc_probe(struct platform_device *pdev) · line 345
Quoted 4 lines
drivers/rtc/rtc-mt6397.c +2
-2- rtc->rtc_dev =rtc_device_register ("mt6397-rtc" , &pdev->dev, - &mtk_rtc_ops,THIS_MODULE ); + rtc->rtc_dev =devm_rtc_device_register (&pdev->dev,"mt6397-rtc" , + &mtk_rtc_ops,THIS_MODULE );You should probably switch to
devm_rtc_allocate_device()andrtc_register_deviceinstead ofdevm_rtc_device_register.
Just would like to know something details
It seems you just encourage me to switch into the new registration method and currently devm_rtc_device_register I used for the driver shouldn't cause any harm. right?
Quoted 7 lines
drivers/rtc/rtc-mt6397.c static int mtk_rtc_probe(struct platform_device *pdev) · line 349
Quoted 5 lines
drivers/rtc/rtc-mt6397.c +1
-1if (IS_ERR (rtc->rtc_dev)) {dev_err (&pdev->dev,"register rtc device failed\n" ); ret =PTR_ERR (rtc->rtc_dev); - goto out_free_irq; +return ret;ret doesn't seem necessary anymore here.
okay, it'll be removed
Quoted 2 lines
Re: [PATCH v1 09/16] rtc: mediatek: convert to use device managed functions
Quoted 9 lines · Sean Wang
Quoted 8 lines
drivers/rtc/rtc-mt6397.c static int mtk_rtc_probe(struct platform_device *pdev) · line 345
Quoted 4 lines
drivers/rtc/rtc-mt6397.c +2
-2- rtc->rtc_dev =rtc_device_register ("mt6397-rtc" , &pdev->dev, - &mtk_rtc_ops,THIS_MODULE ); + rtc->rtc_dev =devm_rtc_device_register (&pdev->dev,"mt6397-rtc" , + &mtk_rtc_ops,THIS_MODULE );You should probably switch to
devm_rtc_allocate_device()andrtc_register_deviceinstead ofdevm_rtc_device_register.
Quoted 6 lines
Just would like to know something details
It seems you just encourage me to switch into the new registration method and currently
devm_rtc_device_registerI used for the driver shouldn't cause any harm. right?
It will work but it will have to be converted to rtc_register_device later anyway.
Signature · 3 lines
Alexandre Belloni, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
[email protected]
maintainerPATCH 10/16 rtc: mediatek: add devm_of_platform_populate
In reply to [email protected]From: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected]>
Add devm_of_platform_populate to populate all child nodes according to the dt-binding.
--- drivers/rtc/rtc-mt6397.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/rtc/rtc-mt6397.c +2 -1
@@ -16,6 +16,7 @@#include <linux/init.h> #include <linux/interrupt.h> #include <linux/module.h> +#include <linux/of_platform.h> #include <linux/regmap.h> #include <linux/rtc.h> #include <linux/jiffies.h>
@@ -349,7 +350,7 @@ static int mtk_rtc_probe(struct platform_device *pdev)return ret; } -return 0 ; +return devm_of_platform_populate (&pdev->dev); }#ifdef CONFIG_PM_SLEEP
Signature · 1 line
2.7.4
[email protected]
maintainerPATCH 11/16 rtc: mediatek: move the declaration into a globally visible header file
In reply to [email protected]From: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected]>
This is in preparation for allowing other drivers can share the declaration, so move the declaration into a globally visible header file.
--- drivers/rtc/rtc-mt6397.c | 53 +--------------------------------- include/linux/rtc/mt6397.h | 72 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 52 deletions(-) create mode 100644 include/linux/rtc/mt6397.h
drivers/rtc/rtc-mt6397.c +1 -52
@@ -19,63 +19,12 @@#include <linux/of_platform.h> #include <linux/regmap.h> #include <linux/rtc.h> -#include <linux/jiffies.h> #include <linux/platform_device.h> #include <linux/of_address.h> #include <linux/of_irq.h> #include <linux/io.h> #include <linux/mfd/mt6397/core.h> - -#define RTC_BBPU 0x0000 -#define RTC_BBPU_CBUSY BIT(6) - -#define RTC_WRTGR 0x003c - -#define RTC_IRQ_STA 0x0002 -#define RTC_IRQ_STA_AL BIT(0) -#define RTC_IRQ_STA_LP BIT(3) - -#define RTC_IRQ_EN 0x0004 -#define RTC_IRQ_EN_AL BIT(0) -#define RTC_IRQ_EN_ONESHOT BIT(2) -#define RTC_IRQ_EN_LP BIT(3) -#define RTC_IRQ_EN_ONESHOT_AL (RTC_IRQ_EN_ONESHOT | RTC_IRQ_EN_AL) - -#define RTC_AL_MASK 0x0008 -#define RTC_AL_MASK_DOW BIT(4) - -#define RTC_TC_SEC 0x000a -/* Min, Hour, Dom... register offset to RTC_TC_SEC */ -#define RTC_OFFSET_SEC 0 -#define RTC_OFFSET_MIN 1 -#define RTC_OFFSET_HOUR 2 -#define RTC_OFFSET_DOM 3 -#define RTC_OFFSET_DOW 4 -#define RTC_OFFSET_MTH 5 -#define RTC_OFFSET_YEAR 6 -#define RTC_OFFSET_COUNT 7 - -#define RTC_AL_SEC 0x0018 - -#define RTC_PDN2 0x002e -#define RTC_PDN2_PWRON_ALARM BIT(4) - -#define RTC_MIN_YEAR 1968 -#define RTC_BASE_YEAR 1900 -#define RTC_NUM_YEARS 128 -#define RTC_MIN_YEAR_OFFSET (RTC_MIN_YEAR - RTC_BASE_YEAR) - -#define MTK_RTC_POLL_DELAY_US 10 -#define MTK_RTC_POLL_TIMEOUT (jiffies_to_usecs(HZ)) - -struct mt6397_rtc { -struct device *dev; -struct rtc_device *rtc_dev; -struct mutex lock; -struct regmap *regmap; -int irq; -u32 addr_base; -}; +#include <linux/rtc/mt6397.h> static int mtk_rtc_write_trigger (struct mt6397_rtc *rtc) {
include/linux/rtc/mt6397.h new file +72 -0
72 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH v1 11/16] rtc: mediatek: move the declaration into a globally visible header file
Quoted 9 lines · On 23/03/2018 at 17:15:08 +0800, sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected].…
From: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected]>
This is in preparation for allowing other drivers can share the declaration, so move the declaration into a globally visible header file.
--- drivers/rtc/rtc-mt6397.c | 53 +--------------------------------- include/linux/rtc/mt6397.h | 72 ++++++++++++++++++++++++++++++++++++++++++++++
This should go in include/linux/mfd/
Quoted 78 lines
2 files changed, 73 insertions(+), 52 deletions(-) create mode 100644 include/linux/rtc/mt6397.hdrivers/rtc/rtc-mt6397.c +1
-52@@ -19,63 +19,12 @@#include <linux/of_platform.h> #include <linux/regmap.h> #include <linux/rtc.h> -#include <linux/jiffies.h> #include <linux/platform_device.h> #include <linux/of_address.h> #include <linux/of_irq.h> #include <linux/io.h> #include <linux/mfd/mt6397/core.h> - -#define RTC_BBPU 0x0000 -#define RTC_BBPU_CBUSY BIT(6) - -#define RTC_WRTGR 0x003c - -#define RTC_IRQ_STA 0x0002 -#define RTC_IRQ_STA_AL BIT(0) -#define RTC_IRQ_STA_LP BIT(3) - -#define RTC_IRQ_EN 0x0004 -#define RTC_IRQ_EN_AL BIT(0) -#define RTC_IRQ_EN_ONESHOT BIT(2) -#define RTC_IRQ_EN_LP BIT(3) -#define RTC_IRQ_EN_ONESHOT_AL (RTC_IRQ_EN_ONESHOT | RTC_IRQ_EN_AL) - -#define RTC_AL_MASK 0x0008 -#define RTC_AL_MASK_DOW BIT(4) - -#define RTC_TC_SEC 0x000a -/* Min, Hour, Dom... register offset to RTC_TC_SEC */ -#define RTC_OFFSET_SEC 0 -#define RTC_OFFSET_MIN 1 -#define RTC_OFFSET_HOUR 2 -#define RTC_OFFSET_DOM 3 -#define RTC_OFFSET_DOW 4 -#define RTC_OFFSET_MTH 5 -#define RTC_OFFSET_YEAR 6 -#define RTC_OFFSET_COUNT 7 - -#define RTC_AL_SEC 0x0018 - -#define RTC_PDN2 0x002e -#define RTC_PDN2_PWRON_ALARM BIT(4) - -#define RTC_MIN_YEAR 1968 -#define RTC_BASE_YEAR 1900 -#define RTC_NUM_YEARS 128 -#define RTC_MIN_YEAR_OFFSET (RTC_MIN_YEAR - RTC_BASE_YEAR) - -#define MTK_RTC_POLL_DELAY_US 10 -#define MTK_RTC_POLL_TIMEOUT (jiffies_to_usecs(HZ)) - -struct mt6397_rtc { -struct device *dev; -struct rtc_device *rtc_dev; -struct mutex lock; -struct regmap *regmap; -int irq; -u32 addr_base; -}; +#include <linux/rtc/mt6397.h> static int mtk_rtc_write_trigger (struct mt6397_rtc *rtc) {include/linux/rtc/mt6397.h new file +0
-0
include/linux/rtc/mt6397.h line 1
Quoted 1 line
include/linux/rtc/mt6397.h new file +1
-0@@ -0,0 +1,72 @@ +
Unnecessary empty line
Quoted 74 lines
include/linux/rtc/mt6397.h new file +71
-0+// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2014-2018 MediaTek Inc. +* +* Author: Tianping.Fang <tianping.fang-NuS5LvNUpcJWk0Htik3J/[email protected]> +* Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected]> +*/ + +#ifndef _LINUX_RTC_MT6397_H_ +#define _LINUX_RTC_MT6397_H_ + +#include <linux/jiffies.h> +#include <linux/mutex.h> +#include <linux/regmap.h> +#include <linux/rtc.h> + +#define RTC_BBPU 0x0000 +#define RTC_BBPU_CBUSY BIT(6) + +#define RTC_WRTGR 0x003c + +#define RTC_IRQ_STA 0x0002 +#define RTC_IRQ_STA_AL BIT(0) +#define RTC_IRQ_STA_LP BIT(3) + +#define RTC_IRQ_EN 0x0004 +#define RTC_IRQ_EN_AL BIT(0) +#define RTC_IRQ_EN_ONESHOT BIT(2) +#define RTC_IRQ_EN_LP BIT(3) +#define RTC_IRQ_EN_ONESHOT_AL (RTC_IRQ_EN_ONESHOT | RTC_IRQ_EN_AL) + +#define RTC_AL_MASK 0x0008 +#define RTC_AL_MASK_DOW BIT(4) + +#define RTC_TC_SEC 0x000a +/* Min, Hour, Dom... register offset to RTC_TC_SEC */ +#define RTC_OFFSET_SEC 0 +#define RTC_OFFSET_MIN 1 +#define RTC_OFFSET_HOUR 2 +#define RTC_OFFSET_DOM 3 +#define RTC_OFFSET_DOW 4 +#define RTC_OFFSET_MTH 5 +#define RTC_OFFSET_YEAR 6 +#define RTC_OFFSET_COUNT 7 + +#define RTC_AL_SEC 0x0018 + +#define RTC_PDN2 0x002e +#define RTC_PDN2_PWRON_ALARM BIT(4) + +#define RTC_MIN_YEAR 1968 +#define RTC_BASE_YEAR 1900 +#define RTC_NUM_YEARS 128 +#define RTC_MIN_YEAR_OFFSET (RTC_MIN_YEAR - RTC_BASE_YEAR) + +#define MTK_RTC_POLL_DELAY_US 10 +#define MTK_RTC_POLL_TIMEOUT (jiffies_to_usecs(HZ)) + +struct mt6397_rtc { +struct device *dev; +struct rtc_device *rtc_dev; + +/* protect registers accessing */ +struct mutex lock; +struct regmap *regmap; +int irq; +u32 addr_base; +}; + +#endif /* _LINUX_RTC_MT6397_H_ */ +Signature · 1 line
2.7.4
Signature · 3 lines
Alexandre Belloni, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
Sean Wang
maintainerRe: [PATCH v1 11/16] rtc: mediatek: move the declaration into a globally visible header file
Quoted 6 lines · Alexandre Belloni
Quoted 5 lines · On 23/03/2018 at 17:15:08 +0800, [email protected] wrote:
From: Sean Wang <[email protected]>
This is in preparation for allowing other drivers can share the declaration, so move the declaration into a globally visible header file.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Sean Wang <[email protected]>--- drivers/rtc/rtc-mt6397.c | 53 +--------------------------------- include/linux/rtc/mt6397.h | 72 ++++++++++++++++++++++++++++++++++++++++++++++This should go in
include/linux/mfd/
include/linux/mfd/mt6397 is present, so include/linux/mfd/mt6397/rtc.h seems a nice place to keep these declarations for the pmic rtc.
Quoted 70 lines
Quoted 70 lines
2 files changed, 73 insertions(+), 52 deletions(-) create mode 100644 include/linux/rtc/mt6397.hdrivers/rtc/rtc-mt6397.c +1
-52@@ -19,63 +19,12 @@#include <linux/of_platform.h> #include <linux/regmap.h> #include <linux/rtc.h> -#include <linux/jiffies.h> #include <linux/platform_device.h> #include <linux/of_address.h> #include <linux/of_irq.h> #include <linux/io.h> #include <linux/mfd/mt6397/core.h> - -#define RTC_BBPU 0x0000 -#define RTC_BBPU_CBUSY BIT(6) - -#define RTC_WRTGR 0x003c - -#define RTC_IRQ_STA 0x0002 -#define RTC_IRQ_STA_AL BIT(0) -#define RTC_IRQ_STA_LP BIT(3) - -#define RTC_IRQ_EN 0x0004 -#define RTC_IRQ_EN_AL BIT(0) -#define RTC_IRQ_EN_ONESHOT BIT(2) -#define RTC_IRQ_EN_LP BIT(3) -#define RTC_IRQ_EN_ONESHOT_AL (RTC_IRQ_EN_ONESHOT | RTC_IRQ_EN_AL) - -#define RTC_AL_MASK 0x0008 -#define RTC_AL_MASK_DOW BIT(4) - -#define RTC_TC_SEC 0x000a -/* Min, Hour, Dom... register offset to RTC_TC_SEC */ -#define RTC_OFFSET_SEC 0 -#define RTC_OFFSET_MIN 1 -#define RTC_OFFSET_HOUR 2 -#define RTC_OFFSET_DOM 3 -#define RTC_OFFSET_DOW 4 -#define RTC_OFFSET_MTH 5 -#define RTC_OFFSET_YEAR 6 -#define RTC_OFFSET_COUNT 7 - -#define RTC_AL_SEC 0x0018 - -#define RTC_PDN2 0x002e -#define RTC_PDN2_PWRON_ALARM BIT(4) - -#define RTC_MIN_YEAR 1968 -#define RTC_BASE_YEAR 1900 -#define RTC_NUM_YEARS 128 -#define RTC_MIN_YEAR_OFFSET (RTC_MIN_YEAR - RTC_BASE_YEAR) - -#define MTK_RTC_POLL_DELAY_US 10 -#define MTK_RTC_POLL_TIMEOUT (jiffies_to_usecs(HZ)) - -struct mt6397_rtc { -struct device *dev; -struct rtc_device *rtc_dev; -struct mutex lock; -struct regmap *regmap; -int irq; -u32 addr_base; -}; +#include <linux/rtc/mt6397.h>
Quoted 12 lines
include/linux/rtc/mt6397.h line 1
Quoted 9 lines
drivers/rtc/rtc-mt6397.c +0
-0static int mtk_rtc_write_trigger (struct mt6397_rtc *rtc) {include/linux/rtc/mt6397.h new file +1
-0@@ -0,0 +1,72 @@ +Unnecessary empty line
will remove the unnecessary empty line
Quoted 75 lines
Quoted 74 lines
include/linux/rtc/mt6397.h new file +71
-0+// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2014-2018 MediaTek Inc. +* +* Author: Tianping.Fang <[email protected]> +* Sean Wang <[email protected]> +*/ + +#ifndef _LINUX_RTC_MT6397_H_ +#define _LINUX_RTC_MT6397_H_ + +#include <linux/jiffies.h> +#include <linux/mutex.h> +#include <linux/regmap.h> +#include <linux/rtc.h> + +#define RTC_BBPU 0x0000 +#define RTC_BBPU_CBUSY BIT(6) + +#define RTC_WRTGR 0x003c + +#define RTC_IRQ_STA 0x0002 +#define RTC_IRQ_STA_AL BIT(0) +#define RTC_IRQ_STA_LP BIT(3) + +#define RTC_IRQ_EN 0x0004 +#define RTC_IRQ_EN_AL BIT(0) +#define RTC_IRQ_EN_ONESHOT BIT(2) +#define RTC_IRQ_EN_LP BIT(3) +#define RTC_IRQ_EN_ONESHOT_AL (RTC_IRQ_EN_ONESHOT | RTC_IRQ_EN_AL) + +#define RTC_AL_MASK 0x0008 +#define RTC_AL_MASK_DOW BIT(4) + +#define RTC_TC_SEC 0x000a +/* Min, Hour, Dom... register offset to RTC_TC_SEC */ +#define RTC_OFFSET_SEC 0 +#define RTC_OFFSET_MIN 1 +#define RTC_OFFSET_HOUR 2 +#define RTC_OFFSET_DOM 3 +#define RTC_OFFSET_DOW 4 +#define RTC_OFFSET_MTH 5 +#define RTC_OFFSET_YEAR 6 +#define RTC_OFFSET_COUNT 7 + +#define RTC_AL_SEC 0x0018 + +#define RTC_PDN2 0x002e +#define RTC_PDN2_PWRON_ALARM BIT(4) + +#define RTC_MIN_YEAR 1968 +#define RTC_BASE_YEAR 1900 +#define RTC_NUM_YEARS 128 +#define RTC_MIN_YEAR_OFFSET (RTC_MIN_YEAR - RTC_BASE_YEAR) + +#define MTK_RTC_POLL_DELAY_US 10 +#define MTK_RTC_POLL_TIMEOUT (jiffies_to_usecs(HZ)) + +struct mt6397_rtc { +struct device *dev; +struct rtc_device *rtc_dev; + +/* protect registers accessing */ +struct mutex lock; +struct regmap *regmap; +int irq; +u32 addr_base; +}; + +#endif /* _LINUX_RTC_MT6397_H_ */ +Signature · 1 line
2.7.4
Re: [PATCH v1 11/16] rtc: mediatek: move the declaration into a globally visible header file
Quoted 12 lines · Sean Wang
Quoted 11 lines · Alexandre Belloni
Quoted 9 lines · On 23/03/2018 at 17:15:08 +0800, [email protected] wrote:
From: Sean Wang <[email protected]>
This is in preparation for allowing other drivers can share the declaration, so move the declaration into a globally visible header file.
Signed-off-by Sean Wang <[email protected]>--- drivers/rtc/rtc-mt6397.c | 53 +--------------------------------- include/linux/rtc/mt6397.h | 72 ++++++++++++++++++++++++++++++++++++++++++++++
Quoted 5 lines
Quoted 1 line
This should go in
include/linux/mfd/
include/linux/mfd/mt6397is present, soinclude/linux/mfd/mt6397/rtc.hseems a nice place to keep these declarations for the pmic rtc.
Yes, this seems good to me.
Quoted 162 lines
Quoted 70 lines
Quoted 70 lines
2 files changed, 73 insertions(+), 52 deletions(-) create mode 100644 include/linux/rtc/mt6397.hdrivers/rtc/rtc-mt6397.c +1
-52@@ -19,63 +19,12 @@#include <linux/of_platform.h> #include <linux/regmap.h> #include <linux/rtc.h> -#include <linux/jiffies.h> #include <linux/platform_device.h> #include <linux/of_address.h> #include <linux/of_irq.h> #include <linux/io.h> #include <linux/mfd/mt6397/core.h> - -#define RTC_BBPU 0x0000 -#define RTC_BBPU_CBUSY BIT(6) - -#define RTC_WRTGR 0x003c - -#define RTC_IRQ_STA 0x0002 -#define RTC_IRQ_STA_AL BIT(0) -#define RTC_IRQ_STA_LP BIT(3) - -#define RTC_IRQ_EN 0x0004 -#define RTC_IRQ_EN_AL BIT(0) -#define RTC_IRQ_EN_ONESHOT BIT(2) -#define RTC_IRQ_EN_LP BIT(3) -#define RTC_IRQ_EN_ONESHOT_AL (RTC_IRQ_EN_ONESHOT | RTC_IRQ_EN_AL) - -#define RTC_AL_MASK 0x0008 -#define RTC_AL_MASK_DOW BIT(4) - -#define RTC_TC_SEC 0x000a -/* Min, Hour, Dom... register offset to RTC_TC_SEC */ -#define RTC_OFFSET_SEC 0 -#define RTC_OFFSET_MIN 1 -#define RTC_OFFSET_HOUR 2 -#define RTC_OFFSET_DOM 3 -#define RTC_OFFSET_DOW 4 -#define RTC_OFFSET_MTH 5 -#define RTC_OFFSET_YEAR 6 -#define RTC_OFFSET_COUNT 7 - -#define RTC_AL_SEC 0x0018 - -#define RTC_PDN2 0x002e -#define RTC_PDN2_PWRON_ALARM BIT(4) - -#define RTC_MIN_YEAR 1968 -#define RTC_BASE_YEAR 1900 -#define RTC_NUM_YEARS 128 -#define RTC_MIN_YEAR_OFFSET (RTC_MIN_YEAR - RTC_BASE_YEAR) - -#define MTK_RTC_POLL_DELAY_US 10 -#define MTK_RTC_POLL_TIMEOUT (jiffies_to_usecs(HZ)) - -struct mt6397_rtc { -struct device *dev; -struct rtc_device *rtc_dev; -struct mutex lock; -struct regmap *regmap; -int irq; -u32 addr_base; -}; +#include <linux/rtc/mt6397.h> Quoted 12 lines
include/linux/rtc/mt6397.h line 1
Quoted 9 lines
drivers/rtc/rtc-mt6397.c +0
-0static int mtk_rtc_write_trigger (struct mt6397_rtc *rtc) {include/linux/rtc/mt6397.h new file +1
-0@@ -0,0 +1,72 @@ +Unnecessary empty line
will remove the unnecessary empty line
Quoted 75 lines
Quoted 74 lines
include/linux/rtc/mt6397.h new file +71
-0+// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2014-2018 MediaTek Inc. +* +* Author: Tianping.Fang <[email protected]> +* Sean Wang <[email protected]> +*/ + +#ifndef _LINUX_RTC_MT6397_H_ +#define _LINUX_RTC_MT6397_H_ + +#include <linux/jiffies.h> +#include <linux/mutex.h> +#include <linux/regmap.h> +#include <linux/rtc.h> + +#define RTC_BBPU 0x0000 +#define RTC_BBPU_CBUSY BIT(6) + +#define RTC_WRTGR 0x003c + +#define RTC_IRQ_STA 0x0002 +#define RTC_IRQ_STA_AL BIT(0) +#define RTC_IRQ_STA_LP BIT(3) + +#define RTC_IRQ_EN 0x0004 +#define RTC_IRQ_EN_AL BIT(0) +#define RTC_IRQ_EN_ONESHOT BIT(2) +#define RTC_IRQ_EN_LP BIT(3) +#define RTC_IRQ_EN_ONESHOT_AL (RTC_IRQ_EN_ONESHOT | RTC_IRQ_EN_AL) + +#define RTC_AL_MASK 0x0008 +#define RTC_AL_MASK_DOW BIT(4) + +#define RTC_TC_SEC 0x000a +/* Min, Hour, Dom... register offset to RTC_TC_SEC */ +#define RTC_OFFSET_SEC 0 +#define RTC_OFFSET_MIN 1 +#define RTC_OFFSET_HOUR 2 +#define RTC_OFFSET_DOM 3 +#define RTC_OFFSET_DOW 4 +#define RTC_OFFSET_MTH 5 +#define RTC_OFFSET_YEAR 6 +#define RTC_OFFSET_COUNT 7 + +#define RTC_AL_SEC 0x0018 + +#define RTC_PDN2 0x002e +#define RTC_PDN2_PWRON_ALARM BIT(4) + +#define RTC_MIN_YEAR 1968 +#define RTC_BASE_YEAR 1900 +#define RTC_NUM_YEARS 128 +#define RTC_MIN_YEAR_OFFSET (RTC_MIN_YEAR - RTC_BASE_YEAR) + +#define MTK_RTC_POLL_DELAY_US 10 +#define MTK_RTC_POLL_TIMEOUT (jiffies_to_usecs(HZ)) + +struct mt6397_rtc { +struct device *dev; +struct rtc_device *rtc_dev; + +/* protect registers accessing */ +struct mutex lock; +struct regmap *regmap; +int irq; +u32 addr_base; +}; + +#endif /* _LINUX_RTC_MT6397_H_ */ +Signature · 1 line
2.7.4
Signature · 3 lines
Alexandre Belloni, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
Re: [PATCH v1 11/16] rtc: mediatek: move the declaration into a globally visible header file
In reply to [email protected]include/linux/rtc/mt6397.h line 2
Quoted 5 lines · On Fri, Mar 23, 2018 at 6:15 AM, <[email protected]> wrote:
include/linux/rtc/mt6397.h new file +2
-0@@ -0,0 +1,72 @@ + +// SPDX-License-Identifier: GPL-2.0
According to Documentation/process/license-rules.rst the SPDX notation for C header file should be:
/* SPDX-License-Identifier: GPL-2.0 */
Sean Wang
maintainerRe: [PATCH v1 11/16] rtc: mediatek: move the declaration into a globally visible header file
Quoted 11 lines · Fabio Estevam
include/linux/rtc/mt6397.h line 2
Quoted 5 lines · On Fri, Mar 23, 2018 at 6:15 AM, <[email protected]> wrote:
include/linux/rtc/mt6397.h new file +2
-0@@ -0,0 +1,72 @@ + +// SPDX-License-Identifier: GPL-2.0 According to
Documentation/process/license-rules.rstthe SPDX notation for C header file should be:
Quoted 1 line
/* SPDX-License-Identifier: GPL-2.0 */
Thank you, I'll have an improvement according to the license rule.
[email protected]
maintainerPATCH 12/16 rtc: mediatek: cleanup header files to include
In reply to [email protected]From: Sean Wang <[email protected]>
Clean up those included header files by removing unreferenced ones, add missing ones the driver explicitly depends on and finally list all #includes in alphabetical order.
--- drivers/rtc/rtc-mt6397.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/rtc/rtc-mt6397.c +4 -7
@@ -12,18 +12,15 @@* GNU General Public License for more details. */ -#include <linux/delay.h> -#include <linux/init.h> +#include <linux/err.h> #include <linux/interrupt.h> +#include <linux/mfd/mt6397/core.h> #include <linux/module.h> +#include <linux/mutex.h> #include <linux/of_platform.h> +#include <linux/platform_device.h> #include <linux/regmap.h> #include <linux/rtc.h> -#include <linux/platform_device.h> -#include <linux/of_address.h> -#include <linux/of_irq.h> -#include <linux/io.h> -#include <linux/mfd/mt6397/core.h> #include <linux/rtc/mt6397.h> static int mtk_rtc_write_trigger (struct mt6397_rtc *rtc)
Signature · 1 line
2.7.4
kbuild test robot
build botRe: [PATCH v1 12/16] rtc: mediatek: cleanup header files to include
I love your patch! Yet something to improve:
Hi Sean,
I love your patch! Yet something to improve:
[auto build test ERROR on abelloni/rtc-next]
[also build test ERROR on v4.16-rc6 next-20180323]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/sean-wang-mediatek-com/Add-support-to-MT6323-RTC-and-its-power-device/20180325-104529 base: https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git rtc-next config: x86_64-randconfig-x004-201812 (attached as .config) compiler: gcc-7 (Debian 7.3.0-1) 7.3.0 reproduce: # save the attached .config to linux build tree make ARCH=x86_64
All errors (new ones prefixed by >>):
drivers//rtc/rtc-mt6397.c: In function 'mtk_rtc_probe':
>> drivers//rtc/rtc-mt6397.c:270:13: error: implicit declaration of function 'irq_create_mapping'; did you mean 'qid_has_mapping'? [-Werror=implicit-function-declaration]
rtc->irq = irq_create_mapping(mt6397_chip->irq_domain, res->start);
^~~~~~~~~~~~~~~~~~
qid_has_mapping Cyclomatic Complexity 1 include/linux/err.h:PTR_ERR
Cyclomatic Complexity 1 include/linux/err.h:IS_ERR
Cyclomatic Complexity 1 include/linux/math64.h:div_s64_rem Cyclomatic Complexity 1 include/linux/math64.h:div_s64 Cyclomatic Complexity 3 include/linux/ktime.h:ktime_compare Cyclomatic Complexity 1 include/linux/ktime.h:ktime_add_us Cyclomatic Complexity 1 include/linux/device.h:devm_kzalloc Cyclomatic Complexity 1 include/linux/pm_wakeup.h:device_set_wakeup_capable Cyclomatic Complexity 1 include/linux/pm_wakeup.h:device_set_wakeup_enable Cyclomatic Complexity 1 include/linux/pm_wakeup.h:device_init_wakeup Cyclomatic Complexity 1 include/linux/device.h:dev_get_drvdata Cyclomatic Complexity 1 include/linux/device.h:dev_set_drvdata Cyclomatic Complexity 1 include/linux/platform_device.h:platform_set_drvdata Cyclomatic Complexity 1 include/linux/of_platform.h:devm_of_platform_populate Cyclomatic Complexity 1 drivers//rtc/rtc-mt6397.c:mtk_rtc_driver_init Cyclomatic Complexity 5 drivers//rtc/rtc-mt6397.c:mtk_rtc_probe Cyclomatic Complexity 11 drivers//rtc/rtc-mt6397.c:mtk_rtc_write_trigger Cyclomatic Complexity 6 drivers//rtc/rtc-mt6397.c:mtk_rtc_set_alarm Cyclomatic Complexity 2 drivers//rtc/rtc-mt6397.c:mtk_rtc_set_time Cyclomatic Complexity 4 drivers//rtc/rtc-mt6397.c:mtk_rtc_read_alarm Cyclomatic Complexity 2 drivers//rtc/rtc-mt6397.c:__mtk_rtc_read_time Cyclomatic Complexity 3 drivers//rtc/rtc-mt6397.c:mtk_rtc_read_time Cyclomatic Complexity 4 drivers//rtc/rtc-mt6397.c:mtk_rtc_irq_handler_thread Cyclomatic Complexity 1 drivers//rtc/rtc-mt6397.c:mtk_rtc_driver_exit
cc1: some warnings being treated as errors
vim +270 drivers//rtc/rtc-mt6397.c
fc2979118 Tianping Fang 2015-05-06 254
fc2979118 Tianping Fang 2015-05-06 255 static int mtk_rtc_probe(struct platform_device *pdev)
fc2979118 Tianping Fang 2015-05-06 256 {
fc2979118 Tianping Fang 2015-05-06 257 struct resource *res;
fc2979118 Tianping Fang 2015-05-06 258 struct mt6397_chip *mt6397_chip = dev_get_drvdata(pdev->dev.parent);
fc2979118 Tianping Fang 2015-05-06 259 struct mt6397_rtc *rtc;
fc2979118 Tianping Fang 2015-05-06 260 int ret;
fc2979118 Tianping Fang 2015-05-06 261
fc2979118 Tianping Fang 2015-05-06 262 rtc = devm_kzalloc(&pdev->dev, sizeof(struct mt6397_rtc), GFP_KERNEL);
fc2979118 Tianping Fang 2015-05-06 263 if (!rtc)
fc2979118 Tianping Fang 2015-05-06 264 return -ENOMEM;
fc2979118 Tianping Fang 2015-05-06 265
fc2979118 Tianping Fang 2015-05-06 266 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
fc2979118 Tianping Fang 2015-05-06 267 rtc->addr_base = res->start;
fc2979118 Tianping Fang 2015-05-06 268
fc2979118 Tianping Fang 2015-05-06 269 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
fc2979118 Tianping Fang 2015-05-06 @270 rtc->irq = irq_create_mapping(mt6397_chip->irq_domain, res->start);
fc2979118 Tianping Fang 2015-05-06 271 if (rtc->irq <= 0)
fc2979118 Tianping Fang 2015-05-06 272 return -EINVAL;
fc2979118 Tianping Fang 2015-05-06 273
fc2979118 Tianping Fang 2015-05-06 274 rtc->regmap = mt6397_chip->regmap;
fc2979118 Tianping Fang 2015-05-06 275 rtc->dev = &pdev->dev;
fc2979118 Tianping Fang 2015-05-06 276 mutex_init(&rtc->lock);
fc2979118 Tianping Fang 2015-05-06 277
fc2979118 Tianping Fang 2015-05-06 278 platform_set_drvdata(pdev, rtc);
fc2979118 Tianping Fang 2015-05-06 279
66c231b40 Sean Wang 2018-03-23 280 ret = devm_request_threaded_irq(&pdev->dev, rtc->irq, NULL,
fc2979118 Tianping Fang 2015-05-06 281 mtk_rtc_irq_handler_thread,
fc2979118 Tianping Fang 2015-05-06 282 IRQF_ONESHOT | IRQF_TRIGGER_HIGH,
fc2979118 Tianping Fang 2015-05-06 283 "mt6397-rtc", rtc);
fc2979118 Tianping Fang 2015-05-06 284 if (ret) {
fc2979118 Tianping Fang 2015-05-06 285 dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
fc2979118 Tianping Fang 2015-05-06 286 rtc->irq, ret);
63044753b Sean Wang 2018-03-23 287 return ret;
fc2979118 Tianping Fang 2015-05-06 288 }
fc2979118 Tianping Fang 2015-05-06 289
baeca4495 Wei-Ning Huang 2015-07-02 290 device_init_wakeup(&pdev->dev, 1);
baeca4495 Wei-Ning Huang 2015-07-02 291
66c231b40 Sean Wang 2018-03-23 292 rtc->rtc_dev = devm_rtc_device_register(&pdev->dev, "mt6397-rtc",
fc2979118 Tianping Fang 2015-05-06 293 &mtk_rtc_ops, THIS_MODULE);
fc2979118 Tianping Fang 2015-05-06 294 if (IS_ERR(rtc->rtc_dev)) {
fc2979118 Tianping Fang 2015-05-06 295 dev_err(&pdev->dev, "register rtc device failed\n");
fc2979118 Tianping Fang 2015-05-06 296 ret = PTR_ERR(rtc->rtc_dev);
fc2979118 Tianping Fang 2015-05-06 297 return ret;
fc2979118 Tianping Fang 2015-05-06 298 }
fc2979118 Tianping Fang 2015-05-06 299
89a68f3c0 Sean Wang 2018-03-23 300 return devm_of_platform_populate(&pdev->dev);
fc2979118 Tianping Fang 2015-05-06 301 }
fc2979118 Tianping Fang 2015-05-06 302 :::::: The code at line 270 was first introduced by commit
:::::: fc2979118f3f5193475cb53d5df7bdaa7e358a42 rtc: mediatek: Add MT6397 RTC driver
:::::: TO: Tianping Fang <[email protected]> :::::: CC: Alexandre Belloni <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
kbuild test robot
build botRe: [PATCH v1 12/16] rtc: mediatek: cleanup header files to include
In reply to [email protected]I love your patch! Yet something to improve:
Hi Sean,
I love your patch! Yet something to improve:
[auto build test ERROR on abelloni/rtc-next]
[also build test ERROR on v4.16-rc6]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/sean-wang-mediatek-com/Add-support-to-MT6323-RTC-and-its-power-device/20180325-104529 base: https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git rtc-next config: tile-allmodconfig (attached as .config) compiler: tilegx-linux-gcc (GCC) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=tile
All errors (new ones prefixed by >>):
drivers//rtc/rtc-mt6397.c: In function 'mtk_rtc_probe':
>> drivers//rtc/rtc-mt6397.c:270:13: error: implicit declaration of function 'irq_create_mapping'; did you mean 'page_mapping'? [-Werror=implicit-function-declaration]
rtc->irq = irq_create_mapping(mt6397_chip->irq_domain, res->start);
^~~~~~~~~~~~~~~~~~
page_mappingcc1: some warnings being treated as errors
vim +270 drivers//rtc/rtc-mt6397.c
fc2979118 Tianping Fang 2015-05-06 254
fc2979118 Tianping Fang 2015-05-06 255 static int mtk_rtc_probe(struct platform_device *pdev)
fc2979118 Tianping Fang 2015-05-06 256 {
fc2979118 Tianping Fang 2015-05-06 257 struct resource *res;
fc2979118 Tianping Fang 2015-05-06 258 struct mt6397_chip *mt6397_chip = dev_get_drvdata(pdev->dev.parent);
fc2979118 Tianping Fang 2015-05-06 259 struct mt6397_rtc *rtc;
fc2979118 Tianping Fang 2015-05-06 260 int ret;
fc2979118 Tianping Fang 2015-05-06 261
fc2979118 Tianping Fang 2015-05-06 262 rtc = devm_kzalloc(&pdev->dev, sizeof(struct mt6397_rtc), GFP_KERNEL);
fc2979118 Tianping Fang 2015-05-06 263 if (!rtc)
fc2979118 Tianping Fang 2015-05-06 264 return -ENOMEM;
fc2979118 Tianping Fang 2015-05-06 265
fc2979118 Tianping Fang 2015-05-06 266 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
fc2979118 Tianping Fang 2015-05-06 267 rtc->addr_base = res->start;
fc2979118 Tianping Fang 2015-05-06 268
fc2979118 Tianping Fang 2015-05-06 269 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
fc2979118 Tianping Fang 2015-05-06 @270 rtc->irq = irq_create_mapping(mt6397_chip->irq_domain, res->start);
fc2979118 Tianping Fang 2015-05-06 271 if (rtc->irq <= 0)
fc2979118 Tianping Fang 2015-05-06 272 return -EINVAL;
fc2979118 Tianping Fang 2015-05-06 273
fc2979118 Tianping Fang 2015-05-06 274 rtc->regmap = mt6397_chip->regmap;
fc2979118 Tianping Fang 2015-05-06 275 rtc->dev = &pdev->dev;
fc2979118 Tianping Fang 2015-05-06 276 mutex_init(&rtc->lock);
fc2979118 Tianping Fang 2015-05-06 277
fc2979118 Tianping Fang 2015-05-06 278 platform_set_drvdata(pdev, rtc);
fc2979118 Tianping Fang 2015-05-06 279
66c231b40 Sean Wang 2018-03-23 280 ret = devm_request_threaded_irq(&pdev->dev, rtc->irq, NULL,
fc2979118 Tianping Fang 2015-05-06 281 mtk_rtc_irq_handler_thread,
fc2979118 Tianping Fang 2015-05-06 282 IRQF_ONESHOT | IRQF_TRIGGER_HIGH,
fc2979118 Tianping Fang 2015-05-06 283 "mt6397-rtc", rtc);
fc2979118 Tianping Fang 2015-05-06 284 if (ret) {
fc2979118 Tianping Fang 2015-05-06 285 dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
fc2979118 Tianping Fang 2015-05-06 286 rtc->irq, ret);
63044753b Sean Wang 2018-03-23 287 return ret;
fc2979118 Tianping Fang 2015-05-06 288 }
fc2979118 Tianping Fang 2015-05-06 289
baeca4495 Wei-Ning Huang 2015-07-02 290 device_init_wakeup(&pdev->dev, 1);
baeca4495 Wei-Ning Huang 2015-07-02 291
66c231b40 Sean Wang 2018-03-23 292 rtc->rtc_dev = devm_rtc_device_register(&pdev->dev, "mt6397-rtc",
fc2979118 Tianping Fang 2015-05-06 293 &mtk_rtc_ops, THIS_MODULE);
fc2979118 Tianping Fang 2015-05-06 294 if (IS_ERR(rtc->rtc_dev)) {
fc2979118 Tianping Fang 2015-05-06 295 dev_err(&pdev->dev, "register rtc device failed\n");
fc2979118 Tianping Fang 2015-05-06 296 ret = PTR_ERR(rtc->rtc_dev);
fc2979118 Tianping Fang 2015-05-06 297 return ret;
fc2979118 Tianping Fang 2015-05-06 298 }
fc2979118 Tianping Fang 2015-05-06 299
89a68f3c0 Sean Wang 2018-03-23 300 return devm_of_platform_populate(&pdev->dev);
fc2979118 Tianping Fang 2015-05-06 301 }
fc2979118 Tianping Fang 2015-05-06 302 :::::: The code at line 270 was first introduced by commit
:::::: fc2979118f3f5193475cb53d5df7bdaa7e358a42 rtc: mediatek: Add MT6397 RTC driver
:::::: TO: Tianping Fang <[email protected]> :::::: CC: Alexandre Belloni <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[email protected]
maintainerPATCH 13/16 rtc: mediatek: update license converting to using SPDX identifiers
In reply to [email protected]From: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected]>
Update the license and as well convert to using SPDX identifiers.
--- drivers/rtc/rtc-mt6397.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)
drivers/rtc/rtc-mt6397.c +8 -12
@@ -1,16 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0 /* -* Copyright (c) 2014-2015 MediaTek Inc. -* Author: Tianping.Fang <tianping.fang-NuS5LvNUpcJWk0Htik3J/[email protected]> -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 2 as -* published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -*/ +* MediaTek PMIC RTC driver +* +* Copyright (C) 2014-2018 MediaTek Inc. +* +* Author: Tianping.Fang <tianping.fang-NuS5LvNUpcJWk0Htik3J/[email protected]> +* Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected]> +*/ #include <linux/err.h> #include <linux/interrupt.h>
Signature · 1 line
2.7.4
[email protected]
maintainerPATCH 14/16 power: reset: mediatek: add a power-off driver using PMIC RTC device
In reply to [email protected]From: Sean Wang <[email protected]>
The power device is responsible for externally down or up the power of the remote MediaTek SoC through the tiny circuit BBPU inside PMIC RTC.
Though it's a part of RTC device, it would be better to be a standalone driver against existent RTC driver so as to make concentration on works about power-controlling topic and help gather more improvements while the subsystem's constantly growing.
Currently, the most basic functionality supported is to just power off the system by writing to a special bit field in BBPU register after the system has reached pm_poweroff.
--- drivers/power/reset/Kconfig | 9 +++ drivers/power/reset/Makefile | 1 + drivers/power/reset/mt6397-rtc-poweroff.c | 100 ++++++++++++++++++++++++++++++ include/linux/rtc/mt6397.h | 1 + 4 files changed, 111 insertions(+) create mode 100644 drivers/power/reset/mt6397-rtc-poweroff.c
drivers/power/reset/Kconfig +9 -0
@@ -121,6 +121,15 @@ config POWER_RESET_LTC2952 This driver supports an external powerdown trigger and board power down via the LTC2952. Bindings are made in the device tree. +config POWER_RESET_MT6397_RTC + bool "MediaTek MT6397 RTC power-off driver" + help + This driver supports turning off a remote MediaTek SoC by + controlling BBPU on MT6397 or MT6323 RTC. + + Select this if you're building a kernel with your MediaTek SoC + with an equipment with MT6397 or MT6323 PMIC. + config POWER_RESET_QNAP bool "QNAP power-off driver" depends on OF_GPIO && PLAT_ORION
drivers/power/reset/Makefile +1 -0
@@ -11,6 +11,7 @@ obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o obj-$(CONFIG_POWER_RESET_GPIO_RESTART) += gpio-restart.o obj-$(CONFIG_POWER_RESET_HISI) += hisi-reboot.o obj-$(CONFIG_POWER_RESET_MSM) += msm-poweroff.o +obj-$(CONFIG_POWER_RESET_MT6397_RTC) += mt6397-rtc-poweroff.o obj-$(CONFIG_POWER_RESET_PIIX4_POWEROFF) += piix4-poweroff.o obj-$(CONFIG_POWER_RESET_LTC2952) += ltc2952-poweroff.o obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o
drivers/power/reset/mt6397-rtc-poweroff.c new file +100 -0
100 lines not on this page · raw message
include/linux/rtc/mt6397.h +1 -0
@@ -17,6 +17,7 @@#define RTC_BBPU 0x0000#define RTC_BBPU_CBUSY BIT(6) +#define RTC_BBPU_KEY (0x43 << 8)#define RTC_WRTGR 0x003c
Signature · 1 line
2.7.4
[email protected]
maintainerPATCH 15/16 MAINTAINERS: update entry for ARM/Mediatek RTC DRIVER
In reply to [email protected]From: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected]>
Add new files for new dt-bindings and a globally visible header file.
--- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+)
MAINTAINERS +2 -0
@@ -1626,9 +1626,11 @@ M: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected]> L: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org (moderated for non-subscribers) L: [email protected] (moderated for non-subscribers) S: Maintained +F: Documentation/devicetree/bindings/rtc/rtc-mt6397.txt F: Documentation/devicetree/bindings/rtc/rtc-mt7622.txt F: drivers/rtc/rtc-mt6397.c F: drivers/rtc/rtc-mt7622.c +F: include/linux/rtc/mt6397.h ARM/Mediatek SoC support M: Matthias Brugger <[email protected]>
Signature · 1 line
2.7.4
[email protected]
maintainerPATCH 16/16 MAINTAINERS: add an entry for MediaTek board level shutdown driver
In reply to [email protected]From: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected]>
Add an entry for the MediaTek board level shutdown driver.
--- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
@@ -8818,6 +8818,13 @@ S: Maintained F: drivers/net/dsa/mt7530.* F: net/dsa/tag_mtk.c +MEDIATEK BOARD LEVEL SHUTDOWN DRIVERS +M: Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/power/reset/mt6397-rtc-poweroff.txt +F: drivers/power/reset/mt6397-rtc-poweroff.c + MEDIATEK JPEG DRIVER M: Rick Chang <rick.chang-NuS5LvNUpcJWk0Htik3J/[email protected]> M: Bin Liu <bin.liu-NuS5LvNUpcJWk0Htik3J/[email protected]>
Signature · 1 line
2.7.4