summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Remove 'sb' and 'sbc' console commandsstabilize-4701.BVic Yang2013-09-171-78/+0
| | | | | | | | | | | | | | | The functionality of these commands can be fully covered by 'i2cxfer' command. Remove them to save code size. BUG=None TEST=Build all boards. Pass all tests. BRANCH=None Change-Id: I3f57e797530b17cff17b50feec80436ad7872409 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/169510 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Mock smart battery at lower levelVic Yang2013-09-172-26/+19
| | | | | | | | | | | | | | | Instead of mocking it at sb_read()/sb_write() level, let's mock them at I2C transaction level so as to increase test coverage of smart battery driver. BUG=chrome-os-partner:19236 TEST=Pass sbs_charging test. BRANCH=None Change-Id: I9bcd69517b084ea598c7b074a40143338e6150fe Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/169512 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Fake I2C device support for emulatorVic Yang2013-09-174-0/+128
| | | | | | | | | | | | | | | | | To test drivers, we need a way to fake I2C periphrals. With this CL, a fake peripheral can be done by declaring its own I2C read/write functions. The fake I2C peripherals may return EC_ERROR_INVAL to indicate it's not responding. The emulator I2C read/write call scans through all registered I2C peripherals and uses the first response. BUG=chrome-os-partner:19235 TEST=Pass sbs_charging test with the next CL. BRANCH=None Change-Id: I9380dc40e147781b42e09eb6979c864bbd9f2ac4 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/169511 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* stm32: Use DMA for UART receiveRandall Spangler2013-09-165-36/+170
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | STM32 has a single-byte mailbox for UART I/O. When the core clock runs at 16Mhz we can service interrupts fast enough to handle 115200 baud input, but when we drop to 1MHz we drop characters. Using DMA to receive input solves this problem. The STM32 DMA engine can only generate interrupts when the transfer is half-done / all-done, so we need to poll the DMA receive-head-pointer to see if individual characters have been received. Do this in the tick task (every 250ms). When a character is received, poll more quickly for a bit (5 times before the next tick) so the input console is more responsive to typing. BUG=chrome-os-partner:20485 BRANCH=none TEST=Console is responsive to debug commands. For example, help -> prints help apshutdown -> shuts down AP arrow keys -> move cursor and scroll through command history Ctrl+Q, help, wait a second, Ctrl+S -> help output printed after Ctrl+S Then in chip/stm32/config_chip.h, comment out #define CONFIG_UART_RX_DMA and rebuild/reflash the EC. When the AP is up, the console works normally but after 'apshutdown', the EC drops to 1MHz core clock, and the arrow keys don't work. (This step confirms that adding DMA support did not change the behavior of systems where CONFIG_UART_RX_DMA is not defined.) Change-Id: I199448354824bd747c7b290ea7fd5ccf354c11bb Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/169406 Reviewed-by: Simon Glass <sjg@chromium.org>
* Add hook statisticsVic Yang2013-09-143-1/+70
| | | | | | | | | | | | | | | | | | If CONFIG_HOOK_DEBUG is defined, the maximum run time of each hook is recorded. Also, record the delayed amount of time of HOOK_TICK and HOOK_SECOND firing. The statistics are available through console command 'hookstats'. Also fix a bug that CC_HOOK is used but not defined when CONFIG_HOOK_DEBUG is defined. BUG=chrome-os-partner:21801 TEST=Build with HOOK_DEBUG and check 'hookstats' BRANCH=None Change-Id: I3acba3abdd487cf20d9a532429f766cdddea2e93 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/169274
* Simplify uart_tx_start()Randall Spangler2013-09-144-23/+15
| | | | | | | | | | | | | | | | | | | All calls to it did if (uart_tx_stopped()) uart_tx_start(); And that was the only use of uart_tx_stopped(). Merge the functions. BUG=chrome-os-partner:20485 BRANCH=none TEST=EC debug console still prints output and accepts commands. Ctrl+Q pauses output and Ctrl+S resumes it. Change-Id: I113c64f5fdfc6b02b63034a74b1a3c6c6a76c351 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/169329 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Fix task priorities for console and hostcmd tasksRandall Spangler2013-09-148-16/+16
| | | | | | | | | | | | | | | | | | | | | The console task should be higher priority than the host command task, since that allows debugging problems with host commands. The keyboard scanning task should be higher priority than both of them, since it's extremely latency-sensitive. As currently written, long-running host commands such as I2C passthru can interfere with keyboard scanning. BUG=chrome-os-partner:22681 BRANCH=none (potentially affects pit, but apparently not noticeably) TEST=type bursts of 6-8 characters quickly while doing a flash update of the EC; should not drop characters. Change-Id: I48db014053750a5f1fae5d06df34768975bb8297 Reviewed-on: https://chromium-review.googlesource.com/169334 Tested-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Randall Spangler <rspangler@chromium.org>
* Remove unused uart functionsRandall Spangler2013-09-132-68/+0
| | | | | | | | | | | | | | Nothing ever called uart_flush_input() or uart_gets(), so remove them. They're dead code, and make implementing UART DMA input more complex. BUG=chrome-os-partner:20485 BRANCH=none TEST=build all platforms; pass unit tests Change-Id: I94c2c372ac3f326b98e819b2c89b8995311b2868 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/169345 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Falco: correct input current limit for 45W adapter, Turbo offBill Richardson2013-09-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | Change the charger's Input Current Register setting for the 45W adapter to match the latest spec. BUG=chrome-os-partner:20739 BRANCH=Falco,ToT TEST=manual Connect a 45W adapter, run the "battery" and "charger" commands on the EC console. When the battery charge is below 10% (turbo off), the "I_in" value displayed by the "charger" command should be 1536. Before it was 2560. Change-Id: I0483b5408aa2da352cd3aeda58e1656c095d86b2 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/169323 Reviewed-by: Randall Spangler <rspangler@chromium.org> (cherry picked from commit 3a2ef8cb38d9b0fcc638bbc9a5f7a465a8b14565) Reviewed-on: https://chromium-review.googlesource.com/169392
* Falco: Always update charger's input current limit.Bill Richardson2013-09-131-11/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I was just updating the input current limit when turbo mode was enabled and disabled. However, it turns out that the charger can decide to change the setting all by itself if the inrush current is too high. This happens pretty much every time that the AC is applied. We didn't notice this while the AP was on, but when the AP was off we were exiting the watch_adapter_closely() function too soon and so we missed the transition. This CL fixes that. But just to be safe, instead of only updating when we think we need to, we're going to just update the value every time we check on the adapter. That way if we happen to miss a change due to a race condition or transient, we'll catch it the next time through the loop. BUG=chrome-os-partner:20739 BRANCH=Falco,ToT TEST=manual Before this CL, you can run "sbc 0x3f" on the EC console while plugging and unplugging the AC adapter. When the AP is off and AC is reapplied, you'd see the reported value mysteriously change. After this CL, it doesn't. Change-Id: I5661c548cccd4eb24ba4d8a0b8cd070acc2e49ef Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/169322 Reviewed-by: Randall Spangler <rspangler@chromium.org> (cherry picked from commit 1bcdd0eb6ff353a7215efe0b24630148ea7a9f28) Reviewed-on: https://chromium-review.googlesource.com/169391
* Implement LED control host commandVic Yang2013-09-121-0/+45
| | | | | | | | | | | | | | | | | | This enables 'ectool led' command. BUG=chrome-os-partner:22056 TEST='ectool led battery query' and check brightness ranges are correct. TEST='ectool led battery green' and LED turns green. TEST='ectool led battery yellow' and LED turns yellow. TEST='ectool led battery auto' and LED goes back to auto control. TEST='ectool led power query' returns error. BRANCH=None Change-Id: Ide4d80851270fc17d474aee58ec46436a709745c Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/168870 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* pit: Change battery level warning and shutdown levelsDerek Basehore2013-09-121-4/+4
| | | | | | | | | | | | | | | | | This causes the EC to give a warning when the battery is less than 3.5% and shutdown when the batteyr is less than 1.5% BUG=chrome-os-partner:21926 TEST=check that warning happens at < 3.5% and shutdown happens at < 1.5% on the EC console. Change-Id: I1bd06f632e969b55bbb041c65ab106ef764e454b Signed-off-by: Derek Basehore <dbasehore@chromium.org> (cherry picked from commit 2f93978e5e5dcf841ef24fa6b9ba2fa9459d3d98) (cherry picked from commit 447d69abcb3c61440d89b4aac8c4472a35b3b77d) Reviewed-on: https://chromium-review.googlesource.com/169055 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* kirby: Detect OTG dongle on EC bootVic Yang2013-09-121-11/+20
| | | | | | | | | | | | | | This fixes the problem that after an EC reboot, OTG dongle stops working. BUG=chrome-os-partner:21964 TEST=Reboot EC and boot from OTG dongle. BRANCH=None Change-Id: Ieec43f612d01114d13afb40293acfd0b3e324e8c Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/168737 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Change get-set host command to be less genericBill Richardson2013-09-127-159/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Having a per-device enum list for use by the EC_CMD_GET_SET_VALUE command won't work when the one-and-only ectool tries to talk to different devices. Any particular enum may be missing or have a completely different meaning. Instead, we can do the same thing that EC_CMD_HOST_EVENT_* does - use the same structs for a bunch of different commands. If/when we run out of command numbers (it's currently only 8 bits), we'll just switch to using EC protocol v3 (see crosbug.com/p/20820), which provides 16 bits for the command. This CL renames EC_CMD_GET_SET_VALUE to EC_CMD_GSV_PAUSE_IN_S5 (since that's the one-and-only use of it at present), and renames the params/response structs as well. Since only the names are changing, the implementation remains backwards-compatible (assuming the flags value usage is preserved by ectool for the EC_CMD_GSV_PAUSE_IN_S5 command, which it is). If I can cherry-pick this change into the one place where it's being used, I will. BUG=chromium:287969 BRANCH=ToT TEST=manual Although this is primarily an internal name change, it also means that the commands to invoke the previous usage of this feature have changed. To test: On Haswell systems only. To enable the pause in S5 at shutdown, do either of these: EC console: pause_in_s5 on root shell: ectool pause_in_s5 on Shut the AP down politely, and it should pause in S5 for 10 seconds before continuing to G3. You can see this by watching the EC console. To disable the pause in S5 at shutdown, do any of these: EC console: pause_in_s5 off root shell: ectool pause_in_s5 off or press Refresh + POWER Boot the system, then politely shut down. This time it should go directly to G3 without pausing in S5. Change-Id: Ic614fed37ad89db794c2bbcca2b83d1603030ab2 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/168816
* stm32: Support DMA-based UART outputRandall Spangler2013-09-116-8/+127
| | | | | | | | | | | | | | | This reduces the number of UART interrupts by a factor of 12, and reduces the overall interrupt rate on STM32 by a factor of 2. BUG=chrome-os-partner:20485 BRANCH=none (not required for pit branch) TEST=Boot pit. Ctrl+Q pauses debug output; Ctrl+S resumes it. 'crash divzero' still prints a full crash dump. And util/makeall.sh passes builds all platforms and passes tests. Change-Id: I86993e14b436150298dcb2c6d29086cc3c9db418 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/168814
* Split uart_process() into input and output processingRandall Spangler2013-09-115-57/+51
| | | | | | | | | | | | | | This is a precursor to DMA-based UART transfers, which require different processing for DMA vs PIO output types. BUG=chrome-os-partner:20485 BRANCH=pit TEST=Boot pit; verify EC console still works. Change-Id: I6d6f55561eeebe9bd2928b2bfb25278c86f689d1 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/168811 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Support multi-bit mask in STM32L's GPIO functionsVic Yang2013-09-118-10/+51
| | | | | | | | | | | | | | | | | | The definition of GPIO interface allows passing in multi-bit mask, and this is what's done by gpio_config_module(). Fix STM32L's function so that it doesn't accidentally set incorrect GPIO register values. BUG=chrome-os-partner:22605 TEST=On Kirby, do 'led r 0' and check the value of 0x40020800 is 0x01540000. BRANCH=None Change-Id: I9a1c8074aab7345485a590ecf138bf99d0742997 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/168739 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Tested-by: Randall Spangler <rspangler@chromium.org>
* Fix a bug in BQ24192 charger driverVic Yang2013-09-111-1/+2
| | | | | | | | | | | | BUG=chrome-os-partner:22238 TEST=Check the return value is EC_SUCCESS BRANCH=None Change-Id: I6010d3f8b55938c5fc6526776bee536868a96b55 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/168733 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Avoid charging over battery's maximum voltageVic Yang2013-09-111-1/+2
| | | | | | | | | | | | | | When the battery doesn't report desired voltage, we should charge at the minimum value of charger maximum voltage and battery maximum voltage. BUG=chrome-os-partner:22055 TEST=Boot Kirby and check we are charging at 4.2V instead of 4.4V. BRANCH=None Change-Id: Ie520aa223d85c0690cc959522c4a46691aaa9a66 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/168732 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Handle multiple independent sources and types of CPU throttlingBill Richardson2013-09-1123-35/+1322
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Depending on the system, the AP can be throttled in at least two different ways - politely, where it's just asked to slow down a bit, and forcefully using a hardware signal (like PROCHOT). In addition, the request for throttling can come from multiple tasks. This CL provides a single interface, specifying both the type of throttling desired and the source of the throttling request. For each type, any source can can start throttling, but all sources must agree before it stops. The changes are protected by a mutex, so that requests from multiple tasks don't interfere with each other. BUG=chrome-os-partner:20739,chromium:287985,chromium:287983 BRANCH=ToT TEST=manual Build-time test: cd src/platform/ec make BOARD=falco runtests Run-time test: Lower the temp thresholds, turn the fan off, and watch the throttling turn off and on as things heat up. For example, on the EC console: > temps PECI : 339 K = 66 C ECInternal : 324 K = 51 C G781Internal : 328 K = 55 C G781External : 327 K = 54 C > thermalset 0 341 343 sensor warn high halt fan_off fan_max name 0 341 343 383 333 363 PECI 1 0 0 0 0 0 ECInternal 2 0 0 0 0 0 G781Internal 3 0 0 0 0 0 G781External > > temps PECI : 339 K = 66 C ECInternal : 324 K = 51 C G781Internal : 328 K = 55 C G781External : 327 K = 54 C > > fanduty 0 Setting fan duty cycle to 0% > > apthrottle AP throttling type 0 is off (0x00000000) AP throttling type 1 is off (0x00000000) > [430.152000 thermal WARN] [430.152233 event set 0x00020000] [430.152497 event clear 0x00020000] [430.152714 ACPI query = 18] [430.152444 sci 0x00020000] [430.153051 set AP throttling type 0 to on (0x00000001)] > gpioget CPU_PROCHOT 0 CPU_PROCHOT > [436.153742 thermal HIGH] [436.153979 set AP throttling type 1 to on (0x00000001)] > gpioget CPU_PROCHOT 1* CPU_PROCHOT > [441.155319 thermal no longer high] [441.155587 set AP throttling type 1 to off (0x00000000)] [442.155604 thermal HIGH] [442.155841 set AP throttling type 1 to on (0x00000001)] [446.156623 thermal no longer high] [446.156890 set AP throttling type 1 to off (0x00000000)] temps PECI : 343 K = 70 C ECInternal : 324 K = 51 C G781Internal : 328 K = 55 C G781External : 327 K = 54 C > [447.156827 thermal HIGH] [447.157064 set AP throttling type 1 to on (0x00000001)] apthrottle AP throttling type 0 is on (0x00000001) AP throttling type 1 is on (0x00000001) > gpioget CPU_PROCHOT 1 CPU_PROCHOT > Now turn the fan back on: > fanauto > [456.159306 thermal no longer high] [456.159574 set AP throttling type 1 to off (0x00000000)] > apthrottle AP throttling type 0 is on (0x00000001) AP throttling type 1 is off (0x00000000) > temps PECI : 341 K = 68 C ECInternal : 324 K = 51 C G781Internal : 328 K = 55 C G781External : 327 K = 54 C > [473.163905 thermal no longer warn] [473.164168 event set 0x00040000] [473.164453 event clear 0x00040000] [473.164670 ACPI query = 19] [473.164379 sci 0x00040000] [473.164987 set AP throttling type 0 to off (0x00000000)] temps PECI : 340 K = 67 C ECInternal : 324 K = 51 C G781Internal : 328 K = 55 C G781External : 327 K = 54 C > > apthrottle AP throttling type 0 is off (0x00000000) AP throttling type 1 is off (0x00000000) > Change-Id: I9ee1491a637d7766395c71e57483fbd9177ea554 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/168802
* Initalize DMA before UARTRandall Spangler2013-09-105-3/+22
| | | | | | | | | | | | | | This is in preparation for enabling DMA-based UART transfers, to improve UART performance on STM32. BUG=chrome-os-partner:20485 BRANCH=none TEST=Boot pit. Host commands should still be received; this verifies DMA is still operational. Change-Id: Ibc3b2e2cd187547eb61b85e4a086704accd7f2fb Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/168810
* Generalize 'charger' command to support BQ24192Vic Yang2013-09-101-33/+40
| | | | | | | | | | | | | | | This changes 'charger' to report '(unsupported)' when charger module returns EC_ERROR_UNIMPLEMENTED, and continues even when there is an error. BUG=chrome-os-partner:22238 TEST=Run 'charger' command and check values are correct. BRANCH=None Change-Id: I5193ec436a10b2c3cbcc4013c846a7bea515864d Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/168734 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* kirby: Update battery voltage parametersVic Yang2013-09-101-6/+4
| | | | | | | | | | | | | Nominal voltage is 3.7V and maximum voltage is 4.2V. BUG=chrome-os-partner:22055 TEST=None BRANCH=None Change-Id: Ia1425ecebad49da676c1a22e4dcdbb43bebbd407 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/168731 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* kirby: Set LED color according to charging statusVic Yang2013-09-101-0/+41
| | | | | | | | | | | | | | | | This sets LED to yellow for charging and battery-assist mode, green for full and near-full, and red for error. BUG=chrome-os-partner:22056 TEST=Unplug battery and see LED go red after 30 seconds TEST=Charge battery and see yellow LED TEST=See green LED when battery is charged TEST=Unplug AC and see LED turned off BRANCH=None Change-Id: I7a512f3b0e6cbdf760c0cbd49cd63c26dc9f8539 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/168182
* Show charging allowed info for 'battery' commandVic Yang2013-09-101-0/+4
| | | | | | | | | | | | This will help us debug battery charging. BUG=chrome-os-partner:22055 TEST=On Kirby, type 'battery' and check the output. BRANCH=None Change-Id: Id510ca7816f359e64072837df6464a412eb7739f Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/168181
* Add comments about hooks and deferred functionsRandall Spangler2013-09-062-1/+40
| | | | | | | | | | | | | No code changes, only comments, and making gaia_suspend_deferred() static. BUG=none TEST=build pit BRANCH=none Change-Id: I96448bd3b7457f2a0ec25276167d2740d0cd0c52 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/168231 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* pit: Add board specific keyscan configWonjoon Lee2013-09-062-0/+16
| | | | | | | | | | | | | | | | | This timing values act as most similar with 8042 which we used in snow And some keyscan jig can not regognize current debounce timing, It based on 8042 timing. BUG=chrome-os-partner:22019 TEST= build and update ec, reboot and see keyscan is fine Change-Id: I48f01f2e1247db5fa324b0896301616c42032585 Signed-off-by: Wonjoon Lee <woojoo.lee@samsung.com> Reviewed-on: https://chromium-review.googlesource.com/168003 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Tested-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Randall Spangler <rspangler@chromium.org>
* falco: delay LCD VCC enable by 270msAaron Durbin2013-09-064-17/+64
| | | | | | | | | | | | | | | | | | | Much like the backlight signal the LCD VCC enable signal needs to be delayed to ensure the panel timings are correct. It's problematic because the LVDS bridge is a black box. The signals need to be scoped to ensure everything eventually matches up. BUG=chrome-os-partner:21234 BRANCH=falco TEST=Built and booted. Panels still come up. Dexter determined the proper delay. Change-Id: I6e61d1dfa9ad03be1735d05d8d8ff2549a7b0db2 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167620 Reviewed-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Add command for Haswell to pause in s5 at shutdownBill Richardson2013-09-066-2/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At normal AP shutdown, Haswell systems skip S5 entirely and go directly to G3. It's sometimes handy to pause in S5 as the other systems do, for things like power-cycle tests that use the RTC to do a delayed wake from S5. This CL adds a console command and a host command to enable/disable that pause in S5. The default is to skip S5, and the override value is not persistent across EC reboots, so whenever the EC hibernates or reboots (Refresh + Power, software sync), you'll have to re-enable it again. BUG=chrome-os-partner:22346 BRANCH=falco,ToT TEST=manual On Haswell systems only. To enable the pause in S5 at shutdown, do either of these: EC console: gsv s5 1 root shell: ectool pause_in_s5 on Shut the AP down politely, and it should pause in S5 for 10 seconds before continuing to G3. You can see this by watching the EC console. To disable the pause in S5 at shutdown, do any of these: EC console: gsv s5 0 root shell: ectool pause_in_s5 off or press Refresh + POWER Boot the system, then politely shut down. This time it should go directly to G3 without pausing in S5. Change-Id: I324e6e2373bc20b61a731b4ef443d7bb8edb6b83 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/168086 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* Introducing MPU module for Cortex-M3Daisuke Nojiri2013-09-057-0/+246
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Preventing instruction fetch from RAM for Link except iram.text, which is used for hibernation. Stm32 on Snow does not support MPU. Tested on Link using commands 'crash nxtext/nxdata/nxstack', which run code from .iram.text, .data section, and the stack, respectively: ... RAM locked. Exclusion 20005980-200059a0 ... > crash nxtext Running from 20005984 > crash nxdata === PROCESS EXCEPTION: 04 ====== xPSR: 61000000 === r0 :00000000 r1 :0000dff2 r2 :00000005 r3 :0000086d r4 :00000000 r5 :00000032 r6 :2000544c r7 :00000000 r8 :00000000 r9 :20005456 r10:00000000 r11:00000000 r12:20005961 sp :20002748 lr :000008d7 pc :20005960 Instruction access violation mmfs = 1, shcsr = 70001, hfsr = 0, dfsr = 0 =========== Process Stack Contents =========== 200027b0: 0000086d 00000002 0000d504 00009f27 200027c0: 2000544c 20005452 00000000 00000000 200027d0: 00000000 00000000 00000000 00000000 200027e0: 00000000 00000000 00000000 00000cbb Rebooting... > crash nxstack === PROCESS EXCEPTION: 04 ====== xPSR: 20000200 === r0 :00000070 r1 :00000047 r2 :00000000 r3 :200027a8 r4 :00000000 r5 :00000001 r6 :2000544c r7 :00000000 r8 :00000000 r9 :20005456 r10:00000000 r11:00000000 r12:00000002 sp :20002740 lr :00000913 pc :200027ac Instruction access violation mmfs = 1, shcsr = 70001, hfsr = 0, dfsr = 0 =========== Process Stack Contents =========== 200027ac: 00000070 00000047 00000002 0000d57c 200027bc: 00009f9f 2000544c 20005452 00000000 200027cc: 00000000 00000000 00000000 00000000 200027dc: 00000000 00000000 00000000 00000000 Rebooting... BUG=chrome-os-partner:16904 BRANCH=master TEST=stated above Change-Id: I7c6593c527f29609442f33550f9d16755f32297c Signed-off-by: Daisuke Nojiri <dnojiri@google.com> Reviewed-on: https://chromium-review.googlesource.com/51337 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Enable charging on KirbyVic Yang2013-09-056-22/+46
| | | | | | | | | | | | | | Now that we have battery and charger drivers, let's enable charging. BUG=chrome-os-partner:22055 TEST=Test charging/discharging on Kirby TEST=Unplug battery and see 'error' state TEST=Plug battery and doesn't see error anymore BRANCH=None Change-Id: Idff513b38c9f5bb90700877750f3d2e2154d4b23 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/168007
* Set termination current to minimum for BQ24192 chargerVic Yang2013-09-051-0/+22
| | | | | | | | | | | | | | The charger stops charging when charging current is smaller than this value. To maximize battery life, let's set this value to its minimum so that the battery is charged to as full as possible. BUG=chrome-os-partner:22238 TEST=Test charging on Kirby with the next CL BRANCH=None Change-Id: I528dd0668244cba480538b825fff1cf28d7748ec Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/168006
* Allow parallel unit testing in make_all.shVic Yang2013-09-051-1/+1
| | | | | | | | | | | | | | | We are already applying arguments of make_all.sh to building ec binary for each board. Let's also apply them to 'make runtests'. BUG=None TEST=util/make_all.sh -j8 BRANCH=None Change-Id: I267aee662c015e65b737640815dbbb0cb72c58ba Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167826 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Add boot key testVic Yang2013-09-056-5/+100
| | | | | | | | | | | | | This checks boot key combination like Power-F3-ESC and Power-F3-Down can be properly detected. BUG=chrome-os-partner:19236 TEST=Pass kb_scan test BRANCH=None Change-Id: I180918977299219a8421798dac2ab9fed84ef9a2 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167802
* Add multi-step test supportVic Yang2013-09-054-51/+115
| | | | | | | | | | | | | We already have a multi-step test. Let's move it to test_util.c so that upcoming tests can also use it. BUG=chrome-os-partner:19235 TEST=Pass all tests BRANCH=None Change-Id: I6b7a036297f3b4b2778687488d1dc5b5bb4fe255 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167950
* Extend charge state machine to accommodate KirbyVic Yang2013-09-056-30/+184
| | | | | | | | | | | | | | | | | | | | | | Currently only x86 platform uses charge_state.c, and it's been tailored to fit smart battery and bq247xx charger family. For Kirby, we have different types of battery and charger, and thus need to make some change to accommodate them. This includes: - Abstract out smart battery specific bit mask - Implement missing functions required by GAIA chipset module - Add config flags for charging-enabled GPIO pin - Allow battery that doesn't report desired voltage and current BUG=chrome-os-partner:22055 TEST=Build all boards TEST=Boot Link and check it charges/discharges battery TEST=Test charging/discharging on Kirby along with the next two CLs BRANCH=None Change-Id: I910c030a45b4f775afffec0127cdc31e89b9dd55 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/168005
* Temporary OTG and external power supportVic Yang2013-09-056-5/+98
| | | | | | | | | | | | | | | This is only for initial bringup that requires OTG to boot kernel. Note that we are expecting firmware for USB ID detection and hardware change to charger chip, so this is likely going to be thrown away. BUG=chrome-os-partner:21964 TEST=Plug in OTG dongle and check VBUS voltage is ~5V TEST=Unplug and check it's ~0V. BRANCH=None Change-Id: Iee66bef117188fea14a76459945be3bf5afef0dd Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167832
* kirby: Enable backlight in S0Vic Yang2013-09-051-0/+15
| | | | | | | | | | | | | When the AP is powered on, turn on backlight. Also turn off backlight when going into S3/S5. BUG=chrome-os-partner:21964 TEST=Power on and see backlight lit. Power off and see it turned off. BRANCH=None Change-Id: I77141848466db3209aa0eba2613057002bd3432a Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167800
* Add BQ27541 battery driverVic Yang2013-09-0513-304/+683
| | | | | | | | | | | | | | | | | | BQ27541 is not a smart battery IC, and thus we cannot use existing smart battery driver. Let's add a driver that implements a smart-battery-like interface. The 'battery' console command is also moved to battery.c so that it can be reused by different battery driver. BUG=chrome-os-partner:22048 TEST=Type 'battery' and check the reported values are sane. TEST=Check 'battery' command works fine on Spring. BRANCH=None Change-Id: I5d1eaeb3f801478f3b9473fd43c1f2a2eda75859 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/66340
* Add a generic get/set host commandBill Richardson2013-09-056-1/+160
| | | | | | | | | | | | | | | | | | This adds EC_CMD_GET_SET_VALUE to the list of host commands. We have a bunch of single-value getter/setter commands, which is wasteful. This is a start towards unifying them into a simpler command. BUG=chromium:285358 BRANCH=ToT,falco TEST=none There's nothing to test just yet. This just adds the command and some basic interfaces. A future commit will make use of it. Change-Id: Iee986b9d273b422bb06f3a0c9b7af50617f03d7f Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/168083 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* kirby: Rename AC_PRESENT to AC_PRESENT_LVic Yang2013-09-052-2/+2
| | | | | | | | | | | | | This signal is active low (1=no AC, 0=AC good.) Renaming it to AC_PRESENT_L so that it's not confusing. BUG=chrome-os-partner:21964 TEST=Build kirby BRANCH=None Change-Id: I17b555945c647f4a24b1920cdb8992b3a5767462 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167458
* Add Kirby ADC channel definitionVic Yang2013-09-052-0/+31
| | | | | | | | | | | | | Kirby has the same ADC channels as Spring, but with different scales and pin assignments. BUG=chrome-os-partner:22055 TEST=Read ADC channel voltage BRANCH=None Change-Id: Ibb618a77647c0477eeb0e8d983df07a258fdb75a Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167460
* STM32L ADC driverVic Yang2013-09-0511-4/+307
| | | | | | | | | | | | | | | | | | | | ADC module on STM32L is clocked by HSI oscillator, and thus we need to switch to HSI if using MSI. After the conversion, if the system is not in S0, clock is switched back to MSI again. There are several register bits that can only be written when ADC is powered down. For now, let's just power down the ADC after each conversion. Currently ADC watchdog is not working and is disabled on STM32L. BUG=chrome-os-partner:22242 TEST=Try multiple all-channel and single-channel reads in S0 and S5. BRANCH=None Change-Id: I769dda8a9c69ac9de1eb22d6d259034eef8c1ac4 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167454
* kirby: Add delay before enabling 3.3V railVic Yang2013-09-051-1/+12
| | | | | | | | | | | | | A delay between enabling PMIC_PWRON and 3.3V rail is needed so as to prevent leakage. BUG=chrome-os-partner:22101 TEST=Power cycle the AP. BRANCH=None Change-Id: I2dd1c7ebc71565fc64dacaeb5caa46b2d3801d50 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167582
* Implement emulator clock fast-forwardingVic Yang2013-09-042-5/+34
| | | | | | | | | | | | | | | | | | | | | | | | | When running an unit test, the emulator is sitting in idle task for most of the time. Since we don't have interrupt support now, the emulator is just waiting for the next wake-up timer to fire. To save time, we can actually just figure out which task is the next to wake up, and then fast-forward the system clock to that time. With this, all tests run faster and we can remove time-scaling for all current tests. This improves not only run time but also stability. If one day we have interrupt support, then we will have to modify this to take into account the fact that an interrupt might wake a task before any wake-up timer fires. BUG=chrome-os-partner:19235 TEST=Run all tests in parallel for 1000 times. BRANCH=None Change-Id: I4cd33b041230267c110af015d425dd78d124f963 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167801 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Add host command testVic Yang2013-09-043-1/+179
| | | | | | | | | | | | | This test checks host command interface handles errors correctly. BUG=chrome-os-partner:19236 TEST=Pass host_command test BRANCH=None Change-Id: I62764977d2063edf5abd37e78e074384eec5f0d4 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167762 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Also test temp sensor read delegation in thermal testVic Yang2013-09-043-8/+8
| | | | | | | | | | | | | | Temperature sensor read is delegated to functions defined in board.c. Let's mock that function instead of the one in temp_sensor module. BUG=chrome-os-partner:19236 TEST=Pass thermal test. BRANCH=None Change-Id: Ic0387bd6a49e3f032e593c11c6f80bd36f8474e7 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167761 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Flush test coverage information before rebooting emulatorVic Yang2013-09-043-1/+18
| | | | | | | | | | | | | | | If we reboots the emulator without flushing test coverage information, the test coverage report will be incorrect. Let's fix this by flushing it before every reboot. BUG=chrome-os-partner:19235 TEST=Generate test coverage report and check correctness. BRANCH=None Change-Id: I1eb060e419b767f382325bed841366c491ba56b7 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167770 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Add unit test for 'chan' commandVic Yang2013-09-041-1/+30
| | | | | | | | | | | | | Command 'chan' is used by servod. Let's add an unit test for it. BUG=chrome-os-partner:19236 TEST=Pass console_edit test BRANCH=None Change-Id: If86e052fa6720d952a8d9fe8745432dc4a458869 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167614 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Add more charge state machine testVic Yang2013-09-043-0/+127
| | | | | | | | | | | | | | | | | | | This includes: - Charge mode control host command - Low battery shutdown/hibernate Also, speed up the test by 20x since we now need to wait for more than 30 seconds for low battery state test. BUG=chrome-os-partner:19236 TEST=Pass the test BRANCH=None Change-Id: If2e91a33f3a80f58da01a6c3da128cb603101dea Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167613 Reviewed-by: Rong Chang <rongchang@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>