[PATCH 5/6] usb: chipidea: usbmisc_imx: Add device tree properties for i.MX7 phy tuning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This adds support for configuring the remaining phy tuning options
from device tree. Some properties are already configurable, the
remaining properties are added following the same pattern.

Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 drivers/usb/chipidea/ci_hdrc_imx.c | 14 ++++++
 drivers/usb/chipidea/ci_hdrc_imx.h |  7 +++
 drivers/usb/chipidea/usbmisc_imx.c | 71 +++++++++++++++++++++++++++++-
 3 files changed, 90 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
index 9ffcecd3058c1..a7c8c0065b9b7 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -172,8 +172,22 @@ static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev)
 
 	of_property_read_u32(np, "samsung,picophy-pre-emp-curr-control",
 			&data->emp_curr_control);
+	of_property_read_u32(np, "samsung,picophy-usb-source-impedance-adjust",
+			&data->usb_source_impedance_adjust);
+	of_property_read_u32(np, "samsung,picophy-hs-rise-time-adjust",
+			&data->hs_transmitter_rise_time_adjust);
 	of_property_read_u32(np, "samsung,picophy-dc-vol-level-adjust",
 			&data->dc_vol_level_adjust);
+	of_property_read_u32(np, "samsung,picophy-fs-ls-source-impedance-adjust",
+			&data->fs_ls_source_impedance_adjust);
+	of_property_read_u32(np, "samsung,picophy-transmitter-hs-crossover-adjust",
+			&data->transmitter_hs_crossover_adjust);
+	of_property_read_u32(np, "samsung,picophy-vbus-valid-threshold-adjust",
+			&data->vbus_valid_threshold_adjust);
+	of_property_read_u32(np, "samsung,picophy-squelsh-threshold-adjust",
+			&data->squelsh_threshold_adjust);
+	of_property_read_u32(np, "samsung,picophy-disconnect-threshold-adjust",
+			&data->disconnect_threshold_adjust);
 
 	return data;
 }
diff --git a/drivers/usb/chipidea/ci_hdrc_imx.h b/drivers/usb/chipidea/ci_hdrc_imx.h
index 7daccb9c5006a..c38f4746d6903 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.h
+++ b/drivers/usb/chipidea/ci_hdrc_imx.h
@@ -27,7 +27,14 @@ struct imx_usbmisc_data {
 	struct usb_phy *usb_phy;
 	enum usb_dr_mode available_role; /* runtime usb dr mode */
 	int emp_curr_control;
+	int hs_transmitter_rise_time_adjust;
 	int dc_vol_level_adjust;
+	int usb_source_impedance_adjust;
+	int fs_ls_source_impedance_adjust;
+	int transmitter_hs_crossover_adjust;
+	int vbus_valid_threshold_adjust;
+	int squelsh_threshold_adjust;
+	int disconnect_threshold_adjust;
 };
 
 int imx_usbmisc_init(struct imx_usbmisc_data *data);
diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c
index 63de7d6fea427..23dea390bf99b 100644
--- a/drivers/usb/chipidea/usbmisc_imx.c
+++ b/drivers/usb/chipidea/usbmisc_imx.c
@@ -126,8 +126,19 @@
 #define MX7D_USB_OTG_PHY_STATUS_CHRGDET		BIT(29)
 
 #define MX7D_USB_OTG_PHY_CFG1		0x30
-#define MX7D_USB_OTG_PHY_CFG1_TXPREEMPAMPTUNE0	GENMASK(29, 28)
-#define MX7D_USB_OTG_PHY_CFG1_TXVREFTUNE0	GENMASK(23, 20)
+#define MX7D_USB_OTG_PHY_CFG1_CHRGDET_MEGAMIX		BIT(31)
+#define MX7D_USB_OTG_PHY_CFG1_TXPREEMPPULSETUNE0	BIT(30)
+#define MX7D_USB_OTG_PHY_CFG1_TXPREEMPAMPTUNE0		GENMASK(29, 28)
+#define MX7D_USB_OTG_PHY_CFG1_TXRESTUNE0		GENMASK(27, 26)
+#define MX7D_USB_OTG_PHY_CFG1_TXRISETUNE0		GENMASK(25, 24)
+#define MX7D_USB_OTG_PHY_CFG1_TXVREFTUNE0		GENMASK(23, 20)
+#define MX7D_USB_OTG_PHY_CFG1_TXFSLSTUNE0		GENMASK(19, 16)
+#define MX7D_USB_OTG_PHY_CFG1_TXHSXVTUNE0		GENMASK(14, 13)
+#define MX7D_USB_OTG_PHY_CFG1_OTGTUNE0			GENMASK(12, 10)
+#define MX7D_USB_OTG_PHY_CFG1_SQRTUNE0			GENMASK(9, 7)
+#define MX7D_USB_OTG_PHY_CFG1_COMPDISTUNE0		GENMASK(6, 4)
+#define MX7D_USB_OTG_PHY_CFG1_FSEL			GENMASK(3, 1)
+#define MX7D_USB_OTG_PHY_CFG1_COMMONONN			BIT(0)
 
 #define MX6_USB_OTG_WAKEUP_BITS (MX6_BM_WAKEUP_ENABLE | MX6_BM_VBUS_WAKEUP | \
 				 MX6_BM_ID_WAKEUP)
