2019-08-12 12:25:11

by Frank Wunderlich

[permalink] [raw]
Subject: [PATCH v5 00/10] implement poweroff for mt6323 / bpi-r2

mainline-driver does not support mt6323

this series makes some cleanup to mt6397-rtc-driver, adds mt6323 and
implement power-controller on it.

tested on bananapi-r2

Original Patch from Josef Friedl

changes since v4:
- relative path in part 1+2
- drop change of copyright-year in part 5
changes since v3:
- moved SOB in 2/10 and 9/10
- moved part 5 to 6 to be near driver-change
- changehistory of patches below ---

changes since v2:
- Splitted some parts and rebased on 5.3-rc2:

v2.1 dt-bindings: add powercontroller – try to make better subject
v2.2 separate rtc-mt6397.txt (suggested by Alexandre Belloni)
add missing commit-message (suggested by Matthias Brugger)
v2.3 fix alloc after IRQ (suggested by Alexandre Belloni)
new compatible (splitting suggested by Alexandre Belloni)
needed due to different rtc-base/size see #7
v2.4 simplifications (Define-res-macros)
add mt6323 rtc+pwrc
v2.5 add poweroff-driver (no change)
v2.6 MAINTAINERS (no change)
v2.7 DTS-Changes (no change)


Josef Friedl (10):
dt-bindings: add powercontroller
dt-bindings: add missing mt6397 rtc
rtc: mt6397: move some common definitions into rtc.h
rtc: mt6397: improvements of rtc driver
mfd: mt6323: some improvements of mt6397-core
rtc: mt6397: add compatible for mt6323
mfd: mt6323: add mt6323 rtc+pwrc
power: reset: add driver for mt6323 poweroff
MAINTAINERS: add Mediatek shutdown drivers
arm: dts: mt6323: add keys, power-controller, rtc and codec

.../devicetree/bindings/mfd/mt6397.txt | 20 +++-
.../bindings/power/reset/mt6323-poweroff.txt | 20 ++++
.../devicetree/bindings/rtc/rtc-mt6397.txt | 29 +++++
MAINTAINERS | 7 ++
arch/arm/boot/dts/mt6323.dtsi | 27 +++++
drivers/mfd/mt6397-core.c | 38 +++++--
drivers/power/reset/Kconfig | 10 ++
drivers/power/reset/Makefile | 1 +
drivers/power/reset/mt6323-poweroff.c | 97 ++++++++++++++++
drivers/rtc/rtc-mt6397.c | 107 ++++--------------
include/linux/mfd/mt6397/core.h | 2 +
include/linux/mfd/mt6397/rtc.h | 71 ++++++++++++
12 files changed, 327 insertions(+), 102 deletions(-)
create mode 100644 Documentation/devicetree/bindings/power/reset/mt6323-poweroff.txt
create mode 100644 Documentation/devicetree/bindings/rtc/rtc-mt6397.txt
create mode 100644 drivers/power/reset/mt6323-poweroff.c
create mode 100644 include/linux/mfd/mt6397/rtc.h

--
2.17.1


2019-08-12 12:25:20

by Frank Wunderlich

[permalink] [raw]
Subject: [PATCH v5 07/10] mfd: mt6323: add mt6323 rtc+pwrc

From: Josef Friedl <[email protected]>

add entry for rtc and power-controller to mt6323

Signed-off-by: Josef Friedl <[email protected]>
Signed-off-by: Frank Wunderlich <[email protected]>
Acked-for-MFD-by: Lee Jones <[email protected]>
---
changes since v4: none
changes since v3: none
changes since v2: only splitting, second part of v2 part 4
---
drivers/mfd/mt6397-core.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)

diff --git a/drivers/mfd/mt6397-core.c b/drivers/mfd/mt6397-core.c
index c9a81087fa55..5916978a8feb 100644
--- a/drivers/mfd/mt6397-core.c
+++ b/drivers/mfd/mt6397-core.c
@@ -16,13 +16,24 @@
#include <linux/mfd/mt6397/registers.h>
#include <linux/mfd/mt6323/registers.h>

+#define MT6323_RTC_BASE 0x8000
+#define MT6323_RTC_SIZE 0x40
+
#define MT6397_RTC_BASE 0xe000
#define MT6397_RTC_SIZE 0x3e

+#define MT6323_PWRC_BASE 0x8000
+#define MT6323_PWRC_SIZE 0x40
+
#define MT6323_CID_CODE 0x23
#define MT6391_CID_CODE 0x91
#define MT6397_CID_CODE 0x97

+static const struct resource mt6323_rtc_resources[] = {
+ DEFINE_RES_MEM(MT6323_RTC_BASE, MT6323_RTC_SIZE),
+ DEFINE_RES_IRQ(MT6323_IRQ_STATUS_RTC),
+};
+
static const struct resource mt6397_rtc_resources[] = {
DEFINE_RES_MEM(MT6397_RTC_BASE, MT6397_RTC_SIZE),
DEFINE_RES_IRQ(MT6397_IRQ_RTC),
@@ -38,8 +49,17 @@ static const struct resource mt6397_keys_resources[] = {
DEFINE_RES_IRQ(MT6397_IRQ_HOMEKEY),
};

+static const struct resource mt6323_pwrc_resources[] = {
+ DEFINE_RES_MEM(MT6323_PWRC_BASE, MT6323_PWRC_SIZE),
+};
+
static const struct mfd_cell mt6323_devs[] = {
{
+ .name = "mt6323-rtc",
+ .num_resources = ARRAY_SIZE(mt6323_rtc_resources),
+ .resources = mt6323_rtc_resources,
+ .of_compatible = "mediatek,mt6323-rtc",
+ }, {
.name = "mt6323-regulator",
.of_compatible = "mediatek,mt6323-regulator"
}, {
@@ -50,6 +70,11 @@ static const struct mfd_cell mt6323_devs[] = {
.num_resources = ARRAY_SIZE(mt6323_keys_resources),
.resources = mt6323_keys_resources,
.of_compatible = "mediatek,mt6323-keys"
+ }, {
+ .name = "mt6323-pwrc",
+ .num_resources = ARRAY_SIZE(mt6323_pwrc_resources),
+ .resources = mt6323_pwrc_resources,
+ .of_compatible = "mediatek,mt6323-pwrc"
},
};

--
2.17.1

2019-08-12 12:25:29

by Frank Wunderlich

[permalink] [raw]
Subject: [PATCH v5 03/10] rtc: mt6397: move some common definitions into rtc.h

From: Josef Friedl <[email protected]>

move code to separate header-file to reuse definitions later
in poweroff-driver (drivers/power/reset/mt6323-poweroff.c)

Suggested-by: Frank Wunderlich <[email protected]>
Signed-off-by: Josef Friedl <[email protected]>
Signed-off-by: Frank Wunderlich <[email protected]>
---
changes since v4: none
changes since v3: none
changes since v2: add missing commit-message
---
drivers/rtc/rtc-mt6397.c | 55 +-------------------------
include/linux/mfd/mt6397/rtc.h | 71 ++++++++++++++++++++++++++++++++++
2 files changed, 72 insertions(+), 54 deletions(-)
create mode 100644 include/linux/mfd/mt6397/rtc.h

diff --git a/drivers/rtc/rtc-mt6397.c b/drivers/rtc/rtc-mt6397.c
index b46ed4dc7015..c08ee5edf865 100644
--- a/drivers/rtc/rtc-mt6397.c
+++ b/drivers/rtc/rtc-mt6397.c
@@ -9,60 +9,7 @@
#include <linux/module.h>
#include <linux/regmap.h>
#include <linux/rtc.h>
-#include <linux/irqdomain.h>
-#include <linux/platform_device.h>
-#include <linux/of_address.h>
-#include <linux/of_irq.h>
-#include <linux/io.h>
-#include <linux/mfd/mt6397/core.h>
-
-#define RTC_BBPU 0x0000
-#define RTC_BBPU_CBUSY BIT(6)
-
-#define RTC_WRTGR 0x003c
-
-#define RTC_IRQ_STA 0x0002
-#define RTC_IRQ_STA_AL BIT(0)
-#define RTC_IRQ_STA_LP BIT(3)
-
-#define RTC_IRQ_EN 0x0004
-#define RTC_IRQ_EN_AL BIT(0)
-#define RTC_IRQ_EN_ONESHOT BIT(2)
-#define RTC_IRQ_EN_LP BIT(3)
-#define RTC_IRQ_EN_ONESHOT_AL (RTC_IRQ_EN_ONESHOT | RTC_IRQ_EN_AL)
-
-#define RTC_AL_MASK 0x0008
-#define RTC_AL_MASK_DOW BIT(4)
-
-#define RTC_TC_SEC 0x000a
-/* Min, Hour, Dom... register offset to RTC_TC_SEC */
-#define RTC_OFFSET_SEC 0
-#define RTC_OFFSET_MIN 1
-#define RTC_OFFSET_HOUR 2
-#define RTC_OFFSET_DOM 3
-#define RTC_OFFSET_DOW 4
-#define RTC_OFFSET_MTH 5
-#define RTC_OFFSET_YEAR 6
-#define RTC_OFFSET_COUNT 7
-
-#define RTC_AL_SEC 0x0018
-
-#define RTC_PDN2 0x002e
-#define RTC_PDN2_PWRON_ALARM BIT(4)
-
-#define RTC_MIN_YEAR 1968
-#define RTC_BASE_YEAR 1900
-#define RTC_NUM_YEARS 128
-#define RTC_MIN_YEAR_OFFSET (RTC_MIN_YEAR - RTC_BASE_YEAR)
-
-struct mt6397_rtc {
- struct device *dev;
- struct rtc_device *rtc_dev;
- struct mutex lock;
- struct regmap *regmap;
- int irq;
- u32 addr_base;
-};
+#include <linux/mfd/mt6397/rtc.h>

static int mtk_rtc_write_trigger(struct mt6397_rtc *rtc)
{
diff --git a/include/linux/mfd/mt6397/rtc.h b/include/linux/mfd/mt6397/rtc.h
new file mode 100644
index 000000000000..b702c29e8c74
--- /dev/null
+++ b/include/linux/mfd/mt6397/rtc.h
@@ -0,0 +1,71 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2014-2018 MediaTek Inc.
+ *
+ * Author: Tianping.Fang <[email protected]>
+ * Sean Wang <[email protected]>
+ */
+
+#ifndef _LINUX_MFD_MT6397_RTC_H_
+#define _LINUX_MFD_MT6397_RTC_H_
+
+#include <linux/jiffies.h>
+#include <linux/mutex.h>
+#include <linux/regmap.h>
+#include <linux/rtc.h>
+
+#define RTC_BBPU 0x0000
+#define RTC_BBPU_CBUSY BIT(6)
+#define RTC_BBPU_KEY (0x43 << 8)
+
+#define RTC_WRTGR 0x003c
+
+#define RTC_IRQ_STA 0x0002
+#define RTC_IRQ_STA_AL BIT(0)
+#define RTC_IRQ_STA_LP BIT(3)
+
+#define RTC_IRQ_EN 0x0004
+#define RTC_IRQ_EN_AL BIT(0)
+#define RTC_IRQ_EN_ONESHOT BIT(2)
+#define RTC_IRQ_EN_LP BIT(3)
+#define RTC_IRQ_EN_ONESHOT_AL (RTC_IRQ_EN_ONESHOT | RTC_IRQ_EN_AL)
+
+#define RTC_AL_MASK 0x0008
+#define RTC_AL_MASK_DOW BIT(4)
+
+#define RTC_TC_SEC 0x000a
+/* Min, Hour, Dom... register offset to RTC_TC_SEC */
+#define RTC_OFFSET_SEC 0
+#define RTC_OFFSET_MIN 1
+#define RTC_OFFSET_HOUR 2
+#define RTC_OFFSET_DOM 3
+#define RTC_OFFSET_DOW 4
+#define RTC_OFFSET_MTH 5
+#define RTC_OFFSET_YEAR 6
+#define RTC_OFFSET_COUNT 7
+
+#define RTC_AL_SEC 0x0018
+
+#define RTC_PDN2 0x002e
+#define RTC_PDN2_PWRON_ALARM BIT(4)
+
+#define RTC_MIN_YEAR 1968
+#define RTC_BASE_YEAR 1900
+#define RTC_NUM_YEARS 128
+#define RTC_MIN_YEAR_OFFSET (RTC_MIN_YEAR - RTC_BASE_YEAR)
+
+#define MTK_RTC_POLL_DELAY_US 10
+#define MTK_RTC_POLL_TIMEOUT (jiffies_to_usecs(HZ))
+
+struct mt6397_rtc {
+ struct device *dev;
+ struct rtc_device *rtc_dev;
+
+ /* Protect register access from multiple tasks */
+ struct mutex lock;
+ struct regmap *regmap;
+ int irq;
+ u32 addr_base;
+};
+
+#endif /* _LINUX_MFD_MT6397_RTC_H_ */
--
2.17.1

2019-08-12 12:25:59

by Frank Wunderlich

[permalink] [raw]
Subject: [PATCH v5 09/10] MAINTAINERS: add Mediatek shutdown drivers

From: Josef Friedl <[email protected]>

add Section in MAINTAINERS file for poweroff driver

Signed-off-by: Josef Friedl <[email protected]>
Signed-off-by: Frank Wunderlich <[email protected]>
---
changes since v4: none
changes since v3: moved SOB
changes since v2: none (=v2 part 6)
---
MAINTAINERS | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 6426db5198f0..4172a3177633 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10128,6 +10128,13 @@ S: Maintained
F: drivers/net/dsa/mt7530.*
F: net/dsa/tag_mtk.c

+MEDIATEK BOARD LEVEL SHUTDOWN DRIVERS
+M: Sean Wang <[email protected]>
+L: [email protected]
+S: Maintained
+F: Documentation/devicetree/bindings/power/reset/mt6323-poweroff.txt
+F: drivers/power/reset/mt6323-poweroff.c
+
MEDIATEK JPEG DRIVER
M: Rick Chang <[email protected]>
M: Bin Liu <[email protected]>
--
2.17.1

2019-08-12 12:26:05

by Frank Wunderlich

[permalink] [raw]
Subject: [PATCH v5 05/10] mfd: mt6323: some improvements of mt6397-core

From: Josef Friedl <[email protected]>

simplyfications (resource definitions my DEFINE_RES_* macros)

Signed-off-by: Josef Friedl <[email protected]>
Signed-off-by: Frank Wunderlich <[email protected]>
Acked-for-MFD-by: Lee Jones <[email protected]>
---
changes since v4: do not touch year of copyright
changes since v3: moved part 6 forward to let compatible and driver be together
changes since v2: splitted v2 part 4 into 6+7
---
drivers/mfd/mt6397-core.c | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/mfd/mt6397-core.c b/drivers/mfd/mt6397-core.c
index 337bcccdb914..c9a81087fa55 100644
--- a/drivers/mfd/mt6397-core.c
+++ b/drivers/mfd/mt6397-core.c
@@ -5,6 +5,7 @@
*/

#include <linux/interrupt.h>
+#include <linux/ioport.h>
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/of_irq.h>
@@ -23,16 +24,8 @@
#define MT6397_CID_CODE 0x97

static const struct resource mt6397_rtc_resources[] = {
- {
- .start = MT6397_RTC_BASE,
- .end = MT6397_RTC_BASE + MT6397_RTC_SIZE,
- .flags = IORESOURCE_MEM,
- },
- {
- .start = MT6397_IRQ_RTC,
- .end = MT6397_IRQ_RTC,
- .flags = IORESOURCE_IRQ,
- },
+ DEFINE_RES_MEM(MT6397_RTC_BASE, MT6397_RTC_SIZE),
+ DEFINE_RES_IRQ(MT6397_IRQ_RTC),
};

static const struct resource mt6323_keys_resources[] = {
--
2.17.1

2019-08-12 12:26:14

by Frank Wunderlich

[permalink] [raw]
Subject: [PATCH v5 01/10] dt-bindings: add powercontroller

From: Josef Friedl <[email protected]>

add mt6323-rtc and mt6323-pwrc to mt6397 mfd DT bindings
an example is shown in mt6323-poweroff.txt

Suggested-by: Frank Wunderlich <[email protected]>
Signed-off-by: Josef Friedl <[email protected]>
Signed-off-by: Frank Wunderlich <[email protected]>
Acked-for-MFD-by: Lee Jones <[email protected]>
---
changes since v4: use relative path
changes since v3: none
changes since v2: separated rtc-mt6397.txt to part 2
---
.../devicetree/bindings/mfd/mt6397.txt | 20 +++++++++++++------
.../bindings/power/reset/mt6323-poweroff.txt | 20 +++++++++++++++++++
2 files changed, 34 insertions(+), 6 deletions(-)
create mode 100644 Documentation/devicetree/bindings/power/reset/mt6323-poweroff.txt

diff --git a/Documentation/devicetree/bindings/mfd/mt6397.txt b/Documentation/devicetree/bindings/mfd/mt6397.txt
index 0ebd08af777d..063f5fe1cace 100644
--- a/Documentation/devicetree/bindings/mfd/mt6397.txt
+++ b/Documentation/devicetree/bindings/mfd/mt6397.txt
@@ -8,11 +8,12 @@ MT6397/MT6323 is a multifunction device with the following sub modules:
- Clock
- LED
- Keys
+- Power controller

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.
See the following for pwarp node definitions:
-Documentation/devicetree/bindings/soc/mediatek/pwrap.txt
+../../bindings/soc/mediatek/pwrap.txt

This document describes the binding for MFD device and its sub module.

@@ -22,14 +23,16 @@ compatible: "mediatek,mt6397" or "mediatek,mt6323"
Optional subnodes:

- rtc
- Required properties:
+ Required properties: Should be one of follows
+ - compatible: "mediatek,mt6323-rtc"
- compatible: "mediatek,mt6397-rtc"
+ For details, see ../../bindings/rtc/rtc-mt6397.txt
- regulators
Required properties:
- compatible: "mediatek,mt6397-regulator"
- see Documentation/devicetree/bindings/regulator/mt6397-regulator.txt
+ see ../../bindings/regulator/mt6397-regulator.txt
- compatible: "mediatek,mt6323-regulator"
- see Documentation/devicetree/bindings/regulator/mt6323-regulator.txt
+ see ../../bindings/regulator/mt6323-regulator.txt
- codec
Required properties:
- compatible: "mediatek,mt6397-codec"
@@ -39,12 +42,17 @@ Optional subnodes:
- led
Required properties:
- compatible: "mediatek,mt6323-led"
- see Documentation/devicetree/bindings/leds/leds-mt6323.txt
+ see ../../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
+ see ../../bindings/input/mtk-pmic-keys.txt
+
+- power-controller
+ Required properties:
+ - compatible: "mediatek,mt6323-pwrc"
+ For details, see ../../bindings/power/reset/mt6323-poweroff.txt

Example:
pwrap: pwrap@1000f000 {
diff --git a/Documentation/devicetree/bindings/power/reset/mt6323-poweroff.txt b/Documentation/devicetree/bindings/power/reset/mt6323-poweroff.txt
new file mode 100644
index 000000000000..933f0c48e887
--- /dev/null
+++ b/Documentation/devicetree/bindings/power/reset/mt6323-poweroff.txt
@@ -0,0 +1,20 @@
+Device Tree Bindings for Power Controller on MediaTek PMIC
+
+The power controller which could be found on PMIC is responsible for externally
+powering off or on the remote MediaTek SoC through the circuit BBPU.
+
+Required properties:
+- compatible: Should be one of follows
+ "mediatek,mt6323-pwrc": for MT6323 PMIC
+
+Example:
+
+ pmic {
+ compatible = "mediatek,mt6323";
+
+ ...
+
+ power-controller {
+ compatible = "mediatek,mt6323-pwrc";
+ };
+ }
--
2.17.1

2019-08-12 12:26:18

by Frank Wunderlich

[permalink] [raw]
Subject: [PATCH v5 04/10] rtc: mt6397: improvements of rtc driver

From: Josef Friedl <[email protected]>

- use regmap_read_poll_timeout to drop while-loop
- use devm-api to drop remove-callback

Suggested-by: Alexandre Belloni <[email protected]>
Signed-off-by: Josef Friedl <[email protected]>
Signed-off-by: Frank Wunderlich <[email protected]>
---
changes since v4: none
changes since v3: none
changes since v2:
- fix allocation after irq-request
- compatible for mt6323 in separate commit => part 5
---
drivers/rtc/rtc-mt6397.c | 51 +++++++++++++++-------------------------
1 file changed, 19 insertions(+), 32 deletions(-)

diff --git a/drivers/rtc/rtc-mt6397.c b/drivers/rtc/rtc-mt6397.c
index c08ee5edf865..9370b7fc9f81 100644
--- a/drivers/rtc/rtc-mt6397.c
+++ b/drivers/rtc/rtc-mt6397.c
@@ -4,16 +4,19 @@
* Author: Tianping.Fang <[email protected]>
*/

-#include <linux/delay.h>
-#include <linux/init.h>
+#include <linux/err.h>
+#include <linux/interrupt.h>
+#include <linux/mfd/mt6397/core.h>
#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/rtc.h>
#include <linux/mfd/mt6397/rtc.h>
+#include <linux/mod_devicetable.h>

static int mtk_rtc_write_trigger(struct mt6397_rtc *rtc)
{
- unsigned long timeout = jiffies + HZ;
int ret;
u32 data;

@@ -21,19 +24,13 @@ static int mtk_rtc_write_trigger(struct mt6397_rtc *rtc)
if (ret < 0)
return ret;

- while (1) {
- ret = regmap_read(rtc->regmap, rtc->addr_base + RTC_BBPU,
- &data);
- if (ret < 0)
- break;
- if (!(data & RTC_BBPU_CBUSY))
- break;
- if (time_after(jiffies, timeout)) {
- ret = -ETIMEDOUT;
- break;
- }
- cpu_relax();
- }
+ ret = regmap_read_poll_timeout(rtc->regmap,
+ rtc->addr_base + RTC_BBPU, data,
+ !(data & RTC_BBPU_CBUSY),
+ MTK_RTC_POLL_DELAY_US,
+ MTK_RTC_POLL_TIMEOUT);
+ if (ret < 0)
+ dev_err(rtc->dev, "failed to write WRTGE: %d\n", ret);

return ret;
}
@@ -266,19 +263,19 @@ static int mtk_rtc_probe(struct platform_device *pdev)
return rtc->irq;

rtc->regmap = mt6397_chip->regmap;
- rtc->dev = &pdev->dev;
mutex_init(&rtc->lock);

platform_set_drvdata(pdev, rtc);

- rtc->rtc_dev = devm_rtc_allocate_device(rtc->dev);
+ rtc->rtc_dev = devm_rtc_allocate_device(&pdev->dev);
if (IS_ERR(rtc->rtc_dev))
return PTR_ERR(rtc->rtc_dev);

- ret = request_threaded_irq(rtc->irq, NULL,
- mtk_rtc_irq_handler_thread,
- IRQF_ONESHOT | IRQF_TRIGGER_HIGH,
- "mt6397-rtc", rtc);
+ ret = devm_request_threaded_irq(&pdev->dev, rtc->irq, NULL,
+ mtk_rtc_irq_handler_thread,
+ IRQF_ONESHOT | IRQF_TRIGGER_HIGH,
+ "mt6397-rtc", rtc);
+
if (ret) {
dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
rtc->irq, ret);
@@ -302,15 +299,6 @@ static int mtk_rtc_probe(struct platform_device *pdev)
return ret;
}

-static int mtk_rtc_remove(struct platform_device *pdev)
-{
- struct mt6397_rtc *rtc = platform_get_drvdata(pdev);
-
- free_irq(rtc->irq, rtc);
-
- return 0;
-}
-
#ifdef CONFIG_PM_SLEEP
static int mt6397_rtc_suspend(struct device *dev)
{
@@ -349,7 +337,6 @@ static struct platform_driver mtk_rtc_driver = {
.pm = &mt6397_pm_ops,
},
.probe = mtk_rtc_probe,
- .remove = mtk_rtc_remove,
};

module_platform_driver(mtk_rtc_driver);
--
2.17.1

2019-08-12 12:26:36

by Frank Wunderlich

[permalink] [raw]
Subject: [PATCH v5 06/10] rtc: mt6397: add compatible for mt6323

From: Josef Friedl <[email protected]>

use mt6397 rtc driver also for mt6323 but with different
base/size see "mfd: mt6323: add mt6323 rtc+pwrc"

Signed-off-by: Josef Friedl <[email protected]>
Signed-off-by: Frank Wunderlich <[email protected]>
---
changes since v4: none
changes since v3: moved (was part 5)
changes since v2: splitted this from v2.3 suggested-by Alexandre Belloni
---
drivers/rtc/rtc-mt6397.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/rtc/rtc-mt6397.c b/drivers/rtc/rtc-mt6397.c
index 9370b7fc9f81..21cd9cc8b4c7 100644
--- a/drivers/rtc/rtc-mt6397.c
+++ b/drivers/rtc/rtc-mt6397.c
@@ -325,6 +325,7 @@ static SIMPLE_DEV_PM_OPS(mt6397_pm_ops, mt6397_rtc_suspend,
mt6397_rtc_resume);

static const struct of_device_id mt6397_rtc_of_match[] = {
+ { .compatible = "mediatek,mt6323-rtc", },
{ .compatible = "mediatek,mt6397-rtc", },
{ }
};
--
2.17.1

2019-08-12 12:26:46

by Frank Wunderlich

[permalink] [raw]
Subject: [PATCH v5 02/10] dt-bindings: add missing mt6397 rtc

From: Josef Friedl <[email protected]>

add missing devicetree-binding document for mt6397 rtc
in later patch driver is extended with mt6323 chip

Suggested-By: Alexandre Belloni <[email protected]>
Signed-off-by: Josef Friedl <[email protected]>
Signed-off-by: Frank Wunderlich <[email protected]>
---
changes since v4: use relative path
changes since v3: moved SOB
changes since v2: splitted rtc-mt6397.txt from first patch
---
.../devicetree/bindings/rtc/rtc-mt6397.txt | 29 +++++++++++++++++++
1 file changed, 29 insertions(+)
create mode 100644 Documentation/devicetree/bindings/rtc/rtc-mt6397.txt

diff --git a/Documentation/devicetree/bindings/rtc/rtc-mt6397.txt b/Documentation/devicetree/bindings/rtc/rtc-mt6397.txt
new file mode 100644
index 000000000000..4d2d8317e16b
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/rtc-mt6397.txt
@@ -0,0 +1,29 @@
+Device-Tree bindings for MediaTek PMIC based RTC
+
+MediaTek PMIC based RTC is an independent function of MediaTek PMIC that works
+as a type of multi-function device (MFD). The RTC can be configured and set up
+with PMIC wrapper bus which is a common resource shared with the other
+functions found on the same PMIC.
+
+For MediaTek PMIC MFD bindings, see:
+../../bindings/mfd/mt6397.txt
+
+For MediaTek PMIC wrapper bus bindings, see:
+../../bindings/soc/mediatek/pwrap.txt
+
+Required properties:
+- compatible: Should be one of follows
+ "mediatek,mt6323-rtc": for MT6323 PMIC
+ "mediatek,mt6397-rtc": for MT6397 PMIC
+
+Example:
+
+ pmic {
+ compatible = "mediatek,mt6323";
+
+ ...
+
+ rtc {
+ compatible = "mediatek,mt6323-rtc";
+ };
+ };
--
2.17.1

2019-08-12 12:27:01

by Frank Wunderlich

[permalink] [raw]
Subject: [PATCH v5 10/10] arm: dts: mt6323: add keys, power-controller, rtc and codec

From: Josef Friedl <[email protected]>

support poweroff and power-related keys on bpi-r2

Suggested-by: Frank Wunderlich <[email protected]>
Signed-off-by: Josef Friedl <[email protected]>
Signed-off-by: Frank Wunderlich <[email protected]>
---
changes since v4: none
changes since v3: none
changes since v2: none (=v2 part 7)
---
arch/arm/boot/dts/mt6323.dtsi | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)

diff --git a/arch/arm/boot/dts/mt6323.dtsi b/arch/arm/boot/dts/mt6323.dtsi
index ba397407c1dd..7fda40ab5fe8 100644
--- a/arch/arm/boot/dts/mt6323.dtsi
+++ b/arch/arm/boot/dts/mt6323.dtsi
@@ -238,5 +238,32 @@
regulator-enable-ramp-delay = <216>;
};
};
+
+ mt6323keys: mt6323keys {
+ compatible = "mediatek,mt6323-keys";
+ mediatek,long-press-mode = <1>;
+ power-off-time-sec = <0>;
+
+ power {
+ linux,keycodes = <116>;
+ wakeup-source;
+ };
+
+ home {
+ linux,keycodes = <114>;
+ };
+ };
+
+ codec: mt6397codec {
+ compatible = "mediatek,mt6397-codec";
+ };
+
+ power-controller {
+ compatible = "mediatek,mt6323-pwrc";
+ };
+
+ rtc {
+ compatible = "mediatek,mt6323-rtc";
+ };
};
};
--
2.17.1

2019-08-12 15:13:37

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH v5 03/10] rtc: mt6397: move some common definitions into rtc.h

On Mon, 12 Aug 2019, Frank Wunderlich wrote:

> From: Josef Friedl <[email protected]>
>
> move code to separate header-file to reuse definitions later
> in poweroff-driver (drivers/power/reset/mt6323-poweroff.c)
>
> Suggested-by: Frank Wunderlich <[email protected]>
> Signed-off-by: Josef Friedl <[email protected]>
> Signed-off-by: Frank Wunderlich <[email protected]>
> ---
> changes since v4: none
> changes since v3: none
> changes since v2: add missing commit-message
> ---
> drivers/rtc/rtc-mt6397.c | 55 +-------------------------
> include/linux/mfd/mt6397/rtc.h | 71 ++++++++++++++++++++++++++++++++++

include/linux/rtc/mt6397.h?

> 2 files changed, 72 insertions(+), 54 deletions(-)
> create mode 100644 include/linux/mfd/mt6397/rtc.h

--
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

2019-08-12 15:16:16

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH v5 01/10] dt-bindings: add powercontroller

On Mon, 12 Aug 2019, Frank Wunderlich wrote:

> From: Josef Friedl <[email protected]>
>
> add mt6323-rtc and mt6323-pwrc to mt6397 mfd DT bindings
> an example is shown in mt6323-poweroff.txt
>
> Suggested-by: Frank Wunderlich <[email protected]>
> Signed-off-by: Josef Friedl <[email protected]>
> Signed-off-by: Frank Wunderlich <[email protected]>
> Acked-for-MFD-by: Lee Jones <[email protected]>
> ---
> changes since v4: use relative path
> changes since v3: none
> changes since v2: separated rtc-mt6397.txt to part 2
> ---
> .../devicetree/bindings/mfd/mt6397.txt | 20 +++++++++++++------
> .../bindings/power/reset/mt6323-poweroff.txt | 20 +++++++++++++++++++
> 2 files changed, 34 insertions(+), 6 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/power/reset/mt6323-poweroff.txt
>
> diff --git a/Documentation/devicetree/bindings/mfd/mt6397.txt b/Documentation/devicetree/bindings/mfd/mt6397.txt
> index 0ebd08af777d..063f5fe1cace 100644
> --- a/Documentation/devicetree/bindings/mfd/mt6397.txt
> +++ b/Documentation/devicetree/bindings/mfd/mt6397.txt
> @@ -8,11 +8,12 @@ MT6397/MT6323 is a multifunction device with the following sub modules:
> - Clock
> - LED
> - Keys
> +- Power controller
>
> 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.
> See the following for pwarp node definitions:
> -Documentation/devicetree/bindings/soc/mediatek/pwrap.txt
> +../../bindings/soc/mediatek/pwrap.txt
>
> This document describes the binding for MFD device and its sub module.
>
> @@ -22,14 +23,16 @@ compatible: "mediatek,mt6397" or "mediatek,mt6323"
> Optional subnodes:
>
> - rtc
> - Required properties:
> + Required properties: Should be one of follows
> + - compatible: "mediatek,mt6323-rtc"
> - compatible: "mediatek,mt6397-rtc"
> + For details, see ../../bindings/rtc/rtc-mt6397.txt

Apologies for the ambiguity. I don't think you need to go all the way
back to 'bindings'. Just one step back will do fine. ../rtc/* will be
fine here.

--
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

2019-08-12 15:41:38

by Alexandre Belloni

[permalink] [raw]
Subject: Re: [PATCH v5 03/10] rtc: mt6397: move some common definitions into rtc.h

On 12/08/2019 16:11:29+0100, Lee Jones wrote:
> On Mon, 12 Aug 2019, Frank Wunderlich wrote:
>
> > From: Josef Friedl <[email protected]>
> >
> > move code to separate header-file to reuse definitions later
> > in poweroff-driver (drivers/power/reset/mt6323-poweroff.c)
> >
> > Suggested-by: Frank Wunderlich <[email protected]>
> > Signed-off-by: Josef Friedl <[email protected]>
> > Signed-off-by: Frank Wunderlich <[email protected]>
> > ---
> > changes since v4: none
> > changes since v3: none
> > changes since v2: add missing commit-message
> > ---
> > drivers/rtc/rtc-mt6397.c | 55 +-------------------------
> > include/linux/mfd/mt6397/rtc.h | 71 ++++++++++++++++++++++++++++++++++
>
> include/linux/rtc/mt6397.h?
>

It's just a bunch of registers and bit definitions so it may as well
stay close to include/linux/mfd/mt6397/registers.h


--
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

2019-08-13 08:45:24

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH v5 03/10] rtc: mt6397: move some common definitions into rtc.h

On Mon, 12 Aug 2019, Alexandre Belloni wrote:

> On 12/08/2019 16:11:29+0100, Lee Jones wrote:
> > On Mon, 12 Aug 2019, Frank Wunderlich wrote:
> >
> > > From: Josef Friedl <[email protected]>
> > >
> > > move code to separate header-file to reuse definitions later
> > > in poweroff-driver (drivers/power/reset/mt6323-poweroff.c)
> > >
> > > Suggested-by: Frank Wunderlich <[email protected]>
> > > Signed-off-by: Josef Friedl <[email protected]>
> > > Signed-off-by: Frank Wunderlich <[email protected]>
> > > ---
> > > changes since v4: none
> > > changes since v3: none
> > > changes since v2: add missing commit-message
> > > ---
> > > drivers/rtc/rtc-mt6397.c | 55 +-------------------------
> > > include/linux/mfd/mt6397/rtc.h | 71 ++++++++++++++++++++++++++++++++++
> >
> > include/linux/rtc/mt6397.h?
> >
>
> It's just a bunch of registers and bit definitions so it may as well
> stay close to include/linux/mfd/mt6397/registers.h

Sure. It was a weak preference.

--
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

2019-08-13 16:08:14

by Rob Herring

[permalink] [raw]
Subject: Re: [PATCH v5 01/10] dt-bindings: add powercontroller

On Mon, Aug 12, 2019 at 6:24 AM Frank Wunderlich
<[email protected]> wrote:
>
> From: Josef Friedl <[email protected]>
>
> add mt6323-rtc and mt6323-pwrc to mt6397 mfd DT bindings
> an example is shown in mt6323-poweroff.txt

How does this get to v5 with such a terrible subject? At least give
some indication this is for some Mediatek chip.

The recipient list needs some work too. Don't Cc git committers that
get_maintainers.pl lists.

>
> Suggested-by: Frank Wunderlich <[email protected]>
> Signed-off-by: Josef Friedl <[email protected]>
> Signed-off-by: Frank Wunderlich <[email protected]>
> Acked-for-MFD-by: Lee Jones <[email protected]>
> ---
> changes since v4: use relative path
> changes since v3: none
> changes since v2: separated rtc-mt6397.txt to part 2
> ---
> .../devicetree/bindings/mfd/mt6397.txt | 20 +++++++++++++------
> .../bindings/power/reset/mt6323-poweroff.txt | 20 +++++++++++++++++++
> 2 files changed, 34 insertions(+), 6 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/power/reset/mt6323-poweroff.txt
>
> diff --git a/Documentation/devicetree/bindings/mfd/mt6397.txt b/Documentation/devicetree/bindings/mfd/mt6397.txt
> index 0ebd08af777d..063f5fe1cace 100644
> --- a/Documentation/devicetree/bindings/mfd/mt6397.txt
> +++ b/Documentation/devicetree/bindings/mfd/mt6397.txt
> @@ -8,11 +8,12 @@ MT6397/MT6323 is a multifunction device with the following sub modules:
> - Clock
> - LED
> - Keys
> +- Power controller
>
> 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.
> See the following for pwarp node definitions:
> -Documentation/devicetree/bindings/soc/mediatek/pwrap.txt
> +../../bindings/soc/mediatek/pwrap.txt

Unrelated change to what the subject says. Clean-ups and new things in
separate patches please.

>
> This document describes the binding for MFD device and its sub module.
>
> @@ -22,14 +23,16 @@ compatible: "mediatek,mt6397" or "mediatek,mt6323"
> Optional subnodes:
>
> - rtc
> - Required properties:
> + Required properties: Should be one of follows
> + - compatible: "mediatek,mt6323-rtc"

How is this related to 'powercontroller'?

> - compatible: "mediatek,mt6397-rtc"
> + For details, see ../../bindings/rtc/rtc-mt6397.txt
> - regulators
> Required properties:
> - compatible: "mediatek,mt6397-regulator"
> - see Documentation/devicetree/bindings/regulator/mt6397-regulator.txt
> + see ../../bindings/regulator/mt6397-regulator.txt
> - compatible: "mediatek,mt6323-regulator"
> - see Documentation/devicetree/bindings/regulator/mt6323-regulator.txt
> + see ../../bindings/regulator/mt6323-regulator.txt
> - codec
> Required properties:
> - compatible: "mediatek,mt6397-codec"
> @@ -39,12 +42,17 @@ Optional subnodes:
> - led
> Required properties:
> - compatible: "mediatek,mt6323-led"
> - see Documentation/devicetree/bindings/leds/leds-mt6323.txt
> + see ../../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
> + see ../../bindings/input/mtk-pmic-keys.txt
> +
> +- power-controller
> + Required properties:
> + - compatible: "mediatek,mt6323-pwrc"
> + For details, see ../../bindings/power/reset/mt6323-poweroff.txt
>
> Example:
> pwrap: pwrap@1000f000 {
> diff --git a/Documentation/devicetree/bindings/power/reset/mt6323-poweroff.txt b/Documentation/devicetree/bindings/power/reset/mt6323-poweroff.txt
> new file mode 100644
> index 000000000000..933f0c48e887
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/power/reset/mt6323-poweroff.txt
> @@ -0,0 +1,20 @@
> +Device Tree Bindings for Power Controller on MediaTek PMIC
> +
> +The power controller which could be found on PMIC is responsible for externally
> +powering off or on the remote MediaTek SoC through the circuit BBPU.
> +
> +Required properties:
> +- compatible: Should be one of follows
> + "mediatek,mt6323-pwrc": for MT6323 PMIC
> +
> +Example:
> +
> + pmic {
> + compatible = "mediatek,mt6323";
> +
> + ...
> +
> + power-controller {
> + compatible = "mediatek,mt6323-pwrc";
> + };
> + }
> --
> 2.17.1
>