summaryrefslogtreecommitdiff
path: root/baseboard/kukui/usb_pd_policy.c
Commit message (Collapse)AuthorAgeFilesLines
* TBT:Add support for exit mode SOP'/SOP'' on chipset transitionAyushee2020-10-141-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When chipset is transitioning to a new state or on sysjump, the EC re-negotiates to enter an alternate mode on booting up. This commit adds support for exiting Thunderbolt mode for SOP' and SOP'' for active cable on chipset transition and also moves all the alternate mode exit rotines to their respective files. It also delays deleting the SVID data until after the EXIT_MODE message has ACKed and avoids pd_dfp_exit_mode() from changing the alternate mode's internal states. This commit also makes sure that the mux is set to safe state before exiting the alternate mode and it is reconfigured according to the port's current data role on receiving ACK/NAK from the cable/port partner. BUG=b:151169925, b:159717794 BRANCH=none TEST=On reboot, able to exit and re-enter into DisplayPort mode, Thunderbolt mode with passive cable and thunderbolt mode with active cable. Change-Id: If1e48e9f31cd678e23fe89bd3494551b5d1a78f1 Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2415082 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
* Charger: Add chgnum parameter to OTG set functionsDiana Z2020-08-271-4/+4
| | | | | | | | | | | | | | | | Add the charger number as an input for setting OTG output current and enabling it, both in the charger driver and in charge_set_output_current_limit(). Also add a clarifying note about the intent of CHARGER_SOLO. BRANCH=None BUG=b:147440290 TEST=make -j buildall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I7656c19a87d8216f5efc72dcffa6d638064d3e2f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2376469 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* damu: set charging current to 0 when enable charger OTGScott Chao2020-06-121-0/+2
| | | | | | | | | | | | | | When enable charger OTG, we need to set charging current to 0 BUG=b:158542099 BRANCH=kukui TEST=make -j BOARD=damu TEST=make buildall Signed-off-by: Scott Chao <scott.chao@bitland.corp-partner.google.com> Change-Id: I9aed83084b8382d80dc266cce5243eba0233e536 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2239588 Reviewed-by: Ting Shen <phoenixshen@chromium.org>
* TCPMv2: Support mode entry for SOP' and SOP''Abe Levkoy2020-06-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | Add a transmit type parameter to functions involved in mode entry; also add such a parameter to various functions calling those functions. For DisplayPort-specific definitions or calls, specify SOP; we do not currently support DisplayPort mode for cable plugs. For TCPMv1-specific code, specify SOP. TCPMv1 generally assumes that the discovery/mode structures are 1-dimensional, as they were previously, and changing that is outside the scope of this CL. BUG=b:155890173 TEST=Enter DP mode on Volteer with TCPMv2 TEST=Enter DP mode on Volteer with TCPMv1 TEST=Enter TBT mode on Volteer with TCPMV1 BRANCH=none Change-Id: I8afc75b3f3be8939c4645058ac4a31f24c88fb9e Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2229279 Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org>
* jacuzzi: enable 3A sourcingTing Shen2020-04-211-0/+11
| | | | | | | | | | | | | | | | | | | According to the hw requirement, Jacuzzi should be able to provide 5V/3A when it's not providing power on any other port. BUG=b:153699375 TEST=1. Connect juniper to another chromebook 2. in ec console, `pd 0 dualrole source` to force juniper sourcing power 3. make sure another device is receiving 5V/3A. BRANCH=kukui Signed-off-by: Ting Shen <phoenixshen@google.com> Change-Id: I3f1b95d3a63b15828b4ea860c32fe2a638593f2b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2145128 Tested-by: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Eric Yilun Lin <yllin@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org>
* usb_mux: retimer: mux as chained mux and retimerDenis Brockus2020-02-281-8/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes retimers appear as generic muxes. By allowing a chain of muxes they can be stacked up to the new configurations that zork requires and will continue to work as they did before on configurations that only have a single mux. The code used to have two different arrays, 1) muxes and 2) retimers. On one of the zork configurations the processor MUX stopped being the primary mux and the retimer took its place. In a different configuration of that same platform it left the primary and secondary alone but the mux_set FLIP operation had to be ignored. Since the same interfaces needed to be available for both it stopped making sense to have two different structures and two different methods of handling them. This consolodates the two into one. The platforms that do not have retimers, this change will not make any difference. For platforms like zork, it will remove the retimers and make them chained muxes. So testing on trembyle makes sense to verify, BUG=b:147593660 BRANCH=none TEST=verify USB still works on trembyle Change-Id: I286cf1e302f9bd3dd7e81098ec08514a2a009fe3 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2066794 Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* kukui: inform AP DP status by USB_MUX eventEric Yilun Lin2020-02-101-7/+17
| | | | | | | | | | | | | | | | | | | | | | This CL notify the usb mux status to AP no matter the it5205 exists or not. Some revs of the krane and kodama replace virtual mux with a real mux. However, this will stop informing the AP usb mux status, but it6505 still need the mux information to control the regulators. BUG=b:149181702 BRANCH=kukui TEST=plug hub w/ DP port, and see exton state DP=1 by 'cat /sys/class/extcon/extcon0/state' Change-Id: I86c0998340c935b16b02ec0c3edf0484f1843ebf Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2043625 Reviewed-by: Pi-Hsun Shih <pihsun@chromium.org> Reviewed-by: Ting Shen <phoenixshen@chromium.org> Tested-by: Pi-Hsun Shih <pihsun@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org>
* juniper: implement otg functionTing Shen2020-02-101-2/+10
| | | | | | | | | | | | | | | | - set otg limit to 5V/3.3A according to hw requirement - remove unused charger_is_sourcing_otg_power function BUG=b:148627490 TEST=verify that the USB ports (both C and A) can supply up to 3A BRANCH=kukui Change-Id: I61b047f1d05e5428d4eef74c9e0af3a222449779 Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2040879 Reviewed-by: Eric Yilun Lin <yllin@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org>
* usb_mux: cleanup: Replace mux state enums with ec_command bit flagVijay Hiremath2020-01-281-3/+4
| | | | | | | | | | | BUG=b:145796172 BRANCH=none TEST=make buildall -j Change-Id: Ie4ffaf208745764262931501f0dff77b525a4e59 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2017569 Reviewed-by: Jett Rink <jettrink@chromium.org>
* usbc: hpd_deadline cleanupDenis Brockus2020-01-161-11/+7
| | | | | | | | | | | | | | | | | | some of the usages of this static variable were used in overridable functions and they also had their own static variable for this same purpose. Since it is not required to override all of the functions, this left two variables out of sync with one another. So made them the same variable. BUG=b:147535104 BRANCH=none TEST=make buildall -j Change-Id: Ic560d3a2a2e129450e918e0cb6dfff75fd1222a2 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2002953 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
* kukui: support DP UFP_U pin modeEric Yilun Lin2020-01-151-1/+2
| | | | | | | | | | | | | UFP_U should be supported as well. TEST=plug to a UFP_U display, and ensure it can output BUG=b:146908979 BRANCH=kukui Change-Id: I18bfbca521c9e90f13413ee9d3af88f9b07588df Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1988032 Reviewed-by: Ting Shen <phoenixshen@chromium.org>
* usb_pd_policy: Make a lot of objects commonAseda Aboagye2019-12-101-224/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is a board specific usb_pd_policy.c file that contains a lot of code for handling DisplayPort Alternate mode, Google Firmware Update Alternate mode, as well as some PD policy functions such as deciding to Accept or Reject a data role swap or a power role swap. Several boards simply copy/paste this code from project to project as a lot of this functionality is not actually board specific. This commit tries to refactor this by pulling the functions that are not mainly board specific into common code. The functions are made overridable such that boards that truly do require a different implementation may do so. Additionally, this consolidation changes the policy behaviour for some boards, but they should be for the better. Some examples include that data swaps are always allowed if we are a UFP (no system image requirement), power swaps are allowed to become a sink if we are no longer dual role (e.g. - in suspend), and DisplayPort Alternate Mode is not entered if the AP is off. In order to facilitate this refactor, a couple CONFIG_* options were introduced: - CONFIG_USB_PD_DP_HPD_GPIO /* HPD is sent to the GPU from the EC via a GPIO */ - CONFIG_USB_PD_CUSTOM_VDO /* * Define this if a board needs custom SNK and/or SRC PDOs. * * The default SRC PDO is a fixed 5V/1.5A with PDO_FIXED_FLAGS indicating * Dual-Role power, USB Communication Capable, and Dual-Role data. * * The default SNK PDOs are: * - Fixed 5V/500mA with the same PDO_FIXED_FLAGS * - Variable (non-battery) min 4.75V, max PD_MAX_VOLTAGE_MV, * operational current PD_MAX_CURRENT_MA, * - Battery min 4.75V, max PD_MAX_VOLTAGE_MV, operational power * PD_OPERATING_POWER_MW */ BUG=chromium:1021724,b:141458448 BRANCH=<as many as we can that are still supported> TEST=`make -j buildall` TEST=Flash a kohaku, verify that DP Alt Mode still works with a variety of DP peripherals TEST=Repeat above with a nocturne TEST=Repeat above with an atlas Change-Id: I18fd7e22dc77fe1dc6c21c38cd7f1bc53cae86cb Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1949052 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
* kukui: refactor PD_MAX_VOLTAGE/PD_OPERATING_POWERTing Shen2019-11-291-6/+8
| | | | | | | | | | | | | | | | | | 1) PD_MAX_VOLTAGE_MV is determined by charger, move it into the ifdef VARIANT_KUKUI_CHARGER_* clause. 2) PD_OPERATING_POWER_MW is determined by board, move it into board.h. 3) update the two config variables above for jacuzzi family. BUG=None TEST=make buildall BRANCH=kukui Change-Id: I6f14a71a34e2c81a5030ff5809996ddf74a4ad12 Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1930521 Reviewed-by: Eric Yilun Lin <yllin@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org>
* Rename CONFIG_USB_PD_PORT_COUNT as CONFIG_USB_PD_PORT_MAX_COUNTKarthikeyan Ramasubramanian2019-11-011-3/+3
| | | | | | | | | | | | | | | | | Certain SKUs of certain boards have lesser number of USB PD ports than defined by CONFIG_USB_PD_PORT_COUNT. Hence rename CONFIG_USB_PD_PORT_COUNT as CONFIG_USB_PD_PORT_MAX_COUNT. BUG=b:140816510, b:143196487 BRANCH=octopus TEST=make -j buildall; Boot to ChromeOS Change-Id: I7c33b27150730a1a3b5813b7b4a72fd24ab73c6a Signed-off-by: Karthikeyan Ramasubramanian <kramasub@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1879337 Tested-by: Karthikeyan Ramasubramanian <kramasub@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
* usb_pd: use enum tcpc_rp_value instead of intCaveh Jalali2019-10-311-1/+1
| | | | | | | | | | | | | | | this changes the declaration and definitions of typec_set_source_current_limit() to take an enum tcpc_rp_value instead of int. BRANCH=none BUG=none TEST=buildall passes Change-Id: If633641a581eeb6085b94bc727e23fb57f7cd435 Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1889117 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* kukui: runtime usb mux config selectionTing Shen2019-10-171-3/+9
| | | | | | | | | | | | | | | | | The compile time IF_ENABLED(CONFIG_USB_MUX_XXX) does not work on kukui, change this to runtime selection. BUG=b:135079572 TEST=On Krane Rev5/Kodama, verify the mux switch to dp + usb mode (i2cxfer r 0 0x48 0x11 returns 0x03 or 0x13) BRANCH=kukui Change-Id: Ib44f0c383ed5f9156e3dd3bf6faa3daebb22e146 Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1864493 Tested-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
* jacuzzi: enable DPTing Shen2019-09-091-7/+21
| | | | | | | | | | | | | | | | | | | | | | enable dp on jacuzzi, and add back the dp implementation before CL:1660524 for all new devices including jacuzzi. usb_pd_policy now supports two different configs: - kukui/krane, rev <= 4: no mux (CONFIG_USB_MUX_VIRTUAL defined) - all new devices: have a real mux BUG=b:135895590,b:135079572 TEST=attach a usb hub and moniter to the dut, verify that dp/dp+mux mode and both polarities can detected correctly BRANCH=master Change-Id: I3e4757c97d555a4afb48076fc4785305c96b0a7f Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1723892 Reviewed-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org>
* krane: add it5205 driverTing Shen2019-09-051-9/+4
| | | | | | | | | | | | | | | | | | | | | | | An it5205 is added in kukui/krane rev 5, and deprecated gpio pin USB_C0_DP_OE_L and USB_C0_DP_POLARITY. This CL is intended to make the fw works for both old and new boards: 1) the default usb_mux driver is updated to rev 5, and board_rev_init may change it back for old boards. 2) keep VARIANT_KUKUI_DP_MUX_GPIO in kukui/board.h, and add a customized function to set/clear these gpio pins. BUG=b:135079572 TEST=verify that type c display works on board rev 4/5 BRANCH=master Change-Id: Ibe28816eed026ccb8a9a5234a612f80b038884f1 Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1785197 Reviewed-by: Yilun Lin <yllin@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org>
* kukui: Check IRQ and HPD in DPStatus message.Pi-Hsun Shih2019-08-121-1/+1
| | | | | | | | | | | | | | | | | | | Per the VESA DisplayPort Alt Mode on USB Type-C spec, IRQ_HPD indicates that a high to low followed by a low to high transition was detected. Therefore, we should be checking when IRQ is high and HPD is low is received as that is an error. This commit fixes that bug where were comparing our level to the GPU instead of what was shown in the PDO. This is basically applying CL:1422458 to kukui. BUG=b:138696135 BRANCH=none TEST=manually Change-Id: I53e6d96a54dc45910055a7d535bf89477ce87430 Signed-off-by: Pi-Hsun Shih <pihsun@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1743906 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* jacuzzi: bringup ecTing Shen2019-07-311-0/+8
| | | | | | | | | | | | | | | | | | | | Initial version of jacuzzi ec. The files are basically copied from board/kukui/, battery and charger configured to the correct i2c port and component, and pogo / sensor removed. BUG=b:135895590 TEST=verify that this is bootable on a Jacuzzi, charger and battery looks good, and no error message spamming on ec console. BRANCH=master Change-Id: Ia786076c08019dd2aa1711a68ff1c82cc7fa45ed Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1673955 Tested-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Alexandru M Stan <amstan@chromium.org> Reviewed-by: Alexandru M Stan <amstan@chromium.org>
* baseboard/kukui: support battery/charger variantsTing Shen2019-07-311-2/+1
| | | | | | | | | | | | | | | | | | This CL introduces config option VARIANT_KUKUI_BATTERY_* and VARIANT_KUKUI_CHARGER_* for derivatives to pick their battery / charger option. BUG=b:137172860 TEST=build and deploy on Krane, verify that `battery` and `charger` console output looks reasonable. BRANCH=master Change-Id: Ic5c33a233ec30c9bc71414c95603157301281041 Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1697781 Reviewed-by: Alexandru M Stan <amstan@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org>
* kukui: add baseboard/kukuiTing Shen2019-07-301-0/+440
Create a baseboard to reduce the effort of forking and maintaining kukui derivatives. This CL is intended to just moving things around, with minimal changes to make compiler happy, complex logic changes will implement in subsequent CLs. BUG=b:137172860 TEST=build and deploy on a Krane BRANCH=master Change-Id: Ifd3ad5c3b03dce101cd15cbcec304f5e3a1081ac Signed-off-by: Ting Shen <phoenixshen@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1695562 Reviewed-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Ting Shen <phoenixshen@chromium.org> Tested-by: Ting Shen <phoenixshen@chromium.org>