summaryrefslogtreecommitdiff
path: root/board/samus_pd/usb_pd_policy.c
Commit message (Collapse)AuthorAgeFilesLines
* Deferred: Use deferred_data instead of function pointerAnton Staaf2016-04-181-2/+3
| | | | | | | | | | | | | | | | | | | | | Previously calls to hook_call_deferred were passed the function to call, which was then looked up in the .rodata.deferred section with a linear search. This linear search can be replaced with a subtract by passing the pointer to the deferred_data object created when DECLARE_DEFERRED was invoked. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None CQ-DEPEND=CL:*255812 TEST=make buildall -j Change-Id: I951dd1541302875b102dd086154cf05591694440 Reviewed-on: https://chromium-review.googlesource.com/334315 Commit-Ready: Bill Richardson <wfrichar@chromium.org> Tested-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* samus_pd: Use less flash spaceShawn Nematbakhsh2016-04-031-1/+1
| | | | | | | | | | | | | | | | - Reduce the size of some board-level strings - Undef two rarely-used console commands BUG=chrome-os-partner:34489 BRANCH=None TEST=`make buildall -j` Change-Id: I34d599adccce97a62e28e7444854081f068029c3 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/336814 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* cleanup: pd: remove duplicate code for checking request msgAlec Berg2015-10-131-26/+0
| | | | | | | | | | | | | | | | Remove duplicate code for checking request message, but keep a board specific check of the request message for custom checks needed on zinger and plankton. BUG=chrome-os-partner:42490 BRANCH=none TEST=make -j buildall. run on samus and connect a hoho, make sure we successfully negotiate a contract. Change-Id: I7398953a158d340e3e113f5a816b55445a857711 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/305374 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* pd: set USB communications capable flag in PDOAlec Berg2015-09-181-1/+2
| | | | | | | | | | | | | | | | | | Set USB communications capable flag in source/sink capabilities PDO on boards that support USB. This signals to other side that we are capable of communication over D+/D- or SS Tx/Rx. BUG=chrome-os-partner:34982 BRANCH=samus,smaug TEST=load on samus, use twinkie to sniff traffic, verify that USB comms capable bit is set in source cap packet Change-Id: I0f49cf19eb141512298c3439a4708c53101d674f Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/300637 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* usb_mux: Add driver interface for USB-C muxesShawn Nematbakhsh2015-06-301-4/+5
| | | | | | | | | | | | | | | | | | | | In preparation for adding support for additional USB-C mux chips, add a new high-level USB-C mux interface usb_mux.c. usb_mux functions are now called from pd code instead of board-level functions. usb_mux calls down into a mux chip-specific driver (currently pi3usb30532) or board-specific drivers which toggle GPIOs (for legacy boards). BUG=chrome-os-partner:41696 TEST=Manual on Glados in subsequent commit. Verify set() and get() functions set and return consistent values. Verify that USB SS device functions when muxes are set to dock or USB. Also, verify that DP dongle and USB SS device are functional on both PD ports on samus_pd. BRANCH=None Change-Id: Ib6477f489310f3be1430585ea09fea26f57e3752 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/281435 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* pd: Fix pin mode field in DP config VDM.Todd Broch2015-06-171-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | VESA SCR titled, 'DP Alt Mode Plug Corrections & Protocol Clarif' Simplified the DP config mode VDM to longer include two separate bytes for UFP vs DFP pin modes since bits <1:0> designate the desired port direction. This change corrects our VDM accordingly so that <23:16> are now zero (SBZ) and <15:8> carry the appropriate pin mode. Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus_pd BUG=chromium:501002 TEST=manual, 1. samus -> hoho, dingdong or apple hdmi dongles still drive DPout 2. twinkie console output samus -> hoho shows correct DP config VDM 369.275296 SRC/2 [256f]VDM Vff01:DPCFG,INI:ff018111 00000406 where: <31:16> = SBZ == 0x0000 <15:08> = PIN_C == 0x04 Change-Id: I1146045dd94458c82b7ed08940af6009658afa05 Reviewed-on: https://chromium-review.googlesource.com/278083 Commit-Queue: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org>
* pd: Refine HPD debounce values.Todd Broch2015-05-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Change refines HPD debounce values into both upstream and downstream values for packetizing across the type-C link. For LVL, the upstream type-C device will packetize any HPD transition >=2ms as either HIGH or LOW. On the downstream side the value is driven immediately. Additional debouncing should be done by true upstream device according to specification. For IRQ, the upstream type-C device will packetize any HPD pulse >250usec as an IRQ. On the downstream side it will be de-packetized to create 750usec pulse. Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=chrome-os-partner:39717 TEST=samus|macbook(2015) + hoho|dingdong|apple HDMI type-C dongles still drive screens successfully. Change-Id: Ide58f3b2d675a82c12ca6afc2be53ca6e2561ace Reviewed-on: https://chromium-review.googlesource.com/273867 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org>
* pd: move non-phy layer config out of usb_pd_config.hAlec Berg2015-05-271-3/+8
| | | | | | | | | | | | | | | | | | | | | Move parts of usb_pd_config.h that are not part of the phy layer out of usb_pd_config.h and into board.h. This cleans up the division between the TCPC and TCPM as only the TCPC needs to use usb_pd_config.h. Also cleans up the use of the CC detection voltage thresholds by creating standard macros to use based on Rp strength for the board. BUG=none BRANCH=none TEST=make -j buildall Change-Id: I946cceb38bea8233095b8a4b287102bb8a3a296d Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/270337 Reviewed-by: Todd Broch <tbroch@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* pd: add explicit setting of D+/D- switch when setting type-C muxesAlec Berg2015-05-051-2/+2
| | | | | | | | | | | | | | | | | | | Add explicit setting of USB D+/D- switch when setting the type-C muxes. This fixes a bug in which we would open D+/D- switch when entering DP mode and lose USB2.0 connection. BUG=chrome-os-partner:39766 BRANCH=samus TEST=add printf to board_set_usb_switches() on samus and make sure we don't open the D+/D- switch when entering DP mode. Change-Id: I2b5bb2185298794ddb4cc457f3695ce6adabd9f8 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/268993 Reviewed-by: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Scott Collyer <scollyer@chromium.org>
* pd: Allow for setting USB mux when swapping into DFP roleScott2015-05-011-2/+1
| | | | | | | | | | | | | | | | | | | | | - Added config option CONFIG_USBC_SS_MUX_DFP_ONLY - If this options is enabled, then the mux is set to TYPEC_USB_MUX only is data role is DFP. - If this option is not enabled, the mux is set for both UFP and DFP (i.e. RYU) BUG=chrome-os-partner:39059 TEST=Manual samus to plankton, switching between source and sink modes. Forced data role swap via ec console command. BRANCH=Samus Change-Id: Ibc2fb0ad42d0fe415d3338d38da94ad4b041513b Signed-off-by: Scott Collyer <scollyer@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/266916 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Alec Berg <alecaberg@chromium.org>
* samus_pd: Increase HPD IRQ pulse to 2msec.Todd Broch2015-05-011-2/+2
| | | | | | | | | | | | | | | | | | | Intel DP sees HPD pulse as 2msec < x < 100msec. While DP spec mentions pulse widths >250usec as acceptable they aren't recognized by i915 driver. CL increases the HPD_IRQ pulse width to 2msec minimum. BRANCH=samus BUG=chrome-os-partner:39717 TEST=manual samus + apple hdmi multiport dongle drivers external screen. Change-Id: I32c33f938ba1aa7a3927a0f75a1269b1278e82de Signed-off-by: Todd Broch <tbroch@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/268653 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
* samus_pd: Request different DP pin modes including multi-function.Todd Broch2015-04-301-4/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously samus_pd just picked pin mode E without regard to what the UFP was requesting. This change surveys the UFP's DP pin capabilities and then requests the appropriate pin config. Additionally if the UFP supports multi-function and has preferred it during the initial DP status message, samus will configure its type-c mux in 'dock' mode. Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=chrome-os-partner:38728 TEST=manual, 1. hoho + samus, pin mode = 'C' 2. dingdong + samus, pin mode = 'E'. 3. apple type-C HDMI multiport + samus, pin mode = 'D' and USB device enumerates as SuperSpeed. 4. plankton + samus w/ patch asserting alternate mode with multi-function preferred sets config to 'F' now and only drives DP out on 2 lanes w/ other two allowing USB key to be seen. Change-Id: Ie4764c33f108e8a88f0052b64ddb96cb92e5a78b Reviewed-on: https://chromium-review.googlesource.com/267796 Commit-Queue: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* samus_pd: Cleanup HPD port calls.Todd Broch2015-04-301-10/+5
| | | | | | | | | | | | | | | Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=chrome-os-partner:38728 TEST=make buildall -j Change-Id: I6be4e59daf7d79f643a6e4fa6400d6f13f521ea4 Reviewed-on: https://chromium-review.googlesource.com/267795 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org>
* samus_pd: Remove pin configuration for DFP_D.Todd Broch2015-04-301-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Samus does NOT provide any sink capabilities for DisplayPort or USB device mode so it should NOT request UFP_U select any pin assignments for DFP_D. Additionally even if this functionality was provided by the DFP the specification states, 'and one pin assignment for either the DFP_D or UFP_D'. This did NOT cause any functional issues but strictly speaking is a compliance bug. Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=chrome-os-partner:38728 TEST=manual, hoho still successfully drives external monitor. Change-Id: Iea3441989924dcee69fdb83299ef7e817df55683 Reviewed-on: https://chromium-review.googlesource.com/267794 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org>
* pd: samus: support vconn swap and enable on Samus when in S0/S3Alec Berg2015-04-111-0/+6
| | | | | | | | | | | | | | | | | Support VCONN swap on samus and always accept VCONN swap when in S0 or S3. In S5, we can't provide VCONN, so reject VCONN swap requests. BUG=chrome-os-partner:34978 BRANCH=samus TEST=load on two samus' and use "pd 1 swap vconn" to swap which side is source vconn. also run in S5 and verify swap request is rejected. Change-Id: I04be8d1d910a2d6c5ad8b27a790f8e33121c86ee Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/264856 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* pd: treat externally powered dualrole devices as dedicated chargersAlec Berg2015-04-071-7/+19
| | | | | | | | | | | | | | | | | | | | | Treat externally powered dualrole devices as dedicated chargers. This allows us to default to consuming power from externally powered dualrole devices and cancels a charger override when one is attached. BUG=chrome-os-partner:38785 BRANCH=samus TEST=tested with third-party dualrole device that can be externally powered. also tested with another samus that was hard-coded with externally powered bit set, and deleted it's policy for power swapping. when this externally-powered samus is plugged into a samus running this CL, we always charge from the externally-powered samus. Change-Id: I850eba668e86d311d9353aa3881fc3a518409630 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/263331 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* samus_pd: ryu: change sink capabilities for voltage inaccuracyAlec Berg2015-04-031-2/+2
| | | | | | | | | | | | | | | Change sink capabilities to account for +/-5% voltage inaccuracy for variable and battery PDOs. BUG=none BRANCH=samus TEST=test with third party variable power supply and make sure it see's our sink capabilities as 4.75V-21V. Change-Id: Id793142c486dfc908c81c4894b2ec48f99c868f4 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/263295 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* charge_manager: Wait for dualrole determination before chargingShawn Nematbakhsh2015-02-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | If a dual-role charger is plugged, we will not realize it is dual-role until after we see a type-C charge source. It can cause us to briefly charge from a dual-role charger, which has bad side effects related to charge override and the lightbar. Fix this by not charging from a port until we are fairly certain that it is a dedicated charger (based upon PD discovery timeout). BUG=chrome-os-partner:36390 TEST=Manual on Samus. Insert 1A Apple charger, verify correct detection. Run 'chgoverride -2' to prevent charging, then repeatedly insert + remove a dual-role charger on the other charge port. Verify that charging is still prevented. Finally, insert a dedicated charger and verify that the override is removed. Also, pass unit tests and verify correct detection in various scenarios with various chargers. BRANCH=Samus Change-Id: Ia4154f34dd0a850b6e72bebadbd938f034532f14 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/247130 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* pd: Allow multiple mode entry.Todd Broch2015-01-281-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current simplified implementation allows single mode entry. Specification allows multiple mode entry and its advantageous for things like flashing RW while staying in DisplayPort mode on video dongles. CL adds capability on DFP to track as many alternate modes as supported by the DFP. Initial mode entered is still the default supported mode ( 1st entry, 1st opos). Policy manager can then use host command, EC_CMD_USB_PD_SET_AMODE, to enter additional supported modes. On the UFP (hoho, dingdong) a small modification to track multiple svid mode entries was made. Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=chrome-os-partner:33946 TEST=manual, On hoho 1. Still successfully enter default mode DP 2. Using ectool's pdsetmode can successfully enter/exit multiple modes. For example, # port:1 svid:18d1 opos:1 cmd:1==enter ectool --name cros_pd pdsetmode 1 0x18d1 1 1 Checking with pdgetmode shows both modes entered. 3. Works across hard & soft resets 4. Can flash via ectool --name cros_pd flashpd 4 <port> <RW image> 5. Still drives external display. With bootarg drm.debug=0x6 and following command: 'tail -f /var/log/messages | grep "Received HPD" &' I see HPD assert & deassert when switching between GFU and DP mode. If both modes entered screen stays lit (after reboot) during write. Change-Id: I7a21ebea377402eb1b0a0cf1d29df59694e301b1 Reviewed-on: https://chromium-review.googlesource.com/241790 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org>
* pd: retrieve logs from accessoriesVincent Palatin2015-01-211-0/+3
| | | | | | | | | | | | | | | | | Send the VDO_CMD_GET_LOG VDM to accessories to get their PD event log and append it to the PD MCU log. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=chrome-os-partner:33248 chrome-os-partner:32785 TEST=ectool --name=cros_pd pdlog Change-Id: Ib52d1e2cae5f77dcec6d0489eaa49527388b02b6 Reviewed-on: https://chromium-review.googlesource.com/242013 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Alec Berg <alecaberg@chromium.org>
* pd: Remove verbosity from console during pd flashing.Todd Broch2015-01-201-1/+0
| | | | | | | | | | | | | | | | | | | Commit 74fd6f9 largely got rid of default printing of VDM traffic to console but one in custom_vdm was missed. Lets remove it too. Note can still view these by 'pd dump 1' Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=none TEST=manual when pd flashing samus_pd console (chan usbpd) is quiet. Change-Id: Idc04750de09572df8d5b15afcdde63f6afc4b5e2 Reviewed-on: https://chromium-review.googlesource.com/241952 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org>
* pd: samus: do not request voltage within boost bypass deadbandAlec Berg2015-01-171-0/+14
| | | | | | | | | | | | | | | | | Do not request a voltage that is within the deadband where we aren't sure if the boost or the boost bypass is on. BUG=chrome-os-partner:34938 BRANCH=samus TEST=test on samus with zinger. change the deadband to [10V, 20V] and see that we only negotiate to 5V. change the deadband to [13V, 20V] and see that we negotiate to 12V. change the deadband to [10V, 13V] and see that we negotiate to 20V. Change-Id: Id761aef35eeadfa2ab7d2ca31a48d4324625ab32 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/241528 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* samus_pd: Restore usb data switches after pericom resetShawn Nematbakhsh2015-01-171-2/+1
| | | | | | | | | | | | | | | | Resetting the pericom charge detector resets all registers, so it's necessary to restore the state of the USB data switches, in case we want them to be open. BUG=chrome-os-partner:35394 TEST=Manual on Samus. Trigger data swap to UFP, verify that USB switches become open. BRANCH=Samus Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: I32b1cf92a05abaab9ecd532537790e72f8f409bc Reviewed-on: https://chromium-review.googlesource.com/240538 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* samus_pd: Don't re-request FW update if RW is already the latestShawn Nematbakhsh2015-01-171-5/+14
| | | | | | | | | | | | | | | | | | The AP informs us of the latest update image for a given device through the EC_CMD_USB_PD_RW_HASH_ENTRY command. If the latest update image is equivalent to our RW, we don't need to request an update. BUG=chrome-os-partner:35510 TEST=Manual on Samus. Flash latest RW FW to Zinger. Verify that subsequent Zinger insertion doesn't trigger the FW update host event. Insert RO-stuck Zinger and verify that FW update host event is triggered. BRANCH=Samus Change-Id: I300b150b3469e3fe32307e61273880a1a052ac5a Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/241172 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* pd: Shorten console error strings.Todd Broch2015-01-161-1/+1
| | | | | | | | | | | | | | Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=chrome-os-partner:34498 TEST=compiles, saves ~100 bytes Change-Id: Ic6e1d86198b3ca2b6582414254ca80f910ff1644 Reviewed-on: https://chromium-review.googlesource.com/241091 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org>
* pd: Queue initial DFP HPD till after DP Config VDM.Todd Broch2015-01-091-5/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | VESA DisplayPort Alt Mode on USB Type-C Standard specifies: When DisplayPort Configuration is not selected (and the converter is driving its HPD output low), the converter shall track the current state of HPD, ready for appropriate indication when DisplayPort Configuration is subsequently selected. Not only are we violating specification here but it also causes a race between enabling DPout muxes to AUX line which in turn causes GPU to timeout trying to read EDID/DPCD on occasion. Change adds post_config function for DFPs alternate mode and in the case of DP it sets the dp_on flag there. This allows attention function to correctly defer HPD_HI that may accompany 'DP status' VDM to be queued (deferred) until such time that AUX muxes are enabled properly. Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=chrome-os-partner:35219 TEST=manual, using hoho & dingdong With kernel bootarg drm.debug=0x6 following cases all show these drm debug lines: [drm:i915_hotplug_work_func], Connector DP-2 (pin 5) received hotplug event. [drm:intel_dp_get_dpcd], DPCD: 12 14 c4 01 01 00 01 00 02 02 06 00 00 00 00 [drm:intel_hpd_irq_event], [CONNECTOR:38:DP-2] status updated from disconnected to connected case1: boot connected to external display case2: attach dongle to external display then samus case3: attach dongle to samus then to external display case4: connect/disconnect rapidly on type-C side case5: connect/disconnect rapidly on external display side. Change-Id: I40eab797fdd5090c8ad13fae2cd053b740d9a307 Reviewed-on: https://chromium-review.googlesource.com/239420 Trybot-Ready: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org>
* samus: pd: reject power swap if not in dual-role modeAlec Berg2015-01-081-2/+6
| | | | | | | | | | | | | | | Samus should reject request for a power swap if it is not in a dual-role mode, for instance if in S3 or lower. BUG=chrome-os-partner:35141 BRANCH=samus TEST=load on two samus'. turn on samus off, then request a power swap from the samus that is on and see that it is rejected. Change-Id: Ifb23febac967c981251c3932856e1e942818694f Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/238963 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* samus: pd: on PD connection, if sink, ask for power swapAlec Berg2015-01-071-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For samus, on PD connection or on resume to S0, if we are a sink, and the other side supports PR_SWAP, then attempt a power swap. This adds callback functions into board policy file to check and issue power or data swaps if required by the product. BUG=chrome-os-partner:31195 BRANCH=samus TEST=connect samus to zinger and make sure zinger always ends up as SRC-UFP. connect samus to samus with both in S0 and see that they swap power roles once and not data roles. connect one samus in S0 to one samus in S5 and see that the one in S5 is sink. then when you boot the one in S5 it switches to a source. connect samus to samus with both in S0. do chgoverride 1 on one side to start charging from the other samus. then on the same side, turn off the machine (S5) and resume (S0), and see that it is still charging from the other samus (ie has not switched roles to source). Change-Id: Ifab2465fccef77448ac4771a3c2de1c867cbbec4 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/238302 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* pd: vdm: remove replicated VDM code.Todd Broch2014-12-221-10/+2
| | | | | | | | | | | | | | | | Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=chrome-os-partner:30645 TEST=manual, Still see alternate mode entry and can use flash VDMS Change-Id: Id7371960a20e7d26a15b3a40ca40aa03b6595956 Reviewed-on: https://chromium-review.googlesource.com/235681 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org>
* pd: Modify EC_CMD_USB_PD_RW_HASH_ENTRY to return PD device image typeShawn Nematbakhsh2014-12-201-3/+9
| | | | | | | | | | | | | | | | This addition allows the AP to query whether the PD device is currently running from RO or RW FW. BUG=chrome-os-partner:34599 TEST=Manual on Samus. Run 'ectool --name cros_pd infopddev 0' and verify that correct RO/RW status of Zinger is printed. Verify that the output matches the index printed by "pd 1 hash" on samus_pd console. BRANCH=Samus Change-Id: I4266cae931f5c7855ca0531717c4a18b138b2d62 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/236771 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* pd: refactor pd policy layer request voltage functionsAlec Berg2014-12-111-93/+0
| | | | | | | | | | | | | | | | | | | Remove common code across all PD policy layers to select the requested voltage and build a Request Data Object (RDO). BUG=none BRANCH=samus TEST=Load onto samus and connect zinger. Make sure we request the right voltage (first 5V, then after initial contract is made, 20V). Make sure input current limit is set appropriately by checking limit on EC console using charger command. Change-Id: Ic6bda5e23b2d7b7d710ffdf085e7fbc1b0c3add9 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/233673 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Shawn Nematbakhsh <shawnn@chromium.org> Tested-by: Shawn Nematbakhsh <shawnn@chromium.org>
* usb_pd: protocol field extraction error for RDOBernard Shyu2014-12-101-2/+2
| | | | | | | | | | | | | | | The RDO fields extraction for op_ma & max_ma are reversed in pd_check_requested_voltage() BUG=none BRANCH=none TEST=make buildall Change-Id: Ifa55b94f43c848b383dc1ab59c857612238e8a63 Reviewed-on: https://chromium-review.googlesource.com/233371 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Bernard Shyu <bernard_shyu@bizlinktech.com> Tested-by: Bernard Shyu <bernard_shyu@bizlinktech.com>
* samus_pd: Open USB data switches in UFP modeShawn Nematbakhsh2014-12-091-1/+3
| | | | | | | | | | | | | | | | Samus USB ports can't actually act as UFPs, so open switches when in UFP mode. BUG=chrome-os-partner:32003 TEST=Manual on Samus. Connect two Samus units, run `pd 1 swap data`, verify that switches are opened on switch to UFP. Unplug samus and connect a USB 2.0 device instead, verify that ports are again closed. BRANCH=samus Change-Id: I9e1ca58089caf29e419698c8426bf8b72500833a Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/233711 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* pd: ectool: Expose device id major & minor.Todd Broch2014-12-021-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | Also unifies other console output of same field. Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=chrome-os-partner:32650 TEST=manual # connect zinger to port 1 on samus ectool --name cros_pd infopddev 1 Before: Port:1 Device:1025 Hash: 0x3f34bc13 0xf8d15d12 0xf81f03cf 0xba3a3db6 0x0152a520 Port:1 ptype:5 vid:0x18d1 pid:0x5012 After: Port:1 DevId:1.1 Hash: 0x3f34bc13 0xf8d15d12 0xf81f03cf 0xba3a3db6 0x0152a520 Port:1 ptype:5 vid:0x18d1 pid:0x5012 Change-Id: I4e7ac56354e92ea3bc54a2c6ab5746399abdefe5 Reviewed-on: https://chromium-review.googlesource.com/231832 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org>
* pd: wait tSnkTransition after ACCEPT to change voltageVincent Palatin2014-11-211-2/+7
| | | | | | | | | | | | | | | | | | | Ensure that the PD source changes the output voltage after tSnkTransition delay after having sent the ACCEPT message (rather than before). Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=chrome-os-partner:33684 TEST=connect Zinger to a PD power sink and monitor VBUS and CC while doing a 20V to 5V transition. Change-Id: If86f59eec67630491f4e8dc13a52015ac2de918a Reviewed-on: https://chromium-review.googlesource.com/230805 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* pd: zinger: add firmware update alternate mode to zingerstabilize-6480.BAlec Berg2014-11-151-8/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a Google Firmware Update alternate mode to zinger. This mode must be entered in order to allow the unstructured VDMs that we use for sending a new firmware. BUG=chrome-os-partner:33754 BRANCH=samus TEST=load on samus and zinger. see that "GFU" is printed on zinger console to represent that it entered GFU mode. use twinkie to see that samus sent discover identity, discover svids, discover modes, enter mode, and then read info. See on samus pd console that we received result of read info. from samus pd console with zinger attached: > pe 1 dump IDENT: [ID Header] 2c0018d1 :: AMA, VID:18d1 [Cert Stat] 00000000 [2] 50100001 [3] 00000003 [4] 52136b91 [5] 0401137d SVID[0]: 18d1 MODES: [1] 00000000 MODE[1]: svid:18d1 caps:00000000 Also, use a samus with cros_pd_update running in kernel, and see that zinger auto-updates when plugged in. Performed 10 updates with no failures. Change-Id: I8d4d38e4a9f649fe0889f688f262630ef55106ee Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/229622 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* pd: allow policy layer to ask for PR/DR_swap on new contractAlec Berg2014-11-151-2/+10
| | | | | | | | | | | | | | | | | Allow policy layer to request a PR or DR swap upon formation of a power contract. Zinger always asks for a data swap so it can be a UFP, and Samus asks for a data swap only if it is a UFP to become a DFP. BUG=chrome-os-partner:33754, chrome-os-partner:31195 BRANCH=samus TEST=load onto samus and zinger and make sure they swap roles upon connect with no collisions Change-Id: I275c9669549c26f25c58f80845daad8edab11313 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/229327 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* pd: add data role swapAlec Berg2014-11-141-2/+15
| | | | | | | | | | | | | Add support for DR_swap, data role swap command. BUG=chrome-os-partner:33686, chrome-os-partner:28343 BRANCH=samus TEST=test with samus and zinger. use "pd 1 swap data" command and verify data role swaps by using twinkie and "pd 1 state". Change-Id: I410309199cdeecb26847a6bf217523fdfe688cba Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/229192
* usb_pd: Negotiate minimum power for unused portsShawn Nematbakhsh2014-11-131-3/+29
| | | | | | | | | | | | | | | | | | | | When a PD charger is detected, gets its max charge capability, but initially negotiate for its minimum charge mode. If we later determine that the port will be the one active charge port, re-negotiate for the max charge capability. BUG=chrome-os-partner:32003 TEST=Manual on Samus. Plug in Zinger, verify that current limit is initially set to 500 mA, then switches to 3000 mA shortly after. Plug in two Zingers, verify that one provides 3000 mA current while the other negotiates to 500 mA. Verify that the 500 mA charger bumps up to a high current once becoming active. BRANCH=Samus Change-Id: Ifa562b72d763642fc8bd62bc7f5aaa4eda1ef950 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/225922 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* pd: Send proper OPOS for DP status & config.Todd Broch2014-11-111-2/+4
| | | | | | | | | | | | | | | | | | | | | | | Once a mode is entered object position (OPOS ... AKA alternate mode) field in the VDM header should always track that mode. CL fixes DP status & config messages which did not add the correct OPOS. In fixing I mapped to the UFPs function pd_alt_mode which for the DFP did require the addition of port parameter. Finally I cleaned up code to use this function throughout common policy layer where previously I'd just accessed the pe structure directly. BRANCH=samus_pd BUG=none TEST=manual, compiles, insert hoho/dingdong into samus and see OPOS=1 from samus for enter, dp_config, dp_status SVDMs Change-Id: I66448c3386be01bae58768632da216aff41a9a30 Signed-off-by: Todd Broch <tbroch@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/228130 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Alec Berg <alecaberg@chromium.org>
* pd: for request message, add operational and max currentAlec Berg2014-11-101-9/+26
| | | | | | | | | | | | | | | | | | For request message, add the operational and max current for each board. If the requested power is less than the operational power required, then set mismatch bit. BUG=none BRANCH=samus TEST=make buildall. load onto samus, plug in zinger and see that request 20V, operational current 3000mA and max current of 3000mA. Change-Id: I4df45d88b7e060f66ff5b806f6fe30803f1afcf7 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/227393 Reviewed-by: Todd Broch <tbroch@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* pd: remove redundant 5V source PDOsAlec Berg2014-11-061-1/+0
| | | | | | | | | | | | | | | | Remove redundant 5V source PDOs in source cap packet. We only need one 5V advertisement with the maximum current that we can provide. BUG=none BRANCH=samus TEST=make buildall Change-Id: I94a01813787eb92fafbf600dcbbc8a2f0aa69e2b Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/227392 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org>
* pd: samus: add support for power swap commandAlec Berg2014-11-061-0/+6
| | | | | | | | | | | | | | | | Add support for PR_SWAP command as per PD specification. BUG=chrome-os-partner:28343 BRANCH=samus TEST=test by connecting two samus' and running 'pd 1 swap power' from console. verified that both sides switch power roles by observing console output. also tested against third party devices. Change-Id: I0e8738b544de9f9a4348250630e67d0fefb4486d Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/225559 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* pd: update source/sink cap PDOs and use to get dual role capableAlec Berg2014-11-061-6/+5
| | | | | | | | | | | | | | | | | | | | | Update source and sink capacity tables for all PD boards. As per spec, the first entry in both tables must be a fixed power supply PDO. Added dual-role capable bit to fixed PDOs and added new state variable to keep track of that information for each port. This will be used to make decisions in charge manager and to pass up via host commands. BUG=chrome-os-partner:28869 BRANCH=samus TEST=make buildall. use "pd 1 status" to check if part partner is dual-role capable and check zinger is not, C to A receptable adapter is not, and another samus is. Change-Id: I49f034a372bc145cd524577c17ca210eec4c1013 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/227170 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org>
* samus_pd: add more host events and host cmd to get event statusAlec Berg2014-10-311-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | Add support for more host events and add a host command for the host to use to get which host events have fired. The EC only uses one real host command to notify the AP whenever the PD MCU needs attention so the EC_CMD_PD_HOST_EVENT_STATUS host command can be used to differentiate the possible triggers for the host event. Current events include: PD remote device needs update, type-C power info changed, and PD identity response received. Added host event for power info change, which fires whenever a charger or device is plugged into a type-C port. BUG=chrome-os-partner:32650 BRANCH=samus TEST=tested on samus by connected various peripherals to type-C ports and verifying on EC console that a host event is sent. Change-Id: Ibfc2cafe5826a0ab41aee96a68fdb561c0a2b4ab Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/225841 Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
* samus: use resulting current limit from charge managerAlec Berg2014-10-281-72/+0
| | | | | | | | | | | | | | | | | Send the current limit chosen by charge manager to the EC so that it can set the current limit appropriately. Note, before this change, only the PD negotiated current limit was sent to EC. BUG=none BRANCH=samus TEST=use a non-PD type-C charger and verify current limit gets set appropriately on EC. Change-Id: Ic4bfce052ec8150cad07d35e2cb2fcbfd3d3e6c8 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/225667 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* charge_manager: Move supplier list and priority hierarchy to boardShawn Nematbakhsh2014-10-261-0/+1
| | | | | | | | | | | | | | | | Allow the list of charge suppliers and port selection priority to be specified at the board level. BUG=chrome-os-partner:32650 TEST=Manual on samus_pd. Plug + unplug PD and BC1.2 chargers, verify that PD is always preferred and higher power port / supplier is always selected. BRANCH=Samus Change-Id: Ic867a40120c809111bf76bf290ed6f204eab1168 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/225292 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* pd: for DP mode, only enter mode if device is DFP_U capableAlec Berg2014-10-251-2/+8
| | | | | | | | | | | | | | | | | | Added return parameter to enter mode functions. For DP mode on samus and fruitpie, only send enter mode if device is a DP sink (DFP_U). BUG=none BRANCH=samus TEST=make buildall. tested a simpler version of this with a third-party DFP_D capable device and verified we don't send enter mode. Change-Id: I5caf008b7b3711232aeb1a1012cde2022584109b Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/225288 Reviewed-by: Todd Broch <tbroch@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* pd: Add DFP parsing for alternate mode status & attention.Todd Broch2014-10-251-0/+42
| | | | | | | | | | | | | | | | | | | | | Once alternate mode is entered the DFP will make an initial status request to the UFP. Future status changes on the UFP are then sent to the DFP via the attention command. This VDM consists of the VDM header plus another VDO containing mode specific information. CL adds ability of DFP to consume the attention VDMs status message and in the case of DisplayPort SID toggle the necessary HPD gpio accordingly. BRANCH=samus BUG=chrome-os-partner:30645 TEST=manual, for DFP w/ HPD over CC see HPD toggle correctly without manually driving it providing cable connected when AMA is inserted. Change-Id: Ifef60b5d0170cbcc1b518e3b13e84bac99a17e32 Signed-off-by: Todd Broch <tbroch@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/224769 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* pd: update DP mode signaling bitsVincent Palatin2014-10-241-1/+1
| | | | | | | | | | | | | | | | | | | | | A USB type-C to DisplayPort dongle can support either DPv1.3 or USB Gen 2 signaling. Our dongles need to advertise that they support DPv1.3 and only this. Our DFP needs to request DPv1.3 signaling. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=chrome-os-partner:30645 TEST=Plug a type-C to DP dongle from another vendor to Samus and see a display output. Change-Id: Ie0ac16b675e86f635220a954a2c03442777cc527 Reviewed-on: https://chromium-review.googlesource.com/225250 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>