Linux RTC
 help / color / mirror / Atom feed
* [PATCH v5 3/6] dt-bindings: input: Add document bindings for mtk-pmic-keys
From: Chen Zhong @ 2017-09-27 10:44 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring, Lee Jones, Alexandre Belloni
  Cc: Mark Rutland, Matthias Brugger, Eddie Huang, Alessandro Zummo,
	Linus Walleij, Chanwoo Choi, Chen Zhong, Jaechul Lee, Andi Shyti,
	linux-input, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-rtc
In-Reply-To: <1506509048-19032-1-git-send-email-chen.zhong@mediatek.com>

This patch adds the device tree binding documentation for the MediaTek
pmic keys found on PMIC MT6397/MT6323.

Signed-off-by: Chen Zhong <chen.zhong@mediatek.com>
---
 .../devicetree/bindings/input/mtk-pmic-keys.txt    |   43 ++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/mtk-pmic-keys.txt

diff --git a/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt b/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt
new file mode 100644
index 0000000..2888d07
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt
@@ -0,0 +1,43 @@
+MediaTek MT6397/MT6323 PMIC Keys Device Driver
+
+There are two key functions provided by MT6397/MT6323 PMIC, pwrkey
+and homekey. The key functions are defined as the subnode of the function
+node provided by MT6397/MT6323 PMIC that is being defined as one kind
+of Muti-Function Device (MFD)
+
+For MT6397/MT6323 MFD bindings see:
+Documentation/devicetree/bindings/mfd/mt6397.txt
+
+Required properties:
+- compatible: "mediatek,mt6397-keys" or "mediatek,mt6323-keys"
+- linux,keycodes: See Documentation/devicetree/bindings/input/keys.txt
+
+Optional Properties:
+- wakeup-source: See Documentation/devicetree/bindings/power/wakeup-source.txt
+- mediatek,long-press-mode: Long press key shutdown setting, 1 for
+	pwrkey only, 2 for pwrkey/homekey together, others for disabled.
+- power-off-time-sec: See Documentation/devicetree/bindings/input/keys.txt
+
+Example:
+
+	pmic: mt6397 {
+		compatible = "mediatek,mt6397";
+
+		...
+
+		mt6397keys: mt6397keys {
+			compatible = "mediatek,mt6397-keys";
+			mediatek,long-press-mode = <1>;
+			power-off-time-sec = <0>;
+
+			power {
+				linux,keycodes = <116>;
+				wakeup-source;
+			};
+
+			home {
+				linux,keycodes = <114>;
+			};
+		};
+
+	};
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH v5 2/6] dt-bindings: input: Add common keyboard document bindings
From: Chen Zhong @ 2017-09-27 10:44 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring, Lee Jones, Alexandre Belloni
  Cc: Mark Rutland, Matthias Brugger, Eddie Huang, Alessandro Zummo,
	Linus Walleij, Chanwoo Choi, Chen Zhong, Jaechul Lee, Andi Shyti,
	linux-input, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-rtc
In-Reply-To: <1506509048-19032-1-git-send-email-chen.zhong@mediatek.com>

This patch adds the device tree binding documentation for common
keyboard.

Signed-off-by: Chen Zhong <chen.zhong@mediatek.com>
---
 Documentation/devicetree/bindings/input/keys.txt |    8 ++++++++
 1 file changed, 8 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/keys.txt

diff --git a/Documentation/devicetree/bindings/input/keys.txt b/Documentation/devicetree/bindings/input/keys.txt
new file mode 100644
index 0000000..a0ea7eb
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/keys.txt
@@ -0,0 +1,8 @@
+General Keys Properties:
+
+Optional properties for Keys:
+- power-off-time-sec: Duration in seconds which the key should be kept
+ 	pressed for device to power off automatically. Device with key pressed
+ 	shutdown feature can specify this property.
+- linux,keycodes: Specifies the numeric keycode values to be used for
+	reporting key presses.
\ No newline at end of file
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH v5 4/6] dt-bindings: mfd: Add bindings for the keys as subnode of PMIC
From: Chen Zhong @ 2017-09-27 10:44 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring, Lee Jones, Alexandre Belloni
  Cc: Mark Rutland, Matthias Brugger, Eddie Huang, Alessandro Zummo,
	Linus Walleij, Chanwoo Choi, Chen Zhong, Jaechul Lee, Andi Shyti,
	linux-input, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-rtc
In-Reply-To: <1506509048-19032-1-git-send-email-chen.zhong@mediatek.com>

This patch adds documentation for device tree bindings for keys support
as the subnode of MT6397/MT6323 PMIC.

Acked-by: Rob Herring <robh@kernel.org>
Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Chen Zhong <chen.zhong@mediatek.com>
---
 Documentation/devicetree/bindings/mfd/mt6397.txt |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/mt6397.txt b/Documentation/devicetree/bindings/mfd/mt6397.txt
index 522a3bb..d1df77f 100644
--- a/Documentation/devicetree/bindings/mfd/mt6397.txt
+++ b/Documentation/devicetree/bindings/mfd/mt6397.txt
@@ -7,6 +7,7 @@ MT6397/MT6323 is a multifunction device with the following sub modules:
 - GPIO
 - Clock
 - LED
+- Keys
 
 It is interfaced to host controller using SPI interface by a proprietary hardware
 called PMIC wrapper or pwrap. MT6397/MT6323 MFD is a child device of pwrap.
@@ -40,6 +41,11 @@ Optional subnodes:
 		- compatible: "mediatek,mt6323-led"
 	see Documentation/devicetree/bindings/leds/leds-mt6323.txt
 
+- keys
+	Required properties:
+		- compatible: "mediatek,mt6397-keys" or "mediatek,mt6323-keys"
+	see Documentation/devicetree/bindings/input/mtk-pmic-keys.txt
+
 Example:
 	pwrap: pwrap@1000f000 {
 		compatible = "mediatek,mt8135-pwrap";
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH v5 1/6] mfd: mt6397: create irq mappings in mfd core driver
From: Chen Zhong @ 2017-09-27 10:44 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring, Lee Jones, Alexandre Belloni
  Cc: Mark Rutland, Matthias Brugger, Eddie Huang, Alessandro Zummo,
	Linus Walleij, Chanwoo Choi, Chen Zhong, Jaechul Lee, Andi Shyti,
	linux-input, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-rtc
In-Reply-To: <1506509048-19032-1-git-send-email-chen.zhong@mediatek.com>

The core driver should create and manage irq mappings instead of
leaf drivers. This patch change to pass irq domain to
devm_mfd_add_devices() and it will create mapping for irq resources
automatically. And remove irq mapping in rtc driver since this has
been done in core driver.

Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Chen Zhong <chen.zhong@mediatek.com>
---
 drivers/mfd/mt6397-core.c |    4 ++--
 drivers/rtc/rtc-mt6397.c  |    7 +++----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/mfd/mt6397-core.c b/drivers/mfd/mt6397-core.c
index 04a601f..6546d7f 100644
--- a/drivers/mfd/mt6397-core.c
+++ b/drivers/mfd/mt6397-core.c
@@ -289,7 +289,7 @@ static int mt6397_probe(struct platform_device *pdev)
 
 		ret = devm_mfd_add_devices(&pdev->dev, -1, mt6323_devs,
 					   ARRAY_SIZE(mt6323_devs), NULL,
-					   0, NULL);
+					   0, pmic->irq_domain);
 		break;
 
 	case MT6397_CID_CODE:
@@ -304,7 +304,7 @@ static int mt6397_probe(struct platform_device *pdev)
 
 		ret = devm_mfd_add_devices(&pdev->dev, -1, mt6397_devs,
 					   ARRAY_SIZE(mt6397_devs), NULL,
-					   0, NULL);
+					   0, pmic->irq_domain);
 		break;
 
 	default:
diff --git a/drivers/rtc/rtc-mt6397.c b/drivers/rtc/rtc-mt6397.c
index 1a61fa5..385f830 100644
--- a/drivers/rtc/rtc-mt6397.c
+++ b/drivers/rtc/rtc-mt6397.c
@@ -322,10 +322,9 @@ static int mtk_rtc_probe(struct platform_device *pdev)
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	rtc->addr_base = res->start;
 
-	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-	rtc->irq = irq_create_mapping(mt6397_chip->irq_domain, res->start);
-	if (rtc->irq <= 0)
-		return -EINVAL;
+	rtc->irq = platform_get_irq(pdev, 0);
+	if (rtc->irq < 0)
+		return rtc->irq;
 
 	rtc->regmap = mt6397_chip->regmap;
 	rtc->dev = &pdev->dev;
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH v5 0/6] Add MediaTek PMIC keys support
From: Chen Zhong @ 2017-09-27 10:44 UTC (permalink / raw)
  To: Dmitry Torokhov, Rob Herring, Lee Jones, Alexandre Belloni
  Cc: Mark Rutland, Matthias Brugger, Eddie Huang, Alessandro Zummo,
	Linus Walleij, Chanwoo Choi, Chen Zhong, Jaechul Lee, Andi Shyti,
	linux-input, devicetree, linux-kernel, linux-arm-kernel,
	linux-mediatek, linux-rtc

Changes since v4:
- rebase to Linux 4.14-rc1
- add a common keyboard binding document
- use child device tree node to define each key

Changes since v3:
- make the naming to be consistent as mtk_pmic or MTK_PMIC
- add suspend/resume functions to enable/disable irq
- change binding properties to define wakeup sources

Changes since v2:
- use standard properties for keycodes and debounce time
- change to use platform_get_irq in leaf drivers
- use better ways to define IRQ resources

Changes since v1:
- create irq mappings in mfd core driver instead of leaf drivers
- remove some unused parts in mtk-pmic-keys driver

