summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Set WLAN_OFF_L to open drainstabilize-4731.85.Bstabilize-4731.62.Bstabilize-4731.31.Brelease-R31-4731.BPaul Stewart2013-09-241-1/+1
| | | | | | | | | | | | | | | | | | On bolt this pin is connected both to the PCH and the EC. As designed, it was intended for both parts to treat this as an open-drain circuit. Signed-off-by: Paul Stewart <pstew@chromium.org> BUG=chrome-os-partner:22175 BRANCH=none TEST=No good test yet, since PCH appears to drive all the time Change-Id: Ib6ca16b4f797c8c334fb9f030f20cdbbc756f3fb Reviewed-on: https://chromium-review.googlesource.com/170257 Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Paul Stewart <pstew@chromium.org> Tested-by: Paul Stewart <pstew@chromium.org>
* Support compiling with chipset task disabledRandall Spangler2013-09-235-15/+31
| | | | | | | | | | | | | | For bringup, we need to be able to compile a binary with the chipset task disabled. Chipset functions should be stubbed to do nothing in that case. BUG=chrome-os-partner:22820 BRANCH=none TEST=compile falco, pit, link with chipset task commented out in ec.tasklist Change-Id: I73a4e09effb049f19b1a128e643b267d6469037b Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/170221
* Fix thermal.c compilation if fans are not present.Randall Spangler2013-09-233-1/+9
| | | | | | | | | | | | | Currently, it doesn't compile unless CONFIG_FAN is defined. BUG=chrome-os-partner:22803 BRANCH=none TEST=temporarily undefine CONFIG_FAN in board/link/board.h; code compiles and all unit tests pass Change-Id: I251d670ccd299f7a50b1455364a817e07fad4cb1 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/170106
* stm32: Fix polarity of charger interruptRandall Spangler2013-09-2312-12/+12
| | | | | | | | | | | | | | | | | | | | | | The charger interrupt is active-low. Snow and Spring properly triggered on falling (asserting) edge, but Pit (and Daisy/Puppy) didn't. Fix those boards, and rename the signal to end in _L so we don't make that mistake again. BUG=chrome-os-partner:22827 BRANCH=pit TEST=unplug/replug AC adapter on pit; see debug output as follows: [batt] state charging -> idle0 Charger IRQ received. [batt] state idle0 -> charging Charger IRQ received. Change-Id: I1f5c9370d1118461dc033955ba77aab2cebb7ece Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/170256 Reviewed-by: Jaehoon Kim <jh228.kim@samsung.com> Tested-by: Jaehoon Kim <jh228.kim@samsung.com> Reviewed-by: Doug Anderson <dianders@chromium.org>
* Record average runtime and delay of hooksVic Yang2013-09-231-12/+43
| | | | | | | | | | | | | | | | | | | | | | | In additional to recording the maximum runtime and delay, let's also keep track of the moving average. The average is calculated by: New_Avg = (Old_Avg * 7 + New_Val) / 8 every time the hook fires. The average values are only accurate for hooks that fire enough times, but it won't be useful anyway for a hook that only fires just once or twice. Also, show warning if HOOK_TICK or HOOK_SECOND fires more than 10% late. BUG=chrome-os-partner:21801 TEST=On Kirby, check average values are sane. TEST='waitms 800' and see warning of HOOK_TICK firing late. BRANCH=None Change-Id: I453545830d854c6c5bfc795d01fc558a965cff6e Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/169704 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* lm4: make CONFIG_UART_HOST optionalRandall Spangler2013-09-202-6/+36
| | | | | | | | | | | | | | | | Currently, CONFIG_UART_HOST must be defined for all LM4-based platforms. Future platforms may not need host UART support, so make it optional. BUG=chrome-os-partner:22802 BRANCH=none TEST=Temporarily comment out CONFIG_UART_HOST in board/link/board.h; code still compiles. Change-Id: I8775d9daaf8f6e45f1f374c9be7f10316611447f Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/170104 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* cleanup: move test mocks to board/host and remove unused mocksRandall Spangler2013-09-197-212/+1
| | | | | | | | | | | | | | | | Now that we have a better test framework in place, mock implementations go in either chip/host/ or board/host/, depending on whether they're mocking chip or common/board functionality. Move the remaining mocks there. Also, several mocks were neither compiled nor used, and haven't kept pace with other refactoring; delete those. BUG=chrome-os-partner:18343 BRANCH=none TEST=build all board; pass all unit tests Change-Id: Ie2a81c3ccd4506679192d979aa87fe7ed6c1c5a0 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/169873
* Turn off backlight power when lid is closed.Jeremy Thorpe2013-09-191-11/+9
| | | | | | | | | | | | | | | Ensure that the backlight is off whenever the lid is closed, independently of whether the AP asserts SUSPEND_L. BUG=None TEST=On Kirby, toggle lid switch closed and see that backlight turns off immediately. BRANCH=None Change-Id: I1516be3b139a8cbb07a8a81229c8143c88118e91 Signed-off-by: Jeremy Thorpe <jeremyt@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/169875 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* cleanup: move board-specific battery files to board dirsRandall Spangler2013-09-1915-59/+22
| | | | | | | | | | | | | | | | | | | | | | | | The battery files contain board-specific constants and a few small methods like battery-detect and battery-cut. Most of these aren't reused across platforms. The battery files have also been cleaned up so those board-specific constants basically all that's left in them. Where a file is used by a single board only, move it to board/(boardname)/battery.c. Batteries used by more than one board (e.g. battery_link.c used by both link and bolt) are still in common/battery_*.c, since that's cleaner than duplicating the file in each board's directory. No code changes, just moving files. BUG=chrome-os-partner:18343 BRANCH=none TEST=build all boards and pass unit tests Change-Id: I946c8eb874672c77f9b77105e5b900f98fa48d0f Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/169893 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Fix console channel name listVic Yang2013-09-181-1/+3
| | | | | | | | | | | | | | | This adds back missing "hook" channel name. Also add a build assertion to make sure we don't miss this again. BUG=chrome-os-partner:21801 TEST=Build all boards. Remove "hook" channel and check build fails. BRANCH=None Change-Id: I373016504fd3753e1a791077d49b3af14b2b1aa4 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/169703 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Haswell: Add control for touchscreen resetDave Parker2013-09-181-0/+17
| | | | | | | | | | | BUG=chrome-os-partner:22076 BRANCH=peppy TEST=Manual. Verify touchscreen operational in S0. Change-Id: Ife2d4e11142195bddf202933430ec8af243b1309 Signed-off-by: Dave Parker <dparker@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167150 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* ec: fix duplicate 'const' declarartion.Yunlian Jiang2013-09-171-1/+1
| | | | | | | | | | | | | | | BRANCH=None BUG=chromium:292965 TEST=CC="i686-pc-linux-gnu-clang" CXX="i686-pc-linux-gnu-clang++" emerge-x86-generic chromeos-ec passes. Signed-off-by: yunlian@chromium.org Change-Id: I936f5e9b3e6ab5a5c1c2f6b6c41d054d748545e3 Reviewed-on: https://chromium-review.googlesource.com/169633 Reviewed-by: Luis Lozano <llozano@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Yunlian Jiang <yunlian@chromium.org> Tested-by: Yunlian Jiang <yunlian@chromium.org>
* 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