return 0;
}
+static int qmp_usbc_check_phy_status(struct qmp_usbc *qmp, bool is_dp)
+{
+ if ((is_dp && qmp->usb_init_count) ||
+ (!is_dp && qmp->dp_init_count)) {
+ dev_err(qmp->dev,
+ "PHY is configured for %s, can not enable %s\n",
+ is_dp ? "USB" : "DP", is_dp ? "DP" : "USB");
+ return -EBUSY;
+ }
+
+ return 0;
+}
+
static int qmp_usbc_usb_enable(struct phy *phy)
{
struct qmp_usbc *qmp = phy_get_drvdata(phy);
mutex_lock(&qmp->phy_mutex);
+ ret = qmp_usbc_check_phy_status(qmp, false);
+ if (ret)
+ goto out_unlock;
+
ret = qmp_usbc_com_init(phy);
if (ret)
goto out_unlock;
mutex_lock(&qmp->phy_mutex);
+ ret = qmp_usbc_check_phy_status(qmp, true);
+ if (ret)
+ goto dp_init_unlock;
+
ret = qmp_usbc_com_init(phy);
if (ret)
goto dp_init_unlock;