MediaTek PMIC are multi-function devices that can handle key interrupts,
typically there are two keys attached to PMIC, which called pwrkey
and homekey. PWRKEY usually used to wake up system from sleep. Homekey
can used as volume down key due to board design. Long press keys can
shutdown PMIC, the mode can be choose to be one key only or two keys
together.
This series add support for key functions for MediaTek PMIC MT6397/MT6323.

Chen Zhong (6):
  mfd: mt6397: create irq mappings in mfd core driver
  dt-bindings: input: Add common keyboard document bindings
  dt-bindings: input: Add document bindings for mtk-pmic-keys
  dt-bindings: mfd: Add bindings for the keys as subnode of PMIC
  input: Add MediaTek PMIC keys support
  mfd: mt6397: Add PMIC keys support to MT6397 driver

 Documentation/devicetree/bindings/input/keys.txt   |   8 +
 .../devicetree/bindings/input/mtk-pmic-keys.txt    |  43 +++
 Documentation/devicetree/bindings/mfd/mt6397.txt   |   6 +
 drivers/input/keyboard/Kconfig                     |   9 +
 drivers/input/keyboard/Makefile                    |   1 +
 drivers/input/keyboard/mtk-pmic-keys.c             | 341 +++++++++++++++++++++
 drivers/mfd/mt6397-core.c                          |  26 +-
 drivers/rtc/rtc-mt6397.c                           |   7 +-
 8 files changed, 434 insertions(+), 7 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/input/keys.txt
 create mode 100644 Documentation/devicetree/bindings/input/mtk-pmic-keys.txt
 create mode 100644 drivers/input/keyboard/mtk-pmic-keys.c

-- 
1.9.1

^ permalink raw reply

* Re: [PATCH] rtc: ds1374: wdt:support suspend/resume for watchdog
From: Guenter Roeck @ 2017-09-26 13:52 UTC (permalink / raw)
  To: Alexandre Belloni, 18502523564
  Cc: a.zummo, linux-rtc, linux-kernel, Wim Van Sebroeck,
	linux-watchdog
In-Reply-To: <20170926102239.qjmhfry4vtaow4gk@piout.net>

On 09/26/2017 03:22 AM, Alexandre Belloni wrote:
> (+Cc wdt maintainers)
> 
> On 26/09/2017 at 09:56:32 +0800, 18502523564 wrote:
>> Hi Alexandre,
>>
>> Thanks for your reply.
>> Do you think is this a issue when using as a watchdog in suspend?
>> I takes the drivers/watchdog/ subsystem for reference, some drivers in suspend
>> also call disable_watchdog.Or do you have any  better suggestion?
> 
> I guess this is a question for the watchdog subsystem maintainers.
> However, I think that everything can be handled properly from userspace
> as I know some atmel based devices have their watchdog enabled while
> the platform is suspended.
> 

Depends on the driver, really. There is one thing wrong below, though:
It appears that on resume, the watchdog is unconditionally enabled.

Guenter

