summaryrefslogtreecommitdiff
path: root/board/ryu/usb_pd_policy.c
Commit message (Collapse)AuthorAgeFilesLines
* cleanup: Remove 'ryu' boardShawn Nematbakhsh2017-09-111-395/+0
| | | | | | | | | | | | | | | Remove 'ryu' and related ryu-only code. BUG=None TEST=`make buildall -j` BRANCH=None Change-Id: I19b966ea6964a7ed083724f7de80ae192235a406 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/656314 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* charger: Send host event after charge info is updated.Sam Hurst2016-08-241-6/+0
| | | | | | | | | | | | | | | | When the charger is detached, the host event would sometimes be sent before the charge info was updated, resulting in the host thinking that the charger was still connected. BUG=chrome-os-partner:55584 BRANCH=none TEST=Connected charger to kevin 15 times and verified that the icon was removed in 2-seconds or less. Change-Id: I1a4e4e0f7cc23010210570fc261da8308d8e8070 Reviewed-on: https://chromium-review.googlesource.com/367809 Commit-Ready: Wonjoon Lee <woojoo.lee@samsung.com> Tested-by: Sam Hurst <shurst@google.com> Reviewed-by: Shawn N <shawnn@chromium.org>
* Deferred: Use deferred_data instead of function pointerAnton Staaf2016-04-181-1/+1
| | | | | | | | | | | | | | | | | | | | | 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>
* 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>
* update case closed debugging partial mode policyVincent Palatin2015-09-081-1/+2
| | | | | | | | | | | | | | | | | | | | | | | When a debug accessory is connected to the type-C port while the write protection is enabled, put the case closed debugging in "partial" mode rather than "full". Update the "partial" mode to provide read-only access to the AP and EC consoles. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=smaug BUG=chrome-os-partner:44700 TEST=check the EC console input/output over USB is still working with SuzyQ on a write-protected system, verify that the console input is disabled. Change-Id: I5baa03d6e738d06437c45469f46b286e76a755a4 Reviewed-on: https://chromium-review.googlesource.com/297141 Commit-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Anton Staaf <robotboy@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org>
* ryu: plankton: allow plankton to send VDM to enter CCDAlec Berg2015-07-221-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | Create new custom VDM to notify DUT to enter case closed debugging mode. Send this VDM from Plankton when the case closed debugging enable button is pressed. Once DUT receives the CCD enable VDM, CCD remains enabled until a reboot. Note, this is polarity dependent, so cable might need to be flipped. BUG=chrome-os-partner:42569 BRANCH=smaug TEST=load on plankton and ryu. attach full feature C to C cable (must have USB3.0 wires). make sure plankton is in USB mode (USB_SS_USB_MODE light should be set, which can be done by pressing DP_USB_TOGGLE button). Press CASE_CLOSE_EN button to send VDM, and then attach micro-B to debug port CN14 on plankton. See that VID/PID for Ryu show up in lsusb on host, and EC console works. If device does not show up, flip polarity of cable. Change-Id: Ifa469e4a43e32089becd75fe6cdfe0ed462d950b Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/287441 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* usb_mux: Add driver interface for USB-C muxesShawn Nematbakhsh2015-06-301-3/+4
| | | | | | | | | | | | | | | | | | | | 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>
* ryu: add missing PD power eventsVincent Palatin2015-06-241-0/+12
| | | | | | | | | | | | | | | | | | | | Send PD_EVENT_POWER_CHANGE events for all changes in the type-C/PD configuration to ensure we are not missing any transition from the AP. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=smaug BUG=chrome-os-partner:41676 TEST=On Ryu, plug and unplug type-C chargers, C-to-A receptacle adapters and A-to-C cables and see the proper "extcon" traces in the kernel log. Change-Id: I918b9c42867f069852a2222b0f47ef0df8d124aa Reviewed-on: https://chromium-review.googlesource.com/280870 Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Trybot-Ready: Vincent Palatin <vpalatin@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-0/+5
| | | | | | | | | | | | | | | | | | | | | 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>
* ryu: update PD swaps configurationVincent Palatin2015-05-081-7/+38
| | | | | | | | | | | | | | | | | | | | | | | | | - allow power swap only when we are dual-role toggling (ie in S0). - enable the VCONN swap feature to support more type-C dongles. and allow it using the same rule as power swap. - become a power sink when we are connected to an externally powered DRP. - by default, try to be a data UFP for USB. so Dual Role Device such as laptops can get our data. - add a message to inform the AP that our USB role has changed (but the host events are fully wired yet on Ryu) Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=make buildall Change-Id: Id0f9027b140cb20f105bcdbc00cac5cb5f44c9e0 Reviewed-on: https://chromium-review.googlesource.com/269857 Reviewed-by: Alec Berg <alecaberg@chromium.org> Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* ryu: enable alternate modes for USB PDVincent Palatin2015-05-071-0/+228
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Enable the support to be a USB-PD alternate mode DFP and add configuration for the DisplayPort alternate mode and the GFU mode. Only on Ryu P6 as the P5 board is using the HPD line for the power sequencing workaround. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:39946 chrome-os-partner:38689 TEST=on Ryu P6, plug a Hoho dongle, see that the superspeed muxes are in DP1 or DP2 mode (using the "typec 0" command), plug and unplug an HDMI monitor and see the HPD line moving when typing "gpioget USBC_DP_HPD". > pd 0 state Port C0, Ena - Role: SRC-DFP-VC Polarity: CC1 Flags: 0x1150, State: SRC_READY > adc VBUS = 4980 CC1_PD = 992 CC2_PD = 57 > typec 0 Port C0: CC1 993 mV CC2 58 mV (polarity:CC1) Superspeed DP1 > gpioget USBC_DP_HPD 0 USBC_DP_HPD <--- PLUG monitor ---> > gpioget USBC_DP_HPD 1* USBC_DP_HPD Change-Id: Ie25a3bb0d6331c1d931b7f542fbc637270c20b3b Reviewed-on: https://chromium-review.googlesource.com/269855 Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
* ryu: update PD electrical parametersVincent Palatin2015-05-051-2/+2
| | | | | | | | | | | | | | | | | | | The new charger has a different input voltage range and has now a 5V boost providing 1.5A when sourcing VBUS (along with an updated 1.5A Rp), update the PD descriptors and voltage thresholds accordingly. Overall, there is no functional change. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:38603 TEST=build and verify 5V and 12V charging is still working Change-Id: Ie3d54956c940781d06039fccd52966f37d7d48e4 Reviewed-on: https://chromium-review.googlesource.com/269261 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* ryu: add Proto 6 supportVincent Palatin2015-05-021-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | - use the TI BQ25892 instead of the BQ24773 as the battery charger, update the board configuration accordingly. => this change is NOT backward compatible with previous boards - upate GPIOs configuration - Use the BQ25892 5V boost to source VBUS. - on the type-C port, Rp has been set to 1.5A, update the USB PD source limit accordingly and set the boost limit to 1.65A. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:38603 chrome-os-partner:39202 TEST=make buildall run on a P4 modified board with BQ25890 and see the battery charging and the system running on AC and battery. Plug on C-to-A receptacle adapter and see 5V. Change-Id: Id28c9dbd155fe5aedc328bf5ab4da4420495e1f5 Reviewed-on: https://chromium-review.googlesource.com/266021 Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
* pd: treat externally powered dualrole devices as dedicated chargersAlec Berg2015-04-071-2/+2
| | | | | | | | | | | | | | | | | | | | | 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: samus: do not request voltage within boost bypass deadbandAlec Berg2015-01-171-0/+6
| | | | | | | | | | | | | | | | | 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>
* ryu: add charge managerAlec Berg2015-01-091-5/+14
| | | | | | | | | | | | | | | | Add charge manager to ryu to set how much current to draw from the port. BUG=none BRANCH=samus TEST=make buildall Signed-off-by: Alec Berg <alecaberg@chromium.org> Change-Id: Ia545532e1bf6586566c0b964d966b5d69c0d4b61 Reviewed-on: https://chromium-review.googlesource.com/230760 Tested-by: Vic Yang <victoryang@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org> Commit-Queue: Vic Yang <victoryang@chromium.org>
* samus: pd: on PD connection, if sink, ask for power swapAlec Berg2015-01-071-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-0/+6
| | | | | | | | | | | | | | | | 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: refactor pd policy layer request voltage functionsAlec Berg2014-12-111-72/+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>
* 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: allow policy layer to ask for PR/DR_swap on new contractAlec Berg2014-11-151-2/+7
| | | | | | | | | | | | | | | | | 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
* ryu: switch default firmware to use STM32F373Vic Yang2014-11-121-51/+0
| | | | | | | | | | | | | | | | This simply renames ryu to ryu_p1, and ryu_p2 to ryu. 'ryu_p1' will be kept for a while and will be decommisioned when most developers make switch to the new boards. BRANCH=None BUG=chrome-os-partner:33583 TEST=Build ryu and boot on P2 board. Change-Id: Ief61c64c6aefdaeae76ac7b86e0ea28131810aa1 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/229291 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@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>
* usb_pd_protocol: Add support for charge_manager and voltage reportingShawn Nematbakhsh2014-10-221-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | Integrate charge_manager and include several API changes designed for reporting voltage. 1. Make pd_choose_voltage set the chosen voltage for use by caller. 2. Add voltage parameter to pd_set_input_current. 3. Add pd_get_role to grab the sync / source state of a port. 4. Add charge manager PD + type C port initialization to the pd state machine. BUG=chrome-os-partner:32003 TEST=Manual on samus. Insert Apple charger, verify charge limit is selected appropriately. Insert PD charger, verify that charge port switches to PD port. Remove + reinsert chargers, verify that port / limit is selected appropriately. Remove battery, insert power source, verify that our power source port never becomes disabled. BRANCH=samus Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: Idf3198c71d2ddf1e401e766fc82a4b7a02aed068 Reviewed-on: https://chromium-review.googlesource.com/223758 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* pd: Correct use of console printing in USB PD policy files.Todd Broch2014-10-211-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | All non-interactive console prints should use their tasks channel parameter to make it easy for developers to inhibit console output. This CL corrects printf's in the various usb_pd_policy files that belong to the USB PD task to use cprintf(CC_USBPD, ...) instead of the macro reserved for interactive console commands ccprintf. BRANCH=none BUG=none TEST=manual, set 'chan 1' and see none of the previous chatter relating to USB PD. set 'chan 0x08000000' and see it return. Output from DFP side for SVDM discovery now looks: SVDM/4 [1] ff008041 340018d1 00000000 11000008 [1119.966911 DONE] SVDM/2 [2] ff008042 ff010000 [1119.970135 DONE] SVDM/2 [3] ff018043 00100081 [1119.973437 DONE] SVDM/1 [4] ff018184 Change-Id: I47e5f4ec2d4a6a25f171177ead5ebc99409f80b6 Signed-off-by: Todd Broch <tbroch@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/224191 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* plankton: Implement cable flipVic Yang2014-10-181-0/+52
| | | | | | | | | | | | | | | | | | | | | | | When the cable flip button is pressed, instead of only flipping on Plankton side, we should also signal the port partner to flip. This is done by sending a custom VDM. Upon receiving the flip VDM, the port partner is responsible of flipping the DP/USB polarity. Note that the "flip" here only affects the superspeed lanes. The CC lines polarity is not changed. We need this for factory test automation, and this "flip" function should only be used for testing purpose as it clearly violates the USB PD spec and it only works on devices that accept the custom flip VDM. BRANCH=Samus BUG=chrome-os-partner:32163 TEST=COnnect Plankton and Ryu. Press the button on Plankton and make sure the polarity GPIOs on Ryu are negated. Change-Id: I7ee5ea70067de4f422a7478623fe7fe8d3724372 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/223325 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* usb_pd: Add port parameter to pd_set_input_current_limitShawn Nematbakhsh2014-10-101-1/+1
| | | | | | | | | | | | | | | | Some platforms may need to take different actions depending on which port is requesting a limit. Add a new port parameter to the pd_set_input_current_limit API to accomodate this. BUG=chrome-os-partner:32003 TEST=Manual on samus_pd. Verify zinger charges battery. BRANCH=samus Change-Id: I1578252c751b3a80b4da6ca68e2a958934283cbf Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/222621 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org>
* samus: ryu: fix charge state machine init of input currentstabilize-6146.BAlec Berg2014-08-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | Currently charge state machine resets input current limit to default every time AC is connected. Problem is by the time charge state machine gets around to setting input current, it could have already been set by successful PD negotiation, and this ends up overriding that value. This fix has the state machine store desired input current limit, as determined from PD negotation or any other place, and send last desired input current limit on AC connect. BUG=chrome-os-partner:24461 BRANCH=none TEST=load on samus, test toggling between "pd 0 dev 5" and "pd 0 dev 20", and test plugging and unplugging zinger numerous times, and verify charger command always gives the expected input current limit based on PD negotiation. Change-Id: I18d8acc9e2085739e783c9c70c682d46bcce7fdb Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/211639 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* samus: ryu: set input current limit based on PD negotiationAlec Berg2014-08-091-5/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Set input current limit based on the max current from the PD negotiation. For samus, this information is passed to the EC as a host command. For ryu, the max current is set directly following a negotiation. CONFIG_CHARGER_INPUT_CURRENT is now just the default limit, but after a successful PD negotiation, the limit can be raised. Note, for now the input current limit for samus is set to 2/3 of the value negotiated for. This is due to hardware problems measuring input current on p2b boards. BUG=chrome-os-partner:28532, chrome-os-partner:24461 BRANCH=none TEST=tested on a samus. Verified input current limit using "charger" console command from EC. Input current limit after a reboot is 512. When zinger is plugged in, it jumps to the appropriate value (currently 1280mA), and when the negotiation is changed using the "pd 0 dev 5" command on the PD console, the input current limit is adjusted to match (2000mA). Change-Id: Iab9186a0f9814655e3240217a9baf4a38f15f84d Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/211023 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* samus_pd: remove dead code around allowing PD negotiationAlec Berg2014-08-061-4/+0
| | | | | | | | | | | | | | | | | | | | Remove code for preventing PD negotiation until the battery is at some minimum SOC. This was originally necessary because transitioning voltages would cause the source voltage to go briefly to 0V, which would kill power to the system unless the battery was at some minimum level of charge. But, that isn't true anymore. It is safe to transition up or down in voltage and the source voltage should never drop to 0V. BUG=chrome-os-partner:29499 BRANCH=none TEST=make -j buildall. No need to do any more testing because this code has been disabled for a while. Change-Id: I8a3dca117f01f0f9c7d04b5d489e4a8588a89be6 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/211021 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Bug fixes for USB PD policiesVic Yang2014-07-291-1/+1
| | | | | | | | | | | | | | | | We used the incorrect src_caps index when choosing PD voltage. Let's fix it to ask for all available power until we are able to ask only for what we need. BUG=None TEST=make buildall BRANCH=None Change-Id: I068264246c2586b8192220eff47838da438899b0 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/207802 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* samus: pd: dual USB-PD port support for samusAlec Berg2014-07-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Adds dual USB-PD port support for samus. Both ports are in dual-role and can perform either role. Both ports work fine when only one of the ports is in use. But, still having problems with PD errors on the lower priority port (port 0). If you have a charger plugged into port 0, and a type-C USB dongle plugged into port 1, then port 1 has higher priority, and in the SRC_DISCONNECTED state, every 1.5 seconds when it sends source cap packet, we occasionally drop pings on port 0, which results in a lot of start/stop charging. BUG=chrome-os-partner:28585 BRANCH=none TEST=Tested on samus to make sure both ports work when I plug in a charger and a type-C USB dongle with a pull-down on the CC line. Tested on plankton and zinger to make sure PD works as expected. Change-Id: Ie7bde3e258f5cd23a0b82b626c0993a45b0df074 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/200750 Reviewed-by: Vic Yang <victoryang@chromium.org> Tested-by: Vic Yang <victoryang@chromium.org>
* Add board support for RyuVincent Palatin2014-07-091-0/+130
Add the Ryu board configuration and USB Power Delivery configuration. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=make BOARD=ryu Change-Id: I61f6f19dc9fe19e1d9f9017c1050fc8a30a862e7 Reviewed-on: https://chromium-review.googlesource.com/206586 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>