All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] power: supply: axp288_*: Use acpi_quirk_skip_acpi_ac_and_battery()
@ 2022-02-24 22:28 Hans de Goede
  2022-02-24 22:28 ` [PATCH 1/2] power: supply: axp288_charger: " Hans de Goede
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Hans de Goede @ 2022-02-24 22:28 UTC (permalink / raw)
  To: Sebastian Reichel; +Cc: Hans de Goede, linux-pm

Hi All,

Normally the native AXP288 fg/charger drivers are preferred but one some
devices the ACPI drivers should be used instead.

The ACPI AC and battery drivers used to both have their own detection if
a PMIC on which native drivers should be preffered was present as well as
their own list of exceptions for devices like the ECS EF20EA, which has
an AXP288 PMIC but uses a separate fuel-gauge.

And the axp288_fuel_guage driver also has a dmi_system_id table entry
for the ECS EF20EA to avoid loading on this board. Where as for
the axp288_charger code it was decided that it was ok to have both
a /sys/class/power_supply/ADP1 from ACPI as well as a /axp288_charger .

So that is 3 separate "ECS EF20EA" dmi_system_id table entries in
3 different drivers (which should really be 4). In 5.17-rc1 a patch
adding a new acpi_quirk_skip_acpi_ac_and_battery() helper was merged
to remove the code duplication for this from the ACPI AC and battery
drivers:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=57a18322227134e37b693ef8ef216ed7ce7ba7d6

This series makes the AXP288 charger and fuelgauge drivers also use
this helper. This allows removing the "ECS EF20EA" dmi_system_id table
entry from the fuel-gauge code and fixes the duplicate
/sys/class/power_supply/axp288_charger power_supply device on these
boards.

This also gives us a single place to add further exceptions if
necessary, rather then needing to do this in 4 different places.

Regards,

Hans


Hans de Goede (2):
  power: supply: axp288_charger: Use
    acpi_quirk_skip_acpi_ac_and_battery()
  power: supply: axp288_fuel_gauge: Use
    acpi_quirk_skip_acpi_ac_and_battery()

 drivers/power/supply/Kconfig             |  4 ++--
 drivers/power/supply/axp288_charger.c    |  7 +++++++
 drivers/power/supply/axp288_fuel_gauge.c | 14 ++++++++------
 3 files changed, 17 insertions(+), 8 deletions(-)

-- 
2.35.1


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

* [PATCH 1/2] power: supply: axp288_charger: Use acpi_quirk_skip_acpi_ac_and_battery()
  2022-02-24 22:28 [PATCH 0/2] power: supply: axp288_*: Use acpi_quirk_skip_acpi_ac_and_battery() Hans de Goede
@ 2022-02-24 22:28 ` Hans de Goede
  2022-02-24 22:28 ` [PATCH 2/2] power: supply: axp288_fuel_gauge: " Hans de Goede
  2022-02-25 17:12 ` [PATCH 0/2] power: supply: axp288_*: " Sebastian Reichel
  2 siblings, 0 replies; 4+ messages in thread
From: Hans de Goede @ 2022-02-24 22:28 UTC (permalink / raw)
  To: Sebastian Reichel; +Cc: Hans de Goede, linux-pm

Normally the native AXP288 fg/charger drivers are preferred but one some
devices the ACPI drivers should be used instead.

The ACPI battery/ac drivers use the acpi_quirk_skip_acpi_ac_and_battery()
helper to determine if they should skip loading because native fuel-gauge/
charger drivers like the AXP288 drivers will be used.

The new acpi_quirk_skip_acpi_ac_and_battery() helper includes a list of
exceptions for boards where the ACPI drivers should be used instead.

Use this new helper to avoid loading on such boards. Note this requires
adding a Kconfig dependency on ACPI, this is not a problem because ACPI
should be enabled on all boards with an AXP288 PMIC anyways.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/power/supply/Kconfig          | 2 +-
 drivers/power/supply/axp288_charger.c | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig
index 3520da74b8a7..ce7ecf2c821e 100644
--- a/drivers/power/supply/Kconfig
+++ b/drivers/power/supply/Kconfig
@@ -351,7 +351,7 @@ config AXP20X_POWER
 
 config AXP288_CHARGER
 	tristate "X-Powers AXP288 Charger"
-	depends on MFD_AXP20X && EXTCON_AXP288 && IOSF_MBI
+	depends on MFD_AXP20X && EXTCON_AXP288 && IOSF_MBI && ACPI
 	help
 	  Say yes here to have support X-Power AXP288 power management IC (PMIC)
 	  integrated charger.
diff --git a/drivers/power/supply/axp288_charger.c b/drivers/power/supply/axp288_charger.c
index c498e62ab4e2..19746e658a6a 100644
--- a/drivers/power/supply/axp288_charger.c
+++ b/drivers/power/supply/axp288_charger.c
@@ -838,6 +838,13 @@ static int axp288_charger_probe(struct platform_device *pdev)
 	struct power_supply_config charger_cfg = {};
 	unsigned int val;
 
+	/*
+	 * Normally the native AXP288 fg/charger drivers are preferred but
+	 * on some devices the ACPI drivers should be used instead.
+	 */
+	if (!acpi_quirk_skip_acpi_ac_and_battery())
+		return -ENODEV;
+
 	/*
 	 * On some devices the fuelgauge and charger parts of the axp288 are
 	 * not used, check that the fuelgauge is enabled (CC_CTRL != 0).
-- 
2.35.1


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

* [PATCH 2/2] power: supply: axp288_fuel_gauge: Use acpi_quirk_skip_acpi_ac_and_battery()
  2022-02-24 22:28 [PATCH 0/2] power: supply: axp288_*: Use acpi_quirk_skip_acpi_ac_and_battery() Hans de Goede
  2022-02-24 22:28 ` [PATCH 1/2] power: supply: axp288_charger: " Hans de Goede
@ 2022-02-24 22:28 ` Hans de Goede
  2022-02-25 17:12 ` [PATCH 0/2] power: supply: axp288_*: " Sebastian Reichel
  2 siblings, 0 replies; 4+ messages in thread
From: Hans de Goede @ 2022-02-24 22:28 UTC (permalink / raw)
  To: Sebastian Reichel; +Cc: Hans de Goede, linux-pm

Normally the native AXP288 fg/charger drivers are preferred but one some
devices the ACPI drivers should be used instead.

The ACPI battery/ac drivers use the acpi_quirk_skip_acpi_ac_and_battery()
helper to determine if they should skip loading because native fuel-gauge/
charger drivers like the AXP288 drivers will be used.

The new acpi_quirk_skip_acpi_ac_and_battery() helper includes a list of
exceptions for boards where the ACPI drivers should be used instead.

Use this new helper to avoid loading on such boards. Note this requires
adding a Kconfig dependency on ACPI, this is not a problem because ACPI
should be enabled on all boards with an AXP288 PMIC anyways.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/power/supply/Kconfig             |  2 +-
 drivers/power/supply/axp288_fuel_gauge.c | 14 ++++++++------
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig
index ce7ecf2c821e..8f9033679f49 100644
--- a/drivers/power/supply/Kconfig
+++ b/drivers/power/supply/Kconfig
@@ -358,7 +358,7 @@ config AXP288_CHARGER
 
 config AXP288_FUEL_GAUGE
 	tristate "X-Powers AXP288 Fuel Gauge"
-	depends on MFD_AXP20X && IIO && IOSF_MBI
+	depends on MFD_AXP20X && IIO && IOSF_MBI && ACPI
 	help
 	  Say yes here to have support for X-Power power management IC (PMIC)
 	  Fuel Gauge. The device provides battery statistics and status
diff --git a/drivers/power/supply/axp288_fuel_gauge.c b/drivers/power/supply/axp288_fuel_gauge.c
index 13be2c1d6528..e9f285dae489 100644
--- a/drivers/power/supply/axp288_fuel_gauge.c
+++ b/drivers/power/supply/axp288_fuel_gauge.c
@@ -9,6 +9,7 @@
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
+#include <linux/acpi.h>
 #include <linux/dmi.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
@@ -544,12 +545,6 @@ static const struct dmi_system_id axp288_no_battery_list[] = {
 			DMI_EXACT_MATCH(DMI_BIOS_VERSION, "1.000"),
 		},
 	},
-	{
-		/* ECS EF20EA */
-		.matches = {
-			DMI_MATCH(DMI_PRODUCT_NAME, "EF20EA"),
-		},
-	},
 	{
 		/* Intel Cherry Trail Compute Stick, Windows version */
 		.matches = {
@@ -673,6 +668,13 @@ static int axp288_fuel_gauge_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	int i, pirq, ret;
 
+	/*
+	 * Normally the native AXP288 fg/charger drivers are preferred but
+	 * on some devices the ACPI drivers should be used instead.
+	 */
+	if (!acpi_quirk_skip_acpi_ac_and_battery())
+		return -ENODEV;
+
 	if (dmi_check_system(axp288_no_battery_list))
 		return -ENODEV;
 
-- 
2.35.1


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

* Re: [PATCH 0/2] power: supply: axp288_*: Use acpi_quirk_skip_acpi_ac_and_battery()
  2022-02-24 22:28 [PATCH 0/2] power: supply: axp288_*: Use acpi_quirk_skip_acpi_ac_and_battery() Hans de Goede
  2022-02-24 22:28 ` [PATCH 1/2] power: supply: axp288_charger: " Hans de Goede
  2022-02-24 22:28 ` [PATCH 2/2] power: supply: axp288_fuel_gauge: " Hans de Goede
@ 2022-02-25 17:12 ` Sebastian Reichel
  2 siblings, 0 replies; 4+ messages in thread
From: Sebastian Reichel @ 2022-02-25 17:12 UTC (permalink / raw)
  To: Hans de Goede; +Cc: linux-pm

[-- Attachment #1: Type: text/plain, Size: 1663 bytes --]

Hi Hans,

On Thu, Feb 24, 2022 at 11:28:03PM +0100, Hans de Goede wrote:
> Normally the native AXP288 fg/charger drivers are preferred but one some
> devices the ACPI drivers should be used instead.
> 
> The ACPI AC and battery drivers used to both have their own detection if
> a PMIC on which native drivers should be preffered was present as well as
> their own list of exceptions for devices like the ECS EF20EA, which has
> an AXP288 PMIC but uses a separate fuel-gauge.
> 
> And the axp288_fuel_guage driver also has a dmi_system_id table entry
> for the ECS EF20EA to avoid loading on this board. Where as for
> the axp288_charger code it was decided that it was ok to have both
> a /sys/class/power_supply/ADP1 from ACPI as well as a /axp288_charger .
> 
> So that is 3 separate "ECS EF20EA" dmi_system_id table entries in
> 3 different drivers (which should really be 4). In 5.17-rc1 a patch
> adding a new acpi_quirk_skip_acpi_ac_and_battery() helper was merged
> to remove the code duplication for this from the ACPI AC and battery
> drivers:
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=57a18322227134e37b693ef8ef216ed7ce7ba7d6
> 
> This series makes the AXP288 charger and fuelgauge drivers also use
> this helper. This allows removing the "ECS EF20EA" dmi_system_id table
> entry from the fuel-gauge code and fixes the duplicate
> /sys/class/power_supply/axp288_charger power_supply device on these
> boards.
> 
> This also gives us a single place to add further exceptions if
> necessary, rather then needing to do this in 4 different places.

Thanks, queued.

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2022-02-25 17:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-24 22:28 [PATCH 0/2] power: supply: axp288_*: Use acpi_quirk_skip_acpi_ac_and_battery() Hans de Goede
2022-02-24 22:28 ` [PATCH 1/2] power: supply: axp288_charger: " Hans de Goede
2022-02-24 22:28 ` [PATCH 2/2] power: supply: axp288_fuel_gauge: " Hans de Goede
2022-02-25 17:12 ` [PATCH 0/2] power: supply: axp288_*: " Sebastian Reichel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.