mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Feng <steven@joint-cloud.com>
To: dmitry.torokhov@gmail.com
Cc: wens@kernel.org, linux-input@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Steven Feng <steven@joint-cloud.com>
Subject: [PATCH] Input: axp20x-pek - add support for AXP313A variant
Date: Wed,  3 Jun 2026 10:59:50 +0800	[thread overview]
Message-ID: <tencent_81FCC0443B81A3078C17F44AB4B22DFB2E07@qq.com> (raw)
In-Reply-To: <ZoMD9s0Xs_VBzIKC@google.com>

Add power button support for the AXP313A PMIC. The AXP313A does not
have the PEK_KEY register (0x36) used to configure startup and shutdown
timings, unlike AXP20X and AXP221. Create a dedicated axp313a_info
configuration with NULL time tables to prevent regmap out-of-bounds
access.

For AXP313A, the sysfs attributes (startup/shutdown) are hidden using
the is_visible callback, as they are not supported by the hardware.

Signed-off-by: Steven Feng <steven@joint-cloud.com>
---
Changes in v3:
- Use is_visible to hide attributes instead of returning -EOPNOTSUPP
- Corrected author name from "steven" to "Steven Feng"

Changes in v2:
- Fixed regmap out-of-bounds access issue reported by Sashiko AI
- Created dedicated axp313a_info with NULL time tables
- Added NULL pointer checks to prevent crashes
- AXP313A lacks PEK_KEY (0x36) per datasheet verification
- Power button still functional using hardware default timings

v2: https://lore.kernel.org/all/tencent_48A497E0CA81323CFB6C7CB84428019A8707@qq.com/
v1: https://lore.kernel.org/all/tencent_5F1FF80489E702360F352F889570656BF608@qq.com/
---
 drivers/input/misc/axp20x-pek.c | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
index d4e2fc9a937f..964b39817af9 100644
--- a/drivers/input/misc/axp20x-pek.c
+++ b/drivers/input/misc/axp20x-pek.c
@@ -85,6 +85,13 @@ static const struct axp20x_info axp221_info = {
 	.shutdown_mask = AXP20X_PEK_SHUTDOWN_MASK,
 };
 
+static const struct axp20x_info axp313a_info = {
+	.startup_time = NULL,
+	.startup_mask = 0,
+	.shutdown_time = NULL,
+	.shutdown_mask = 0,
+};
+
 static ssize_t axp20x_show_attr(struct device *dev,
 				const struct axp20x_time *time,
 				unsigned int mask, char *buf)
@@ -193,7 +200,28 @@ static struct attribute *axp20x_attrs[] = {
 	&dev_attr_shutdown.attr,
 	NULL,
 };
-ATTRIBUTE_GROUPS(axp20x);
+
+static umode_t axp20x_attr_is_visible(struct kobject *kobj,
+				      struct attribute *attr, int n)
+{
+	struct device *dev = kobj_to_dev(kobj);
+	struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
+
+	if (!axp20x_pek->info->startup_time)
+		return 0;
+
+	return attr->mode;
+}
+
+static const struct attribute_group axp20x_group = {
+	.attrs = axp20x_attrs,
+	.is_visible = axp20x_attr_is_visible,
+};
+
+static const struct attribute_group *axp20x_groups[] = {
+	&axp20x_group,
+	NULL,
+};
 
 static irqreturn_t axp20x_pek_irq(int irq, void *pwr)
 {
@@ -395,7 +423,7 @@ static const struct platform_device_id axp_pek_id_match[] = {
 	},
 	{
 		.name = "axp313a-pek",
-		.driver_data = (kernel_ulong_t)&axp20x_info,
+		.driver_data = (kernel_ulong_t)&axp313a_info,
 	},
 	{ /* sentinel */ }
 };
-- 
2.43.0


       reply	other threads:[~2026-06-03  3:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <ZoMD9s0Xs_VBzIKC@google.com>
2026-06-03  2:59 ` Steven Feng [this message]
2026-06-03  7:23   ` Chen-Yu Tsai
2026-06-03  1:38 steven
2026-06-03  2:25 ` Dmitry Torokhov
  -- strict thread matches above, loose matches on Subject: below --
2026-06-02  9:55 steven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tencent_81FCC0443B81A3078C17F44AB4B22DFB2E07@qq.com \
    --to=steven@joint-cloud.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wens@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®