diff mbox series

[v2,1/3] usb: chipidea: imx: improve logic if samsung,picophy-* parameter is 0

Message ID 20230627112126.1882666-1-xu.yang_2@nxp.com (mailing list archive)
State Accepted
Commit 36668515d56bf73f06765c71e08c8f7465f1e5c4
Headers show
Series [v2,1/3] usb: chipidea: imx: improve logic if samsung,picophy-* parameter is 0 | expand

Commit Message

Xu Yang June 27, 2023, 11:21 a.m. UTC
In current driver, the value of tuning parameter will not take effect
if samsung,picophy-* is assigned as 0. Because 0 is also a valid value
acccording to the description of USB_PHY_CFG1 register, this will improve
the logic to let it work.

Fixes: 58a3cefb3840 ("usb: chipidea: imx: add two samsung picophy parameters tuning implementation")
cc: <stable@vger.kernel.org>
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>

---
Changes in v2:
 - no change
---
 drivers/usb/chipidea/ci_hdrc_imx.c | 10 ++++++----
 drivers/usb/chipidea/usbmisc_imx.c |  6 ++++--
 2 files changed, 10 insertions(+), 6 deletions(-)

Comments

Peter Chen July 10, 2023, 3:03 a.m. UTC | #1
On 23-06-27 19:21:24, Xu Yang wrote:
> In current driver, the value of tuning parameter will not take effect
> if samsung,picophy-* is assigned as 0. Because 0 is also a valid value
> acccording to the description of USB_PHY_CFG1 register, this will improve
> the logic to let it work.
> 
> Fixes: 58a3cefb3840 ("usb: chipidea: imx: add two samsung picophy parameters tuning implementation")
> cc: <stable@vger.kernel.org>
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>

Acked-by: Peter Chen <peter.chen@kernel.org>

Peter

> 
> ---
> Changes in v2:
>  - no change
> ---
>  drivers/usb/chipidea/ci_hdrc_imx.c | 10 ++++++----
>  drivers/usb/chipidea/usbmisc_imx.c |  6 ++++--
>  2 files changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
> index 336ef6dd8e7d..873539f9a2c0 100644
> --- a/drivers/usb/chipidea/ci_hdrc_imx.c
> +++ b/drivers/usb/chipidea/ci_hdrc_imx.c
> @@ -175,10 +175,12 @@ static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev)
>  	if (of_usb_get_phy_mode(np) == USBPHY_INTERFACE_MODE_ULPI)
>  		data->ulpi = 1;
>  
> -	of_property_read_u32(np, "samsung,picophy-pre-emp-curr-control",
> -			&data->emp_curr_control);
> -	of_property_read_u32(np, "samsung,picophy-dc-vol-level-adjust",
> -			&data->dc_vol_level_adjust);
> +	if (of_property_read_u32(np, "samsung,picophy-pre-emp-curr-control",
> +			&data->emp_curr_control))
> +		data->emp_curr_control = -1;
> +	if (of_property_read_u32(np, "samsung,picophy-dc-vol-level-adjust",
> +			&data->dc_vol_level_adjust))
> +		data->dc_vol_level_adjust = -1;
>  
>  	return data;
>  }
> diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c
> index 9ee9621e2ccc..1c7932f22218 100644
> --- a/drivers/usb/chipidea/usbmisc_imx.c
> +++ b/drivers/usb/chipidea/usbmisc_imx.c
> @@ -659,13 +659,15 @@ static int usbmisc_imx7d_init(struct imx_usbmisc_data *data)
>  			usbmisc->base + MX7D_USBNC_USB_CTRL2);
>  		/* PHY tuning for signal quality */
>  		reg = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG1);
> -		if (data->emp_curr_control && data->emp_curr_control <=
> +		if (data->emp_curr_control >= 0 &&
> +			data->emp_curr_control <=
>  			(TXPREEMPAMPTUNE0_MASK >> TXPREEMPAMPTUNE0_BIT)) {
>  			reg &= ~TXPREEMPAMPTUNE0_MASK;
>  			reg |= (data->emp_curr_control << TXPREEMPAMPTUNE0_BIT);
>  		}
>  
> -		if (data->dc_vol_level_adjust && data->dc_vol_level_adjust <=
> +		if (data->dc_vol_level_adjust >= 0 &&
> +			data->dc_vol_level_adjust <=
>  			(TXVREFTUNE0_MASK >> TXVREFTUNE0_BIT)) {
>  			reg &= ~TXVREFTUNE0_MASK;
>  			reg |= (data->dc_vol_level_adjust << TXVREFTUNE0_BIT);
> -- 
> 2.34.1
>
diff mbox series

Patch

diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
index 336ef6dd8e7d..873539f9a2c0 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -175,10 +175,12 @@  static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev)
 	if (of_usb_get_phy_mode(np) == USBPHY_INTERFACE_MODE_ULPI)
 		data->ulpi = 1;
 
-	of_property_read_u32(np, "samsung,picophy-pre-emp-curr-control",
-			&data->emp_curr_control);
-	of_property_read_u32(np, "samsung,picophy-dc-vol-level-adjust",
-			&data->dc_vol_level_adjust);
+	if (of_property_read_u32(np, "samsung,picophy-pre-emp-curr-control",
+			&data->emp_curr_control))
+		data->emp_curr_control = -1;
+	if (of_property_read_u32(np, "samsung,picophy-dc-vol-level-adjust",
+			&data->dc_vol_level_adjust))
+		data->dc_vol_level_adjust = -1;
 
 	return data;
 }
diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c
index 9ee9621e2ccc..1c7932f22218 100644
--- a/drivers/usb/chipidea/usbmisc_imx.c
+++ b/drivers/usb/chipidea/usbmisc_imx.c
@@ -659,13 +659,15 @@  static int usbmisc_imx7d_init(struct imx_usbmisc_data *data)
 			usbmisc->base + MX7D_USBNC_USB_CTRL2);
 		/* PHY tuning for signal quality */
 		reg = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG1);
-		if (data->emp_curr_control && data->emp_curr_control <=
+		if (data->emp_curr_control >= 0 &&
+			data->emp_curr_control <=
 			(TXPREEMPAMPTUNE0_MASK >> TXPREEMPAMPTUNE0_BIT)) {
 			reg &= ~TXPREEMPAMPTUNE0_MASK;
 			reg |= (data->emp_curr_control << TXPREEMPAMPTUNE0_BIT);
 		}
 
-		if (data->dc_vol_level_adjust && data->dc_vol_level_adjust <=
+		if (data->dc_vol_level_adjust >= 0 &&
+			data->dc_vol_level_adjust <=
 			(TXVREFTUNE0_MASK >> TXVREFTUNE0_BIT)) {
 			reg &= ~TXVREFTUNE0_MASK;
 			reg |= (data->dc_vol_level_adjust << TXVREFTUNE0_BIT);