浏览代码

phy: ti: j721e-wiz: Add support Type-C DIR GPIO delay

Type-C companions typically need some time after the cable is
plugged before and before they reflect the correct status of
Type-C plug orientation on the DIR line.

Type-C Spec specifies CC attachment debounce time (tCCDebounce)
of 100 ms (min) to 200 ms (max).

Use the DT property to figure out if we need to add delay
or not before sampling the Type-C DIR line.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Roger Quadros 6 年之前
父节点
当前提交
8023a438c1
共有 1 个文件被更改,包括 13 次插入0 次删除
  1. 13 0
      drivers/phy/ti/phy-j721e-wiz.c

+ 13 - 0
drivers/phy/ti/phy-j721e-wiz.c

@@ -183,6 +183,7 @@ struct wiz {
 	struct platform_device	*serdes_pdev;
 	struct platform_device	*serdes_pdev;
 	struct reset_controller_dev wiz_phy_reset_dev;
 	struct reset_controller_dev wiz_phy_reset_dev;
 	struct gpio_desc	*gpio_typec_dir;
 	struct gpio_desc	*gpio_typec_dir;
+	int			typec_dir_delay;
 
 
 	bool used_for_dp;
 	bool used_for_dp;
 };
 };
@@ -689,6 +690,9 @@ static int wiz_phy_reset_deassert(struct reset_controller_dev *rcdev,
 
 
 	/* if typec-dir gpio was specified, set LN10 SWAP bit based on that */
 	/* if typec-dir gpio was specified, set LN10 SWAP bit based on that */
 	if (id == 0 && wiz->gpio_typec_dir) {
 	if (id == 0 && wiz->gpio_typec_dir) {
+		if (wiz->typec_dir_delay)
+			msleep_interruptible(wiz->typec_dir_delay);
+
 		if (gpiod_get_value_cansleep(wiz->gpio_typec_dir)) {
 		if (gpiod_get_value_cansleep(wiz->gpio_typec_dir)) {
 			regmap_update_bits(wiz->regmap, WIZ_SERDES_TYPEC,
 			regmap_update_bits(wiz->regmap, WIZ_SERDES_TYPEC,
 					   WIZ_SERDES_TYPEC_LN10_SWAP,
 					   WIZ_SERDES_TYPEC_LN10_SWAP,
@@ -797,6 +801,15 @@ static int wiz_probe(struct platform_device *pdev)
 		goto err_addr_to_resource;
 		goto err_addr_to_resource;
 	}
 	}
 
 
+	if (wiz->gpio_typec_dir) {
+		ret = of_property_read_u32(node, "typec-dir-debounce",
+					   &wiz->typec_dir_delay);
+		if (ret && ret != -EINVAL) {
+			dev_err(dev, "Invalid typec-dir-debounce property\n");
+			goto err_addr_to_resource;
+		}
+	}
+
 	wiz->dev = dev;
 	wiz->dev = dev;
 	wiz->regmap = regmap;
 	wiz->regmap = regmap;
 	wiz->num_lanes = num_lanes;
 	wiz->num_lanes = num_lanes;