Commit Graph

768 Commits

Author SHA1 Message Date
Bill Richardson
001fb660bd Split the USB port power control into smart and dumb versions.
Also renaming to avoid confusion as to what's being charged.

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

Build everything, Link still works.

Change-Id: I4205a1210c7dfe57cfbbdd740970ef57e6a011b8
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49775
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-05-01 15:36:22 -07:00
Vic Yang
8961ef44e4 spring: Implement battery cut-off command
BUG=chrome-os-partner:18818
TEST='ectool batterycutoff' on Spring.
BRANCH=spring

Change-Id: Idf315562930744ae1e7425d6e15915b0477c2343
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49651
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-05-01 13:19:35 -07:00
Vic Yang
7319480603 Rename REINIT to IDLE0 in TPS65090 charge state machine
The state REINIT in TPS65090 charge state machine is more like IDLE0
state in charge_state.h. Rename it so that it's less confusing and
easier to merge the two state machines in the future. Also move the
state name definition to the header file.

BUG=chrome-os-partner:18914
TEST=Boot Spring
BRANCH=None

Change-Id: I116438fedc46ff188dfb6a3964795715b5af4d1f
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49732
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-05-01 13:19:20 -07:00
Vic Yang
7de52688be Monitor video detachment with ADC watchdog
This eliminates a per-second hook and removes a duplicated ADC read per
second. Also, TSU6721 is now reset after every detachment. This way, we
don't suffer from TSU6721 dirty state (most commonly seen after OTG
dongle detached.)

BUG=chrome-os-partner:17928
TEST=1. Test plugging/unplugging video dongle.
     2. Test Toad cable mode switching.
     3. Test charging with 200K charger.
BRANCH=spring

Change-Id: Ic035b7332e07ca385d766c735ce39efd31e46034
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49578
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-04-30 22:53:15 -07:00
Bill Richardson
e63aade5bd Split x86_power.c into Ivybridge and Haswell variants
The voltage rails, inputs, and sequencing is completely different. Easiest
to just handle it separately for each chipset.

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

Built Link, still works.

Change-Id: Ibf26ef47cdf2284b7bfb3a2e5ccfb6841aba5ac6
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49559
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-04-30 19:03:03 -07:00
Randall Spangler
312b884c42 Split STM32 i2c implementation for STM32F vs STM32L
STM32L doesn't need the DMA-based workarounds needed by STM32F, since
the STM32L I2C block isn't broken.  DMA adds a lot of code overhead
when transferring 2-3 bytes, and is implemented differently on STM32F
vs STM32L so it doesn't even work on STM32L

Add a simple polled I2C implementation for STM32L.  This is not the
final implementation, which will use interrupts, but for now it works,
unlike the DMA-based version.

BUG=chrome-os-partner:18969
BRANCH=none
TEST=i2cscan on pit finds a device at 0x90

Change-Id: Ie2a6c9ac6f62b7fd3c35e313b4015e080d9f937a
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49555
2013-04-30 14:49:07 -07:00
Vincent Palatin
980df54979 add option to de-activate EC console input when WP is on
With a Toad cable, the user can access the EC serial console through the
micro-B connector.
We probably need to de-activate the input on the EC serial console when
the Write-Protect is on, since we have fairly "powerful" commands on the
EC command-line.
Add a new CONFIG_CONSOLE_RESTRICTED_INPUT on platforms with externally
accessible EC serial port.

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

BRANCH=spring
BUG=chrome-os-partner:18716
TEST=on Spring with CONFIG_CONSOLE_RESTRICTED_INPUT set, try with and without
write-protect, use successfully the EC console in the former case, and see
"Console is DISABLED" in the latter case.

Change-Id: Ic9646d5468183f4d8f94b5e5e1d2a727941d7bbe
Reviewed-on: https://gerrit.chromium.org/gerrit/49537
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2013-04-30 11:45:58 -07:00
Randall Spangler
0a6b7620d6 Move i2cread and i2cwrite functions to i2c_common
Also moves the handy i2cscan command to i2c_common.  The
platform-dependent interface is now i2c_xfer().

Still more to do in follow-up CLs; for example, i2c_read_string() has
platform-dependent implementation, and the i2c/i2cread console
commands aren't common yet.

BUG=chrome-os-partner:18969
BRANCH=none
TEST=i2cscan on link, spring

