summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Clear OWNERS for factory/firmware branchfactory-samus-5939.BBrian Norris2021-09-102-10/+1
| | | | | | | | | | | | BUG=none TEST=none Change-Id: I0f03f432ada1064ffba9595be78ca7ab4d25ecd1 Signed-off-by: Brian Norris <briannorris@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3155095 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Owners-Override: Jora Jacobi <jora@google.com> Tested-by: Jack Rosenthal <jrosenth@chromium.org>
* Add display-battery-level function to lightbarBill Richardson2014-06-074-76/+489
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a new lightbar sequence (TAP), which temporarily displays the battery level. It pulses if the system is charging. BUG=chrome-os-partner:29041 BRANCH=ToT TEST=manual From the EC console, run lightbar seq tap The lightbar should change temporarily. Then run lightbar demo on and press the Up, Down, Left, and Right keys to fake the battery charge level (up & down) and the AC present state (left & right). Run the lightbar seq tap command periodically to watch it change. Change-Id: I84ff928d93060f7ef7d46d608732d37cf5185aff Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/202964 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* samus: enable PP3300_ACCEL_EN by defaultAlec Berg2014-06-071-1/+1
| | | | | | | | | | | | | | | | | | | | | Keep accelerometer power enabled all the time. It consumes very little power, we will need it to be on all the time for tap for battery, and when it is off, it can cause problems because the PP3300_EC rail leaks through the i2c pull-ups into the accelerometer. With this change, we should never see the bug in which i2c bus 1 is getting a lot of errors on boot. BUG=chrome-os-partner:29003 BRANCH=none TEST=tested on multiple samus units. can talk to accel using i2cxfer console command, and never saw any bus problems. Change-Id: I2034e217fbb1157cc0f9b867ef50e7932d75c761 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/202988 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* samus_pd: fix pd tx should output low when not transmittingAlec Berg2014-06-071-6/+7
| | | | | | | | | | | | | | fixed pd tx so that it really outputs low when not transmitting. BUG=none BRANCH=none TEST=tested on samus by making sure we can still talk PD to charger and charge. Change-Id: If04eb3d0e6620985906c49df0429a92832cffd8d Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/202668 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* samus: allow charging of dead battery requesting nilAlec Berg2014-06-074-0/+37
| | | | | | | | | | | | | | | | | | | | | | | On samus battery, when the battery is dead it reports 0 for desired voltage, current, and state of charge. In this case we should allow charging. Added a CONFIG option for this that should be removed as soon as the battery side is fixed. With this CL, when a dead samus battery is used and a charger is connected, we attempt to charge it. BUG=chrome-os-partner:29465 BRANCH=none TEST=test on a samus with a dead battery. w/o this CL, the battery never charges because the charging not allowed flag is set. With this CL, the battery charges. Change-Id: Ic61f27a27237166d33cb9ea5f024d3ef6360ce82 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/202603 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* samus: remove config to use custom battery present signalAlec Berg2014-06-071-1/+0
| | | | | | | | | | | | | | | | | The custom battery present signal which relies upon a battery temp ADC is not working on many of the samus batteries. For now, we'll use the default battery present status signal which depends on successful i2c communication. BUG=none BRANCH=none TEST=Test on samus with battery with broken temp sensor. Run chgstate and make sure is_present = yes and battery does charge. Change-Id: Idc28a922359106f3b2880236e6df64a4a2ede8e6 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/202777 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* fruitpie: provide VBUS in host modeVincent Palatin2014-06-072-0/+16
| | | | | | | | | | | | | | | | | When we are a USB host (and a power source), provide 5V VBUS on the type-C receptacle. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=with 2 Fruitpies, put one in source mode ("pd charger" command) and plug a type-C cable between them. Change-Id: Ifbdbf9db659b2fd03d11197faf2c7e14cb971e75 Reviewed-on: https://chromium-review.googlesource.com/202446 Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org>
* samus_pd: provide VBUS in host modeVincent Palatin2014-06-072-0/+12
| | | | | | | | | | | | | | | | | | | When we are a USB host (and a power source), provide 5V VBUS on the type-C receptacle. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:28782 TEST=on Samus, put port0 in host mode (by doing "pd charger" on the PD MCU command line), then insert a type-C to type-A cable and observe we have VBUS on the other side. Change-Id: I5c6cd78b54dc1c651420eaaf122b8545b9f0b0de Reviewed-on: https://chromium-review.googlesource.com/201066 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
* fruitpie: new PD TX driving for reworked boardVincent Palatin2014-06-073-3/+12
| | | | | | | | | | | | | | | | | | | | | | | For boards reworked with FETs on the TX path, TX_DATA (PB14) needs to be driven low when we are not transmitting. Set MISO as GPIO low by default and set the alternate SPI function in the TX enable code. This should be backward compatible with non-reworked Fruitpies. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=plug 2 fruitpies with a type-C cable and do a PD power negotiation. Change-Id: I9ef9c84147e9468667eed9c96647c6a9a7f79fdd Reviewed-on: https://chromium-review.googlesource.com/202512 Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Daming Chen <ddchen@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
* samus_pd: force USB2.0 + DisplayPort on Port1Vincent Palatin2014-06-051-3/+3
| | | | | | | | | | | | | | | | | | | | | Until we have the full dual port support, hardcoded the 2nd type-C receptacle (port C1) as a power provider with USB2.0 and DisplayPort source. Should be reverted to default as a power sink for the dead battery case when the dual port logic is in place. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:28341 TEST=Plug a USB key on port 1 through a type-C to type-A cable. Change-Id: I85d0c48412087d6afcdeb214a485a2bab9d8bcd4 Reviewed-on: https://chromium-review.googlesource.com/201064 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
* Tweaks to lightbar simulationBill Richardson2014-06-054-4/+69
| | | | | | | | | | | | | | | | | Improve the get_time() function, add support for GNU readline if desired. BUG=none BRANCH=ToT TEST=manual cd extra make ./lightbar Change-Id: Iedf84253b0e616a6a1b502415a487a2e6248cb2e Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/202698 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* samus: Add EC <-> PD i2c interface using host commandsAlec Berg2014-06-0510-2/+433
| | | | | | | | | | | | | | | | | | | | Initial support for EC to PD communication using host command interface over i2c. BUG=chrome-os-partner:28351, chrome-os-partner:28352 BRANCH=none TEST=on EC console send hello host command: > pdcmd 0x01 0 0xa0 0xb0 0xc0 0xd0 Host command 0x01, returned 4 a4 b3 c2 d1 Change-Id: I0969808f455574ee456d6db8a60ce9b1204a0739 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/200786 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Add CONFIG_BRINGUP option to help debug signals for bringupBill Richardson2014-06-054-0/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When this option is configured, two changes take place. First, the AP doesn't power on by default when the EC reboots. To boot it, you can run the "powerbtn" command, or poke the power button manually, or any of the normal things. Second, we watch for power-related signal changes (anything that's connected to the power_signal_interrupt() function) and keep track of them as they happen. After a second with no further changes, we print the time and value of each change. For example: [19.939212 Port 80: 0x29] [19.967971 HC 0x23] [19.976236 Port 80: 0x3a] [19.995700 HC 0x87] [20.567884 Port 80: 0x73] 11 signal changes: 19.638241 +0.000000 PCH_SLP_SUS_L => 1 19.654378 +0.016137 PCH_SLP_S5_L => 1 19.654457 +0.000079 PCH_SLP_A_L => 1 19.654535 +0.000078 PCH_SLP_S3_L => 1 19.654587 +0.000052 PCH_SLP_S4_L => 1 19.659630 +0.005043 PGOOD_1_5V_DDR => 1 19.663199 +0.003569 PGOOD_1_5V_PCH => 1 19.664751 +0.001552 PGOOD_1_8VS => 1 19.668735 +0.003984 PGOOD_VCCP => 1 19.671883 +0.003148 PGOOD_VCCSA => 1 19.868406 +0.196523 PGOOD_CPU_CORE => 1 [21.908551 Port 80: 0xf0] [21.908855 HC 0x48] BUG=none BRANCH=ToT TEST=manual Build with CONFIG_BRINGUP, notice those two changes. Change-Id: I55fd2021a0eae7dbfd1aaf5d93971f65bf2367b9 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/202574 Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
* Make Ctrl-S and Ctrl-Q match the rest of the worldBill Richardson2014-06-041-4/+4
| | | | | | | | | | | | | | | | | | | Traditionally, Ctrl-S means XOFF and Ctrl-Q means XON (http://en.wikipedia.org/wiki/Software_flow_control) We've had it reversed on the EC console, and it's kind of annoying. BUG=none BRANCH=ToT TEST=make buildall Boot, watch the EC console. Hit Ctrl-S to stop the output, Ctrl-Q to continue. Change-Id: Ib2b9ba9a2688229d5d44f3b3f845208499ef09ff Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/202532 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* build: Move libs after source or object filesAnton Staaf2014-06-041-3/+4
| | | | | | | | | | | | | | | | | | | | | When not using gold as the linker the ordering of libraries with respect to objects and source files is important. Previously the build placed -l libraries before source and objects on the gcc command line. This doesn't work with the default ld linker because since none of the symbols in the libraries are yet required they are thrown out before their uses are found in the objects and source. BUG=none BRANCH=none TEST=make buildall Change-Id: Ic9f83ba6138d6592d3b6e28de6fb0688e664f480 Reviewed-on: https://chromium-review.googlesource.com/202469 Tested-by: Anton Staaf <robotboy@google.com> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Anton Staaf <robotboy@google.com> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* samus: move als sampling from hooks to its own taskAlec Berg2014-06-042-13/+10
| | | | | | | | | | | | | | | | | Moved sampling of ALS to its own task. The problem is that it spin waits on the i2c bus mutex, and it's a bad idea to spin wait for very long in the hooks task because the hooks task tickles the watchdog. BUG=chrome-os-partner:29003 BRANCH=none TEST=tested on samus: make sure ALS task is running and no watchdog timeouts when the i2c bus is wedged indefinitely. Change-Id: Ifcebabdfc151ea85cecdfe7a8ed489e8a82ee5ba Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/202545 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* lm4: decrease i2c timeoutAlec Berg2014-06-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | The i2c timeout on lm4 is currently 1 second, which is very long. This changes it to 100ms. Note, the biggest transfer we might every do is probably ~256 bytes to do a flash program using a host command over i2c. And the slowest bus speed is ~100kHz. So, worst case, the transaction shouldn't be more than about 25ms. Decreasing the timeout is useful when peripherals are not plugged in. For example, the ALS is sampled in the hooks task every second. We don't want the ALS sampling to be delayed for a second because it will throw off all of our other hooks. BUG=chrome-os-partner:29003 BRANCH=none TEST=ran on a samus and tested i2c commands to various peripherals Change-Id: I5e1b6d0f8b100cbcb6cd9209c6198e31d99bb085 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/202515 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* samus_pd: pd tx should output low when not transmittingAlec Berg2014-06-043-23/+16
| | | | | | | | | | | | | | Change pd spi tx pin to output low when not transmitting. BUG=none BRANCH=none TEST=tested on samus by making sure we can still talk PD to charger and charge. Change-Id: I33665d01860c765cc0ff2e7813b04cac0ab9c8fe Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/202511 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* add INA231 driverVincent Palatin2014-06-033-0/+239
| | | | | | | | | | | | | | | | | Add a driver for INA231 Power/Current monitoring I2C chip. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:28337 TEST=make BOARD=twinkie and run "ina" command on Twinkie. Change-Id: Id322aca74cbb6bbf866aed22e7815c0e01951414 Reviewed-on: https://chromium-review.googlesource.com/202205 Reviewed-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* pd: detect sink disconnectionVincent Palatin2014-06-031-0/+10
| | | | | | | | | | | | | | | | | | | | For non-PD aware sink, ensure that we detect their disconnection when the CC goes back above Vnc. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:28782 TEST=on Samus, put the port in source mode (using the "pd charger" console command), then plug and unplug the type-C to type-A cable and see the PD state going from Disconnected to Discovery and the other way round (using "pd state" console command). Change-Id: Ic9e19fee78f0c5e1fc742e2443eaf4b804ee5ee9 Reviewed-on: https://chromium-review.googlesource.com/202445 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* pd: handle Soft ResetVincent Palatin2014-06-031-1/+7
| | | | | | | | | | | | | | | | | When receiving a Soft Reset request, handle it as expected: reset our ID counter, send back an Accept message. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=make buildall Change-Id: I85d64d0349092b3a773ab6134fec0a1dcac6e284 Reviewed-on: https://chromium-review.googlesource.com/202456 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* pd: support bist carrier mode 2Alec Berg2014-06-033-7/+124
| | | | | | | | | | | | | | | | | | | | | | | | | Support bist carrier mode 2 - continuously transmit alternating 1's and 0's, and check for bit errors on receive side. note that once the test is started the only way to stop is to hard reboot the devices involved. BUG=none BRANCH=none TEST=connect two fruitpies together. set one to be source: > pd charger and then start the bist > pd bist start receiving data: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa - incorrect bits: 0 / 0 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 - incorrect bits: 0 / 0 Change-Id: Id920f6b7177a418a80e1ce325042243cd633cec6 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/202187 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* pd: set BMC bitVincent Palatin2014-06-031-1/+5
| | | | | | | | | | | | | | | | | | | | | In the current version of USB-PD standard, the packet header should have bit 15 set to 1 to tell the other side that we are supporting Biphase Mark Coding (aka BMC). For now, just set it, do not check it as most of our devices are setting it yet. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=make buildall Change-Id: Ia6f89f592632520b46478a7d7975e9e8d3a28b59 Reviewed-on: https://chromium-review.googlesource.com/202391 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* stm32: add SPI register definitions and refactorDominic Chen2014-06-032-4/+8
| | | | | | | | | | | | | refactor existing code in usb_pd_phy.c to use new register definitions BRANCH=none BUG=none TEST=manually verify macro substitutions produce same value Change-Id: Ia0cd815164b0262640425abd6da973c170163f2f Signed-off-by: Dominic Chen <ddchen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/202392 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Add basic support for Twinkie dongleVincent Palatin2014-06-025-1/+235
| | | | | | | | | | | | | | | | Just the board configuration to test the PCB Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:28337 TEST=make BOARD=twinkie Change-Id: I3468a651c97aba48a7d3c07ff6a34a676988e426 Reviewed-on: https://chromium-review.googlesource.com/196692 Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
* Keyborg: options to turn on/off fast scan modeVic Yang2014-05-312-0/+13
| | | | | | | | | | | | | | For experiments, we sometimes need to turn off fast scan mode. Let's add an option so that this can be easily done. BUG=None TEST=Manual test with fast scan mode on/off. BRANCH=None Change-Id: Icd9a4a4b18699f34f424e84167748fcfe30588e3 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/202141 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Keyborg: provide options on data encoding/printing styleVic Yang2014-05-314-1/+95
| | | | | | | | | | | | | | | | | | | | | | For easier developement/experiment, this adds two options: - CONFIG_ENCODE_SEGMENT/CONFIG_ENCODE_RAW SEGMENT style encoding uses less RAM, so it can store the entire frame. However, it sometimes losses data. RAW style encoding is always lossless, but it can only save a bit more than a half frame. - CONFIG_ENCODE_DUMP_PYTHON If this flag is defined, the output style is a 2-D Python list. This is used so that the data can be easily fed into another script. BUG=None TEST=Tries all four combinations. BRANCH=None Change-Id: Ic6a916f1cae20edccee5d05783ef98a1c48dff2e Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/202140 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Keyborg: improve panel dischargeVic Yang2014-05-301-2/+18
| | | | | | | | | | | | | | | | | | This fix includes: - A faster discharge procedure - Added discharge steps between scanning two columns. This is to prevent the shadow "wraps around" to the beginning of the next column, which is much harder to filter out. BUG=None TEST=Press hard on the end of one column. Check the shadow doesn't wrap around to the next column. BRANCH=None Change-Id: Ie1342f7778d0fe18a0ec2086af79d5e459f1cd7d Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/202073 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Keyborg: show version on bootVic Yang2014-05-281-1/+8
| | | | | | | | | | | | | Makes it more convenient to tell which version we are running. BUG=None TEST=Boot and see version string BRANCH=None Change-Id: Icf5497904bad1a8b3ea9dd81fbbe1b416c77127d Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/201668 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Keyborg: handle ADC overflowVic Yang2014-05-282-11/+14
| | | | | | | | | | | | | | Previously we assumed the ADC reading wouldn't overflow, which is apparently wrong. This CL handles the overflow case. BUG=None TEST=Touch the keyboard. Still see sane heat map. BRANCH=None Change-Id: Iab5372915319d6a0ef76799f9b5fe821af5a9ca5 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/201804 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* move stringify macro to common includestabilize-5899.BVincent Palatin2014-05-271-0/+9
| | | | | | | | | | | | | | | | | | We need to stringify macros arguments in various places in the code, avoid duplicating this definition. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=make buildall Change-Id: I03530c06139fad4c60711d041239b396d9ed321e Reviewed-on: https://chromium-review.googlesource.com/201576 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* zinger: activate the watchdog.Vincent Palatin2014-05-272-0/+5
| | | | | | | | | | | | | | | | | | | | | Ensure we are never stuck somewhere without doing the safety checks by enabling the watchdog and reloading it in the safaty checks function. I have kept the default timing constants, so on STM32F0xx the watchdog period should be between 1.2s (LSI at 30kHz) and 2.0s (LSI at 50kHz). Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=add a 2s loop in the serial port interrupt handler and see the power supply rebooting. Change-Id: I000f2a36a31e1166adf63a36c2b7f52999adc928 Reviewed-on: https://chromium-review.googlesource.com/201575 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* flash_ec: enclose variable $IMG in quotes to handle whitespace in filenameDominic Chen2014-05-231-1/+1
| | | | | | | | | | | BRANCH=none BUG=chromium:346807 TEST=flash firmware image with whitespace in filename Change-Id: I8aa2ea9439a8f861e617256a63803c278708596e Signed-off-by: Dominic Chen <ddchen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/200995 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Keyborg: implement fast scan modeVic Yang2014-05-232-14/+97
| | | | | | | | | | | | | | With fast scan mode, the scan rate can usually go up to 90-100 Hz. In worst case, the rate still maintains at around 50 Hz. BUG=None TEST=Manual test. Check heat map. BRANCH=None Change-Id: I2dc25028ffa5b3175b856d3437004c21b84e7df7 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/200829 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* pd: when PD sink request is rejected go back to discovery stateAlec Berg2014-05-231-2/+3
| | | | | | | | | | | | | | | | When sink receives a power request rejected packet, go back to discovery state in order to retry transmitting request. BUG=none BRANCH=none TEST=tested with zinger. when zinger has an over current fault, it rejects requests for power. made sure that when device gets rejected it goes back to discovery state. Change-Id: Id532b69f52bd533e5d7ac1171d8833bc993a0e9f Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/201157 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* pd: detect source disconnectionAlec Berg2014-05-231-0/+10
| | | | | | | | | | | | | | | For non-PD aware source, ensure that we detect their disconnection when the CC goes back below Vnc. BUG=none BRANCH=none TEST=when zinger gets into state where it is not talking PD, remove charger and make sure we transition to disconnected state. Change-Id: I675ff6d3300eda680acdd7814f0163f222eeb516 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/201156 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* samus_pd: add interrupt to detect VBUS transitions quicklyAlec Berg2014-05-232-1/+6
| | | | | | | | | | | | | | | | | | Add interrupt to VBUS signal to detect VBUS transitions quickly to make sure we transition out of SNK_READY when VBUS goes away. BUG=chrome-os-partner:28611 BRANCH=none TEST=Test on samus 1.9 board. Ran for hours with charger plugged in, made sure when charger cuts out after missing ping responses, that it successfully goes to disconnected state and renogiates power. Change-Id: I93b2e49891e6a38c98095b7311a9435606cc61ab Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/201155 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* samus: limit input current to 2.5A to prevent over currenting zingerAlec Berg2014-05-231-1/+1
| | | | | | | | | | | | | | | | | Set maximum input current limit to ~2.5A to prevent over current faults on zinger. Note, we still get over current faults sometimes but it always clears in < 10seconds. BUG=chrome-os-partner:28611 BRANCH=none TEST=Test with a samus 1.9 and a zinger. Plug and unplug charger many times and make sure that we are eventually able to successfully negotiate for power and start charging. Change-Id: I5a7adf9fc7f5ed7a0c7dfdb620e0c1474f72a878 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/201154 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Samus: The Silego on proto1b inverts the COL2 outputBill Richardson2014-05-221-0/+1
| | | | | | | | | | | | | | | Without this change, COL2 is dead. BUG=chrome-os-partner:28721 BRANCH=ToT TEST=manual Tried all keys, now they work. Change-Id: Ie6f6ba342c7dae035d9a1dc6b2d4837146840d95 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/200852 Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
* zinger: ensure we re-enable the output once a fault is clearedVincent Palatin2014-05-211-0/+5
| | | | | | | | | | | | | | | | | | When a fault is cleared, reset the PD state and communicate, so that we re-enable the output and negociate a new voltage. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=on Zinger connected to Firefly, trigger an OCP (using an electronic load) and see that the output is re-enabled once the OCP is cleared after 1 second. Change-Id: I3199d2c8675ab43958321378fd7f65ac383468cc Reviewed-on: https://chromium-review.googlesource.com/200338 Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org>
* samus_pd: when sinking power detect loss of VBUS and disconnectAlec Berg2014-05-214-0/+23
| | | | | | | | | | | | | | | | | | Detect loss of VBUS when acting as PD sink and go to the disconnected state. This allows us to renegotiate power when power supply drops and switches to 5V. BUG=none BRANCH=none TEST=On a samus, tested by running for a couple of hours, and verifying that occasionally when zinger drops from 20V to 5V, we detect it and go to the disconnected state. Note, this only happens a couple times every hour. Change-Id: I237d267824ff564662c9c02e525ce2613ed229e6 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/200365 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Add cprints() and ccprints()Vic Yang2014-05-2178-417/+451
| | | | | | | | | | | | | | | | | | | | | Our code base contains a lot of debug messages in this pattern: CPRINTF("[%T xxx]\n") or ccprintf("[%T xxx]\n") The strings are taking up spaces in the EC binaries, so let's refactor this by adding cprints() and ccprints(). cprints() is just like cprintf(), except that it adds the brackets and the timestamp. ccprints() is equivalent to cprints(CC_CONSOLE, ...) This saves us hundreds of bytes in EC binaries. BUG=chromium:374575 TEST=Build and check flash size BRANCH=None Change-Id: Ifafe8dc1b80e698b28ed42b70518c7917b49ee51 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/200490 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* samus: change battery charging current sense resistor valueAlec Berg2014-05-211-1/+1
| | | | | | | | | | | | | | Correct battery current sense resistor is 5m-ohms. BUG=none BRANCH=none TEST=Still having charging problems, but this should be a little better. Change-Id: I54f664a3efa3b3afdc46c2329467cb97ad02a301 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/200751 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* stm32: Enable USART TCIE after clearing TCstabilize-5875.BDavid Hendricks2014-05-211-0/+3
| | | | | | | | | | | | | | | | | | | After clearing the TC flag, we should re-enable TCIE so that when the DMA transfer is done we re-interrupt and allow uart_process_output() to continue printing whatever is in the circular buffer (in the case of wrap-around) or finish gracefully if there is nothing left in the buffer. BUG=chrome-os-partner:28837 BRANCH=nyan TEST=Commands now reliably print full output whereas before they might appear truncated until another interrupt was triggered to finish printing the buffer. Change-Id: I0a4236139f57812f384e2b99af45195537201a04 Signed-off-by: Randall Spangler <rspangler@chromium.org> Signed-off-by: David Hendricks <dhendrix@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/200499
* Show success message after 'make buildall'Vic Yang2014-05-211-0/+1
| | | | | | | | | | | | | | | | | | 'make buildall' spews out a long long long message, and when an error occurs, it's sometimes hard to spot the error message. By adding a explicit success message after a successful run, one can just look for that success message to determine if it failed. BUG=None TEST=Build and see success message. TEST=Introduce an error, build, and check there is no success message. BRANCH=None Change-Id: Ia5468342ad2eb5378c3e10774ed81c5c91f002a2 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/200618 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* pd: revert slow traces in PD codeVincent Palatin2014-05-211-18/+16
| | | | | | | | | | | | | | | | | | | | | | The commit 4ba7a15 has modified the traces resulting in a far larger overhead (mainly due to %T doing dozen? of 64-bit divisions which is an expensive operation on a Cortex-M0) as a result the code is now missing communication deadlines. for lack of a better solution, revert the modification is this file. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=run PD communication between Zinger and Firefly, and between Fruitpie and Samus and see communication error rate is going down from 30% failure to less than a few percents. Change-Id: I902b951450bc200baad722ae5d65053ceda5357b Reviewed-on: https://chromium-review.googlesource.com/200326 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* Keyborg: fix a bug in task_wait_event()Vic Yang2014-05-211-4/+3
| | | | | | | | | | | | | The match interrupt is disabled before we actually intend to. Fix it. BUG=None TEST=Build and boot BRANCH=None Change-Id: I8fb171e849809d1e4f35f00bbf6d15c9a8caad74 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/200680 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Keyborg: do not trim response before sending back to masterVic Yang2014-05-211-9/+3
| | | | | | | | | | | | | | | ADC sampling is slower than SPI communication. If we spend more CPU cycle trimming the response, we are just wasting time and letting SPI bus sit idle. BUG=None TEST=Build and boot. Check scanning rate. BRANCH=None Change-Id: I9a4ece28a29ffd3205931ea71958cbc73642be6b Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/200673 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Keyborg: make a copy of response before transmittingVic Yang2014-05-211-5/+7
| | | | | | | | | | | | | | | | | Before transmitting the response back to the master, the slave should make a copy of it. Otherwise, if the buffer is reused, we run the risk of overwriting the last response before it's sent out. We got away with this before because we didn't overwrite it fast enough. Let's fix this to be safe. BUG=None TEST=Build and boot BRANCH=None Change-Id: If3c50692d554119de9ff0f0ae0de450b923b11af Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/200672 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Keyborg: fix ADC timing and increase sampling rateVic Yang2014-05-212-10/+9
| | | | | | | | | | | | | | This fixes a bug that PMSE_MRCR is changed too early. Also, with this bug fixed, we can increase the sampling rate to 13.5 cycles/sample. BUG=None TEST=Check heat map BRANCH=None Change-Id: Id7dc34fd7975ca7153b96443b8d4d28f1557eec4 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/200651 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>