• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Intel Cherry Trail ACPI INT33FE pseudo device driver for devices with
4  * USB Micro-B connector (e.g. without of FUSB302 USB Type-C controller)
5  *
6  * Copyright (C) 2019 Yauhen Kharuzhy <jekhor@gmail.com>
7  *
8  * At least one Intel Cherry Trail based device which ship with Windows 10
9  * (Lenovo YogaBook YB1-X91L/F tablet), have this weird INT33FE ACPI device
10  * with a CRS table with 2 I2cSerialBusV2 resources, for 2 different chips
11  * attached to various i2c busses:
12  * 1. The Whiskey Cove PMIC, which is also described by the INT34D3 ACPI device
13  * 2. TI BQ27542 Fuel Gauge Controller
14  *
15  * So this driver is a stub / pseudo driver whose only purpose is to
16  * instantiate i2c-client for battery fuel gauge, so that standard i2c driver
17  * for these chip can bind to the it.
18  */
19 
20 #include <linux/acpi.h>
21 #include <linux/i2c.h>
22 #include <linux/module.h>
23 #include <linux/pci.h>
24 #include <linux/platform_device.h>
25 #include <linux/regulator/consumer.h>
26 #include <linux/slab.h>
27 #include <linux/usb/pd.h>
28 
29 #include "intel_cht_int33fe_common.h"
30 
31 static const char * const bq27xxx_suppliers[] = { "bq25890-charger" };
32 
33 static const struct property_entry bq27xxx_props[] = {
34 	PROPERTY_ENTRY_STRING_ARRAY("supplied-from", bq27xxx_suppliers),
35 	{ }
36 };
37 
cht_int33fe_microb_probe(struct cht_int33fe_data * data)38 int cht_int33fe_microb_probe(struct cht_int33fe_data *data)
39 {
40 	struct device *dev = data->dev;
41 	struct i2c_board_info board_info;
42 
43 	memset(&board_info, 0, sizeof(board_info));
44 	strscpy(board_info.type, "bq27542", ARRAY_SIZE(board_info.type));
45 	board_info.dev_name = "bq27542";
46 	board_info.properties = bq27xxx_props;
47 	data->battery_fg = i2c_acpi_new_device(dev, 1, &board_info);
48 
49 	return PTR_ERR_OR_ZERO(data->battery_fg);
50 }
51 
cht_int33fe_microb_remove(struct cht_int33fe_data * data)52 int cht_int33fe_microb_remove(struct cht_int33fe_data *data)
53 {
54 	i2c_unregister_device(data->battery_fg);
55 
56 	return 0;
57 }
58