Change-Id: Ia53d57beaa157bece293a4262257e20b4107589e
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49492
Reviewed-by: Simon Glass <sjg@chromium.org>
Commit-Queue: Daniel Erat <derat@chromium.org>
Commit-Queue: Simon Glass <sjg@chromium.org>
2013-04-30 11:45:52 -07:00
Vic Yang
115ab924fc Handle battery charged alarm
When battery flags TERMINATE_CHARGE or OVER_CHARGED alarm, we should
treat them as a signal of battery fully charged.

BUG=chrome-os-partner:18914
TEST=On Spring:
       1. Plug in adapter when battery if full, see green LED.
       2. Plug in adapter when battery is not full, see yellow LED.
BRANCH=spring

Change-Id: Ica414a0e1667b8f30a0cc9a5d66dba1b119a59ba
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49456
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-04-29 23:31:29 -07:00
Randall Spangler
00f2041d86 Clean up gaia_power debug messages
Should use CPRINTF("[%T...\n]") so the messages are timestamped; this
is really helpful to see when things are going wrong.

No functional changes; just changing debug output.

BUG=none
BRANCH=none
TEST=build pit and spring; see prettier debug output

Change-Id: I9c658385b836a184a3ebb84856b844cbfc3224a7
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49551
Reviewed-by: Simon Glass <sjg@chromium.org>
2013-04-29 17:50:28 -07:00
Randall Spangler
deb05123f8 Don't enable charger interrupt if charger task is disabled
This fixes pmu_init() failing on pit, where the charger task isn't
enabled yet (and thus the charger interrupt is NULL - which can't be
enabled).

BUG=chrome-os-partner:18657
BRANCH=none
TEST=build all platforms; on pit, check that pmu_init() no longer fails

Change-Id: I191bbaeb4df10241e3508ccf7ef5ea83f42c5697
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49550
Reviewed-by: Simon Glass <sjg@chromium.org>
2013-04-29 17:50:27 -07:00
Randall Spangler
7cebaa0a01 Fix charging state descriptions
Two states were added, but the descriptions weren't.  This caused a crash.

BUG=chrome-os-partner:18914
TEST=boot spring with no battery, wait a few secs; shouldn't crash
BRANCH=spring

Change-Id: I10f9280232259a1f467ea3b02f3b1b61cee57471
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49391
2013-04-29 10:03:44 -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
8bc24ec311 Rename i2c_commands.c to i2c_common.c
It will soon have cross-platform code moved to it.

This CL just does the renaming; no functional changes.

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

Change-Id: I8cc475f9dd1422a0a9c586c93eb0d7aaf21a001d
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49359
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-04-26 16:07:20 -07:00
Randall Spangler
7a9e47d74e Allow disabling PMU charger task, and do so on pit
I2C communication doesn't work on pit yet, so the charger task is
spewing errors to the console.  This change allows the task to be
disabled cleanly on pit, and has no effect on other platforms.

BUG=chrome-os-partner:18657
BRANCH=none
TEST=build all platforms and see that charger task is still compiled
     everywhere but pit

Change-Id: I788e817d5630fb1a28694819f4ef9948a503a744
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49344
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-04-26 13:46:48 -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
0d645f105e spring: Show yellow LED when not fully charged
This includes two situations:
  1. When charge state machine is still trying to decide the next state.
  2. When we are waiting for acceptable condition to start charging.

For now, we show yellow for both.

BUG=chrome-os-partner:18914
TEST=none
BRANCH=spring

Change-Id: I5dd97c735a1ecfee29d506452695014c85d2da0b
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49327
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-04-26 12:36:27 -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
Randall Spangler
a55e270f0b Temporarily enable all FETs at chipset poweron
This will allow debugging until the I2C passthru command is supported,
and should be removed once it is supported.

BUG=chrome-os-partner:18778
BRANCH=pit
TEST=build pit; can't test until we have boards

Change-Id: I6285e76763a5f3bfd759161115d4905697b56e6c
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49096
Reviewed-by: Doug Anderson <dianders@chromium.org>
2013-04-24 17:33:09 -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
9d8e0d0859 Move common chipset console commands to chipset.c
apreset and apshutdown are now the same across all platforms.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all platforms; make sure 'apreset warm', 'apreset cold', and
     'apshutdown' work.

