Merge "usb: pd: simplify pd_phy_write() and pd_phy_signal() usage"
This commit is contained in:
commit
47b13c41e7
3 changed files with 21 additions and 20 deletions
|
@ -489,13 +489,10 @@ static int pd_send_msg(struct usbpd *pd, u8 msg_type, const u32 *data,
|
|||
|
||||
hdr = PD_MSG_HDR(msg_type, pd->current_dr, pd->current_pr,
|
||||
pd->tx_msgid, num_data, pd->spec_rev);
|
||||
ret = pd_phy_write(hdr, (u8 *)data, num_data * sizeof(u32), sop, 15);
|
||||
/* TODO figure out timeout. based on tReceive=1.1ms x nRetryCount? */
|
||||
|
||||
if (ret < 0)
|
||||
ret = pd_phy_write(hdr, (u8 *)data, num_data * sizeof(u32), sop);
|
||||
if (ret)
|
||||
return ret;
|
||||
else if (ret != num_data * sizeof(u32))
|
||||
return -EIO;
|
||||
|
||||
pd->tx_msgid = (pd->tx_msgid + 1) & PD_MAX_MSG_ID;
|
||||
return 0;
|
||||
|
@ -596,7 +593,7 @@ static void pd_send_hard_reset(struct usbpd *pd)
|
|||
/* Force CC logic to source/sink to keep Rp/Rd unchanged */
|
||||
set_power_role(pd, pd->current_pr);
|
||||
pd->hard_reset_count++;
|
||||
pd_phy_signal(HARD_RESET_SIG, 5); /* tHardResetComplete */
|
||||
pd_phy_signal(HARD_RESET_SIG);
|
||||
pd->in_pr_swap = false;
|
||||
power_supply_set_property(pd->usb_psy, POWER_SUPPLY_PROP_PR_SWAP, &val);
|
||||
}
|
||||
|
|
|
@ -80,6 +80,10 @@
|
|||
#define VDD_PDPHY_VOL_MAX 3300000 /* uV */
|
||||
#define VDD_PDPHY_HPM_LOAD 3000 /* uA */
|
||||
|
||||
/* timers */
|
||||
#define RECEIVER_RESPONSE_TIME 15 /* tReceiverResponse */
|
||||
#define HARD_RESET_COMPLETE_TIME 5 /* tHardResetComplete */
|
||||
|
||||
struct usb_pdphy {
|
||||
struct device *dev;
|
||||
struct regmap *regmap;
|
||||
|
@ -401,14 +405,13 @@ int pd_phy_open(struct pd_phy_params *params)
|
|||
}
|
||||
EXPORT_SYMBOL(pd_phy_open);
|
||||
|
||||
int pd_phy_signal(enum pd_sig_type sig, unsigned int timeout_ms)
|
||||
int pd_phy_signal(enum pd_sig_type sig)
|
||||
{
|
||||
u8 val;
|
||||
int ret;
|
||||
struct usb_pdphy *pdphy = __pdphy;
|
||||
|
||||
dev_dbg(pdphy->dev, "%s: type %d timeout %u\n", __func__, sig,
|
||||
timeout_ms);
|
||||
dev_dbg(pdphy->dev, "%s: type %d\n", __func__, sig);
|
||||
|
||||
if (!pdphy) {
|
||||
pr_err("%s: pdphy not found\n", __func__);
|
||||
|
@ -436,7 +439,8 @@ int pd_phy_signal(enum pd_sig_type sig, unsigned int timeout_ms)
|
|||
return ret;
|
||||
|
||||
ret = wait_event_interruptible_timeout(pdphy->tx_waitq,
|
||||
pdphy->tx_status != -EINPROGRESS, msecs_to_jiffies(timeout_ms));
|
||||
pdphy->tx_status != -EINPROGRESS,
|
||||
msecs_to_jiffies(HARD_RESET_COMPLETE_TIME));
|
||||
if (ret <= 0) {
|
||||
dev_err(pdphy->dev, "%s: failed ret %d", __func__, ret);
|
||||
return ret ? ret : -ETIMEDOUT;
|
||||
|
@ -455,16 +459,15 @@ int pd_phy_signal(enum pd_sig_type sig, unsigned int timeout_ms)
|
|||
}
|
||||
EXPORT_SYMBOL(pd_phy_signal);
|
||||
|
||||
int pd_phy_write(u16 hdr, const u8 *data, size_t data_len,
|
||||
enum pd_sop_type sop, unsigned int timeout_ms)
|
||||
int pd_phy_write(u16 hdr, const u8 *data, size_t data_len, enum pd_sop_type sop)
|
||||
{
|
||||
u8 val;
|
||||
int ret;
|
||||
size_t total_len = data_len + USB_PDPHY_MSG_HDR_LEN;
|
||||
struct usb_pdphy *pdphy = __pdphy;
|
||||
|
||||
dev_dbg(pdphy->dev, "%s: hdr %x frame sop_type %d timeout %u\n",
|
||||
__func__, hdr, sop, timeout_ms);
|
||||
dev_dbg(pdphy->dev, "%s: hdr %x frame sop_type %d\n",
|
||||
__func__, hdr, sop);
|
||||
|
||||
if (data && data_len)
|
||||
print_hex_dump_debug("tx data obj:", DUMP_PREFIX_NONE, 32, 4,
|
||||
|
@ -525,7 +528,8 @@ int pd_phy_write(u16 hdr, const u8 *data, size_t data_len,
|
|||
return ret;
|
||||
|
||||
ret = wait_event_interruptible_timeout(pdphy->tx_waitq,
|
||||
pdphy->tx_status != -EINPROGRESS, msecs_to_jiffies(timeout_ms));
|
||||
pdphy->tx_status != -EINPROGRESS,
|
||||
msecs_to_jiffies(RECEIVER_RESPONSE_TIME));
|
||||
if (ret <= 0) {
|
||||
dev_err(pdphy->dev, "%s: failed ret %d", __func__, ret);
|
||||
return ret ? ret : -ETIMEDOUT;
|
||||
|
@ -534,7 +538,7 @@ int pd_phy_write(u16 hdr, const u8 *data, size_t data_len,
|
|||
if (hdr && !pdphy->tx_status)
|
||||
pdphy->tx_bytes += data_len + USB_PDPHY_MSG_HDR_LEN;
|
||||
|
||||
return pdphy->tx_status ? pdphy->tx_status : data_len;
|
||||
return pdphy->tx_status ? pdphy->tx_status : 0;
|
||||
}
|
||||
EXPORT_SYMBOL(pd_phy_write);
|
||||
|
||||
|
|
|
@ -72,9 +72,9 @@ struct pd_phy_params {
|
|||
|
||||
#if IS_ENABLED(CONFIG_QPNP_USB_PDPHY)
|
||||
int pd_phy_open(struct pd_phy_params *params);
|
||||
int pd_phy_signal(enum pd_sig_type sig, unsigned int timeout_ms);
|
||||
int pd_phy_signal(enum pd_sig_type sig);
|
||||
int pd_phy_write(u16 hdr, const u8 *data, size_t data_len,
|
||||
enum pd_sop_type sop, unsigned int timeout_ms);
|
||||
enum pd_sop_type sop);
|
||||
int pd_phy_update_roles(enum data_role dr, enum power_role pr);
|
||||
void pd_phy_close(void);
|
||||
#else
|
||||
|
@ -83,13 +83,13 @@ static inline int pd_phy_open(struct pd_phy_params *params)
|
|||
return -ENODEV;
|
||||
}
|
||||
|
||||
static inline int pd_phy_signal(enum pd_sig_type type, unsigned int timeout_ms)
|
||||
static inline int pd_phy_signal(enum pd_sig_type type)
|
||||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
static inline int pd_phy_write(u16 hdr, const u8 *data, size_t data_len,
|
||||
enum pd_sop_type sop, unsigned int timeout_ms)
|
||||
enum pd_sop_type sop)
|
||||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue