Loading drivers/usb/pd/policy_engine.c +68 −41 Original line number Diff line number Diff line Loading @@ -374,7 +374,6 @@ struct usbpd { struct rx_msg *rx_ext_msg; u32 received_pdos[PD_MAX_DATA_OBJ]; u32 received_ado; u16 src_cap_id; u8 selected_pdo; u8 requested_pdo; Loading Loading @@ -443,6 +442,7 @@ struct usbpd { u8 src_cap_ext_db[PD_SRC_CAP_EXT_DB_LEN]; bool send_get_pps_status; u32 pps_status_db; bool send_get_status; u8 status_db[PD_STATUS_DB_LEN]; bool send_get_battery_cap; u8 get_battery_cap_db; Loading Loading @@ -2252,7 +2252,7 @@ static void usbpd_sm(struct work_struct *w) pd->send_pr_swap = false; ret = pd_send_msg(pd, MSG_PR_SWAP, NULL, 0, SOP_MSG); if (ret) { dev_err(&pd->dev, "Error sending PR Swap\n"); usbpd_err(&pd->dev, "Error sending PR Swap\n"); usbpd_set_state(pd, PE_SRC_SEND_SOFT_RESET); break; } Loading @@ -2263,7 +2263,7 @@ static void usbpd_sm(struct work_struct *w) pd->send_dr_swap = false; ret = pd_send_msg(pd, MSG_DR_SWAP, NULL, 0, SOP_MSG); if (ret) { dev_err(&pd->dev, "Error sending DR Swap\n"); usbpd_err(&pd->dev, "Error sending DR Swap\n"); usbpd_set_state(pd, PE_SRC_SEND_SOFT_RESET); break; } Loading Loading @@ -2552,8 +2552,7 @@ static void usbpd_sm(struct work_struct *w) ret = pd_send_msg(pd, MSG_GET_SOURCE_CAP_EXTENDED, NULL, 0, SOP_MSG); if (ret) { dev_err(&pd->dev, "Error sending get_src_cap_ext\n"); usbpd_err(&pd->dev, "Error sending get_src_cap_ext\n"); usbpd_set_state(pd, PE_SNK_SEND_SOFT_RESET); break; } Loading @@ -2572,8 +2571,7 @@ static void usbpd_sm(struct work_struct *w) ret = pd_send_msg(pd, MSG_GET_PPS_STATUS, NULL, 0, SOP_MSG); if (ret) { dev_err(&pd->dev, "Error sending get_pps_status\n"); usbpd_err(&pd->dev, "Error sending get_pps_status\n"); usbpd_set_state(pd, PE_SNK_SEND_SOFT_RESET); break; } Loading @@ -2588,23 +2586,32 @@ static void usbpd_sm(struct work_struct *w) sizeof(pd->pps_status_db)); complete(&pd->is_ready); } else if (IS_DATA(rx_msg, MSG_ALERT)) { if (rx_msg->data_len != sizeof(pd->received_ado)) { u32 ado; if (rx_msg->data_len != sizeof(ado)) { usbpd_err(&pd->dev, "Invalid ado\n"); break; } memcpy(&pd->received_ado, rx_msg->payload, sizeof(pd->received_ado)); ret = pd_send_msg(pd, MSG_GET_STATUS, NULL, 0, SOP_MSG); memcpy(&ado, rx_msg->payload, sizeof(ado)); usbpd_dbg(&pd->dev, "Received Alert 0x%08x\n", ado); /* * Don't send Get_Status right away so we can coalesce * multiple Alerts. 150ms should be enough to not get * in the way of any other AMS that might happen. */ pd->send_get_status = true; kick_sm(pd, 150); } else if (pd->send_get_status && is_sink_tx_ok(pd)) { pd->send_get_status = false; ret = pd_send_msg(pd, MSG_GET_STATUS, NULL, 0, SOP_MSG); if (ret) { dev_err(&pd->dev, "Error sending get_status\n"); usbpd_err(&pd->dev, "Error sending get_status\n"); usbpd_set_state(pd, PE_SNK_SEND_SOFT_RESET); break; } kick_sm(pd, SENDER_RESPONSE_TIME); } else if (rx_msg && IS_EXT(rx_msg, MSG_STATUS)) { } else if (rx_msg && IS_EXT(rx_msg, MSG_STATUS)) { if (rx_msg->data_len != PD_STATUS_DB_LEN) { usbpd_err(&pd->dev, "Invalid status db\n"); break; Loading @@ -2617,8 +2624,7 @@ static void usbpd_sm(struct work_struct *w) ret = pd_send_ext_msg(pd, MSG_GET_BATTERY_CAP, &pd->get_battery_cap_db, 1, SOP_MSG); if (ret) { dev_err(&pd->dev, "Error sending get_battery_cap\n"); usbpd_err(&pd->dev, "Error sending get_battery_cap\n"); usbpd_set_state(pd, PE_SNK_SEND_SOFT_RESET); break; } Loading @@ -2637,8 +2643,7 @@ static void usbpd_sm(struct work_struct *w) ret = pd_send_ext_msg(pd, MSG_GET_BATTERY_STATUS, &pd->get_battery_status_db, 1, SOP_MSG); if (ret) { dev_err(&pd->dev, "Error sending get_battery_status\n"); usbpd_err(&pd->dev, "Error sending get_battery_status\n"); usbpd_set_state(pd, PE_SNK_SEND_SOFT_RESET); break; } Loading Loading @@ -2668,7 +2673,7 @@ static void usbpd_sm(struct work_struct *w) pd->send_pr_swap = false; ret = pd_send_msg(pd, MSG_PR_SWAP, NULL, 0, SOP_MSG); if (ret) { dev_err(&pd->dev, "Error sending PR Swap\n"); usbpd_err(&pd->dev, "Error sending PR Swap\n"); usbpd_set_state(pd, PE_SNK_SEND_SOFT_RESET); break; } Loading @@ -2679,7 +2684,7 @@ static void usbpd_sm(struct work_struct *w) pd->send_dr_swap = false; ret = pd_send_msg(pd, MSG_DR_SWAP, NULL, 0, SOP_MSG); if (ret) { dev_err(&pd->dev, "Error sending DR Swap\n"); usbpd_err(&pd->dev, "Error sending DR Swap\n"); usbpd_set_state(pd, PE_SNK_SEND_SOFT_RESET); break; } Loading Loading @@ -3297,9 +3302,9 @@ static int usbpd_uevent(struct device *dev, struct kobj_uevent_env *env) "explicit" : "implicit"); add_uevent_var(env, "ALT_MODE=%d", pd->vdm_state == MODE_ENTERED); add_uevent_var(env, "ADO=%08x", pd->received_ado); for (i = 0; i < PD_STATUS_DB_LEN; i++) add_uevent_var(env, "SDB%d=%08x", i, pd->status_db[i]); add_uevent_var(env, "SDB=%02x %02x %02x %02x %02x", pd->status_db[0], pd->status_db[1], pd->status_db[2], pd->status_db[3], pd->status_db[4]); return 0; } Loading Loading @@ -3690,38 +3695,56 @@ static ssize_t get_src_cap_ext_show(struct device *dev, return ret; for (i = 0; i < PD_SRC_CAP_EXT_DB_LEN; i++) len += snprintf(buf + len, PAGE_SIZE - len, "%d\n", pd->src_cap_ext_db[i]); len += snprintf(buf + len, PAGE_SIZE - len, "%s0x%02x", i ? " " : "", pd->src_cap_ext_db[i]); buf[len++] = '\n'; buf[len] = '\0'; return len; } static DEVICE_ATTR_RO(get_src_cap_ext); static ssize_t get_pps_status_show(struct device *dev, static ssize_t get_status_show(struct device *dev, struct device_attribute *attr, char *buf) { int ret; int i, ret, len = 0; struct usbpd *pd = dev_get_drvdata(dev); if (pd->spec_rev == USBPD_REV_20) return -EINVAL; ret = trigger_tx_msg(pd, &pd->send_get_pps_status); ret = trigger_tx_msg(pd, &pd->send_get_status); if (ret) return ret; return snprintf(buf, PAGE_SIZE, "%d\n", pd->pps_status_db); for (i = 0; i < PD_STATUS_DB_LEN; i++) len += snprintf(buf + len, PAGE_SIZE - len, "%s0x%02x", i ? " " : "", pd->status_db[i]); buf[len++] = '\n'; buf[len] = '\0'; return len; } static DEVICE_ATTR_RO(get_pps_status); static DEVICE_ATTR_RO(get_status); static ssize_t rx_ado_show(struct device *dev, struct device_attribute *attr, char *buf) static ssize_t get_pps_status_show(struct device *dev, struct device_attribute *attr, char *buf) { int ret; struct usbpd *pd = dev_get_drvdata(dev); /* dump the ADO as a hex string */ return snprintf(buf, PAGE_SIZE, "%08x\n", pd->received_ado); if (pd->spec_rev == USBPD_REV_20) return -EINVAL; ret = trigger_tx_msg(pd, &pd->send_get_pps_status); if (ret) return ret; return snprintf(buf, PAGE_SIZE, "0x%08x\n", pd->pps_status_db); } static DEVICE_ATTR_RO(rx_ado); static DEVICE_ATTR_RO(get_pps_status); static ssize_t get_battery_cap_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) Loading Loading @@ -3751,8 +3774,12 @@ static ssize_t get_battery_cap_show(struct device *dev, return -EINVAL; for (i = 0; i < PD_BATTERY_CAP_DB_LEN; i++) len += snprintf(buf + len, PAGE_SIZE - len, "%d\n", pd->battery_cap_db[i]); len += snprintf(buf + len, PAGE_SIZE - len, "%s0x%02x", i ? " " : "", pd->battery_cap_db[i]); buf[len++] = '\n'; buf[len] = '\0'; return len; } static DEVICE_ATTR_RW(get_battery_cap); Loading Loading @@ -3783,7 +3810,7 @@ static ssize_t get_battery_status_show(struct device *dev, if (pd->get_battery_status_db == -EINVAL) return -EINVAL; return snprintf(buf, PAGE_SIZE, "%d\n", pd->battery_sts_dobj); return snprintf(buf, PAGE_SIZE, "0x%08x\n", pd->battery_sts_dobj); } static DEVICE_ATTR_RW(get_battery_status); Loading @@ -3807,8 +3834,8 @@ static struct attribute *usbpd_attrs[] = { &dev_attr_rdo_h.attr, &dev_attr_hard_reset.attr, &dev_attr_get_src_cap_ext.attr, &dev_attr_get_status.attr, &dev_attr_get_pps_status.attr, &dev_attr_rx_ado.attr, &dev_attr_get_battery_cap.attr, &dev_attr_get_battery_status.attr, NULL, Loading drivers/usb/pd/qpnp-pdphy.c +19 −10 Original line number Diff line number Diff line Loading @@ -50,7 +50,7 @@ #define TX_SIZE_MASK 0xF #define USB_PDPHY_TX_CONTROL 0x44 #define TX_CONTROL_RETRY_COUNT (BIT(6) | BIT(5)) #define TX_CONTROL_RETRY_COUNT(n) (((n) & 0x3) << 5) #define TX_CONTROL_FRAME_TYPE (BIT(4) | BIT(3) | BIT(2)) #define TX_CONTROL_FRAME_TYPE_CABLE_RESET (0x1 << 2) #define TX_CONTROL_SEND_SIGNAL BIT(1) Loading Loading @@ -80,6 +80,9 @@ #define VDD_PDPHY_VOL_MAX 3088000 /* uV */ #define VDD_PDPHY_HPM_LOAD 3000 /* uA */ /* Message Spec Rev field */ #define PD_MSG_HDR_REV(hdr) (((hdr) >> 6) & 3) /* timers */ #define RECEIVER_RESPONSE_TIME 15 /* tReceiverResponse */ #define HARD_RESET_COMPLETE_TIME 5 /* tHardResetComplete */ Loading Loading @@ -437,12 +440,12 @@ int pd_phy_signal(enum pd_sig_type sig) if (ret) return ret; ret = wait_event_interruptible_timeout(pdphy->tx_waitq, ret = wait_event_interruptible_hrtimeout(pdphy->tx_waitq, pdphy->tx_status != -EINPROGRESS, msecs_to_jiffies(HARD_RESET_COMPLETE_TIME)); if (ret <= 0) { ms_to_ktime(HARD_RESET_COMPLETE_TIME)); if (ret) { dev_err(pdphy->dev, "%s: failed ret %d", __func__, ret); return ret ? ret : -ETIMEDOUT; return ret; } ret = pdphy_reg_write(pdphy, USB_PDPHY_TX_CONTROL, 0); Loading Loading @@ -520,18 +523,24 @@ int pd_phy_write(u16 hdr, const u8 *data, size_t data_len, enum pd_sop_type sop) usleep_range(2, 3); val = TX_CONTROL_RETRY_COUNT | (sop << 2) | TX_CONTROL_SEND_MSG; val = (sop << 2) | TX_CONTROL_SEND_MSG; /* nRetryCount == 2 for PD 3.0, 3 for PD 2.0 */ if (PD_MSG_HDR_REV(hdr) == USBPD_REV_30) val |= TX_CONTROL_RETRY_COUNT(2); else val |= TX_CONTROL_RETRY_COUNT(3); ret = pdphy_reg_write(pdphy, USB_PDPHY_TX_CONTROL, val); if (ret) return ret; ret = wait_event_interruptible_timeout(pdphy->tx_waitq, ret = wait_event_interruptible_hrtimeout(pdphy->tx_waitq, pdphy->tx_status != -EINPROGRESS, msecs_to_jiffies(RECEIVER_RESPONSE_TIME)); if (ret <= 0) { ms_to_ktime(RECEIVER_RESPONSE_TIME)); if (ret) { dev_err(pdphy->dev, "%s: failed ret %d", __func__, ret); return ret ? ret : -ETIMEDOUT; return ret; } if (hdr && !pdphy->tx_status) Loading Loading
drivers/usb/pd/policy_engine.c +68 −41 Original line number Diff line number Diff line Loading @@ -374,7 +374,6 @@ struct usbpd { struct rx_msg *rx_ext_msg; u32 received_pdos[PD_MAX_DATA_OBJ]; u32 received_ado; u16 src_cap_id; u8 selected_pdo; u8 requested_pdo; Loading Loading @@ -443,6 +442,7 @@ struct usbpd { u8 src_cap_ext_db[PD_SRC_CAP_EXT_DB_LEN]; bool send_get_pps_status; u32 pps_status_db; bool send_get_status; u8 status_db[PD_STATUS_DB_LEN]; bool send_get_battery_cap; u8 get_battery_cap_db; Loading Loading @@ -2252,7 +2252,7 @@ static void usbpd_sm(struct work_struct *w) pd->send_pr_swap = false; ret = pd_send_msg(pd, MSG_PR_SWAP, NULL, 0, SOP_MSG); if (ret) { dev_err(&pd->dev, "Error sending PR Swap\n"); usbpd_err(&pd->dev, "Error sending PR Swap\n"); usbpd_set_state(pd, PE_SRC_SEND_SOFT_RESET); break; } Loading @@ -2263,7 +2263,7 @@ static void usbpd_sm(struct work_struct *w) pd->send_dr_swap = false; ret = pd_send_msg(pd, MSG_DR_SWAP, NULL, 0, SOP_MSG); if (ret) { dev_err(&pd->dev, "Error sending DR Swap\n"); usbpd_err(&pd->dev, "Error sending DR Swap\n"); usbpd_set_state(pd, PE_SRC_SEND_SOFT_RESET); break; } Loading Loading @@ -2552,8 +2552,7 @@ static void usbpd_sm(struct work_struct *w) ret = pd_send_msg(pd, MSG_GET_SOURCE_CAP_EXTENDED, NULL, 0, SOP_MSG); if (ret) { dev_err(&pd->dev, "Error sending get_src_cap_ext\n"); usbpd_err(&pd->dev, "Error sending get_src_cap_ext\n"); usbpd_set_state(pd, PE_SNK_SEND_SOFT_RESET); break; } Loading @@ -2572,8 +2571,7 @@ static void usbpd_sm(struct work_struct *w) ret = pd_send_msg(pd, MSG_GET_PPS_STATUS, NULL, 0, SOP_MSG); if (ret) { dev_err(&pd->dev, "Error sending get_pps_status\n"); usbpd_err(&pd->dev, "Error sending get_pps_status\n"); usbpd_set_state(pd, PE_SNK_SEND_SOFT_RESET); break; } Loading @@ -2588,23 +2586,32 @@ static void usbpd_sm(struct work_struct *w) sizeof(pd->pps_status_db)); complete(&pd->is_ready); } else if (IS_DATA(rx_msg, MSG_ALERT)) { if (rx_msg->data_len != sizeof(pd->received_ado)) { u32 ado; if (rx_msg->data_len != sizeof(ado)) { usbpd_err(&pd->dev, "Invalid ado\n"); break; } memcpy(&pd->received_ado, rx_msg->payload, sizeof(pd->received_ado)); ret = pd_send_msg(pd, MSG_GET_STATUS, NULL, 0, SOP_MSG); memcpy(&ado, rx_msg->payload, sizeof(ado)); usbpd_dbg(&pd->dev, "Received Alert 0x%08x\n", ado); /* * Don't send Get_Status right away so we can coalesce * multiple Alerts. 150ms should be enough to not get * in the way of any other AMS that might happen. */ pd->send_get_status = true; kick_sm(pd, 150); } else if (pd->send_get_status && is_sink_tx_ok(pd)) { pd->send_get_status = false; ret = pd_send_msg(pd, MSG_GET_STATUS, NULL, 0, SOP_MSG); if (ret) { dev_err(&pd->dev, "Error sending get_status\n"); usbpd_err(&pd->dev, "Error sending get_status\n"); usbpd_set_state(pd, PE_SNK_SEND_SOFT_RESET); break; } kick_sm(pd, SENDER_RESPONSE_TIME); } else if (rx_msg && IS_EXT(rx_msg, MSG_STATUS)) { } else if (rx_msg && IS_EXT(rx_msg, MSG_STATUS)) { if (rx_msg->data_len != PD_STATUS_DB_LEN) { usbpd_err(&pd->dev, "Invalid status db\n"); break; Loading @@ -2617,8 +2624,7 @@ static void usbpd_sm(struct work_struct *w) ret = pd_send_ext_msg(pd, MSG_GET_BATTERY_CAP, &pd->get_battery_cap_db, 1, SOP_MSG); if (ret) { dev_err(&pd->dev, "Error sending get_battery_cap\n"); usbpd_err(&pd->dev, "Error sending get_battery_cap\n"); usbpd_set_state(pd, PE_SNK_SEND_SOFT_RESET); break; } Loading @@ -2637,8 +2643,7 @@ static void usbpd_sm(struct work_struct *w) ret = pd_send_ext_msg(pd, MSG_GET_BATTERY_STATUS, &pd->get_battery_status_db, 1, SOP_MSG); if (ret) { dev_err(&pd->dev, "Error sending get_battery_status\n"); usbpd_err(&pd->dev, "Error sending get_battery_status\n"); usbpd_set_state(pd, PE_SNK_SEND_SOFT_RESET); break; } Loading Loading @@ -2668,7 +2673,7 @@ static void usbpd_sm(struct work_struct *w) pd->send_pr_swap = false; ret = pd_send_msg(pd, MSG_PR_SWAP, NULL, 0, SOP_MSG); if (ret) { dev_err(&pd->dev, "Error sending PR Swap\n"); usbpd_err(&pd->dev, "Error sending PR Swap\n"); usbpd_set_state(pd, PE_SNK_SEND_SOFT_RESET); break; } Loading @@ -2679,7 +2684,7 @@ static void usbpd_sm(struct work_struct *w) pd->send_dr_swap = false; ret = pd_send_msg(pd, MSG_DR_SWAP, NULL, 0, SOP_MSG); if (ret) { dev_err(&pd->dev, "Error sending DR Swap\n"); usbpd_err(&pd->dev, "Error sending DR Swap\n"); usbpd_set_state(pd, PE_SNK_SEND_SOFT_RESET); break; } Loading Loading @@ -3297,9 +3302,9 @@ static int usbpd_uevent(struct device *dev, struct kobj_uevent_env *env) "explicit" : "implicit"); add_uevent_var(env, "ALT_MODE=%d", pd->vdm_state == MODE_ENTERED); add_uevent_var(env, "ADO=%08x", pd->received_ado); for (i = 0; i < PD_STATUS_DB_LEN; i++) add_uevent_var(env, "SDB%d=%08x", i, pd->status_db[i]); add_uevent_var(env, "SDB=%02x %02x %02x %02x %02x", pd->status_db[0], pd->status_db[1], pd->status_db[2], pd->status_db[3], pd->status_db[4]); return 0; } Loading Loading @@ -3690,38 +3695,56 @@ static ssize_t get_src_cap_ext_show(struct device *dev, return ret; for (i = 0; i < PD_SRC_CAP_EXT_DB_LEN; i++) len += snprintf(buf + len, PAGE_SIZE - len, "%d\n", pd->src_cap_ext_db[i]); len += snprintf(buf + len, PAGE_SIZE - len, "%s0x%02x", i ? " " : "", pd->src_cap_ext_db[i]); buf[len++] = '\n'; buf[len] = '\0'; return len; } static DEVICE_ATTR_RO(get_src_cap_ext); static ssize_t get_pps_status_show(struct device *dev, static ssize_t get_status_show(struct device *dev, struct device_attribute *attr, char *buf) { int ret; int i, ret, len = 0; struct usbpd *pd = dev_get_drvdata(dev); if (pd->spec_rev == USBPD_REV_20) return -EINVAL; ret = trigger_tx_msg(pd, &pd->send_get_pps_status); ret = trigger_tx_msg(pd, &pd->send_get_status); if (ret) return ret; return snprintf(buf, PAGE_SIZE, "%d\n", pd->pps_status_db); for (i = 0; i < PD_STATUS_DB_LEN; i++) len += snprintf(buf + len, PAGE_SIZE - len, "%s0x%02x", i ? " " : "", pd->status_db[i]); buf[len++] = '\n'; buf[len] = '\0'; return len; } static DEVICE_ATTR_RO(get_pps_status); static DEVICE_ATTR_RO(get_status); static ssize_t rx_ado_show(struct device *dev, struct device_attribute *attr, char *buf) static ssize_t get_pps_status_show(struct device *dev, struct device_attribute *attr, char *buf) { int ret; struct usbpd *pd = dev_get_drvdata(dev); /* dump the ADO as a hex string */ return snprintf(buf, PAGE_SIZE, "%08x\n", pd->received_ado); if (pd->spec_rev == USBPD_REV_20) return -EINVAL; ret = trigger_tx_msg(pd, &pd->send_get_pps_status); if (ret) return ret; return snprintf(buf, PAGE_SIZE, "0x%08x\n", pd->pps_status_db); } static DEVICE_ATTR_RO(rx_ado); static DEVICE_ATTR_RO(get_pps_status); static ssize_t get_battery_cap_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) Loading Loading @@ -3751,8 +3774,12 @@ static ssize_t get_battery_cap_show(struct device *dev, return -EINVAL; for (i = 0; i < PD_BATTERY_CAP_DB_LEN; i++) len += snprintf(buf + len, PAGE_SIZE - len, "%d\n", pd->battery_cap_db[i]); len += snprintf(buf + len, PAGE_SIZE - len, "%s0x%02x", i ? " " : "", pd->battery_cap_db[i]); buf[len++] = '\n'; buf[len] = '\0'; return len; } static DEVICE_ATTR_RW(get_battery_cap); Loading Loading @@ -3783,7 +3810,7 @@ static ssize_t get_battery_status_show(struct device *dev, if (pd->get_battery_status_db == -EINVAL) return -EINVAL; return snprintf(buf, PAGE_SIZE, "%d\n", pd->battery_sts_dobj); return snprintf(buf, PAGE_SIZE, "0x%08x\n", pd->battery_sts_dobj); } static DEVICE_ATTR_RW(get_battery_status); Loading @@ -3807,8 +3834,8 @@ static struct attribute *usbpd_attrs[] = { &dev_attr_rdo_h.attr, &dev_attr_hard_reset.attr, &dev_attr_get_src_cap_ext.attr, &dev_attr_get_status.attr, &dev_attr_get_pps_status.attr, &dev_attr_rx_ado.attr, &dev_attr_get_battery_cap.attr, &dev_attr_get_battery_status.attr, NULL, Loading
drivers/usb/pd/qpnp-pdphy.c +19 −10 Original line number Diff line number Diff line Loading @@ -50,7 +50,7 @@ #define TX_SIZE_MASK 0xF #define USB_PDPHY_TX_CONTROL 0x44 #define TX_CONTROL_RETRY_COUNT (BIT(6) | BIT(5)) #define TX_CONTROL_RETRY_COUNT(n) (((n) & 0x3) << 5) #define TX_CONTROL_FRAME_TYPE (BIT(4) | BIT(3) | BIT(2)) #define TX_CONTROL_FRAME_TYPE_CABLE_RESET (0x1 << 2) #define TX_CONTROL_SEND_SIGNAL BIT(1) Loading Loading @@ -80,6 +80,9 @@ #define VDD_PDPHY_VOL_MAX 3088000 /* uV */ #define VDD_PDPHY_HPM_LOAD 3000 /* uA */ /* Message Spec Rev field */ #define PD_MSG_HDR_REV(hdr) (((hdr) >> 6) & 3) /* timers */ #define RECEIVER_RESPONSE_TIME 15 /* tReceiverResponse */ #define HARD_RESET_COMPLETE_TIME 5 /* tHardResetComplete */ Loading Loading @@ -437,12 +440,12 @@ int pd_phy_signal(enum pd_sig_type sig) if (ret) return ret; ret = wait_event_interruptible_timeout(pdphy->tx_waitq, ret = wait_event_interruptible_hrtimeout(pdphy->tx_waitq, pdphy->tx_status != -EINPROGRESS, msecs_to_jiffies(HARD_RESET_COMPLETE_TIME)); if (ret <= 0) { ms_to_ktime(HARD_RESET_COMPLETE_TIME)); if (ret) { dev_err(pdphy->dev, "%s: failed ret %d", __func__, ret); return ret ? ret : -ETIMEDOUT; return ret; } ret = pdphy_reg_write(pdphy, USB_PDPHY_TX_CONTROL, 0); Loading Loading @@ -520,18 +523,24 @@ int pd_phy_write(u16 hdr, const u8 *data, size_t data_len, enum pd_sop_type sop) usleep_range(2, 3); val = TX_CONTROL_RETRY_COUNT | (sop << 2) | TX_CONTROL_SEND_MSG; val = (sop << 2) | TX_CONTROL_SEND_MSG; /* nRetryCount == 2 for PD 3.0, 3 for PD 2.0 */ if (PD_MSG_HDR_REV(hdr) == USBPD_REV_30) val |= TX_CONTROL_RETRY_COUNT(2); else val |= TX_CONTROL_RETRY_COUNT(3); ret = pdphy_reg_write(pdphy, USB_PDPHY_TX_CONTROL, val); if (ret) return ret; ret = wait_event_interruptible_timeout(pdphy->tx_waitq, ret = wait_event_interruptible_hrtimeout(pdphy->tx_waitq, pdphy->tx_status != -EINPROGRESS, msecs_to_jiffies(RECEIVER_RESPONSE_TIME)); if (ret <= 0) { ms_to_ktime(RECEIVER_RESPONSE_TIME)); if (ret) { dev_err(pdphy->dev, "%s: failed ret %d", __func__, ret); return ret ? ret : -ETIMEDOUT; return ret; } if (hdr && !pdphy->tx_status) Loading