summaryrefslogtreecommitdiff
path: root/common
Commit message (Collapse)AuthorAgeFilesLines
* Fix thermal.c compilation if fans are not present.Randall Spangler2013-09-231-0/+2
| | | | | | | | | | | | | 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-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | 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>
* cleanup: move test mocks to board/host and remove unused mocksRandall Spangler2013-09-196-438/+0
| | | | | | | | | | | | | | | | 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
* cleanup: move board-specific battery files to board dirsRandall Spangler2013-09-197-270/+5
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* 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>
* stm32: Use DMA for UART receiveRandall Spangler2013-09-161-23/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-141-1/+64
| | | | | | | | | | | | | | | | | | 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-141-6/+5
| | | | | | | | | | | | | | | | | | | 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>
* Remove unused uart functionsRandall Spangler2013-09-131-42/+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-123-110/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-111-0/+49
| | | | | | | | | | | | | | | 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-111-48/+31
| | | | | | | | | | | | | | 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-111-0/+7
| | | | | | | | | | | | | | | | | | 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-116-16/+132
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-101-0/+6
| | | | | | | | | | | | | | 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-061-1/+12
| | | | | | | | | | | | | 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>
* Add command for Haswell to pause in s5 at shutdownBill Richardson2013-09-061-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-052-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-053-7/+40
| | | | | | | | | | | | | | 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
* Add boot key testVic Yang2013-09-051-0/+3
| | | | | | | | | | | | | 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-051-0/+45
| | | | | | | | | | | | | 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-054-27/+163
| | | | | | | | | | | | | | | | | | | | | | 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-053-0/+86
| | | | | | | | | | | | | | | 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
* Add BQ27541 battery driverVic Yang2013-09-056-192/+539
| | | | | | | | | | | | | | | | | | 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-052-1/+108
| | | | | | | | | | | | | | | | | | 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: 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
* Also test temp sensor read delegation in thermal testVic Yang2013-09-041-1/+1
| | | | | | | | | | | | | | 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-041-1/+10
| | | | | | | | | | | | | | | 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>
* kirby: Pull XPSHOLD low to shut down the APVic Yang2013-09-041-0/+9
| | | | | | | | | | | | | | | | On Kirby, the EC has no direct control over several power rails. To shut down the AP, we need to pull low XPSHOLD from the EC so that PMIC would turn off AP power. BUG=chrome-os-partner:22101 TEST=Repeatedly do 'power on' and 'power off'. TEST=Reboot the EC and see AP booted. BRANCH=None Change-Id: I21d04e46a6cfb455ced073389a928f2549d5212d Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167201 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Peppy: Set battery pre-charge current to worst case value.Dave Parker2013-09-031-1/+1
| | | | | | | | | | | | | | | Which in this case is the max across batteries we plan to ship. BUG=chrome-os-partner:20801 BRANCH=peppy TEST=Difficult to test without a deeply discharged battery. Change-Id: Ieeb8fafc1768accb3cd2cd85a919b232aab77343 Signed-off-by: Dave Parker <dparker@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167555 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Shawn Nematbakhsh <shawnn@chromium.org>
* Add LIGHTBAR_CMD_VERSION command to detect lightbar features.stabilize-4636.BBill Richardson2013-08-301-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most systems don't have a lightbar. Those that do need a way to detect that one exists. That's easily done by just sending a EC_CMD_LIGHTBAR_CMD command to the EC and checking the result. If the response is EC_RES_INVALID_COMMAND, there isn't a lightbar. But what .cmd value should we use in struct ec_params_lightbar? Future lightbar implementations (if any), could remove existing functions or add new ones, so there isn't a safe choice. This change adds a LIGHTBAR_CMD_VERSION operation to determine if any new implementation exists. Future systems should return some useful information in response to this command. Existing systems will return EC_RES_INVALID_PARAM, which is enough to distinguish them. BUG=chromium:239205 BRANCH=none TEST=manual make BOARD=link make BOARD=link runtests There are no user-visible changes in functionality to anything. Change-Id: Ibe37f74a4dcbf68dd6bfd1963530aec907e67534 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167549 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Kirby LED driverVic Yang2013-08-302-0/+71
| | | | | | | | | | | | | This is just a simple driver that provides a function to set LED color and also a console command for testing. BUG=chrome-os-partner:22056 TEST=Change LED color and brightness with the console command. BRANCH=None Change-Id: I66ece63310a0547127698d1b242a5a1c130abff6 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167450
* Add config options for power rail controlsVic Yang2013-08-301-5/+5
| | | | | | | | | | | | | | | | Instead of checking for BOARD_<board> to determine whether the board has control over a power rail or not, use config option for this. Boards without control over some power rails can then undefine the option in board.h. BUG=chrome-os-partner:21964 TEST=Build all boards. BRANCH=None Change-Id: I7ee4ebdb3ea595e182845e40db165623ee271997 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167200 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Add BQ24192 charger driverVic Yang2013-08-308-82/+263
| | | | | | | | | | | | | | | | | This is the initial version of BQ24192 charger driver. For now, it only probes for BQ24192 chip on initialization and get BQ24192 into host mode. Also, charger_closest_current() is identical across all charger drivers. Let's move it to charger_common.c. BUG=chrome-os-partner:22238 TEST=Build all boards. Boot Kirby and see BQ24192 initialized. BRANCH=None Change-Id: I5291362ff0e69b281bffd6d609ce6dc48eb10898 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167457