summaryrefslogtreecommitdiff
path: root/driver
Commit message (Collapse)AuthorAgeFilesLines
* battery: don't talk to battery after cut-offLouis Yung-Chieh Lo2014-04-251-3/+30
| | | | | | | | | | | | | | | | | | | | | Add a shortcut in smart battery driver and i2c passthru. Once the battery cut-off order is submitted (in the factory line), the EC will no longer talk to battery. BUG=chrome-os-partner:28248 BRANCH=tot,nyan TEST=See below > remove AC, cutoff: expect system is off. > cutoff, then remove AC: expect system is off. > cutoff, wait for 1 min, then remove AC: expect system is off. Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org> Change-Id: Ied963c19d17d581ce99e4543469cf2fa165f0439 Reviewed-on: https://chromium-review.googlesource.com/196657 Tested-by: Yung-chieh Lo <yjlou@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Yung-chieh Lo <yjlou@chromium.org>
* Big: Correct the charger IC drivercloud_lin2014-04-243-0/+241
| | | | | | | | | | | | | | Add bq24735 driver and move to here for further developing BRANCH=big BUG=None TEST=test basic charing/discharging function Change-Id: I66c22a29cf94383cec86c5cf53db82494504fa77 Reviewed-on: https://chromium-review.googlesource.com/196541 Reviewed-by: Yung-chieh Lo <yjlou@chromium.org> Tested-by: Lin Cloud <cloud_lin@compal.com> Commit-Queue: Lin Cloud <cloud_lin@compal.com>
* accel: add accel driver for lsm6ds0Alec Berg2014-04-233-223/+330
| | | | | | | | | | | | | | | | | | | | This adds the basics for the accelerometer potion only of the ST lsm6ds0 accel/gyro. Still need to add the acceleration interrupt functionality, and all of the gyro portion of the chip. BUG=none BRANCH=none TEST=Tested on a samus prototype hacked up to have the lsm6ds0 connected to the EC i2c bus. Added motion sense task to the samus tasklist, added accelerometer information to the samus board file, and tested console functions interacting with accelerometer. The data seems reasonable, and can successfully change data rate and range. Change-Id: I7949d9c20642a40ede82dc291b2c80f01b0a7d8b Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/196426 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Smart Battery: Buffer battery parameters while they are updatedDave Parker2014-04-121-33/+34
| | | | | | | | | | | | | | | | | | | | | | BUG=chrome-os-partner:27736 BRANCH=ToT TEST=Verify battery charges and 'battery' console command returns sane values. Original-Change-Id: I57d9d432bce4ed28678dddc43fa5166905525557 Signed-off-by: Dave Parker <dparker@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/193338 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Conflicts: driver/battery/smart.c Change-Id: Idae79859961da888e652b3af306ba49c467b412e Reviewed-on: https://chromium-review.googlesource.com/193655 Tested-by: Dave Parker <dparker@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Dave Parker <dparker@chromium.org>
* accel: add host command to modify accel params and add ectool commandAlec Berg2014-04-052-88/+180
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Created a host command to set/get various motion sensor parameters and added an ectool command to use that host command. The host command is created such that the first argument is a sub-command. Sub-commands created include: dump: dumps all current motion sensor data info: returns general information about each motion sensor ec_rate: set/get the EC sampling rate of sensors sensor_range: set/get the sensor range (ie +/- 2G,4G,8G) sensor_odr: set/get the sensor output data rate (ie 50Hz, 100Hz, ...) For sensor_range and sensor_odr parameters, since the host doesn't know what are valid values for the parameter, the host can specify to round up or down to the nearest valid value. For example, the host can specify to set the output data rate to at least 100Hz, and the EC will return the closest valid output data rate that is at least 100Hz. BUG=chrome-os-partner:27321 BRANCH=rambi TEST=Test on a glimmer using ectool from vt-2 prompt: > ectool motionsense help Usage: motionsense - dump all motion data motionsense info NUM - print sensor info motionsense ec_rate [RATE_MS] - set/get sample rate motionsense odr NUM [ODR [ROUNDUP]] - set/get sensor ODR motionsense range NUM [RANGE [ROUNDUP]]- set/get sensor range > > ectool motionsense Sensor 0: 0, 0, 1024 Sensor 1: 1024, 0, 0 Sensor 2: None > ectool motionsense info 0 Type: accel Location: base Chip: kxcj9 > ectool motionsense ec_rate 10 > ectool motionsense ec_rate 1000 1000 > ectool motionsense odr 0 100000 > ectool motionsense odr 0 40000 1 50000 > ectool motionsense range 0 8 8 After running this I verified on the EC console that all the parameters were set appropriately. I tested the EC sampling rate was 1000ms by running lidangle on and making sure samples were displayed roughly every second. I verified the sensor odr and range by defining CONFIG_CMD_ACCELS and typing: > accelrange 0 8 > accelrate 0 50000 Change-Id: I444e2f0eafabd607f1c7aa78b5c4e91f6cb06387 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/192064 Reviewed-on: https://chromium-review.googlesource.com/193307 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Add host command to control charge state v2Bill Richardson2014-04-051-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This replaces the obsolete and temporary (ha!) EC_CMD_CHARGE_DUMP host command with EC_CMD_CHARGE_STATE. This is used to monitor and adjust the new charge state implementation, including any board-specific customizations. This command is a single catch-all command with multiple subcommands (similar to EC_CMD_LIGHTBAR_CMD) so that we don't have to keep adding new top-level host commands just to support incremental changes. BUG=chrome-os-partner:23776 BRANCH=ToT TEST=manual From the AP, try these commands: ectool chargestate show ectool chargestate param ectool chargestate param <NUM> ectool chargestate param <NUM> <VALUE> Watch the EC console and use its "chg" command to verify the effects of setting various params. Note: the Samus-specific fast-charging profile override is param 0x10000. You can check it with the EC console "fastcharge" command. Change-Id: Iad2f773a085bc25c05073b3eed9866f122ae9d78 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/193305 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Add charge_state_v2 algorithm for use by SamusBill Richardson2014-04-013-2/+132
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a complete rewrite of the charge_state task used by x86 platforms. Rather than having a bunch of state-specific functions, each with their own error handling and special cases, this is organized like so: Forever: 1. Read everything we can from the battery and charger. 2. Figure out what we'd like to do (including error handling). 3. Allow for customization to override that. 4. Do it. Things I need to file bugs for are marked with "TODO(wfrichar)". I'll file the bugs after this CL goes in, so that they'll have something relevant to refer to. BUG=chrome-os-partner:20881 BRANCH=ToT TEST=manual make buildall -j Try it on Samus, watch it charge from nearly empty to full, both with and without fastcharge enabled. Also undefine CONFIG_BATTERY_PRESENT_CUSTOM, plug and unplug the battery to be sure the trickle charging logic is correct when it can't tell if the battery is present. Change-Id: I3935cd3b87f322eb52178f8a675a886c16b75d58 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/191767 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Add driver for TI BQ24773 chargerVincent Palatin2014-03-293-0/+226
| | | | | | | | | | | | | | | | | | | | Add support TI BQ24773 1S/2S/3S NVDC battery charger. This is not a "Smart Battery" compliant charger IC, it should and cannot use the sbc_ helpers. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=on FruitPie, run "charger" command on the EC console, add the charger task and see the battery charging. Change-Id: I6f470184f0ce424a05007e493d802dcdb2156477 Reviewed-on: https://chromium-review.googlesource.com/191212 Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
* Add more fields and error flags to struct batt_paramsBill Richardson2014-03-282-22/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds two battery parameters that need to be monitored constantly: remaining_capacity and full_capacity (that one only changes occasionally, but we have to notify the AP when it does). It also adds the is_present field to indicate whether the battery is physically present or not (when we can tell), so we know whether to try to wake up a deep-discharged battery. Along with that, we clean up the error flags to provide indication of which fields were unable to be read, and replace the manual logical-or of all errors as they were set with a bitmask (BATT_FLAG_BAD_ANY). No functionality is changed, only new & better information is provided for use in the upcoming cleanup of the charge state machine. BUG=chrome-os-partner:20881 BRANCH=ToT TEST=make buildall -j All targets build; all tests pass. Change-Id: I4312c2fdd3cf2dd9570718e90571eff796b269db Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/191917 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* accel: added mutex to protect critical code in kxcj9 accel driverAlec Berg2014-03-272-40/+143
| | | | | | | | | | | | | | | | | | | | | | | Added a mutex in kxcj9 accelerometer driver to prevent concurrent accesses when writing to critical registers on sensor. Also added more console debugging functions behind CONFIG_CMD_ACCELS to allow writing a new range, resolution, or data rate to each sensor. BUG=chrome-os-partner:26884 BRANCH=rambi TEST=Tested by defining CONFIG_CMD_ACCELS and playing around with writing/reading various parameters on each sensor and making sure that the accelerometer is still reporting data every so often using the lidangle on command. Change-Id: Ic009951d508b125d1c479d042455713c9c8de761 Original-Change-Id: I2038f167fc8ca51723b0d1330aa090ab5158cf15 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/191173 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/191611
* accel: Add disable and re-enable accel around critical register writesAlec Berg2014-03-271-24/+138
| | | | | | | | | | | | | | | | | | According to the kionix datasheet, you are supposed to disable the accel before writing to various critical registers. We haven't had a problem thus far, but better to match the datasheet to avoid future problems. BUG=none BRANCH=rambi TEST=ran on glimmer. made sure accels still work using lidangle command. Change-Id: I363435862ed473b315afdf6d2aea64cebe3bac55 Original-Change-Id: If2d86c39c24c6ba13e118850c5e3f6c0174f4eb7 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/190486 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/191610
* accel: clapper: glimmer: Add support for accelerometer interrupt.stabilize-5696.BAlec Berg2014-03-262-8/+145
| | | | | | | | | | | | | | | | | | | | | | | | | Adding in support for accelerometer interrupt for use currently in clapper and glimmer. This is disabled by default and can be enabled with CONFIG_ACCEL_INTERRUPTS. BUG=none BRANCH=rambi TEST=Manual test on a glimmer using accelint console command. On console enter: accelint 0 32 When you tap the lid, it should fire the interrupt and print msg to console. accelint 1 32 Tap the base and it will fire another interrupt. Change-Id: Iaab324945e34d527140399ec4f06efd812a62840 Original-Change-Id: I0329112fdcae3c8adc0ca07e74fef7a591d4b9a1 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/190099 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/191549
* rambi: change EC accel sampling rate and default sensor output data rate.Alec Berg2014-03-201-2/+2
| | | | | | | | | | | | | | | | | | Two accelerometer changes: - Lower accel sampling rate when chipset is off to 10Hz. Increase sampling rate back up to 100Hz when transitioning to S0. - Change the default output data rate of the accelerometers to 100Hz which matches the EC sampling rate when in S0. BUG=none BRANCH=rambi TEST=manual testing. used lidangle command to verify that in S0, EC is sampling at 100Hz, and in S3 or lower it is sampling at 10Hz. Change-Id: Ie4e20f45f9371d674c3325a362d2729c331fac4f Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/190032 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Big: Add ectool discharge command.cloud_lin2014-03-181-0/+17
| | | | | | | | | | | | | | | BRANCH=big BUG=None TEST=Run ectool chargecontrol command with each option (normal, idle, discharge) on Big. Verifiy battery is discharging in discharge mode via EC console 'battery' command. Signed-off-by: Cloud Lin <Cloud_Lin@compal.com> Change-Id: Iab150c36df64016d06831a6a6c620742738ae2af Reviewed-on: https://chromium-review.googlesource.com/189450 Reviewed-by: Katie Roberts-Hoffman <katierh@chromium.org> Tested-by: Lin Cloud <cloud_lin@compal.com> Commit-Queue: Lin Cloud <cloud_lin@compal.com>
* rambi: fix potential bug in accelerometer initAlec Berg2014-03-081-2/+2
| | | | | | | | | | | | | | | | | | | | | Fixed a potential bug in accelerometer initialization that could result in failing to write the desired accelereometer settings. Before writing the desired settings, we first send a command to perform a software reset. While waiting for software reset to complete, if we have an I2C error, then we could interpret this as software reset complete and go on to write the accelerometer settings before the reset has actually completed. BUG=none BRANCH=rambi TEST=Code inspection. I haven't actually seen this bug, I just saw the potential for it. Change-Id: I78757106291ffbaeff27f94aa6f74c9cea81e0b9 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/189064 (cherry picked from commit 521a99e38428fcfe928616f4932b5d1167e2f6cb) Reviewed-on: https://chromium-review.googlesource.com/189233 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* samus: Add host command to read raw tmp006 dataRandall Spangler2014-03-071-0/+22
| | | | | | | | | | | | | | | This is needed to calibrate the tmp006 remote sensor values. BUG=chrome-os-partner:26581 BRANCH=none TEST='ectool tmp006raw N' works for N=0,1,2,3 And fails with invalid param for N=4. Data matches result of tmp006 ec console command. Change-Id: I04ec093c7727b55caca7d02baaf373d1ff234731 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/189207 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
* rambi: fix two bugs with accelerometer driverAlec Berg2014-03-011-2/+29
| | | | | | | | | | | | | | | | | | | | | Two bugs are: - Need to grab the I2C port mutex before performing i2cxfer. - Added sending software reset command to accelerometers on init. This is necessary because the accelerometers can be powered through an EC reboot, and it's important we restore them to a known state. BUG=none BRANCH=rambi TEST=Manually set accelerometer setting, rebooted, manually read that setting and verified it was restored to default. Change-Id: Ic3034ae39c936e07ca28458a60557b9623674ff1 Original-Change-Id: I0ea571f3a8dc46052128def24cbb5c1c29638469 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/188349 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/188387
* Mark some private functions static in unused driverBill Richardson2014-02-281-2/+2
| | | | | | | | | | | | | | | | | The BQ24192 driver exports some functions that should be static. Let's mark them so, mostly so I don't keep finding them when I search through the code for common functions. Note that nothing in the ToT branch uses this module anyway. BUG=chrome-os-partner:23815 BRANCH=ToT TEST=make buildall -j Change-Id: I012111a2c9b9b84f0f3bfacc3bdc8804a83116a6 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/188179 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Enable IDPM for bq24715 charge controllerChromeOS Developer2014-02-262-3/+6
| | | | | | | | | | | | | | | | | | | Dynamic Power Management enables proper regulation of the input adapter current set in board.h. BUG=chrome-os-partner:24933 BRANCH=None TEST=Power a DUT with a bench supply. Verify the input current doesn't exceed the input current limit set in board.h while the system is under load and charging the battery. Change-Id: Ie68d92afe0ef89c691f460d120f8574cb17e2c4e Original-Change-Id: Ida6b05f1d89b21d7cf1553f5e9936360679f8149 Signed-off-by: Dave Parker <dparker@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/187517 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/187911
* rambi: Accelerometer driver for kxcj9.Alec Berg2014-02-223-0/+384
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Added accelerometer driver for kxcj9 accelerometers. Currently the accelerometers aren't being used by anything, but there are console commands, accelwrite and accelread, to perform transactions. BUG=none BRANCH=rambi TEST=Used EC console commands to test that accelerometers respond and data looks reasonable. Original-Change-Id: I6ddcf04ec278adeacb148c19b10c3c296b467954 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/184693 Reviewed-by: Randall Spangler <rspangler@chromium.org> (cherry picked from commit 5e1d2052b034b2400b98b2126243e01397a2ce56) Conflicts: board/clapper/board.c board/clapper/board.h board/glimmer/board.c board/glimmer/board.h Change-Id: If8744ddc3273fc08e29830adfd068dc302dd120a Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/187432 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Support discharge on BQ24715 for Rambi and SquawksJustin Chuang2014-01-162-3/+19
| | | | | | | | | | | | | | | | | | | BUG=chrome-os-partner:25031 BRANCH=rambi TEST=Manually make BOARD=peppy make BOARD=falco make BOARD=rambi make BOARD=squawks On rambi and squawks, connect charger ectool chargecontrol discharge ectool i2cread 16 0 0x16 0x0a It should return 16-bit negative integer. Change-Id: I8a8dfa90d2ad82595ac7a420c3c8ffc13b12cde6 Signed-off-by: Justin Chuang <jchuang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/182586 Reviewed-by: Dave Parker <dparker@chromium.org>
* cleanup: Remove checkpatch warningsRandall Spangler2013-12-192-29/+29
| | | | | | | | | | | | | | | | This make minor syntactic changes and renames some camel-cased symbols to keep checkpatch from complaining. The goal is to reduce the temptation to use 'repo upload --no-verify'. This is a big furball of find/replace, but no functional changes. BUG=chromium:322144 BRANCH=none TEST=build all boards; pass unit tests Change-Id: I0269b7dd95836ef9a6e33f88c003ab0f24f842a0 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/180495
* Clean up g781 temp sensor function namesChromeOS Developer2013-12-091-35/+35
| | | | | | | | | | | | | | | 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>
* Basic driver for tmp432 temperature sensorChromeOS Developer2013-12-073-0/+314
| | | | | | | | | | | | | | | | | | | | | 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>
* Move battery temp ranges to battery_info structRandall Spangler2013-12-031-9/+6
| | | | | | | | | | | | | | | | | | 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>
* Cleanly force battery to mAh mode when reading capacityRandall Spangler2013-12-022-38/+27
| | | | | | | | | | | | | | | | | 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
* Add battery_get_params()Randall Spangler2013-12-023-108/+93
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Add EC_MEMMAP_ALS, update it once per secondBill Richardson2013-11-081-12/+19
| | | | | | | | | | | | | | | | | | | | | | 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>
* Add ALS driver for light sensors connected to ECBill Richardson2013-11-073-0/+81
| | | | | | | | | | | | | | | | | 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
* Cleanup: only compile battery_vendor_params() when enabledBill Richardson2013-11-051-34/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Show smart battery status with 'battery' commandBill Richardson2013-11-051-0/+5
| | | | | | | | | | | | | | | | | | | | | | | 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
* cleanup: Still more TODO commentsRandall Spangler2013-11-021-2/+2
| | | | | | | | | | | | | 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>
* cleanup: Assorted TODO commentsRandall Spangler2013-10-311-3/+3
| | | | | | | | | | | | | | | 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>
* cleanup: Add bug number to TODO comment in charger driverRandall Spangler2013-10-251-7/+8
| | | | | | | | | | | | | | 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>
* cleanup: rename I2C_PORT_HOST to I2C_PORT_MASTERRandall Spangler2013-10-254-9/+9
| | | | | | | | | | | | | | | | | 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>
* pit: Fix battery cutoff command to use deferred function callRandall Spangler2013-10-251-16/+14
| | | | | | | | | | | | | | | | 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>
* cleanup: Rename and move header filesRandall Spangler2013-10-2315-6/+607
| | | | | | | | | | | | | | 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>
* Move source files to driver/ and power/ subdirsRandall Spangler2013-10-2316-0/+3243
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>