From 1526cac8ab5180e481b33e63e88beae55cb737ff Mon Sep 17 00:00:00 2001 From: Jack Pham Date: Thu, 17 Nov 2016 11:51:05 -0800 Subject: [PATCH 1/2] usb: pd: pdphy: Acknowledge Rx sooner To avoid missing an incoming packet that was quickly sent while still processing the previous packet, clear the acknowledge bit as soon as the message is consumed from the Rx FIFO. This gives the hardware a chance to send a GoodCRC without causing the sender to retry. Change-Id: I8a9ef42685576ab68aa65efab1bebc40d801990d Signed-off-by: Jack Pham --- drivers/usb/pd/qpnp-pdphy.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/pd/qpnp-pdphy.c b/drivers/usb/pd/qpnp-pdphy.c index 0b9b60c3ca45..933b489de457 100644 --- a/drivers/usb/pd/qpnp-pdphy.c +++ b/drivers/usb/pd/qpnp-pdphy.c @@ -673,6 +673,9 @@ static irqreturn_t pdphy_msg_rx_irq_thread(int irq, void *data) if (ret) goto done; + /* ack to change ownership of rx buffer back to PDPHY RX HW */ + pdphy_reg_write(pdphy, USB_PDPHY_RX_ACKNOWLEDGE, 0); + if (((buf[0] & 0xf) == PD_MSG_BIST) && size >= 5) { /* BIST */ u8 mode = buf[5] >> 4; /* [31:28] of 1st data object */ @@ -689,9 +692,6 @@ static irqreturn_t pdphy_msg_rx_irq_thread(int irq, void *data) if (pdphy->msg_rx_cb) pdphy->msg_rx_cb(pdphy->usbpd, frame_type, buf, size + 1); - /* ack to change ownership of rx buffer back to PDPHY RX HW */ - pdphy_reg_write(pdphy, USB_PDPHY_RX_ACKNOWLEDGE, 0); - print_hex_dump_debug("rx msg:", DUMP_PREFIX_NONE, 32, 4, buf, size + 1, false); pdphy->rx_bytes += size + 1; From 8bd4723a22edf223c5573650e6b7bef60928a358 Mon Sep 17 00:00:00 2001 From: Jack Pham Date: Thu, 17 Nov 2016 11:55:03 -0800 Subject: [PATCH 2/2] usb: pd: pdphy: Update Tx Trim setting HW recommendation is to set the TX_TRIM_3 value to 0x2 for a steeper slope. This improves eye diagram testing result. This register is secure access so write to the SEC_ACCESS prior to setting this. Change-Id: I80b0a02feb0e4d1fb382407087fa30f390641ccb Signed-off-by: Jack Pham --- drivers/usb/pd/qpnp-pdphy.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/pd/qpnp-pdphy.c b/drivers/usb/pd/qpnp-pdphy.c index 933b489de457..1a03b0d71a18 100644 --- a/drivers/usb/pd/qpnp-pdphy.c +++ b/drivers/usb/pd/qpnp-pdphy.c @@ -71,6 +71,9 @@ #define USB_PDPHY_RX_BUFFER 0x80 +#define USB_PDPHY_SEC_ACCESS 0xD0 +#define USB_PDPHY_TRIM_3 0xF3 + /* VDD regulator */ #define VDD_PDPHY_VOL_MIN 3088000 /* uV */ #define VDD_PDPHY_VOL_MAX 3088000 /* uV */ @@ -806,6 +809,14 @@ static int pdphy_probe(struct platform_device *pdev) if (ret < 0) return ret; + ret = pdphy_reg_write(pdphy, USB_PDPHY_SEC_ACCESS, 0xA5); + if (ret) + return ret; + + ret = pdphy_reg_write(pdphy, USB_PDPHY_TRIM_3, 0x2); + if (ret) + return ret; + /* usbpd_create() could call back to us, so have __pdphy ready */ __pdphy = pdphy;