tegra: usb: phy: support for minus calib offset
Ken Chang [Mon, 17 Oct 2011 05:26:15 +0000 (13:26 +0800)]
need to support negative values for usb calibration.
change xcvr_setup_offset from unsigned to signed.

bug 872648

(cherry picked from commit 06258b46589436b5579c8265405b1cb286c406aa)
(reviewed on http://git-master/r/66101)

Change-Id: I1ab6a63184fe48bc734152546a541085ac7c6efc
Reviewed-on: http://git-master/r/74503
Reviewed-by: Simone Willett <swillett@nvidia.com>
Signed-off-by: Ken Chang <kenc@nvidia.com>
Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
Reviewed-on: http://git-master/r/76464
Reviewed-by: Automatic_Commit_Validation_User

arch/arm/mach-tegra/include/mach/usb_phy.h
arch/arm/mach-tegra/usb_phy.c

index 6e3a9f9..b5bf001 100644 (file)
@@ -29,7 +29,7 @@ struct tegra_utmip_config {
        u8 idle_wait_delay;
        u8 term_range_adj;
        u8 xcvr_setup;
-       u8 xcvr_setup_offset;
+       signed char xcvr_setup_offset;
        u8 xcvr_use_fuses;
        u8 xcvr_lsfslew;
        u8 xcvr_lsrslew;
index 197ede5..8c2990b 100644 (file)
 
 #define UTMIP_XCVR_MAX_OFFSET          2
 #define UTMIP_XCVR_SETUP_MAX_VALUE     0x7f
+#define UTMIP_XCVR_SETUP_MIN_VALUE     0
 #define XCVR_SETUP_MSB_CALIB(x)        ((x) >> 4)
 
 #define UTMIP_BIAS_CFG0                0x80c
 
 #define UTMIP_XCVR_MAX_OFFSET          2
 #define UTMIP_XCVR_SETUP_MAX_VALUE     0x7f
+#define UTMIP_XCVR_SETUP_MIN_VALUE     0
 #define XCVR_SETUP_MSB_CALIB(x)        ((x) >> 4)
 
 #define UTMIP_BIAS_CFG0                0x80c
@@ -961,7 +963,7 @@ static void utmip_phy_enable_trking_data(struct tegra_usb_phy *phy)
 
 static unsigned int tegra_phy_xcvr_setup_value(struct tegra_utmip_config *cfg)
 {
-       unsigned long val;
+       signed long val;
 
        if (cfg->xcvr_use_fuses) {
                val = FUSE_USB_CALIB_XCVR_SETUP(
@@ -973,12 +975,16 @@ static unsigned int tegra_phy_xcvr_setup_value(struct tegra_utmip_config *cfg)
                        val = UTMIP_XCVR_SETUP_MAX_VALUE;
                        pr_info("%s: reset XCVR_SETUP to max value\n",
                                 __func__);
+               } else if (val < UTMIP_XCVR_SETUP_MIN_VALUE) {
+                       val = UTMIP_XCVR_SETUP_MIN_VALUE;
+                       pr_info("%s: reset XCVR_SETUP to min value\n",
+                                __func__);
                }
        } else {
                val = cfg->xcvr_setup;
        }
 
-       return val;
+       return (unsigned int)val;
 }
 
 static int utmi_phy_power_on(struct tegra_usb_phy *phy, bool is_dpd)