Commit bb22fc51 authored by Hans de Goede's avatar Hans de Goede

platform/x86: intel_cht_int33fe: Drop Lenovo Yogabook YB1-X9x code

Move the Lenovo Yogabook YB1-X9x fuel-gauge instantiation code over to
the x86-android-tablets module, which already deals with this for various
other devices.

This removes the need to have a special intel_cht_int33fe_microb module
just for Lenovo Yogabook YB1-X9x laptops.
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20220206220220.88491-3-hdegoede@redhat.com
parent 915623a8
......@@ -6,19 +6,15 @@ config INTEL_CHT_INT33FE
depends on USB_ROLES_INTEL_XHCI=y || (USB_ROLES_INTEL_XHCI=m && m)
depends on TYPEC_MUX_PI3USB30532=y || (TYPEC_MUX_PI3USB30532=m && m)
help
This driver add support for the INT33FE ACPI device found on
some Intel Cherry Trail devices.
This driver add support for the INT33FE ACPI device found on the
GPD win and the GPD pocket.
There are two kinds of INT33FE ACPI device possible: for hardware
with USB Type-C and Micro-B connectors. This driver supports both.
The INT33FE ACPI device has a CRS table with I2cSerialBusV2
resources for Fuel Gauge Controller and (in the Type-C variant)
FUSB302 USB Type-C Controller and PI3USB30532 USB switch.
The INT33FE ACPI device on these mini laptops contains I2cSerialBusV2
resources for a MAX17042 Fuel Gauge, FUSB302 USB Type-C Controller
and PI3USB30532 USB switch.
This driver instantiates i2c-clients for these, so that standard
i2c drivers for these chips can bind to the them.
If you enable this driver it is advised to also select
CONFIG_BATTERY_BQ27XXX=m or CONFIG_BATTERY_BQ27XXX_I2C=m for Micro-B
device and CONFIG_TYPEC_FUSB302=m and CONFIG_BATTERY_MAX17042=m
for Type-C device.
CONFIG_TYPEC_FUSB302=m, CONFIG_TYPEC_MUX_PI3USB30532=m and
CONFIG_BATTERY_MAX17042=m.
# SPDX-License-Identifier: GPL-2.0-only
obj-$(CONFIG_INTEL_CHT_INT33FE) += intel_cht_int33fe_typec.o intel_cht_int33fe_microb.o
obj-$(CONFIG_INTEL_CHT_INT33FE) += intel_cht_int33fe_typec.o
// SPDX-License-Identifier: GPL-2.0
/*
* Intel Cherry Trail ACPI INT33FE pseudo device driver for devices with
* USB Micro-B connector (e.g. without of FUSB302 USB Type-C controller)
*
* Copyright (C) 2019 Yauhen Kharuzhy <jekhor@gmail.com>
*
* At least one Intel Cherry Trail based device which ship with Windows 10
* (Lenovo YogaBook YB1-X91L/F tablet), have this weird INT33FE ACPI device
* with a CRS table with 2 I2cSerialBusV2 resources, for 2 different chips
* attached to various i2c busses:
* 1. The Whiskey Cove PMIC, which is also described by the INT34D3 ACPI device
* 2. TI BQ27542 Fuel Gauge Controller
*
* So this driver is a stub / pseudo driver whose only purpose is to
* instantiate i2c-client for battery fuel gauge, so that standard i2c driver
* for these chip can bind to the it.
*/
#include <linux/acpi.h>
#include <linux/dmi.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/platform_device.h>
#include <linux/regulator/consumer.h>
#include <linux/slab.h>
#include <linux/usb/pd.h>
struct cht_int33fe_data {
struct i2c_client *battery_fg;
};
static const char * const bq27xxx_suppliers[] = { "bq25890-charger" };
static const struct property_entry bq27xxx_props[] = {
PROPERTY_ENTRY_STRING_ARRAY("supplied-from", bq27xxx_suppliers),
{ }
};
static const struct software_node bq27xxx_node = {
.properties = bq27xxx_props,
};
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 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));
board_info.dev_name = "bq27542";
board_info.swnode = &bq27xxx_node;
data->battery_fg = i2c_acpi_new_device(dev, 1, &board_info);
return PTR_ERR_OR_ZERO(data->battery_fg);
}
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");
......@@ -679,6 +679,25 @@ static const struct x86_dev_info czc_p10t __initconst = {
.init = czc_p10t_init,
};
/* Lenovo Yoga Book X90F / X91F / X91L need manual instantiation of the fg client */
static const struct x86_i2c_client_info lenovo_yogabook_x9x_i2c_clients[] __initconst = {
{
/* BQ27542 fuel-gauge */
.board_info = {
.type = "bq27542",
.addr = 0x55,
.dev_name = "bq27542",
.swnode = &fg_bq25890_supply_node,
},
.adapter_path = "\\_SB_.PCI0.I2C1",
},
};
static const struct x86_dev_info lenovo_yogabook_x9x_info __initconst = {
.i2c_client_info = lenovo_yogabook_x9x_i2c_clients,
.i2c_client_count = ARRAY_SIZE(lenovo_yogabook_x9x_i2c_clients),
};
/* Nextbook Ares 8 tablets have an Android factory img with everything hardcoded */
static const char * const nextbook_ares8_accel_mount_matrix[] = {
"0", "-1", "0",
......@@ -915,6 +934,14 @@ static const struct dmi_system_id x86_android_tablet_ids[] __initconst = {
},
.driver_data = (void *)&czc_p10t,
},
{
/* Lenovo Yoga Book X90F / X91F / X91L */
.matches = {
/* Non exact match to match all versions */
DMI_MATCH(DMI_PRODUCT_NAME, "Lenovo YB1-X9"),
},
.driver_data = (void *)&lenovo_yogabook_x9x_info,
},
{
/* Nextbook Ares 8 */
.matches = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment