Skip to content

Commit 96d5fb4

Browse files
committed
usb: typec: ucsi_ccg: Add OF support
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2122414 Upstream Status: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git Tested: Verify USB-A and USB-C are functional on Nvidia Orin board, and no regressions on other platforms. commit 6d9e066 Author: Wayne Chang <waynec@nvidia.com> Date: Tue Jan 31 17:57:45 2023 +0000 usb: typec: ucsi_ccg: Add OF support Add device-tree support for the Cypress CCG UCSI driver. The device-tree binding for the Cypress CCG device uses the standard device-tree 'firmware-name' string property to indicate the firmware build that is used. The NVIDIA GPU I2C driver has been updated to use an ACPI string property that is also named 'firmware-build' and given that this was the only users of the 'ccgx,firmware-build' property, we can now remove support for this legacy property. Signed-off-by: Wayne Chang <waynec@nvidia.com> Co-developed-by: Jon Hunter <jonathanh@nvidia.com> Signed-off-by: Jon Hunter <jonathanh@nvidia.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20230131175748.256423-4-jonathanh@nvidia.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit 6d9e066) Signed-off-by: David Marlin <dmarlin@redhat.com>
1 parent e191b17 commit 96d5fb4

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

drivers/usb/typec/ucsi/ucsi_ccg.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ static int ccg_request_irq(struct ucsi_ccg *uc)
643643
{
644644
unsigned long flags = IRQF_ONESHOT;
645645

646-
if (!has_acpi_companion(uc->dev))
646+
if (!dev_fwnode(uc->dev))
647647
flags |= IRQF_TRIGGER_HIGH;
648648

649649
return request_threaded_irq(uc->irq, NULL, ccg_irq_handler, flags, dev_name(uc->dev), uc);
@@ -1343,6 +1343,7 @@ static int ucsi_ccg_probe(struct i2c_client *client,
13431343
{
13441344
struct device *dev = &client->dev;
13451345
struct ucsi_ccg *uc;
1346+
const char *fw_name;
13461347
int status;
13471348

13481349
uc = devm_kzalloc(dev, sizeof(*uc), GFP_KERNEL);
@@ -1358,9 +1359,15 @@ static int ucsi_ccg_probe(struct i2c_client *client,
13581359
INIT_WORK(&uc->pm_work, ccg_pm_workaround_work);
13591360

13601361
/* Only fail FW flashing when FW build information is not provided */
1361-
status = device_property_read_u16(dev, "ccgx,firmware-build",
1362-
&uc->fw_build);
1363-
if (status)
1362+
status = device_property_read_string(dev, "firmware-name", &fw_name);
1363+
if (!status) {
1364+
if (!strcmp(fw_name, "nvidia,jetson-agx-xavier"))
1365+
uc->fw_build = CCG_FW_BUILD_NVIDIA_TEGRA;
1366+
else if (!strcmp(fw_name, "nvidia,gpu"))
1367+
uc->fw_build = CCG_FW_BUILD_NVIDIA;
1368+
}
1369+
1370+
if (!uc->fw_build)
13641371
dev_err(uc->dev, "failed to get FW build information\n");
13651372

13661373
/* reset ccg device and initialize ucsi */
@@ -1429,6 +1436,12 @@ static int ucsi_ccg_remove(struct i2c_client *client)
14291436
return 0;
14301437
}
14311438

1439+
static const struct of_device_id ucsi_ccg_of_match_table[] = {
1440+
{ .compatible = "cypress,cypd4226", },
1441+
{ /* sentinel */ }
1442+
};
1443+
MODULE_DEVICE_TABLE(of, ucsi_ccg_of_match_table);
1444+
14321445
static const struct i2c_device_id ucsi_ccg_device_id[] = {
14331446
{"ccgx-ucsi", 0},
14341447
{}
@@ -1483,6 +1496,7 @@ static struct i2c_driver ucsi_ccg_driver = {
14831496
.pm = &ucsi_ccg_pm,
14841497
.dev_groups = ucsi_ccg_groups,
14851498
.acpi_match_table = amd_i2c_ucsi_match,
1499+
.of_match_table = ucsi_ccg_of_match_table,
14861500
},
14871501
.probe = ucsi_ccg_probe,
14881502
.remove = ucsi_ccg_remove,

0 commit comments

Comments
 (0)