Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f19be103 authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "phy: msm: qusb: Add support for USB HS AC/DC coupling"

parents 171cd0ab 28c7d132
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -189,6 +189,9 @@ Optional properties:
   de-asserted, it will prevent random leakage from qusb2 phy resulting from
   out of sequence turn on/off of 1p8, 3p3 and DVDD regulators.
   "refgen_north_bg_reg" : address used to read REFGEN status for overriding QUSB PHY register.
   "tcsr_conn_box_spare" : To enable/disable USB HS AC/DC coupling feature. When
   enabled, DP/DM signals will take path through capacitor when USB HS device is
   connected. This is a required property if 'qcom,usb-hs-ac-bitmask' property is present.
 - clocks: a list of phandles to the PHY clocks. Use as per
   Documentation/devicetree/bindings/clock/clock-bindings.txt
 - clock-names: Names of the clocks in 1-1 correspondence with the "clocks"
@@ -205,8 +208,8 @@ Optional properties:
 - qcom,hold-reset: Indicates that hold QUSB PHY into reset state.
 - qcom,phy-clk-scheme: Should be one of "cml" or "cmos" if ref_clk_addr is provided.
 - qcom,major-rev: provide major revision number to differentiate power up sequence. default is 2.0
 - pinctrl-names/pinctrl-0/1: The GPIOs configured as output function. Names represents "active"
   state when attached in host mode and "suspend" state when detached.
 - pinctrl-names/pinctrl-0/1: The GPIOs configured as output function. Allowed names are
   "default" and "sleep".
 - qcom,tune2-efuse-correction: The value to be adjusted from fused value for
   improved rise/fall times.
 - qcom,host-chirp-erratum: Indicates host chirp fix is required.
@@ -216,6 +219,11 @@ Optional properties:
   usually it is defined by qfprom device node.
 - nvmem-cell-names: specifies the given nvmem cell name as defined in
   qfprom node.
 - qcom,usb-hs-ac-bitmask: Specifies the polarity and enable bitfields in
   tcsr_conn_box_spare register so as to enable USB HS AC/DC coupling feature.
 - qcom,usb-hs-ac-value: Specifies the value to be written to polarity and
   enable bitfields so as to enable USB HS AC/DC coupling feature. This is a
   required property if 'qcom,usb-hs-ac-bitmask' property is present.

Example:
	qusb_phy: qusb@f9b39000 {
+41 −0
Original line number Diff line number Diff line
@@ -127,6 +127,7 @@ struct qusb_phy {
	void __iomem		*tune2_efuse_reg;
	void __iomem		*ref_clk_base;
	void __iomem		*tcsr_clamp_dig_n;
	void __iomem		*tcsr_conn_box_spare;

	struct clk		*ref_clk_src;
	struct clk		*ref_clk;
@@ -143,6 +144,8 @@ struct qusb_phy {
	int			init_seq_len;
	int			*qusb_phy_init_seq;
	u32			major_rev;
	u32			usb_hs_ac_bitmask;
	u32			usb_hs_ac_value;

	u32			tune2_val;
	int			tune2_efuse_bit_pos;
@@ -904,6 +907,7 @@ static int qusb_phy_probe(struct platform_device *pdev)
	int ret = 0, size = 0;
	const char *phy_type;
	bool hold_phy_reset;
	u32 temp;

	qphy = devm_kzalloc(dev, sizeof(*qphy), GFP_KERNEL);
	if (!qphy)
@@ -989,6 +993,32 @@ static int qusb_phy_probe(struct platform_device *pdev)
		}
	}

	ret = of_property_read_u32(dev->of_node, "qcom,usb-hs-ac-bitmask",
					&qphy->usb_hs_ac_bitmask);
	if (!ret) {
		ret = of_property_read_u32(dev->of_node, "qcom,usb-hs-ac-value",
						&qphy->usb_hs_ac_value);
		if (ret) {
			dev_err(dev, "usb_hs_ac_value not passed\n", __func__);
			return ret;
		}

		res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
						"tcsr_conn_box_spare_0");
		if (!res) {
			dev_err(dev, "tcsr_conn_box_spare_0 not passed\n",
								__func__);
			return -ENOENT;
		}

		qphy->tcsr_conn_box_spare = devm_ioremap_nocache(dev,
						res->start, resource_size(res));
		if (IS_ERR(qphy->tcsr_conn_box_spare)) {
			dev_err(dev, "err reading tcsr_conn_box_spare\n");
			return PTR_ERR(qphy->tcsr_conn_box_spare);
		}
	}

	qphy->ref_clk_src = devm_clk_get(dev, "ref_clk_src");
	if (IS_ERR(qphy->ref_clk_src))
		dev_dbg(dev, "clk get failed for ref_clk_src\n");
@@ -1212,6 +1242,17 @@ static int qusb_phy_probe(struct platform_device *pdev)
	if (qphy->tcsr_clamp_dig_n)
		writel_relaxed(0x0, qphy->tcsr_clamp_dig_n);

	/*
	 * Write the usb_hs_ac_value to usb_hs_ac_bitmask of tcsr_conn_box_spare
	 * reg to enable AC/DC coupling
	 */
	if (qphy->tcsr_conn_box_spare) {
		temp = readl_relaxed(qphy->tcsr_conn_box_spare) &
						~qphy->usb_hs_ac_bitmask;
		writel_relaxed(temp | qphy->usb_hs_ac_value,
						qphy->tcsr_conn_box_spare);
	}

	qphy->suspended = true;

	return ret;