Skip to contentSkip to conversation

Input: axp20x-pek - support the AXP313A power key

PATCH Superseded Jernej Skrabec 3 participants 5 messages Nov 15 – Nov 16

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Input: axp20x-pek - support the AXP313A power key

The AXP313A MFD cell is registered as "axp313a-pek", which this driver doesn't match, so the power key doesn't work on boards with this PMIC.

Match it as well. The AXP313A has no AXP20X_PEK_KEY register, so hide the startup and shutdown attributes on PMICs without timing tables.

---
 drivers/input/misc/axp20x-pek.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)
drivers/input/misc/axp20x-pek.c +27 -1
index c34e002258ee..d7e696dd7c09 100644
@@ -85,6 +85,9 @@ static const struct axp20x_info axp221_info = {
 	.shutdown_mask = AXP20X_PEK_SHUTDOWN_MASK,
 };
 
+/* The AXP313A has no AXP20X_PEK_KEY register, so no timing controls. */
+static const struct axp20x_info axp313a_info = { };
+
 static ssize_t axp20x_show_attr(struct device *dev,
 				const struct axp20x_time *time,
 				unsigned int mask, char *buf)
@@ -193,7 +196,26 @@ 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 axp20x_pek *axp20x_pek = dev_get_drvdata(kobj_to_dev(kobj));
+
+	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 const struct attribute_group axp20x_group = {
+	.attrs = axp20x_attrs,
+	.is_visible = axp20x_attr_is_visible,
+};
+__ATTRIBUTE_GROUPS(axp20x);
 
 static irqreturn_t axp20x_pek_irq(int irq, void *pwr)
 {
@@ -392,6 +414,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);

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4

Signature · 1 line
2.43.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Jernej Skrabec

The AXP313A MFD cell is registered as "axp313a-pek", which this driver doesn't match, so the power key doesn't work on boards with this PMIC.

Match it as well. The AXP313A has no AXP20X_PEK_KEY register, so hide the startup and shutdown attributes on PMICs without timing tables.

maintainer
#2 lore raw
In reply to Jernej Skrabec

Hi Jernej,

Quoted 2 lines · Jernej Skrabec

The AXP313A MFD cell is registered as "axp313a-pek", which this driver doesn't match, so the power key doesn't work on boards with this PMIC.

...

Quoted 15 lines
drivers/input/misc/axp20x-pek.c +7 -1
+/* The AXP313A has no AXP20X_PEK_KEY register, so no timing controls. */
+static const struct axp20x_info axp313a_info = { };
+
 static ssize_t axp20x_show_attr(struct device *dev,
 				const struct axp20x_time *time,
 				unsigned int mask, char *buf)
@@ -193,7 +196,26 @@ 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)
+{

drivers/input/misc/axp20x-pek.c static struct attribute *axp20x_attrs[] = { · line 212

Quoted 10 lines
drivers/input/misc/axp20x-pek.c +10 -0
+	struct axp20x_pek *axp20x_pek = dev_get_drvdata(kobj_to_dev(kobj));
+
+	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;
+}

axp20x_pek->info is only used by the startup and shutdown sysfs attributes, and we do not have variants that support only one of them. Can we drop the empty axp313a_info structure (leaving driver_data as 0 for "axp313a-pek") and simplify this to:

	return axp20x_pek->info ? attr->mode : 0;

?

Thanks.

Signature · 1 line
Dmitry
#3 lore raw

Dne ponedeljek, 16. november 2026 ob 08:39:21 Srednjeevropski standardni čas je Dmitry Torokhov napisal(a):

Quoted 37 lines

Hi Jernej,

Quoted 2 lines · Jernej Skrabec

The AXP313A MFD cell is registered as "axp313a-pek", which this driver doesn't match, so the power key doesn't work on boards with this PMIC.

...

Quoted 15 lines
drivers/input/misc/axp20x-pek.c +7 -1
+/* The AXP313A has no AXP20X_PEK_KEY register, so no timing controls. */
+static const struct axp20x_info axp313a_info = { };
+
 static ssize_t axp20x_show_attr(struct device *dev,
 				const struct axp20x_time *time,
 				unsigned int mask, char *buf)
@@ -193,7 +196,26 @@ 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)
+{

drivers/input/misc/axp20x-pek.c static struct attribute *axp20x_attrs[] = { · line 212

Quoted 10 lines
drivers/input/misc/axp20x-pek.c +10 -0
+	struct axp20x_pek *axp20x_pek = dev_get_drvdata(kobj_to_dev(kobj));
+
+	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;
+}

axp20x_pek->info is only used by the startup and shutdown sysfs attributes, and we do not have variants that support only one of them. Can we drop the empty axp313a_info structure (leaving driver_data as 0 for "axp313a-pek") and simplify this to:

Quoted 7 lines
	return axp20x_pek->info ? attr->mode : 0;

?

Thanks.

Makes sense, will do.

Best regards,
Jernej

#4 lore raw

PATCH v2 1/1 Input: axp20x-pek - support the AXP313A power key

In reply to Jernej Skrabec

The AXP313A MFD cell is registered as "axp313a-pek", which this driver doesn't match, so the power key doesn't work on boards with this PMIC.

Match it as well. The AXP313A has no AXP20X_PEK_KEY register, so leave its driver_data empty and hide the startup and shutdown attributes on PMICs without timing info.

---
Changes in v2:
- Drop empty axp313a_info and check for NULL info instead (Dmitry)
- Collect Chen-Yu's Acked-by
- Link to v1: https://lore.kernel.org/linux-input/[email protected]/

 drivers/input/misc/axp20x-pek.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/input/misc/axp20x-pek.c +18 -1
index c34e002258ee..040aec5f9e4c 100644
@@ -193,7 +193,20 @@ 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 axp20x_pek *axp20x_pek = dev_get_drvdata(kobj_to_dev(kobj));
+
+	return axp20x_pek->info ? attr->mode : 0;
+}
+
+static const struct attribute_group axp20x_group = {
+	.attrs = axp20x_attrs,
+	.is_visible = axp20x_attr_is_visible,
+};
+__ATTRIBUTE_GROUPS(axp20x);
 
 static irqreturn_t axp20x_pek_irq(int irq, void *pwr)
 {
@@ -392,6 +405,10 @@ static const struct platform_device_id axp_pek_id_match[] = {
 		.name = "axp221-pek",
 		.driver_data = (kernel_ulong_t)&axp221_info,
 	},
+	{
+		/* No AXP20X_PEK_KEY register, so no timing controls. */
+		.name = "axp313a-pek",
+	},
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(platform, axp_pek_id_match);

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4

Signature · 1 line
2.43.0