Commit Graph

622 Commits

Author SHA1 Message Date
Randall Spangler
c2b94fd184 Move files in preparation for merging keyboard_scan modules
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>
2013-03-27 11:35:20 -07:00
Randall Spangler
c5127abeee stm32: unimplemented hibernate hard-reboots instead of hanging
This more closely emulates what LM4 does if it hibernates and then
immediately wakes.  Keeps the system from becoming silently
unresponsive if a hibernate is triggered on STM32.

BUG=chrome-os-partner:18371
BRANCH=none
TEST=from ec console, 'hibernate' reboots instead of hanging

Change-Id: I031f79239725d69ba054323e4fbf8f59133f2093
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46286
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-03-25 11:45:19 -07:00
Randall Spangler
10ac310605 Move keyboard dimension and key constants to keyboard_config.h
These were previously duplicated between multiple keyboard_scan.c and
board.c files, and there were a bunch of different constants #defined
to be 13.

BUG=chrome-os-partner:18360
BRANCH=none
TEST=compile all boards; test keyboard on spring and link

Change-Id: I91bf9d56d2a56ff25ff307ff10883ca87b6937e5
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46165
2013-03-22 11:24:29 -07:00
Randall Spangler
743c05f01f Add keyboard_raw interface
This is the low-level platform-dependent interface to drive keyboard
columns, read rows, and handle keyboard interrupts.

Both lm4 and stm32 had something like this before, but the interfaces
weren't fully explicit or compatible.

BUG=chrome-os-partner:18360
BRANCH=none
TEST=manual

- Build all platforms.
- Boot system and test typing on keyboard.
- Hold power+refresh+esc to test boot key detection; should go to recovery.

Change-Id: Ie3bcc1d066a4da5204f0e236daeb52c4064a6213
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46156
2013-03-22 11:24:28 -07:00
Randall Spangler
447b05b828 Move asserting host keyboard interrupt signal to keyboard_scan
The implementation is identical on all stm32 hardware, so remove all
the duplicate copies from board.c files.  mccrosskey doesn't have
GPIO_EC_INT so stub it out like we do on bds.

No functional change, just moving code.

BUG=none
BRANCH=none
TEST=build mccrosskey,daisy,snow,spring

Change-Id: I7d4378650d7b4c640c15180c41459a41620f5bd3
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45920
2013-03-20 17:42:04 -07:00
Randall Spangler
78b0e9863d Use chipset_reset() interface instead of system_warm_reboot()
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
2013-03-20 15:23:29 -07:00
Randall Spangler
34e17d4c05 Move I2C arbitration to its own file
It's only board-specific in that we've only needed it on snow so far.
But by that logic, x86_power would be board specific because we've
only needed it on link.

No functionality change, just moving code between files and renaming
the interface to indicate it's not board-specific.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build daisy,snow,spring

Change-Id: I35debdaa71829d55a2fbc5d3c62b2aaf6e467633
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45879
2013-03-20 15:23:29 -07:00
Vic Yang
19920f1f74 spring: reset TSU6721 when Toad's ID changes
When Toad's ID changes, VBUS goes low for 10ms. This, however, is not
picked up by TSU6721 and thus we need to monitor VBUS and reset TSU6721
when necessary. By resetting TSU6721, we can force it to update device
type.

BUG=chrome-os-partner:18292
TEST=manual
BRANCH=spring

Change-Id: Ib96bbb0f101c8c5f5371591603af2dee27f01cc8
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45727
2013-03-20 01:02:09 -07:00
Randall Spangler
24f0d888dd Use common declaration of keyboard_scan_interrupt()
Code cleanup: declare keyboard_scan_interrupt() once, not per board;
the implementation is common anyway.

No functional changes; just renaming.

BUG=none
BRANCH=none
TEST=build daisy,snow,spring,mccrosskey

