Commit Graph

16 Commits

Author SHA1 Message Date
ChromeOS Developer
f762717059 Clean up g781 temp sensor function names
BUG=None
BRANCH=None
TEST=Manual. Run the following console commands:
g781 - verify temps and status look sane.
temps - verify local and remote values for the 781 are listed
g781 settemp 0x05 80 - verify local high alarm set to 80C
g781 setbyte 0x09 0x80 - verify config register is 1000 0000

Change-Id: Ia437647fd052295dfd8901c2ef241ff69c0d950e
Signed-off-by: Dave Parker <dparker@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/179152
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-12-09 18:29:09 +00:00
ChromeOS Developer
d53fe7b79b Basic driver for tmp432 temperature sensor
This allows local and remote temp values to be added
to a board's list of temp sensors. It also adds a
'tmp432' EC console command to query temps
and set alert thresholds. Fractional degrees are not
supported. DPTF support is not addressed.

BUG=chrome-os-partner:23985
BRANCH=none
TEST=Add tmp432 support to a board with the sensor
then run the 'tmp432' and 'temps' EC console commands.

Signed-off-by: Dave Parker <dparker@chromium.org>

Change-Id: Ifee47cf4d4cf5eedef9ef2bfa2149f183f1d7a7b
Reviewed-on: https://chromium-review.googlesource.com/178688
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Dave Parker <dparker@chromium.org>
Tested-by: Dave Parker <dparker@chromium.org>
2013-12-07 00:57:24 +00:00
Randall Spangler
3b0a4055d1 Move battery temp ranges to battery_info struct
This allows boards to detect the battery and return the correct temp
ranges, which will be needed for upcoming boards.

In the board-specific implementations, it's pretty much just moving
the fields from one const struct to another, so the impact is minor.

BUG=chrome-os-partner:24310
BRANCH=none
TEST=build all platforms; verify pit and rambi still charge

Change-Id: I7be075b3abb4039577f6362316adc1860c121d5c
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/178424
Reviewed-by: Yung-chieh Lo <yjlou@chromium.org>
Reviewed-by: Rong Chang <rongchang@chromium.org>
2013-12-03 07:28:50 +00:00
Randall Spangler
40a1e7fa75 Cleanly force battery to mAh mode when reading capacity
Smart batteries can report capacity in mAh or 10mW units.  We forced
the units to mAh in charge_state.c's main loop, but that doesn't
guarantee that they're actually set before the capacity is read.  It's
cleaner to check the capacity reporting mode when actually reading the
capacity.

BUG=chrome-os-partner:20881
BRANCH=none
TEST=battery command reports the same capacity data before/after change
     (on rambi, design=2940 mAh)

Change-Id: I4a4c80eaade72bb09627d5d65693c097e264a992
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/176154
2013-12-02 22:03:54 +00:00
Randall Spangler
c0ec787ba1 Add battery_get_params()
The charge state machine asks for all of this stuff at the same time
anyway.  Bundling it into a single function removes a number of
redundant (and painfully slow) I2C reads.

Also refactor the battery debug command so it doesn't have so many
local variables all in one function; it was consuming considerably
more stack space than any other debug command.

Spring still needs low-level access to the smart battery, so move the
two functions it needs directly into the Spring implementation.

BUG=chrome-os-partner:20881
BRANCH=none
TEST=charge/discharge rambi, pit and spring; watch debug messages and
     LED and output of 'battery' debug command.  All should behave the
     same as before.  Then run 'taskinfo' and see that the console task
     has at least 20 bytes unused.

Change-Id: I951b569542e28bbbb58853d62b57b0aaaf183e3f
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/177797
2013-12-02 22:03:51 +00:00
Bill Richardson
1d2845d2db Add EC_MEMMAP_ALS, update it once per second
This adds space for up to two ALS lux readings to be available to the AP
through the memory-mapped LPC region. If enabled, the values are updated
once a second.

The ALS will be reinitialized at every AP resume, since it's typically
unpowered otherwise. The reported value will be zero when the ALS is off.

BUG=chrome-os-partner:23380
BRANCH=samus
TEST=manual

Boot the AP, then from the EC console run "als" or just monitor the
memory-mapped region directly ("rw 0x40080780" on Samus), while pointing the
sensor at bright and dim areas. The value should change.

Change-Id: I705371fcd57345dc9adae1231ea30c7ff024aaf8
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/176142
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-11-08 00:53:12 +00:00
Bill Richardson
f23e68d721 Add ALS driver for light sensors connected to EC
This adds the driver and a console command to read an Intersil ISL29305
light sensor connected to the EC.

BUG=chrome-os-partner:23380
BRANCH=samus
TEST=manual

Run the "als" command from the EC console, while pointing the sensor in
various directions. It should give higher numbers when facing a light
source.  If you get "Error 1", it means the ALS isn't powered.

Change-Id: I855ed64dab7fc60e29126ab3e97669be24dc6a64
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/176056
2013-11-07 23:42:56 +00:00
Bill Richardson
6c126f559a Cleanup: only compile battery_vendor_params() when enabled
Bolt uses Link's battery, but doesn't override the smart battery charge
profile with CONFIG_BATTERY_VENDOR_PARAMS. But the image still compiles and
includes the battery_vendor_params() function, although it's never called.

This CL stops doing that.

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

Build all targets.

Confirm that Link still has battery_vendor_params():

  $ make BOARD=link
  $ nm build/link/common/charge_state.o  | grep vendor
           U battery_vendor_params
  $ nm build/link/driver/battery/link.o | grep vendor
  00000009 T battery_vendor_params
  $

Confirm that Bolt does not have battery_vendor_params():

  $ make BOARD=bolt
  $ nm build/bolt/common/charge_state.o  | grep vendor
  $ nm build/bolt/driver/battery/link.o | grep vendor
  $

Change-Id: I48a535208bdcfd3d2cb26f6f15a28a728dbe4d0b
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/175731
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-11-05 22:46:09 +00:00
Bill Richardson
d64de2bb1b Show smart battery status with 'battery' command
The smart battery status register holds some useful info. This displays it
along with all the other stuff.

This decodes the alarm and status bits, but not the error code, since that
field is only valid immediately after a failed i2c transaction (that's how
the battery indicates error). Since we do all sorts of automatic battery
probing in other threads, that value will never be reliable when we run the
"battery" console command.

BUG=none
BRANCH=none
TEST=manual

Run "battery". You should see a new line amongst the output:

  Status:    0x00c0 DCHG INIT

Change-Id: I5e684198af2cf7767f89786c91a7d946ad95d4c2
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/175659
2013-11-05 22:45:21 +00:00
Randall Spangler
00682eb80f cleanup: Still more TODO comments
More of same.  Comment changes only; no code changes.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all platforms; pass unit tests

Change-Id: I8c42ed7d332cd9d461067e1aeac670855106cbcd
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/175405
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-11-02 01:07:10 +00:00
Randall Spangler
2dc1418ccd cleanup: Assorted TODO comments
Remove comments if no longer applicable, or assign bug numbers if they
still are.  Tidy some debug output.  No code changes other than the
debug output.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all platforms, pass unit tests

Change-Id: I2277e73fbf8cc93f3b1b35ee115e0f2f52eb8cf9
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/175215
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-10-31 18:43:39 +00:00
Randall Spangler
235a735f7a cleanup: Add bug number to TODO comment in charger driver
And tidy the code a little.

BUG=chrome-os-partner:22238
BRANCH=none
TEST=compile kirby

Change-Id: Ib424e66c5068297cc48ee3d3b8f900baea432bbc
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/174570
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-10-25 01:33:48 +00:00
Randall Spangler
df541c6ffd cleanup: rename I2C_PORT_HOST to I2C_PORT_MASTER
Previously, it was really confusing whether I2C_PORT_HOST meant the
port where the EC was the master, or the port used to talk to the AP.

No functional changes, just a global find/replace and some tidying of
unused comments.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all platforms; pass unit tests

Change-Id: Ia591ba4577d3399729556e0234ba0db3a0e3c5ea
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/174546
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2013-10-25 01:32:15 +00:00
Randall Spangler
4a1ecb67f9 pit: Fix battery cutoff command to use deferred function call
Rather than hackily sending a host response before sending the battery
cutoff command, just put the cutoff command in a deferred function
call and respond normally to the host command.

BUG=chrome-os-partner:23568
BRANCH=none
TEST=On battery power, 'ectool batterycutoff' prints success, then the
     system loses power due to battery cutoff.

Change-Id: Ic42d08ef94a10f89d093290cda63da01fca985a5
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/174573
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-10-25 00:29:00 +00:00
Randall Spangler
2ad076f8a0 cleanup: Rename and move header files
Device-specific headers belong in driver/ or chip/.  The include/
directory should be for common interfaces.

Code should not normally need to include driver-specific headers.  If
it does, it should use the full relative path from the EC project root
(for example, drivers/charger/bq24715.h).

Change-Id: Id23db37a431e2d802a74ec601db6f69b613352ba
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/173746
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-10-23 21:27:40 +00:00
Randall Spangler
8cf03ac056 Move source files to driver/ and power/ subdirs
The common/ subdir was getting cluttered.  Move drivers for external
components to a new driver/ tree, and move what used to be called
chipset_*.c to a new power/ directory.

This does not move/rename header files or CONFIG options.  That will
be done in subsequent steps, since moving and modifying .c files in
the same CL is harder to review.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all boards; pass unit tests

Change-Id: I67a3003dc8564783a320335cf0e9620a21982d5e
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/173601
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-10-23 20:07:25 +00:00