Change-Id: I4ace1ab2bbda4d400528039ad5f84da63c9c7d0e
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48942
2013-04-24 09:58:22 -07:00
Vic Yang
5f86cc0aa5 spring: Improve battery LED stability
Previously, we sometimes saw battery LED went off when going into or out
of battery assist mode. This CL adds a state machine to stabilize
battery LED. By controlling the state of lighting engine, the
tranisition from/to battery assist mode is seamless now.

BUG=chrome-os-partner:18844
TEST=On spring, check:
      1. LED doesn't go off when going into battery assist mode.
      2. LED doesn't suddenly change brightness when coming out of
         battery assist mode.
      3. LED goes red after few seconds when battery is not present.
      4. LED goes green when battery is charged.
BRANCH=spring
Signed-off-by: Vic Yang <victoryang@chromium.org>

Change-Id: I3286b54a76edd77c65033ec3bbf0d81d916f7be0
Reviewed-on: https://gerrit.chromium.org/gerrit/48875
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2013-04-24 00:06:01 -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
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
Vic Yang
4d96bf649d Unify lid switch GPIO name
Link uses LID_SWITCH_L but it means the same thing as LID_OPEN. Changing
it to LID_OPEN so that all boards use the same name.

No functional changes, just renaming.

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

Change-Id: I74893e1365ad3068f13e7fe948f1a54c6c6301bb
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48893
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-04-23 10:39:10 -07:00
Vic Yang
2dd01e59ea Software flow control in console
This adds software flow control handling (a.k.a X-on/X-off). When Ctrl-Q
is received, UART transmitting is paused until Ctrl-S is received. If
the FIFO or buffer fill up during this period, console output is lost.

BUG=chrome-os-partner:18680
TEST=Press Ctrl-Q and see console stopped. Press Ctrl-S and see buffered
messages.
BRANCH=spring

Change-Id: I9ce1198a1119dadc558bb522c48037bb83bba415
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48887
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-04-23 10:39:09 -07:00
Bill Richardson
4d0c4b1a53 Increase EC low-battery threshold to 14% to match kernel
There is a 4% difference between the kernel's view of battery level and the
actual battery level, to give userspace a chance to shut down cleanly. The
EC should turn the lightbar red when the battery drops below 10%, so this
change makes that happen when the kernel says it's 10%, instead of the real
10%.

Note: We don't have to cherry-pick this to the Link branch. Although it
affects the EC, we already patch the EC lightbar parameters at boot and
that's done in userspace.

BUG=chromium:225500
BRANCH=none
TEST=manual

Unplug Link, let the battery run down. The lightbar should pulse red when
the battery level reported by the UI drops to 9% (there may be a little
delay due to rounding). Note that it's only red when on battery.

Change-Id: If3d335c54ceb37c86da59e4a66f8ecd46ce15664
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48904
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-04-23 10:39:09 -07:00
Randall Spangler
57b77a3a8f Active-low Link GPIOs end with _L, not n.
This is now consistent with other boards.

No functional changes, just renaming,

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

Change-Id: Ifd7c1ec608ab61f5f66800e91803ffafe1d944b6
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48804
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-04-22 16:44:37 -07:00
Randall Spangler
dcb2425f45 Turn on 3.3V rail earlier in power sequence for pit
The 3.3V rails powers some of the buck supplies, so must be turned on
1ms after the 5V rail.

BUG=chrome-os-partner:18657
BRANCH=none
TEST=build pit, snow

Change-Id: I18a165744352ae375080824fecfeb56f6ac81a9c
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48729
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-04-22 09:55:49 -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
9844e82ca8 Remove _OFF from GPIO register macros
This is left over from when we had a pair of macros for each GPIO
register, one which concatenated its base address name and one which
took a base address.  Only the latter has survived, but its naming is
longer than it needs to be and isn't consistent with other register
banks (USART, TIM, etc.).

No code changes, just renaming macros.

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

Change-Id: I15a282fd01db2a25219970e28ce551d8dc80193f
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48226
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-04-16 14:55:12 -07:00
Vic Yang
216bb93128 Fix flash tests
This merges flash_overwrite and flash_rw_erase to a single test binary.

BUG=chrome-os-partner:18598
TEST=Run on Spring
BRANCH=None

Change-Id: I1da7577cb5dc196178930dda3a07bb942d959866
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48090
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-04-15 20:40:02 -07:00
Randall Spangler
b9d0d9c60b Move gpio_get_name() to gpio_common.c
Its implementation is the same on all platforms.