Change-Id: I1e33cbe2c868bc47b641d36d26f07c3b5a7ba3c7
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45874
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-03-19 14:59:32 -07:00
ChromeOS Developer
6c285c0994 Move external power detect for link to its own file
Now that it doesn't need to leverage SWITCH_TASK to send the AC_CHANGE
notification, pure GPIO-based external power detection can move from
switch.c to its own file.

BUG=chrome-os-partner:18256
BRANCH=none
TEST=add AC power, UI shows charging indicator; remove AC, indicator goes away

Change-Id: Id495f34185b7d971c241ac6d0a8311a6bf544507
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45789
2013-03-19 10:31:12 -07:00
David Hendricks
94f4bb38a0 Initial McCroskey support
This adds a board target for McCroskey. It is loosely based on
Snow.

The clock will be set up differently and the keyboard GPIOs are
not the same, so some stm32 code needed to be updated.

BUG=none
BRANCH=none
TEST=tested on McCroskey (we get to the serial console)
Signed-off-by: David Hendricks <dhendrix@chromium.org>

Change-Id: I5e11a3257fed1797f4cc4dcccf3530585b78da82
Reviewed-on: https://gerrit.chromium.org/gerrit/43414
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
2013-03-13 16:05:39 -07:00
David Hendricks
2f229ea226 stm32: make read_raw_input_state() more portable
This re-factors read_raw_input_state() to use GPIO port and mask
values from the board's gpio_list array. This eliminates the reliance
on hard-coded bit mask values and ports, thus making the code
adaptable for future designs.

As a slight optimization, the GPIO input data register is re-read
only if the port changes from the previous iteration. Thus, it's best
if the GPIOs are listed such that changes to the port address are
minimized.

BUG=none
BRANCH=none
TEST=Tested on Snow by running finger across keys.

Change-Id: I4a79363f060f37690bfebfd6763f7bfe6cb7991a
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44993
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-13 14:14:02 -07:00
David Hendricks
e1c1756808 stm32: remove unused kbc_gpio struct
This removes a struct which is unused.

BUG=none
BRANCH=none
TEST=locally compiled

Change-Id: I664714d371aac9829c984b5a5ed591745ef78eb1
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44983
2013-03-13 13:04:15 -07:00
David Hendricks
7c9f26b582 stm32: add some documentation to keyboard_scan.c
This adds some documentation explaining the method to the madness
involving the board's gpio_list array.

BUG=none
BRANCH=none
TEST=it's just comments.

Change-Id: I30731555bbc358b0bebd75f906cbbb3116206146
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44994
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-13 12:41:12 -07:00
David Hendricks
cdfbe88e92 stm32: list keyboard output ports on a per-board basis
This CL moves the keyboard port listing to board.h for each mainboard
to reduce board-specific clutter in keyboard_scan.c. Since the info
is now exposed outside of keyboard_scan.c, a more descriptive name was
chosen.

Note: GPIO_D does not need to be included in this list for any current
platform.

BUG=none
BRANCH=none
Test=tested on Snow by pressing all number and letter keys

Signed-off-by: David Hendricks <dhendrix@chromium.org>

Change-Id: I1ce924a41cafae557467997ecba9c5abeed86211
Reviewed-on: https://gerrit.chromium.org/gerrit/45284
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
2013-03-13 12:12:01 -07:00
Vic Yang
2823e7e132 stm32f: Add support for ADC watchdog
This makes it possible to have ADC module monitor an input voltage and
trigger interrupt when it goes out of accepted range.

BUG=chrome-os-partner:18171
TEST=Manual
BRANCH=spring

Change-Id: Ia0c981fadd9bcaa40afe30ca2624c2f3644b95fe
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45277
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-13 12:11:59 -07:00
Todd Broch
eefc0ac8c5 spring: stm32: Generate battery key when charging status changes.
In order to update charger status we have added a virtual keystroke to
signal change to the kernel via the MKBP interface.

CL creates the virtual key press and calls it from within the
USB charging code.

Signed-off-by: Todd Broch <tbroch@chromium.org>

BUG=chrome-os-partner:17927
BRANCH=spring
TEST=manual

1. Compile for daisy,snow,spring.
2. Test on spring.

Change-Id: I0afa0fc82c96fa3fd8119523a113b5028c8f64a3
Reviewed-on: https://gerrit.chromium.org/gerrit/45126
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
2013-03-13 11:14:55 -07:00
David Hendricks
f5f30a22c6 stm32: Move KB_INPUTS to board.h
This moves KB_INPUTS from keyboard_scan.c to board.h where KB_OUTPUTS
is #defined. Although we use the same 13x8 keyboard matrix on all
platforms, KB_OUTPUTS is defined on a per-board basis due to its usage
in keyboard_test.

BUG=none
BRANCH=none
TEST=locally compiled

Change-Id: I0d66705d2959c7824b96cc8aae55368eca39a21a
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44970
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-11 22:08:56 -07:00
David Hendricks
0631409955 stm32: finish cleaning up row/column/input/output naming
This is a purely cosmetic change that removes any remaining
references of rows/columns in favor of inputs/outputs since the
former is inconsistent across platforms.

Higher-level code (such as MKBP) may still refer to logical rows
and columns, but low-level GPIO handling code will refer to GPIOs
by their input/output function.

BUG=none
BRANCH=none
TEST=Tested on Snow (ran finger across all numbers and letters)

Change-Id: Idb8b76e8d013568505d826c3a54a1ed8ce143d12
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44982
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-11 22:08:55 -07:00
David Hendricks
d4ca1d9c00 stm32: Dynamically generate keyboard IRQ mask
This replaces the hard-coded IRQ mask which has so far worked on
Chrome platforms with a variable that gets set in the initialization
part of keyboard_scan_task(). A simple loop is used to OR the GPIO
mask for each keyboard input provided by the board's gpio_list array.

This will make it easier to adapt the code to future targets with
different pin mappings.

BUG=none
BRANCH=none
TEST=Tested on Snow

Signed-off-by: David Hendricks <dhendrix@chromium.org>
Change-Id: I848ab3c7e8d276dbb807a97c6b26c5b3c05af166
Reviewed-on: https://gerrit.chromium.org/gerrit/44952
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-08 13:27:22 -08:00
David Hendricks
ea000b0fc0 stm32f10x: Initial import
This adds initial support for the other chips in the stm32f10x
series: stm32f101, stm32f102x, stm32f103x, stm32f105x, stm32f107x.

The main difference is in the register definitions. Clock, flash,
GPIO, and JTAG modules are similar enough that for now we can symlink
the existing source for stm32f100.

BRANCH=none
BUG=none
TEST=Tested on McCroskey (follow-up CL)
Signed-off-by: David Hendricks <dhendrix@chromium.org>

Change-Id: I67363d02578e21be51d842b6bd8b5e4848720993
Reviewed-on: https://gerrit.chromium.org/gerrit/43412
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
2013-03-08 12:01:46 -08:00
Randall Spangler
70cdf52ea1 Wait to power on system until battery state is known
This prevents the system from waking from hibernate at very low
battery, then powering on the AP to do software sync only to find that
the charge state machine shuts down the AP before software sync can
complete.

BUG=chrome-os-partner:17124
BRANCH=link
TEST=manual

On both AC and mostly-charged battery:
- With lid open, reboot EC -> on
- With lid open, reboot EC with power held down -> on
- With lid closed, reboot EC -> system boots and does EC software sync
- With system on -> battfake 2 shuts system down
  (and at that point, opening lid or pressing power does nothing)

With a hacked charge_state.c so fake_state_of_charge starts at 2:
- With lid open or closed, reboot EC -> off
- Opening lid does not turn on system
- Pressing power button does not turn on system
- Plug power back in and press power -> system turns on

Change-Id: Ie1f2933060fac87b1afe68718f374d51cb8994de
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44313
2013-03-05 10:26:20 -08:00
Vic Yang
f84a5fa8b1 stm32: Lengthen ADC sample time
Current sample time 1.75us seems too short and some nets with weaker
driver don't convert correctly. Let's lengthen it to 8.75us.

BUG=chrome-os-partner:14319
TEST=See correct voltage level.
BRANCH=none

Change-Id: Ib65a07474787504e5f72522167bafad8bb5730bc
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/42845
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-02-06 23:17:15 -08:00
Vincent Palatin
231319c08c stm32: implement SMBUS-style read block/string
Add support in the I2C driver for SMBUS-style read block operations.
As defined by the SMBUS standard, a "read block" returns at most 32
bytes of data plus the size of response as the first byte.

It's used to read smart battery strings such as manufacturer or model.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=none
BUG=chrome-os-partner:14314
TEST=On Spring, read the battery manufacturer and model from a kernel
patched for the smart-battery passthrough.

Change-Id: I069ce7f64414817e94516e913643d3847a29d176
Reviewed-on: https://gerrit.chromium.org/gerrit/42647
Reviewed-by: Vic Yang <victoryang@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2013-02-05 20:16:22 -08:00
Dave Parker
3182778dbb Add 'unprotect' flag for flashing link ec.
BRANCH=link
BUG=chromium-os:37967
TEST=Remove write protect, reflash without 'unprotect', flag
     and verify the write protect flag is stil enabled with
     flashrom -p internal:bus=lpc --wp-status. Power down,
     then reflash with the --unprotect flag. Now verify the
     write protect status flag is disabled.

Change-Id: Ie05b5dc85dd31d29ab43a392fe948a52d547fff3
Signed-off-by: Dave Parker <dparker@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/41477
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-01-17 13:44:24 -08:00
Randall Spangler
7326b7475a Tidy ACPI debug output
The host does a lot of ACPI keyboard backlight writes, which were
scrolling the debug console output.  Change to using CR instead of LF,
so it's not so distracting.

(No code changes other than debug output)

BUG=none
BRANCH=none

TEST=Move laptop through different ambient light settings and look at
console output as keyboard backlight ramps up and down.  The 'ACPI
kblight' messages shouldn't cause piles of scrolling.

Change-Id: Iafde57ffe6090830fa54d4920c48b198c36d8d85
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/39914
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-12-18 18:18:19 -08:00
Randall Spangler
eb6e08570a link: Workaround for errata 3.2
Reads of HIBRTCC and HIBRTCCSS are not properly synchronized and may
return incorrect data.  We were re-checking HIBRTC, but not HIBRTCSS.

BUG=chrome-os-partner:16864
BRANCH=link
TEST=from ec console, do 'rtc' command repeatedly;
printed values should be strictly increasing.

Change-Id: I3e59dc840316ad36bb4851f03b66a3ae3df5cccd
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/39795
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-12-17 14:24:50 -08:00
Vic Yang
243e935ad4 stm32: Add option to select timer for hardware clock
Hardware clock uses two timers, currently TIM3 and TIM4. This CL adds an
option to select between TIM2, TIM3, and TIM4, so that we can use any
one the three timer as a PWM source.

BUG=chrome-os-partner:14319, chrome-os-partner:7463
TEST=Build and run on snow/spring. Build success on daisy.
BRANCH=none

Change-Id: I1a00b3d491ee3e131708b573f6ea70e6b56c96dd
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/39584
2012-12-12 19:52:13 -08:00
Vic Yang
73a0bb2ecf lm4: Postfix chip name when debug mode is enabled
This adds a '-debug' postfix to chip name when debug mode is enabled,
allowing us to probe debug mode from host.

BUG=chrome-os-partner:16700
TEST='mosys -k ec info' and see chip name postfixed with '-tm'
     Test same thing on DVT and chip name is not postfixed.
BRANCH=link

Change-Id: Iade26f2009dd3bdb8ddbe92da0da8da5404c6e99
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/39455
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-12-10 23:06:39 -08:00
Randall Spangler
ab727c4941 Add more paranoia for flash write protect
If the entire flash is protected (as it normally is after software
sync), fail all flash write/erase operations.

Add a shadow copy of the all_now flag.

BUG=chrome-os-partner:16727
BRANCH=link
TEST=manual

Verify that flash operations work properly before all_now.  Then enable HW WP
and
   flashwp enable
   flashwp now
and try
   flasherase 0x38000 0x1000
   flashwrite 0x38000 0x100
Those commands should fail with error 7

From the host side
   ectool flasherase 0x38000 0x1000
   echo 'Khaaaaaaaaaaan' > /tmp/b16727
   ectool flashwrite 0x38000 /tmp/b16727
should also fail.

Change-Id: I99a4d2bb86080bd12c900582a8fbdfc79c99916c
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/39517
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-12-10 15:42:21 -08:00
Randall Spangler
7a2e3372ee link: Increase cold reset hibernate time to 1 second
This gives VDDC more time to bleed out before the system reboots.

This will require FAFT changes to compensate for the longer cold reset time.

BUG=chrome-os-partner:16600
BRANCH=link
TEST=from ec console, 'reboot cold' should take a second.

Change-Id: I7e0e901958593262868151642560296f0c5496a7
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/39515
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-12-10 15:42:10 -08:00
Randall Spangler
c26a242e94 Increase cold reset hibernate time to 200ms
The hardware fix for issue 16600 adds RC delays to ENABLE_5VALW, so
that +5VALW stays on during a warm reset of the EC.  In the worst
case, +5VALW will drop around 150ms, which could then move the +3VALW
glitch right into the time frame where the EC is booting following
hibernate.

Increase the cold reset hibernate time from 150ms to 200ms.  This
ensures that +5VALW has dropped before the EC comes out of hibernate.

BUG=chrome-os-partner:16600
BRANCH=link
TEST=manual

From the EC console, 'reboot cold' a bunch of times.  The system
shouldn't hang.  (Alternately, you can 'ectool reboot_ec cold' a bunch
of times)

Change-Id: I4bebdb552b8e917c6345badd6efb68b10d7d1f86
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/39340
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-12-06 17:58:32 -08:00
Randall Spangler
52440ef893 link: Disable interrupts while reading/writing bits via onewire
When reading, the line must be sampled in a narrow timing window after
the output pulse.  Interrupts or context switches during this time
corrupt the data.

Similarly, when writing, the difference between a 0-bit and a 1-bit is
the length of the output pulse.  So a context switch or interrupt
there can turn a 1-bit into a 0-bit.

BUG=chrome-os-partner:15507
BRANCH=link
TEST=manual

0. plug in AC power
1. hold down shift key for the duration of this test
2. powerled yellow
3. powerled red
4. repeat steps 2-3 several times
5. release shift key

Power adapter LED should toggle color each time.  (It may also toggle
to the normally expected color during this experiment, if the charging
task updates it.)  Power adapter LED should NOT turn off during this test.

Change-Id: Ief11e6e9a5b07aa3a25c60c50e4e7744a4705713
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/38925
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-11-29 12:02:51 -08:00
Randall Spangler
d619cdd58f Handle arbitration lost on I2C ports
This seems to happen when the I2C signals come up so that the EC sees
a start condition from the remote end.  In this case, the EC refuses
to talk on the I2C port until the EC's I2C state machine is reset.

Also, don't fail on bus-busy, since that's true during a multi-part
transaction such as an I2C string read.

BUG=chrome-os-partner:16262
BRANCH=link

TEST=boot system; 'battery' and 'temps' should give good info
Then run snanda's suspend_stress_test for a while and repeat.

Or a better test is to open 2 crosh shells, sudo bash in each, and
  1) while true; do ectool temps all; sleep 0.5; done
  2) suspend_stress_test

Then watch the EC console for "I2C5 bad status" errors.  These happen
rarely, only on some systems.  With this fix, they'll be reported when
they occur, but should not cause errors to be reported by 'ectool
temps all', since the I2C module will clear the arbitration-lost
status before retrying.

Change-Id: Idfaf9cd7e8ef2abcc0130332890329dd5d2ca052
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/38686
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
2012-11-28 09:50:23 -08:00
Randall Spangler
e2f8466997 Handle bus errors on thermal I2C bus
1) Properly report I2C errors on TMP006 as error, not device-not-powered.

2) Treat clock timeout and bus-busy I2C status as error (previously ignored).

3) If clock timeout or bus-busy, reset I2C master for that bus to clear the
error.

These should help with systems where the thermal I2C bus gets into a
weird state on suspend/resume.

BUG=chrome-os-partner:16262
BRANCH=link

TEST=boot system; 'battery' and 'temps' should give good info
Then run snanda's suspend_stress_test for a while and repeat.

Change-Id: I534be8236a4d6de82575fe6d33a68502ce0a3a95
Original-Change-Id: Iec5d6bbd357d2e5eb3dc3d361c829f353e996ab6
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/38444
Reviewed-on: https://gerrit.chromium.org/gerrit/38659
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
2012-11-26 14:49:49 -08:00
Vadim Bendebury
4efe1ed157 Fix the ec flash programming script to properly handle errors
When a nonexisting file is specified as the EC image, the ec flash
programming script reports the error, but continues running and
returns zero status (success) after completion.

With this change the exit status on some errors gets communicated to
the caller.

The openocd script is edited to drop the unused parameter of the
flash_lm4() function and the flash_ec script is edited not to require
EC images to be executable.

BRANCH=none
BUG=chrome-os-partner:15610
TEST=manual
   . run flash_ec with nonexisting or nonreadable file as a parameter,
     observe it to report proper return status. Run it with a proper
     image file name and observe it succeed.
   . run the command again, while the device is being programmed enter
     'ctl-c', observe programming stepped but the 'Restoring servo
     settings..." message still showing up.

Change-Id: Iac0b233fe579b0d5a84cf5a9acf85ed8bf10422e
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/37363
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-11-07 09:48:29 -08:00
Louis Yung-Chieh Lo
25bbb6b5de More supports for A20 enable/disable
Add i8042 output port commands (0xf0-0xff), I8042_ENABLE_A20 and
I8042_DISABLE_A20.

BUG=chrome-os-partner:13119,
BRANCH=None
TEST=Tested on W7 installer. No KB error shown on EC console.

Change-Id: I9ad1fd7baa10683ef18ccf13faf09dc0cefcca0a
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/34994
Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
2012-11-04 20:27:57 -08:00
Randall Spangler
e9e02762dd Move reset/overheat/shutdown funcs to chipset interface
They're not x86-specific, so move to the chipset interface.

BUG=chrome-os-partner:15579
BRANCH=none
TEST=x86reset warm, then x86reset cold.  Should reboot OS in each case.

Change-Id: Ib571ab916bab16179198a0d054320e59afbae124
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36785
2012-11-01 12:45:28 -07:00
Randall Spangler
d83f42bdc8 Switch temp sensor polling to use hooks instead of task
This reduces memory / code size, and gets rid of ifdefs in temp_sensor.c.

BUG=chrome-os-partner:15714
BRANCH=none
TEST=boot system and run 'ectool temps all' every few seconds
    - ectool temps all
The numbers should update over time.

Change-Id: Idaac7e6e4cbc1d6689f5d3b607c623a5cc536a4f
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36940
2012-11-01 12:45:22 -07:00
Randall Spangler
9a1548984d link: Cold reboot should ignore WAKE# pin
This fixes the EC not being able to do a cold reset while the power
button is held down, because the power button asserts WAKE#.

BUG=chrome-os-partner:15705
BRANCH=link
TEST=manual

- scope HIB#
- hold down power button
- from console, 'reboot cold'

HIB# should stay asserted for 150ms.  Before this fix, it asserted only briefly.

Change-Id: I07c6bb5ee3f846544c75e7e0d4584f8434a9cd56
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/37090
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Puneet Kumar <puneetster@chromium.org>
2012-10-31 18:06:10 -07:00
Simon Glass
f3c88fa1ab stm32: Implement keyscan test infrastructure
Support the keyscan test functionality on stm32.

Note: This is enabled by default so that it continues to build. But it
is unlikely that we will want this in a shipping image. I suggest we add
the facility for a dev build.

Secondly, the stack has to be larger due to a printf (which admittedly I
could just remove). Should we make the stack size conditional on the
CONFIG? Seems a bit ugly, on the other hand we don't want to waste IRAM.

BUG=chrome-os-partner:12179
BRANCH=none
TEST=manual for now:
On snow:
./ectool keyscan 20000 key_sequence.txt

See that the test passes.

Change-Id: Ic441ca0bde1be9589a924374605e2f146d16f423
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35118
2012-10-31 17:21:00 -07:00
Randall Spangler
eee95c9448 Switch PWM to use HOOK_SECOND instead of its own task
BUG=chrome-os-partner:15714
BRANCH=none

TEST=taskinfo no longer shows PWM task, and 'ectool pwmgetfanrpm'
updates as fan speed changes.

Change-Id: Ia23f52527c40c8117238ddc2ee4c023f59eba05a
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36939
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-10-30 15:33:25 -07:00
Randall Spangler
8b3a242ff0 Watchdog is reloaded by HOOK_TICK, not its own task
This reduces memory footprint.

BUG=chrome-os-partner:15714
BRANCH=none
TEST=system still boots; 'waitms 1500' prints watchdog error dump

Change-Id: Ieb0248a34655514b03d919cc36c2b369691da716
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36937
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-10-30 15:33:24 -07:00
Randall Spangler
a21ea56e76 Rename power_button module to switch
Since it handles not just power button, but also lid switch, AC
detect, and other switches.

No functional changes; just renaming.

BUG=chrome-os-partner:15579
BRANCH=none
TEST=boot system, power on/off with power button

Change-Id: I51628a52293f7207715f5f6bf368a08fe6c3dbce
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36821
2012-10-30 14:50:03 -07:00
Randall Spangler
80467aff91 Clean up clock module
No functional changes; just code cleanup.  On LM4 this also #ifdef's
out the 'sleep' and 'pll' commands since they're big and we don't use
them.

BUG=chrome-os-partner:15579
BRANCH=none
TEST=boot system

Change-Id: I1b72d07d6cca2c783d7ac4c880119df3e88e356e
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36799
2012-10-30 12:42:47 -07:00
Randall Spangler
ef89439cc0 Clean up GPIO module.
No functional changes, just code cleanup.

BUG=chrome-os-partner:15579
BRANCH=none
TEST=gpioget returns reasonable values

Change-Id: I4301ccc68ade775f78f4ccd84710d2cd4bc25252
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36800
2012-10-30 12:42:46 -07:00
Randall Spangler
e82b68bcb9 Clean up jtag module
No functional changes

BUG=chrome-os-partner:15579
BRANCH=none
TEST=boot system; use gdb to connect to EC

Change-Id: I2817d04e4de102e4201506cfe51cdf0bd939fcdb
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36802
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-10-30 12:42:46 -07:00
Randall Spangler
f76cb374f8 Clean up LPC module
Tidied comments, and removed handling of ACPI events on host command
port (not needed since EVT hardware is now EOL'd).

BUG=chrome-os-partner:15579
BRANCH=none
TEST='ectool hello' succeeds

Change-Id: I063382b9981f713ba23f7714b4ccb7faa957b411
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36804
2012-10-30 12:42:45 -07:00
Randall Spangler
d5ade1b2ed Clean up UART module
And change some direct uart_printf()/uart_puts() output to console
output methods instead.  Disable unused comxtest debug command.  No
other functional changes.

BUG=chrome-os-partner:15579
BRANCH=none
TEST=boot system; should still see debug output with reset flags

Change-Id: I57fe6bb781a1ba7884afa6d090b74a92f45a53cc
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36835
2012-10-30 12:42:43 -07:00
Randall Spangler
bda48fc5db Switch LPC to use HOOK_TICK instead of task
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>
2012-10-30 12:42:41 -07:00