All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] power: supply: axp288_fuel_gauge: Fix battery reporting on the One Mix 1
@ 2022-05-02 11:12 Hans de Goede
  2022-05-02 11:12 ` [PATCH 2/2] power: supply: axp288_fuel_gauge: Drop BIOS version check from "T3 MRD" DMI quirk Hans de Goede
  2022-05-03 15:35 ` [PATCH 1/2] power: supply: axp288_fuel_gauge: Fix battery reporting on the One Mix 1 Sebastian Reichel
  0 siblings, 2 replies; 4+ messages in thread
From: Hans de Goede @ 2022-05-02 11:12 UTC (permalink / raw)
  To: Sebastian Reichel; +Cc: Hans de Goede, linux-pm

Commit 3a06b912a5ce ("power: supply: axp288_fuel_gauge: Make "T3 MRD"
no_battery_list DMI entry more generic") added a generic no-battery DMI
match for many mini-PCs / HDMI-sticks which use "T3 MRD" as their DMI
board-name.

It turns out that the One Mix 1 mini laptop also uses "T3 MRD" for its
DMI boardname and it also has its chassis-type wrongly set to a value
of "3" (desktop). This was causing the axp288_fuel_gauge driver to
disable battery reporting because this matches the no-battery DMI
list entry for generic "T3 MRD" mini-PCs.

Change the no-battery DMI list into a quirks DMI list and add a
specific match for the One Mix 1 mini laptop before the generic
"T3 MRD" no-battery quirk entry to fix this.

Fixes: 3a06b912a5ce ("power: supply: axp288_fuel_gauge: Make "T3 MRD" no_battery_list DMI entry more generic")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/power/supply/axp288_fuel_gauge.c | 40 +++++++++++++++++++++---
 1 file changed, 36 insertions(+), 4 deletions(-)

diff --git a/drivers/power/supply/axp288_fuel_gauge.c b/drivers/power/supply/axp288_fuel_gauge.c
index e9f285dae489..5b8aa4a980cd 100644
--- a/drivers/power/supply/axp288_fuel_gauge.c
+++ b/drivers/power/supply/axp288_fuel_gauge.c
@@ -90,6 +90,8 @@
 #define AXP288_REG_UPDATE_INTERVAL		(60 * HZ)
 #define AXP288_FG_INTR_NUM			6
 
+#define AXP288_QUIRK_NO_BATTERY			BIT(0)
+
 static bool no_current_sense_res;
 module_param(no_current_sense_res, bool, 0444);
 MODULE_PARM_DESC(no_current_sense_res, "No (or broken) current sense resistor");
@@ -524,7 +526,7 @@ static struct power_supply_desc fuel_gauge_desc = {
  * detection reports one despite it not being there.
  * Please keep this listed sorted alphabetically.
  */
-static const struct dmi_system_id axp288_no_battery_list[] = {
+static const struct dmi_system_id axp288_quirks[] = {
 	{
 		/* ACEPC T8 Cherry Trail Z8350 mini PC */
 		.matches = {
@@ -534,6 +536,7 @@ static const struct dmi_system_id axp288_no_battery_list[] = {
 			/* also match on somewhat unique bios-version */
 			DMI_EXACT_MATCH(DMI_BIOS_VERSION, "1.000"),
 		},
+		.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
 	},
 	{
 		/* ACEPC T11 Cherry Trail Z8350 mini PC */
@@ -544,6 +547,7 @@ static const struct dmi_system_id axp288_no_battery_list[] = {
 			/* also match on somewhat unique bios-version */
 			DMI_EXACT_MATCH(DMI_BIOS_VERSION, "1.000"),
 		},
+		.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
 	},
 	{
 		/* Intel Cherry Trail Compute Stick, Windows version */
@@ -551,6 +555,7 @@ static const struct dmi_system_id axp288_no_battery_list[] = {
 			DMI_MATCH(DMI_SYS_VENDOR, "Intel"),
 			DMI_MATCH(DMI_PRODUCT_NAME, "STK1AW32SC"),
 		},
+		.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
 	},
 	{
 		/* Intel Cherry Trail Compute Stick, version without an OS */
@@ -558,34 +563,55 @@ static const struct dmi_system_id axp288_no_battery_list[] = {
 			DMI_MATCH(DMI_SYS_VENDOR, "Intel"),
 			DMI_MATCH(DMI_PRODUCT_NAME, "STK1A32SC"),
 		},
+		.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
 	},
 	{
 		/* Meegopad T02 */
 		.matches = {
 			DMI_MATCH(DMI_PRODUCT_NAME, "MEEGOPAD T02"),
 		},
+		.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
 	},
 	{	/* Mele PCG03 Mini PC */
 		.matches = {
 			DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Mini PC"),
 			DMI_EXACT_MATCH(DMI_BOARD_NAME, "Mini PC"),
 		},
+		.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
 	},
 	{
 		/* Minix Neo Z83-4 mini PC */
 		.matches = {
 			DMI_MATCH(DMI_SYS_VENDOR, "MINIX"),
 			DMI_MATCH(DMI_PRODUCT_NAME, "Z83-4"),
-		}
+		},
+		.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
 	},
 	{
-		/* Various Ace PC/Meegopad/MinisForum/Wintel Mini-PCs/HDMI-sticks */
+		/*
+		 * One Mix 1, this uses the "T3 MRD" boardname used by
+		 * generic mini PCs, but it is a mini laptop so it does
+		 * actually have a battery!
+		 */
+		.matches = {
+			DMI_MATCH(DMI_BOARD_NAME, "T3 MRD"),
+			DMI_MATCH(DMI_BIOS_DATE, "06/14/2018"),
+		},
+		.driver_data = NULL,
+	},
+	{
+		/*
+		 * Various Ace PC/Meegopad/MinisForum/Wintel Mini-PCs/HDMI-sticks
+		 * This entry must be last because it is generic, this allows
+		 * adding more specifuc quirks overriding this generic entry.
+		 */
 		.matches = {
 			DMI_MATCH(DMI_BOARD_NAME, "T3 MRD"),
 			DMI_MATCH(DMI_CHASSIS_TYPE, "3"),
 			DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."),
 			DMI_MATCH(DMI_BIOS_VERSION, "5.11"),
 		},
+		.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
 	},
 	{}
 };
@@ -665,7 +691,9 @@ static int axp288_fuel_gauge_probe(struct platform_device *pdev)
 		[BAT_D_CURR] = "axp288-chrg-d-curr",
 		[BAT_VOLT] = "axp288-batt-volt",
 	};
+	const struct dmi_system_id *dmi_id;
 	struct device *dev = &pdev->dev;
+	unsigned long quirks = 0;
 	int i, pirq, ret;
 
 	/*
@@ -675,7 +703,11 @@ static int axp288_fuel_gauge_probe(struct platform_device *pdev)
 	if (!acpi_quirk_skip_acpi_ac_and_battery())
 		return -ENODEV;
 
-	if (dmi_check_system(axp288_no_battery_list))
+	dmi_id = dmi_first_match(axp288_quirks);
+	if (dmi_id)
+		quirks = (unsigned long)dmi_id->driver_data;
+
+	if (quirks & AXP288_QUIRK_NO_BATTERY)
 		return -ENODEV;
 
 	info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
-- 
2.36.0


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

* [PATCH 2/2] power: supply: axp288_fuel_gauge: Drop BIOS version check from "T3 MRD" DMI quirk
  2022-05-02 11:12 [PATCH 1/2] power: supply: axp288_fuel_gauge: Fix battery reporting on the One Mix 1 Hans de Goede
@ 2022-05-02 11:12 ` Hans de Goede
  2022-05-03 15:35   ` Sebastian Reichel
  2022-05-03 15:35 ` [PATCH 1/2] power: supply: axp288_fuel_gauge: Fix battery reporting on the One Mix 1 Sebastian Reichel
  1 sibling, 1 reply; 4+ messages in thread
From: Hans de Goede @ 2022-05-02 11:12 UTC (permalink / raw)
  To: Sebastian Reichel; +Cc: Hans de Goede, linux-pm

Some "T3 MRD" mini-PCs / HDMI-sticks without a battery use a different
value then "5.11" for their DMI BIOS version field.

Drop the BIOS version check so that the no-battery "T3 MRD" DMI quirk
applies to these too.

Fixes: 3a06b912a5ce ("power: supply: axp288_fuel_gauge: Make "T3 MRD" no_battery_list DMI entry more generic")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/power/supply/axp288_fuel_gauge.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/power/supply/axp288_fuel_gauge.c b/drivers/power/supply/axp288_fuel_gauge.c
index 5b8aa4a980cd..8e6f8a655079 100644
--- a/drivers/power/supply/axp288_fuel_gauge.c
+++ b/drivers/power/supply/axp288_fuel_gauge.c
@@ -609,7 +609,6 @@ static const struct dmi_system_id axp288_quirks[] = {
 			DMI_MATCH(DMI_BOARD_NAME, "T3 MRD"),
 			DMI_MATCH(DMI_CHASSIS_TYPE, "3"),
 			DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."),
-			DMI_MATCH(DMI_BIOS_VERSION, "5.11"),
 		},
 		.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
 	},
-- 
2.36.0


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

* Re: [PATCH 1/2] power: supply: axp288_fuel_gauge: Fix battery reporting on the One Mix 1
  2022-05-02 11:12 [PATCH 1/2] power: supply: axp288_fuel_gauge: Fix battery reporting on the One Mix 1 Hans de Goede
  2022-05-02 11:12 ` [PATCH 2/2] power: supply: axp288_fuel_gauge: Drop BIOS version check from "T3 MRD" DMI quirk Hans de Goede
@ 2022-05-03 15:35 ` Sebastian Reichel
  1 sibling, 0 replies; 4+ messages in thread
From: Sebastian Reichel @ 2022-05-03 15:35 UTC (permalink / raw)
  To: Hans de Goede; +Cc: linux-pm

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

Hi,

On Mon, May 02, 2022 at 01:12:34PM +0200, Hans de Goede wrote:
> Commit 3a06b912a5ce ("power: supply: axp288_fuel_gauge: Make "T3 MRD"
> no_battery_list DMI entry more generic") added a generic no-battery DMI
> match for many mini-PCs / HDMI-sticks which use "T3 MRD" as their DMI
> board-name.
> 
> It turns out that the One Mix 1 mini laptop also uses "T3 MRD" for its
> DMI boardname and it also has its chassis-type wrongly set to a value
> of "3" (desktop). This was causing the axp288_fuel_gauge driver to
> disable battery reporting because this matches the no-battery DMI
> list entry for generic "T3 MRD" mini-PCs.
> 
> Change the no-battery DMI list into a quirks DMI list and add a
> specific match for the One Mix 1 mini laptop before the generic
> "T3 MRD" no-battery quirk entry to fix this.
> 
> Fixes: 3a06b912a5ce ("power: supply: axp288_fuel_gauge: Make "T3 MRD" no_battery_list DMI entry more generic")
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---

Thanks, queued to my fixes branch.

-- Sebastian

>  drivers/power/supply/axp288_fuel_gauge.c | 40 +++++++++++++++++++++---
>  1 file changed, 36 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/power/supply/axp288_fuel_gauge.c b/drivers/power/supply/axp288_fuel_gauge.c
> index e9f285dae489..5b8aa4a980cd 100644
> --- a/drivers/power/supply/axp288_fuel_gauge.c
> +++ b/drivers/power/supply/axp288_fuel_gauge.c
> @@ -90,6 +90,8 @@
>  #define AXP288_REG_UPDATE_INTERVAL		(60 * HZ)
>  #define AXP288_FG_INTR_NUM			6
>  
> +#define AXP288_QUIRK_NO_BATTERY			BIT(0)
> +
>  static bool no_current_sense_res;
>  module_param(no_current_sense_res, bool, 0444);
>  MODULE_PARM_DESC(no_current_sense_res, "No (or broken) current sense resistor");
> @@ -524,7 +526,7 @@ static struct power_supply_desc fuel_gauge_desc = {
>   * detection reports one despite it not being there.
>   * Please keep this listed sorted alphabetically.
>   */
> -static const struct dmi_system_id axp288_no_battery_list[] = {
> +static const struct dmi_system_id axp288_quirks[] = {
>  	{
>  		/* ACEPC T8 Cherry Trail Z8350 mini PC */
>  		.matches = {
> @@ -534,6 +536,7 @@ static const struct dmi_system_id axp288_no_battery_list[] = {
>  			/* also match on somewhat unique bios-version */
>  			DMI_EXACT_MATCH(DMI_BIOS_VERSION, "1.000"),
>  		},
> +		.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
>  	},
>  	{
>  		/* ACEPC T11 Cherry Trail Z8350 mini PC */
> @@ -544,6 +547,7 @@ static const struct dmi_system_id axp288_no_battery_list[] = {
>  			/* also match on somewhat unique bios-version */
>  			DMI_EXACT_MATCH(DMI_BIOS_VERSION, "1.000"),
>  		},
> +		.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
>  	},
>  	{
>  		/* Intel Cherry Trail Compute Stick, Windows version */
> @@ -551,6 +555,7 @@ static const struct dmi_system_id axp288_no_battery_list[] = {
>  			DMI_MATCH(DMI_SYS_VENDOR, "Intel"),
>  			DMI_MATCH(DMI_PRODUCT_NAME, "STK1AW32SC"),
>  		},
> +		.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
>  	},
>  	{
>  		/* Intel Cherry Trail Compute Stick, version without an OS */
> @@ -558,34 +563,55 @@ static const struct dmi_system_id axp288_no_battery_list[] = {
>  			DMI_MATCH(DMI_SYS_VENDOR, "Intel"),
>  			DMI_MATCH(DMI_PRODUCT_NAME, "STK1A32SC"),
>  		},
> +		.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
>  	},
>  	{
>  		/* Meegopad T02 */
>  		.matches = {
>  			DMI_MATCH(DMI_PRODUCT_NAME, "MEEGOPAD T02"),
>  		},
> +		.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
>  	},
>  	{	/* Mele PCG03 Mini PC */
>  		.matches = {
>  			DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Mini PC"),
>  			DMI_EXACT_MATCH(DMI_BOARD_NAME, "Mini PC"),
>  		},
> +		.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
>  	},
>  	{
>  		/* Minix Neo Z83-4 mini PC */
>  		.matches = {
>  			DMI_MATCH(DMI_SYS_VENDOR, "MINIX"),
>  			DMI_MATCH(DMI_PRODUCT_NAME, "Z83-4"),
> -		}
> +		},
> +		.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
>  	},
>  	{
> -		/* Various Ace PC/Meegopad/MinisForum/Wintel Mini-PCs/HDMI-sticks */
> +		/*
> +		 * One Mix 1, this uses the "T3 MRD" boardname used by
> +		 * generic mini PCs, but it is a mini laptop so it does
> +		 * actually have a battery!
> +		 */
> +		.matches = {
> +			DMI_MATCH(DMI_BOARD_NAME, "T3 MRD"),
> +			DMI_MATCH(DMI_BIOS_DATE, "06/14/2018"),
> +		},
> +		.driver_data = NULL,
> +	},
> +	{
> +		/*
> +		 * Various Ace PC/Meegopad/MinisForum/Wintel Mini-PCs/HDMI-sticks
> +		 * This entry must be last because it is generic, this allows
> +		 * adding more specifuc quirks overriding this generic entry.
> +		 */
>  		.matches = {
>  			DMI_MATCH(DMI_BOARD_NAME, "T3 MRD"),
>  			DMI_MATCH(DMI_CHASSIS_TYPE, "3"),
>  			DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."),
>  			DMI_MATCH(DMI_BIOS_VERSION, "5.11"),
>  		},
> +		.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
>  	},
>  	{}
>  };
> @@ -665,7 +691,9 @@ static int axp288_fuel_gauge_probe(struct platform_device *pdev)
>  		[BAT_D_CURR] = "axp288-chrg-d-curr",
>  		[BAT_VOLT] = "axp288-batt-volt",
>  	};
> +	const struct dmi_system_id *dmi_id;
>  	struct device *dev = &pdev->dev;
> +	unsigned long quirks = 0;
>  	int i, pirq, ret;
>  
>  	/*
> @@ -675,7 +703,11 @@ static int axp288_fuel_gauge_probe(struct platform_device *pdev)
>  	if (!acpi_quirk_skip_acpi_ac_and_battery())
>  		return -ENODEV;
>  
> -	if (dmi_check_system(axp288_no_battery_list))
> +	dmi_id = dmi_first_match(axp288_quirks);
> +	if (dmi_id)
> +		quirks = (unsigned long)dmi_id->driver_data;
> +
> +	if (quirks & AXP288_QUIRK_NO_BATTERY)
>  		return -ENODEV;
>  
>  	info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
> -- 
> 2.36.0
> 

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

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

* Re: [PATCH 2/2] power: supply: axp288_fuel_gauge: Drop BIOS version check from "T3 MRD" DMI quirk
  2022-05-02 11:12 ` [PATCH 2/2] power: supply: axp288_fuel_gauge: Drop BIOS version check from "T3 MRD" DMI quirk Hans de Goede
@ 2022-05-03 15:35   ` Sebastian Reichel
  0 siblings, 0 replies; 4+ messages in thread
From: Sebastian Reichel @ 2022-05-03 15:35 UTC (permalink / raw)
  To: Hans de Goede; +Cc: linux-pm

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

Hi,

On Mon, May 02, 2022 at 01:12:35PM +0200, Hans de Goede wrote:
> Some "T3 MRD" mini-PCs / HDMI-sticks without a battery use a different
> value then "5.11" for their DMI BIOS version field.
> 
> Drop the BIOS version check so that the no-battery "T3 MRD" DMI quirk
> applies to these too.
> 
> Fixes: 3a06b912a5ce ("power: supply: axp288_fuel_gauge: Make "T3 MRD" no_battery_list DMI entry more generic")
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---

Thanks, queued to my fixes branch.

-- Sebastian

>  drivers/power/supply/axp288_fuel_gauge.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/power/supply/axp288_fuel_gauge.c b/drivers/power/supply/axp288_fuel_gauge.c
> index 5b8aa4a980cd..8e6f8a655079 100644
> --- a/drivers/power/supply/axp288_fuel_gauge.c
> +++ b/drivers/power/supply/axp288_fuel_gauge.c
> @@ -609,7 +609,6 @@ static const struct dmi_system_id axp288_quirks[] = {
>  			DMI_MATCH(DMI_BOARD_NAME, "T3 MRD"),
>  			DMI_MATCH(DMI_CHASSIS_TYPE, "3"),
>  			DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."),
> -			DMI_MATCH(DMI_BIOS_VERSION, "5.11"),
>  		},
>  		.driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
>  	},
> -- 
> 2.36.0
> 

[-- 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-05-03 15:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-02 11:12 [PATCH 1/2] power: supply: axp288_fuel_gauge: Fix battery reporting on the One Mix 1 Hans de Goede
2022-05-02 11:12 ` [PATCH 2/2] power: supply: axp288_fuel_gauge: Drop BIOS version check from "T3 MRD" DMI quirk Hans de Goede
2022-05-03 15:35   ` Sebastian Reichel
2022-05-03 15:35 ` [PATCH 1/2] power: supply: axp288_fuel_gauge: Fix battery reporting on the One Mix 1 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.