aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/intel/int33fe/intel_cht_int33fe_microb.c
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2022-02-06 23:02:18 +0100
committerHans de Goede <hdegoede@redhat.com>2022-02-11 10:52:56 +0100
commit915623a80b5a0e4f214197519740c0faa297f6d8 (patch)
tree3b5e94c0e5b39875c0ca6a6d3db6f83a834dc12f /drivers/platform/x86/intel/int33fe/intel_cht_int33fe_microb.c
parentplatform/x86: x86-android-tablets: Minor charger / fuel-gauge improvements (diff)
downloadlinux-dev-915623a80b5a0e4f214197519740c0faa297f6d8.tar.xz
linux-dev-915623a80b5a0e4f214197519740c0faa297f6d8.zip
platform/x86: intel_cht_int33fe: Switch to DMI modalias based loading
The intel_cht_int33fe driver is intended to deal with ACPI INT33FE firmware-nodes on Cherry Trail devices with a Whiskey Cove PMIC. The original version of the driver only dealt with the GPD win and GPD pocket boards where the WC PMIC is connected to a TI BQ24292i charger, paired with a Maxim MAX17047 fuelgauge + a FUSB302 USB Type-C Controller + a PI3USB30532 USB switch, for a fully functional Type-C port. Later it was split into a Type-C and a Micro-B variant to deal with the Lenovo Yoga Book YB1-X90 / Lenovo Yoga Book YB1-X91 boards where the ACPI INT33FE firmware-node only describes the TI BQ27542 fuelgauge. Currently the driver differentiates between these 2 models by counting the number of I2cSerialBus resources in the firmware-node. There are a number of problems with this approach: 1. The driver autoloads based on the acpi:INT33FE modalias causing it to get loaded on almost all Bay Trail and Cherry Trail devices. It checks for the presence of a WC PMIC, so it won't bind but the loading still wastes time and memory. 2. Both code paths in the driver are really only designed for a single board and have harcoded various assumptions about these boards, if another design matching the current checks ever shows up the driver may end up doing something completely wrong. Avoid both issues by switching to using DMI based autoloading of the module, which has neither of these problems. Note this splits the previous intel_cht_int33fe kernel module into two modules: intel_cht_int33fe_typec and intel_cht_int33fe_microb, one for each model. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20220206220220.88491-2-hdegoede@redhat.com
Diffstat (limited to 'drivers/platform/x86/intel/int33fe/intel_cht_int33fe_microb.c')
-rw-r--r--drivers/platform/x86/intel/int33fe/intel_cht_int33fe_microb.c53
1 files changed, 49 insertions, 4 deletions
diff --git a/drivers/platform/x86/intel/int33fe/intel_cht_int33fe_microb.c b/drivers/platform/x86/intel/int33fe/intel_cht_int33fe_microb.c
index 673f41cd14b5..6c2feca8a06f 100644
--- a/drivers/platform/x86/intel/int33fe/intel_cht_int33fe_microb.c
+++ b/drivers/platform/x86/intel/int33fe/intel_cht_int33fe_microb.c
@@ -18,6 +18,7 @@
*/
#include <linux/acpi.h>
+#include <linux/dmi.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/pci.h>
@@ -26,7 +27,9 @@
#include <linux/slab.h>
#include <linux/usb/pd.h>
-#include "intel_cht_int33fe_common.h"
+struct cht_int33fe_data {
+ struct i2c_client *battery_fg;
+};
static const char * const bq27xxx_suppliers[] = { "bq25890-charger" };
@@ -39,10 +42,30 @@ static const struct software_node bq27xxx_node = {
.properties = bq27xxx_props,
};
-int cht_int33fe_microb_probe(struct cht_int33fe_data *data)
+static const struct dmi_system_id cht_int33fe_microb_ids[] = {
+ {
+ /* Lenovo Yoga Book X90F / X91F / X91L */
+ .matches = {
+ /* Non exact match to match all versions */
+ DMI_MATCH(DMI_PRODUCT_NAME, "Lenovo YB1-X9"),
+ },
+ },
+ { }
+};
+MODULE_DEVICE_TABLE(dmi, cht_int33fe_microb_ids);
+
+static int cht_int33fe_microb_probe(struct platform_device *pdev)
{
- struct device *dev = data->dev;
struct i2c_board_info board_info;
+ struct device *dev = &pdev->dev;
+ struct cht_int33fe_data *data;
+
+ if (!dmi_check_system(cht_int33fe_microb_ids))
+ return -ENODEV;
+
+ data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
+ if (!data)
+ return -ENOMEM;
memset(&board_info, 0, sizeof(board_info));
strscpy(board_info.type, "bq27542", ARRAY_SIZE(board_info.type));
@@ -53,9 +76,31 @@ int cht_int33fe_microb_probe(struct cht_int33fe_data *data)
return PTR_ERR_OR_ZERO(data->battery_fg);
}
-int cht_int33fe_microb_remove(struct cht_int33fe_data *data)
+static int cht_int33fe_microb_remove(struct platform_device *pdev)
{
+ struct cht_int33fe_data *data = platform_get_drvdata(pdev);
+
i2c_unregister_device(data->battery_fg);
return 0;
}
+
+static const struct acpi_device_id cht_int33fe_acpi_ids[] = {
+ { "INT33FE", },
+ { }
+};
+
+static struct platform_driver cht_int33fe_microb_driver = {
+ .driver = {
+ .name = "Intel Cherry Trail ACPI INT33FE micro-B driver",
+ .acpi_match_table = ACPI_PTR(cht_int33fe_acpi_ids),
+ },
+ .probe = cht_int33fe_microb_probe,
+ .remove = cht_int33fe_microb_remove,
+};
+
+module_platform_driver(cht_int33fe_microb_driver);
+
+MODULE_DESCRIPTION("Intel Cherry Trail ACPI INT33FE micro-B pseudo device driver");
+MODULE_AUTHOR("Yauhen Kharuzhy <jekhor@gmail.com>");
+MODULE_LICENSE("GPL v2");