summaryrefslogtreecommitdiff
path: root/board/zinger
Commit message (Collapse)AuthorAgeFilesLines
* zinger: do an intermediate step when discharging from 20V to 5Vstabilize-storm-6683.BVincent Palatin2015-01-101-19/+54
| | | | | | | | | | | | | | | | | | | | | | If we discharge directly the output voltage from 20V to 5V under load, an undershot happens and we dip below the 5V UVP threshold. So when doing a down voltage transition from 20V to 5V, split it into 2 steps : a 20V->12V transition then once we are reached 12V, a 12V->5V transition. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=chrome-os-partner:33794 TEST=connect Zinger to a Firefly and an electronic load. Using Firefly, ask for 20V->5V, 12V->5V and 20V->12V transitions, check the VBUS waveforms on the scope. Change-Id: Ie1e091ae6f1fee1fb7d4e3bd72edbe7491acd5ea Reviewed-on: https://chromium-review.googlesource.com/229732 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Alec Berg <alecaberg@chromium.org> Tested-by: Alec Berg <alecaberg@chromium.org>
* zinger: pre-compute RW hashVincent Palatin2015-01-101-6/+12
| | | | | | | | | | | | | | | | | To ensure we respond fast enough to the Discover Identity VDM (which timeout after 30ms), we need to pre-cache the RW hash at startup. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=chrome-os-partner:35327 TEST=plug Zinger to a PD sink and check the PD protocol trace on Twinkie Change-Id: I9decdff358dd1ab9ac373ce8bfdd0402f5e21f04 Reviewed-on: https://chromium-review.googlesource.com/240080 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Alec Berg <alecaberg@chromium.org>
* pd: implement new type-C connect state machineAlec Berg2015-01-101-2/+2
| | | | | | | | | | | | | | | | | | | | | Implement the new type-C connect state machine which removes lock and hold times and adds a debounce time to make sure CC lines settle before going into the attached state. This also adds detection of accessories, but doesn't do anything when an accessory is detected. BUG=chrome-os-partner:33680 BRANCH=samus TEST=test samus connected zinger and samus connected to samus. make sure that the connection is always formed. also tested with a third party with old state machine implementation and formed a connection every time. Change-Id: I91a7a6031bc35082cc19d7697142e4aa92ef46f2 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/238210 Reviewed-by: Vincent Palatin <vpalatin@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>
* zinger: enable RO partition write-protectionVincent Palatin2015-01-053-0/+85
| | | | | | | | | | | | | | | | | | | | | Check the flash protection at startup, if the RDP is still at level 0 (no read protection) or if the RO partition is not write protected : - set the write protection on the first 16KB of flash (4 LSB of WRP0) - push the RDP to level 1, so SWD/serial monitor needs to fully erase the part before re-writing the code or the write-protection. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=chrome-os-partner:34935 TEST=dump the content of the option bytes. Change-Id: I11af64365a6fbc34327b2e463eb8e2d369ffacd2 Reviewed-on: https://chromium-review.googlesource.com/238262 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* zinger: maintain a 64-bit time counterVincent Palatin2015-01-032-10/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | Keep track of the high 32-bit of the microsecond time counter to avoid rollback issues. Just activate the timer "update" interrupt (aka UIE) and increment the high word on every update interrupt. Also disable STOP mode when we are going to roll-over during sleep to avoid missing the event. Given that's only happening every hour, we should not waste too much power. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=chrome-os-partner:34159 TEST=patch the code to set the initial TIM2 value to 0xFC000000, wait for 67s, see the counter rolling and the high word incrementing, then verify that Zinger is still functional. Change-Id: I3a2f8fc09104d8ac75c581b2abcbcef99344def7 Reviewed-on: https://chromium-review.googlesource.com/238220 Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
* zinger: fix task_wait_event() bug causing missed wake eventsAlec Berg2015-01-011-2/+2
| | | | | | | | | | | | | | | | | | | Fix task_wait_event() in zinger runtime so that checking for events fired is done with interrupts disabled to avoid getting an interrupt that sets an event right after checking for that event. BUG=none BRANCH=samus TEST=load on zinger and plug/unplug ~10 times and see successful negotiations without any communication errors. note that without this CL, under certain circumstances, zinger fails to respond with goodCRC at the right time because the RX interrupt sets the event after task_wait_event() has already checked it. Change-Id: I2b43b8e389c6655d2a7a62b791014d1d5d678158 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/238092 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: check for collisions before transmittingAlec Berg2014-12-171-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added check for collision just before transmitting on CC line. To check for collision, RX monitoring is left on all the time (except when in the act of receiving or transmitting, or in between receiving and sending a goodCRC), and a simple check for RX transmission started is used to see if the CC line is idle or not. RX monitoring is also changed to only trigger on 3 edges within 20us, as per the PD spec. When a collision is detected by seeing that CC is not idle, the transmitting packet is dropped. BUG=chrome-os-partner:30135 BRANCH=samus TEST=load onto samus and zinger. make sure we negotiate and make sure custom VDMs succeed. enabled pings and made sure we stay alive with pings for a few min. Also added code to pd_rx_handler to toggle a test point on EVT board to verify the timing of when we get RX interrupts: Change-Id: I22d172163319437d3d901e019eda79d4d592f6b8 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/226118 Reviewed-by: Vincent Palatin <vpalatin@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: Re-factor common flash vdms.Todd Broch2014-12-055-105/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CL to migrate the flashing VDMs from zinger's custom vdm to common/usb_pd_flash.c such that other updateable type-C devices can share. Additionally adds gaskets to call standard runtime flashing facilities for USB-PD devices using it. Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=chrome-os-partner:31192,chrome-os-partner:31193 TEST=manual, Try following: 1. From samus_pd console w/ zinger in port 1 pd 1 flash version pd 1 flash reboot pd 1 flash info 2. From samus linux prompt w/ zinger in port 1 ectool --name cros_pd flashpd 1 1 <zinger RW payload> Reading 16384 bytes from /usr/local/zinger_v1.1.2528-d809e42.ec.RW.bin... Erasing expected RW hash Rebooting Erasing RW flash Writing RW flash Rebooting PD into new RW Complete 3. Repeat 1&2 above on hoho & dingdong. Change-Id: I018055fa9de128f937c57debdc21dea026137bcf Reviewed-on: https://chromium-review.googlesource.com/231835 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org>
* pd: move get_info to common file.Todd Broch2014-12-052-11/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | get_info command needs to be used by all type-C accessories that would entertain being updated in the field. This CL migrates function to common/usb_pd_protocol.c for other boards to use. Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=chrome-os-partner:31192,chrome-os-partner:31193 TEST=manual, Using ectool --name=cros_pd infopddev <0|1> Port:1 Devid 1.1 Hash: 0x00ec9619 0x811f3e68 0x4b90c8e9 0xd5b98fa8 0xfd373777 Port:1 Devid 3.0 Hash: 0x682fd366 0x7213f55e 0xddefb802 0xbedfec42 0x5cdcc226 Port:0 Devid 4.0 Hash: 0x57b1e4e0 0x7204075f 0x65c0fa72 0xdcca15ed 0xf3231237 Change-Id: Iffa8699056351f62cf90fdecbc7ef5cee81e67bb Reviewed-on: https://chromium-review.googlesource.com/226891 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org>
* zinger: change product type to undefinedAlec Berg2014-11-222-13/+2
| | | | | | | | | | | | | | | | | | | | | Change zinger/minimuffin product type from AMA to undefined. BUG=none BRANCH=samus TEST=make buildall. load onto zinger, plug in samus, see: SVDM/4 [1] ff008041 040018d1 00000000 50120001 [19.163111 DONE] Verify ID header, 2nd word, bits 27-29 are product type, where 0 is undefined. Also verify that product VDO is present, 4th word. Change-Id: I34a70d9356b5a8ee7ad64a4e8f072d7748aa916e Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/231172 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org>
* pd: wait tSnkTransition after ACCEPT to change voltageVincent Palatin2014-11-211-4/+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>
* zinger: optimize idle currentVincent Palatin2014-11-181-0/+16
| | | | | | | | | | | | | | | | | | | | | | Force enabling STOP mode when we have a power contract etablished but the sink is consuming a low current (<500mA). As a side effect, when the STOP mode is on, the fast OCP is no longer reacting fast because the analog watchdog ADC conversion will only happen on the next wake-up (dozens of milliseconds). Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=none TEST=run on Zinger with the UART RX used as debug GPIO to record STOP mode entry/exit. Change-Id: If78b2651862782cee45cfcdb22425b94f1eee678 Reviewed-on: https://chromium-review.googlesource.com/230341 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>
* Zinger: honor disable_sleep()Vincent Palatin2014-11-182-1/+5
| | | | | | | | | | | | | | | | | | | Extend the Zinger runtime to take into account the disable_sleep() issued by the USB protocol stack and avoid going into deep-sleep while connected. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=none TEST=connect Zinger to a PD power sink (Twinkie) and monitor the stop mode entry/exit on a GPIO. Change-Id: I04e35fdd65f3be3da7a4304dc1a92e6268930888 Reviewed-on: https://chromium-review.googlesource.com/230340 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* zinger: fix task_wait_event() to only exit on event receivedAlec Berg2014-11-181-27/+45
| | | | | | | | | | | | | | | Fix task_wait_event() so that it only wakes when an event is received or on timeout. Currently it wakes up on any interrupt, which can cause subtle timing issues with PD communication. BUG=none BRANCH=samus TEST=load onto samus, see it negotiate for 20V a few times Change-Id: Ia1268a1ac902433433949269d779ef11403eeae3 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/226811 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* zinger: change minor revision back to 1Alec Berg2014-11-171-1/+1
| | | | | | | | | | | | | | The minor revision was accidentally set back to 0 in CL:229622. Restoring back to 1. BUG=none BRANCH=samus TEST=load onto zinger, make sure minor revision is set to 1 Signed-off-by: Alec Berg <alecaberg@chromium.org> Change-Id: Ia934e4a6f1674f666defe9e4337dee45cd7ab7bd Reviewed-on: https://chromium-review.googlesource.com/229985 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* pd: zinger: add firmware update alternate mode to zingerstabilize-6480.BAlec Berg2014-11-154-37/+163
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-1/+9
| | | | | | | | | | | | | | | | | 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-3/+16
| | | | | | | | | | | | | 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
* zinger: (re-)enable the flash prefetch bufferVincent Palatin2014-11-141-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | At 48Mhz, due to the flash accessing requiring 1 Wait-State, we need to enable the flash prefetch buffer to get the full CPU execution speed. The bit used to enable flash prefetching was fixed : crosreview.com/219921 , but the change was overriden by the CL enabling the STOP mode : crosreview.com/219933 Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=chrome-os-partner:28335 TEST=plug Zinger into a PD power sink, with the Twinkie protocol analyzer observe how long Zinger takes to send back GoodCRC after the Request and SinkCap messages. With the patch, the average delay is going from 160us to 50us. Change-Id: I9de1bc10e14485919046c841eea16de3c3b3c800 Reviewed-on: https://chromium-review.googlesource.com/229671 Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
* pd: remove redundant 5V source PDOsAlec Berg2014-11-061-3/+1
| | | | | | | | | | | | | | | | 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: update source/sink cap PDOs and use to get dual role capableAlec Berg2014-11-061-3/+3
| | | | | | | | | | | | | | | | | | | | | 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>
* pd: allow selection of Tx timer channelVic Yang2014-10-211-1/+3
| | | | | | | | | | | | | | | | So far, we always use channel 1 of the Tx timer and the configuration code is hard coded. We need to support other channels for new Ryu boards. Let's make this a configurable bit. BRANCH=samus BUG=chrome-os-partner:32660 TEST=make buildall TEST=Plug in Zinger to Ryu and see 20V come up. Change-Id: Id08d4eb0d6a5721d8a03672484d0892a0714383b Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/223836 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* zinger: enable hibernateAlec Berg2014-10-171-1/+1
| | | | | | | | | | | | | | | | Enable hibernate on zinger for DVT. Note: this may break some EVT zingers. BUG=chrome-os-partner:28335 BRANCH=samus TEST=make buildall Hibernate tested in CL:220837 Change-Id: I65f4776d27ad88beee101fb00d0b6221ba272a26 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/223738 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* zinger: fix double ADC interrupt bugAlec Berg2014-10-151-0/+3
| | | | | | | | | | | | | | | | | | | | | The ADC interrupt does not clear the NVIC pending register. This can cause the interrupt to fire more than once for a given interrupt. BUG=none BRANCH=samus TEST=Send hard reset from samus to zinger using "pd 1 hard" on PD MCU console. This causes zinger to cut its output voltage and go into voltage discharging mode. When voltage discharge is complete, we get an ADC interrupt and switch back to current monitoring. Before this CL, sometimes (1 out of 20) times the ADC interrupt will fire twice, causing an OCP to be detected. With this CL, we never see the double fire. Change-Id: I91397a04773d04e263bc80a698c8799342b80a2e Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/223381 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* pd: VDM Alternate mode support.Todd Broch2014-10-091-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Successfully communicate SVDM for discovery (identity, svids, modes) and enter mode. Still need to: - Add same functionality on when power role is sink too. - determine what connected events would require exit mode. - do proper cleanup on disconnect. - implement real display port 'enter' mode for samus_pd - test & cleanup Additionally the USB Billboard class functionality needs to be added but will likely do that in a separate CL. BRANCH=none BUG=chrome-os-partner:28342 TEST=manual, From fruitpie, [Image: RO, fruitpie_v1.1.2263-d79140d-dirty 2014-09-29 17:44:15 tbroch@brisket.mtv.corp.google.com] [0.000383 Inits done] C0 st2 Console is enabled; type HELP for help. > [0.250551 USB PD initialized] pd dualrole source C0 st8 > [8.366335 PD TMOUT RX 1/1] RX ERR (-1) [8.478308 PD TMOUT RX 1/1] RX ERR (-1) [8.590280 PD TMOUT RX 1/1] RX ERR (-1) C0 st9 Switch to 5000 V 3000 mA (for 3000/3000 mA) C0 st10 C0 st11 C0 st12 8.867593] SVDM/4 [1] ff008081 340018d1 00000000 17000008 8.867906] DONE 8.871006] SVDM/2 [2] ff008082 ff010000 8.871224] DONE 8.875092] SVDM/7 [3] ff018083 00100081 00000000 00000000 00000000 00000000 00000000 Entering mode w/ vdo = 00100081 8.875492] DONE 8.878435] SVDM/1 [4] ff018144 8.878612] DONE > pe 0 dump SVID[0]: ff01 [0] 00100081 [1] 00000000 [2] 00000000 [3] 00000000 [4] 00000000 [5] 00000000 MODE[0]: svid:ff01 mode:1 caps:00100081 From hoho, [Image: RO, hoho_v1.1.2263-d79140d-dirty 2014-09-29 17:54:59 tbroch@brisket.mtv.corp.google.com] [0.000375 Inits done] C0 st2 Console is enabled; type HELP for help. > [0.250542 USB PD initialized] C0 st3 [0.264637 PD TMOUT RX 1/1] RX ERR (-1) Request [1] 5V 3000mA C0 st4 C0 st5 C0 st6 0.487451] SVDM/1 [1] ff008001 0.487628] DONE 0.491190] SVDM/1 [2] ff008002 0.491346] DONE 0.494510] SVDM/1 [3] ff018003 0.494667] DONE 0.498777] SVDM/1 [4] ff018104 0.498934] DONE Change-Id: I5e2b7802c66b8aaad97e5120dca7a02820086bc1 Signed-off-by: Todd Broch <tbroch@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/219513 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* zinger: Remove references to SHA1 hashShawn Nematbakhsh2014-10-092-2/+0
| | | | | | | | | | | | | | | | The PD protocol no longer uses a SHA1 RW hash. Instead, it uses the first 20 bytes of the SHA-256 hash. Update constants and comments accordingly. BUG=chrome-os-partner:31361 TEST='make buildall -j' BRANCH=samus Change-Id: Ice74b841dbd1d81205c1ef0079a5e18fca2153b6 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/222446 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* stm32f0: fix potential hang in adc initializationAlec Berg2014-10-081-7/+9
| | | | | | | | | | | | | | | | | | | | | | Fix bug that can cause ADC initialization to hang and eventually watchdog. Problem was that you need at least 4 ADC clock cycles between end of ADC calibration and enabling ADC (setting ADEN). Fix is to (1) move some ADC configuration to between end of cal and setting ADEN, and then just to be safe, (2) continually set ADEN until we see ADRDY (ADC ready). See bug report for more information. BUG=chrome-os-partner:32561 BRANCH=samus TEST=load onto a samus that regularly has ADC problems on boot. Using power+refresh verify that without this change PD hangs some of the time, and with this change it never hangs. Change-Id: Ifa4c3240ad7e1612647cc74e2105e6545ed19db4 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/221984 Reviewed-by: Vic Yang <victoryang@chromium.org>
* zinger: samus_pd: increment zinger hardware id minor revisionAlec Berg2014-10-072-10/+8
| | | | | | | | | | | | | | | | | | Add a minor revision to the PD device hardware ID field in the info custom VDM and set increment this minor ID from 0 to 1 for zinger. This differentiates zingers for the auto-update payload, so we can update only those with a specific major and minor ID version. BUG=none BRANCH=samus TEST=load onto samus and zinger. when connect zinger, see on PD console: Dev:0x0401 SW:2289 RW:0, which shows the appropriate device ID. Change-Id: I482ee2d850332b608cdd81537f68d4dc509bfc1a Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/221320 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* pd: zinger: move sending info VDM from UFP to DFPAlec Berg2014-10-072-9/+20
| | | | | | | | | | | | | | | | | | | | | Changed sending of info VDM from the UFP side in SNK_DISCONNECTED to the DFP side in SRC_READY to match the PD spec. Only the DFP is supposed to send VDMs, and by default the power source is the DFP. This affects simple DFPs such as power adapters, they must initiate the info VDM once a power contract has been negotiated. BUG=none BRANCH=samus TEST=load onto samus_pd and zinger and make sure that when you attached zinger to samus, samus receives info VDM and prints out something like: VDM/7 [11] 18d1000b Dev:1 SW:2280 RW:0 Change-Id: I16ceac31939fdc1c74be7323e628dd8706e1283b Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/221174 Reviewed-by: Todd Broch <tbroch@chromium.org>
* Update Zinger flashing processVincent Palatin2014-10-071-3/+9
| | | | | | | | | | | | | | | | | | | | Convert the Zinger flash update commands to the new RSA signature mechanism. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=chrome-os-partner:28336 TEST=from the workstation: ./util/flash_pd.py -m 1 build/zinger/ec.RW.bin from Samus command-line : ectool --name=cros_pd flashpd 0 1 ec.RW.bin Change-Id: Ie8cd7f644ec94e461c5775a4dbbcd408782c72e1 Reviewed-on: https://chromium-review.googlesource.com/221560 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
* zinger: add config option for hibernate and disable by defaultAlec Berg2014-10-072-0/+5
| | | | | | | | | | | | | | | Disable hibernate by default on zinger because some EVT zingers do not wake up on connect due to hardware problem. BUG=chrome-os-partner:28335 BRANCH=samus TEST=load onto zinger, leave disconnected for 60s, make sure it doesn't go into hibernate Change-Id: I9f5f9fb1ce349ea862652cd38aa5d1e521234b30 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/221478 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* zinger: add hibernate if disconnected for 60sAlec Berg2014-10-033-0/+42
| | | | | | | | | | | | | | | | | Automatically go into hibernate (standby mode) if not powering anything for 60 seconds. Will wake up when it is plugged into something (senses pull-down on CC line). BUG=chrome-os-partner:28335 BRANCH=samus TEST=load onto zinger. if disconnected for 60s, see hibernate print on zinger console. when connected to a device, verified it boots again. Change-Id: I2564c6192395bb5e4f6d7586c2725f13a4581049 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/220837 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* zinger: check RW firmware signatureVincent Palatin2014-10-026-25/+61
| | | | | | | | | | | | | | | | | | | | | | | The Zinger RW is now signed with 2048-bit RSA key (using SHA-256 as digest). This CL implements the verification mechanism. note: the RSA key used for signing must be provided as a .pem file. The path to .pem file must be provided in the PEM environment variable. By default, it's using the dev key stored in zinger_dev_key.pem. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=chrome-os-partner:28336 TEST=on Zinger, run with properly signed RW firmware and corrupted firmware and check the serial traces. Change-Id: Ia58482458904a3ed72d6b0e95996cae86a0ead83 Reviewed-on: https://chromium-review.googlesource.com/220178 Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org>
* zinger: minimuffin: add board support for minimuffinAlec Berg2014-10-022-8/+25
| | | | | | | | | | | | | | | | | | | | | | | Minimuffin is identical to zinger, same MCU, same gpio, same circuitry aroundt the MCU with two differences: - Rated current is 2.25A instead of 3A - USB PD hardware device ID needs to be different so that host can differentiate between the two. Due to the similarity between the two, minimuffin is defined as a symlink to the zinger board. BUG=none BRANCH=samus TEST=make BOARD=minimuffin load onto a zinger and verify that samus reads device ID correctly and limits input current limit to 2.25mA. Change-Id: Ie39ec43262c7d14663eb68abff073bfeec451a24 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/220689 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* zinger: add low power stop modeAlec Berg2014-09-294-32/+107
| | | | | | | | | | | | | | | | Add low power mode for zinger. This uses stop mode in task_wait_event(), the non-runtime equivalent of the idle task. BUG=chrome-os-partner:28335 BRANCH=samus TEST=load onto zinger and plug and unplug into samus a bunch of times to make sure it negotiates to 20V every time. also send custom vdm's from samus_pd and make sure those always succeed. Change-Id: I626365e7d22e030792d28dbf7eafaeb8f54f8a74 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/219933 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* stm32f0: enable flash prefetch bufferAlec Berg2014-09-251-2/+5
| | | | | | | | | | | | | | | | Enable flash prefetch buffer for stm32f0 chips to make for faster CPU execution. BUG=none BRANCH=none TEST=load onto samus_pd and zinger. let run for a while. connect/disconnect AC a few times. boot samus. Change-Id: I88c0ae67a3205987344552f5b44952f9890c8177 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/219921 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alexandru Stan <amstan@chromium.org>
* stm32f0: fix rare ADC initialization bugAlec Berg2014-09-251-3/+7
| | | | | | | | | | | | | | | | | | | | Fix potential bug in ADC initialization. After setting ADEN bit to enable ADC module, we must wait for ADRDY (ADC ready) bit before continuing. This bug only affects a few chips, and only some of the time. BUG=chrome-os-partner:31978 BRANCH=none TEST=Used a samus board where the PD MCU fails ADC initialization quite often. Without this fix, if you reboot the PD MCU, it will sometimes come up with all ADC's reading 0 and ADEN reading 0. With this fix, it always boots with the ADC's working Change-Id: Iba1d0e56006ba1ad6d9f0eee964a70ef2d0f8dcf Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/219522 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Vic Yang <victoryang@chromium.org>
* zinger: samus_pd: change zinger SW ver to report commit countAlec Berg2014-08-282-2/+1
| | | | | | | | | | | | | | | | | | | | | Change the zinger software version returned by VDO_CMD_READ_INFO to report the commit count portion of the version string to make the software version automatically change. This software version is important for debugging and is printed to PD console every time a zinger is attached. BUG=none BRANCH=none TEST=load onto zinger and samus, plug in zinger and see: Dev:1 SW:2147 RW:0 compare to the version string in zinger binary and we see: zinger_v1.1.2147-... Change-Id: Ieafe89b4b16cee076be17bcbc6774bbd7fc24f8e Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/214428 Reviewed-by: Todd Broch <tbroch@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* pd: add sending read info VDM every time source is plugged inAlec Berg2014-08-272-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Every time a type-C source is plugged in, send a special VDM to read device info. Device info will contain RW Hash (sha1), a unique hardware descriptor (USB_PD_HARDWARE_DEVICE_ID), a software version number just for debugging (USB_PD_DBG_SW_VERSION), and a flag for if the device is in RW. This feature is off by default and can be turned on by defining CONFIG_USB_PD_READ_INFO_ON_CONNECT, currently defined for samus and ryu only. Renamed the read RW_HASH VDM to READ_INFO since it now returns more than just the hash. When device info is received, we store the RW hash. In the future we will use this to check if device needs an update. BUG=chrome-os-partner:31361 BRANCH=none TEST=load onto a samus and a zinger. test when you attach zinger we send a VDM, and we get device info printed to console. also use "pd 0 hash" to query last hash received. Change-Id: I0ca57651cf8506ea738b080a6cf8e7b020ef8724 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/213832 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org>
* zinger: add voltage dischargeVincent Palatin2014-08-232-24/+89
| | | | | | | | | | | | | | | | | | | | | When the power supply voltage is transitioning to a lower value, use the discharging FET to ensure that the voltage is acceptable before re-enabling the output. Note: when discharging, we must disable the fast OCP ADC interrupt, but that is ok because we still have the slow OCP check in board_checks(). BRANCH=none BUG=chrome-os-partner:28332 TEST=on Zinger, transition from 20V to 5V using Firefly buttons and observe that we no longer have an over-voltage event. Also, verified that fast OCP triggering still works after a discharge. Change-Id: Ie327645e74819aebd1260f5ce16b2ba46a674a7b Signed-off-by: Vincent Palatin <vpalatin@chromium.org> Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/201577 Reviewed-by: Todd Broch <tbroch@chromium.org>
* zinger: add custom VDM to read last measured currentAlec Berg2014-08-221-1/+11
| | | | | | | | | | | | | Add custom VDM to read last measured output current in mA. BUG=chrome-os-partner:30850 BRANCH=none TEST=Run "pd 0 vdm curr" on samus pd console and verify reasonable current Change-Id: Ie1f1ab235560eb4e90f399ceac31c5cd93003d80 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/212981
* pd: zinger: Turn off pings by defaultAlec Berg2014-08-221-0/+3
| | | | | | | | | | | | | | | | | | | | | | Turn off sending pings in SRC_READY by default. Added custom VDM to turn pings back on, which only zinger supports right now. Changed the "pd ping" console command to be used to enabled/disable pings in SRC_READY. BUG=chrome-os-partner:31409 BRANCH=none TEST=loaded onto samus and zinger. on samus_pd, enabled highest level of debug info: "pd 0 debug 2" to allow printing ping received. Then plugged in zinger. By default, we negotiate to SNK_READY and receive no pings. Then send "pd 0 vdm ping 1" to send VDM to zinger to enable pings, and verified we start receiving pings. Sending "pd 0 vdm ping 0" sends VDM to stop sending pings. Change-Id: I4f64c6fc59bb734146eeca5e3ea3a24954c786b2 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/212965 Reviewed-by: Vic Yang <victoryang@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org>
* zinger: always disable adc watchdog before reading ADC channelAlec Berg2014-08-223-13/+27
| | | | | | | | | | | | | | | | | | | This fixes a bug where we were reading the CC line ADC without disabling the adc watchdog, which caused misreads. Instead, I changed adc_read_channel so that every ADC read disables and restores the ADC watchdog. BUG=chrome-os-partner:31454 BRANCH=none TEST=tested on EVT zinger. Added debug code to print out CC line voltage after reading it in usb_pd_protocol.c. Before the change the CC voltage is mostly wrong, unless you read the ADC twice back to back and look at the second read value. After this change, the CC voltage ADC reading always matches the real voltage. Change-Id: I9d3aa02b3d22defb9cf6f5a866de2b846a6b8a35 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/213253 Reviewed-by: Todd Broch <tbroch@chromium.org>
* zinger: keyborg: fix runtime bug with task_wait_event()Alec Berg2014-08-221-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | Fix zinger and keyborg to use correct event mask when timing out from task_wait_event(): TASK_EVENT_TIMER. On zinger, move storing the last event to after enabling interrupts. This gives an opportunity to interrupt handler to set the wake event. BUG=chrome-os-partner:30135 BRANCH=none TEST=load on zinger, and test PD communication with samus. notably tested sending rw_hash vdm from samus, which is known to cause zinger to retry the following ping transmit. The retry on the ping transmit uses task_wait_event(), and without this fix we were getting false wake events that had been stored up from the last rx received event. with this fix, the retry mechanism works. Change-Id: I9a6902ceaab49a00d3660f9813ca7761cf38f190 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/213560 Reviewed-by: Todd Broch <tbroch@chromium.org>
* zinger: change source capabilities to support 20V at 3AAlec Berg2014-08-061-1/+1
| | | | | | | | | | | | | Changed source capabilities table to support 20V at 3A. BUG=none BRANCH=none TEST=make -j buildall Change-Id: I9dac730fff7e148a2667da12fd23c35036191dfd Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/211022 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* samus_pd: remove dead code around allowing PD negotiationAlec Berg2014-08-061-5/+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>
* Makefile: Add support for per-board symlinks to top levelAnton Staaf2014-07-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | Previously if you were working on a single board you had to add BOARD= to all of your make command lines. Now if you are in a board directory you can just use "make", or "make clean", or any other top level make command. This commit also adds support for a top level "make flash" command that can be used from the board directories as well. This command uses openocd and requires that the board provides an openocd-flash.cfg file. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=none TEST=(from a few board directories) make clean; make -j (from the discovery-stm32f072 directory) make flash Change-Id: Ie09a74881371169a2c3cd9cd9922f39f4873f1a6 Reviewed-on: https://chromium-review.googlesource.com/209669 Tested-by: Anton Staaf <robotboy@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org>