summaryrefslogtreecommitdiff
path: root/drivers/usb/pd (follow)
Commit message (Collapse)AuthorAge
* usb: pd: qpnp-pdphy: Switch to hrtimer-based waitJack Pham2020-04-18
| | | | | | | | | | | | Currently wait_event_interruptible_timeout() is used when sending a message or hard reset signal to wait for a completion interrupt. However, the jiffies-based timer is not accurate for the short timeout durations used (15ms TX, 5ms hard reset) and can result in timing out too early. Switch to hrtimer-based wait_event_interruptible_hrtimeout() for better accuracy. Change-Id: I1c9866114b548ce849ec6002c0eb1362ac9a7786 Signed-off-by: Jack Pham <jackp@codeaurora.org>
* usb: pd: Don't reject sink request based on max currentJack Pham2019-01-18
| | | | | | | | | | | | | A fixed sink PDO request includes both operating current and max current. Although the max current requested may be greater than the available source advertisement, as per spec only the operating current request needs to be considered. The sink will likely have also set the Capability Mismatch bit as well. Hence, don't reject the request otherwise the sink will keep re-requesting and never enter a contract. Change-Id: Ia15e2e17abe43f2bcbc1fe7011b70ab0e0f5d9eb Signed-off-by: Jack Pham <jackp@codeaurora.org>
* Merge "USB: pd: Notify selfpowered state based on type C current"Linux Build Service Account2018-09-08
|\
| * USB: pd: Notify selfpowered state based on type C currentVijayavardhan Vennapusa2018-09-05
| | | | | | | | | | | | | | | | | | | | It is required to notify device as selfpowered and bmaxpower as zero even for non PD capable devices based on Type C current. Hence notify as selfpowerer in bMattributes of configuation descriptor in case of medium or high Type C current. Change-Id: Ie552560d93a8195f4c69fdaf6086ef3a52b31d39 Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
* | USB: pd: Send PS_RDY within tNewSrc after PS_RDY receivedVijayavardhan Vennapusa2018-07-27
| | | | | | | | | | | | | | | | | | | | | | | | | | USBPD spec mentions max time within which device that transitions from sink power role to source needs to send PS_RDY message after PS_RDY received from other device as part of PR_SWAP. Currently USB PD driver is taking time around 380msec i.e greater than tNewSrc (275msec) and resulting in USB PD complaince test "2.2.3.1.2 Procedure/Checks for Tester (Source) Originated Swap" failure. Fix it by waiting only till VBUS voltage reaches VSafe5Vmin. Change-Id: I3138e6d31ba964507230fe5f914aaaf2e261647d Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
* | usb: pd: avoid out-of-bounds access when reading PDOsJack Pham2018-01-17
| | | | | | | | | | | | | | | | | | | | | | Most often a source will send fewer than the maximum number of PDOs (7). Since the rx_msg buffer is now allocated up to the size of the actual data, honor the rx_msg->data_len when copying to pd->received_pdos rather than always 28 bytes. This fixes out-of-bounds read access as reported by KASAN. Change-Id: I5f98f7ccba027c1ab436ccf6fc822e2a319bafa1 Signed-off-by: Jack Pham <jackp@codeaurora.org>
* | usb: pd: ensure source hard reset is handled timelyJack Pham2018-01-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When in source mode if a hard reset is received just before or while usbpd_sm() is in the middle of trying to send an outgoing message, the signal handling would get delayed due waiting for the PD PHY to complete retrying and failing both the message as well as the subsequent Soft_Reset message. Instead, treat the incoming hard reset with priority try to bail out of further attempts to send a message so that we can immeidately re-queue and process the hard reset on the next usbpd_sm() invocation. In case the TX attempt still manages to win the race, this will cause delay that affects our tPSHardReset (25-35ms) required time resulting in VBUS getting turned off too late. Handle this by keeping track of when the hard reset signal arrived so that we can schedule SRC_TRANSITION_TO_DEFAULT within this window. Also promote the error message when a hard reset is received from KERN_DEBUG to KERN_ERR, as this is abnormal enough to deserve printing to the kernel log with higher priority. Change-Id: Ie503f7b776022067ec3a4788d5229ec508b9c55f Signed-off-by: Jack Pham <jackp@codeaurora.org>
* | usb: pd: Support revision 3.0 in sink-only modeHemant Kumar2018-01-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | commit 07040df2790e ("usb: pd: policy_engine: Handle spec revision properly") changed the spec revision handling to be 2.0 mode unless a programmable power supply is seen. Extend this via a module parameter to allow PD 3.0 in sink-only mode regardless of PPS when a 3.0 source is connected. Since the revision of the source is first encountered when receiving the Source Capabilities message, this information is lost by the time pd_eval_src_caps() is called. So bring back the handling in phy_msg_received() removed in commit 07040df2790e ("usb: pd: policy_engine: Handle spec revision properly"). Change-Id: I0485224aeadcffbfaecd0c7942c6dbcd9ddd3813 Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | usb: pd: qpnp-pdphy: move RX handling to hard IRQJack Pham2017-12-08
| | | | | | | | | | | | | | | | | | | | | | | | For improved performance, move RX handling from a thread to a hard IRQ handler. This helps to decrease the chance of missing incoming back-to-back messages (e.g. Accept -> PS_Ready following a successful power request) due to the pending RX token in case the IRQ thread is delayed due to high system load. policy_engine needs to perform the buffer allocation with the GFP_ATOMIC flag. Change-Id: Iacb2623280f1ac4de9f483a8abbf5dc055041be7 Signed-off-by: Jack Pham <jackp@codeaurora.org>
* | usb: pd: qpnp-pdphy: Remove rx_busy flagJack Pham2017-12-07
| | | | | | | | | | | | | | | | | | | | | | | | Having this flag was causing PD TX messages to incorrectly get blocked in the case where the policy engine state machine worker got scheduled to run in the RX IRQ, but before the handler exits and clears the flag. This caused false errors that an RX message is pending. Remove usage of this flag as it was doing more harm than good. Change-Id: Iffccfc9ffafac6017192d86d8d97d5534890c7b5 Signed-off-by: Jack Pham <jackp@codeaurora.org>
* | usb: pd: Avoid blocking wait in SRC_TRANSITION_TO_DEFAULTJack Pham2017-12-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When sending/receiving a hard reset in source mode, the PE_SRC_TRANSITION_TO_DEFAULT state turns off VBUS/VCONN and sleeps for 750ms. During this fairly long period any Type-C event such as cable disconnect or reconnect won't get processed as the workqueue is blocked by this wait condition. This can lead to incorrect state handling, for example when a sink is removed and a source is attached; the state machine will think a sink is still attached. Fix this by removing the msleep() and set a timer to restart the state machine to PE_UNKNOWN which will turn VBUS/VCONN back on and start again in PE_SRC_STARTUP. This frees up the workqueue to process any potential incoming events in the meantime. Change-Id: I282551a58252a672f319d1559eac9f4ad4c3ca8a Signed-off-by: Jack Pham <jackp@codeaurora.org>
* | usb: pd: Send pending VDM message upon entering SNK/SRC_ReadyJack Pham2017-12-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Entering SNK_Ready or SRC_Ready state from usbpd_set_state() is somewhat terminal as it is the end state of a contract negotiation. If there was a previous pending VDM message waiting to be sent, for example the start of a Discovery which was queued prior to a PR Swap, it would not get sent. Check for this and enqueue usbpd_sm once again so that it could be sent out. Otherwise, start the Discovery process in case we are in DFP mode, and do that for SNK_Ready as well. Change-Id: I4516ccb0deec8cdabdb62d539d7d2b66dc23f1ee Signed-off-by: Jack Pham <jackp@codeaurora.org>
* | usb: pd: Add support to send PD 3.0 extended messagesHemant Kumar2017-09-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for sending extended messages. Since the underlying PD PHY only supports a fixed 30 byte payload, longer messages up to 260 bytes must use chunking, which requires the receiver to request the next chunk until the entire payload is delivered. Use a completion variable to wait for the chunk requests so that pd_send_ext_msg() can be a blocking call. Send following two extended messages using sysfs in SINK ready state and cache response:- 1) Get_Battery_Cap and Battery_Capabilities as response 2) Get_Battery_Status and Battery_Status as response. These two extended messages are recommended for PD 3.0 SINK. Change-Id: Ib2b4e658c47995de1ea139406d7d83737c6208d4 Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | usb: pd: Add support to handle alert message for PD 3.0Hemant Kumar2017-09-08
| | | | | | | | | | | | | | | | | | | | | | | | Policy engine receives an alert message in PD 3.0 SINK ready state and caches alert data object. It sends Get_Status to receive status information from port partnet to check for alert specific changes. Once status information is received send uevent to notify the same. This message is recommended to be supported by PD 3.0 SINK. Change-Id: I5d6f32693f43fbaf8f8d8da23f8cb3de1e1e89c6 Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | usb: pd: Add support for PD revision 3.0 control messagesHemant Kumar2017-09-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Send following two control messages using sysfs in SINK ready state and cache response:- 1) Get_Source_Cap_Extended and Source_Capabilities_Extended as response 2) Get_PPS_Status and PPS_Status as response. These two control messages are recommended for PD 3.0 SINK. Change-Id: I338bafd76db9e5e48ac5dd6aeb266867996b267d Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | usb: pd: send Not Supported message when operating in 3.0Jack Pham2017-09-08
| | | | | | | | | | | | | | | | | | | | | | | | PD 3.0 requires the Not Supported message to be sent after receiving a message that is not supported. Add this to both PE_SNK_READY and PE_SRC_READY states when there is an unhandled message. If 3.0 sink-only mode is enabled, also disallow PR_SWAP, VCONN_SWAP, and GET_SOURCE_CAP, so that the state machine can fall through to responding with Not Supported. Change-Id: If28bfcb1a483fcdb0c398c66d26fe7b1607b461a Signed-off-by: Jack Pham <jackp@codeaurora.org>
* | usb: pd: support PD 3.0 extended messages with chunkingJack Pham2017-09-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for receiving extended messages. Since the underlying PD PHY only supports a fixed 30 byte payload, longer messages up to 260 bytes must use chunking, which requires the receiver to request the next chunk until the entire payload is delivered. When receiving a chunk, call a helper from phy_msg_received() to stage the received bytes into a long rx_msg and queue a request for the next chunk. Refactor struct rx_msg to use a flexible array member to accommodate the larger potential sizes. Finally, add new enum definitions for the new PD 3.0 message types. Change-Id: I962ad3a1f00db9c16133301d185bf123af2a3224 Signed-off-by: Jack Pham <jackp@codeaurora.org>
* | Merge "usb: pd: simplify pd_phy_write() and pd_phy_signal() usage"Linux Build Service Account2017-08-21
|\ \
| * | usb: pd: simplify pd_phy_write() and pd_phy_signal() usageJack Pham2017-08-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove the timeout_ms parameter as this can be part of the function implementation itself. Define tReceiverResponse (15ms) for message writes which is a reasonable value to allow for up to 3 retries without receiving GoodCRC before determining the send failed. On successful transmission simply return 0 to unburden the caller from having to check against the data_len param. For signals set the timeout as tHardResetComplete (5ms). Change-Id: I7ac31fa5a00f01f10f17a01b138e71868c2a6eba Signed-off-by: Jack Pham <jackp@codeaurora.org>
* | | Merge "usb: pd: force disconnect upon unexpected SRC->SNK transition"Linux Build Service Account2017-08-21
|\ \ \
| * | | usb: pd: force disconnect upon unexpected SRC->SNK transitionJack Pham2017-08-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While in Source mode, a notification that a source is attached is unexpected. In this case, force a disconnect in order to clean up state and turn off VBUS and Vconn. Change-Id: Ie576feeb7622376e8cb0dd8454b626b3b24b190b Signed-off-by: Jack Pham <jackp@codeaurora.org>
| * | | usb: pd: avoid missed connection notificationJack Pham2017-08-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the disconnect handler of usbpd_sm(), pd->current_pr is already set to PR_NONE, so there is no reason to set it again. This helps for cases where a quick reconnection notification just arrived and sets the variable to either PR_SRC or PR_SINK but the disconnect handling clears it resulting in nothing to be done the next time work is scheduled. Change-Id: Ia88520149905989a3b3efb94361670760b79c0bd Signed-off-by: Jack Pham <jackp@codeaurora.org>
* | | | Merge "power: qpnp-smb2: expose CHARGE_COUNTER prop via batt psy"Linux Build Service Account2017-08-21
|\ \ \ \ | |_|/ / |/| | |
| * | | power: qpnp-smb2: use correct propertiesNicholas Troast2017-08-10
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CURRENT_MAX and VOLTAGE_MAX should be used to show the current values for the charger. The driver currently uses them to communicate with the USB and PD drivers. Update the code such that USB uses SDP_CURRENT_MAX to set 500mA/900mA current limits after enumeration and PD uses PD_VOLTAGE_MIN/MAX to set the adapter voltage limits. CURRENT_MAX now shows the max current that can be drawn from the charger and VOLTAGE_MAX shows the max voltage that the charger can negotiate up to. CURRENT_MAX and VOLTAGE_MAX can no longer be set. Change-Id: I660e39effc1862051cff8b9babc885d8de3f9c84 Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
* / / usb: pd: rename enum pd_msg_type to pd_sop_typeJack Pham2017-08-03
|/ / | | | | | | | | | | | | | | | | | | | | | | | | This enum is used to specify what packet type (SOP, SOP', SOP'') to the PD PHY when sending and receiving messages. To avoid confusion with the message type field of a message header (e.g. MSG_REQUEST, MSG_ACCEPT, etc), rename the enum to pd_sop_type and change the parameter name from 'type' to 'sop'. Also change the enum pd_sig_type parameter name to 'sig' for similar clarity. This patch is cosmetic, no functional changes. Change-Id: Idf74f7635ec5afee3538815f2efd9bc032ee6d89 Signed-off-by: Jack Pham <jackp@codeaurora.org>
* | Merge "USB: policy_engine: Enable VBUS after VCONN before PE_SRC_Startup"Linux Build Service Account2017-07-25
|\ \
| * | USB: policy_engine: Enable VBUS after VCONN before PE_SRC_StartupVijayavardhan Vennapusa2017-07-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently driver is enabling VBUS first and then enable VCONN before PE_SRC_startup when type C mode is POWER_SUPPLY_TYPEC_SINK_POWERED_CABLE. On some platforms, enabling VBUS is taking time which is causing VCONN reaching 2.7V after VBUS reaches VsafeV. This is exceeding 2msec timelimit mentioned in type C specification and causes type C complaince tests failure. Hence enable VCONN first and then enable VBUS to pass below type C compliance tests: TD 4.8.3 DRP Connect Vconn Accessory Test TD 4.9.1 Source Suspend Test Change-Id: I2697acdcaa063f251dd37035475392510037bee5 Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
* | | usb: pd: policy_engine: Add support to handle floating chargerHemant Kumar2017-07-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is a possibility of PMI detecting SDP as a floating charger when connected to a PC. Workaround this issue by starting peripheral stack for floating charger as well. Stop peripheral stack after 10 sec in absence of USB device enumeration. Change-Id: I6effee71affbe0baeb28c54ce799ade79ec4b42a Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | | usb: pd: Add delay before sending Source CapabilitiesJack Pham2017-07-07
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | The PD specification defines tFirstSourceCap as the time before a source must send its first Source_Capabilities message and allows this to be up to 250ms. This is advantageous for cases in which a sink partner is quickly detached (or possibly even attempting Try.SRC) just after VBUS is turned on and the unnecessary PD messaging causes the HW to fail to detect the detach condition right away. Add a delay of 200ms during the transition from PE_SRC_STARTUP to PE_SRC_SEND_CAPABILITIES. Change-Id: I13dd31d71b8b93adadb70b113cba28ce5aed6e4e Signed-off-by: Jack Pham <jackp@codeaurora.org>
* | Policy_engine: Add module parameter to disable PDVijayavardhan Vennapusa2017-06-09
| | | | | | | | | | | | | | | | | | | | | | | | Currently power Delivery (PD) is enabled by default which sends PD Hard reset in SINK mode to negogiate PD contract with host machine after connect, if no capabilities message is received from other device. This impacts with compliance for example: PMI ignores type-c disconnects during PD Hard Reset. Add module parameter to disable PD so that it doesn't enable PD communication during USB3.1 compliance testing. Change-Id: Ia3e39cee1e65895402c18b380b650f0a34fb0cec Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
* | Merge "PD: policy_engine: Add timeout for mode change through sysfs"Linux Build Service Account2017-06-09
|\ \
| * | PD: policy_engine: Add timeout for mode change through sysfsVijayavardhan Vennapusa2017-06-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently USB driver tries to set power role as none and waits for disconnect notification to set new mode. But there is a chance that it might fail and stuck in infinite loop if other device is not dual-role capable. Fix it by having timeout and bail out in case timeout happens. Change-Id: I569356ee445c53950ed8fdd3f9994d4ae0e86131 Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
* | | Merge "usb: pd: Increment MessageID only on successful TX"Linux Build Service Account2017-06-07
|\ \ \
| * | | usb: pd: Increment MessageID only on successful TXJack Pham2017-06-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to the PD 2.0 Spec, Section 6.2.1.3, the MessageID field shall only be incremented upon successful transmission (meaning GoodCRC was received). Thus, increment the counter only when pd_phy_write() succeeds. Change-Id: I73dce5736c473a1f79db9be868442c7941d13c44 Signed-off-by: Jack Pham <jackp@codeaurora.org>
| * | | usb: pdphy: Prevent sending when message is just receivedJack Pham2017-06-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prevent pd_phy_write() from sending a TX message if an RX message IRQ is being handled, or if the RX_TOKEN is set (indicating a message has just arrived) by returning -EBUSY to let the upper layer gracefully abort. This helps in cases (such as compliance testing) in which VDM messages are received very quickly after one another and the protocol layer needs to first handle the incoming message. Change-Id: I3e26d7ff062ff7f51b6c66ab8d078b05749f808a Signed-off-by: Jack Pham <jackp@codeaurora.org>
| * | | usb: pd: Keep PROP_PR_SWAP set during ERROR_RECOVERYJack Pham2017-06-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since ErrorRecovery handling requires a spoof disconnect, the charger driver needs to avoid immediately reapplying the terminations. Re-use the PROP_PR_SWAP property which ignores the disconnect. After the 25ms delay, policy engine will explicitly reset back to DRP. Also remove the transition to ErrorRecovery from PE_SNK_DISCOVERY as it is removed in V1.3 of the PD 2.0 specification. Change-Id: I41f1da293208b6813dfb540a123ee84ac35b4a68 Signed-off-by: Jack Pham <jackp@codeaurora.org>
| * | | usb: pd: Set PD_IN_HARD_RESET as soon as hard reset receivedJack Pham2017-06-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move setting of PD_IN_HARD_RESET to the phy_sig_received() callback in order to inform the charger to ignore the upcoming VBUS toggle as soon as possible. This will help decrease the possibility of racing to set the appropriate HW bits while VBUS turns off and leads to the charger indicating disconnect. Change-Id: I42cc2969defa48c9987fa4bea64780866861d868 Signed-off-by: Jack Pham <jackp@codeaurora.org>
| * | | usb: pd: Don't draw current during sink hard resetJack Pham2017-05-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During hard reset inform charger driver to suspend current draw as the sink should not draw more than 1mA while VBUS is driven to VSafe0V. Once VBUS returns to VSafe5V the current draw can be restored when contract is re-established. Change-Id: I3f529c861706d4544f3c8b65d6fc6be47a598309 Signed-off-by: Jack Pham <jackp@codeaurora.org>
| * | | usb: pd: Notify charger when PR Swap is in progressJack Pham2017-05-26
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | Charger driver needs to know when PR Swap is happening in order to avoid resetting state when the disconnect (which is expected) occurs. Utilize the new power supply PR_SWAP property to notify whenever PD is in PR Swap. Change-Id: I13fdbd4a3cf3e0716d48d1268795189f6b064598 Signed-off-by: Jack Pham <jackp@codeaurora.org>
* | | Merge "policy_engine: Add module parameter to start USB stack"Linux Build Service Account2017-06-07
|\ \ \
| * | | policy_engine: Add module parameter to start USB stackVijayavardhan Vennapusa2017-06-05
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | USB 3.1 super speed compliance equipment may be detected as floating charger by PMI as it may leave D+/D- lines floating (High speed data lines). PD Policy engine does not start USB stack which results into compliance failure as compliance expects USB stack to be started. Add module parameter usb_compliance_mode to start USB stack on cable connect (w/o depending on charger type). Change-Id: Ieb33057a85b4bcff9c1e7c32c256663dd23f17ef Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
* | | usb: pd: policy_engine: Handle spec revision properlyHemant Kumar2017-06-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As per USB PD 3.0 specification the 2-bit Specification Revision field of a GoodCRC Message does not carry any meaning and Shall be considered as don't care by the recipient of the Message. Hence set spec revision to USBPD_REV_20 for GoodCRC message. PD protocol message header defaults to USBPD_REV_20 which gets updated USBPD_REV_30 if PD 3.0 source capabale of programmable power supply. Change-Id: I5209bb00c437f3c959d093a972f1ac75233cbcf9 Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | | Merge "usb: pd: policy_engine: Handle Get_Source_Cap properly from PE_SRC_Ready"Linux Build Service Account2017-05-31
|\ \ \
| * | | usb: pd: policy_engine: Handle Get_Source_Cap properly from PE_SRC_ReadyHemant Kumar2017-05-30
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Get_Source_Cap message is responded by sending source capability message without running sender response timer after GoodCRC is received. As a result if sender response is timed out driver is not issuing hard reset. Fix the issue by moving policy engine state from PE_SRC_READY to PE_SRC_SEND_CAPABILITIES which starts sender response timer and handles timeout. Change-Id: Id47a4c8f989db19d28ef9c8b2c069d0b7797e17f Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | | Merge "usb: pd: Rerun usbpd_sm if RX queue is not empty"Linux Build Service Account2017-05-31
|\ \ \
| * | | usb: pd: Rerun usbpd_sm if RX queue is not emptyJack Pham2017-05-31
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upon receiving a PD message the state machine is queued to act on it. However, if another message is received quickly before usbpd_sm is scheduled, it will only process the first message. Add a check if the RX queue is not empty in order to drain the messages properly. Change-Id: Ie9e079a51a5740024c9a1be5ba27b3edacf9b2df Signed-off-by: Jack Pham <jackp@codeaurora.org>
* | | Merge "usb: pd: Re-check for disconnect after PR swap"Linux Build Service Account2017-05-30
|\ \ \ | |/ / |/| |
| * | usb: pd: Re-check for disconnect after PR swapJack Pham2017-04-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During SNK->SRC PR Swap, the in_pr_swap flag is set and is used to ignore the Type-C disconnect notification from the charger since that is expected to happen. However, if the "sink connect" notification never arrives, the swap operation is incomplete, indicating the port partner has either disconnected or is unresponsive. But since the state machine ignored the disconnect, it continues until reaching SRC_DISABLED due to no response, and that is a dead-end state. Add one more check here to see if the CC state is still disconnected and set current_pr PR_NONE to get the state machine to process the disconnect. Similarly do this for PE_SRC_HARD_RESET as that is an extension of the above if a physical disconnect occurred after successful sending of capabilities but before receiving a request and the response timer times out. Again the disconnect notification during the previous swap was ignored and no new CC state change arrived. Change-Id: Ib28c541cff36a895f9a75cb67161dd116f3eb47f Signed-off-by: Jack Pham <jackp@codeaurora.org>
* | | Merge "usb: pd: policy_engine: Disable vconn first upon disconnect"Linux Build Service Account2017-05-26
|\ \ \
| * | | usb: pd: policy_engine: Disable vconn first upon disconnectHemant Kumar2017-05-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently vconn is getting disabled late after disabling vbus. This is causing failure if type-C compliance TD.4.8.3(DRP Connect Alternate Mode), as delay is disabling vconn goes above 35ms. Fix the issue by moving vconn disable as first step upon receiving disconnect notification. Also, making policy engine workqueue as high priority workqueue to be able to run state machine work with lower latency. Change-Id: If9a979b4cc5bab3aa2ebf42397c36e5b434b50b9 Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>