>> Thank you.
>>
>>
>>
>>
>> ------------------ Original ------------------
>> From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
>> Date: 周一,9月 25,2017 20:07
>> To: winton.liu <18502523564@163.com>
>> Cc: a.zummo <a.zummo@towertech.it>, linux-rtc <linux-rtc@vger.kernel.org>,
>> linux-kernel <linux-kernel@vger.kernel.org>
>> Subject: Re: [PATCH] rtc: ds1374: wdt:support suspend/resume for watchdog
>>
>>
>> Hi,
>>
>> On 25/09/2017 at 19:58:44 +0800, winton.liu wrote:
>>> When enable CONFIG_RTC_DRV_DS1374_WDT use as watchdog,
>>> in suspend mode, watchdog is still working but no daemon
>>> patting the watchdog. The system will reboot if timeout.
>>> So disable watchdog in suspend  and recover it in resume.
>>>
>>
>> That is definitively not what we want. Many people will want to still
>> have the watchdog running when the platform is suspended. Your options
>> are to either disable the watchdog before going to suspend or wake up
>> the platform just in time to ping the watchdog.
>>
>>> Signed-off-by: winton.liu <18502523564@163.com>
>>> ---
>>>   drivers/rtc/rtc-ds1374.c | 8 ++++++++
>>>   1 file changed, 8 insertions(+)
>>>
>>> diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
>>> index 38a2e9e..e990773 100644
>>> --- a/drivers/rtc/rtc-ds1374.c
>>> +++ b/drivers/rtc/rtc-ds1374.c
>>> @@ -690,6 +690,10 @@ static int ds1374_suspend(struct device *dev)
>>>   {
>>>        struct i2c_client *client = to_i2c_client(dev);
>>>
>>> +#ifdef CONFIG_RTC_DRV_DS1374_WDT
>>> +     ds1374_wdt_disable();
>>> +#endif
>>> +
>>>        if (client->irq > 0 && device_may_wakeup(&client->dev))
>>>                enable_irq_wake(client->irq);
>>>        return 0;
>>> @@ -699,6 +703,10 @@ static int ds1374_resume(struct device *dev)
>>>   {
>>>        struct i2c_client *client = to_i2c_client(dev);
>>>
>>> +#ifdef CONFIG_RTC_DRV_DS1374_WDT
>>> +     ds1374_wdt_settimeout(131072);
>>> +#endif
>>> +
>>>        if (client->irq > 0 && device_may_wakeup(&client->dev))
>>>                disable_irq_wake(client->irq);
>>>        return 0;
>>> --
>>> 1.9.1
>>>
>>>
>>
>> --
>> Alexandre Belloni, Free Electrons
>> Embedded Linux and Kernel engineering
>> http://free-electrons.com
>>
> 

^ permalink raw reply

* Re: [PATCH] dt-bindings: RTC: Add sirf,prima2-sysrtc bindings
From: Alexandre Belloni @ 2017-09-26 13:45 UTC (permalink / raw)
  To: Rob Herring; +Cc: linux-rtc, linux-kernel, devicetree, Barry Song
In-Reply-To: <20170920205216.sgxyxc3bjcw3whot@rob-hp-laptop>

On 20/09/2017 at 15:52:16 -0500, Rob Herring wrote:
> On Fri, Sep 15, 2017 at 02:20:35AM +0200, Alexandre Belloni wrote:
> > Add device tree bindings for the SiRFSoC Real Time Clock.
> 
> Would be useful to note this is already in use and was undocumented.
> 
> > 
> > Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> > ---
> >  .../devicetree/bindings/rtc/sirf,prima2-sysrtc.txt         | 14 ++++++++++++++
> >  1 file changed, 14 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/rtc/sirf,prima2-sysrtc.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/rtc/sirf,prima2-sysrtc.txt b/Documentation/devicetree/bindings/rtc/sirf,prima2-sysrtc.txt
> > new file mode 100644
> > index 000000000000..206a5b44af48
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/rtc/sirf,prima2-sysrtc.txt
> > @@ -0,0 +1,14 @@
> > +SiRFSoC Real Time Clock
> > +
> > +Required properties:
> > +- compatible: must be "sirf,prima2-sysrtc"
> > +- reg: address range of rtc register set.
> > +- interrupts: rtc alarm interrupts.
> > +
> > +Example:
> > +			sysrtc@2000 {
> 
> rtc@...
> 
> Did you want to take all these patches or I can? At least the ones 
> touching trivial-devices.txt I'll take so I can deal with any conflicts.
> 

I think you can take them through your tree as they don't touch code in
drivers/rtc.

I'll resend v2 as a proper series.


-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply

* Re: [PATCH 3/3] powerpc/5200: dts: digsy_mtc.dts: fix rv3029 compatible
From: Alexandre Belloni @ 2017-09-26 13:40 UTC (permalink / raw)
  To: Anatolij Gustschin
  Cc: linux-rtc, linux-kernel, linux-arm-kernel, Nicolas Ferre,
	Michael Ellerman, linuxppc-dev, Rob Herring, devicetree
In-Reply-To: <20170915091326.4b93bde1@crub>

Hi,

On 15/09/2017 at 09:13:26 +0200, Anatolij Gustschin wrote:
> On Fri, 15 Sep 2017 04:00:04 +0200
> Alexandre Belloni alexandre.belloni@free-electrons.com wrote:
> 
> >The proper compatible for rv3029 is microcrystal,rv3029.
> >
> >Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> 
> Acked-by: Anatolij Gustschin <agust@denx.de>

If that is fine for you, I would prefer that goes through your tree as
I'm not usually taking DT patches through the RTC tree. there is no
dependency as the i2c subsystem will already match the new compatible
with the i2c device_id.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply

* Re: [PATCH] rtc: ds1374: wdt:support suspend/resume for watchdog
From: Alexandre Belloni @ 2017-09-26 10:22 UTC (permalink / raw)
  To: 18502523564
  Cc: a.zummo, linux-rtc, linux-kernel, Wim Van Sebroeck, Guenter Roeck,
	linux-watchdog
In-Reply-To: <tencent_BD3706918C1500105699D4E6@qq.com>

(+Cc wdt maintainers)

On 26/09/2017 at 09:56:32 +0800, 18502523564 wrote:
> Hi Alexandre,
> 
> Thanks for your reply.
> Do you think is this a issue when using as a watchdog in suspend?
> I takes the drivers/watchdog/ subsystem for reference, some drivers in suspend
> also call disable_watchdog.Or do you have any  better suggestion?

I guess this is a question for the watchdog subsystem maintainers.
However, I think that everything can be handled properly from userspace
as I know some atmel based devices have their watchdog enabled while
the platform is suspended.

> Thank you.
> 
> 
> 
> 
> ------------------ Original ------------------
> From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Date: 周一,9月 25,2017 20:07
> To: winton.liu <18502523564@163.com>
> Cc: a.zummo <a.zummo@towertech.it>, linux-rtc <linux-rtc@vger.kernel.org>,
> linux-kernel <linux-kernel@vger.kernel.org>
> Subject: Re: [PATCH] rtc: ds1374: wdt:support suspend/resume for watchdog
> 
> 
> Hi,
> 
> On 25/09/2017 at 19:58:44 +0800, winton.liu wrote:
> > When enable CONFIG_RTC_DRV_DS1374_WDT use as watchdog,
> > in suspend mode, watchdog is still working but no daemon
> > patting the watchdog. The system will reboot if timeout.
> > So disable watchdog in suspend  and recover it in resume.
> >
> 
> That is definitively not what we want. Many people will want to still
> have the watchdog running when the platform is suspended. Your options
> are to either disable the watchdog before going to suspend or wake up
> the platform just in time to ping the watchdog.
> 
> > Signed-off-by: winton.liu <18502523564@163.com>
> > ---
> >  drivers/rtc/rtc-ds1374.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
> > index 38a2e9e..e990773 100644
> > --- a/drivers/rtc/rtc-ds1374.c
> > +++ b/drivers/rtc/rtc-ds1374.c
> > @@ -690,6 +690,10 @@ static int ds1374_suspend(struct device *dev)
> >  {
> >       struct i2c_client *client = to_i2c_client(dev);
> >
> > +#ifdef CONFIG_RTC_DRV_DS1374_WDT
> > +     ds1374_wdt_disable();
> > +#endif
> > +
> >       if (client->irq > 0 && device_may_wakeup(&client->dev))
> >               enable_irq_wake(client->irq);
> >       return 0;
> > @@ -699,6 +703,10 @@ static int ds1374_resume(struct device *dev)
> >  {
> >       struct i2c_client *client = to_i2c_client(dev);
> >
> > +#ifdef CONFIG_RTC_DRV_DS1374_WDT
> > +     ds1374_wdt_settimeout(131072);
> > +#endif
> > +
> >       if (client->irq > 0 && device_may_wakeup(&client->dev))
> >               disable_irq_wake(client->irq);
> >       return 0;
> > --
> > 1.9.1
> >
> >
> 
> --
> Alexandre Belloni, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com
> 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply

* Re: [PATCH] rtc: ds1374: wdt:support suspend/resume for watchdog
From: 18502523564 @ 2017-09-26  1:56 UTC (permalink / raw)
  To: Alexandre Belloni ; +Cc: a.zummo, linux-rtc, linux-kernel
In-Reply-To: <20170925120742.ja54wu2orgai6fsr@piout.net>

[-- Attachment #1: Type: text/html, Size: 4283 bytes --]

^ permalink raw reply

* [PATCH] rtc: ds1374: wdt:support suspend/resume for watchdog
From: winton.liu @ 2017-09-25 11:58 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni, linux-rtc, linux-kernel; +Cc: winton.liu

When enable CONFIG_RTC_DRV_DS1374_WDT use as watchdog,
in suspend mode, watchdog is still working but no daemon
patting the watchdog. The system will reboot if timeout.
So disable watchdog in suspend  and recover it in resume.

Signed-off-by: winton.liu <18502523564@163.com>
---
 drivers/rtc/rtc-ds1374.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
index 38a2e9e..e990773 100644
--- a/drivers/rtc/rtc-ds1374.c
+++ b/drivers/rtc/rtc-ds1374.c
@@ -690,6 +690,10 @@ static int ds1374_suspend(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 
+#ifdef CONFIG_RTC_DRV_DS1374_WDT
+	ds1374_wdt_disable();
+#endif
+
 	if (client->irq > 0 && device_may_wakeup(&client->dev))
 		enable_irq_wake(client->irq);
 	return 0;
@@ -699,6 +703,10 @@ static int ds1374_resume(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 
+#ifdef CONFIG_RTC_DRV_DS1374_WDT
+	ds1374_wdt_settimeout(131072);
+#endif
+
 	if (client->irq > 0 && device_may_wakeup(&client->dev))
 		disable_irq_wake(client->irq);
 	return 0;
-- 
1.9.1

^ permalink raw reply related

* Re: [PATCH] rtc: ds1374: wdt:support suspend/resume for watchdog
From: Alexandre Belloni @ 2017-09-25 12:07 UTC (permalink / raw)
  To: winton.liu; +Cc: a.zummo, linux-rtc, linux-kernel
In-Reply-To: <1506340724-18108-1-git-send-email-18502523564@163.com>

Hi,

On 25/09/2017 at 19:58:44 +0800, winton.liu wrote:
> When enable CONFIG_RTC_DRV_DS1374_WDT use as watchdog,
> in suspend mode, watchdog is still working but no daemon
> patting the watchdog. The system will reboot if timeout.
> So disable watchdog in suspend  and recover it in resume.
> 

That is definitively not what we want. Many people will want to still
have the watchdog running when the platform is suspended. Your options
are to either disable the watchdog before going to suspend or wake up
the platform just in time to ping the watchdog.

> Signed-off-by: winton.liu <18502523564@163.com>
> ---
>  drivers/rtc/rtc-ds1374.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
> index 38a2e9e..e990773 100644
> --- a/drivers/rtc/rtc-ds1374.c
> +++ b/drivers/rtc/rtc-ds1374.c
> @@ -690,6 +690,10 @@ static int ds1374_suspend(struct device *dev)
>  {
>  	struct i2c_client *client = to_i2c_client(dev);
>  
> +#ifdef CONFIG_RTC_DRV_DS1374_WDT
> +	ds1374_wdt_disable();
> +#endif
> +
>  	if (client->irq > 0 && device_may_wakeup(&client->dev))
>  		enable_irq_wake(client->irq);
>  	return 0;
> @@ -699,6 +703,10 @@ static int ds1374_resume(struct device *dev)
>  {
>  	struct i2c_client *client = to_i2c_client(dev);
>  
> +#ifdef CONFIG_RTC_DRV_DS1374_WDT
> +	ds1374_wdt_settimeout(131072);
> +#endif
> +
>  	if (client->irq > 0 && device_may_wakeup(&client->dev))
>  		disable_irq_wake(client->irq);
>  	return 0;
> -- 
> 1.9.1
> 
> 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply

* Re: [PATCH v4 2/5] dt-bindings: input: Add document bindings for mtk-pmic-keys
From: Chen Zhong @ 2017-09-25  8:14 UTC (permalink / raw)
  To: Rob Herring
  Cc: Dmitry Torokhov, Lee Jones, Alexandre Belloni, Mark Rutland,
	Matthias Brugger, Eddie Huang, Alessandro Zummo, Andi Shyti,
	Jaechul Lee, Krzysztof Kozlowski, Linus Walleij,
	linux-input@vger.kernel.org, devicetree@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-mediatek,
	linux-kernel@vger.kernel.org, linux-rtc
In-Reply-To: <CAL_JsqJZtn7YLn6o9mQMPD+kuseKLbfKe+JiY=1BosqnVqi5Kw@mail.gmail.com>

On Sun, 2017-09-24 at 23:11 -0500, Rob Herring wrote:
> On Sat, Sep 23, 2017 at 1:47 AM, Chen Zhong <chen.zhong@mediatek.com> wrote:
> > Sorry for the typo.
> >
> > On Sat, 2017-09-23 at 14:38 +0800, Chen Zhong wrote:
> >> On Wed, 2017-09-20 at 15:53 -0500, Rob Herring wrote:
> >> > On Sun, Sep 17, 2017 at 04:00:49PM +0800, Chen Zhong wrote:
> >> > > This patch adds the device tree binding documentation for the MediaTek
> >> > > pmic keys found on PMIC MT6397/MT6323.
> >> > >
> >> > > Signed-off-by: Chen Zhong <chen.zhong@mediatek.com>
> >> > > ---
> >> > >  .../devicetree/bindings/input/mtk-pmic-keys.txt    |   41 ++++++++++++++++++++
> >> > >  1 file changed, 41 insertions(+)
> >> > >  create mode 100644 Documentation/devicetree/bindings/input/mtk-pmic-keys.txt
> >> > >
> >> > > diff --git a/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt b/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt
> >> > > new file mode 100644
> >> > > index 0000000..fd48ff7
> >> > > --- /dev/null
> >> > > +++ b/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt
> >> > > @@ -0,0 +1,41 @@
> >> > > +MediaTek MT6397/MT6323 PMIC Keys Device Driver
> >> > > +
> >> > > +There are two key functions provided by MT6397/MT6323 PMIC, pwrkey
> >> > > +and homekey. The key functions are defined as the subnode of the function
> >> > > +node provided by MT6397/MT6323 PMIC that is being defined as one kind
> >> > > +of Muti-Function Device (MFD)
> >> > > +
> >> > > +For MT6397/MT6323 MFD bindings see:
> >> > > +Documentation/devicetree/bindings/mfd/mt6397.txt
> >> > > +
> >> > > +Required properties:
> >> > > +- compatible: "mediatek,mt6397-keys" or "mediatek,mt6323-keys"
> >> > > +- linux,keycodes: Specifies the numeric keycode values to
> >> > > + be used for reporting keys presses. The array can
> >> > > + contain up to 2 entries.
> >> > > +
> >> > > +Optional Properties:
> >> > > +- mediatek,wakeup-keys: Specifies each key can be used as a wakeup source
> >> > > + or not. This can be customized depends on board design.
> >> >
> >> > I think this should be a common property if we're going to put into DT.
> >> > Something like "wakeup-scancodes" to be clear the values are the raw
> >> > scancodes. Alternatively, we could list Linux keycodes instead with
> >> > something like "linux,wakeup-keycodes".
> >> >
> >> > > +- wakeup-source: PMIC keys can be used as wakeup sources.
> >> >
> >> > Just "See ../power/wakeup-source.txt" for the description.
> >> >
> >> > > +- mediatek,long-press-mode: Long press key shutdown setting, 1 for
> >> > > + pwrkey only, 2 for pwrkey/homekey together, others for disabled.
> >> > > +- debounce-interval: Long press key shutdown debouncing interval time
> >> > > + in seconds. 0/1/2/3 for 8/11/14/5 seconds. If not specified defaults to 0.
> >> >
> >> > This property units should be in milliseconds. However, this doesn't
> >> > sound like debounce filtering time if 5-14 seconds. That sounds like
> >> > forced power off time (i.e. for a hung device). This also should be
> >> > common. I imagine we already have some drivers with similar properties.
> >>
> >> Hi Rob,
> >>
> >> I searched in kernel documents and found a similar usage in
> >> "ti,palmas-pwrbutton.txt"
> >> "- ti,palmas-long-press-seconds: Duration in seconds which the power
> >>   button should be kept pressed for Palmas to power off automatically."
> >>
> >> Could I just wrote it like this?
> >> mediatek,long-press-seconds = <0>;
> 
> That doesn't really tell what the long press does. How about
> "power-off-time-sec"? Surprisingly we don't have a common keyboard
> binding doc, so please start one and document it there. Then just
> refer to it.
> 

OK, I will add a common document named "keys.txt" and put the long press
property "power-off-time-sec" there as a common property.

> >>
> >> And for the wakeup source part, how about Dmitry's suggestion?
> 
> It's fine for me.
> 
> >> The whole device node would be:
> >>
> >> mt6397keys: mt6397keys {
> >>       compatible = "mediatek,mt6397-keys";
> >>       mediatek,long-press-mode = <1>;
> >>       mediatek,long-press-seconds = <0>;
> >>
> >>       power@0 {
> >>               linux,code = <116>;
> 
> linux,keycodes
> 
> Also, you either need a reg property with "0" or drop the unit address.

There is no need to add reg property here, I'll drop the unit address.

Thank you.
> 
> >>               wakeup-source;
> >>       };
> >>
> >>       home@0 {
> > should be home@1 {
> >>               linux,code = <114>;
> >>       };
> >> };
> >>
> >> Thank you.
> >>
> >> >
> >> > Rob
> >>
> >
> >

^ permalink raw reply

* Re: [PATCH v4 2/5] dt-bindings: input: Add document bindings for mtk-pmic-keys
From: Rob Herring @ 2017-09-25  4:11 UTC (permalink / raw)
  To: Chen Zhong
  Cc: Dmitry Torokhov, Lee Jones, Alexandre Belloni, Mark Rutland,
	Matthias Brugger, Eddie Huang, Alessandro Zummo, Andi Shyti,
	Jaechul Lee, Krzysztof Kozlowski, Linus Walleij,
	linux-input@vger.kernel.org, devicetree@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-mediatek,
	linux-kernel@vger.kernel.org, linux-rtc
In-Reply-To: <1506149223.19409.11.camel@mhfsdcap03>

On Sat, Sep 23, 2017 at 1:47 AM, Chen Zhong <chen.zhong@mediatek.com> wrote:
> Sorry for the typo.
>
> On Sat, 2017-09-23 at 14:38 +0800, Chen Zhong wrote:
>> On Wed, 2017-09-20 at 15:53 -0500, Rob Herring wrote:
>> > On Sun, Sep 17, 2017 at 04:00:49PM +0800, Chen Zhong wrote:
>> > > This patch adds the device tree binding documentation for the MediaTek
>> > > pmic keys found on PMIC MT6397/MT6323.
>> > >
>> > > Signed-off-by: Chen Zhong <chen.zhong@mediatek.com>
>> > > ---
>> > >  .../devicetree/bindings/input/mtk-pmic-keys.txt    |   41 ++++++++++++++++++++
>> > >  1 file changed, 41 insertions(+)
>> > >  create mode 100644 Documentation/devicetree/bindings/input/mtk-pmic-keys.txt
>> > >
>> > > diff --git a/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt b/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt
>> > > new file mode 100644
>> > > index 0000000..fd48ff7
>> > > --- /dev/null
>> > > +++ b/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt
>> > > @@ -0,0 +1,41 @@
>> > > +MediaTek MT6397/MT6323 PMIC Keys Device Driver
>> > > +
>> > > +There are two key functions provided by MT6397/MT6323 PMIC, pwrkey
>> > > +and homekey. The key functions are defined as the subnode of the function
>> > > +node provided by MT6397/MT6323 PMIC that is being defined as one kind
>> > > +of Muti-Function Device (MFD)
>> > > +
>> > > +For MT6397/MT6323 MFD bindings see:
>> > > +Documentation/devicetree/bindings/mfd/mt6397.txt
>> > > +
>> > > +Required properties:
>> > > +- compatible: "mediatek,mt6397-keys" or "mediatek,mt6323-keys"
>> > > +- linux,keycodes: Specifies the numeric keycode values to
>> > > + be used for reporting keys presses. The array can
>> > > + contain up to 2 entries.
>> > > +
>> > > +Optional Properties:
>> > > +- mediatek,wakeup-keys: Specifies each key can be used as a wakeup source
>> > > + or not. This can be customized depends on board design.
>> >
>> > I think this should be a common property if we're going to put into DT.
>> > Something like "wakeup-scancodes" to be clear the values are the raw
>> > scancodes. Alternatively, we could list Linux keycodes instead with
>> > something like "linux,wakeup-keycodes".
>> >
>> > > +- wakeup-source: PMIC keys can be used as wakeup sources.
>> >
>> > Just "See ../power/wakeup-source.txt" for the description.
>> >
>> > > +- mediatek,long-press-mode: Long press key shutdown setting, 1 for
>> > > + pwrkey only, 2 for pwrkey/homekey together, others for disabled.
>> > > +- debounce-interval: Long press key shutdown debouncing interval time
>> > > + in seconds. 0/1/2/3 for 8/11/14/5 seconds. If not specified defaults to 0.
>> >
>> > This property units should be in milliseconds. However, this doesn't
>> > sound like debounce filtering time if 5-14 seconds. That sounds like
>> > forced power off time (i.e. for a hung device). This also should be
>> > common. I imagine we already have some drivers with similar properties.
>>
>> Hi Rob,
>>
>> I searched in kernel documents and found a similar usage in
>> "ti,palmas-pwrbutton.txt"
>> "- ti,palmas-long-press-seconds: Duration in seconds which the power
>>   button should be kept pressed for Palmas to power off automatically."
>>
>> Could I just wrote it like this?
>> mediatek,long-press-seconds = <0>;

That doesn't really tell what the long press does. How about
"power-off-time-sec"? Surprisingly we don't have a common keyboard
binding doc, so please start one and document it there. Then just
refer to it.

>>
>> And for the wakeup source part, how about Dmitry's suggestion?

It's fine for me.

>> The whole device node would be:
>>
>> mt6397keys: mt6397keys {
>>       compatible = "mediatek,mt6397-keys";
>>       mediatek,long-press-mode = <1>;
>>       mediatek,long-press-seconds = <0>;
>>
>>       power@0 {
>>               linux,code = <116>;

linux,keycodes

Also, you either need a reg property with "0" or drop the unit address.

>>               wakeup-source;
>>       };
>>
>>       home@0 {
> should be home@1 {
>>               linux,code = <114>;
>>       };
>> };
>>
>> Thank you.
>>
>> >
>> > Rob
>>
>
>

^ permalink raw reply

* Re: [PATCH v4 2/5] dt-bindings: input: Add document bindings for mtk-pmic-keys
From: Chen Zhong @ 2017-09-23  6:47 UTC (permalink / raw)
  To: Rob Herring
  Cc: Dmitry Torokhov, Lee Jones, Alexandre Belloni, Mark Rutland,
	Matthias Brugger, Eddie Huang, Alessandro Zummo, Andi Shyti,
	Jaechul Lee, Krzysztof Kozlowski, Linus Walleij, linux-input,
	devicetree, linux-arm-kernel, linux-mediatek, linux-kernel,
	linux-rtc
In-Reply-To: <1506148695.19409.10.camel@mhfsdcap03>

Sorry for the typo.

On Sat, 2017-09-23 at 14:38 +0800, Chen Zhong wrote:
> On Wed, 2017-09-20 at 15:53 -0500, Rob Herring wrote:
> > On Sun, Sep 17, 2017 at 04:00:49PM +0800, Chen Zhong wrote:
> > > This patch adds the device tree binding documentation for the MediaTek
> > > pmic keys found on PMIC MT6397/MT6323.
> > > 
> > > Signed-off-by: Chen Zhong <chen.zhong@mediatek.com>
> > > ---
> > >  .../devicetree/bindings/input/mtk-pmic-keys.txt    |   41 ++++++++++++++++++++
> > >  1 file changed, 41 insertions(+)
> > >  create mode 100644 Documentation/devicetree/bindings/input/mtk-pmic-keys.txt
> > > 
> > > diff --git a/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt b/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt
> > > new file mode 100644
> > > index 0000000..fd48ff7
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt
> > > @@ -0,0 +1,41 @@
> > > +MediaTek MT6397/MT6323 PMIC Keys Device Driver
> > > +
> > > +There are two key functions provided by MT6397/MT6323 PMIC, pwrkey
> > > +and homekey. The key functions are defined as the subnode of the function
> > > +node provided by MT6397/MT6323 PMIC that is being defined as one kind
> > > +of Muti-Function Device (MFD)
> > > +
> > > +For MT6397/MT6323 MFD bindings see:
> > > +Documentation/devicetree/bindings/mfd/mt6397.txt
> > > +
> > > +Required properties:
> > > +- compatible: "mediatek,mt6397-keys" or "mediatek,mt6323-keys"
> > > +- linux,keycodes: Specifies the numeric keycode values to
> > > +	be used for reporting keys presses. The array can
> > > +	contain up to 2 entries.
> > > +
> > > +Optional Properties:
> > > +- mediatek,wakeup-keys: Specifies each key can be used as a wakeup source
> > > +	or not. This can be customized depends on board design.
> > 
> > I think this should be a common property if we're going to put into DT. 
> > Something like "wakeup-scancodes" to be clear the values are the raw 
> > scancodes. Alternatively, we could list Linux keycodes instead with 
> > something like "linux,wakeup-keycodes".
> > 
> > > +- wakeup-source: PMIC keys can be used as wakeup sources.
> > 
> > Just "See ../power/wakeup-source.txt" for the description.
> > 
> > > +- mediatek,long-press-mode: Long press key shutdown setting, 1 for
> > > +	pwrkey only, 2 for pwrkey/homekey together, others for disabled.
> > > +- debounce-interval: Long press key shutdown debouncing interval time
> > > +	in seconds. 0/1/2/3 for 8/11/14/5 seconds. If not specified defaults to 0.
> > 
> > This property units should be in milliseconds. However, this doesn't 
> > sound like debounce filtering time if 5-14 seconds. That sounds like 
> > forced power off time (i.e. for a hung device). This also should be 
> > common. I imagine we already have some drivers with similar properties.
> 
> Hi Rob,
> 
> I searched in kernel documents and found a similar usage in
> "ti,palmas-pwrbutton.txt"
> "- ti,palmas-long-press-seconds: Duration in seconds which the power
>   button should be kept pressed for Palmas to power off automatically."
> 
> Could I just wrote it like this?
> mediatek,long-press-seconds = <0>;
> 
> And for the wakeup source part, how about Dmitry's suggestion? 
> The whole device node would be:
> 
> mt6397keys: mt6397keys {
> 	compatible = "mediatek,mt6397-keys";
> 	mediatek,long-press-mode = <1>;
> 	mediatek,long-press-seconds = <0>;
> 	
> 	power@0 {
> 		linux,code = <116>;
> 		wakeup-source;
> 	};
> 
> 	home@0 {
should be home@1 {
> 		linux,code = <114>;
> 	};
> };
> 
> Thank you.
> 
> > 
> > Rob
> 

^ permalink raw reply

* Re: [PATCH v4 2/5] dt-bindings: input: Add document bindings for mtk-pmic-keys
From: Chen Zhong @ 2017-09-23  6:38 UTC (permalink / raw)
  To: Rob Herring
  Cc: Dmitry Torokhov, Lee Jones, Alexandre Belloni, Mark Rutland,
	Matthias Brugger, Eddie Huang, Alessandro Zummo, Andi Shyti,
	Jaechul Lee, Krzysztof Kozlowski, Linus Walleij, linux-input,
	devicetree, linux-arm-kernel, linux-mediatek, linux-kernel,
	linux-rtc
In-Reply-To: <20170920205301.v6gpmhll4pdpuyxv@rob-hp-laptop>

On Wed, 2017-09-20 at 15:53 -0500, Rob Herring wrote:
> On Sun, Sep 17, 2017 at 04:00:49PM +0800, Chen Zhong wrote:
> > This patch adds the device tree binding documentation for the MediaTek
> > pmic keys found on PMIC MT6397/MT6323.
> > 
> > Signed-off-by: Chen Zhong <chen.zhong@mediatek.com>
> > ---
> >  .../devicetree/bindings/input/mtk-pmic-keys.txt    |   41 ++++++++++++++++++++
> >  1 file changed, 41 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/input/mtk-pmic-keys.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt b/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt
> > new file mode 100644
> > index 0000000..fd48ff7
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt
> > @@ -0,0 +1,41 @@
> > +MediaTek MT6397/MT6323 PMIC Keys Device Driver
> > +
> > +There are two key functions provided by MT6397/MT6323 PMIC, pwrkey
> > +and homekey. The key functions are defined as the subnode of the function
> > +node provided by MT6397/MT6323 PMIC that is being defined as one kind
> > +of Muti-Function Device (MFD)
> > +
> > +For MT6397/MT6323 MFD bindings see:
> > +Documentation/devicetree/bindings/mfd/mt6397.txt
> > +
> > +Required properties:
> > +- compatible: "mediatek,mt6397-keys" or "mediatek,mt6323-keys"
> > +- linux,keycodes: Specifies the numeric keycode values to
> > +	be used for reporting keys presses. The array can
> > +	contain up to 2 entries.
> > +
> > +Optional Properties:
> > +- mediatek,wakeup-keys: Specifies each key can be used as a wakeup source
> > +	or not. This can be customized depends on board design.
> 
> I think this should be a common property if we're going to put into DT. 
> Something like "wakeup-scancodes" to be clear the values are the raw 
> scancodes. Alternatively, we could list Linux keycodes instead with 
> something like "linux,wakeup-keycodes".
> 
> > +- wakeup-source: PMIC keys can be used as wakeup sources.
> 
> Just "See ../power/wakeup-source.txt" for the description.
> 
> > +- mediatek,long-press-mode: Long press key shutdown setting, 1 for
> > +	pwrkey only, 2 for pwrkey/homekey together, others for disabled.
> > +- debounce-interval: Long press key shutdown debouncing interval time
> > +	in seconds. 0/1/2/3 for 8/11/14/5 seconds. If not specified defaults to 0.
> 
> This property units should be in milliseconds. However, this doesn't 
> sound like debounce filtering time if 5-14 seconds. That sounds like 
> forced power off time (i.e. for a hung device). This also should be 
> common. I imagine we already have some drivers with similar properties.

Hi Rob,

I searched in kernel documents and found a similar usage in
"ti,palmas-pwrbutton.txt"
"- ti,palmas-long-press-seconds: Duration in seconds which the power
  button should be kept pressed for Palmas to power off automatically."

Could I just wrote it like this?
mediatek,long-press-seconds = <0>;

And for the wakeup source part, how about Dmitry's suggestion? 
The whole device node would be:

mt6397keys: mt6397keys {
	compatible = "mediatek,mt6397-keys";
	mediatek,long-press-mode = <1>;
	mediatek,long-press-seconds = <0>;
	
	power@0 {
		linux,code = <116>;
		wakeup-source;
	};

	home@0 {
		linux,code = <114>;
	};
};

Thank you.

> 
> Rob

^ permalink raw reply

* Re: [PATCH 3/4] rtc: mediatek: enhance the description for MediaTek PMIC based RTC
From: Eddie Huang @ 2017-09-22  8:07 UTC (permalink / raw)
  To: sean.wang
  Cc: a.zummo, alexandre.belloni, robh+dt, mark.rutland, linux-rtc,
	devicetree, linux-mediatek, linux-kernel
In-Reply-To: <0d9d5559d9d884c98ef589a8f56ab0dcb140e5e0.1506049341.git.sean.wang@mediatek.com>

Hi Sean,

On Fri, 2017-09-22 at 11:33 +0800, sean.wang@mediatek.com wrote:
> From: Sean Wang <sean.wang@mediatek.com>
> 
> Give a better description for original MediaTek RTC driver as PMIC based
> RTC in order to distinguish SoC based RTC. Also turning all words with
> Mediatek to MediaTek here.
> 
> Cc: Eddie Huang <eddie.huang@mediatek.com>
> Signed-off-by: Sean Wang <sean.wang@mediatek.com>
> ---
>  drivers/rtc/Kconfig | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
> index 4226295..4500f77 100644
> --- a/drivers/rtc/Kconfig
> +++ b/drivers/rtc/Kconfig
> @@ -1716,14 +1716,14 @@ config RTC_DRV_MEDIATEK
>  	  will be called rtc-mediatek.
>  
>  config RTC_DRV_MT6397
> -	tristate "Mediatek Real Time Clock driver"
> +	tristate "MediaTek PMIC based RTC"
>  	depends on MFD_MT6397 || (COMPILE_TEST && IRQ_DOMAIN)
>  	help
> -	  This selects the Mediatek(R) RTC driver. RTC is part of Mediatek
> +	  This selects the MediaTek(R) RTC driver. RTC is part of MediaTek
>  	  MT6397 PMIC. You should enable MT6397 PMIC MFD before select
> -	  Mediatek(R) RTC driver.
> +	  MediaTek(R) RTC driver.
>  
> -	  If you want to use Mediatek(R) RTC interface, select Y or M here.
> +	  If you want to use MediaTek(R) RTC interface, select Y or M here.
>  
>  config RTC_DRV_XGENE
>  	tristate "APM X-Gene RTC"

Thanks your correction.

Acked-by: Eddie Huang <eddie.huang@mediatek.com>

Regards,

^ permalink raw reply

* [PATCH 4/4] rtc: mediatek: update MAINTAINERS entry with MediaTek RTC driver
From: sean.wang @ 2017-09-22  3:33 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni, robh+dt, mark.rutland
  Cc: linux-rtc, devicetree, linux-mediatek, linux-kernel, Sean Wang,
	Eddie Huang
In-Reply-To: <cover.1506049341.git.sean.wang@mediatek.com>

From: Sean Wang <sean.wang@mediatek.com>

I work for MediaTek on maintaining the MediaTek SoC based RTC driver for
the existing SoCs and keep adding support for the following SoCs in the
future.

Cc: Eddie Huang <eddie.huang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
 MAINTAINERS | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 2281af4..5142029 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1579,10 +1579,13 @@ F:	drivers/rtc/rtc-armada38x.c
 
 ARM/Mediatek RTC DRIVER
 M:	Eddie Huang <eddie.huang@mediatek.com>
+M:	Sean Wang <sean.wang@mediatek.com>
 L:	linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
 L:	linux-mediatek@lists.infradead.org (moderated for non-subscribers)
 S:	Maintained
+F:	Documentation/devicetree/bindings/rtc/rtc-mediatek.txt
 F:	drivers/rtc/rtc-mt6397.c
+F:	drivers/rtc/rtc-mediatek.c
 
 ARM/Mediatek SoC support
 M:	Matthias Brugger <matthias.bgg@gmail.com>
-- 
2.7.4

^ permalink raw reply related

* [PATCH 3/4] rtc: mediatek: enhance the description for MediaTek PMIC based RTC
From: sean.wang @ 2017-09-22  3:33 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni, robh+dt, mark.rutland
  Cc: linux-rtc, devicetree, linux-mediatek, linux-kernel, Sean Wang,
	Eddie Huang
In-Reply-To: <cover.1506049341.git.sean.wang@mediatek.com>

From: Sean Wang <sean.wang@mediatek.com>

Give a better description for original MediaTek RTC driver as PMIC based
RTC in order to distinguish SoC based RTC. Also turning all words with
Mediatek to MediaTek here.

Cc: Eddie Huang <eddie.huang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
 drivers/rtc/Kconfig | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 4226295..4500f77 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -1716,14 +1716,14 @@ config RTC_DRV_MEDIATEK
 	  will be called rtc-mediatek.
 
 config RTC_DRV_MT6397
-	tristate "Mediatek Real Time Clock driver"
+	tristate "MediaTek PMIC based RTC"
 	depends on MFD_MT6397 || (COMPILE_TEST && IRQ_DOMAIN)
 	help
-	  This selects the Mediatek(R) RTC driver. RTC is part of Mediatek
+	  This selects the MediaTek(R) RTC driver. RTC is part of MediaTek
 	  MT6397 PMIC. You should enable MT6397 PMIC MFD before select
-	  Mediatek(R) RTC driver.
+	  MediaTek(R) RTC driver.
 
-	  If you want to use Mediatek(R) RTC interface, select Y or M here.
+	  If you want to use MediaTek(R) RTC interface, select Y or M here.
 
 config RTC_DRV_XGENE
 	tristate "APM X-Gene RTC"
-- 
2.7.4

^ permalink raw reply related

* [PATCH 2/4] rtc: mediatek: add driver for RTC on MT7622 SoC
From: sean.wang @ 2017-09-22  3:33 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni, robh+dt, mark.rutland
  Cc: linux-rtc, devicetree, linux-mediatek, linux-kernel, Sean Wang
In-Reply-To: <cover.1506049341.git.sean.wang@mediatek.com>

From: Sean Wang <sean.wang@mediatek.com>

This patch introduces the driver for the RTC on MT7622 SoC.

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
 drivers/rtc/Kconfig        |  10 ++
 drivers/rtc/Makefile       |   1 +
 drivers/rtc/rtc-mediatek.c | 398 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 409 insertions(+)
 create mode 100644 drivers/rtc/rtc-mediatek.c

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index e0e58f3..4226295 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -1705,6 +1705,16 @@ config RTC_DRV_MOXART
 	   This driver can also be built as a module. If so, the module
 	   will be called rtc-moxart
 
+config RTC_DRV_MEDIATEK
+	tristate "MediaTek SoC based RTC"
+	depends on ARCH_MEDIATEK || COMPILE_TEST
+	help
+	  This enables support for the real time clock built in the MediaTek
+	  SoCs.
+
+	  This drive can also be built as a module. If so, the module
+	  will be called rtc-mediatek.
+
 config RTC_DRV_MT6397
 	tristate "Mediatek Real Time Clock driver"
 	depends on MFD_MT6397 || (COMPILE_TEST && IRQ_DOMAIN)
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 7230014..ba0206a 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -101,6 +101,7 @@ obj-$(CONFIG_RTC_DRV_MOXART)	+= rtc-moxart.o
 obj-$(CONFIG_RTC_DRV_MPC5121)	+= rtc-mpc5121.o
 obj-$(CONFIG_RTC_DRV_VRTC)	+= rtc-mrst.o
 obj-$(CONFIG_RTC_DRV_MSM6242)	+= rtc-msm6242.o
+obj-$(CONFIG_RTC_DRV_MEDIATEK)	+= rtc-mediatek.o
 obj-$(CONFIG_RTC_DRV_MT6397)	+= rtc-mt6397.o
 obj-$(CONFIG_RTC_DRV_MV)	+= rtc-mv.o
 obj-$(CONFIG_RTC_DRV_MXC)	+= rtc-mxc.o
diff --git a/drivers/rtc/rtc-mediatek.c b/drivers/rtc/rtc-mediatek.c
new file mode 100644
index 0000000..c6c06fe
--- /dev/null
+++ b/drivers/rtc/rtc-mediatek.c
@@ -0,0 +1,398 @@
+/*
+ * Driver for MediaTek SoC based RTC
+ *
+ * Copyright (C) 2017 Sean Wang <sean.wang@mediatek.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * 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.
+ */
+
+#include <linux/clk.h>
+#include <linux/interrupt.h>
+#include <linux/module.h>
+#include <linux/of_address.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/rtc.h>
+
+#define MTK_RTC_DEV KBUILD_MODNAME
+
+#define MTK_RTC_PWRCHK1		0x4
+#define	RTC_PWRCHK1_MAGIC	0xc6
+
+#define MTK_RTC_PWRCHK2		0x8
+#define	RTC_PWRCHK2_MAGIC	0x9a
+
+#define MTK_RTC_KEY		0xc
+#define	RTC_KEY_MAGIC		0x59
+
+#define MTK_RTC_PROT1		0x10
+#define	RTC_PROT1_MAGIC		0xa3
+
+#define MTK_RTC_PROT2		0x14
+#define	RTC_PROT2_MAGIC		0x57
+
+#define MTK_RTC_PROT3		0x18
+#define	RTC_PROT3_MAGIC		0x67
+
+#define MTK_RTC_PROT4		0x1c
+#define	RTC_PROT4_MAGIC		0xd2
+
+#define MTK_RTC_CTL		0x20
+#define	RTC_RC_STOP		BIT(0)
+
+#define MTK_RTC_DEBNCE		0x2c
+#define	RTC_DEBNCE_MASK		GENMASK(2, 0)
+
+#define MTK_RTC_INT		0x30
+#define RTC_INT_AL_STA		BIT(4)
+
+/* Ranges from 0x40 to 0x78 provide RTC time setup for year, month,
+ * day of month, day of week, hour, minute and second.
+ */
+#define MTK_RTC_TREG(_t, _f)	(0x40 + (0x4 * (_f)) + ((_t) * 0x20))
+
+#define MTK_RTC_AL_CTL		0x7c
+#define	RTC_AL_EN		BIT(0)
+#define	RTC_AL_ALL		GENMASK(7, 0)
+
+/* Types of the function the RTC provides are time counter and alarm. */
+enum {
+	MTK_TC,
+	MTK_AL
+};
+
+/* Indexes are used for the pointer to relevant registers in MTK_RTC_TREG */
+enum {
+	MTK_YEA,
+	MTK_MON,
+	MTK_DOM,
+	MTK_DOW,
+	MTK_HOU,
+	MTK_MIN,
+	MTK_SEC
+};
+
+struct mtk_rtc {
+	struct rtc_device *rtc;
+	void __iomem *base;
+	int irq;
+	struct clk *clk;
+};
+
+static void mtk_w32(struct mtk_rtc *rtc, u32 reg, u32 val)
+{
+	__raw_writel(val, rtc->base + reg);
+}
+
+static u32 mtk_r32(struct mtk_rtc *rtc, u32 reg)
+{
+	return __raw_readl(rtc->base + reg);
+}
+
+static void mtk_rmw(struct mtk_rtc *rtc, u32 reg, u32 mask, u32 set)
+{
+	u32 val;
+
+	val = mtk_r32(rtc, reg);
+	val &= ~mask;
+	val |= set;
+	mtk_w32(rtc, reg, val);
+}
+
+static void mtk_set(struct mtk_rtc *rtc, u32 reg, u32 val)
+{
+	mtk_rmw(rtc, reg, 0, val);
+}
+
+static void mtk_clr(struct mtk_rtc *rtc, u32 reg, u32 val)
+{
+	mtk_rmw(rtc, reg, val, 0);
+}
+
+static void mtk_rtc_hw_init(struct mtk_rtc *hw)
+{
+	/* The setup of the init sequence is for allowing RTC got to work */
+	mtk_w32(hw, MTK_RTC_PWRCHK1, RTC_PWRCHK1_MAGIC);
+	mtk_w32(hw, MTK_RTC_PWRCHK2, RTC_PWRCHK2_MAGIC);
+	mtk_w32(hw, MTK_RTC_KEY, RTC_KEY_MAGIC);
+	mtk_w32(hw, MTK_RTC_PROT1, RTC_PROT1_MAGIC);
+	mtk_w32(hw, MTK_RTC_PROT2, RTC_PROT2_MAGIC);
+	mtk_w32(hw, MTK_RTC_PROT3, RTC_PROT3_MAGIC);
+	mtk_w32(hw, MTK_RTC_PROT4, RTC_PROT4_MAGIC);
+	mtk_rmw(hw, MTK_RTC_DEBNCE, RTC_DEBNCE_MASK, 0);
+	mtk_clr(hw, MTK_RTC_CTL, RTC_RC_STOP);
+}
+
+static void mtk_rtc_get_alarm_or_time(struct mtk_rtc *hw, struct rtc_time *tm,
+				      int time_alarm)
+{
+	u32 year, mon, mday, wday, hour, min, sec;
+
+	/*
+	 * Read again until all fields are not changed for all fields in the
+	 * consistent state.
+	 */
+	do {
+		year = mtk_r32(hw, MTK_RTC_TREG(time_alarm, MTK_YEA));
+		mon = mtk_r32(hw, MTK_RTC_TREG(time_alarm, MTK_MON));
+		wday = mtk_r32(hw, MTK_RTC_TREG(time_alarm, MTK_DOW));
+		mday = mtk_r32(hw, MTK_RTC_TREG(time_alarm, MTK_DOM));
+		hour = mtk_r32(hw, MTK_RTC_TREG(time_alarm, MTK_HOU));
+		min = mtk_r32(hw, MTK_RTC_TREG(time_alarm, MTK_MIN));
+		sec = mtk_r32(hw, MTK_RTC_TREG(time_alarm, MTK_SEC));
+	} while (year != mtk_r32(hw, MTK_RTC_TREG(time_alarm, MTK_YEA)) ||
+		 mon != mtk_r32(hw, MTK_RTC_TREG(time_alarm, MTK_MON))  ||
+		 mday != mtk_r32(hw, MTK_RTC_TREG(time_alarm, MTK_DOM))	||
+		 wday != mtk_r32(hw, MTK_RTC_TREG(time_alarm, MTK_DOW))	||
+		 hour != mtk_r32(hw, MTK_RTC_TREG(time_alarm, MTK_HOU))	||
+		 min != mtk_r32(hw, MTK_RTC_TREG(time_alarm, MTK_MIN))	||
+		 sec != mtk_r32(hw, MTK_RTC_TREG(time_alarm, MTK_SEC))
+		);
+
+	tm->tm_sec  = sec;
+	tm->tm_min  = min;
+	tm->tm_hour = hour;
+	tm->tm_wday = wday;
+	tm->tm_mday = mday;
+	tm->tm_mon  = mon - 1;
+	tm->tm_year = year;
+	tm->tm_year += 100;
+}
+
+static void mtk_rtc_set_alarm_or_time(struct mtk_rtc *hw, struct rtc_time *tm,
+				      int time_alarm)
+{
+	mtk_w32(hw, MTK_RTC_TREG(time_alarm, MTK_YEA), tm->tm_year - 100);
+	mtk_w32(hw, MTK_RTC_TREG(time_alarm, MTK_MON), tm->tm_mon + 1);
+	mtk_w32(hw, MTK_RTC_TREG(time_alarm, MTK_DOW), tm->tm_wday);
+	mtk_w32(hw, MTK_RTC_TREG(time_alarm, MTK_DOM), tm->tm_mday);
+	mtk_w32(hw, MTK_RTC_TREG(time_alarm, MTK_HOU), tm->tm_hour);
+	mtk_w32(hw, MTK_RTC_TREG(time_alarm, MTK_MIN), tm->tm_min);
+	mtk_w32(hw, MTK_RTC_TREG(time_alarm, MTK_SEC), tm->tm_sec);
+}
+
+static irqreturn_t mtk_rtc_alarmirq(int irq, void *id)
+{
+	struct mtk_rtc *hw = (struct mtk_rtc *)id;
+	u32 irq_sta;
+
+	/* Stop alarm also implicitly disable the alarm interrupt */
+	mtk_w32(hw, MTK_RTC_AL_CTL, 0);
+	irq_sta = mtk_r32(hw, MTK_RTC_INT);
+	if (irq_sta & RTC_INT_AL_STA) {
+		rtc_update_irq(hw->rtc, 1, RTC_IRQF | RTC_AF);
+
+		/* Ack alarm interrupt status */
+		mtk_w32(hw, MTK_RTC_INT, RTC_INT_AL_STA);
+		return IRQ_HANDLED;
+	}
+
+	return IRQ_NONE;
+}
+
+static int mtk_rtc_gettime(struct device *dev, struct rtc_time *tm)
+{
+	struct mtk_rtc *hw = dev_get_drvdata(dev);
+
+	mtk_rtc_get_alarm_or_time(hw, tm, MTK_TC);
+
+	return rtc_valid_tm(tm);
+}
+
+static int mtk_rtc_settime(struct device *dev, struct rtc_time *tm)
+{
+	struct mtk_rtc *hw = dev_get_drvdata(dev);
+
+	/* Stop time counter before setting a new one*/
+	mtk_set(hw, MTK_RTC_CTL, RTC_RC_STOP);
+
+	/* Epoch == 1900 */
+	if (tm->tm_year < 100 || tm->tm_year > 199)
+		return -EINVAL;
+
+	mtk_rtc_set_alarm_or_time(hw, tm, MTK_TC);
+
+	/* Restart the time counter */
+	mtk_clr(hw, MTK_RTC_CTL, RTC_RC_STOP);
+
+	return 0;
+}
+
+static int mtk_rtc_getalarm(struct device *dev, struct rtc_wkalrm *wkalrm)
+{
+	struct mtk_rtc *hw = dev_get_drvdata(dev);
+	struct rtc_time *alrm_tm = &wkalrm->time;
+
+	mtk_rtc_get_alarm_or_time(hw, alrm_tm, MTK_AL);
+
+	wkalrm->enabled = !!(mtk_r32(hw, MTK_RTC_AL_CTL) & RTC_AL_EN);
+	wkalrm->pending = !!(mtk_r32(hw, MTK_RTC_INT) & RTC_INT_AL_STA);
+
+	return 0;
+}
+
+static int mtk_rtc_setalarm(struct device *dev, struct rtc_wkalrm *wkalrm)
+{
+	struct mtk_rtc *hw = dev_get_drvdata(dev);
+	struct rtc_time *alrm_tm = &wkalrm->time;
+
+	/* Epoch == 1900 */
+	if (alrm_tm->tm_year < 100 || alrm_tm->tm_year > 199)
+		return -EINVAL;
+
+	/*
+	 * Stop the alarm also implicitly including disables interrupt before
+	 * setting a new one.
+	 */
+	mtk_clr(hw, MTK_RTC_AL_CTL, RTC_AL_EN);
+
+	/*
+	 * Avoid contention between mtk_rtc_setalarm and IRQ handler so that
+	 * disabling the interrupt and awaiting for pending IRQ handler to
+	 * complete.
+	 */
+	synchronize_irq(hw->irq);
+
+	mtk_rtc_set_alarm_or_time(hw, alrm_tm, MTK_AL);
+
+	/* Restart the alarm with the new setup */
+	mtk_w32(hw, MTK_RTC_AL_CTL, RTC_AL_ALL);
+
+	return 0;
+}
+
+static const struct rtc_class_ops mtk_rtc_ops = {
+	.read_time		= mtk_rtc_gettime,
+	.set_time		= mtk_rtc_settime,
+	.read_alarm		= mtk_rtc_getalarm,
+	.set_alarm		= mtk_rtc_setalarm,
+};
+
+static const struct of_device_id mtk_rtc_match[] = {
+	{ .compatible = "mediatek,mt7622-rtc" },
+	{ .compatible = "mediatek,soc-rtc" },
+	{},
+};
+
+static int mtk_rtc_probe(struct platform_device *pdev)
+{
+	struct mtk_rtc *hw;
+	struct resource *res;
+	int ret;
+
+	hw = devm_kzalloc(&pdev->dev, sizeof(*hw), GFP_KERNEL);
+	if (!hw)
+		return -ENOMEM;
+
+	platform_set_drvdata(pdev, hw);
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	hw->base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(hw->base))
+		return PTR_ERR(hw->base);
+
+	hw->clk = devm_clk_get(&pdev->dev, "rtc");
+	if (IS_ERR(hw->clk)) {
+		dev_err(&pdev->dev, "No clock\n");
+		return PTR_ERR(hw->clk);
+	}
+
+	ret = clk_prepare_enable(hw->clk);
+	if (ret)
+		return ret;
+
+	hw->irq = platform_get_irq(pdev, 0);
+	if (hw->irq < 0) {
+		dev_err(&pdev->dev, "No IRQ resource\n");
+		ret = hw->irq;
+		goto err;
+	}
+
+	ret = devm_request_irq(&pdev->dev, hw->irq, mtk_rtc_alarmirq,
+			       0, dev_name(&pdev->dev), hw);
+	if (ret) {
+		dev_err(&pdev->dev, "Can't request IRQ\n");
+		goto err;
+	}
+
+	mtk_rtc_hw_init(hw);
+
+	device_init_wakeup(&pdev->dev, true);
+
+	hw->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
+					   &mtk_rtc_ops, THIS_MODULE);
+	if (IS_ERR(hw->rtc)) {
+		ret = PTR_ERR(hw->rtc);
+		dev_err(&pdev->dev, "Unable to register device\n");
+		goto err;
+	}
+
+	dev_info(&pdev->dev, "MediaTek SoC based RTC enabled\n");
+
+	return 0;
+err:
+	clk_disable_unprepare(hw->clk);
+
+	return ret;
+}
+
+static int mtk_rtc_remove(struct platform_device *pdev)
+{
+	struct mtk_rtc *hw = platform_get_drvdata(pdev);
+
+	clk_disable_unprepare(hw->clk);
+
+	return 0;
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int mtk_rtc_suspend(struct device *dev)
+{
+	struct mtk_rtc *hw = dev_get_drvdata(dev);
+
+	if (device_may_wakeup(dev))
+		enable_irq_wake(hw->irq);
+
+	return 0;
+}
+
+static int mtk_rtc_resume(struct device *dev)
+{
+	struct mtk_rtc *hw = dev_get_drvdata(dev);
+
+	if (device_may_wakeup(dev))
+		disable_irq_wake(hw->irq);
+
+	return 0;
+}
+
+static SIMPLE_DEV_PM_OPS(mtk_rtc_pm_ops, mtk_rtc_suspend, mtk_rtc_resume);
+
+#define MTK_RTC_PM_OPS (&mtk_rtc_pm_ops)
+#else	/* CONFIG_PM */
+#define MTK_RTC_PM_OPS NULL
+#endif	/* CONFIG_PM */
+
+static struct platform_driver mtk_rtc_driver = {
+	.probe	= mtk_rtc_probe,
+	.remove	= mtk_rtc_remove,
+	.driver = {
+		.name = MTK_RTC_DEV,
+		.of_match_table = mtk_rtc_match,
+		.pm = MTK_RTC_PM_OPS,
+	},
+};
+
+module_platform_driver(mtk_rtc_driver);
+
+MODULE_DESCRIPTION("MediaTek SoC based RTC Driver");
+MODULE_AUTHOR("Sean Wang <sean.wang@mediatek.com>");
+MODULE_LICENSE("GPL");
-- 
2.7.4

^ permalink raw reply related

* [PATCH 1/4] dt-bindings: rtc: mediatek: add bindings for MediaTek SoC based RTC
From: sean.wang @ 2017-09-22  3:33 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni, robh+dt, mark.rutland
  Cc: linux-rtc, devicetree, linux-mediatek, linux-kernel, Sean Wang
In-Reply-To: <cover.1506049341.git.sean.wang@mediatek.com>

From: Sean Wang <sean.wang@mediatek.com>

Add device-tree binding for MediaTek SoC based RTC

Cc: devicetree@vger.kernel.org
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
 .../devicetree/bindings/rtc/rtc-mediatek.txt        | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rtc/rtc-mediatek.txt

diff --git a/Documentation/devicetree/bindings/rtc/rtc-mediatek.txt b/Documentation/devicetree/bindings/rtc/rtc-mediatek.txt
new file mode 100644
index 0000000..09fe8f5
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/rtc-mediatek.txt
@@ -0,0 +1,21 @@
+Device-Tree bindings for MediaTek SoC based RTC
+
+Required properties:
+- compatible	    : Should be
+			"mediatek,mt7622-rtc", "mediatek,soc-rtc" : for MT7622 SoC
+- reg 		    : Specifies base physical address and size of the registers;
+- interrupts	    : Should contain the interrupt for RTC alarm;
+- clocks	    : Specifies list of clock specifiers, corresponding to
+		      entries in clock-names property;
+- clock-names	    : Should contain "rtc" entries
+
+Example:
+
+rtc: rtc@10212800 {
+	compatible = "mediatek,mt7622-rtc",
+		     "mediatek,soc-rtc";
+	reg = <0 0x10212800 0 0x200>;
+	interrupts = <GIC_SPI 129 IRQ_TYPE_LEVEL_LOW>;
+	clocks = <&topckgen CLK_TOP_RTC>;
+	clock-names = "rtc";
+};
-- 
2.7.4

^ permalink raw reply related

* [PATCH 0/4] rtc: mediatek: add support for SoC based RTC on MT7622
From: sean.wang @ 2017-09-22  3:33 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni, robh+dt, mark.rutland
  Cc: linux-rtc, devicetree, linux-mediatek, linux-kernel, Sean Wang

From: Sean Wang <sean.wang@mediatek.com>

This patchset introduces support for MediaTek SoC based real time clock
(RTC) Currently, the driver is already tested successfully with hwclock
and wakealarm on MT7622 SoC. And it should also be workable on other
similar MediaTek SoCs. And patch 3 is a distinct patch used to distinguish
between either SoC based or PMIC based RTC to avoid confusion for the RTC
selection for the target SoC.

Sean Wang (4):
  dt-bindings: rtc: mediatek: add bindings for MediaTek SoC based RTC
  rtc: mediatek: add driver for RTC on MT7622 SoC
  rtc: mediatek: enhance the description for MediaTek PMIC based RTC
  rtc: mediatek: update MAINTAINERS entry with MediaTek RTC driver

 .../devicetree/bindings/rtc/rtc-mediatek.txt       |  21 ++
 MAINTAINERS                                        |   3 +
 drivers/rtc/Kconfig                                |  18 +-
 drivers/rtc/Makefile                               |   1 +
 drivers/rtc/rtc-mediatek.c                         | 398 +++++++++++++++++++++
 5 files changed, 437 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/rtc/rtc-mediatek.txt
 create mode 100644 drivers/rtc/rtc-mediatek.c

-- 
2.7.4

^ permalink raw reply

* Re: [PATCH] dt-bindings: fix vendor prefix for Abracon
From: Rob Herring @ 2017-09-21 22:57 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: linux-rtc, linux-kernel, devicetree
In-Reply-To: <20170914213938.4980-1-alexandre.belloni@free-electrons.com>

On Thu, Sep 14, 2017 at 11:39:38PM +0200, Alexandre Belloni wrote:
> Commit 446810f2dd41 ("of: add vendor prefix for Abracon Corporation")
> claimed that "abcn" was used as the vendor prefix while in fact "abracon"
> was used in the subsequent commits. It is also the only prefix used in the
> tree.
> 
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
>  Documentation/devicetree/bindings/vendor-prefixes.txt | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied with alphabetical ordering fixed.

Rob

^ permalink raw reply

* Re: [PATCH] rtc: interface: set the next alarm event appropriately
From: Alexandre Belloni @ 2017-09-21  8:57 UTC (permalink / raw)
  To: YiPing Xu
  Cc: a.zummo, linux-rtc, linux-kernel, roy.chenjun, colin.king,
	wanghao24
In-Reply-To: <b13fabbb-fe2e-b3a3-6e8e-c42b8bab063c@hisilicon.com>

Hi,

On 21/09/2017 at 14:45:17 +0800, YiPing Xu wrote:
> 
> 
> On 2017/9/20 17:16, Alexandre Belloni wrote:
> > Hi,
> > 
> > On 20/09/2017 at 11:22:31 +0800, Xu Yiping wrote:
> > > From: Xu YiPing  <xuyiping@hisilicon.com>
> > > 
> > > After commit 2b2f5ff00f63 ("rtc: interface: ignore expired timers when
> > > enqueuing new timers"), the rtc_timer_enqueue will not reprogram the RTC
> > > when there is any non-expired timers in the timerqueue. If we set a
> > > RTC_TIMER between now and the next non-expired timers, it won't go into
> > > effect in time.
> > > 
> > > So, besides ignoring the expired timers, we should take the next effect
> > > timer into account, and reprogram the RTC timer appropriately.
> > > 
> > 
> > Can you try this patch instead? I think it solves this issue:
> > http://patchwork.ozlabs.org/patch/792482/
> 
>    We've tested this patch, it works too.
> 
>    Will it be merged into the main tree?
> 

Yes, I will send it as a fix for 4.14.


-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply

* Re: [PATCH] rtc: interface: set the next alarm event appropriately
From: YiPing Xu @ 2017-09-21  6:45 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: a.zummo, linux-rtc, linux-kernel, roy.chenjun, colin.king,
	wanghao24
In-Reply-To: <20170920091617.j7sie3mrncjkcj3m@piout.net>



On 2017/9/20 17:16, Alexandre Belloni wrote:
> Hi,
>
> On 20/09/2017 at 11:22:31 +0800, Xu Yiping wrote:
>> From: Xu YiPing  <xuyiping@hisilicon.com>
>>
>> After commit 2b2f5ff00f63 ("rtc: interface: ignore expired timers when
>> enqueuing new timers"), the rtc_timer_enqueue will not reprogram the RTC
>> when there is any non-expired timers in the timerqueue. If we set a
>> RTC_TIMER between now and the next non-expired timers, it won't go into
>> effect in time.
>>
>> So, besides ignoring the expired timers, we should take the next effect
>> timer into account, and reprogram the RTC timer appropriately.
>>
>
> Can you try this patch instead? I think it solves this issue:
> http://patchwork.ozlabs.org/patch/792482/

    We've tested this patch, it works too.

    Will it be merged into the main tree?

>> Signed-off-by: Xu YiPing <xuyiping@hisilicon.com>
>> Signed-off-by: Chen Jun <roy.chenjun@hisilicon.com>
>> ---
>>  drivers/rtc/interface.c | 9 ++++++---
>>  1 file changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
>> index 8cec9a0..e237166 100644
>> --- a/drivers/rtc/interface.c
>> +++ b/drivers/rtc/interface.c
>> @@ -766,20 +766,23 @@ static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer)
>>  	struct timerqueue_node *next = timerqueue_getnext(&rtc->timerqueue);
>>  	struct rtc_time tm;
>>  	ktime_t now;
>> +	ktime_t next_effect = KTIME_MAX;
>>
>>  	timer->enabled = 1;
>>  	__rtc_read_time(rtc, &tm);
>>  	now = rtc_tm_to_ktime(tm);
>>
>> -	/* Skip over expired timers */
>> +	/* Skip over expired timers, get next effect timer */
>>  	while (next) {
>> -		if (next->expires >= now)
>> +		if (next->expires >= now) {
>> +			next_effect = next->expires;
>>  			break;
>> +		}
>>  		next = timerqueue_iterate_next(next);
>>  	}
>>
>>  	timerqueue_add(&rtc->timerqueue, &timer->node);
>> -	if (!next) {
>> +	if (timer->node.expires < next_effect) {
>>  		struct rtc_wkalrm alarm;
>>  		int err;
>>  		alarm.time = rtc_ktime_to_tm(timer->node.expires);
>> --
>> 2.7.4
>>
>

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox