lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250817102751.29709-4-akurz@blala.de>
Date: Sun, 17 Aug 2025 10:27:47 +0000
From: Alexander Kurz <akurz@...la.de>
To: Lee Jones <lee@...nel.org>, Rob Herring <robh@...nel.org>,
        Krzysztof Kozlowski <krzk+dt@...nel.org>,
        Conor Dooley <conor+dt@...nel.org>,
        Dmitry Torokhov <dmitry.torokhov@...il.com>,
        Dzmitry Sankouski <dsankouski@...il.com>,
        "Dr. David Alan Gilbert" <linux@...blig.org>,
        Heiko Stuebner <heiko@...ech.de>,
        Uwe Kleine-König <u.kleine-koenig@...libre.com>,
        devicetree@...r.kernel.org, linux-input@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, Alexander Kurz <akurz@...la.de>
Subject: [PATCH 3/6] Input: mc13783-pwrbutton: enable other mc13xxx PMIC

All three mc13xxx types do feature two common power buttons while mc13783
and mc13892 provide one extra button each that differs unfortunately.
The common buttons are ONOFD[12] (mc13783) and PWRON[12] (mc13892/mc34708).
ONOFD3 on mc13783 will still be supported while support for PWRON3 for
mc13892 will be left unsupported for simplicity.
Add the similarities to the header files for reference, extend the
platform_driver struct with the id table to support all three types.

Signed-off-by: Alexander Kurz <akurz@...la.de>
---
 drivers/input/misc/Kconfig             |  4 ++--
 drivers/input/misc/mc13783-pwrbutton.c | 21 ++++++++++++++++++---
 include/linux/mfd/mc13783.h            |  4 ++--
 include/linux/mfd/mc13xxx.h            |  9 +++++++++
 4 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 0fb21c99a5e3..b66e920369f2 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -276,8 +276,8 @@ config INPUT_MC13783_PWRBUTTON
 	tristate "MC13783 ON buttons"
 	depends on MFD_MC13XXX
 	help
-	  Support the ON buttons of MC13783 PMIC as an input device
-	  reporting power button status.
+	  Support the ON buttons of MC13783/MC13892/MC34708 PMIC as an input
+	  device reporting power button status.
 
 	  To compile this driver as a module, choose M here: the module
 	  will be called mc13783-pwrbutton.
diff --git a/drivers/input/misc/mc13783-pwrbutton.c b/drivers/input/misc/mc13783-pwrbutton.c
index 9fd84b8d163d..cb2f25a1a757 100644
--- a/drivers/input/misc/mc13783-pwrbutton.c
+++ b/drivers/input/misc/mc13783-pwrbutton.c
@@ -33,13 +33,14 @@
 struct mc13783_pwrb {
 	struct input_dev *pwr;
 	struct mc13xxx *mc13783;
-#define MC13783_PWRB_B1_POL_INVERT	(1 << 0)
-#define MC13783_PWRB_B2_POL_INVERT	(1 << 1)
-#define MC13783_PWRB_B3_POL_INVERT	(1 << 2)
 	int flags;
 	unsigned short keymap[3];
 };
 
+#define MC13783_PWRB_B1_POL_INVERT	(1 << 0)
+#define MC13783_PWRB_B2_POL_INVERT	(1 << 1)
+#define MC13783_PWRB_B3_POL_INVERT	(1 << 2)
+
 #define MC13783_REG_INTERRUPT_SENSE_1		5
 #define MC13783_IRQSENSE1_ONOFD1S		(1 << 3)
 #define MC13783_IRQSENSE1_ONOFD2S		(1 << 4)
@@ -108,6 +109,7 @@ static int mc13783_pwrbutton_probe(struct platform_device *pdev)
 {
 	const struct mc13xxx_buttons_platform_data *pdata;
 	struct mc13xxx *mc13783 = dev_get_drvdata(pdev->dev.parent);
+	enum mc13xxx_chip_type chip = platform_get_device_id(pdev)->driver_data;
 	struct input_dev *pwr;
 	struct mc13783_pwrb *priv;
 	int err = 0;
@@ -127,6 +129,11 @@ static int mc13783_pwrbutton_probe(struct platform_device *pdev)
 	if (!priv)
 		return -ENOMEM;
 
+	/* ONOFD3 is only supported for MC13783. */
+	if (pdata->b3on_flags & MC13783_BUTTON_ENABLE &&
+		chip != MC13XXX_CHIP_TYPE_MC13783)
+		return -ENODEV;
+
 	reg |= (pdata->b1on_flags & 0x3) << MC13783_POWER_CONTROL_2_ON1BDBNC;
 	reg |= (pdata->b2on_flags & 0x3) << MC13783_POWER_CONTROL_2_ON2BDBNC;
 	reg |= (pdata->b3on_flags & 0x3) << MC13783_POWER_CONTROL_2_ON3BDBNC;
@@ -254,7 +261,15 @@ static void mc13783_pwrbutton_remove(struct platform_device *pdev)
 	mc13xxx_unlock(priv->mc13783);
 }
 
+static const struct platform_device_id mc13xxx_pwrbutton_idtable[] = {
+	{ "mc13783-pwrbutton", MC13XXX_CHIP_TYPE_MC13783 },
+	{ "mc13892-pwrbutton", MC13XXX_CHIP_TYPE_MC13892 },
+	{ "mc34708-pwrbutton", MC13XXX_CHIP_TYPE_MC34708 },
+	{ /* sentinel */ }
+};
+
 static struct platform_driver mc13783_pwrbutton_driver = {
+	.id_table	= mc13xxx_pwrbutton_idtable,
 	.probe		= mc13783_pwrbutton_probe,
 	.remove		= mc13783_pwrbutton_remove,
 	.driver		= {
diff --git a/include/linux/mfd/mc13783.h b/include/linux/mfd/mc13783.h
index c25b1676741b..ab6db774e1fa 100644
--- a/include/linux/mfd/mc13783.h
+++ b/include/linux/mfd/mc13783.h
@@ -65,8 +65,8 @@
 #define MC13783_IRQ_UDM		23
 #define MC13783_IRQ_1HZ		MC13XXX_IRQ_1HZ
 #define MC13783_IRQ_TODA	MC13XXX_IRQ_TODA
-#define MC13783_IRQ_ONOFD1	27
-#define MC13783_IRQ_ONOFD2	28
+#define MC13783_IRQ_ONOFD1	MC13XXX_IRQ_PWRON1
+#define MC13783_IRQ_ONOFD2	MC13XXX_IRQ_PWRON2
 #define MC13783_IRQ_ONOFD3	29
 #define MC13783_IRQ_SYSRST	MC13XXX_IRQ_SYSRST
 #define MC13783_IRQ_RTCRST	MC13XXX_IRQ_RTCRST
diff --git a/include/linux/mfd/mc13xxx.h b/include/linux/mfd/mc13xxx.h
index f372926d5894..6984ea69db3e 100644
--- a/include/linux/mfd/mc13xxx.h
+++ b/include/linux/mfd/mc13xxx.h
@@ -67,6 +67,8 @@ int mc13xxx_irq_unmask(struct mc13xxx *mc13xxx, int irq);
 #define MC13XXX_IRQ_LOBATH	14
 #define MC13XXX_IRQ_1HZ		24
 #define MC13XXX_IRQ_TODA	25
+#define MC13XXX_IRQ_PWRON1	27
+#define MC13XXX_IRQ_PWRON2	28
 #define MC13XXX_IRQ_SYSRST	30
 #define MC13XXX_IRQ_RTCRST	31
 #define MC13XXX_IRQ_PC		32
@@ -78,6 +80,13 @@ int mc13xxx_irq_unmask(struct mc13xxx *mc13xxx, int irq);
 
 struct regulator_init_data;
 
+enum mc13xxx_chip_type {
+	MC13XXX_CHIP_TYPE_MC13783,
+	MC13XXX_CHIP_TYPE_MC13892,
+	MC13XXX_CHIP_TYPE_MC34708,
+	MC13XXX_CHIP_TYPE_AMOUNT
+};
+
 struct mc13xxx_regulator_init_data {
 	int id;
 	struct regulator_init_data *init_data;
-- 
2.39.5


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