summaryrefslogtreecommitdiff
path: root/chip
Commit message (Collapse)AuthorAgeFilesLines
* Switch LPC to use HOOK_TICK instead of taskRandall Spangler2012-10-301-10/+8
| | | | | | | | | | | | BUG=chrome-os-partner:15714 BRANCH=none TEST=taskinfo no longer shows LPC task Change-Id: I693cc8695d89d0207076f12d82bdc1f30d5df7b7 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36910 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Add tick taskRandall Spangler2012-10-302-0/+6
| | | | | | | | | | | | | | | | | | | Adds a new HOOK_TICK event which is called every 250ms (LM4) or 500ms (STM32). This will be used to consolidate a number of tasks which do small amounts of work infrequently, and previously needed their own task functions. This CL adds the tick task; subsequent CLs will consolidate watchdog and other tasks into tick hooks. BUG=chrome-os-partner:15714 BRANCH=none TEST=taskinfo shows TICK task as lowest priority Change-Id: I9068ee99d56a5bf5c12afd86ad51998c013f4954 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36908 Reviewed-by: Simon Glass <sjg@chromium.org>
* Clean up power button moduleRandall Spangler2012-10-301-38/+62
| | | | | | | | | | | | | No functional changes BUG=chrome-os-partner:15579 BRANCH=none TEST=boot system, power off with power button, power on with power button Change-Id: I25aa5c527b7b9f9db6f5c539cecb37ac4bc197f8 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36820 Reviewed-by: Simon Glass <sjg@chromium.org>
* Clean up ADC moduleRandall Spangler2012-10-303-79/+73
| | | | | | | | | | | | | | ADC config structs are now chip-specific; this saves code size (several hundred bytes on LM4, since no need for 24-entry ADC channel to GPIO mapping table). BUG=chrome-os-partner:15579 BRANCH=none TEST='adc' with system on and off; ChargerCurrent should be bigger when on. Change-Id: Ia88b3f043438bec049f2d2ad39fc42dcf86d9424 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36798
* Use SECOND and MSEC constantsRandall Spangler2012-10-2916-85/+73
| | | | | | | | | | | | | | | | | | 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
* Clean up x86power moduleRandall Spangler2012-10-261-1/+16
| | | | | | | | | | | | | Code cleanup; no functional changes. BUG=chrome-os-partner:15579 BRANCH=none TEST=boot system to OS; should still boot Change-Id: Icbb628e60792cbecd073a526cd6f879d9e4b20ab Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36692 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Clean up pwm moduleRandall Spangler2012-10-251-25/+87
| | | | | | | | | | | | | No functional changes. But hey, I'm having lots of fun reformatting comments. BUG=chrome-os-partner:15579 BRANCH=none TEST=fanset -1; fanset 0; fanset 4000 Change-Id: Iddcea5b8e59fa6668cdd347b6d31155c28991521 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36585 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Clean up system moduleRandall Spangler2012-10-252-27/+21
| | | | | | | | | | | | | | No functional changes. (it might look like SYSTEM_HIB_MINIMUM_DURATION is a change, but it's not used at present) BUG=chrome-os-partner:15579 BRANCH=none TEST=version; chip info should print successfully Change-Id: Idd7f60a29528e9f6af4f91cd5a556e7336acee9f Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36599 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Clean up LED and onewire modulesRandall Spangler2012-10-252-39/+44
| | | | | | | | | | | | | No functional changes. BUG=chrome-os-partner:15579 BRANCH=none TEST=powerled red, then powerled green Change-Id: I595b725c14d94133f7f151d0b92cabe0e0bcf4ca Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36577 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Clean up I2C moduleRandall Spangler2012-10-252-150/+149
| | | | | | | | | | | | | No functional changes, just cleanup BUG=chrome-os-partner:15579 BRANCH=none TEST=i2cscan; should find all expected devices Change-Id: I8e11d3fa460236e80a0ce1ee923e4413b3202c1e Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36569 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Cleanup: flash moduleRandall Spangler2012-10-253-50/+71
| | | | | | | | | | | | | No functional changes; just clean up comments and remove dead code BUG=chrome-os-partner:15579 BRANCH=none TEST=code compiles Change-Id: Id006ae18f2b26cea1720196f696f937811b6ba5b Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36448 Reviewed-by: Simon Glass <sjg@chromium.org>
* Clean up GPIO moduleRandall Spangler2012-10-254-67/+65
| | | | | | | | | | | | | Just code cleanup; no functional changes BUG=chrome-os-partner:15579 BRANCH=none TEST=build code; boot link; gpioget still works Change-Id: If0770c1a5ce0d5c51ba528fbe2944a73fafa949b Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36556 Reviewed-by: Simon Glass <sjg@chromium.org>
* Revert "lm4: Add chip name for lm4fs1gh5bbfig"Jon Salz2012-10-231-2/+0
| | | | | | | | | | This reverts commit db2c527d5cab61af399694cc853d1dfce1bbd3cd Change-Id: I033916921993bffc6a3c0d6bbb70a867b73b25a9 Reviewed-on: https://gerrit.chromium.org/gerrit/36414 Commit-Ready: Jon Salz <jsalz@chromium.org> Reviewed-by: Jon Salz <jsalz@chromium.org> Tested-by: Jon Salz <jsalz@chromium.org>
* Clean up keyboard_scan moduleRandall Spangler2012-10-232-22/+6
| | | | | | | | | | | | | We only have one scan mask and no capability to change scan masks, so don't reserve space for masks we're not using. BUG=chrome-os-partner:15579 BRANCH=none TEST=type on keyboard; should still work Change-Id: I8ad0c5c894f93c2a79ca646e7666b3279c90a63c Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36347
* Clean up i8042 moduleRandall Spangler2012-10-231-6/+2
| | | | | | | | | | | | | | | | | Remove unused code paths. Simplify interfaces. Clarify comments. Split the protocol constants into their own header file (since they're used only by keyboard.c, not i8042.c, which is really keyboard buffering... and will be renamed so in a followup CL.) This cleanup reduces binary size by about 200 bytes. BUG=chrome-os-partner:15579 BRANCH=none TEST=type on the keyboard; it should still work. Change-Id: I6acbab5fe5604b4b0c516ba3622e6f41820985d1 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36271
* Hook functions no longer return valuesRandall Spangler2012-10-2317-108/+44
| | | | | | | | | | | | | | | 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
* lm4: Add chip name for lm4fs1gh5bbfigVic Yang2012-10-221-0/+2
| | | | | | | | | | BUG=chrome-os-partner:15519 TEST=none BRANCH=link Change-Id: I00c27eab4320a95b17c4f18572835fea1fb8cdf7 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36307
* lm4: Report raw DID value when chip name cannot be determinedVic Yang2012-10-221-1/+26
| | | | | | | | | | | | | | | | | We map the raw DID value to chip name in EC. If the raw value is not in the mapping table, EC just returns empty string and we lose this information from host side. Let's return raw DID value like "Unknown-10ea". BUG=chrome-os-partner:15519 TEST=remove 0x10ea from the mapping and check 'mosys -k ec info' shows 'Unknown-10ea'. BRANCH=link Change-Id: I9399f44ab40db02202ee03ba3f988f3ece010d9f Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36305 Reviewed-by: David Hendricks <dhendrix@chromium.org>
* link: Fix checking runtime keysRandall Spangler2012-10-181-2/+3
| | | | | | | | | | | | | | | | | This accidentally got disabled when printing keyboard scan state was turned off by default. BUG=chrome-os-partner:15466 BRANCH=link TEST=alt+volup+R should reboot system Then from console, ksstate on Then press keys; KB state should print on console Change-Id: I7d410b56210fda0c73c65d9d76ccc7b4e873516c Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/35971 Reviewed-by: Simon Glass <sjg@chromium.org>
* link: Increase EC cold reboot time to 150msRandall Spangler2012-10-181-1/+1
| | | | | | | | | | | | | | | | This matches Silego's recommendation as of 10/18. BUG=chrome-os-partner:14687 BRANCH=link TEST='reboot cold' repeatedly from EC console (or 'ectool reboot_ec cold' repeatedly from root shell), then check that Power+Esc still reboots the system. Change-Id: Ief2962bf66a947e83dfe934e45e18dc37d6ba326 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/35968 Reviewed-by: Simon Glass <sjg@chromium.org>
* link: host command params must be 32-bit alignedRandall Spangler2012-10-171-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a problem where flash writes would fail because the source buffer was not 32-bit aligned. BUG=chrome-os-partner:15435 BRANCH=link TEST=from a root shell, localhost ~ # echo 1234567812345678123456781234567 > /tmp/data localhost ~ # ls -l /tmp/data -rw-r--r-- 1 root root 32 Oct 17 17:28 /tmp/data localhost ~ # ectool flasherase 0x3a000 0x4000 Erasing 16384 bytes at offset 237568... done. localhost ~ # ectool flashwrite 0x3a000 /tmp/data Reading 32 bytes from /tmp/data... Writing to offset 237568... done. If that doesn't crash, the fix works (prior to this fix, that would reboot the system). Change-Id: I8d197e7ef7a1c74825916bd788f7d450088a55cc Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/35916 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* link: Don't print keyboard state changes by defaultRandall Spangler2012-10-171-1/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The keyboard scan module generates a lot of debug output when the user is typing on the keyboard - enough so that switching to the console, logging in as root, and typing 'ectool console' flushes the EC's console output buffer of any useful data. Default printing this to off. Add a new 'ksstate' command which will print the current keyboard scan state or toggle printing off/on. This is important for debugging LPC communication failures. BUG=chrome-os-partner:13819 BRANCH=link TEST=manual - Boot system - Type on keyboard. At EC console, should not see KB state: output - Hold down space bar. - At EC console, type 'ksstate'. Should print: ksstate [20.943886 KB debounced : -- -- -- -- -- -- -- -- -- -- -- 20 --] [20.945215 KB prev : -- -- -- -- -- -- -- -- -- -- -- 20 --] [20.945568 KB debouncing: -- -- -- -- -- -- -- -- -- -- -- -- --] Keyboard scan state printing off - Release space bar - At EC console, type 'ksstate on' - Type on keyboard. Should see KB state: output - At EC console, type 'ksstate off' - Type on keyboard. At EC console, should not see KB state: output Change-Id: I4343b7b777fd13057b3222eeba77ed099c5e5a93 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/35843 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
* link: don't rely on host-write interrupt statusRandall Spangler2012-10-171-36/+55
| | | | | | | | | | | | | | | | | | | | | | | | This works around a potential LM4 chip problem where edges on the FRMH status bit don't always trigger interrupts. The workaround is to look at FRMH for each channel in the interrupt handler rather than the interrupt status, and to trigger the interrupt every 250ms to sweep up any missed writes. We already do this for port 80 writes; this just extends the workaround to all channels. BUG=chrome-os-partner:13965 BRANCH=link TEST=manual - boot system - EC console should show a number of HC lines for host command - EC console should show a number of ACPI queries - switch to root shell; keyboard should work - ectool version should work Change-Id: If02d685519c69ee88c055c8374a6c655a277e637 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/35871 Reviewed-by: Simon Glass <sjg@chromium.org>
* stm32: Swallow special keys instead of passing them to APSimon Glass2012-10-171-5/+10
| | | | | | | | | | | | | | | | | | | During the debounce refactor we unintentionally adjusted the behavior of special keys so that they are no longer swallowed (as per commit 9332d76). The LM4's keyboard behaves differently so this code cannot be brought over as is. Bring back the required behavior for STM32. BUG=chrome-os-partner:14496 TEST=hit alt-volume_up-r keys together. See that the AP does not see this keypress in U-Boot by checking the EC console has no 0x60 messages. BRANCH=snow Change-Id: I043fbba4d9be5941e550257b99bdb2137792c133 Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/35767 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* link: increase time in hibernate for EC cold resetRandall Spangler2012-10-161-2/+10
| | | | | | | | | | | | | | | This works around a problem where the Silego chip doesn't cleanly reset for short hibernate durations. BUG=chrome-os-partner:14687 BRANCH=link TEST=ectool reboot_ec cold (~100 times), then check if power+refresh still reboots the system Change-Id: I14098940da9331856dd061a56a60a47c9a1cf1f8 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/34832 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* link:re-enable fan RPM controller when neededRandall Spangler2012-10-151-38/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, any command which set the fan duty manually would leave the PWM RPM controller disabled. Setting the fan back to auto mode via 'ectool autofanctrl' or 'autofan' or 'ectool pwmsetfanrpm' wouldn't turn the controller back on. Now it does. BUG=chrome-os-partner:14307 BRANCH=link TEST=manual - Reboot in recovery mode and wait for INSERT screen - From EC console fanduty 100 -> fan turns on all the way faninfo -> mode is duty fanset 6000 -> fan turns down to a lower level faninfo -> mode is rpm fanduty 0 -> fan turns off all the way faninfo -> mode is duty (wait a min or so for the system to heat up) autofan -> fan turns on faninfo -> mode is rpm - Reboot normally - From root shell ectool fanduty 100 -> fan turns on all the way ectool pwmsetfanrpm 6000 -> fan turns down to a lower level Change-Id: I3b07e8b49500f5f8a42f20909d2869cf63987d6d Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/35335 Reviewed-by: Sameer Nanda <snanda@chromium.org>
* link: Ignore keyboard when lid is closedRandall Spangler2012-10-122-14/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The lid is flexible enough that it's possible to press keys by squeezing the laptop. To keep this from waking the device from suspend or powering it on, don't scan the keyboard or power button when the lid is closed. BUG=chrome-os-partner:15252 BRANCH=link TEST=manual - boot system - use a magnet near the search key to trigger the lid-closed switch - press space, then power. neither one should trigger resume - remove magnet. system resumes - space and power should work as expected again - log out - use magnet to trigger lid-closed switch (looking at EC console output is handy here). system should shut down - pressing power should not boot the system - remove magnet; system will boot - pressing power should work as expected again Change-Id: I92080237b0a2f21774301df3d8e866878697b793 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/35425 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* stm32: support DMA on I2C1Vincent Palatin2012-10-113-30/+54
| | | | | | | | | | | | | | | | | | | | | Each I2C controller needs to use a fixed pair of DMA channels. The former code was hardcoded for I2C2. We now use the board configuration to decide between I2C1 and I2C2 DMA channels. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:15185 TEST=make BOARD=snow && make BOARD=spring && make BOARD=daisy run on Spring and Snow and see we can communicate both with the PMU (using "pmu" EC console command) and the AP (answering U-Boot host command) Change-Id: Ifd6806205b443c623e3db09fb1a2d5804bb94214 Reviewed-on: https://gerrit.chromium.org/gerrit/35355 Reviewed-by: Charlie Mooney <charliemooney@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org> Commit-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
* stm32: make power led optionalVincent Palatin2012-10-111-1/+2
| | | | | | | | | | | | | | | | | | | | | The spring board doesn't have one and we doesn't want to mess up with that pin. When the POWERLED task is not present, let's de-activate cleanly that code. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BUG=chrome-os-partner:14324 TEST=make BOARD=spring (no power_led.o compiled) make BOARD=snow (power_led.o compiled) make BOARD=link && make BOARD=bds run on Snow and see the power LED working Change-Id: Ib44f5df54ec4fdee1863814e6c7052fd6620fee8 Reviewed-on: https://gerrit.chromium.org/gerrit/35272 Commit-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* link: EC reclaims fan control on AP shutdownRandall Spangler2012-10-111-2/+2
| | | | | | | | | | | | | | | | | | | | | Previously, if the AP took fan control, the EC would never take it back. This meant the EC would leave the fan off even if the system was sitting at the INSERT screen or booted an alternate OS. BUG=chrome-os-partner:15189 BRANCH=link TEST=manual - boot system - from EC console, fanset 0 - faninfo shows fan at 0rpm - from root shell, crossystem recovery_request=123 && reboot - wait a few mins - faninfo should show fan spinning again Change-Id: I534c9978194085467f1df6eae971c55d4e8083be Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/35309
* link: Reset fan target RPM when suspendingRandall Spangler2012-10-111-0/+1
| | | | | | | | | | | | | | | | | | This prevents the fan from coming on loudly during resume. BUG=chrome-os-partner:15187 BRANCH=link TEST=manual - power on system - wait for it to heat up; type faninfo periodically from ec console - when faninfo reports non-zero, type 'powerd_suspend' at root shell - faninfo should now report Target: 0 rpm Enable: no Change-Id: Ia5ee93c0f5c6626afd54a22d2996ab65cf8e3b18 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/35303 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* link: Temp sensors can return not-powered error codeRandall Spangler2012-10-111-1/+5
| | | | | | | | | | | | | | | | | | | | | | | This removes the need for a separate method to check sensor power, and gets rid of temp_sensor.c knowledge of what powers each sensor. BUG=chrome-os-partner:15174 BRANCH=link TEST=manual - reboot - within a second, type 'temps'; I2C sensors should return error 1 - type 'temps' again; all sensors should return data - power off system - type 'temps' again; I2C sensors and PECI should return error 8 - 'gpioset enable_vs 1' - type 'temps' again; I2C sensors should return valid data; PECI should still return error 8. Change-Id: I17c353b3c483bc320769307c7715008ec729089b Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/35287 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* link: Temp sensor read can return an error codeRandall Spangler2012-10-112-8/+15
| | | | | | | | | | | | | | | | | | | | | This will be used in a follow-up CL to return specific error codes (not powered, not calibrated, etc.) BUG=chrome-os-partner:15174 BRANCH=link TEST=manual Power on system. 'temps' should return all good temps. Power off system (into S5) Only ECInternal temp should work; others should return Error 1 'gpioset enable_vs 1' and wait a second Now all the I2C temps should display good data, but PECI will still be error 1. Change-Id: I925434e71653ad53ad76bad992a7a8fdeadb088c Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/35286 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* stm32: fix race condition enabling keyboard interruptVincent Palatin2012-10-101-39/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, if a key was pressed after the last polling but the interrupts were fully enabled, we were missing the edge. So dropping the key press event and seeing only the key release. Now we check if keys are down before waiting for the next interrupt, if any, we re-start polling immediatly. The row state reading code is unchanged, just moved to a function in order to re-use it. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> (Note: This patch was originally submitted in the firmware-snow-2695.B branch, but needed some re-factoring to merge cleanly into ToT) BRANCH=snow BUG=chrome-os-partner:7484 chrome-os-partner:12179 TEST=type on the keyboard and do not see any missing key presses. On instrumented board, record the the matrix scans with a logic analyzer and stare at the waveforms. Change-Id: I98dc4c3af9611a276b960887384a6304b91d8b30 Reviewed-on: https://gerrit.chromium.org/gerrit/35168 Commit-Ready: David Hendricks <dhendrix@chromium.org> Reviewed-by: David Hendricks <dhendrix@chromium.org> Tested-by: David Hendricks <dhendrix@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* snow: i2c: Reset i2c if we get a timeout in slave modeDoug Anderson2012-10-101-1/+9
| | | | | | | | | | | | | | | | | | | | | This is important to do because if we don't reset we could leave the i2c bus in a wedged state (it's possible that whoever was mastering us could have reset halfway through a transaction). BUG=chrome-os-partner:14430 BRANCH=snow TEST=From vt2 type: "echo bug > /proc/breakme" several times and see good reboots. Check scope trace and see that reset of i2c bus helped (SDA low for 100ms and then fixed). TEST=Run hacky "repro" script from bug see that i2c doesn't get wedged. Change-Id: I57010dcc5f4baa63278b6a025d44f10f00eb9e9d Signed-off-by: Doug Anderson <dianders@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/35115 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Charlie Mooney <charliemooney@chromium.org>
* stm32: Implement keyboard debouncingSimon Glass2012-10-051-54/+182
| | | | | | | | | | | | | | | | | | | | | | | | | | | This brings Randall's key debounce logic into STM32. We need to rationalize the code, but for this morning... This should fix problems with double keypresses and missing keypresses. BUG=chrome-os-partner:12179 BRANCH=snow TEST=manual - type quickly; should work - run your finger really quickly over the keyboard; should be able to see keys which don't show up because you didn't press them long enough - run your finger quickly from 1 to 0; numbers should show up in order (some may be missing if you sweep too fast. there is a point where if two keys are hit within 1.7ms of each other they can be swapped, but any slower than that and they should never be out of order) - mash your face into the keyboard to cause ghosting; should see only a few keys pressed Change-Id: I6b164a17de1b4dd698f9b45a3852fd3b6c084e0a Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/34765 Commit-Ready: Randall Spangler <rspangler@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Tested-by: Randall Spangler <rspangler@chromium.org>
* stm32: Implement keyscan configuration commandSimon Glass2012-10-051-0/+88
| | | | | | | | | | | | | | | | | | | | | Implement a command to allow getting and setting the keyboard configuration. BUG=chrome-os-partner:12179 TEST=manual - use ectool to read all keyscan paramters - use ectool to update flags to 0, see that keyboard stops working, then set flags to 1 and see that it starts working again. - use ectool to update scanning period to 100ms, see that it drops lots of keys when typing - use ectool to set fifo size to 1, see that the fifo no longer fills up Change-Id: I5afb3b48b1262a1570d7411ffd8b2e6ea3a65f6b BRANCH=snow,link Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/34635 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* stm32: Reduce keyboard scan period from 10ms to 3msSimon Glass2012-10-051-1/+1
| | | | | | | | | | | | | | | | | | | | | Experimentally it is possible to press a key on snow for only 4.8ms. We should aim to scan more frequently to catch those who only just touch the keys, or type very quickly. It takes a little over 2ms to complete a keyboard scan at present. We shold aim to reduce this, but for now, it seems safe to reduce the default scanning frequency to 3ms. BUG=chrome-os-partner:12179 TEST=manual Type on keyboard on snow in browser, and see that we still get results and the EC is stable. Change-Id: I60827c33a58c34dd808504e58bca480bd61f5932 BRANCH=snow Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/34634 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* stm32: Update keyboard_scan to use run-time configurationSimon Glass2012-10-051-41/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | At present the keyboard scan parameters are hard-coded, so changing them requires a new EC image. This can be problematic if we want to adjust the behavior of keyboard scanning since we must send an EC update. Change stm32's keyboard scan to use run-time config. All parameters and behavior should remain the same with this change. The configuration is defined by ec_commands.h since we intend to create a command to allow access to it. It does not seem worth defining a separate structure within keyboard_scan at present, although if we add a new version of the command in the future then we may want to separate these. BUG=chrome-os-partner:12179 BRANCH=snow TEST=manual Boot snow into U-Boot and Linux, try the keyboard, seeing that it seems to work as before. This is a very subjective test. Change-Id: Ie6160f1d73b983867b96f8ccb421853f6ec99524 Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/34633 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* stm32: Drop key scan masksSimon Glass2012-10-051-21/+0
| | | | | | | | | | | | | | | The masks were intended to be used to ignore certain keys in the matrix to help with de-ghosting of keys. Since this is done on the AP anyway, there really isn't any need for them. Punt. BUG=chrome-os-partner:12179 BRANCH=snow TEST=manual Build and boot into kernel, see that keyboard still works. Change-Id: I00d1b761d24ab503c66439b095a8336fff5d5db6 Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/34657
* link: fix race condition enabling keyboard interruptRandall Spangler2012-10-051-5/+13
| | | | | | | | | | | | | | | | | | | | | | | Previously, an edge on a keyboard row could be missed if it occurred after the last scan, but before interrupts are enabled. Now we explicitly check if any keys are down before waiting for an interrupt, and if any are, we simply don't wait to scan. BUG=chrome-os-partner:7484 BRANCH=link TEST=the race condition's really tricky to hit The best we can do for testing is to ensure that we ARE sleeping in the normal case where no keys are held down. For that, don't press any keys, and run 'taskinfo' from the EC console twice about 10 sec apart. Both printouts should have virtually identical times for the KEYSCAN task. Change-Id: I4e0ef18a2d71d0a5d3655742bd49fc15afc4aaed Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/34709 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
* link: Implement keyboard debouncingRandall Spangler2012-10-051-79/+150
| | | | | | | | | | | | | | | | | | | | | | This should fix problems with double keypresses and missing keypresses. BUG=chrome-os-partner:8826 BRANCH=link TEST=manual - type quickly; should work - run your finger really quickly over the keyboard; should be able to see keys which don't show up because you didn't press them long enough - run your finger quickly from 1 to 0; numbers should show up in order (some may be missing if you sweep too fast. there is a point where if two keys are hit within 1.7ms of each other they can be swapped, but any slower than that and they should never be out of order) - mash your face into the keyboard to cause ghosting; should see only a few keys pressed Change-Id: I66e95c56d94cba16454ee2c37498deeb57f1a2c3 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/34697 Reviewed-by: Simon Glass <sjg@chromium.org>
* link: Pass keyboard state array as a parameterRandall Spangler2012-10-041-36/+49
| | | | | | | | | | | | | | | | | This is a precursor to implementing proper keyboard debouncing, and should have no functional effect; it's just refactoring. BUG=chrome-os-partner:8826 BRANCH=link TEST=manual - power+refresh+esc -> recovery mode - boot normally and type -> yaay, you can type Change-Id: I828d2380c164c92330d725002379b6442894f41d Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/34567 Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* Enable FPU support for Link ECBill Richardson2012-10-021-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | With this CL, if CONFIG_FPU is defined (only for Link, ATM), the EC task switcher will enable CONTROL.FPCA and expect all stack contexts to include floating point state as well as normal state (an additional 18 words). To support this, we need to increase the allocated stack space for each task. The stack sizes are already chosen empirically, so I'm just rounding them up a bit. BUG=chrome-os-partner:14766 BRANCH=Link TEST=manual There should be no noticeable change. If you run the EC command "taskinfo" you'll see the increased size each thread's stack, but everything that was working before should continue to work just fine. The additional overhead required to load and store another 18 words on each context switch is not really measurable (I tried). Change-Id: Ibaca7d7a2565285f049fda6906f32761e83207af Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/34391 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Re-enable keyboard scanning at end of debounce intervalRandall Spangler2012-09-281-6/+10
| | | | | | | | | | | | | | | | This fixes a problem where a very short power button press would disable scanning, but not debounce to down so we'd never have a debounced release to re-enable scanning. BUG=chrome-os-partner:14678 BRANCH=link TEST=tap power button very quickly, then see if keyboard still works (may need to repeat that a few times to be sure it always works) Change-Id: I3dd3d3f2d892f309a507463d7ad6accf32df30c4 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/34225 Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
* stm32f: ADC driverVic Yang2012-09-264-2/+244
| | | | | | | | | | | | | | | This adds basic ADC support for multiple channel conversion. BUG=chrome-os-partner:14316 BRANCH=none TEST=1. Boot on snow. 2. Use keyboard signal as input. Check read value changes as input signal changes. Change-Id: I3c15c37446fa9273d098f6d581573c11ced45b5e Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/33883 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* stm32: Export DMA memory size optionVic Yang2012-09-265-31/+74
| | | | | | | | | | | | | | We need different memory size configuration in different application. Let's export the memory size option to DMA function parameters. BUG=chrome-os-partner:14316 TEST=Boot on snow. Check I2C host command works. BRANCH=none Change-Id: I30481ddf86a1526d517961e009898642ecdd649a Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/33981 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* Don't forward keys in case of warm reboot sequence matchSameer Nanda2012-09-241-1/+4
| | | | | | | | | | | | | | | | | | | If the key combination matches the warm reboot sequence (alt-volume_up-r), do not forward these keys to the AP. If the keys do get forwarded, the AP's key handler can race with the EC's GAIAPOWER task and unpredicatable things may happen. BUG=chrome-os-partner:14496 TEST=hit alt-volume_up-r keys together. This should cause the system to reboot. If in dev mode, check the contents of /dev/pstore/console_ramoops file -- the contents should be from the previous boot. BRANCH=snow Change-Id: Ida08bf10c593c75186f472721992a52015e4bf24 Signed-off-by: Sameer Nanda <snanda@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/33916 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: David Hendricks <dhendrix@chromium.org>
* Prevent I2C interrupts from consuming pending task eventsBill Richardson2012-09-211-5/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This manifested as the lightbar task missing transitions between CPU states. The underlying cause was that when a task talks over the I2C bus, the I2C communication was using the task scheduler to wait for an interrupt to signal completed I2C traffic without blocking the other threads, but while doing so it was not preserving pending events. This CL seems to fix it. BUG=chrome-os-partner:12431 BRANCH=all TEST=manual The original bug is tricky to reproduce without adding some delay to the I2C task code, but you can do it. Boot the CPU, then from the EC console repeatedly alternate these two commands: lightbar seq s0 lightbar seq s3 You should see the lightbar pattern turn off and on, but occasionally you'll type the command and the EC won't change the pattern. With this change applied, it should *always* work. Change-Id: Ie6819a4a36162a8760455c71c41ab8a468656af1 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/33805 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Add Spring board configurationVincent Palatin2012-09-201-1/+1
| | | | | | | | | | | | | | | | | | Assign GPIOs and board specific peripheral/pin mux configurations. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BUG=chrome-os-partner:14313 TEST=make BOARD=spring run spring binary on snow for basic sanity checking. BRANCH=none Change-Id: I6384024a0f27af67744e98a55b66d08f587bffa0 Reviewed-on: https://gerrit.chromium.org/gerrit/33631 Reviewed-by: David Hendricks <dhendrix@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Vic Yang <victoryang@chromium.org> Commit-Ready: Vincent Palatin <vpalatin@chromium.org>