Commit Graph

484 Commits

Author SHA1 Message Date
Randall Spangler
5cd6f3cf7f Remove unused uart.h includes
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=none
TEST=none

Change-Id: I8f9c6e67427a5c7f2c42754b421db44504f9c10d
2012-04-25 15:56:10 -07:00
Randall Spangler
1aa57e140e Watchdog fixes
1) When frequency changes, reload the watchdog timer right away, or it
may expire before the next reload.  (Only matters when re-enabling the
PLL.)

2) Split out the timer/task debug output used by the watchdog into
their own routines, instead of assuming it's safe to call the command
handlers.  Also make the flushes in those print routines safe to call
from interrupt level.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=none
TEST=waitms 1500; should print task dump again

Change-Id: I07e0ed24a526ae499566dab0bbeb0f5755cd5be6
2012-04-25 14:49:49 -07:00
Randall Spangler
212784b5fa Fix watchdog handler stack alignment
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:9306
TEST=waitms 1600; see that timer info isn't all upscrewed

Change-Id: I7945f5114bbe0e9525cac76ce7376d4c32c4e654
2012-04-25 14:06:42 -07:00
David Hendricks
83082746a9 Separate message protocol command types and reserve slots accordingly
This organizes the commands in the messaging protocol so that we have
a more clear distinction between commands which are intended to to
control or get status of the EC itself and those which are intended
to query information about peripherals, such as the obtaining the
keyboard state.

Note: This will require the mkbp code to be updated.

BUG=none
TEST=compile tested for now

Change-Id: I2d5c58fc794563d402da24e19fee146df817472a
Signed-off-by: David Hendricks <dhendrix@chromium.org>
2012-04-25 11:31:42 -07:00
Gerrit
e21e5bd46a Merge "Only chain from interrupt to svc_handler if an event was set." 2012-04-25 10:27:25 -07:00
Bill Richardson
b4ac7cf558 Clean up lightbar msg command parsing, add some help.
BUG=none
TEST=none

Change-Id: I5767bd45bd66793606014b3ce8020d0eb2e17090
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
2012-04-25 09:30:20 -07:00
Randall Spangler
334f0f5475 Only chain from interrupt to svc_handler if an event was set.
(Or, if profiling is enabled.)

Also, track the number of task switches if profiling is enabled.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:9274
TEST=taskinfo

Also test by commenting out CONFIG_TASK_PROFILING in board.h; code
should still compile and run.

Change-Id: Ib3dbce74b6ccfba2bbe18c7309136412c30f364e
2012-04-25 09:24:05 -07:00
Rong Chang
5774ebbd78 Handle overtemp condition in discharging state
This change adds battery operating temperature check. Host and EC
will be turned off when overtemp. EC can be waked up by predefined
external signals like key press or AC_PRESENT gpio.

For safty reason, this change does not check battery temperature
after EC deep sleep.

Signed-off-by: Rong Chang <rongchang@chromium.org>
BUG=chrome-os-partner:8451,9108
TEST=none
  Mock battery_temperature() fucntion to test.

Change-Id: I3203515b3df86192f690f9b98901020209ce49b3
2012-04-25 15:54:26 +08:00
Randall Spangler
470916fb0f Use console output instead of uart output for console commands
This completes console output cleanup.  The remaining calls to
uart_puts() and uart_printf() actually need to be that way.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7464
TEST=manual

Change-Id: Ib1d6d370d30429017b3d11994894fece75fab6ea
2012-04-24 18:34:46 -07:00
Randall Spangler
135f14bf49 Refactor async console output
This adds a 'ch' command which prints/sets which channels are active

This handles all the async output; the remaining debug commands will
be refactored to use ccprintf() / ccputs() in a followup CL.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7464
TEST=manual

ch --> all channels active
ch 0x100 -> just port80 active
powerbtn -> system boots; only port 80 codes shown on console

Change-Id: I9efc43acec919b62b78c2c82c61946d32380adfe
2012-04-24 17:46:54 -07:00
Randall Spangler
0d19c59aba Implement task profiling
Also tracks the distribution of IRQs, so we can see what's triggering
interrupts.

Task profiling is optional, enabled via CONFIG_TASK_PROFILING.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7464
TEST=taskinfo

Change-Id: I266f2b49bff9648cda446210d5a302b460fec244
2012-04-24 12:54:29 -07:00
Gerrit
dbd896103e Merge "ASSERT() cleanup. Remove blocking assert macro to avoid attack." 2012-04-24 10:44:39 -07:00
Gerrit
7e3caf483b Merge "Disable PLL at end of init" 2012-04-24 10:44:39 -07:00
Gerrit
3a4cd3f8f3 Merge "stm32l: clear and then set GPIO mode and pull-up/down settings" 2012-04-24 10:44:39 -07:00
Randall Spangler
7ecb8358b9 Disable PLL at end of init
This saves power.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:8798
TEST=manual

Get a proto1 system modified with INA current sensor

1) From chroot:
  dut-control i2c_mux_en:on i2c_mux:rem
  dut-control pp3300_alw_mv pp3300_alw_ma

2) From EC console:
pll
(this should turn the PLL back on; it'll report clock frequency ~66MHz)

3) From chroot:
  dut-control i2c_mux_en:on i2c_mux:rem
  dut-control pp3300_alw_mv pp3300_alw_ma
Current (ma) should be bigger than in step 1

Change-Id: I806953684c57fd60bf481acb01dddffe2f2ad0ed
2012-04-24 09:59:31 -07:00
Randall Spangler
507532d081 Set BOOTCFG register to test value
Needed for testing preprogramming chips

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:8769
TEST=manual

hibernate 1; should reboot
rw 0x400fe1d0; should print: read word 0x400fe1d0 = 0xfffffdfe

Change-Id: I95b419d7285a0bf5204f95d1f68f64dc212bb39e
2012-04-24 09:18:41 -07:00
Louis Yung-Chieh Lo
92a3a1507e ASSERT() cleanup. Remove blocking assert macro to avoid attack.
For those inputs from host, they are potential points fot cracker to stop
EC running. This patch removes these ASSERT() macro, but keeps those
for checking internal code logic.

BUG=none
TEST=build success

Change-Id: I91bf61f429a2387bb992b9518af60439f5592ea7
2012-04-24 11:34:16 +08:00
David Hendricks
97a49113d9 stm32l: clear and then set GPIO mode and pull-up/down settings
GPIO mode and pull-up/down registers do not all get initialized to
zero on reset. This patch ensures that all bits in the those registers
are set explicitly. An intermediate variable is used so that changes
are made atomically.

Note: output speed registers are also not all initialized to zero, but
we don't handle that in gpio_pre_init yet.

BUG=none
TEST=tested on newer daisy boards (which needed this patch to boot)

Change-Id: Ice2795197135dcee8f8484e4908dbfcf90fec2c9
Signed-off-by: David Hendricks <dhendrix@chromium.org>
2012-04-23 19:18:42 -07:00
Gerrit
e8c86b2a68 Merge "daisy: move i2c port initialization back into configure_board" 2012-04-23 15:22:19 -07:00
David Hendricks
e56ba2e689 Update message protocol length byte to include postamble
This simply changes the constant '4' to MSG_PROTO_BYTES, which
includes the postamble. This helps reduce magic constant values
used in processing a packet.

BUG=chrome-os-partner:8975
TEST=tested on daisy (with kernel mkbp driver change)

Signed-off-by: David Hendricks <dhendrix@chromium.org>
Change-Id: Id4634076ad63f45783354179dfebea4fd450fc1e
2012-04-23 14:05:41 -07:00
David Hendricks
fd5d6cc019 daisy: move i2c port initialization back into configure_board
This patch moves all I2C port initialization into configure_board
to ensure the alternate function gets set properly.

I2C ports should come up in their high-impedance state (Output,
open-drain, output set) and then get set as alternate function.
However, configure_board() runs before gpio_pre_init(), so the
mode register was getting set set back to general purpose output
instead of alt. function.

TODO: Fix gpio_pre_init() so we do not need to explicitly handle port
configuration in configure_board().

BUG=none
TEST=tested on daisy using keyboard

Change-Id: If837acd4f4204e467e7ed276f048b5b70ecbdb25
Signed-off-by: David Hendricks <dhendrix@chromium.org>
2012-04-23 11:59:54 -07:00
David Hendricks
66fa2685f0 fix array indexing bug in message_process_cmd
Source buffer was not being incremented properly, so the destination
buffer containing message payload was always msg[0].

BUG=none
TEST=tested on daisy (now keyboard protocol actually shows keys...)

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

Change-Id: If5a417291c9bff36bbeb2a87153de80300045257
2012-04-23 11:53:57 -07:00
Gerrit
f99b650a23 Merge "stm32l: fix length argument for i2c writes" 2012-04-23 11:32:25 -07:00
David Hendricks
9b942e570c stm32l: fix length argument for i2c writes
Pass the actual msg_len instead of the maximum outbound message size.

BUG=none
TEST=tested on daisy using logic analyzer (notes below)

Beforehand, the output on a logic analyzer looked sane until the last
bits and stop condition, after which the bus appeared to go haywire
and the system would reset. I'm guessing that this is due to the EC
trying to drive SDA line while the host is holding SCL high.

Change-Id: I1afa520d858905a571540341fe02f374dcdf43c1
Signed-off-by: David Hendricks <dhendrix@chromium.org>
2012-04-23 10:56:12 -07:00
Louis Yung-Chieh Lo
913473db71 Keyboard hook up for SYSJUMP and INIT.
During the reboot_ec command, the keyboard state is lost after jump.
We need to restore info including:
  - code set
  - controller_ram[0]:
    - XLATE
    - KB/TP disabled
    - KB/TP IRQ enabled

Remove the un-necessary keyboard_init() function.

BUG=chrome-os-partner:9102
TEST=tested on link.
EC runs on A
% ectool reboot_ec A
keyboard still working
% ectool reboot_ec RO
keybaord still working
% ectool reboot_ec RO
keybaord still working
ESC + power yo reset all system
repeat above steps and the keyboard keeps working.

Change-Id: I0fe21f7876459fc8047ff018fbfaaef5311cc49b
2012-04-23 17:57:41 +08:00
Randall Spangler
9f552ff5aa Implement 64-bit integer printing in uart_printf()
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7490
TEST=timerinfo; numbers should look reasonable

Change-Id: I698be99c87bf311013427ac0ed9e93e5687f40c0
2012-04-20 14:01:11 -07:00
Gerrit
a05deade13 Merge "Remove clock calibration for PIOSC" 2012-04-20 11:09:45 -07:00
Randall Spangler
34df8261f7 Remove clock calibration for PIOSC
Proto1 has A3 silicon which is factory-trimmed.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7693
TEST=boot and look for glitchy EC console.  If it's not glitchy, it worked.

Change-Id: I56cb2458e600e76e458bce0f24832ef4f456ac14
2012-04-20 10:13:17 -07:00
Randall Spangler
b2f34fcfd1 Add openocd macros to write image A or B
These are faster than writing the entire EC, and safer if you're
mucking with things like the clock config.  Of course, if you're
changing verified boot or something else that happens before
vboot_init(), these new commands won't help, and you should keep using
the existing flash_link command.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=none
TEST=manual from openocd
- Compile a new image
- From openocd, flash_link_b
- From ec console, note build compile date in image A: shouldn't have changed
- From ec consle, sysjump b; compile date should be for your new image

Change-Id: Ifd6aabe963948d3c5da5bdeb78c5f962a0f9f857
2012-04-20 10:04:48 -07:00
Randall Spangler
13ad1c007b Implement HOOK_SYSJUMP and use it to preserve LPC host event mask
This also changes shared_mem to use all the remaining RAM, instead of
reserving a fixed-size buffer.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:9161
TEST=manual

hostevent  --> all masks should be 0
hostevent smi 0x12300000
hostevent  --> should confirm SMI mask was set
sysjump b
hostevent  --> should confirm SMI mask is still set
reboot
hostevent  --> should confirm SMI mask is back to 0

Change-Id: Iccb6da6ccc93ee5036a3f478d24b717a462d9150
2012-04-19 18:15:18 -07:00
Randall Spangler
24dafefb3a Move externs from .lds file into a header file
Fewer magic externs = good.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=none
TEST=if it boots, it works

Change-Id: Ifadeb1701400c5492c40d2eaf8f68f2d70189648
2012-04-19 14:29:07 -07:00
Gerrit
ff8926b5e3 Merge "Added HOOK_INIT for driver module inits" 2012-04-19 14:22:36 -07:00
Gerrit
92ded9777c Merge "Tweaks to lightbar code, detect konami sequence" 2012-04-19 14:03:42 -07:00
Randall Spangler
f4e772708b Added HOOK_INIT for driver module inits
This covers modules which need to initialize before task_start(), but
don't particularly care in what order they're initialized.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=none
TEST=if it boots, it works

Change-Id: I69829aac8d1c3c14ee04916a794b84bbf03a09eb
2012-04-19 13:08:58 -07:00
Bill Richardson
49de2279d1 Tweaks to lightbar code, detect konami sequence
More cleanup to come...

BUG=chrome-os-partner:7839
TEST=manual

Lights should blink in various ways, depending on the CPU state.

Also try the konami code on the keyboard.

Change-Id: I90be9aabb611278ed509493fbab4d5faff74e24c
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
2012-04-19 12:44:43 -07:00
Gerrit
d5d2159c6d Merge "Clean up inits" 2012-04-19 11:47:46 -07:00
Randall Spangler
ee3edc0116 Clean up inits
We can clear the reset cause in system pre-init now because of a
previous change which preserves it across a sysjump.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=none
TEST=if it boots, it works

Change-Id: I1d8b99df5a0be0de9545d22ad1a6b7fb3140f813
2012-04-19 11:08:28 -07:00
Gerrit
44f5f0189c Merge "Change ectool command args to work like main()" 2012-04-19 10:20:55 -07:00
Bill Richardson
addcb13711 Change ectool command args to work like main()
The commands in ectool.c look like this:

  int cmd_foo(int argc, char *argv[]) { ... }

but unlike normal C convention, argv[0] is NOT the command. This change
makes argv[0] be the command name, so it's just like main().

BUG=chrome-os-partner:8748
TEST=manual

Run ectool as usual. You should see no difference in behavior.

Change-Id: Ia92784d46a287ab08f279f6255487817b620f200
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
2012-04-19 09:41:18 -07:00
Randall Spangler
70f3fcaf86 Add hooks module so modules can be notified of system-level events.
This will be used for sleep/wake/sysjump/etc.  For now it's just wired
up to clock frequency changing.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=none
TEST=manual: use nopll command, should still work

Change-Id: Iedcea5830bc18eacfd955c29b8f793aba8905dd8
2012-04-19 08:39:41 -07:00
Gerrit
6ecbb86b63 Merge "EC: Use interrupt for ADC" 2012-04-19 07:25:19 -07:00
Gerrit
61ea623120 Merge "Add chipinfo command" 2012-04-19 07:25:18 -07:00
Randall Spangler
55dfbb89cc Add chipinfo command
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=none
TEST=chipinfo

Change-Id: Ie3414bf92c9dd35aaa4e54028bd525e860028c33
2012-04-18 18:55:27 -07:00
Rong Chang
23b8885a02 Trickle charging state and minor bugs fix
Adding trickle charging mode to precharge batteries with
voltage lower than minimal design value. This CL adds
control to charger voltage to track battery input current
change.

To prevent battery from deeply discharging, this CL preserves
3% of the design capacity.

Minor bug fixes include error state check and charger control
logic.

Signed-off-by: Rong Chang <rongchang@chromium.org>

BUG=chrome-os-partner:8660,8661
TEST=manual
  Plug AC power, the power adapter led should be
  'yellow'. On the EC serial console, type 'battery'
  and 'charger' commands.

  Battery input current should staid close to its
  desired current.

  A deeply discharged battery (5.5V) should be revived to
  a healthy state after 30 minutes ~ 4 hours.

Change-Id: Ibaa2396c6b751639d98db32f5919b1e8ec700e40
2012-04-19 01:16:01 +08:00
Louis Yung-Chieh Lo
a77d59b19a Fixe the bug in keyboard state restore.
For legacy issue, the keyboard controller defaults to turn on XLATE
(translate) bit (which means EC generates scan codeset 1 althought
it internally supports codeset 2). In normal case, the BIOS/OS would clear
the XLATE bit to ask EC to generate codeset 2.

However, when EC jumps happens, the internal keyboard state doesn't know
this and always reset XLATE as on. This makes the EC generate garbage to OS.

So, this patch fixes would clear the XLATE if the EC reboot is a warmboot
based on the assumption that moderm OSes clear the XLATE bit.

BUG=chrome-os-partner:9102
TEST=on link
% ectool reboot_ec A  (from r438 to r438)
  Expect keyboard is hang (r438 is still buggy)
% chromeos-firmwareupdater --mode=recovery
  Expect fail at gec_need_2nd_pass()
% ectool reboot_ec RO
  Keyboard is still working!  Bug fixed!
% ectool reboot_ec RO
  Again. Still working.

Change-Id: If47bd8d7bbbb03b810d3b464ba3d92f8ff548237
2012-04-18 13:57:11 +08:00
Louis Yung-Chieh Lo
755a767c2b Fixed the bug that reboot_ec resets the keyboard state to disabled.
The reboot_ec command could warm boot the EC while the host is still
running. However, this resets the internal state so that the keyboard
module is disabled on the EC side.

Check the reset cause during the keyboard init code. If it is wrm boot,
enable the keyboard (assume the host is on).

BUG=chrome-os-partner:9102
TEST=on link 1.0
% ectool version
Firmware copy: RO
% ectool reboot_ec RO
the keyboard keeps working.

Change-Id: I0009c561e2cd88789e50f9129b494538e50ee00e
2012-04-18 10:45:28 +08:00
David Hendricks
7a33ee53a6 daisy: Plumb in I2C driver
This adds I2C2 support for Daisy:
- Initializes I2C2 GPIO lines
- Adds CONFIG_I2C so main() will call init function
- Adds work task for I2C2

BUG=chromium-os:28925
TEST=build on daisy and discovery; run on daisy

Change-Id: I147e3781b8bcac87ff248fb45c9978b614a24b89
Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: David Hendricks <dhendrix@chromium.org>
2012-04-17 13:44:03 -07:00
David Hendricks
2559041f39 daisy v1.02: setup GPIO signal to audio codec
Set up signal to audio codec as open-drain output. This should
be benign on older revisions of Daisy.

The signal CODEC_INT is driven low whenever a keypress has been
processed. For Daisy, a delay of about ~1ms from the time a key
is pressed until the time the codec is signaled is okay. This
gives us time to scan the columns to see if a key was actually
pressed so that we don't cause spurious codec interrupts.

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

BUG=None
TEST=Tested on Daisy using oscilloscope

Change-Id: Id3564f4aacbf7294b7151b082075f3c3ec8b1eb2
2012-04-17 12:46:29 -07:00
Gerrit
48aba27dd5 Merge "stm32l: eliminate GPIO initialization done in keyboard code" 2012-04-17 11:36:35 -07:00
Gerrit
92efde83c4 Merge "daisy: Set up EC_INT as open-drain output" 2012-04-17 11:36:34 -07:00