2018-09-26 23:27:40 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2017-04-06 15:24:36 +08:00
|
|
|
/*
|
|
|
|
* Intel Cherry Trail ACPI INT33FE pseudo device driver
|
|
|
|
*
|
|
|
|
* Copyright (C) 2017 Hans de Goede <hdegoede@redhat.com>
|
|
|
|
*
|
|
|
|
* Some Intel Cherry Trail based device which ship with Windows 10, have
|
|
|
|
* this weird INT33FE ACPI device with a CRS table with 4 I2cSerialBusV2
|
2020-04-09 00:09:06 +08:00
|
|
|
* resources, for 4 different chips attached to various I²C buses:
|
|
|
|
* 1. The Whiskey Cove PMIC, which is also described by the INT34D3 ACPI device
|
2017-04-06 15:24:36 +08:00
|
|
|
* 2. Maxim MAX17047 Fuel Gauge Controller
|
|
|
|
* 3. FUSB302 USB Type-C Controller
|
|
|
|
* 4. PI3USB30532 USB switch
|
|
|
|
*
|
|
|
|
* So this driver is a stub / pseudo driver whose only purpose is to
|
2020-04-09 00:09:06 +08:00
|
|
|
* instantiate I²C clients for chips 2 - 4, so that standard I²C drivers
|
2017-04-06 15:24:36 +08:00
|
|
|
* for these chips can bind to the them.
|
|
|
|
*/
|
|
|
|
|
2022-02-07 06:02:18 +08:00
|
|
|
#include <linux/dmi.h>
|
2017-04-06 15:24:36 +08:00
|
|
|
#include <linux/i2c.h>
|
|
|
|
#include <linux/interrupt.h>
|
2019-05-31 22:15:46 +08:00
|
|
|
#include <linux/pci.h>
|
2018-10-17 16:59:28 +08:00
|
|
|
#include <linux/platform_device.h>
|
2020-04-09 00:09:03 +08:00
|
|
|
#include <linux/property.h>
|
2017-10-11 17:41:21 +08:00
|
|
|
#include <linux/regulator/consumer.h>
|
2017-04-06 15:24:36 +08:00
|
|
|
#include <linux/slab.h>
|
2019-05-31 22:15:45 +08:00
|
|
|
#include <linux/usb/pd.h>
|
2017-04-06 15:24:36 +08:00
|
|
|
|
2022-02-07 06:02:18 +08:00
|
|
|
struct cht_int33fe_data {
|
|
|
|
struct i2c_client *battery_fg;
|
|
|
|
struct i2c_client *fusb302;
|
|
|
|
struct i2c_client *pi3usb30532;
|
|
|
|
struct fwnode_handle *dp;
|
|
|
|
};
|
2017-04-06 15:24:36 +08:00
|
|
|
|
2017-09-03 00:20:40 +08:00
|
|
|
/*
|
2020-04-09 00:09:06 +08:00
|
|
|
* Grrr, I severely dislike buggy BIOS-es. At least one BIOS enumerates
|
2017-09-03 00:20:40 +08:00
|
|
|
* the max17047 both through the INT33FE ACPI device (it is right there
|
|
|
|
* in the resources table) as well as through a separate MAX17047 device.
|
|
|
|
*
|
2020-04-09 00:09:06 +08:00
|
|
|
* These helpers are used to work around this by checking if an I²C client
|
2017-09-03 00:20:40 +08:00
|
|
|
* for the max17047 has already been registered.
|
|
|
|
*/
|
2017-10-11 17:30:10 +08:00
|
|
|
static int cht_int33fe_check_for_max17047(struct device *dev, void *data)
|
2017-09-03 00:20:40 +08:00
|
|
|
{
|
|
|
|
struct i2c_client **max17047 = data;
|
|
|
|
struct acpi_device *adev;
|
|
|
|
|
|
|
|
adev = ACPI_COMPANION(dev);
|
|
|
|
if (!adev)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* The MAX17047 ACPI node doesn't have an UID, so we don't check that */
|
2020-04-09 00:09:05 +08:00
|
|
|
if (!acpi_dev_hid_uid_match(adev, "MAX17047", NULL))
|
2017-09-03 00:20:40 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
*max17047 = to_i2c_client(dev);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2017-05-26 18:53:48 +08:00
|
|
|
static const char * const max17047_suppliers[] = { "bq24190-charger" };
|
|
|
|
|
2020-04-09 00:09:03 +08:00
|
|
|
static const struct property_entry max17047_properties[] = {
|
2017-05-26 18:53:48 +08:00
|
|
|
PROPERTY_ENTRY_STRING_ARRAY("supplied-from", max17047_suppliers),
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2020-04-09 00:09:03 +08:00
|
|
|
static const struct software_node max17047_node = {
|
|
|
|
.name = "max17047",
|
|
|
|
.properties = max17047_properties,
|
|
|
|
};
|
|
|
|
|
2019-11-08 12:22:23 +08:00
|
|
|
/*
|
|
|
|
* We are not using inline property here because those are constant,
|
|
|
|
* and we need to adjust this one at runtime to point to real
|
|
|
|
* software node.
|
|
|
|
*/
|
|
|
|
static struct software_node_ref_args fusb302_mux_refs[] = {
|
|
|
|
{ .node = NULL },
|
|
|
|
};
|
|
|
|
|
2020-04-09 00:09:03 +08:00
|
|
|
static const struct property_entry fusb302_properties[] = {
|
2018-11-15 21:16:19 +08:00
|
|
|
PROPERTY_ENTRY_STRING("linux,extcon-name", "cht_wcove_pwrsrc"),
|
2019-11-08 12:22:23 +08:00
|
|
|
PROPERTY_ENTRY_REF_ARRAY("usb-role-switch", fusb302_mux_refs),
|
2019-05-31 22:15:44 +08:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2020-04-09 00:09:03 +08:00
|
|
|
static const struct software_node fusb302_node = {
|
|
|
|
.name = "fusb302",
|
|
|
|
.properties = fusb302_properties,
|
|
|
|
};
|
|
|
|
|
2019-05-31 22:15:45 +08:00
|
|
|
#define PDO_FIXED_FLAGS \
|
|
|
|
(PDO_FIXED_DUAL_ROLE | PDO_FIXED_DATA_SWAP | PDO_FIXED_USB_COMM)
|
|
|
|
|
|
|
|
static const u32 src_pdo[] = {
|
|
|
|
PDO_FIXED(5000, 1500, PDO_FIXED_FLAGS),
|
|
|
|
};
|
|
|
|
|
|
|
|
static const u32 snk_pdo[] = {
|
|
|
|
PDO_FIXED(5000, 400, PDO_FIXED_FLAGS),
|
|
|
|
PDO_VAR(5000, 12000, 3000),
|
|
|
|
};
|
|
|
|
|
2020-04-09 00:09:03 +08:00
|
|
|
static const struct software_node pi3usb30532_node = {
|
|
|
|
.name = "pi3usb30532",
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct software_node displayport_node = {
|
|
|
|
.name = "displayport",
|
|
|
|
};
|
2019-11-08 12:22:23 +08:00
|
|
|
|
2020-04-09 00:09:03 +08:00
|
|
|
static const struct property_entry usb_connector_properties[] = {
|
2019-05-31 22:15:45 +08:00
|
|
|
PROPERTY_ENTRY_STRING("data-role", "dual"),
|
|
|
|
PROPERTY_ENTRY_STRING("power-role", "dual"),
|
|
|
|
PROPERTY_ENTRY_STRING("try-power-role", "sink"),
|
|
|
|
PROPERTY_ENTRY_U32_ARRAY("source-pdos", src_pdo),
|
|
|
|
PROPERTY_ENTRY_U32_ARRAY("sink-pdos", snk_pdo),
|
|
|
|
PROPERTY_ENTRY_U32("op-sink-microwatt", 2500000),
|
2020-04-09 00:09:03 +08:00
|
|
|
PROPERTY_ENTRY_REF("orientation-switch", &pi3usb30532_node),
|
|
|
|
PROPERTY_ENTRY_REF("mode-switch", &pi3usb30532_node),
|
|
|
|
PROPERTY_ENTRY_REF("displayport", &displayport_node),
|
2019-05-31 22:15:45 +08:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2020-04-09 00:09:03 +08:00
|
|
|
static const struct software_node usb_connector_node = {
|
|
|
|
.name = "connector",
|
|
|
|
.parent = &fusb302_node,
|
|
|
|
.properties = usb_connector_properties,
|
|
|
|
};
|
|
|
|
|
2021-04-09 21:40:33 +08:00
|
|
|
static const struct software_node altmodes_node = {
|
|
|
|
.name = "altmodes",
|
|
|
|
.parent = &usb_connector_node,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct property_entry dp_altmode_properties[] = {
|
|
|
|
PROPERTY_ENTRY_U32("svid", 0xff01),
|
|
|
|
PROPERTY_ENTRY_U32("vdo", 0x0c0086),
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct software_node dp_altmode_node = {
|
|
|
|
.name = "displayport-altmode",
|
|
|
|
.parent = &altmodes_node,
|
|
|
|
.properties = dp_altmode_properties,
|
|
|
|
};
|
|
|
|
|
2020-04-09 00:09:03 +08:00
|
|
|
static const struct software_node *node_group[] = {
|
|
|
|
&fusb302_node,
|
|
|
|
&max17047_node,
|
|
|
|
&pi3usb30532_node,
|
|
|
|
&displayport_node,
|
|
|
|
&usb_connector_node,
|
2021-04-09 21:40:33 +08:00
|
|
|
&altmodes_node,
|
|
|
|
&dp_altmode_node,
|
2020-04-09 00:09:03 +08:00
|
|
|
NULL
|
2017-10-11 17:41:21 +08:00
|
|
|
};
|
|
|
|
|
2019-05-31 22:15:46 +08:00
|
|
|
static int cht_int33fe_setup_dp(struct cht_int33fe_data *data)
|
|
|
|
{
|
|
|
|
struct fwnode_handle *fwnode;
|
|
|
|
struct pci_dev *pdev;
|
|
|
|
|
2020-04-09 00:09:03 +08:00
|
|
|
fwnode = software_node_fwnode(&displayport_node);
|
2019-05-31 22:15:46 +08:00
|
|
|
if (!fwnode)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
/* First let's find the GPU PCI device */
|
|
|
|
pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, NULL);
|
|
|
|
if (!pdev || pdev->vendor != PCI_VENDOR_ID_INTEL) {
|
|
|
|
pci_dev_put(pdev);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2021-05-03 23:46:47 +08:00
|
|
|
/* Then the DP-2 child device node */
|
|
|
|
data->dp = device_get_named_child_node(&pdev->dev, "DD04");
|
2019-05-31 22:15:46 +08:00
|
|
|
pci_dev_put(pdev);
|
|
|
|
if (!data->dp)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
fwnode->secondary = ERR_PTR(-ENODEV);
|
|
|
|
data->dp->secondary = fwnode;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cht_int33fe_remove_nodes(struct cht_int33fe_data *data)
|
|
|
|
{
|
2020-04-09 00:09:03 +08:00
|
|
|
software_node_unregister_node_group(node_group);
|
2019-05-31 22:15:46 +08:00
|
|
|
|
2019-11-08 12:22:23 +08:00
|
|
|
if (fusb302_mux_refs[0].node) {
|
2020-04-09 00:09:03 +08:00
|
|
|
fwnode_handle_put(software_node_fwnode(fusb302_mux_refs[0].node));
|
2019-11-08 12:22:23 +08:00
|
|
|
fusb302_mux_refs[0].node = NULL;
|
2019-05-31 22:15:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (data->dp) {
|
|
|
|
data->dp->secondary = NULL;
|
|
|
|
fwnode_handle_put(data->dp);
|
|
|
|
data->dp = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int cht_int33fe_add_nodes(struct cht_int33fe_data *data)
|
|
|
|
{
|
2019-11-08 12:22:23 +08:00
|
|
|
const struct software_node *mux_ref_node;
|
2019-05-31 22:15:46 +08:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
/*
|
2019-08-19 18:07:24 +08:00
|
|
|
* There is no ACPI device node for the USB role mux, so we need to wait
|
|
|
|
* until the mux driver has created software node for the mux device.
|
|
|
|
* It means we depend on the mux driver. This function will return
|
|
|
|
* -EPROBE_DEFER until the mux device is registered.
|
2019-05-31 22:15:46 +08:00
|
|
|
*/
|
2019-11-08 12:22:23 +08:00
|
|
|
mux_ref_node = software_node_find_by_name(NULL, "intel-xhci-usb-sw");
|
|
|
|
if (!mux_ref_node)
|
|
|
|
return -EPROBE_DEFER;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Update node used in "usb-role-switch" property. Note that we
|
2022-08-24 23:21:15 +08:00
|
|
|
* rely on software_node_register_node_group() to use the original
|
2019-11-08 12:22:23 +08:00
|
|
|
* instance of properties instead of copying them.
|
|
|
|
*/
|
|
|
|
fusb302_mux_refs[0].node = mux_ref_node;
|
|
|
|
|
2020-04-09 00:09:03 +08:00
|
|
|
ret = software_node_register_node_group(node_group);
|
2019-11-08 12:22:23 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* The devices that are not created in this driver need extra steps. */
|
2019-05-31 22:15:46 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The DP connector does have ACPI device node. In this case we can just
|
|
|
|
* find that ACPI node and assign our node as the secondary node to it.
|
|
|
|
*/
|
|
|
|
ret = cht_int33fe_setup_dp(data);
|
|
|
|
if (ret)
|
|
|
|
goto err_remove_nodes;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err_remove_nodes:
|
|
|
|
cht_int33fe_remove_nodes(data);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-05-31 22:15:42 +08:00
|
|
|
static int
|
|
|
|
cht_int33fe_register_max17047(struct device *dev, struct cht_int33fe_data *data)
|
|
|
|
{
|
|
|
|
struct i2c_client *max17047 = NULL;
|
|
|
|
struct i2c_board_info board_info;
|
2019-05-31 22:15:44 +08:00
|
|
|
struct fwnode_handle *fwnode;
|
2019-05-31 22:15:42 +08:00
|
|
|
int ret;
|
|
|
|
|
2020-04-09 00:09:03 +08:00
|
|
|
fwnode = software_node_fwnode(&max17047_node);
|
2019-05-31 22:15:44 +08:00
|
|
|
if (!fwnode)
|
|
|
|
return -ENODEV;
|
|
|
|
|
2019-05-31 22:15:42 +08:00
|
|
|
i2c_for_each_dev(&max17047, cht_int33fe_check_for_max17047);
|
|
|
|
if (max17047) {
|
2020-04-09 00:09:06 +08:00
|
|
|
/* Pre-existing I²C client for the max17047, add device properties */
|
2020-04-09 00:09:04 +08:00
|
|
|
set_secondary_fwnode(&max17047->dev, fwnode);
|
2020-04-09 00:09:06 +08:00
|
|
|
/* And re-probe to get the new device properties applied */
|
2019-05-31 22:15:42 +08:00
|
|
|
ret = device_reprobe(&max17047->dev);
|
|
|
|
if (ret)
|
|
|
|
dev_warn(dev, "Reprobing max17047 error: %d\n", ret);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&board_info, 0, sizeof(board_info));
|
2022-08-19 05:00:57 +08:00
|
|
|
strscpy(board_info.type, "max17047", I2C_NAME_SIZE);
|
2019-05-31 22:15:42 +08:00
|
|
|
board_info.dev_name = "max17047";
|
2019-05-31 22:15:44 +08:00
|
|
|
board_info.fwnode = fwnode;
|
2019-10-06 04:42:55 +08:00
|
|
|
data->battery_fg = i2c_acpi_new_device(dev, 1, &board_info);
|
2019-05-31 22:15:42 +08:00
|
|
|
|
2019-10-06 04:42:55 +08:00
|
|
|
return PTR_ERR_OR_ZERO(data->battery_fg);
|
2019-05-31 22:15:42 +08:00
|
|
|
}
|
|
|
|
|
2022-02-07 06:02:18 +08:00
|
|
|
static const struct dmi_system_id cht_int33fe_typec_ids[] = {
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* GPD win / GPD pocket mini laptops
|
|
|
|
*
|
|
|
|
* This DMI match may not seem unique, but it is. In the 67000+
|
|
|
|
* DMI decode dumps from linux-hardware.org only 116 have
|
|
|
|
* board_vendor set to "AMI Corporation" and of those 116 only
|
|
|
|
* the GPD win's and pocket's board_name is "Default string".
|
|
|
|
*/
|
|
|
|
.matches = {
|
|
|
|
DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
|
|
|
|
DMI_EXACT_MATCH(DMI_BOARD_NAME, "Default string"),
|
|
|
|
DMI_EXACT_MATCH(DMI_BOARD_SERIAL, "Default string"),
|
|
|
|
DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Default string"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(dmi, cht_int33fe_typec_ids);
|
|
|
|
|
|
|
|
static int cht_int33fe_typec_probe(struct platform_device *pdev)
|
2017-04-06 15:24:36 +08:00
|
|
|
{
|
|
|
|
struct i2c_board_info board_info;
|
2022-02-07 06:02:18 +08:00
|
|
|
struct device *dev = &pdev->dev;
|
|
|
|
struct cht_int33fe_data *data;
|
2019-05-31 22:15:44 +08:00
|
|
|
struct fwnode_handle *fwnode;
|
2017-10-11 17:41:21 +08:00
|
|
|
struct regulator *regulator;
|
2017-04-06 15:24:36 +08:00
|
|
|
int fusb302_irq;
|
2017-09-03 00:20:40 +08:00
|
|
|
int ret;
|
2017-04-06 15:24:36 +08:00
|
|
|
|
2022-02-07 06:02:18 +08:00
|
|
|
if (!dmi_check_system(cht_int33fe_typec_ids))
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
|
|
|
|
if (!data)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2017-10-11 17:41:21 +08:00
|
|
|
/*
|
|
|
|
* We expect the WC PMIC to be paired with a TI bq24292i charger-IC.
|
|
|
|
* We check for the bq24292i vbus regulator here, this has 2 purposes:
|
|
|
|
* 1) The bq24292i allows charging with up to 12V, setting the fusb302's
|
|
|
|
* max-snk voltage to 12V with another charger-IC is not good.
|
|
|
|
* 2) For the fusb302 driver to get the bq24292i vbus regulator, the
|
|
|
|
* regulator-map, which is part of the bq24292i regulator_init_data,
|
|
|
|
* must be registered before the fusb302 is instantiated, otherwise
|
|
|
|
* it will end up with a dummy-regulator.
|
|
|
|
* Note "cht_wc_usb_typec_vbus" comes from the regulator_init_data
|
2020-04-09 00:09:06 +08:00
|
|
|
* which is defined in i2c-cht-wc.c from where the bq24292i I²C client
|
2017-10-11 17:41:21 +08:00
|
|
|
* gets instantiated. We use regulator_get_optional here so that we
|
|
|
|
* don't end up getting a dummy-regulator ourselves.
|
|
|
|
*/
|
|
|
|
regulator = regulator_get_optional(dev, "cht_wc_usb_typec_vbus");
|
|
|
|
if (IS_ERR(regulator)) {
|
|
|
|
ret = PTR_ERR(regulator);
|
|
|
|
return (ret == -ENODEV) ? -EPROBE_DEFER : ret;
|
|
|
|
}
|
|
|
|
regulator_put(regulator);
|
|
|
|
|
2020-04-09 00:09:06 +08:00
|
|
|
/* The FUSB302 uses the IRQ at index 1 and is the only IRQ user */
|
2017-04-06 15:24:36 +08:00
|
|
|
fusb302_irq = acpi_dev_gpio_irq_get(ACPI_COMPANION(dev), 1);
|
|
|
|
if (fusb302_irq < 0) {
|
|
|
|
if (fusb302_irq != -EPROBE_DEFER)
|
|
|
|
dev_err(dev, "Error getting FUSB302 irq\n");
|
|
|
|
return fusb302_irq;
|
|
|
|
}
|
|
|
|
|
2019-05-31 22:15:46 +08:00
|
|
|
ret = cht_int33fe_add_nodes(data);
|
2019-05-31 22:15:44 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2020-04-09 00:09:06 +08:00
|
|
|
/* Work around BIOS bug, see comment on cht_int33fe_check_for_max17047() */
|
2019-05-31 22:15:42 +08:00
|
|
|
ret = cht_int33fe_register_max17047(dev, data);
|
|
|
|
if (ret)
|
2019-05-31 22:15:44 +08:00
|
|
|
goto out_remove_nodes;
|
2017-04-06 15:24:36 +08:00
|
|
|
|
2020-04-09 00:09:03 +08:00
|
|
|
fwnode = software_node_fwnode(&fusb302_node);
|
2019-05-31 22:15:44 +08:00
|
|
|
if (!fwnode) {
|
|
|
|
ret = -ENODEV;
|
|
|
|
goto out_unregister_max17047;
|
|
|
|
}
|
|
|
|
|
2017-04-06 15:24:36 +08:00
|
|
|
memset(&board_info, 0, sizeof(board_info));
|
2022-08-19 05:00:57 +08:00
|
|
|
strscpy(board_info.type, "typec_fusb302", I2C_NAME_SIZE);
|
2017-10-11 17:41:21 +08:00
|
|
|
board_info.dev_name = "fusb302";
|
2019-05-31 22:15:44 +08:00
|
|
|
board_info.fwnode = fwnode;
|
2017-04-06 15:24:36 +08:00
|
|
|
board_info.irq = fusb302_irq;
|
|
|
|
|
|
|
|
data->fusb302 = i2c_acpi_new_device(dev, 2, &board_info);
|
2018-11-28 19:45:26 +08:00
|
|
|
if (IS_ERR(data->fusb302)) {
|
2018-11-28 19:45:22 +08:00
|
|
|
ret = PTR_ERR(data->fusb302);
|
2017-04-06 15:24:36 +08:00
|
|
|
goto out_unregister_max17047;
|
2018-11-28 19:45:26 +08:00
|
|
|
}
|
2017-04-06 15:24:36 +08:00
|
|
|
|
2020-04-09 00:09:03 +08:00
|
|
|
fwnode = software_node_fwnode(&pi3usb30532_node);
|
2019-05-31 22:15:44 +08:00
|
|
|
if (!fwnode) {
|
|
|
|
ret = -ENODEV;
|
|
|
|
goto out_unregister_fusb302;
|
|
|
|
}
|
|
|
|
|
2017-04-06 15:24:36 +08:00
|
|
|
memset(&board_info, 0, sizeof(board_info));
|
2017-10-11 17:41:21 +08:00
|
|
|
board_info.dev_name = "pi3usb30532";
|
2019-05-31 22:15:44 +08:00
|
|
|
board_info.fwnode = fwnode;
|
2022-08-19 05:00:57 +08:00
|
|
|
strscpy(board_info.type, "pi3usb30532", I2C_NAME_SIZE);
|
2017-04-06 15:24:36 +08:00
|
|
|
|
|
|
|
data->pi3usb30532 = i2c_acpi_new_device(dev, 3, &board_info);
|
2018-11-28 19:45:26 +08:00
|
|
|
if (IS_ERR(data->pi3usb30532)) {
|
2018-11-28 19:45:22 +08:00
|
|
|
ret = PTR_ERR(data->pi3usb30532);
|
2017-04-06 15:24:36 +08:00
|
|
|
goto out_unregister_fusb302;
|
2018-11-28 19:45:26 +08:00
|
|
|
}
|
2017-04-06 15:24:36 +08:00
|
|
|
|
2022-05-19 20:21:03 +08:00
|
|
|
platform_set_drvdata(pdev, data);
|
|
|
|
|
2017-04-06 15:24:36 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
out_unregister_fusb302:
|
|
|
|
i2c_unregister_device(data->fusb302);
|
|
|
|
|
|
|
|
out_unregister_max17047:
|
2019-10-06 04:42:55 +08:00
|
|
|
i2c_unregister_device(data->battery_fg);
|
2017-04-06 15:24:36 +08:00
|
|
|
|
2019-05-31 22:15:44 +08:00
|
|
|
out_remove_nodes:
|
2019-05-31 22:15:46 +08:00
|
|
|
cht_int33fe_remove_nodes(data);
|
2019-05-31 22:15:44 +08:00
|
|
|
|
2018-11-28 19:45:22 +08:00
|
|
|
return ret;
|
2017-04-06 15:24:36 +08:00
|
|
|
}
|
|
|
|
|
2022-02-07 06:02:18 +08:00
|
|
|
static int cht_int33fe_typec_remove(struct platform_device *pdev)
|
2017-04-06 15:24:36 +08:00
|
|
|
{
|
2022-02-07 06:02:18 +08:00
|
|
|
struct cht_int33fe_data *data = platform_get_drvdata(pdev);
|
|
|
|
|
2017-04-06 15:24:36 +08:00
|
|
|
i2c_unregister_device(data->pi3usb30532);
|
|
|
|
i2c_unregister_device(data->fusb302);
|
2019-10-06 04:42:55 +08:00
|
|
|
i2c_unregister_device(data->battery_fg);
|
2017-04-06 15:24:36 +08:00
|
|
|
|
2019-05-31 22:15:46 +08:00
|
|
|
cht_int33fe_remove_nodes(data);
|
2018-03-20 20:57:12 +08:00
|
|
|
|
2017-04-06 15:24:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-02-07 06:02:18 +08:00
|
|
|
|
|
|
|
static const struct acpi_device_id cht_int33fe_acpi_ids[] = {
|
|
|
|
{ "INT33FE", },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct platform_driver cht_int33fe_typec_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "Intel Cherry Trail ACPI INT33FE Type-C driver",
|
|
|
|
.acpi_match_table = ACPI_PTR(cht_int33fe_acpi_ids),
|
|
|
|
},
|
|
|
|
.probe = cht_int33fe_typec_probe,
|
|
|
|
.remove = cht_int33fe_typec_remove,
|
|
|
|
};
|
|
|
|
|
|
|
|
module_platform_driver(cht_int33fe_typec_driver);
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("Intel Cherry Trail ACPI INT33FE Type-C pseudo device driver");
|
|
|
|
MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>");
|
|
|
|
MODULE_LICENSE("GPL v2");
|