@@ -666,6 +677,22 @@ static int usbmisc_imx7d_init(struct imx_usbmisc_data *data)
 					  data->emp_curr_control);
 		}
 
+		if (data->usb_source_impedance_adjust &&
+		    FIELD_FIT(MX7D_USB_OTG_PHY_CFG1_TXRESTUNE0,
+			      data->usb_source_impedance_adjust)) {
+			reg &= ~MX7D_USB_OTG_PHY_CFG1_TXRESTUNE0;
+			reg |= FIELD_PREP(MX7D_USB_OTG_PHY_CFG1_TXRESTUNE0,
+					  data->usb_source_impedance_adjust);
+		}
+
+		if (data->hs_transmitter_rise_time_adjust &&
+		    FIELD_FIT(MX7D_USB_OTG_PHY_CFG1_TXRISETUNE0,
+			      data->hs_transmitter_rise_time_adjust)) {
+			reg &= ~MX7D_USB_OTG_PHY_CFG1_TXRISETUNE0;
+			reg |= FIELD_PREP(MX7D_USB_OTG_PHY_CFG1_TXRISETUNE0,
+					  data->hs_transmitter_rise_time_adjust);
+		}
+
 		if (data->dc_vol_level_adjust &&
 		    FIELD_FIT(MX7D_USB_OTG_PHY_CFG1_TXVREFTUNE0,
 			      data->dc_vol_level_adjust)) {
@@ -674,6 +701,46 @@ static int usbmisc_imx7d_init(struct imx_usbmisc_data *data)
 					  data->dc_vol_level_adjust);
 		}
 
+		if (data->fs_ls_source_impedance_adjust &&
+		    FIELD_FIT(MX7D_USB_OTG_PHY_CFG1_TXFSLSTUNE0,
+			      data->fs_ls_source_impedance_adjust)) {
+			reg &= ~MX7D_USB_OTG_PHY_CFG1_TXFSLSTUNE0;
+			reg |= FIELD_PREP(MX7D_USB_OTG_PHY_CFG1_TXFSLSTUNE0,
+					  data->fs_ls_source_impedance_adjust);
+		}
+
+		if (data->transmitter_hs_crossover_adjust &&
+		    FIELD_FIT(MX7D_USB_OTG_PHY_CFG1_TXHSXVTUNE0,
+			      data->transmitter_hs_crossover_adjust)) {
+			reg &= ~MX7D_USB_OTG_PHY_CFG1_TXHSXVTUNE0;
+			reg |= FIELD_PREP(MX7D_USB_OTG_PHY_CFG1_TXHSXVTUNE0,
+					  data->transmitter_hs_crossover_adjust);
+		}
+
+		if (data->vbus_valid_threshold_adjust &&
+		    FIELD_FIT(MX7D_USB_OTG_PHY_CFG1_OTGTUNE0,
+			      data->vbus_valid_threshold_adjust)) {
+			reg &= ~MX7D_USB_OTG_PHY_CFG1_OTGTUNE0;
+			reg |= FIELD_PREP(MX7D_USB_OTG_PHY_CFG1_OTGTUNE0,
+					  data->vbus_valid_threshold_adjust);
+		}
+
+		if (data->squelsh_threshold_adjust &&
+		    FIELD_FIT(MX7D_USB_OTG_PHY_CFG1_SQRTUNE0,
+			      data->squelsh_threshold_adjust)) {
+			reg &= ~MX7D_USB_OTG_PHY_CFG1_SQRTUNE0;
+			reg |= FIELD_PREP(MX7D_USB_OTG_PHY_CFG1_SQRTUNE0,
+					  data->squelsh_threshold_adjust);
+		}
+
+		if (data->disconnect_threshold_adjust &&
+		    FIELD_FIT(MX7D_USB_OTG_PHY_CFG1_COMPDISTUNE0,
+			      data->disconnect_threshold_adjust)) {
+			reg &= ~MX7D_USB_OTG_PHY_CFG1_COMPDISTUNE0;
+			reg |= FIELD_PREP(MX7D_USB_OTG_PHY_CFG1_COMPDISTUNE0,
+					  data->disconnect_threshold_adjust);
+		}
+
 		writel(reg, usbmisc->base + MX7D_USB_OTG_PHY_CFG1);
 	}
 
-- 
2.30.2




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux