diff mbox series

[v3,06/13] usb: typec: ucsi_ccg: Add cypress,firmware-build as a well-known regex

Message ID 20221114124053.1873316-7-waynec@nvidia.com
State New
Headers show
Series Enable USB host and device functions on Jetson | expand

Commit Message

Wayne Chang Nov. 14, 2022, 12:40 p.m. UTC
ccgx is refer to the cypress cypd4226 typec controller.
add cypress,firmware-build as a well-known regex.

16-bit value is not sufficient for descriptiva names.
Using string instead of u16 to make it more descriptive.

Signed-off-by: Wayne Chang <waynec@nvidia.com>
---
V2 -> V3:nothing has changed
V1 -> V2:new change added for adding cypress,firmware-build
 drivers/usb/typec/ucsi/ucsi_ccg.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Jon Hunter Nov. 17, 2022, 7:45 p.m. UTC | #1
On 14/11/2022 12:40, Wayne Chang wrote:
> ccgx is refer to the cypress cypd4226 typec controller.
> add cypress,firmware-build as a well-known regex.
> 
> 16-bit value is not sufficient for descriptiva names.
> Using string instead of u16 to make it more descriptive.
> 
> Signed-off-by: Wayne Chang <waynec@nvidia.com>
> ---
> V2 -> V3:nothing has changed
> V1 -> V2:new change added for adding cypress,firmware-build
>   drivers/usb/typec/ucsi/ucsi_ccg.c | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/usb/typec/ucsi/ucsi_ccg.c b/drivers/usb/typec/ucsi/ucsi_ccg.c
> index 139707a2f3d6..e412a457bbfc 100644
> --- a/drivers/usb/typec/ucsi/ucsi_ccg.c
> +++ b/drivers/usb/typec/ucsi/ucsi_ccg.c
> @@ -1343,6 +1343,7 @@ static int ucsi_ccg_probe(struct i2c_client *client,
>   {
>   	struct device *dev = &client->dev;
>   	struct ucsi_ccg *uc;
> +	const char *of_fw_build;
>   	int status;
>   
>   	uc = devm_kzalloc(dev, sizeof(*uc), GFP_KERNEL);
> @@ -1363,6 +1364,17 @@ static int ucsi_ccg_probe(struct i2c_client *client,
>   	if (status)
>   		dev_err(uc->dev, "failed to get FW build information\n");
>   
> +	status = device_property_read_string(dev, "cypress,firmware-build",
> +					  &of_fw_build);
> +	if (!status) {
> +		if (!strcmp(of_fw_build, "nvidia,jetson-agx-xavier"))
> +			uc->fw_build = CCG_FW_BUILD_NVIDIA_TEGRA;
> +		else if (!strcmp(of_fw_build, "nvidia,gpu"))
> +			uc->fw_build = CCG_FW_BUILD_NVIDIA;
> +	} else {
> +		dev_err(uc->dev, "failed to get FW build information\n");
> +	}
> +

Instead of having the 'else' clause above, we should just ...

  if (!uc->fw_build)
          dev_err(uc->dev, "failed to get FW build information\n");

It is possible that status == 0, but the fw_build is not 
recognised/supported and so 'uc->fw_build' is not set.

Jon
diff mbox series

Patch

diff --git a/drivers/usb/typec/ucsi/ucsi_ccg.c b/drivers/usb/typec/ucsi/ucsi_ccg.c
index 139707a2f3d6..e412a457bbfc 100644
--- a/drivers/usb/typec/ucsi/ucsi_ccg.c
+++ b/drivers/usb/typec/ucsi/ucsi_ccg.c
@@ -1343,6 +1343,7 @@  static int ucsi_ccg_probe(struct i2c_client *client,
 {
 	struct device *dev = &client->dev;
 	struct ucsi_ccg *uc;
+	const char *of_fw_build;
 	int status;
 
 	uc = devm_kzalloc(dev, sizeof(*uc), GFP_KERNEL);
@@ -1363,6 +1364,17 @@  static int ucsi_ccg_probe(struct i2c_client *client,
 	if (status)
 		dev_err(uc->dev, "failed to get FW build information\n");
 
+	status = device_property_read_string(dev, "cypress,firmware-build",
+					  &of_fw_build);
+	if (!status) {
+		if (!strcmp(of_fw_build, "nvidia,jetson-agx-xavier"))
+			uc->fw_build = CCG_FW_BUILD_NVIDIA_TEGRA;
+		else if (!strcmp(of_fw_build, "nvidia,gpu"))
+			uc->fw_build = CCG_FW_BUILD_NVIDIA;
+	} else {
+		dev_err(uc->dev, "failed to get FW build information\n");
+	}
+
 	/* reset ccg device and initialize ucsi */
 	status = ucsi_ccg_init(uc);
 	if (status < 0) {