No functional changes, just renaming/moving.

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

Change-Id: I78741c6587ea61e7ac8edae5a509502b7ab5078b
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47898
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-04-11 15:38:08 -07:00
Vic Yang
4adcb45f2c Fix kb_deghost test
BUG=chrome-os-partner:18598
TEST=Run test on Spring
BRANCH=none

Change-Id: Ia95ba6144dbdac0ffe77f6aef9c4ed948de181d8
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47841
2013-04-11 11:29:32 -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
Vic Yang
9aa3716ca0 Turn on/off 3.3V output properly
When the system is turned off and then back on, we need to re-enable
3.3V output from TPS65090. Also, when we see 5V input, we should shut
down 3.3V output and re-enable it when 5V input goes away.

BUG=chrome-os-partner:18186, chrome-os-partner:18482
TEST=Manual
BRANCH=spring

Change-Id: I0cf0597a60988cc9ec28282eea54908c81e5eabc
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47736
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-04-10 09:35:05 -07:00
Vic Yang
64ae15f3b3 Decouple gaia_power from keyscan task
This makes gaia_power.c compile when keyscan task is not present.

BUG=chrome-os-partner:18598
TEST=Build spring without keyscan task.
BRANCH=none

Change-Id: I70823fb562a2542d92929b9219d034216f636938
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47630
2013-04-10 01:08:43 -07:00
Randall Spangler
861d7d667d Rename usb_charging.c to extpower_usb.c and move to common/
This more clearly indicates what it does - it manages external power
supplied by USB.  This code will be common to multiple boards which
take power via USB, so it might as well move now.

No code changes, just moving the file.

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

Change-Id: Iae74122db38666bc346104a5096fa82df8cb0c19
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47656
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-04-09 14:47:28 -07:00
Vic Yang
54ea657965 Decouple keyboard MKBP code from key scan code
When unit testing, we may need to disable key scan task but leave
keyboard protocol code for testing.

Also fix a bug in determining if ENABLE flag is set.

BUG=chrome-os-partner:18598
TEST=Remove KEYSCAN task and build for spring.
BRANCH=none

Change-Id: I3b3adf1257e8446fd1f57bce50b4c7a029b1ce3b
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47539
2013-04-08 21:03:47 -07:00
Randall Spangler
303aef9e3f Rename onewire_led functions and constants
This removes overlap between onewire_led.c (LED on link cable) and
powerled.c (LED on snow power button), which had the same names but
did different things.

No functional changes, just renaming.

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

Change-Id: I711f1a7e4e5512d1923872cb0f19d64be153c7c5
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47420
2013-04-05 14:28:49 -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
a3dcfd54ef Improve deferred function calls
1) Check vs. number of allowable deferred function calls is made at
link time.

2) Added a check for whether hook_call_deferred() has been made after
the start of calculating the time when the hook task should wake.  If
it has, go back and recalculate the wake time.  This works around a
race condition.

BUG=chrome-os-partner:18473
BRANCH=none
TEST=add a bunch of deferrable functions and recompile; generates a link error

Change-Id: Ie833e2a699c47b6702957ed67bf7d3925f2df099
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47266
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-04-04 16:32:27 -07:00
Todd Broch
af4d0fb297 Inhibit host interrupt for battery_key.
Battery key is used to signal to the host that USB charging status has
changed.  This virtual keystroke should not wake the device like
physical keystroke does.  Change still copies keystroke to the
keyboard fifo but bypasses sending host interrupt.

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

BRANCH=spring
BUG=chrome-os-partner:18333
TEST=manual,

Scenario1:
  suspend device then plug/unplug USB charging.  Device doesn't wake.
  When resume 'cat /sys/class/power_supply/cros_ec-charger/online' is
  correct.

Scenario2:
  while true ; do
    cat /sys/class/power_supply/cros_ec-charger/online
  done

  plug/unplug USB charging and device online status changes in a
  timely manner

Change-Id: I8938798b30e70c0c5021405d4fc5da9ce398c311
Reviewed-on: https://gerrit.chromium.org/gerrit/47251
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
2013-04-04 16:32:20 -07:00
Randall Spangler
6d49e2660e Add common implementation for daisy/snow extpower_is_present
The implementations are identical for daisy and snow, so move to a
common file instead of having duplicate code in board.c

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

Change-Id: I63597885607fd03b3bf87bcebf2146190b301f22
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47183
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
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