Currently the code prevents pd if an hvdcp is detected. We want to
change that in that we want to prevent pd only while hvdcp detection
is in progress. Once completed, we need to enable pd even if an hvdcp
is detected. Enabling PD even for hvdcp allows us to detect a QC 4.0
which communicates over PD.
Currently we model the pd_allowed votable as an enable votable i.e.
if any one of the voters enable it, pd_allowed gets enabled.
Change that to a disable votable named pd_disallowed_votable,
which gets disabled when CC is detached, and hvdcp2.0 detection is not
yet completed.
Change-Id: I2ae261c71694695b41d8a31c4b40542d5e227c3a
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Some platforms do not support HVDCP charging. Provide means to
disable them.
Provide a votable for disabling HVDCP in preparation to handle
VBUS and CC line shorted situation.
Note that when hvdcp is disabled, we only disable voltage
negotiations i.e. qc 2.0 detection remains enabled since it
does not need voltage to change.
Change-Id: Id7eaa46f08ac451a918a550f7837efbef78ab6f6
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
When a float charger is detected by APSD there are configuration options
that change the behavior of the charger. These options should be
configurable from the device tree. Add a DT parameter "qcom,float-option"
and configure it as follows:
1 - Treat as a DCP
2 - Treat as a SDP
3 - Disable charging
4 - Suspend USB input
Change-Id: Ia9219bc232f2092569dfb1a14f628e788173c4ff
Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
It is useful when debugging to force power supply changed events. Add
debugfs entries for each power supply to allow forcing power supply
changed events.
Change-Id: I018eb018de2a8119acc09824c82cca8ff1b52faa
Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
The PARALLEL_PERCENT property is used for the parallel distribution
percentage.
Change-Id: I7d2a7a775437770075ddbd2d1a36ce5d9e44a631
Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
900mA can be drawn from a USB 3.0 port that has been enumerated. Do it.
Change-Id: I94e5d36feb3cd54bcc46e8c56933340cad839c1f
Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
The SMB138X TADC can provide the parallel charger with the
measured battery current. Enable it.
Change-Id: I32e5e5ed4ab3f09635f4fe512a1e9b75436ab88e
Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
Switch to setting the POWER_SUPPLY_PROP_PD_CURRENT_MAX for
indicating the current limit to the charger driver when
an explicit contract is established. Also set the
POWER_SUPPLY_PROP_PD_USB_SUSPEND_SUPPORTED property whenever
encountering the "USB Suspend Supported" bit in the first
PDO of a Source Capabilities message. This is an indication
to the charger that when the USB bus enters suspend state that
it should follow suspend rules according to USB 2.0/3.1 spec.
Change-Id: I665ec788a770632b4849b9beff8444d00e956ce1
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Charger may be able to detect a legacy cable connection in which
PD is not supported however the state machine still needs to
run in order to send the EXTCON_USB notification to start the
USB controller in peripheral mode (assuming type is SDP or CDP).
Move checking of PD_ALLOWED to the state machine which can be used
to determine if moving beyond PE_SNK_STARTUP is allowed or not.
The psy_changed() callback should only queue the work when either
typec_mode or pd_allowed states have changed. Also move handling
of the in_pr_swap flag to this function by absorbing the
disconnect callback and clearing the flag when CC state indicates
it is reconnected.
Change-Id: I8879699531a49915e7286e4a166944709076fbd1
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Set the POWER_SUPPLY_PROP_PD_IN_HARD_RESET when hard reset
has been issued and clear it when completed. This replaces
the previous use of PD_ACTIVE which is now used to indicate
assertively whether the port partner is PD capable or not.
As such, since charger driver now definitively knows, it is
also not necessary to explicitly change PROP_TYPE to USB_PD.
Change-Id: I4d8c9fcdf553d1cf1ae79c66932773834804d1a9
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Add additional properties for USB PD usage:
- POWER_SUPPLY_PROP_PD_IN_HARD_RESET is set when PD is
undergoing a hard reset
- POWER_SUPPLY_PROP_PD_CURRENT_MAX used to indicate the
current limit as negotiated over PD
- POWER_SUPPLY_PROP_PD_USB_SUSPEND_SUPPORTED is set when
USB suspend current limit must be honored when USB bus
is suspended
Also add enums to distinguish PD activity state: inactive, active.
Change-Id: I0a3d98ac1e1202e5b655b2e3a8102691b61359c8
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Support incoming VCONN Swap requests by accepting and turning
off/on VCONN.
Due to HW board limitations, if VCONN is being sourced from the
VBUS input we cannot support enabling VCONN while as a sink and
greater than 5V has been negotiated on VBUS. In that case, reject
the request. Add a device tree property that indicates whether
the board is configured for separate VCONN supply.
Change-Id: If3a9aa316ae08a80468631f3d536a1b345e21b18
Signed-off-by: Jack Pham <jackp@codeaurora.org>
With PM autosleep enabled, the system may aggressively enter
and re-enter suspend in between calls to queue_work() and
when the state machine function gets executed, which may
at best result in numerous suspend/resume cycles and at
worse starve the PD state machine from even executing.
Fix this by calling pm_stay_awake() whenever the work is
queued and relinquish with pm_relax() when no further work
is to be done.
Change-Id: I71d8ea0c69a7b174c2280f92d1f5342e5e50d9b0
Signed-off-by: Jack Pham <jackp@codeaurora.org>
VDMs, especially structured ones, are almost always handled
as requests and responses. Hence it does not make sense to
allow more than one outgoing VDM at a time, so get rid of the
vdm_tx_queue list and simplify it to a single-issued packet.
Because port partners can only have one VDM request/response in
flight, also handle the case when a new structured request is
received before the previous response has been sent. In that
case we simply discard the queued message as it's now invalid.
Change-Id: I144f8158dbf8be0babf5516b01d084fd053413c3
Signed-off-by: Jack Pham <jackp@codeaurora.org>
As UFP since the policy engine only responds to the Discover
Identity command, all other commands are unrecognized and
therefore should be NAKed. Fix the handling as follows:
- Ensure the standard Discover Identity was sent using
SID of 0xFF00, otherwise it is invalid
- Don't NAK incoming Attention messages
- When sending a NAK, respond with the same SVID of the
initiating command, whether it was correct or not
- Enter Mode is not supported in general, but the NAK
should also be sent back with the same mode index
- Re-issue Discover SVIDs when more than 12 SVIDs are returned
- Clean up macro name prefixes from 'VDM' to 'SVDM' to
emphasize they are accessing structured VDM specific bits
Change-Id: Id2590065a01e46f8da70733d55f3bfabff5b532d
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Fix several issues which help address PD compliance testing:
- Soft reset should be issued instead of hard reset in cases
where an unexpected message is received.
- In source mode, send a Reject if the Request PDO object also
exceeds the advertised current capability. Fix the incorrect
bitmask in the PD_RDO_FIXED_CURR macro.
- Handle possibility of quick back-to-back RX messages by
flushing the sm worker to ensure the last message was fully
processed before overwriting the buffer.
- Discard PING messages as they are not applicable to Type-C.
- Respond to GET_SINK_CAP while in source mode, and vice
versa, respond to GET_SOURCE_CAP when in sink mode.
- Move pd->hard_reset=false to PE_SRC/SNK_TRANSITION_TO_DEFAULT
for consistency.
- Change default sink capabilities to advertise only 5V @ 900mA
since the policy engine will not automatically request higher
voltages. If userspace wants to request greater than 5V it should
also update the sink capabilities.
- Reset the protocol counters at the beginning of PE_SNK_STARTUP.
Change-Id: I44598eb0b49efd763f86f303c70e8b018fca994b
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Some UDC driver doesn't allow or throw errors when USB request buffer
queued is unaligned i.e. buffer size is not equal to wMaxPacketSize or
multiple of wMaxPacketSize. Fix this issue by using 1024 bytes as MIDI
buffer size instead of 256 bytes.
Change-Id: I71d520a5a800a3e612dc4d57e7baffa93fad61b3
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Add support for Lpass PIL which facilitates the loading of Lpass
firmware, authentication and bringing it out of reset.
Change-Id: I587b39bc302449591cc0c71ff15b740374a8af4d
Signed-off-by: Gaurav Kohli <gkohli@codeaurora.org>