summaryrefslogtreecommitdiff
path: root/common/gaia_power.c
Commit message (Collapse)AuthorAgeFilesLines
* Rename files in common/ to be more consistentRandall Spangler2013-07-081-680/+0
| | | | | | | | | | | | | | | | This gets rid of mystery files like "ir357x" and "lp5562". All chip names are now prefixed with their module type (e.g. "chipset_", "led_driver_", etc.) No functional changes; renaming files and CONFIG constants only. BUG=chrome-os-partner:18343 BRANCH=none TEST=build all platforms Change-Id: I3227fb0f6b0243bb08a13577cdb0f6def0e15d54 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/60922
* ec: Add Puppy support to generic/common filesYen Lin2013-07-031-2/+2
| | | | | | | | | | | | | | | | add #ifdefs needed to support Puppy board in generic/common files BUG=none TEST=tested on Venice board Change-Id: I46592010cb5dfcc40db312c746f1e0d2886b3758 Signed-off-by: Yen Lin <yelin@nvidia.com> Reviewed-on: https://gerrit.chromium.org/gerrit/60688 Reviewed-by: Andrew Chew <achew@nvidia.com> Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Tested-by: Jimmy Zhang <jimmzhang@nvidia.com> Commit-Queue: Jimmy Zhang <jimmzhang@nvidia.com>
* spring: Keep system power on sysjumpVic Yang2013-05-281-3/+6
| | | | | | | | | | | | | | If the AP is already on, the kernel should handle low-power event. We shouldn't power off the system on sysjump. BUG=chrome-os-partner:18318 TEST=None BRANCH=spring Change-Id: I4e80c61a25d2fa503d0c97e22dc2f4ad9c44f716 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/56706 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* pit: Add more delay for proper power_on sequenceWonjoon Lee2013-05-161-3/+4
| | | | | | | | | | | | | | | It makes delay between 3.3V_EN and PMIC_ON So we are now 5V EN -> 2ms Delay -> 3.3V EN -> 2ms Delay -> PMC3_ACOK BUG=chrome-os-partner:19305 BRANCH=none TEST=Using osiloscope, See until PMC3_ACOK is far from P3.3V_AUX as 5ms Change-Id: I65bfece28f55edf4f5640fe411bd57caaaaa5e1d Reviewed-on: https://gerrit.chromium.org/gerrit/50449 Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Randall Spangler <rspangler@chromium.org> Tested-by: Randall Spangler <rspangler@chromium.org>
* Clean up gaia_power debug messagesRandall Spangler2013-04-291-15/+14
| | | | | | | | | | | | | | | | Should use CPRINTF("[%T...\n]") so the messages are timestamped; this is really helpful to see when things are going wrong. No functional changes; just changing debug output. BUG=none BRANCH=none TEST=build pit and spring; see prettier debug output Change-Id: I9c658385b836a184a3ebb84856b844cbfc3224a7 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/49551 Reviewed-by: Simon Glass <sjg@chromium.org>
* Allow disabling PMU charger task, and do so on pitRandall Spangler2013-04-261-0/+2
| | | | | | | | | | | | | | | | I2C communication doesn't work on pit yet, so the charger task is spewing errors to the console. This change allows the task to be disabled cleanly on pit, and has no effect on other platforms. BUG=chrome-os-partner:18657 BRANCH=none TEST=build all platforms and see that charger task is still compiled everywhere but pit Change-Id: I788e817d5630fb1a28694819f4ef9948a503a744 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/49344 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Replace generated CONFIG_TASK_ macros with HAS_TASK_Bill Richardson2013-04-241-1/+1
| | | | | | | | | | | | | | | CONFIG_ macros should be set directly. Expanding the task names in the same way made it difficult to tell what was a configuration choice and what was due to changes in ec.tasklist BUG=chrome-os-partner:18343 TEST=build all, run link BRANCH=none Change-Id: Ib82e34f974238ee2dd216f33b701b6f4c6a4f1f1 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/49098 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Move common chipset console commands to chipset.cRandall Spangler2013-04-241-10/+0
| | | | | | | | | | | | | apreset and apshutdown are now the same across all platforms. BUG=chrome-os-partner:18343 BRANCH=none TEST=build all platforms; make sure 'apreset warm', 'apreset cold', and 'apshutdown' work. Change-Id: I4ace1ab2bbda4d400528039ad5f84da63c9c7d0e Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/48942
* Unify lid switch processingRandall Spangler2013-04-241-18/+19
| | | | | | | | | | | | | | | | | | | STM32-based platforms now use the same lid debouncing code as LM4-based platforms, generate lid-open / lid-closed events, and trigger lid-change hooks. This is needed for disabling keyboard scanning when the lid is closed, as well as future changes to mask off wake events when the lid is closed. BUG=chrome-os-partner:18896 BRANCH=spring TEST=build all platforms; check that spring boots when lid is opened Change-Id: I09a6e91119c3739297fe49b7eacac6efda988284 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/48924 Reviewed-by: Vic Yang <victoryang@chromium.org>
* Turn on 3.3V rail earlier in power sequence for pitRandall Spangler2013-04-221-6/+22
| | | | | | | | | | | | | | The 3.3V rails powers some of the buck supplies, so must be turned on 1ms after the 5V rail. BUG=chrome-os-partner:18657 BRANCH=none TEST=build pit, snow Change-Id: I18a165744352ae375080824fecfeb56f6ac81a9c Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/48729 Reviewed-by: Vic Yang <victoryang@chromium.org>
* PMIC_PWROK is active-high on pitRandall Spangler2013-04-161-11/+35
| | | | | | | | | | | | | | | | | Add a function which handles translation of PWROK from logical level to physical level. Also implement chipset_force_shutdown() in gaia_power.c, so PMU code doesn't need to know about PWROK physical level. BUG=chrome-os-partner:18738 BRANCH=none TEST=build all platforms; boot spring Change-Id: I360266ef89b6ead49a633cd57b7530f791b04c9e Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/48251 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Decouple gaia_power from keyscan taskVic Yang2013-04-101-0/+2
| | | | | | | | | | | | This makes gaia_power.c compile when keyscan task is not present. BUG=chrome-os-partner:18598 TEST=Build spring without keyscan task. BRANCH=none Change-Id: I70823fb562a2542d92929b9219d034216f636938 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/47630
* Move board hard reset code into tpschrome driverRandall Spangler2013-04-051-9/+1
| | | | | | | | | | | | | | | | | Hard reset is done by shorting 3.3V to ground. This is only really necessary to work around the PMU's I2C engine getting into a weird / uncommunicative state. This should not make any functional changes; the code is behaving the same way it did before. BUG=chrome-os-partner:18343 BRANCH=none TEST=build daisy, snow, spring Change-Id: I0edbdfc11bd5f6643075ffc83f4df3e11fc14675 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/47199
* Add parse_bool() to centralize parsing boolean optionsRandall Spangler2013-03-291-6/+6
| | | | | | | | | | | | | | | | | | | | | | This way debug commands which previously took only yes/no or on/off or enable/disable can take any of those options. BUG=chrome-os-partner:18467 BRANCH=none TEST=Try "on", "off", "yes", "no", "true", "false", "ena", "disable", for each of the following commands: - ilim (spring) - pll (link) - power (spring/snow) - hcdebug (all) - kblog (link) - ksscan (all) - lp5562 (spring) Change-Id: Ie8e0fae3775b1da711864bcba6682ba5e68a06f1 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/46900 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Move files in preparation for merging keyboard_scan modulesRandall Spangler2013-03-271-8/+1
| | | | | | | | | | | | | | | | | | This is part one of a series to merge the keyboard scan interface to be common across all platforms. This change just moves and renames files and APIs and removes some read code, and sets up protocol-specific CONFIG options. It makes the next CL which actually merges keyboard scanning easier to parse. BUG=chrome-os-partner:18360 BRANCH=none TEST=compile all boards; test keyboard on spring and link Change-Id: I815a40aae4e5d5f333b8501aff9656080533d913 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/46549 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* spring: keep AP off when battery level is too lowVic Yang2013-03-201-3/+23
| | | | | | | | | | | | | | | | | | When battery level is too low, we want to keep the AP off even when a power on event is received. Current threshold is set to 1 mAh. Note that after this change, a board without a battery will need to wait for 15 seconds before it can boot up. BUG=chrome-os-partner:18318 TEST=Press power button and see power on event ignored. Charge battery to over AP off threshold and check we can power on the system. BRANCH=spring Change-Id: If32a1935a69be102778bde7ad8976eea0921f87e Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/45825 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Move gaia event handler declarations to gaia_power.hRandall Spangler2013-03-201-0/+1
| | | | | | | | | | | | | | This removes duplicated code in 3 different board.c files. No functional changes, just moving declarations. BUG=chrome-os-partner:18343 BRANCH=none TEST=build daisy,spring,snow Change-Id: Ie6266dca7d7d160e154fce1a09452e5cc9a1095c Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/45898
* Use chipset_reset() interface instead of system_warm_reboot()Randall Spangler2013-03-201-19/+19
| | | | | | | | | | | | | | | | We have a common chipset interface for performing a warm reset of the AP, so move the implementation from system_warm_reboot() there. (It was never a system function anyway; system = EC+AP; chipset = AP) No functional change; just renaming functions. BUG=chrome-os-partner:18343 BRANCH=none TEST=build daisy,snow,spring,mccroskey Change-Id: Ibc2c5efced5660c4335cd1868470184397800acd Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/45891
* Rename tasks to HOOKS and CHIPSETRandall Spangler2013-03-191-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | Rename tasks TICK -> HOOKS The hooks task handles more than just the TICK hook now. X86POWER -> CHIPSET GAIAPOWER -> CHIPSET Kinda kludgy that the name of the task controls which chipset source gets included. Change this to a CONFIG_CHIPSET_{X86,GAIA} #define to make it easier to support future chipsets. Also, rename the task function to chipset_task() so ec.tasklist is chipset-agnostic. No code changes, just renaming constants and functions. BUG=none BRANCH=none TEST=build bds,link,daisy,snow,spring Change-Id: I163ce1cd27b2d8d030d42bb1f7eb46b880c244fb Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/45805
* Use SECOND and MSEC constantsRandall Spangler2012-10-291-10/+10
| | | | | | | | | | | | | | | | | | We'd defined them in a number of different files. This moves definitions to timer.h, and uses them everywhere we have large delays (since 10*SECOND is less typo-prone than 10000000). Also add msleep() and sleep() inline functions. No need for mdelay() or delay(), since any delays that long should use sleep funcs instead of spin-waiting. BUG=chrome-os-partner:15579 BRANCH=none TEST=boot system; taskinfo displays similar numbers to before Change-Id: I2a92a9f10f46b6b7b6571759b1f8ab4ecfbf8259 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36726
* Hook functions no longer return valuesRandall Spangler2012-10-231-5/+5
| | | | | | | | | | | | | | | Previously, all hook functions returned EC_SUCCESS, which was meaningless because nothing ever looked at the return value. Changing the return value to void saves ~100 bytes of code size and an equal amount of source code size. BUG=none BRANCH=none TEST=code still builds; link still boots Change-Id: I2a636339894e5a804831244967a9c9d134df7d13 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36372
* Fixed a bug of sysjump: shutdown but reboot.Louis Yung-Chieh Lo2012-09-191-5/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | CL 31370 almost fixed the power on bug except in the sysjump mode. While EC firmware is being updated, the EC would sysjump between RO and RW. So that gaia_power_init() would be called and accidentally set auto_power_on to 1, which makes the next shutdown reboot instead. Thus, clear the auto_power_on if the system is already on. Also added more debug for future debug and fixed the XPSHOLD message output. Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org> BRANCH=Snow BUG=chrome-os-partner:14183, TEST=On snow: ; reboot successes. power on 1 (XPSHOLD seen) ssh root@snow_ip "ectool reboot_ec RO; ectool reboot_ec A; reboot" ; ; system halts (no more automatical power-on, ending loop 3) ssh root@snow_ip "ectool reboot_ec RO; ectool reboot_ec A; shutdown -h now" Change-Id: Iad54377d53701b986ff4f0c9996f02f8f17f070a Reviewed-on: https://gerrit.chromium.org/gerrit/33601 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Ready: Yung-Chieh Lo <yjlou@chromium.org> Tested-by: Yung-Chieh Lo <yjlou@chromium.org>
* Snow: Retry accesses to PMU before hard resetCharlie Mooney2012-09-181-1/+8
| | | | | | | | | | | | | | | | | | | | | | | Previously, after the first error when trying to reset the pmu over i2c, the ec would immediately give up and force a hard reset. Since i2c can be a little flaky from time to time, to prevent unneeded resets this allows the EC 3 attempts to configure it nicely it before it forces the whole system to reset. BUG=chrome-os-partner:14156 TEST=Boot machine successfully multiple times. Add a line in to force a failure whenever the pmu is accessed to simulate a total failure and check the EC logs, it should try 3 times on startup and on shutdown before finally resorting to a hard reset. If you add a fake failure that only triggers once, the machine should still turn out without incident. Without any fake failures, everything should work as normal. BRANCH=snow Change-Id: I1f453e9a6acc59d63e4cc80cffb58684f104ca6d Signed-off-by: Charlie Mooney <charliemooney@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/33466 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: David Hendricks <dhendrix@chromium.org>
* gaia_power: Report power on reasonSimon Glass2012-09-061-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | Report the reason for a power on, to assist with debugging. BUG=chrome-os-partner:11307 BRANCH=snow TEST=manual Build and boot on snow See that power on reason is now reported > 0.003508 power on 2 [0.028674 AP running ...] ... 12.163780 ending loop 2 Shutdown complete. [batt] state discharging -> idle 17.801167 power on 4 Overriding CHARGER_INT with CHARGER_INT on EXTI4 [17.825873 AP running ...] 17.826071 XPSHOLD seen [batt] state idle -> discharg Change-Id: I2044419b330a74d19d8c4e63fa8853aa477b4df1 Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/32301 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* gaia: notify chipset pre-init hook before turning on APDavid Hendricks2012-08-291-5/+9
| | | | | | | | | | | | | | | | | This notifies the CHIPSET_PRE_INIT hook before turning on the AP. Signed-off-by: David Hendricks <dhendrix@chromium.org> BRANCH=snow BUG=chrome-os-partner:13315 TEST=tested in subsequent CL Change-Id: Ic2bc17ed2b561f640af53970d291e5d04d2f72e7 Reviewed-on: https://gerrit.chromium.org/gerrit/31739 Reviewed-by: Charlie Mooney <charliemooney@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Ready: David Hendricks <dhendrix@chromium.org> Tested-by: David Hendricks <dhendrix@chromium.org>
* gaia: update ap_suspended usageDavid Hendricks2012-08-291-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL updates ap_suspended usage so that it's only updated when it makes sense to do so: - Clear ap_suspended during power_off() since it can only be reliably determined when the pull-up on PA7 is enabled (when AP is on). - chipset_in_state() should not re-assign ap_suspended. That was a hack to try to get around earlier brokenness. However, that does not really work since SUSPEND_L can appear to be asserted when AP is off and could cause ap_suspended to become inconsistent with the actual AP state. - When AP is on, ap_suspended should be managed by gaia_suspend_event. When AP is off, ap_suspended should be 0 ( Signed-off-by: David Hendricks <dhendrix@chromium.org> BRANCH=snow BUG=chrome-os-partner:13200 TEST=tested on Snow using "power" command at EC console 1. AP running > power on 2. after running powerd_suspend > power suspend 3. "power off" at EC console > power off Change-Id: I88dad9f02d57fe7244bf607eea2088ee0b80b75a Reviewed-on: https://gerrit.chromium.org/gerrit/31627 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Ready: David Hendricks <dhendrix@chromium.org> Tested-by: David Hendricks <dhendrix@chromium.org>
* gaia: Add a warm reboot functionSameer Nanda2012-08-281-0/+27
| | | | | | | | | | | | | | | | | | | | Added a warm reboot function that reboots the AP while preserving RAM contents. This will be helpful in debugging AP/OS hard hangs since in conjunction with PSTORE_CONSOLE in the kernel, the kernel log messages from the previous boot will be preserved. BUG=chrome-os-partner:13249 TEST=1. From EC console issue the "warm_reboot" command. Upon rebooting "cat /dev/pstore/console-ramoops" and ensure that the contents are dmesg of previous boot. 2. Reboot the system using alt-volume_up-r key combination. Upon rebooting, check pstore contents in the same manner as case#1 above. BRANCH=snow Change-Id: Ic8f0415da6182f4c1bc2d35b91302ceda5c19569 Signed-off-by: Sameer Nanda <snanda@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/31523 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Snow: Adding in EC ability to hard reset pmicCharlie Mooney2012-08-281-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By pulling line gio_A15 high, you can for a hard reset of the pmic after the stuff resistor is changed. This change adds a function that you can call from the EC and trigger this event (board_hard_reset). The user has access to this command over the EC console by running "pmu reset" and it will force the emergency reset. The board_hard_reset function is used in the pmu's reset code. Whenever it is trying to initialize or shut down the pmu, it resets many or all of its registers over i2c. If the i2c commands fail to get a response from the pmu, the EC will now force a hard reset of the system, which restores everything, allowing for a restart to fix any situation where the pmu has gotten its configuration trashed. BUG=chrome-os-partner:12913 TEST=boot the machine. From EC console check the pmic's register values, then alter them. Run "pmu reset" to force a reset, and check the values again. They should be safe values, which you can confirm by powering on the AP. Repeat this from various starting states: only the EC on, AP on as well, and setting various registers to 0x00's and 0xff's. To stress test the hard-reset ability from the EC's POV, run while true; do echo "pmu reset"; sleep 5; done | cu -l DEVICE -s 15200 BRANCH=snow Change-Id: I911fb9623a7c106d1f993ee4681258c05d4dedae Signed-off-by: Charlie Mooney <charliemooney@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/31524 Reviewed-by: Simon Glass <sjg@chromium.org>
* Reset pmic registers to known safe values on bootCharlie Mooney2012-08-271-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | If a bug causes the pmic's internal registers to be overwritten with garbage, they won't go away and can cause long lasting problems. This change overwrites them all whenever the EC or AP turn on with known, safe values, so if that happens, a reboot will restore them instead of forcing the user to pull the battery. It also overwrites a few of them when the AP shuts down, to prevent AP bugs from leaving the pmu powering a bunch of peripherals that it doesn't need after it has turned off. BUG=chrome-os-partner:12913 TEST=from EC console run "i2c w 0x90 0x0c 0xff" to screw up one of the pmic registers. Reboot the EC, and the AP should be able to boot just fine. Once the AP is booted, run that command again. This time, just reboot the AP, it should come back on like normal. Try again with "i2c w 0x90 0x0c 0x00". Without the change, this fails to work. BRANCH=snow Change-Id: If3f0764f23e0112cc11be60b413f51e1b66e54a7 Signed-off-by: Charlie Mooney <charliemooney@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/31259 Reviewed-by: Doug Anderson <dianders@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Puneet Kumar <puneetster@chromium.org>
* stm32: fix AP auto power onVincent Palatin2012-08-241-3/+3
| | | | | | | | | | | | | | | | | | | | | The logic introduced by CL 28139 was incorrect (ie it just sets to 0 the auto_power_on variable which is already 0) For software sync, we always want to power the AP. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BUG=chrome-os-partner:13126 TEST=on Snow, cold reset the EC and see the AP firmware booting. in U-Boot console, type "mbkp reboot cold" and see the AP rebooting instead of shutting down. BRANCH=snow Change-Id: Ib88f75a8b159015df708c041cdc14153fe8736a9 Reviewed-on: https://gerrit.chromium.org/gerrit/31370 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* Fix poweron state machine in the ECPuneet Kumar2012-08-241-52/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The existing state machine does the following: - when power button is pressed it 1. powers on the AP 2. sets a timer of 1 sec and then 3. waits for power button to be released When the timer fires it checks xpshold is set by the AP and if so it clears the pwron signal (which is used by the AP to detect power button is pressed). The problem occurs when the user holds the power button for more than a second. The AP turns on xpshold, then notices that pwron is still on and subsequently powers down because it thinks the power button is pressed. When the button is finally released, since it was held down for more than a second, the timer routine notices that xpshold is not on and therefore shuts down the system. Another problem found while analysing this state machine is that loop checking for poweroff only triggers on the rising edge of xpshold. This means that if the AP powers down the EC might miss a possible power event. Here is the proposed fix: When the power button is pressed the EC will: 1. power on the AP 2. Check for xpshold to be asserted with a 1 sec timeout 3. If uboot is healthy xpshold should come on pretty quickly; the EC then waits for the power button to be released in less than 8 seconds 4. If the power button is released then the EC waits for power off events. 5. If the power button is not released it waits for upto 8 seconds before turning off the AP. The added wrinkle is how to address a borked uboot case. In the case where xpshold doesn't come on in < 1 second, the EC will allow the AP to stay on for upto 16 seconds so that USB boot can finish. The user must hold the power button down until uboot boots and sets xpshold. The assumption here is that USB boot takes < 16 seconds. BUG=chrome-os-partner:12748 TEST="follow instructions in bug report" Change-Id: I5b582a6c3ae3449238e2813e4a581bd8f92dd846 Signed-off-by: Puneet Kumar <puneetster@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/31291 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: David Hendricks <dhendrix@chromium.org>
* gaia: Assert PMIC_PWRON_L only if XPSHOLD is lowDavid Hendricks2012-08-221-2/+7
| | | | | | | | | | | | | | | | | | | This is intended to prevent accidental AP reboot when soft rebooting the EC, e.g. via sysjump during firmware updates. For our platforms, the PMIC_PWRON_L causes the AP to see a keyboard power button press. Signed-off-by: David Hendricks <dhendrix@chromium.org> BRANCH=snow BUG=chrome-os-partner:12650 TEST=sysjump via "ectool reboot_ec RW" or firmware update no longer causes AP to reboot, Change-Id: Ife227285499d5cd52d6a0cb0ebe5df2f51d706d4 Reviewed-on: https://gerrit.chromium.org/gerrit/30291 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Ready: David Hendricks <dhendrix@chromium.org> Tested-by: David Hendricks <dhendrix@chromium.org>
* stm32: don't go to stop mode in suspendVincent Palatin2012-08-161-2/+0
| | | | | | | | | | | | | | | | | | | | When the AP is suspended, we are using the timer TMR2 to do the power led "breathing", so we cannot cut the clocks as they are used for this PWM. The EC will be in idle mode instead of stop mode during S3. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BUG=chrome-os-partner:8866 TEST=on Snow, suspend the AP and see you can still type in the EC console and the power led is "breathing". Change-Id: Ib4cce36c5a9bf649996bf627baeb30ef2a3221a8 Reviewed-on: https://gerrit.chromium.org/gerrit/30057 Reviewed-by: David Hendricks <dhendrix@chromium.org> Reviewed-by: Rong Chang <rongchang@chromium.org> Tested-by: Rong Chang <rongchang@chromium.org> Commit-Ready: <arscott@google.com>
* daisy: Modify charging flow to comply charging specificationRong Chang2012-08-161-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | This change corrects charger interrupt event handling, charger enable gpio, battery full condition, EC deep sleep mode support when AC unplugged, and lid controlled power off. Signed-off-by: Rong Chang <rongchang@chromium.org> BRANCH=snow BUG=chrome-os-partner:12573,12574,12575 TEST=manual - ec console command 'gpioget': - SPI1_MISO should be 0 when AP off - CHARGER_EN should be 0 after AC unplugged - charging led should be off after AC unplugged - when battery remaining charge < 3%, system should be powered off without AC. - ec console command 'sleepmask 0', turn off AP: - deep sleep only when AC unplugged Change-Id: I0f63835dae67d90de7a8c8c6c3537ca9a16faed4 Reviewed-on: https://gerrit.chromium.org/gerrit/30316 Commit-Ready: Rong Chang <rongchang@chromium.org> Reviewed-by: Rong Chang <rongchang@chromium.org> Tested-by: Rong Chang <rongchang@chromium.org>
* Handle IRQ from TPS65090, pass AC status to APSimon Que2012-08-141-0/+3
| | | | | | | | | | | | | | | | | | | Changes made by this patch: 1. Create IRQ handler for the TPS65090 IRQ. IRQ wakes up charger task. 2. Charger task sets the AC_STATUS GPIO based on the AC status. 3. Initialize PMU at power-on. BRANCH=snow BUG=chrome-os-partner:11739 TEST=Power on the system, with servo v2 connected to EC console. Plug and unplug AC. The IRQ handler should be triggered. Change-Id: Ice23411c275111fdb56d2c47ba28c3c44dee4d71 Signed-off-by: Simon Que <sque@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/29914 Commit-Ready: Rong Chang <rongchang@chromium.org> Reviewed-by: Rong Chang <rongchang@chromium.org> Tested-by: Rong Chang <rongchang@chromium.org>
* stm32f100: implement low power modeVincent Palatin2012-08-091-0/+5
| | | | | | | | | | | | | | | | | | | | | When the AP is not running and we have enough time go to STOP mode instead of simple idle. The EC consumption should drop from 12mW to a few mW. This is currently not activated by default, you need to type "sleepmask 0" in the EC console to activate it. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BUG=chrome-os-partner:8866 TEST=on Snow, check the software is still working properly when STOP mode is activated and measure power consumption on 3v_alw rail. Change-Id: I231d76fe6494c07b198c41694755b82d87c00e75 Reviewed-on: https://gerrit.chromium.org/gerrit/29315 Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
* Fixing lid power behavior -- shutdowns vs rebootsCharlie Mooney2012-08-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | When the user is logged in a closes/opens the lid of the laptop the lid_changed flag gets set, but never cleared. Normally, it would get cleared when it powered back on from being opened, but without powerm running or is the machine is only suspended, then that never happens. This fixes the problem by additionally clearing the flag whenever the computer is powered down. This forces the computer to not turn on based on anything that happened to its lid before it was turned off, which is the behavior you'd expect. BUG=chrome-os-partner:12189 TEST=Log in to your Chomebook completely. Close, then open the lid. Shut the computer down. It should stay off now. Once it's back on close the lid and confirm that it still suspends correctly. Now open the lid and make sure it turns back on. Repeat these steps, but kill powerm first. Change-Id: I2275b3125115b4eacc6a5d074978d7a1d51b0695 Signed-off-by: Charlie Mooney <charliemooney@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/29111 Reviewed-by: Benson Leung <bleung@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Fixing bug: Keyboard locks up after 8s pwr pressCharlie Mooney2012-07-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | The EC was not re-enabling keyboard scanning on boot if the power button was released. This works fine if the power button is released before the shutdown is complete, but if the user holds it down until the device is completed powered down the lock will never be released, and the next time they turn on the computer, the keyboard won't work. To fix this, all that is needed is to make the power event task keep unlocking it whenever the power button isn't pressed down. There's no problem with unlocking multiple times, so it's not dangerous to do this. BUG=chrome-os-partner:12070 TEST=Boot the machine normally, then press and hold the power button until the machine is entirely powered down before releasing it. Press the power button a second time to turn on the machine. You should be able to type as normal. Change-Id: I88852ed228bd8f6a9446406bab642812ef1327db Signed-off-by: Charlie Mooney <charliemooney@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/28871 Reviewed-by: David Hendricks <dhendrix@chromium.org>
* Modify Gaia power message to match x86 power moduleVic Yang2012-07-261-4/+5
| | | | | | | | | | | | | Message from power modules should be similar for easier testing. BUG=chrome-os-partner:11815 TEST=none Change-Id: I07e061a34e7d8f8c1f1547d6e15f22f29ee22b84 Reviewed-on: https://gerrit.chromium.org/gerrit/28394 Commit-Ready: Vic Yang <victoryang@chromium.org> Reviewed-by: Vic Yang <victoryang@chromium.org> Tested-by: Vic Yang <victoryang@chromium.org>
* Stop keyboard scans from triggering ARM EC resetCharlie Mooney2012-07-261-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | The ARM EC was being rebooted when both the power and one of several other keys were pressed. (LCtrl, Tab, Reload, t, [, ], y, Dim Screen and Mute) It should only do this when the key combo PWR + Reload is pressed. To fix it, keyboard scanning is disabled whenever the power button is pressed. It locks a mutex indicating that scanning should be disabled, and the main keyboard scanning task blocks on the step where it sets up the keyboard and waits for the mutex to unlock. BUG=chrome-os-partner:10889 TEST=Pick one of the troublesome keys. First press it, then quickly press the power button. Then press the power button followed by the troublesome key. Repeat this process several times for each key, it should not reset the system. Press power + reload, this should still reset the system. Pressing and holding power should initiate a shutdown. Change-Id: Ib60d2ebbb57eb8a3c135662514ec622c37a7eb07 Signed-off-by: Charlie Mooney <charliemooney@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/28402 Reviewed-by: David Hendricks <dhendrix@chromium.org>
* Refactor reboot command to add ap-off and cancel optionsRandall Spangler2012-07-231-2/+7
| | | | | | | | | | | | | | | | | | | | | | Also add 'preserve' flag, for tracking when flags have been preserved from a previous boot. BUG=chrome-os-partner:11663 TEST=manual reboot -> flags = soft reboot preserve -> flags = soft preserve From ectool, 'ectool reboot_ec cold at-shutdown' sysinfo -> shows reboot at shutdown: 4 reboot cancel sysinfo -> no longer shows pending reboot reboot ap-off -> flags = soft ap-off, AP is not powered on Change-Id: I117f33fe21048edb2261be4dcdc6c828a5794d54 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/28139
* daisy/snow: enable SUSPEND_L interruptDavid Hendricks2012-07-191-0/+1
| | | | | | | | | | | | | | This enables interrupts on SUSPEND_L. Signed-off-by: David Hendricks <dhendrix@chromium.org> BUG=none TEST=Power LED on Snow throbs when powerd_suspend is used Change-Id: I5f06e717ddc07d5c2f129ff59a108131da8dbf87 Reviewed-on: https://gerrit.chromium.org/gerrit/27968 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Ready: David Hendricks <dhendrix@chromium.org> Tested-by: David Hendricks <dhendrix@chromium.org>
* Send hook notification on GAIA power eventVic Yang2012-07-181-0/+10
| | | | | | | | | | | | | | GAIA power module should send hook notification when power state changes. BUG=chrome-os-partner:11536 TEST=Hook a console message to HOOK_CHIPSET_SHUTDOWN and check this message is printed to console when system shuts down. Change-Id: I5bc3e69eeefeeda453526625887f852b9095ac08 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/27814 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* gaia_power: Allow AP power to be controlledSimon Glass2012-07-171-2/+37
| | | | | | | | | | | | | | | | Enhance the power command to support turning power on/off. Do this by requesting the state of the main power control loop, rather than hacking in new states or flags. BUG=chrome-os-partner:11427 TEST=manual Try 'power on' and 'power off' and see that it obeys. Change-Id: Ie6db41dda16176818510f8902ab803e165494424 Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/27654 Reviewed-by: David Hendricks <dhendrix@chromium.org>
* gaia_power: Add power command to check power state.Simon Glass2012-07-171-0/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is useful to be able to see the current AP power state, and x86 has a command for this. Add one for gaia. BUG=chrome-os-partner:11427 TEST=manual (start with power off) > powerinfo off (press power button) > [batt] state idle -> pre-charging AP running ... Power button released Setting pwron timer 10038870 powerinfo on > Releasing pwron (after kernel boots, make device go into suspend by typing this at kernel command line: type echo mem > /sys/power/state) > powerinfo suspend Change-Id: I3244b3a7fd0b6dd689f3470fb97ffe5a72c8d8f9 Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/27653 Reviewed-by: David Hendricks <dhendrix@chromium.org>
* daisy: Re-read suspend gpio when asked for chipset stateRong Chang2012-07-171-0/+7
| | | | | | | | | | | | | | | | | | The SUSPEND_L GPIO is marked interruptable, but this apparently does not work, and the gaia_suspend_event() function is not updated as expected. As a workaround, check the GPIO value on ever call to chipset_in_state(). BUG=chrome-os-partner:11285 TEST=manal Using new 'power' command check that the state updates when the AP is in suspend from 'on' to 'suspend'. Change-Id: I9c520e69b9910c649bf6d8381ee167da6facc634 Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/27652 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* gaia: add lid switch functionality to power statesDavid Hendricks2012-07-071-8/+40
| | | | | | | | | | | | | | | | | This adds a small interrupt handler for lid open/close event which updates a state variable and wakes up the power task to decide if action must be taken. For the suspend mode path, it will determine which state to set the power LED in. BUG=chrome-os-partner:9708 TEST=Lid open turns on Snow, suspend mode to be tested separately Signed-off-by: David Hendricks <dhendrix@chromium.org> Change-Id: Ib8bb682affc5b9f6d729eb5f05d23098074e1a77 Reviewed-on: https://gerrit.chromium.org/gerrit/26647 Reviewed-by: David Hendricks <dhendrix@chromium.org> Tested-by: David Hendricks <dhendrix@chromium.org> Commit-Ready: David Hendricks <dhendrix@chromium.org>
* Daisy/Snow: Drive power LED with PWMDavid Hendricks2012-07-021-57/+5
| | | | | | | | | | | | | | | | | | | | This drives the power LED for Snow (PB3) using TIM2 in PWM mode. Since timer setup and manipulation is STM32-specific, the power LED logic moved to to chip/stm32/power_led.c. This also adds a "powerled" console command for testing. Signed-off-by: David Hendricks <dhendrix@chromium.org> BUG=chrome-os-partner:10647 TEST=Tested on Snow with powerled command, compiled for Daisy Change-Id: I5a7dc20d201ea058767e3e76d54e7c8567a3b83c Reviewed-on: https://gerrit.chromium.org/gerrit/26267 Commit-Ready: David Hendricks <dhendrix@chromium.org> Reviewed-by: David Hendricks <dhendrix@chromium.org> Tested-by: David Hendricks <dhendrix@chromium.org>
* stm32: drive the keyboard power LEDVincent Palatin2012-06-221-4/+73
| | | | | | | | | | | | | | | | | | | | Put the power LED in the right state (off, on, breathing) depending on the AP state (off, running, suspending). The power LED is connected to GPIO B3. The AP suspend detection is done through GPIO A7. (so we no longer configure it as SPI alternate function) Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BUG=chrome-os-partner:10647 TEST=on Lucas DVT, boot/stop the board and see the LED on and off. Change-Id: I42121aacab35e9da7a751dc9f56bcc5af7850783 Reviewed-on: https://gerrit.chromium.org/gerrit/25880 Reviewed-by: David Hendricks <dhendrix@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
* Detect recovery key combinationVincent Palatin2012-05-311-0/+14
| | | | | | | | | | | | | | | | Check if ESC+Power+Refresh is pressed at startup, if the recovery combination is detected, record it to allow U-Boot to go into recovery. The status of the keyboard recovery can be read from the response of the EC_CMD_MKBP_INFO command. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BUG=chrome-os-partner:9916 TEST=On Snow, do a recovery reset by pressing ESC+Refresh+Power and see the trace, try other resets and don't see it. Change-Id: I0e1a8214781a6e74bd90bf8313887a9dcf4df56d