Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH v2] Input: axp20x-pek - add AXP313a support
@ 2026-09-23 11:07 Vladimir
  2026-09-26  3:48 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: Vladimir @ 2026-09-23 11:07 UTC (permalink / raw)
  To: Chen-Yu Tsai, Samuel Holland; +Cc: linux-input, linux-pm, linux-sunxi

The AXP313a MFD driver registers its power button cell as "axp313a-pek",
but the axp20x-pek platform id table only matches "axp20x-pek" and
"axp221-pek".  The power button therefore never probes on boards using the
AXP313a PMIC (e.g. the OrangePi Zero 2W).

Add the missing id table entry.  Unlike the other variants the AXP313a has
no PEK key/startup/shutdown registers - AXP20X_PEK_KEY (0x36) lies beyond
its register map (max_register = AXP313A_IRQ_STATE, 0x21) - so give it its
own axp20x_info without start-up/shutdown times and hide the corresponding
sysfs attributes, instead of exposing files that always fail with -EIO.

Tested on: OrangePi Zero 2W (Allwinner H618 + AXP313a), kernel 7.1.13.

Signed-off-by: Vladimir <anykey196@gmail.com>
---
 drivers/input/misc/axp20x-pek.c | 39 ++++++++++++++++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
index 24f9e9d893d..b912f13b607 100644
--- a/drivers/input/misc/axp20x-pek.c
+++ b/drivers/input/misc/axp20x-pek.c
@@ -85,6 +85,16 @@ static const struct axp20x_info axp221_info = {
 	.shutdown_mask = AXP20X_PEK_SHUTDOWN_MASK,
 };
 
+static const struct axp20x_info axp313a_info = {
+	/*
+	 * The AXP313a has no PEK key/startup/shutdown registers: AXP20X_PEK_KEY
+	 * (0x36) lies beyond the end of its register map (max_register =
+	 * AXP313A_IRQ_STATE, 0x21).  Leaving startup_time/shutdown_time unset
+	 * keeps the matching sysfs attributes from being created, so they
+	 * cannot fail with -EIO.
+	 */
+};
+
 static ssize_t axp20x_show_attr(struct device *dev,
 				const struct axp20x_time *time,
 				unsigned int mask, char *buf)
@@ -188,12 +198,35 @@ static DEVICE_ATTR(startup, 0644, axp20x_show_attr_startup,
 static DEVICE_ATTR(shutdown, 0644, axp20x_show_attr_shutdown,
 		   axp20x_store_attr_shutdown);
 
+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 (attr == &dev_attr_startup.attr && !axp20x_pek->info->startup_time)
+		return 0;
+	if (attr == &dev_attr_shutdown.attr && !axp20x_pek->info->shutdown_time)
+		return 0;
+
+	return attr->mode;
+}
+
 static struct attribute *axp20x_attrs[] = {
 	&dev_attr_startup.attr,
 	&dev_attr_shutdown.attr,
 	NULL,
 };
-ATTRIBUTE_GROUPS(axp20x);
+
+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)
 {
@@ -393,6 +426,10 @@ static const struct platform_device_id axp_pek_id_match[] = {
 		.name = "axp221-pek",
 		.driver_data = (kernel_ulong_t)&axp221_info,
 	},
+	{
+		.name = "axp313a-pek",
+		.driver_data = (kernel_ulong_t)&axp313a_info,
+	},
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(platform, axp_pek_id_match);
-- 
2.55.0.windows.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] Input: axp20x-pek - add AXP313a support
  2026-09-23 11:07 [PATCH v2] Input: axp20x-pek - add AXP313a support Vladimir
@ 2026-09-26  3:48 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2026-09-26  3:48 UTC (permalink / raw)
  To: Vladimir; +Cc: Chen-Yu Tsai, Samuel Holland, linux-input, linux-pm, linux-sunxi

On Wed, Sep 23, 2026 at 04:07:41PM +0500, Vladimir wrote:
> The AXP313a MFD driver registers its power button cell as "axp313a-pek",
> but the axp20x-pek platform id table only matches "axp20x-pek" and
> "axp221-pek".  The power button therefore never probes on boards using the
> AXP313a PMIC (e.g. the OrangePi Zero 2W).
> 
> Add the missing id table entry.  Unlike the other variants the AXP313a has
> no PEK key/startup/shutdown registers - AXP20X_PEK_KEY (0x36) lies beyond
> its register map (max_register = AXP313A_IRQ_STATE, 0x21) - so give it its
> own axp20x_info without start-up/shutdown times and hide the corresponding
> sysfs attributes, instead of exposing files that always fail with -EIO.
> 
> Tested on: OrangePi Zero 2W (Allwinner H618 + AXP313a), kernel 7.1.13.
> 
> Signed-off-by: Vladimir <anykey196@gmail.com>

While we no longer require legal names on sign-offs we do need a "known
identity" and just the first name does not cut.

> ---
>  drivers/input/misc/axp20x-pek.c | 39 ++++++++++++++++++++++++++++++++-
>  1 file changed, 38 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
> index 24f9e9d893d..b912f13b607 100644
> --- a/drivers/input/misc/axp20x-pek.c
> +++ b/drivers/input/misc/axp20x-pek.c
> @@ -85,6 +85,16 @@ static const struct axp20x_info axp221_info = {
>  	.shutdown_mask = AXP20X_PEK_SHUTDOWN_MASK,
>  };
>  
> +static const struct axp20x_info axp313a_info = {
> +	/*
> +	 * The AXP313a has no PEK key/startup/shutdown registers: AXP20X_PEK_KEY
> +	 * (0x36) lies beyond the end of its register map (max_register =
> +	 * AXP313A_IRQ_STATE, 0x21).  Leaving startup_time/shutdown_time unset
> +	 * keeps the matching sysfs attributes from being created, so they
> +	 * cannot fail with -EIO.
> +	 */

Maybe just say:

	.startup_time = NULL, /* not supported */
	.shutdown_time = NULL, /* not supported */
> +};
> +

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-26  3:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-23 11:07 [PATCH v2] Input: axp20x-pek - add AXP313a support Vladimir
2026-09-26  3:48 ` Dmitry Torokhov

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