summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* CHERRY-PICK: ectool: Add back support for version 0 of batterycutoff commandstabilize.59781.98.Bstabilize.5978.98.Bstabilize.5978.51.Brelease-R37-5978.BDave Parker2014-07-152-9/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | ectool must support all prior versions of commands that shipped EC binaries use. BUG=chrome-os-partner:29830 BRANCH=None TEST=Manual With an EC that only supports version 0: - Run 'ectool batterycutoff' -> success - Run 'ectool batterycutoff at-shutdown' -> error with explicit message about at-shutdown not being supported - Run 'ectool batterycutoff foo' -> error, bad parameter With an EC that support version 0 or 1: - Run 'ectool batterycutoff' -> success - Run 'ectool batterycutoff at-shutdown' -> success - Run 'ectool batterycutoff foo' -> error, bad parameter Change-Id: Ifd1d24a37abae259d3f504805267ca1183598b58 Original-Change-Id: Ia88cfc5fa7c5125828ec0595f0b6a505916c97ea Signed-off-by: Dave Parker <dparker@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/205155 Reviewed-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/207682 Reviewed-by: Mohammed Habibulla <moch@chromium.org>
* watchdog: Help ensure that the stm32 watchdog help printsDoug Anderson2014-06-213-9/+9
| | | | | | | | | | | | | | | | | | | | | | | On stm32 we were programming the WATCHDOG_HELP timer with the same value as the independent watchdog (which automatically resets the CPU). That means we weren't guaranteed to see the WATCHDOG_HELP. It happened to work most of the time due to the the LSI oscillator fudge (we assumed the watchdog was on a 56 kHz oscillator when it was probably on a 38 kHz one), but let's give ourselves a guaranteed gap. It's unlikely that this extra gap will actually help on most machines (if we're running at 53 kHz or lower we already had this much margin), but it's nice to be safe. BRANCH=ToT BUG=chrome-os-partner:29162 TEST=Increase margin to 400 (instead of 50) and type "waitms 300". Sometimes hit watchdog warning. Change-Id: I7f876757c15d7775116720c408a4127b4b94adfa Signed-off-by: Doug Anderson <dianders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/204894 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* zinger: fix bug, increase watchdog timeout to 1.8sAlec Berg2014-06-206-6/+7
| | | | | | | | | | | | | | | | | Fix bug and actually increase watchdog timeout to 1.8s. BUG=none BRANCH=none TEST=put a 3 second blocking delay in pd_task and make sure watchdog reboots. set blocking delay to 1.5seconds and make sure no reboot. Change-Id: Ie66621a3bd98354f9fd22b9b10a866d004277340 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/204471 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* zinger: update current and voltage sensing gainsVincent Palatin2014-06-201-3/+3
| | | | | | | | | | | | | | | | | | | | | | | On the P2 boards, the operational amplifier gain for current sensing is exactly x100 rather than x101. (non-inverter configuration with R1=1.8kOhm R2=178kOhm) The voltage gain constant had a typo introducing a 10% error. the voltage divider is 10k/100k,so it's x11 gain. ie it should be written (10+100)/10 rather than (10+110). Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:28331 TEST=make BOARD=zinger checked manually with a voltmeter and traces. Change-Id: I8097ab50149fee319efc11ebae75802e8a49a7f8 Reviewed-on: https://chromium-review.googlesource.com/204540 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* Twinkie: Enable flashing with dfu-util.Todd Broch2014-06-201-1/+23
| | | | | | | | | | | | | | | | | Twinkie only has test points for uart connection so nominally it will need to be programmed via DFU mode over USB micro-B connection. This CL changes from programming via flash_stm32 function and instead adds dfu support. BUG=chrome-os-partner:28337 TEST=util/flash_ec --board=twinkie successfully programs twinkie f/w Change-Id: Ia5433b569579bb879bd405e98921450764510a73 Reviewed-on: https://chromium-review.googlesource.com/204749 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org>
* usb: add USB HID driverVincent Palatin2014-06-193-0/+208
| | | | | | | | | | | | | | | | Add a USB HID endpoint providing a keyboard interface. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=build for the Reston keyboard and press keys on the matrix. Change-Id: I3f4cc55acdd33286f0638dabaa9050c37698404f Reviewed-on: https://chromium-review.googlesource.com/204166 Reviewed-by: Vic Yang <victoryang@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
* Keyborg: implement methods needed for touch wakeVic Yang2014-06-198-3/+154
| | | | | | | | | | | | | | | | | | | | In order to wake the chips from STOP/SLEEP mode with a touch, we need to put the two chips in correct state before going into STOP/SLEEP mode. Also, when one of the chips wakes up, it needs to wake the other chip with GPIO interrupt. This CL implements the necessary methods and also adds a sample routine that put the chips in STOP mode and wait for a touch using the implemented methods. BUG=None TEST=Build and boot. Touch the panel and see the response in console. BRANCH=None Change-Id: Ia5f7df8b550ee2459bcae1840f8a2717c8d947ce Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/204482 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* IRQ list support for enabling specific IRQs without common runtimeVic Yang2014-06-1911-12/+60
| | | | | | | | | | | | | | | | | | | This adds back DECLARE_IRQ() support when building without common runtime. With this, we can enable only a subset of IRQs and avoid linking in other unused IRQ handlers. Note that after this change, all boards without common runtime need to have a ec.irqlist file. BUG=None TEST=Build Keyborg and check it still works. TEST=make buildall BRANCH=None Change-Id: If68062a803b9a78f383027a1625cf99eb3370d3f Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/203264 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* stm32: update USB buffer size for STM32F0x2Vincent Palatin2014-06-182-0/+5
| | | | | | | | | | | | | | | | | The STM32F0x2 has a 1024-byte dedicated SRAM buffer for USB rather than a 512-byte one as previous parts. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:28295 TEST=make buildall Change-Id: I9fc8d76fbaa01f2b4cb0a814314c69192a6cbb95 Reviewed-on: https://chromium-review.googlesource.com/204437 Reviewed-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* twinkie: initialize INAs at startupVincent Palatin2014-06-182-1/+7
| | | | | | | | | | | | | | | | | Disable INA1 to avoid leaking current from VCONN2. Put the calibration in INA0. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:28337 TEST=plug Twinkie and measure VBUS current/voltage. Change-Id: I6b063460a86a7a3dd87ec5e3c2c9b992b66db146 Reviewed-on: https://chromium-review.googlesource.com/204468 Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org>
* stm32: add USB driverVincent Palatin2014-06-1814-3/+704
| | | | | | | | | | | | | | | | | | Enough USB support to be able to enumerate the device and use bulk or interrupt endpoints. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:28295 TEST=with the following USB console CL, connect a Fruitpie through USB and use its console over USB. Change-Id: I37b7f3b6a754cb82ab5f940ea20122d2e16b3b5b Reviewed-on: https://chromium-review.googlesource.com/193983 Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
* twinkie: fix GPIO settingsVincent Palatin2014-06-182-2/+5
| | | | | | | | | | | | | | | | | | The high FET on the TX path should be driven low to disable it by default. The SCK pin (SPI clock input for TX) is on PA5. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:28337 TEST=scope outputs Change-Id: I72fa52a170ae0e4043beb88d4fd82680ed4aefa2 Reviewed-on: https://chromium-review.googlesource.com/204165 Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
* zinger: change watchdog timeout to 1.8 secondAlec Berg2014-06-173-3/+4
| | | | | | | | | | | | | | | | | | | | | Increase watchdog timeout to 1.8 second. The pd_task can delay up to 1.5 seconds, so the watchdog must be at least that value. On Zinger, the new timeout period will be 2 seconds with LSI clock at 50kHz and 3.36 seconds with LSI clock at 30kHz. Note: the LSI frequency range is tighter on STM32F0 and cannot go up to 56kHz. BUG=none BRANCH=none TEST=add 1.5 second blocking delay to pd_task and make sure watchdog is normally not firing. Change-Id: I444639ccacd3452181a5fb6caab8e5df7ef3c847 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/204333 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* i2c: remove (lack of) 10-bit support in i2c passthruRandall Spangler2014-06-172-10/+0
| | | | | | | | | | | | | | | We never implemented this. We have no devices which support it. And we used bit #17 in a 16-bit field to flag it, so it wouldn't have worked even if we did. So, remove this (dead) code. BUG=chromium:382944 BRANCH=none TEST=make -j buildall Change-Id: Id3a4a93612d1078a3239d85921a05cfd7362b84c Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/204162 Reviewed-by: Doug Anderson <dianders@chromium.org>
* Keyborg: improve async slave responseVic Yang2014-06-152-10/+28
| | | | | | | | | | | | | | | | | Currently the master and the slave must synchronize before starting slave response. This is to make sure the previous slave response is done and the slave is ready for the next response. By enabling interrupt on the master side to capture slave ready event, we can get rid of the extra sync's. This saves about 1300 us per frame. BUG=None TEST=Build and boot. Measure time. Examine heat map. BRANCH=None Change-Id: I3c319d8a3636f1f6ae905d7021433c3ba220c9b0 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/203789 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Add 'at-shutdown' option to batterycutoff host commandDave Parker2014-06-155-26/+125
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If at-shutdown is specified, the battery is cut off 1 seconds after the host has shutdown. BUG=chrome-os-partner:29292,chrome-os-partner:28887 BRANCH=tot,nyan TEST=Run batterycutoff ectool command and cutoff console command with and without 'at-shutdown' option. Verify the battery is cut off immediately without the option specified and 1 seconds after shutdown with. View the console log to see the deferred cutoff occur. The following tests are verified on big. console: cutoff, AC on: system is off after removing AC. cutoff, AC off: system is off immediately. at-shutdown, AC on: system is off after "power off" and removing AC. at-shutdown, AC off: system is off after "power off". ectool: batterycutoff, AC on: system is off after removing AC. batterycutoff, AC off: system is off immediately. at-shutdown, AC on: battery is cut off after 1s of shutdown. system is off right after removing AC power. at-shutdown, AC off: system is off after 1s of shutdown. [84.058416 power state 3 = S0, in 0x0000] [84.058803 power lost input; wanted 0x0001, got 0x0000] [84.059120 power off 3] [84.072148 Cutting off battery in 1 second(s)] [84.123896 power shutdown complete] [84.128790 power state 7 = S0->S3, in 0x0002] [84.139694 power state 2 = S3, in 0x0002] [84.150857 power state 8 = S3->S5, in 0x0002] [84.166975 power state 1 = S5, in 0x0002] [84.177972 power state 1 = S5, in 0x0002] [85.080012 Battery cut off succeeded.] Change-Id: Id4bacf79ad3add885260655f80cb8127bafe1ad6 Signed-off-by: Dave Parker <dparker@google.com> Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/203694 Reviewed-by: Vic Yang <victoryang@chromium.org>
* samus: Power sequence changes for P2 boardsDuncan Laurie2014-06-133-22/+38
| | | | | | | | | | | | | | | | | | - Wait for SLP_SUS to deassert before bringing up PP1050 to avoid leakage when PP1050 is enabled before the PCH is ready. - CPU PGOOD is now connected to RSMRST_L on PCH. Configure this GPIO as an output and hook it into the power sequencing. - Add a "chipset_force_g3()" function to use for aborting G3->S5 transitions when there is an issue with a rail not coming up. BUG=chrome-os-partner:29502 BRANCH=samus TEST=build for samus, tested on reworked p1.9 board Change-Id: Ib0251943864594ee89a4a9f2c71c45da2c01f44e Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/203081 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* fruitpie: detect source disconnect and go to disconnected stateAlec Berg2014-06-131-1/+1
| | | | | | | | | | | | | | | | Detect when VBUS is disconnected when acting as a sink and go to the disconnected state. BUG=none BRANCH=none TEST=Connect a zinger to fruitpie, run pd state from console to verify it is in SNK_READY, then remove zinger and verify the state changes to SNK_DISCONNECTED. Change-Id: I0b46cfe3ac129f1ec9c11327c9e0d45c0c6761e8 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/203564 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Keyborg: remove unneeded 64-bit integer operationVic Yang2014-06-131-2/+2
| | | | | | | | | | | | | | | | | The timer on Keyborg is only of 32-bit width, so we should always use get_time().le.lo instead of get_time().val to avoid unneeded 64-bit integer operations. This saves about 0.66 us per call to master_slave_sync(), which is called about 500 times per frame. BUG=None TEST=Measure the time used on master_slave_sync(). TEST=Boot and check touch scanning still works. BRANCH=None Change-Id: I6668cda3c6c00d1af971fc55fcc8d643b83a4578 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/203670 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Keyborg: always send max size packet on slave responseVic Yang2014-06-132-19/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | In order to make SPI CRC work, we had to ensure the master and the slave agree on the size of slave response. This required us to first send the response size and then send the full response. The downside of this is that we cannot take full advantage of DMA. Given the SPI bus is fast enough, let's add an option to always transfer max size packet on slave response. This incurs some overhead as unused bytes are also sent, but the overhead doesn't affect us when the slave is busy with touch scanning. (The scanning time is longer than transferring 64 bytes over SPI.) This situation may change in the future, so make it a compile time option for now. Also removed the use of RX channel on the slave side when the slave is sending response. The RX channel is useless in this case. BUG=None TEST=Build and measure scan rate w/ and w/o CONFIG_KEYBORG_SPI_FULL_PACKET flag. BRANCH=None Change-Id: I4b23b1d89903dd022b445eb81667679276858008 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/203660 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* samus_pd: extend typec console cmd to work for both type C portsAlec Berg2014-06-131-45/+103
| | | | | | | | | | | | | | Added extra arg to typec console command to give the port number (0 or 1) in order to set the muxes appropriately for both ports. BUG=none BRANCH=none TEST=make -j buildall Change-Id: I7abddb9f27c22082aed0fbf09a301ca2d5e7c5fc Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/203653 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* samus_pd: board file changes for version 2 and 2BAlec Berg2014-06-132-8/+17
| | | | | | | | | | | | | | | | Samus PD MCU board file changes for version 2 and 2B of the samus board. Adds more I/O for case closed debugging, adds sensing of VBUS voltage (boostin), and moves USB C0 BC12 interrupt pin. BUG=none BRANCH=none TEST=none Change-Id: I545ff518add19919d1747de91318c33363d99403 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/203314
* tsu6721: add function to control output pinsDominic Chen2014-06-132-0/+12
| | | | | | | | | | | BRANCH=none BUG=none TEST=check mux actually switches Change-Id: If157302329c2b570814d2a071078949bfe368356 Signed-off-by: Dominic Chen <ddchen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/203492 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Keyborg: disable fast scan at compile time instead of run timeVic Yang2014-06-131-16/+9
| | | | | | | | | | | | | | This slightly reduces binary size and increases scan rate when running without fast scan. BUG=None TEST=Build and boot w/ and w/o fast scan. BRANCH=None Change-Id: I66683dce9c8f5e74f86764d8a4f33f4e1a161e08 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/203633 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* samus_pd: add PCH inputs to GPIO listAlec Berg2014-06-122-0/+11
| | | | | | | | | | | | | Add PCH inputs to GPIO list but don't enable interrupt. BUG=none BRANCH=none TEST=make -j BOARD=samus_pd Change-Id: Ife43375f8e8369516d9b363a39f9b3b9ab8a11ef Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/203528 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* flash: add config option to exclude building console commands by defaultDominic Chen2014-06-122-0/+3
| | | | | | | | | | | | | | | some commands, e.g. flashwrite, are never used on the final product and also increase the size of the flash image. BRANCH=none BUG=none TEST=make buildall Change-Id: I2a2a0a749b8eee16db5bae6a1dc92c430570e928 Signed-off-by: Dominic Chen <ddchen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/202993 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Keyborg: implement system rebootVic Yang2014-06-123-1/+27
| | | | | | | | | | | | | | | | | | | In case the slave got into a bad state, we may need a way to reboot the slave from the master. The protocol must not involve SPI communication; otherwise this will fail if the slave SPI module is in a bad state. This CL implements this using SPI_NSS. In normal SPI communication, the master pulls SPI_NSS low and immediately sync with the slave. To reboot the slave, the master pulls SPI_NSS low without the following sync. BUG=None TEST=Reboots the slave from the master. BRANCH=None Change-Id: I947523e1d86fb2332b87fbfa3dab73cba958fb72 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/203485 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Keyborg: add debug info on sync failureVic Yang2014-06-122-2/+6
| | | | | | | | | | | | | | | It's often hard to find out which sync call failed when one happens. Let's add debug info. BUG=None TEST=Add a sync call on master side only, and see the file name and line number. BRANCH=None Change-Id: I68d0fa12d5d84293870e845fbb5f83aa3a8125fa Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/203339 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Keyborg: improve error recoveryVic Yang2014-06-123-28/+56
| | | | | | | | | | | | | | | | | Previously an error in master-slave communication often leaves the chips in bad states and thus prevents further operation. Improve this by: - Making master_slave_sync() state-less. - Restoring SPI_NSS and disabling DMA on error. BUG=None TEST=Inject errors on master side and slave side. Check the subsequent operations succeed. BRANCH=None Change-Id: Ief8b5b0df3d4be6319957bb1f9daf93e0e9b5d92 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/203337 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* zinger: do not cut output on up voltage transitionsVincent Palatin2014-06-111-1/+2
| | | | | | | | | | | | | | | | | | | Update according to the current PD standard, a monotonic transition seems mandatory in all cases, so keep the voltage output enabled when increasing the output voltage. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:28331 TEST=connect Zinger to Fruitpie and probe the VBUS voltage during a transition. Change-Id: I3c728cc0049ca41536efd4f075139626b7d371da Reviewed-on: https://chromium-review.googlesource.com/202657 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* Keyborg: fix incorrect column driving in fast scanningVic Yang2014-06-111-5/+10
| | | | | | | | | | | | | | In the fast scan code, the master chip is driving the right side of the panel at incorrect time. Let's fix this. BUG=None TEST=Manual BRANCH=None Change-Id: I9500f8ec4947c46762505ff20d0e5c4169bf5a67 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/203370 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Emit error when board.h or config_chip.h is included before config.hVic Yang2014-06-117-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If board.h or config_chip.h is included before config.h, CONFIG_* flags may be incorrect. For example, if config.h says: ... #define CONFIG_DEFINED_FLAG ... #include "board.h" ... And board.h says: #ifndef __BOARD_H #define __BOARD_H ... #undef CONFIG_DEFINED_FLAG ... #endif Then this code: #include "board.h" #include "config.h" would results in CONFIG_DEFINED_FLAG being defined, instead of undefined as stated in board.h. Avoid this by emitting error when board.h or config_chip.h is included before config.h. BUG=None TEST=make buildall BRANCH=None Change-Id: Ic4a8b68e8ab1ef2a4cf9e926ab9008d2b106b943 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/203265 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* samus: decrease stack size for smaller tasksAlec Berg2014-06-112-2/+3
| | | | | | | | | | | | | | | Created a new smaller task size, 384, for tasks that don't need much stack space including PDCMD and ALS tasks. BUG=none BRANCH=none TEST=loaded on samus, ran taskinfo, made sure we were comfortbaly under the smaller task size for those tasks that changed. Change-Id: Icfa26eeaeed26171ec8b2d888e1190be32f688d1 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/202719 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* util: move console command argument parsing to util.cDominic Chen2014-06-113-32/+44
| | | | | | | | | | | | | move parse_offset_size() from flash.c to util.c for SPI flash driver usage BRANCH=none BUG=none TEST=make buildall Change-Id: Ib4824d2a7e2f5b8c3e4b918d6507c072ded8837d Signed-off-by: Dominic Chen <ddchen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/202530 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Keyborg: fix a bug in fast scan modeVic Yang2014-06-111-1/+1
| | | | | | | | | | | | | | The fast scan buffer is of type 32-bit integer, so the byte size is 4 times of its size. BUG=None TEST=Check buffer is fully cleared after each frame BRANCH=None Change-Id: I0980e418a4b323195fec56f4970aca3918a6ee11 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/203205 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* pd: increase delay after receiving good CRC to avoid starting new packetAlec Berg2014-06-111-1/+1
| | | | | | | | | | | | | | | Increase the delay after receiving a good CRC in send_validate_message() to avoid catching the last edge as the start of a new packet. BUG=none BRANCH=none TEST=Tested with zinger and samus using the python script to flash zinger RW, and simply negotiating power and receiving pings. Change-Id: Iffdd73e02e5d292396d46a611d728f66402f2da4 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/203206 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* zinger: fix check for is in ROAlec Berg2014-06-111-1/+1
| | | | | | | | | | | | | | | | Fix check for whether or not we are running in RO. The previous code read the contents of the RW reset vector, but RW code may be corrupted causing us to think we are in RW when we are not. BUG=none BRANCH=none TEST=mostly just code inspection. verified this code running in RW correctly identifies we are in RW. Change-Id: I2c27af45a59b29f55fd24295f91d5c5f0e491dd4 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/203192 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Keep IRQ_HANDLER macro when building without common runtimestabilize-5944.Bstabilize-5943.BVic Yang2014-06-101-0/+1
| | | | | | | | | | | | | | | | | | | | Without common runtime, we need to use IRQ_HANDLER to define IRQ handlers. Previously IRQ_HANDLER is only implemented in irq_handler.h which is not included by task.h when building without common runtime. This causes problem when we want to use code that includes task.h and uses IRQ. By adding IRQ_HANDLER to task.h, we don't need to include irq_handler.h in any case, and thus avoid that problem. BUG=None TEST=make buildall TEST=include task.h instead of irq_handler.h. Check Keyborg still builds. BRANCH=None Change-Id: I1213506132025fc656630565f58686b9e7de940c Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/203084 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* samus: Allow samus to charge w/o battery or with dead batterystabilize-5942.BAlec Berg2014-06-0916-9/+209
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Use a EC to PD host command to notify the PD MCU when a battery is present and charged enough that it is ok to negotiate for a higher power. The PD MCU will not negotiate until the host command is received, which allows the system to be powered without a battery or with a dead battery with 5V. BUG=chrome-os-partner:28611 BRANCH=none TEST=Tested on a samus: 1) Tested the normal case of battery charged and plugged in. When charger is plugged in, the device immediately starts negotiating for 20V and starts charging. 2) Tested with no battery. Plug in a charger, samus boots and stays alive. VBUS measured at 5V. When a battery is plugged in, device negotiates for 20V and starts charging. 3) Tested dead battery by taking a battery with no charge, and plugging in zinger. Everything boots, but PD does not negotiate for power. Then when battery reaches 1%, PD negotiates and zinger switches to 20V without causing a reboot. Change-Id: Iaa451403674e86cddbd3fe80e9503584910be576 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/201958 Reviewed-by: Vincent Palatin <vpalatin@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>