* 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
* [PATCH] rtc: rv3029: Clean up error handling in rv3029_eeprom_write()
From: Dan Carpenter @ 2017-09-20 21:45 UTC (permalink / raw)
To: Alessandro Zummo; +Cc: Alexandre Belloni, linux-rtc, kernel-janitors
We don't need both "ret" and "err" when they do the same thing. All the
functions called here return zero on success or negative error codes.
It's more clear to return a literal zero at the end instead of
"return ret;"
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/rtc/rtc-rv3029c2.c b/drivers/rtc/rtc-rv3029c2.c
index aa09771de04f..f4f957ab5fe6 100644
--- a/drivers/rtc/rtc-rv3029c2.c
+++ b/drivers/rtc/rtc-rv3029c2.c
@@ -282,13 +282,13 @@ static int rv3029_eeprom_read(struct device *dev, u8 reg,
static int rv3029_eeprom_write(struct device *dev, u8 reg,
u8 const buf[], size_t len)
{
- int ret, err;
+ int ret;
size_t i;
u8 tmp;
- err = rv3029_eeprom_enter(dev);
- if (err < 0)
- return err;
+ ret = rv3029_eeprom_enter(dev);
+ if (ret < 0)
+ return ret;
for (i = 0; i < len; i++, reg++) {
ret = rv3029_read_regs(dev, reg, &tmp, 1);
@@ -304,11 +304,11 @@ static int rv3029_eeprom_write(struct device *dev, u8 reg,
break;
}
- err = rv3029_eeprom_exit(dev);
- if (err < 0)
- return err;
+ ret = rv3029_eeprom_exit(dev);
+ if (ret < 0)
+ return ret;
- return ret;
+ return 0;
}
static int rv3029_eeprom_update_bits(struct device *dev,
^ permalink raw reply related
* Re: [PATCH v4 2/5] dt-bindings: input: Add document bindings for mtk-pmic-keys
From: Dmitry Torokhov @ 2017-09-20 21:14 UTC (permalink / raw)
To: Rob Herring
Cc: Chen Zhong, 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, Sep 20, 2017 at 03:53:01PM -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".
Should we go the gpio-keys way and describe keys as sub-nodes, possibly
using address as index?
mt6397keys: mt6397keys {
...
power@0 {
linux,code = <116>;
wakeup-source;
};
home@1 {
linux,code = <...>;
};
};
Thanks.
--
Dmitry
^ permalink raw reply
* Re: [PATCH v4 2/5] dt-bindings: input: Add document bindings for mtk-pmic-keys
From: Rob Herring @ 2017-09-20 20:53 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,
devicetree, linux-arm-kernel, linux-mediatek, linux-kernel,
linux-rtc
In-Reply-To: <1505635252-27716-3-git-send-email-chen.zhong@mediatek.com>
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.
Rob
^ permalink raw reply
* Re: [PATCH 1/3] RTC: rv3029: fix vendor string
From: Rob Herring @ 2017-09-20 20:52 UTC (permalink / raw)
To: Alexandre Belloni
Cc: linux-rtc, linux-kernel, linux-arm-kernel, Nicolas Ferre,
Michael Ellerman, Anatolij Gustschin, linuxppc-dev, devicetree
In-Reply-To: <20170915020004.24272-1-alexandre.belloni@free-electrons.com>
On Fri, Sep 15, 2017 at 04:00:02AM +0200, Alexandre Belloni wrote:
> The vendor string for Microcrystal is microcrystal.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
> Documentation/devicetree/bindings/trivial-devices.txt | 2 +-
> drivers/rtc/rtc-rv3029c2.c | 2 ++
> 2 files changed, 3 insertions(+), 1 deletion(-)
Acked-by: Rob Herring <robh@kernel.org>
^ permalink raw reply
* Re: [PATCH] dt-bindings: RTC: merge ds1339 in ds1307 documentation
From: Rob Herring @ 2017-09-20 20:52 UTC (permalink / raw)
To: Alexandre Belloni; +Cc: linux-rtc, linux-kernel, devicetree
In-Reply-To: <20170915014551.22664-2-alexandre.belloni@free-electrons.com>
On Fri, Sep 15, 2017 at 03:45:51AM +0200, Alexandre Belloni wrote:
> Now that there is documentation for the ds1307 and compatible RTCs, merge
> the ds1339 documentation in it.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
> .../devicetree/bindings/rtc/dallas,ds1339.txt | 18 ------------------
> Documentation/devicetree/bindings/rtc/rtc-ds1307.txt | 6 ++++++
> 2 files changed, 6 insertions(+), 18 deletions(-)
> delete mode 100644 Documentation/devicetree/bindings/rtc/dallas,ds1339.txt
>
> diff --git a/Documentation/devicetree/bindings/rtc/dallas,ds1339.txt b/Documentation/devicetree/bindings/rtc/dallas,ds1339.txt
> deleted file mode 100644
> index 916f57601a8f..000000000000
> --- a/Documentation/devicetree/bindings/rtc/dallas,ds1339.txt
> +++ /dev/null
> @@ -1,18 +0,0 @@
> -* Dallas DS1339 I2C Serial Real-Time Clock
> -
> -Required properties:
> -- compatible: Should contain "dallas,ds1339".
> -- reg: I2C address for chip
> -
> -Optional properties:
> -- trickle-resistor-ohms : Selected resistor for trickle charger
> - Values usable for ds1339 are 250, 2000, 4000
> - Should be given if trickle charger should be enabled
> -- trickle-diode-disable : Do not use internal trickle charger diode
> - Should be given if internal trickle charger diode should be disabled
> -Example:
> - ds1339: rtc@68 {
> - compatible = "dallas,ds1339";
> - trickle-resistor-ohms = <250>;
> - reg = <0x68>;
> - };
> diff --git a/Documentation/devicetree/bindings/rtc/rtc-ds1307.txt b/Documentation/devicetree/bindings/rtc/rtc-ds1307.txt
> index d1a820e25cb9..2eacc17a9b8d 100644
> --- a/Documentation/devicetree/bindings/rtc/rtc-ds1307.txt
> +++ b/Documentation/devicetree/bindings/rtc/rtc-ds1307.txt
> @@ -26,6 +26,11 @@ Optional properties:
> - clock-output-names: From common clock binding to override the default output
> clock name
> - wakeup-source: Enables wake up of host system on alarm
> +- trickle-resistor-ohms : Selected resistor for trickle charger
> + Values usable for ds1339 are 250, 2000, 4000
> + Should be given if trickle charger should be enabled
> +- trickle-diode-disable : Do not use internal trickle charger diode
> + Should be given if internal trickle charger diode should be disabled
Do these apply to all compatibles or just 1339?
Rob
^ permalink raw reply
* Re: [PATCH] dt-bindings: RTC: Add sirf,prima2-sysrtc bindings
From: Rob Herring @ 2017-09-20 20:52 UTC (permalink / raw)
To: Alexandre Belloni; +Cc: linux-rtc, linux-kernel, devicetree, Barry Song
In-Reply-To: <20170915002035.13284-1-alexandre.belloni@free-electrons.com>
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.
Rob
^ permalink raw reply
* Re: [PATCH] rtc: interface: set the next alarm event appropriately
From: YiPing Xu @ 2017-09-20 9:36 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>
Hi,
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/
it looks work.
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
* Re: [PATCH] rtc: interface: set the next alarm event appropriately
From: Alexandre Belloni @ 2017-09-20 9:16 UTC (permalink / raw)
To: Xu Yiping
Cc: a.zummo, linux-rtc, linux-kernel, roy.chenjun, colin.king,
wanghao24
In-Reply-To: <1505877751-26566-1-git-send-email-xuyiping@hisilicon.com>
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/
> 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
>
--
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply
* [PATCH] rtc: interface: set the next alarm event appropriately
From: Xu Yiping @ 2017-09-20 3:22 UTC (permalink / raw)
To: a.zummo, alexandre.belloni, linux-rtc, linux-kernel, roy.chenjun,
colin.king, wanghao24
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.
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 related
* [PATCH] rtc: jz4740: fix loading of rtc driver
From: Mathieu Malaterre @ 2017-09-18 19:10 UTC (permalink / raw)
To: Ralf Baechle
Cc: Alex Smith, Mathieu Malaterre, Zubair Lutfullah Kakakhel,
Alessandro Zummo, Alexandre Belloni, linux-rtc, linux-kernel
The current timeout for waiting for WRDY is not always sufficient. Always
increase it to 10000 even on JZ4740. This is technically only required on
JZ4780, where the current symptoms seen after a hard reboot are:
jz4740-rtc 10003000.rtc: rtc core: registered 10003000.rtc as rtc0
jz4740-rtc 10003000.rtc: Could not write to RTC registers
jz4740-rtc: probe of 10003000.rtc failed with error -5
Suggested-by: Alex Smith <alex.smith@imgtec.com>
Cc: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>
Signed-off-by: Mathieu Malaterre <malat@debian.org>
---
drivers/rtc/rtc-jz4740.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/rtc/rtc-jz4740.c b/drivers/rtc/rtc-jz4740.c
index c9536fb0ba4a..ff65a7d2b9c9 100644
--- a/drivers/rtc/rtc-jz4740.c
+++ b/drivers/rtc/rtc-jz4740.c
@@ -82,7 +82,7 @@ static inline uint32_t jz4740_rtc_reg_read(struct jz4740_rtc *rtc, size_t reg)
static int jz4740_rtc_wait_write_ready(struct jz4740_rtc *rtc)
{
uint32_t ctrl;
- int timeout = 1000;
+ int timeout = 10000;
do {
ctrl = jz4740_rtc_reg_read(rtc, JZ_REG_RTC_CTRL);
@@ -94,7 +94,7 @@ static int jz4740_rtc_wait_write_ready(struct jz4740_rtc *rtc)
static inline int jz4780_rtc_enable_write(struct jz4740_rtc *rtc)
{
uint32_t ctrl;
- int ret, timeout = 1000;
+ int ret, timeout = 10000;
ret = jz4740_rtc_wait_write_ready(rtc);
if (ret != 0)
--
2.11.0
^ permalink raw reply related
* [PATCH] rtc: sun6i: fix memory leak
From: Sudip Mukherjee @ 2017-09-17 12:43 UTC (permalink / raw)
To: Alessandro Zummo, Alexandre Belloni, Maxime Ripard, Chen-Yu Tsai
Cc: linux-kernel, linux-rtc, linux-arm-kernel, Sudip Mukherjee
If 'clk_data' is not allocated we returned but we failed to free 'rtc'.
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
---
drivers/rtc/rtc-sun6i.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c
index 3d2216c..5bc28ee 100644
--- a/drivers/rtc/rtc-sun6i.c
+++ b/drivers/rtc/rtc-sun6i.c
@@ -201,8 +201,10 @@ static void __init sun6i_rtc_clk_init(struct device_node *node)
clk_data = kzalloc(sizeof(*clk_data) + (sizeof(*clk_data->hws) * 2),
GFP_KERNEL);
- if (!clk_data)
+ if (!clk_data) {
+ kfree(rtc);
return;
+ }
spin_lock_init(&rtc->lock);
--
2.7.4
^ permalink raw reply related
* [PATCH v4 4/5] input: Add MediaTek PMIC keys support
From: Chen Zhong @ 2017-09-17 8:00 UTC (permalink / raw)
To: Dmitry Torokhov, Rob Herring, Lee Jones, Alexandre Belloni
Cc: Mark Rutland, Matthias Brugger, Eddie Huang, Alessandro Zummo,
Andi Shyti, Jaechul Lee, Krzysztof Kozlowski, Linus Walleij,
Chen Zhong, linux-input, devicetree, linux-arm-kernel,
linux-mediatek, linux-kernel, linux-rtc
In-Reply-To: <1505635252-27716-1-git-send-email-chen.zhong@mediatek.com>
This patch add support to handle MediaTek PMIC MT6397/MT6323 key
interrupts including pwrkey and homekey, also add setting for
long press key shutdown behavior.
Signed-off-by: Chen Zhong <chen.zhong@mediatek.com>
---
drivers/input/keyboard/Kconfig | 9 +
drivers/input/keyboard/Makefile | 1 +
drivers/input/keyboard/mtk-pmic-keys.c | 354 ++++++++++++++++++++++++++++++++
3 files changed, 364 insertions(+)
create mode 100644 drivers/input/keyboard/mtk-pmic-keys.c
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index 4c4ab1c..bd4e20a 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -756,4 +756,13 @@ config KEYBOARD_BCM
To compile this driver as a module, choose M here: the
module will be called bcm-keypad.
+config KEYBOARD_MTK_PMIC
+ tristate "MediaTek PMIC keys support"
+ depends on MFD_MT6397
+ help
+ Say Y here if you want to use the pmic keys (powerkey/homekey).
+
+ To compile this driver as a module, choose M here: the
+ module will be called pmic-keys.
+
endif
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index d2338ba..20c0b98 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -40,6 +40,7 @@ obj-$(CONFIG_KEYBOARD_MATRIX) += matrix_keypad.o
obj-$(CONFIG_KEYBOARD_MAX7359) += max7359_keypad.o
obj-$(CONFIG_KEYBOARD_MCS) += mcs_touchkey.o
obj-$(CONFIG_KEYBOARD_MPR121) += mpr121_touchkey.o
+obj-$(CONFIG_KEYBOARD_MTK_PMIC) += mtk-pmic-keys.o
obj-$(CONFIG_KEYBOARD_NEWTON) += newtonkbd.o
obj-$(CONFIG_KEYBOARD_NOMADIK) += nomadik-ske-keypad.o
obj-$(CONFIG_KEYBOARD_NSPIRE) += nspire-keypad.o
diff --git a/drivers/input/keyboard/mtk-pmic-keys.c b/drivers/input/keyboard/mtk-pmic-keys.c
new file mode 100644
index 0000000..23b6ee4
--- /dev/null
+++ b/drivers/input/keyboard/mtk-pmic-keys.c
@@ -0,0 +1,354 @@
+/*
+ * Copyright (C) 2017 MediaTek, Inc.
+ *
+ * Author: Chen Zhong <chen.zhong@mediatek.com>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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/module.h>
+#include <linux/kernel.h>
+#include <linux/input.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/kernel.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/regmap.h>
+#include <linux/mfd/mt6323/registers.h>
+#include <linux/mfd/mt6397/registers.h>
+#include <linux/mfd/mt6397/core.h>
+
+#define MTK_PMIC_PWRKEY_RST_EN_MASK 0x1
+#define MTK_PMIC_PWRKEY_RST_EN_SHIFT 6
+#define MTK_PMIC_HOMEKEY_RST_EN_MASK 0x1
+#define MTK_PMIC_HOMEKEY_RST_EN_SHIFT 5
+#define MTK_PMIC_RST_DU_MASK 0x3
+#define MTK_PMIC_RST_DU_SHIFT 8
+
+#define MTK_PMIC_PWRKEY_RST \
+ (MTK_PMIC_PWRKEY_RST_EN_MASK << MTK_PMIC_PWRKEY_RST_EN_SHIFT)
+#define MTK_PMIC_HOMEKEY_RST \
+ (MTK_PMIC_HOMEKEY_RST_EN_MASK << MTK_PMIC_HOMEKEY_RST_EN_SHIFT)
+
+#define MTK_PMIC_PWRKEY_INDEX 0
+#define MTK_PMIC_HOMEKEY_INDEX 1
+#define MTK_PMIC_MAX_KEY_COUNT 2
+
+struct mtk_pmic_keys_regs {
+ u32 deb_reg;
+ u32 deb_mask;
+ u32 intsel_reg;
+ u32 intsel_mask;
+};
+
+#define MTK_PMIC_KEYS_REGS(_deb_reg, _deb_mask, \
+ _intsel_reg, _intsel_mask) \
+{ \
+ .deb_reg = _deb_reg, \
+ .deb_mask = _deb_mask, \
+ .intsel_reg = _intsel_reg, \
+ .intsel_mask = _intsel_mask, \
+}
+
+struct mtk_pmic_regs {
+ const struct mtk_pmic_keys_regs keys_regs[MTK_PMIC_MAX_KEY_COUNT];
+ u32 pmic_rst_reg;
+};
+
+static const struct mtk_pmic_regs mt6397_regs = {
+ .keys_regs[MTK_PMIC_PWRKEY_INDEX] =
+ MTK_PMIC_KEYS_REGS(MT6397_CHRSTATUS,
+ 0x8, MT6397_INT_RSV, 0x10),
+ .keys_regs[MTK_PMIC_HOMEKEY_INDEX] =
+ MTK_PMIC_KEYS_REGS(MT6397_OCSTATUS2,
+ 0x10, MT6397_INT_RSV, 0x8),
+ .pmic_rst_reg = MT6397_TOP_RST_MISC,
+};
+
+static const struct mtk_pmic_regs mt6323_regs = {
+ .keys_regs[MTK_PMIC_PWRKEY_INDEX] =
+ MTK_PMIC_KEYS_REGS(MT6323_CHRSTATUS,
+ 0x2, MT6323_INT_MISC_CON, 0x10),
+ .keys_regs[MTK_PMIC_HOMEKEY_INDEX] =
+ MTK_PMIC_KEYS_REGS(MT6323_CHRSTATUS,
+ 0x4, MT6323_INT_MISC_CON, 0x8),
+ .pmic_rst_reg = MT6323_TOP_RST_MISC,
+};
+
+struct mtk_pmic_keys_info {
+ struct mtk_pmic_keys *keys;
+ const struct mtk_pmic_keys_regs *regs;
+ unsigned int keycode;
+ int irq;
+ bool wakeup:1;
+};
+
+struct mtk_pmic_keys {
+ struct input_dev *input_dev;
+ struct device *dev;
+ struct regmap *regmap;
+ struct mtk_pmic_keys_info keys[MTK_PMIC_MAX_KEY_COUNT];
+};
+
+enum mtk_pmic_keys_lp_mode {
+ LP_DISABLE,
+ LP_ONEKEY,
+ LP_TWOKEY,
+};
+
+static void mtk_pmic_keys_lp_reset_setup(struct mtk_pmic_keys *keys,
+ u32 pmic_rst_reg)
+{
+ int ret;
+ u32 long_press_mode, long_press_debounce;
+
+ ret = of_property_read_u32(keys->dev->of_node,
+ "debounce-interval", &long_press_debounce);
+ if (ret)
+ long_press_debounce = 0;
+
+ regmap_update_bits(keys->regmap, pmic_rst_reg,
+ MTK_PMIC_RST_DU_MASK << MTK_PMIC_RST_DU_SHIFT,
+ long_press_debounce << MTK_PMIC_RST_DU_SHIFT);
+
+ ret = of_property_read_u32(keys->dev->of_node,
+ "mediatek,long-press-mode", &long_press_mode);
+ if (ret)
+ long_press_mode = LP_DISABLE;
+
+ switch (long_press_mode) {
+ case LP_ONEKEY:
+ regmap_update_bits(keys->regmap, pmic_rst_reg,
+ MTK_PMIC_PWRKEY_RST,
+ MTK_PMIC_PWRKEY_RST);
+ regmap_update_bits(keys->regmap, pmic_rst_reg,
+ MTK_PMIC_HOMEKEY_RST,
+ 0);
+ break;
+ case LP_TWOKEY:
+ regmap_update_bits(keys->regmap, pmic_rst_reg,
+ MTK_PMIC_PWRKEY_RST,
+ MTK_PMIC_PWRKEY_RST);
+ regmap_update_bits(keys->regmap, pmic_rst_reg,
+ MTK_PMIC_HOMEKEY_RST,
+ MTK_PMIC_HOMEKEY_RST);
+ break;
+ case LP_DISABLE:
+ regmap_update_bits(keys->regmap, pmic_rst_reg,
+ MTK_PMIC_PWRKEY_RST,
+ 0);
+ regmap_update_bits(keys->regmap, pmic_rst_reg,
+ MTK_PMIC_HOMEKEY_RST,
+ 0);
+ break;
+ default:
+ break;
+ }
+}
+
+static irqreturn_t mtk_pmic_keys_irq_handler_thread(int irq, void *data)
+{
+ struct mtk_pmic_keys_info *info = data;
+ u32 key_deb, pressed;
+
+ regmap_read(info->keys->regmap, info->regs->deb_reg, &key_deb);
+
+ key_deb &= info->regs->deb_mask;
+
+ pressed = !key_deb;
+
+ input_report_key(info->keys->input_dev, info->keycode, pressed);
+ input_sync(info->keys->input_dev);
+
+ dev_dbg(info->keys->dev, "(%s) key =%d using PMIC\n",
+ pressed ? "pressed" : "released", info->keycode);
+
+ return IRQ_HANDLED;
+}
+
+static int mtk_pmic_key_setup(struct mtk_pmic_keys *keys,
+ struct mtk_pmic_keys_info *info)
+{
+ int ret;
+
+ info->keys = keys;
+
+ ret = regmap_update_bits(keys->regmap, info->regs->intsel_reg,
+ info->regs->intsel_mask,
+ info->regs->intsel_mask);
+ if (ret < 0)
+ return ret;
+
+ ret = devm_request_threaded_irq(keys->dev, info->irq, NULL,
+ mtk_pmic_keys_irq_handler_thread,
+ IRQF_ONESHOT | IRQF_TRIGGER_HIGH,
+ "mtk-pmic-keys", info);
+ if (ret) {
+ dev_err(keys->dev, "Failed to request IRQ: %d: %d\n",
+ info->irq, ret);
+ return ret;
+ }
+
+ input_set_capability(keys->input_dev, EV_KEY, info->keycode);
+
+ return 0;
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int mtk_pmic_keys_suspend(struct device *dev)
+{
+ struct mtk_pmic_keys *keys = dev_get_drvdata(dev);
+ int index;
+
+ for (index = 0; index < MTK_PMIC_MAX_KEY_COUNT; index++) {
+ if (keys->keys[index].wakeup)
+ enable_irq_wake(keys->keys[index].irq);
+ }
+
+ return 0;
+}
+
+static int mtk_pmic_keys_resume(struct device *dev)
+{
+ struct mtk_pmic_keys *keys = dev_get_drvdata(dev);
+ int index;
+
+ for (index = 0; index < MTK_PMIC_MAX_KEY_COUNT; index++) {
+ if (keys->keys[index].wakeup)
+ disable_irq_wake(keys->keys[index].irq);
+ }
+
+ return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(mtk_pmic_keys_pm_ops, mtk_pmic_keys_suspend,
+ mtk_pmic_keys_resume);
+
+static const struct of_device_id of_mtk_pmic_keys_match_tbl[] = {
+ {
+ .compatible = "mediatek,mt6397-keys",
+ .data = &mt6397_regs,
+ }, {
+ .compatible = "mediatek,mt6323-keys",
+ .data = &mt6323_regs,
+ }, {
+ /* sentinel */
+ }
+};
+MODULE_DEVICE_TABLE(of, of_mtk_pmic_keys_match_tbl);
+
+static int mtk_pmic_keys_probe(struct platform_device *pdev)
+{
+ int error, index = 0;
+ unsigned int keycount;
+ unsigned int keycodes[MTK_PMIC_MAX_KEY_COUNT];
+ unsigned int wakeup_srcs[MTK_PMIC_MAX_KEY_COUNT] = {0};
+ struct mt6397_chip *pmic_chip = dev_get_drvdata(pdev->dev.parent);
+ struct mtk_pmic_keys *keys;
+ const struct mtk_pmic_regs *mtk_pmic_regs;
+ struct input_dev *input_dev;
+ const struct of_device_id *of_id =
+ of_match_device(of_mtk_pmic_keys_match_tbl, &pdev->dev);
+
+ keys = devm_kzalloc(&pdev->dev, sizeof(*keys), GFP_KERNEL);
+ if (!keys)
+ return -ENOMEM;
+
+ keys->dev = &pdev->dev;
+ keys->regmap = pmic_chip->regmap;
+ mtk_pmic_regs = of_id->data;
+
+ keys->input_dev = input_dev = devm_input_allocate_device(keys->dev);
+ if (!input_dev) {
+ dev_err(keys->dev, "input allocate device fail.\n");
+ return -ENOMEM;
+ }
+
+ input_dev->name = "mtk-pmic-keys";
+ input_dev->id.bustype = BUS_HOST;
+ input_dev->id.vendor = 0x0001;
+ input_dev->id.product = 0x0001;
+ input_dev->id.version = 0x0001;
+
+ keycount = device_property_read_u32_array(keys->dev, "linux,keycodes",
+ NULL, 0);
+ if (keycount > MTK_PMIC_MAX_KEY_COUNT) {
+ dev_err(keys->dev, "too many keys defined (%d)\n", keycount);
+ return -EINVAL;
+ }
+
+ error = device_property_read_u32_array(keys->dev, "linux,keycodes",
+ keycodes, keycount);
+ if (error) {
+ dev_err(keys->dev,
+ "failed to read linux,keycode property: %d\n", error);
+ return error;
+ }
+
+ if (device_property_read_bool(keys->dev, "wakeup-source")) {
+ error = device_property_read_u32_array(keys->dev,
+ "mediatek,wakeup-keys",
+ wakeup_srcs, keycount);
+ if (error) {
+ dev_err(keys->dev,
+ "failed to read wakeup-source property: %d\n",
+ error);
+ return error;
+ }
+ }
+
+ for (index = 0; index < keycount; index++) {
+ keys->keys[index].regs = &mtk_pmic_regs->keys_regs[index];
+
+ keys->keys[index].irq = platform_get_irq(pdev, index);
+ if (keys->keys[index].irq < 0)
+ return keys->keys[index].irq;
+
+ keys->keys[index].keycode = keycodes[index];
+
+ if (wakeup_srcs[index])
+ keys->keys[index].wakeup = true;
+
+ error = mtk_pmic_key_setup(keys, &keys->keys[index]);
+ if (error)
+ return error;
+ }
+
+ error = input_register_device(input_dev);
+ if (error) {
+ dev_err(&pdev->dev,
+ "register input device failed (%d)\n", error);
+ return error;
+ }
+
+ mtk_pmic_keys_lp_reset_setup(keys, mtk_pmic_regs->pmic_rst_reg);
+
+ platform_set_drvdata(pdev, keys);
+
+ return 0;
+}
+
+static struct platform_driver pmic_keys_pdrv = {
+ .probe = mtk_pmic_keys_probe,
+ .driver = {
+ .name = "mtk-pmic-keys",
+ .of_match_table = of_mtk_pmic_keys_match_tbl,
+ .pm = &mtk_pmic_keys_pm_ops,
+ },
+};
+
+module_platform_driver(pmic_keys_pdrv);
+
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Chen Zhong <chen.zhong@mediatek.com>");
+MODULE_DESCRIPTION("MTK pmic-keys driver v0.1");
--
1.7.9.5
^ permalink raw reply related
* [PATCH v4 5/5] mfd: mt6397: Add PMIC keys support to MT6397 driver
From: Chen Zhong @ 2017-09-17 8:00 UTC (permalink / raw)
To: Dmitry Torokhov, Rob Herring, Lee Jones, Alexandre Belloni
Cc: Mark Rutland, Matthias Brugger, Eddie Huang, Alessandro Zummo,
Andi Shyti, Jaechul Lee, Krzysztof Kozlowski, Linus Walleij,
Chen Zhong, linux-input, devicetree, linux-arm-kernel,
linux-mediatek, linux-kernel, linux-rtc
In-Reply-To: <1505635252-27716-1-git-send-email-chen.zhong@mediatek.com>
This patch adds compatible strings and interrupts for pmic keys
which serves as child device of MFD.
Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Chen Zhong <chen.zhong@mediatek.com>
---
drivers/mfd/mt6397-core.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/mfd/mt6397-core.c b/drivers/mfd/mt6397-core.c
index 6546d7f..77b64bd 100644
--- a/drivers/mfd/mt6397-core.c
+++ b/drivers/mfd/mt6397-core.c
@@ -43,6 +43,16 @@
},
};
+static const struct resource mt6323_keys_resources[] = {
+ DEFINE_RES_IRQ(MT6323_IRQ_STATUS_PWRKEY),
+ DEFINE_RES_IRQ(MT6323_IRQ_STATUS_FCHRKEY),
+};
+
+static const struct resource mt6397_keys_resources[] = {
+ DEFINE_RES_IRQ(MT6397_IRQ_PWRKEY),
+ DEFINE_RES_IRQ(MT6397_IRQ_HOMEKEY),
+};
+
static const struct mfd_cell mt6323_devs[] = {
{
.name = "mt6323-regulator",
@@ -50,6 +60,11 @@
}, {
.name = "mt6323-led",
.of_compatible = "mediatek,mt6323-led"
+ }, {
+ .name = "mtk-pmic-keys",
+ .num_resources = ARRAY_SIZE(mt6323_keys_resources),
+ .resources = mt6323_keys_resources,
+ .of_compatible = "mediatek,mt6323-keys"
},
};
@@ -71,7 +86,12 @@
}, {
.name = "mt6397-pinctrl",
.of_compatible = "mediatek,mt6397-pinctrl",
- },
+ }, {
+ .name = "mtk-pmic-keys",
+ .num_resources = ARRAY_SIZE(mt6397_keys_resources),
+ .resources = mt6397_keys_resources,
+ .of_compatible = "mediatek,mt6397-keys"
+ }
};
static void mt6397_irq_lock(struct irq_data *data)
--
1.7.9.5
^ permalink raw reply related
* [PATCH v4 0/5] Add MediaTek PMIC keys support
From: Chen Zhong @ 2017-09-17 8:00 UTC (permalink / raw)
To: Dmitry Torokhov, Rob Herring, Lee Jones, Alexandre Belloni
Cc: Mark Rutland, Matthias Brugger, Eddie Huang, Alessandro Zummo,
Andi Shyti, Jaechul Lee, Krzysztof Kozlowski, Linus Walleij,
Chen Zhong, linux-input, devicetree, linux-arm-kernel,
linux-mediatek, linux-kernel, linux-rtc
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 (5):
mfd: mt6397: create irq mappings in mfd core driver
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
.../devicetree/bindings/input/mtk-pmic-keys.txt | 41 +++
Documentation/devicetree/bindings/mfd/mt6397.txt | 6 +
drivers/input/keyboard/Kconfig | 9 +
drivers/input/keyboard/Makefile | 1 +
drivers/input/keyboard/mtk-pmic-keys.c | 354 ++++++++++++++++++++
drivers/mfd/mt6397-core.c | 26 +-
drivers/rtc/rtc-mt6397.c | 7 +-
7 files changed, 437 insertions(+), 7 deletions(-)
create mode 100644 Documentation/devicetree/bindings/input/mtk-pmic-keys.txt
create mode 100644 drivers/input/keyboard/mtk-pmic-keys.c
--
1.7.9.5
^ permalink raw reply
* [PATCH v4 2/5] dt-bindings: input: Add document bindings for mtk-pmic-keys
From: Chen Zhong @ 2017-09-17 8:00 UTC (permalink / raw)
To: Dmitry Torokhov, Rob Herring, Lee Jones, Alexandre Belloni
Cc: Mark Rutland, Matthias Brugger, Eddie Huang, Alessandro Zummo,
Andi Shyti, Jaechul Lee, Krzysztof Kozlowski, Linus Walleij,
Chen Zhong, linux-input, devicetree, linux-arm-kernel,
linux-mediatek, linux-kernel, linux-rtc
In-Reply-To: <1505635252-27716-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 | 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.
+- wakeup-source: PMIC keys can be used as wakeup sources.
+- 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.
+
+Example:
+
+ pmic: mt6397 {
+ compatible = "mediatek,mt6397";
+
+ ...
+
+ mt6397keys: mt6397keys {
+ compatible = "mediatek,mt6397-keys";
+ linux,keycodes = <116>, <114>;
+ mediatek,wakeup-keys = <1>, <0>;
+ wakeup-source;
+ mediatek,long-press-mode = <1>;
+ debounce-interval = <0>;
+ };
+ };
--
1.7.9.5
^ permalink raw reply related
* [PATCH v4 1/5] mfd: mt6397: create irq mappings in mfd core driver
From: Chen Zhong @ 2017-09-17 8:00 UTC (permalink / raw)
To: Dmitry Torokhov, Rob Herring, Lee Jones, Alexandre Belloni
Cc: Mark Rutland, Matthias Brugger, Eddie Huang, Alessandro Zummo,
Andi Shyti, Jaechul Lee, Krzysztof Kozlowski, Linus Walleij,
Chen Zhong, linux-input, devicetree, linux-arm-kernel,
linux-mediatek, linux-kernel, linux-rtc
In-Reply-To: <1505635252-27716-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 v4 3/5] dt-bindings: mfd: Add bindings for the keys as subnode of PMIC
From: Chen Zhong @ 2017-09-17 8:00 UTC (permalink / raw)
To: Dmitry Torokhov, Rob Herring, Lee Jones, Alexandre Belloni
Cc: Mark Rutland, Matthias Brugger, Eddie Huang, Alessandro Zummo,
Andi Shyti, Jaechul Lee, Krzysztof Kozlowski, Linus Walleij,
Chen Zhong, linux-input, devicetree, linux-arm-kernel,
linux-mediatek, linux-kernel, linux-rtc
In-Reply-To: <1505635252-27716-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
* Re: [rtc-linux] [PATCH] drivers/rtc/rtc-pcf85263.c: add support for devicetree
From: Alexandre Belloni @ 2017-09-15 23:21 UTC (permalink / raw)
To: ying.zhang22455; +Cc: rtc-linux, jiafei.pan
In-Reply-To: <20170906054403.18567-1-ying.zhang22455@nxp.com>
Hi,
This email was not send to the correct mailing list.
On 06/09/2017 at 13:44:03 +0800, ying.zhang22455@nxp.com wrote:
> From: Zhang Ying-22455 <ying.zhang22455@nxp.com>
>
> Add compatible string "nxp,rtc-pcf85263"
It doesn't add the compatible string anywhere.
> Document the binding
>
> Signed-off-by: Zhang Ying-22455 <ying.zhang22455@nxp.com>
> ---
> Documentation/devicetree/bindings/rtc/nxp,rtc-85263.txt | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/rtc/nxp,rtc-85263.txt
>
> diff --git a/Documentation/devicetree/bindings/rtc/nxp,rtc-85263.txt b/Documentation/devicetree/bindings/rtc/nxp,rtc-85263.txt
> new file mode 100644
> index 000000000000..d2ffd3626f5c
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/rtc/nxp,rtc-85263.txt
> @@ -0,0 +1,15 @@
> +NXP PCF85263 SPI Real Time Clock
> +
> +Required properties:
> +- compatible: should be: "nxp,rtc-pcf85263"
The proper compatible string would be "nxp,pcf85263"
Also, please have a look at
http://patchwork.ozlabs.org/patch/658956/
http://patchwork.ozlabs.org/patch/658957/
Martin never replied but you can probably push them again.
--
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: Anatolij Gustschin @ 2017-09-15 7:13 UTC (permalink / raw)
To: Alexandre Belloni
Cc: linux-rtc, linux-kernel, linux-arm-kernel, Nicolas Ferre,
Michael Ellerman, linuxppc-dev, Rob Herring, devicetree
In-Reply-To: <20170915020004.24272-3-alexandre.belloni@free-electrons.com>
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>
^ permalink raw reply
* Re: [PATCH] dt-bindings: RTC: add stericsson,coh901331 bindings
From: Linus Walleij @ 2017-09-15 7:13 UTC (permalink / raw)
To: Alexandre Belloni
Cc: linux-rtc, linux-kernel@vger.kernel.org, Rob Herring,
devicetree@vger.kernel.org
In-Reply-To: <20170915001952.13170-1-alexandre.belloni@free-electrons.com>
On Fri, Sep 15, 2017 at 2:19 AM, Alexandre Belloni
<alexandre.belloni@free-electrons.com> wrote:
> Add device tree bindings for the ST-Ericsson COH 901 331 Real Time Clock
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Oh this was merged so far back in the day that we were even lax
about adding bindings properly. Too bad, sorry about it.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Linus Walleij
^ permalink raw reply
* Re: [PATCH 2/3] ARM: dts: at91: usb_a9g20: fix rtc node
From: Nicolas Ferre @ 2017-09-15 7:08 UTC (permalink / raw)
To: Alexandre Belloni, linux-rtc
Cc: linux-kernel, linux-arm-kernel, Michael Ellerman,
Anatolij Gustschin, linuxppc-dev, Rob Herring, devicetree
In-Reply-To: <20170915020004.24272-2-alexandre.belloni@free-electrons.com>
On 15/09/2017 at 04:00, Alexandre Belloni wrote:
> The rv3029 compatible is missing its vendor string, add it.
> Also fix the node name to be a proper generic name.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
> ---
> arch/arm/boot/dts/usb_a9g20_common.dtsi | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/boot/dts/usb_a9g20_common.dtsi b/arch/arm/boot/dts/usb_a9g20_common.dtsi
> index 088c2c3685ab..81c3fe0465d9 100644
> --- a/arch/arm/boot/dts/usb_a9g20_common.dtsi
> +++ b/arch/arm/boot/dts/usb_a9g20_common.dtsi
> @@ -20,8 +20,8 @@
> };
>
> i2c-gpio-0 {
> - rv3029c2@56 {
> - compatible = "rv3029c2";
> + rtc@56 {
> + compatible = "microcrystal,rv3029";
> reg = <0x56>;
> };
> };
>
--
Nicolas Ferre
^ permalink raw reply
* [PATCH 3/3] powerpc/5200: dts: digsy_mtc.dts: fix rv3029 compatible
From: Alexandre Belloni @ 2017-09-15 2:00 UTC (permalink / raw)
To: linux-rtc
Cc: linux-kernel, linux-arm-kernel, Nicolas Ferre, Michael Ellerman,
Anatolij Gustschin, linuxppc-dev, Rob Herring, devicetree,
Alexandre Belloni
In-Reply-To: <20170915020004.24272-1-alexandre.belloni@free-electrons.com>
The proper compatible for rv3029 is microcrystal,rv3029.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
arch/powerpc/boot/dts/digsy_mtc.dts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/boot/dts/digsy_mtc.dts b/arch/powerpc/boot/dts/digsy_mtc.dts
index c280e75c86bf..c3922fc03e0b 100644
--- a/arch/powerpc/boot/dts/digsy_mtc.dts
+++ b/arch/powerpc/boot/dts/digsy_mtc.dts
@@ -78,7 +78,7 @@
};
rtc@56 {
- compatible = "mc,rv3029c2";
+ compatible = "microcrystal,rv3029";
reg = <0x56>;
};
--
2.14.1
^ permalink raw reply related
* [PATCH 2/3] ARM: dts: at91: usb_a9g20: fix rtc node
From: Alexandre Belloni @ 2017-09-15 2:00 UTC (permalink / raw)
To: linux-rtc
Cc: linux-kernel, linux-arm-kernel, Nicolas Ferre, Michael Ellerman,
Anatolij Gustschin, linuxppc-dev, Rob Herring, devicetree,
Alexandre Belloni
In-Reply-To: <20170915020004.24272-1-alexandre.belloni@free-electrons.com>
The rv3029 compatible is missing its vendor string, add it.
Also fix the node name to be a proper generic name.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
arch/arm/boot/dts/usb_a9g20_common.dtsi | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm/boot/dts/usb_a9g20_common.dtsi b/arch/arm/boot/dts/usb_a9g20_common.dtsi
index 088c2c3685ab..81c3fe0465d9 100644
--- a/arch/arm/boot/dts/usb_a9g20_common.dtsi
+++ b/arch/arm/boot/dts/usb_a9g20_common.dtsi
@@ -20,8 +20,8 @@
};
i2c-gpio-0 {
- rv3029c2@56 {
- compatible = "rv3029c2";
+ rtc@56 {
+ compatible = "microcrystal,rv3029";
reg = <0x56>;
};
};
--
2.14.1
^ permalink raw reply related
* [PATCH 1/3] RTC: rv3029: fix vendor string
From: Alexandre Belloni @ 2017-09-15 2:00 UTC (permalink / raw)
To: linux-rtc
Cc: linux-kernel, linux-arm-kernel, Nicolas Ferre, Michael Ellerman,
Anatolij Gustschin, linuxppc-dev, Rob Herring, devicetree,
Alexandre Belloni
The vendor string for Microcrystal is microcrystal.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
Documentation/devicetree/bindings/trivial-devices.txt | 2 +-
drivers/rtc/rtc-rv3029c2.c | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/trivial-devices.txt b/Documentation/devicetree/bindings/trivial-devices.txt
index af284fbd4d23..aae37352c574 100644
--- a/Documentation/devicetree/bindings/trivial-devices.txt
+++ b/Documentation/devicetree/bindings/trivial-devices.txt
@@ -72,7 +72,6 @@ isil,isl29030 Intersil ISL29030 Ambient Light and Proximity Sensor
maxim,ds1050 5 Bit Programmable, Pulse-Width Modulator
maxim,max1237 Low-Power, 4-/12-Channel, 2-Wire Serial, 12-Bit ADCs
maxim,max6625 9-Bit/12-Bit Temperature Sensors with I²C-Compatible Serial Interface
-mc,rv3029c2 Real Time Clock Module with I2C-Bus
mcube,mc3230 mCube 3-axis 8-bit digital accelerometer
memsic,mxc6225 MEMSIC 2-axis 8-bit digital accelerometer
microchip,mcp4531-502 Microchip 7-bit Single I2C Digital Potentiometer (5k)
@@ -141,6 +140,7 @@ microchip,mcp4662-503 Microchip 8-bit Dual I2C Digital Potentiometer with NV Mem
microchip,mcp4662-104 Microchip 8-bit Dual I2C Digital Potentiometer with NV Memory (100k)
microchip,tc654 PWM Fan Speed Controller With Fan Fault Detection
microchip,tc655 PWM Fan Speed Controller With Fan Fault Detection
+microcrystal,rv3029 Real Time Clock Module with I2C-Bus
miramems,da226 MiraMEMS DA226 2-axis 14-bit digital accelerometer
miramems,da280 MiraMEMS DA280 3-axis 14-bit digital accelerometer
miramems,da311 MiraMEMS DA311 3-axis 12-bit digital accelerometer
diff --git a/drivers/rtc/rtc-rv3029c2.c b/drivers/rtc/rtc-rv3029c2.c
index aa09771de04f..cfe3aece51d1 100644
--- a/drivers/rtc/rtc-rv3029c2.c
+++ b/drivers/rtc/rtc-rv3029c2.c
@@ -876,6 +876,8 @@ static const struct i2c_device_id rv3029_id[] = {
MODULE_DEVICE_TABLE(i2c, rv3029_id);
static const struct of_device_id rv3029_of_match[] = {
+ { .compatible = "microcrystal,rv3029" },
+ /* Backward compatibility only, do not use compatibles below: */
{ .compatible = "rv3029" },
{ .compatible = "rv3029c2" },
{ .compatible = "mc,rv3029c2" },
--
2.14.1
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox