Commit Graph

493 Commits

Author SHA1 Message Date
Bill Richardson
d9bddaa072 Improved the BUILD_ASSERT macro to work outside of functions.
This will let us check the size of static array initializers.

Also moved this macro definition and ARRAY_SIZE into a new "tricks.h"
header, so that userspace utils can use it too.

BUG=none
BRANCH=none
TEST=manual

Built everything, tested on Link. Tried various assertions.

Change-Id: I612891108ea37dbca3572e0f25ab54a7bc0ed860
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49417
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-04-29 11:05:08 -07:00
Vic Yang
6d19c024a9 spring: Enable both VFET2 and VFET4 for video
We are moving video power from VFET2 to VFET4. To support old boards, we
need to enable both of them. When new boards are in place, we can then
drop VFET2.

BUG=chrome-os-partner:18186
TEST=Build spring
BRANCH=spring

Change-Id: If0cbc1ac49affc1e3c7ec9650a661f80be826f97
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49431
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-04-29 03:47:56 -07:00
Bill Richardson
df06f61ccc Split pwm.c into pwm_fan.c and pwm_kblight.c
Sadly, the existence of fans may not always imply the existence of keyboard
backlights.

BUG=chrome-os-partner:18825
BRANCH=slippy
TEST=manual

Use the Link EC console to make sure that both functions still behave.

  faninfo
  fanset 4400
  faninfo
  fanset 9999
  faninfo
  autofan
  faninfo
  fanduty 50
  faninfo
  fanduty 100
  faninfo
  autofan

  kblight 0
  kblight 100
  kblight 50
  kbligth 100

Change-Id: I2e07cd46c21bce2d0d4162275a8ea6ae40135e96
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49355
2013-04-26 16:07:21 -07:00
Randall Spangler
fd38ba353c Move PMU charger irq handler to charger module
No code changes; this is just moving the irq to the module which
actually handles it.  This makes it simpler to disable the charger
task separately from the PMU module.

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

Change-Id: Ife44a17f69bf21aa000d162318a459cea6fdf661
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49334
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2013-04-26 13:46:47 -07:00
Vic Yang
92bd863d8d Add new TPS65090 charge state REINIT and BAD_COND
Currently INIT state can mean different things. This change introduces
two new states to demultiplex INIT. Now, REINIT means charge state
machine is deciding the next state. BAD_COND means it's waiting for
acceptable charging condition. Note that the three states are doing the
same thing so there is no functional change.

BUG=chrome-os-partner:18914
TEST=none
BRANCH=spring
CQ-DEPEND=CL:49327

Change-Id: Ia783e76cf27e28103ef44fe7b8a43674dadccc54
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49326
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-04-26 12:36:26 -07:00
Randall Spangler
45bc5c1a21 Split out power button code from switch.c
The power button code is platform-independent.  This change splits the
code out of the LM4 switch.c module so that a subseqent change to
STM32 platforms can start using it.

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

1. Power+refresh+esc goes to recovery mode,
2. Press power button at recovery screen turns off.
3. With system off, power button turns system on.
4. Press power button for a second; screen locks.
5. Press power button while typing; blocks keystrokes while it's pressed.
6. Hold power button down for 8 sec; system forced to shutdown.
7. From EC console, with system on:
   hostevent clear
   hostevent -> event 0x04 is clear
   press power button
   hostevent -> event 0x04 is set
8. From EC console, with system off:
   powerbtn -> system turns on
   powerbtn 5000 -> system turns off, just like power button was held for 5 sec

Change-Id: If2a9b02514a201e1d03c857d128e2ccab51a16ef
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49217
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-04-25 17:03:18 -07:00
Bill Richardson
0bfb7ddd07 Replace generated CONFIG_TASK_ macros with HAS_TASK_
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>
2013-04-24 16:32:58 -07:00
Randall Spangler
01279936cb Unify lid switch processing
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>
2013-04-24 00:06:00 -07:00
Bill Richardson
3def4e04fa Allow keyboard_scan_config to be customized per-board
By default it's not, but if you #define CONFIG_CUSTOM_KEYSCAN, you can add
your own settings in board.c

BUG=chrome-os-partner:18343
TEST=build link, bds
BRANCH=none

Change-Id: I2a9dd48fd7f4610bc39dcc59e59a3fedec539e28
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48994
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-04-24 00:05:53 -07:00
Bill Richardson
c747652e49 Allow building without battery charging
Some experimental boards may want to build without a battery charging task
to make bringup easier.

BUG=chrome-os-partner:18343
TEST=build all boards
BRANCH=none

Change-Id: I4269fea4046325241ad7720ec3457b0534aadda3
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48974
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-04-24 00:05:52 -07:00
Vic Yang
c6e5d592cb Add LP5562 functions to control engine execution state
This gives us better control over the execution state of lighting
engine.

BUG=chromium:233832
TEST=Build success
BRANCH=spring

Change-Id: Ibfa86be0eef2b7dff8495f770649577295d4cb6f
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48773
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-04-23 10:39:13 -07:00
Daisuke Nojiri
74c34bbad4 Saving the main stack pointer at the entry of exception_panic.
CPU creates an exception frame on the main stack instead of the process
stack when the exception happens in a handler's context. So, we need to
save both msp and psp, and pick the right one to locate the exception frame.

Tested by marking the stack (as you see in the dump below) then triggering
divzero in svc_handler.

> crash svc

=== HANDLER EXCEPTION: 03 ====== xPSR: 6100000b ===
r0 :00000000 r1 :0000e237 r2 :000015cf r3 :000015cf
r4 :00000001 r5 :22222222 r6 :11111111 r7 :0000df01
r8 :00000000 r9 :2000545e r10:00000000 r11:00000000
r12:0000000d sp :20000fb8 lr :000055d7 pc :00000b40
Divide by 0, Forced hard fault
mmfs = 2000000, shcsr = 70080, hfsr = 40000000, dfsr = 0

=========== Process Stack Contents ===========
20002738: 11111111 22222222 33333333 44444444
20002748: 00000000 000003ad 000003c0 81000000
20002758: 00000000 0000557d 0000557c 21000000
20002768: 00000000 00000000 00000000 00000000

Rebooting...

BUG=chrome-os-partner:16901
BRANCH=none
TEST=mentioned above

Change-Id: I3ca08a1df20375953552b3dc926350e262b78b2a
Signed-off-by: Daisuke Nojiri <dnojiri@google.com>
Reviewed-on: https://gerrit.chromium.org/gerrit/47495
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-04-18 20:56:15 -07:00
Randall Spangler
36317d46f7 Move STM32 timer regs struct to registers.h
This is a struct representation of the STM32 timer registers, so
belongs in registers.h instead of the platform-independent hwtimer.h.

Note that there are other problems with the use of this struct.  It
should be volatile, and if it's a win vs. the macros we should replace
ALL macro'd timer register accesses with the struct instead of just
those in hwtimer.c (that is, we shouldn't do things both ways).  I'll
address those in a subsequent CL after testing which way generates the
most compact code.

No functional changes, just moving the struct definition.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all platforms

Change-Id: If29d008fb38b9cc847b69eda1ee7c05e67f6e5e7
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48415
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-04-17 18:47:05 -07:00
Randall Spangler
5f18b03e1b PMIC_PWROK is active-high on pit
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>
2013-04-16 14:55:13 -07:00
Randall Spangler
108235225d Refactor gpio_set_level() and gpio_pre_init()
gpio_set_level() now allows setting the pin level if GPIO_LOW or
GPIO_HIGH is specified.  Previously, stm32 platforms did this even
though the definition of gpio_set_level() said it wouldn't work.

Fixed gpio_set_level() not setting level after warm reboot on stm32
because it was checking the GPIO_DEFAULT flag in the wrong place.

Fixed LM4 still mucking with alternate function settings and levels
even if GPIO_DEFAULT was specified.

And checked gpio_list[] and all of the calls to gpio_set_flags() to
make sure everything still behaves the same way it did before (or
better, in the case of actual bugs).

BUG=chrome-os-partner:18718
BRANCH=none
TEST=build all platforms; boot spring and link

Change-Id: I4b84815f76060252df235ff9a37da52c54a8eac5
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48058
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-04-15 14:27:45 -07:00
Vic Yang
27459f8600 Fix test compilation error for link
Now pingpong and mutex tests compile. Still need some more work to
handle the i8042-specific KEYPROTO task for keyboard tests.

BUG=chrome-os-partner:18598
TEST=Build tests for link
BRANCH=None

Change-Id: I9ee35d4edb811f17b9a81beb799484a07c0bef14
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47981
2013-04-13 03:12:21 -07:00
Randall Spangler
79c6132a6e Allow GPIO alternate function 0
gpio_set_alternate_function() used 0 to mean "normal GPIO function".
But on chips like STM32L, alternate function 0 is actually a function
on some pins.  So change "normal GPIO function" to -1.

Also add support for this on STM32L.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build and boot link and daisy

Change-Id: I9cdd9ad91a315b616e373a0dc9a50545cf9d20fa
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47903
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-04-11 15:38:09 -07:00
Randall Spangler
08f8c6857f Strip out old LPC command protocol
Nothing has used this since link EVT, so it's just dead code at this point.

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

- Update ectool but leave old firmware
- ectool version -> works
- ectool flashread 0 0x10000 foo -> puts the first 64KB of EC flash into foo

- Update firmware
- ectool version -> works
- ectool flashread 0 0x10000 foo -> puts the first 64KB of EC flash into foo
- power+esc+refresh -> recovery mode

Change-Id: Ib25a705bcd8280d5295c8e7890969d796542b6c9
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47866
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-04-11 11:29:38 -07:00
Randall Spangler
e5f4032866 Clean up USB external power module
Make internal APIs static, and remove board_ prefix for clarity.

Move TSU6721 calls from charger task to extpower_usb functions for
better encapsulation.

No functional changes, just moving code.  Yes, this will make
cherry-picking back from spring to TOT less convenient, but now the
code is more readable and it will make maintaining the PMU code easier
as we add boards.

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

Change-Id: I52b37e57fc8519859996a110b0503277c6f0bbc8
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47657
2013-04-10 14:24:10 -07:00
Randall Spangler
a649f52d5f Move REG16 and REG32 macros to common.h
And use them for LM4 as well as STM32.  Consistency is good.

No functional changes, just moving/renaming code.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all platforms

Change-Id: I029a21fadb50726500255219dc38615874a369e7
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47700
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-04-10 11:19:38 -07:00
Vic Yang
8a06eb1d35 Only includes necessary tasks for test binaries
This changes current TASK() syntax to TASK_BASE() and TASK_NORMAL(),
where TASK_BASE is necessary for the EC to boot on a board and
TASK_NORMAL represents the task that can be removed in a test binary.

Tasks introduced by a test should be listed as TASK_TEST().

Note that this CL breaks current tests (many of them are broken anyway),
which will be fixed in up coming CLs.

BUG=chrome-os-partner:18598
TEST=Build link/bds/spring/snow/daisy/mccroskey. (mccroskey failed for
unrelated issue)
BRANCH=none

Change-Id: Ic645cdae0906ed21dc473553f1f43c2537ec4bb9
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47531
2013-04-10 01:08:45 -07:00
Randall Spangler
95250857ad Fix mccroskey build
There's no chipset for mccroskey, so its keyboard code stopped compiling.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build mccroskey, spring, link

Change-Id: If94dfaf2819f047a6aa825ee10aa1d320c8ca882
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47566
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-04-09 10:13:10 -07:00
Randall Spangler
fcb1e1c819 Move power LED GPIO code from snow board.c into power_led.c
And remove the daisy power button LED task for now.  Since daisy
didn't have a board.c implementation (or a power button LED), its
power LED task did nothing.

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

Change-Id: I1eb3d0bd038d88685e7caad087eb1a1d1495ef9a
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47442
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-04-08 10:00:35 -07:00
Vic Yang
f273ae7173 Add macros for mocking functions
This introduces two symbols for mocking functions in existing code:
  - test_mockable
  - test_mockable_static

BUG=chrome-os-partner:18598
TEST=none
BRANCH=none

Change-Id: Ia7251a9b609136c8f3b155c221634bac7dcb1d68
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47540
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-04-08 09:33:47 -07:00
Randall Spangler
14adad27e8 Clean up board configuration
Board configuration interfaces are now defined in board_config.h, not
in every board.h file.

Tidied /alphabetized CONFIG defines.

No functional changes, just rearranging code.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all targets

Change-Id: I6196591784f8fa9ce6dfccd31891b679fb200063
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47419
2013-04-05 14:28:42 -07:00
Randall Spangler
765c50ef5f Move board hard reset code into tpschrome driver
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
2013-04-05 11:28:51 -07:00
Randall Spangler
4d1aadaf60 Trigger dma_init() via HOOK_INIT
There's no need for it to be initalized in board_init(); it just needs
to be done before ADC / I2C / SPI initialize.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=boot spring; verify EC communication and 'adc' console command still work

Change-Id: I6039848fe031222d5ca59b459adfe18fc3e8ef08
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47182
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-04-03 11:49:07 -07:00
Randall Spangler
9137686ebe Clean up board.c files
Just renaming functions and reordering #defines; no functional changes.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all EC boards

Change-Id: I90e9ea860110625012cd5fb99de966283ec82880
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47179
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-04-03 11:49:06 -07:00
Vic Yang
13c74da5ad spring: Add host command to limit external power current
This is useful for debugging and the factory.

BUG=chrome-os-partner:18530
TEST=On spring, check we can set PWM duty cycle and can go back to
automatic control.
BRANCH=spring

Change-Id: I3da75f0a356cc0f21d748bf135e3b95fbd9c465b
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47105
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-04-02 20:42:48 -07:00
Randall Spangler
23bbebaeb9 Remove unused EC_SWITCH_KEYBOARD_RECOVERY
This was left over from the way we reported keyboard recovery early in
link/snow, before we had host events.  No shipping EC ever reported it.

Coreboot and u-boot look for this flag, so we can't repurpose it until
they ignore it too.

BUG=chrome-os-partner:18512
BRANCH=none
TEST=compile link,spring

Change-Id: I38fbf0fa7d958c3774c8b293d4be25faaecdadea
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47058
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-04-02 14:12:58 -07:00
Randall Spangler
bdd16f8206 Split lid switch code out of switch.c to its own file
This will allow ARM code to use the same lid switch code (in a subsequent CL).

BUG=chrome-os-partner:18343
BRANCH=none
TEST=open lid; system boots. close lid; system suspends.  open lid; resumes.

Change-Id: I83536a3ad24c4446dccf8a6b6e296756659070a8
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47043
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-04-02 14:12:57 -07:00
Randall Spangler
5966f22a8a Add support for calling deferred functions
This is a cleaner way of deferring work from interrupt-time to
task-time without requiring a task for each module which needs this.

Replaces/supersedes delayed hook notification, which didn't scale well
(since every function would have needed to be its own hook type).

BUG=chrome-os-partner:18473
BRANCH=none
TEST=boot system.  plug/unplug AC power; notifies the host properly

Change-Id: I50263fe1ce37e74c1ef8db3671379098997102ed
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46953
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-04-02 14:12:55 -07:00
Randall Spangler
97bf36c9d3 Add parse_bool() to centralize parsing boolean options
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>
2013-03-29 15:39:34 -07:00
Randall Spangler
95a3a4107a Merge i8042.c into keyboard_8042.c
This is in preparation for cleaning up the 8042 protocol stack and
merging the typematic and i8042cmd tasks.

No functionality change, just shuffling code and renaming functions.

BUG=chrome-os-partner:18360
BRANCH=none
TEST=boot link and type on its keyboard

Change-Id: Iefc41cd5b8d18ac87830bff3080cfff92e9d10d2
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46805
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-03-29 11:40:35 -07:00
Randall Spangler
fe3ccdf70a Merge lm4 and stm32 implementations of keyboard_scan
Scanning is now performed identically on all platforms.  keyboard_scan
talks to chip-specific keyboard_raw on the bottom end, and 8042 or mkbp
keyboard protocol on the top end.

8042 can now take advantage of CONFIG_KEYBOARD_TEST to simulate scan results.

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

1) Type on keyboard.  Should produce keystrokes.

2) At EC console:
    kbpress 3 7 1
    kbpress 3 7 0
Should produce 'r' keystroke(s); key repeat should kick in if you wait
a while between the commands.

3) Hold power button while typing.  Should not produce keystrokes.

4) Reboot with power+refresh+esc.  Should go to recovery mode.

5) While the system is up, alt+volup+R should reboot the AP.

Change-Id: I48e0bca15b869162672b5f54ffcb561f6fcf0f45
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/46666
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-03-29 11:40:34 -07:00
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
Todd Broch
0a2603e8ea spring: Enable low power mode.
This mode was disabled initially to make sure it didn't side-effect
things during early development.  Now that branch is cut lets
re-enable and backport when stability is proven.

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

BRANCH=spring
BUG=chrome-os-partner:17587
TEST=manual, install & run on Spring ... system functions.

When device is plugged stays awake regardless of battery state.
When device is unplugged sleeps and power is saved.
When device is re-plugged awakes.

Change-Id: I9a85fa7376d1a94c9864beed3d053e8b49480959
Reviewed-on: https://gerrit.chromium.org/gerrit/45594
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
2013-03-26 18:03:20 -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
Vic Yang
db20e7afde spring: keep AP off when battery level is too low
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>
2013-03-20 23:47:40 -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
22ff9df913 Move battery LED code on spring to common
It's not board-specific, so move it out of board.c.

No functional changes; this is just moving code and renaming a few functions.

BUG=chrome-os-partner:18256
BRANCH=none
TEST=build spring

Change-Id: Ib004066aed93745cb0c96d3cb45d70b728545492
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45918
2013-03-20 17:42:04 -07:00
Randall Spangler
f8393fab2c Move gaia event handler declarations to gaia_power.h
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
2013-03-20 17:42:03 -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
Vic Yang
6e07f94c90 spring: More stable battery LED control
This includes:
  - Discharging with AC present now recognized as battery assist mode
  - Trigger LED update every second instead of from PMU task
  - Minor breathing effect optimization
  - Control LED power and color from the same task to prevent
    simultaneous access to LED driver

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

Change-Id: I9b34934f46cd4f04aaa7ca30cbe90316aec3e61e
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45632
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-03-19 14:59:47 -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
Randall Spangler
c196c66432 Call AC change hook from the hook task
Using code like this, modules which service interrupts and notify
hooks will no longer need to have their own tasks to call
hook_notify() from.  They can share the hook task as long as they
don't mind the notification possibly being deferred.

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

Change-Id: I1bc32d21b2202c3242d39e0fc533198cd5bb9c66
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45780
2013-03-19 10:31:10 -07:00