// SPDX-License-Identifier: GPL-2.0 /* * 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 * 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 * 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 * instantiate I²C clients for chips 2 - 4, so that standard I²C drivers * for these chips can bind to the them.
*/
/* * Grrr, I severely dislike buggy BIOS-es. At least one BIOS enumerates * the max17047 both through the INT33FE ACPI device (it is right there * in the resources table) as well as through a separate MAX17047 device. * * These helpers are used to work around this by checking if an I²C client * for the max17047 has already been registered.
*/ staticint cht_int33fe_check_for_max17047(struct device *dev, void *data)
{ 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 */ if (!acpi_dev_hid_uid_match(adev, "MAX17047", NULL)) return 0;
/* * 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.
*/ staticstruct software_node_ref_args fusb302_mux_refs[] = {
{ .node = NULL },
};
staticint cht_int33fe_add_nodes(struct cht_int33fe_data *data)
{ conststruct software_node *mux_ref_node; int ret;
/* * 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.
*/
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 * rely on software_node_register_node_group() to use the original * instance of properties instead of copying them.
*/
fusb302_mux_refs[0].node = mux_ref_node;
ret = software_node_register_node_group(node_group); if (ret) return ret;
/* The devices that are not created in this driver need extra steps. */
/* * 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;
fwnode = software_node_fwnode(&max17047_node); if (!fwnode) return -ENODEV;
i2c_for_each_dev(&max17047, cht_int33fe_check_for_max17047); if (max17047) { /* Pre-existing I²C client for the max17047, add device properties */
set_secondary_fwnode(&max17047->dev, fwnode); /* And re-probe to get the new device properties applied */
ret = device_reprobe(&max17047->dev); if (ret)
dev_warn(dev, "Reprobing max17047 error: %d\n", ret); return 0;
}
staticconststruct 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);
if (!dmi_check_system(cht_int33fe_typec_ids)) return -ENODEV;
data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM;
/* * 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 * which is defined in i2c-cht-wc.c from where the bq24292i I²C client * 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);
/* The FUSB302 uses the IRQ at index 1 and is the only IRQ user */
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;
}
ret = cht_int33fe_add_nodes(data); if (ret) return ret;
/* Work around BIOS bug, see comment on cht_int33fe_check_for_max17047() */
ret = cht_int33fe_register_max17047(dev, data); if (ret) goto out_remove_nodes;
fwnode = software_node_fwnode(&fusb302_node); if (!fwnode) {
ret = -ENODEV; goto out_unregister_max17047;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.