Commit Graph

514 Commits

Author SHA1 Message Date
Marco Chen
a2e2be193a OPT3001: Support MOTIONSENSE_CMD_SENSOR_[OFFSET|RANGE] for calibration.
1. The original driver of OPT3001
  a. didn't support to process the command of offset.
  b. implemented command of range to setter/getter of Range Number Field
     of chip.
But reffering to cros_ec_light_prox.c from linux kernel side, these two
commands are actually leveraged for in_illuminance_calib[bias|scale]
and these calibration factors should be applied into raw lux value read
from the chip.

2. Move ALS in Poppy / Soraka boards from ALS_TASK to MOTIONSENSE_TASK.

3. Mofify parameters of ALS in Reef board in order to adapt changes
here.

BUG=b:69236269
BRANCH=none
TEST=Manually test on the DUT.

Change-Id: Ic3b593feb3e4bc6da0bada6b5d614975f0cf2280
Signed-off-by: Marco Chen <marcochen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/774341
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-11-26 05:21:39 -08:00
Nicolas Boichat
4cb524de67 touchpad_elan: Rename task/interrupts functions
Change the names to generic touchpad_* functions, instead of
vendor-specific names. Makes it a little easier to add drivers
for other touchpads.

Also fix console_channel.inc to add the channel whenever any
touchpad is used.

BRANCH=none
BUG=b:68934906
TEST=make buildall -j

Change-Id: I6d268db5ebd53db272fb2ee7bbf06bbe80845734
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/778750
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-11-20 04:53:20 -08:00
Gwendal Grignou
f587852570 motion_sense: Put set_range in common code
At the end of the sensor initialization, all _init sensor routines set
the range to the default value from board.c file.
Put all the code in a single place, move it from sensor_common.c to
motion_sense.c.

BUG=none
BRANCH=none
TEST=compile

Change-Id: If89cf27c6438e0f215c193d68a480e027110174c
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/767610
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-11-17 20:18:30 -08:00
Sam Hurst
ee208a57b7 PS8751 and PS8805 does not generate BIST Carrier Mode 2
On Nasher, sending TCPC_TX_BIST_MODE_2 to register 0x50 on the
PS8751 TCPC does not generate BIST Carrier Mode 2.

BUG=b:68337231
BRANCH=None
TEST=`make -j buildall`
Generated an eye diagram for Nasher on the GRL USB-PD test station
Signed-off-by: Sam Hurst <shurst@chromium.org>

Change-Id: Ia6e5df54a183c989a68d12be3a46896e3daea738
Reviewed-on: https://chromium-review.googlesource.com/741090
Commit-Ready: Sam Hurst <shurst@google.com>
Tested-by: Sam Hurst <shurst@google.com>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-11-14 16:03:23 -08:00
Nicolas Boichat
7fdcb8bf86 usb_update: Add support for touchpad debugging feature
We support touchpad-specific debugging feature over the USB update
protocol. This will be used to fetch raw data from the sensor,
without requiring to remove the write-protect screw.

BRANCH=none
BUG=b:63993891
TEST=./usb_updater2 -g 00 -d 18d1:502b

Change-Id: I46dfd97aaa17b73a5893fe1e8c62327a302f829b
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/763574
Reviewed-by: Chun-ta Lin <itspeter@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-11-14 03:22:31 -08:00
Aseda Aboagye
358e249916 isl9238: Don't reread PROG pin or reload ILIM.
The ISL9238 has a functionality where it will reload the adapter current
limit from a strap which is read from the PROG pin.  This is problematic
when we decide to set the current limit prior to AC actually being
inserted.  This commit disables this functionality from the charger.

It seems however that the charger will read the PROG pin and reload the
ILIM at least once before respecting the bits.

BUG=b:67120928, b:66017697
BRANCH=None
TEST=Plug and unplug and then plug again AC.  Verify that the default
current limit is not set by the charger automatically.

Change-Id: Ia8e8742843f6ceb286635b31e0fe5c070a2b6dfe
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/759693
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Shamile Khan <shamile.khan@intel.corp-partner.google.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-11-14 00:42:42 -08:00
Aseda Aboagye
adf00a969f isl923x: Change charger_post_init().
The ISL9237/8 can both be powered by VSYS or AC, therefore, it's not
needed to reinitialize the charger after AC is present.

This commit moves the contents of charger_post_init() into a new init
function that will be run once at HOOK_INIT time.

BUG=b:67964166
BRANCH=None
TEST=make -j buildall

Change-Id: I637b1209f86f686013fee0783914fa1596076fa6
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/759692
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-11-14 00:42:42 -08:00
Aseda Aboagye
f539b9de81 isl9238: Raise min input voltage limit.
The ISL9238 has functionality for a input voltage regulation loop.  By
default, the regulation reference voltage is set to 4096mV, however we
can be kinder to chargers by raising this regulation reference.  In
testing, there appears to be insignificant change in current pulled at
the higher limit.

BUG=b:67964166
BRANCH=None
TEST=Flash a board with a ISL9238, verify that 0x4b reads as 0x0d00.
TEST=make -j buildall

Change-Id: I920c4b922106fca3001f2759cad0479a368f735b
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/745527
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-11-13 15:25:49 -08:00
Rong Chang
d6c836b4da pi3usb9281: sync USB switch hardware control with switch state
When sysjump to another image, if USB switch state and HW switch control
are not sychronized, the switch can be left in open state. This CL
resets USB switch on init to close USB.

BRANCH=oak
BUG=b:36234142
TEST=manual
  plug BC1.2 charger, sysjump to another EC image and unplug the chager.
  check pi3usb9281 control register(02h) bit2 == 1.

Change-Id: Iaadfaf51064ed1508271e974b9caf88b96bbe008
Signed-off-by: Rong Chang <rongchang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/502835
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-11-13 02:51:44 -08:00
Shawn Nematbakhsh
0354ad02cb bd9995x: Leave USB data switches closed on PD power swap
In order for BC1.2 detection to succeed, USB data switches must be
open. Previously we performed BC1.2 detection whenever VBUS transitioned
up to 5V, including on power swap. In fact, there is no need to do BC1.2
detection on a PD-capable port, since we will always charge using the
USB-C or PD negotiated ILIM. Skip BC1.2 detection on power swap (and
more generally when a partner port is known to speak PD) by manually
triggering BC1.2 detection. In addition, manage USB switch state
differently, so that "auto mode" is only enabled during BC1.2 detection.

BUG=chromium:780905
BRANCH=gru
TEST=Attach USB-PD phone capable of role swap. Verify USB 2.0 device is
enumerated on plug, and not re-enumerated through a series of
"pd # swap power" commands on the EC console. Also verify BC1.2 charging
and PD charging are still functional on kevin.

Change-Id: I1d7d4dee3bc8d2e7885e7adb49ded84b4f515ad5
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/755878
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-11-07 15:25:22 -08:00
Shawn Nematbakhsh
f4ee6caa66 bd9995x: Use fixed PD-port-to-VBUS/VCC mapping
The bd9995x driver was written to allow any PD port # to be VBUS or VCC,
but the mapping is broken in a few places. Since all boards use VBUS =
port 0, remove the conversion entirely.

BUG=chromium:781849
BRANCH=kevin
TEST=Verify PD and BC1.2 charging still works on kevin.

Change-Id: I3687866835d1684342d9f746d91b3a6079ab5cc4
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/755000
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-11-07 12:17:43 -08:00
Ryan Zhang
f48cf0e8b2 Fizz: Modify thermal table
Modify thermal table for Fizz
reference patches: 627542, 288256, 329359

       on  off  RPM
step0              0
step1  16   2   2800
step2  27  18   3200
step3  35  29   3400
step4  43  37   4200
step5  54  45   4800
step6  64  56   5200
step7  97  83   5600

Prochot degree:
	active when t >= 88C
	release when t <= 85C
Shutdown degree: when t >= 90C

BUG=b:67487721, b:64439568
BRANCH=master
TEST=fan target speed follows table, make -j buildall pass

Change-Id: I3378668a560b8ddc568fe9cbf2703613fad8e4b6
Signed-off-by: Ryan Zhang <ryan.zhang@quanta.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/729606
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2017-11-06 13:48:38 -08:00
Philip Chen
10dc1b8aad battery/max17055: Allow charging
We didn't set BATT_FLAG_WANT_CHARGE in battery_get_params(), so
battery command always shows 'charging not allowed'.

Let's set the flag in the same condition as it is set in
battery/smart.c.

BUG=b:68027469
BRANCH=none
TEST='battery' on EC console shows 'Charging: Allowed'

Change-Id: Ifbdb6aee2572c8fc5f67103ca940738fb221ce5d
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/749025
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-11-03 01:53:39 -07:00
Philip Chen
f28ab5c2ec battery/max17055: Use macros to clean up duplicate code
BUG=none
BRANCH=none
TEST=manually test on Scarlet rev2 and confirm max17055 still
initializes and works by 'battery' command

Change-Id: I3f553a1392cc1c4364ac605111564501bd706ec2
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/737712
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Philip Chen <philipchen@chromium.org>
2017-11-02 11:07:13 -07:00
Philip Chen
bca028445d charger/rt946x: Implement VBUS measurement
BUG=b:67991345
BRANCH=none
TEST=Plug in guppy on Scarlet rev2, 'ectool usbpdpower' on console,
and see VBUS is measured as 4975mV

Change-Id: I960290745a343ef597fa32575491d936269ae628
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/732084
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-11-01 14:06:32 -07:00
Dino Li
73d0ed0b79 driver: add IT5205 mux driver
Add support the ITE IT5205 Type-C USB alternate mode mux.

BRANCH=none
BUG=none
TEST=1. Successfully verify chip ID.
     2. Verify set_mux() and get_mux() functions set and return
        consistent values.
     3. The mux control register setting as expected after set_mux().

Change-Id: I9ff066dc9e74683df1371b70290e2aeaa86cb96b
Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
Reviewed-on: https://chromium-review.googlesource.com/741211
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-10-31 21:49:24 -07:00
Gwendal Grignou
8a2d0a5de6 driver: BMM150: Set max frequency based on repetitions setting
The compass uses oversampling to produce accurate values.
MAX_ODR is functions of the repetitions setting.
80Hz is too high, calculate the frequency based on preset setting.
Currently, we use 'SPECIAL' that was calculated for Ryu.

BUG=b:68394559
BRANCH=eve,reef,poppy
TEST=Check with ectool motionsense info 3 the frequency is around 30Hz.
Before:
Min Frequency:              781 mHz
Max Frequency:              80000 mHz
After:
Min Frequency:              781 mHz
Max Frequency:              29579 mHz
Check with AIDA64 the compass is not stuck and return changing values.

Fixup of CL/570482

Change-Id: Idcfed1418f59e755e5647d018351c6a7397ffe1b
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/742146
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-10-30 14:03:10 -07:00
Aseda Aboagye
de63c62822 driver: Rename pmic_tps650830 -> pmic_tps650x30.
The registers seem to be the same for the TPS650930, therefore, this
commit just renames the register map to have a more generic name.

BUG=None
BRANCH=None
TEST=make -j buildall

Change-Id: Ib1c604b29e7f0e47cc036e042fe597f644d7ad36
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/736311
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-10-26 20:20:59 -07:00
Philip Chen
a109ebc3b1 battery/max17055: Measure temperature using external thermistor
By default max17055 measures from internal temperature sensor.

BUG=b:68170538
BRANCH=none
TEST=place a heat source on top of the battery pack and see
temperature rise from 'battery' command

Change-Id: I1c0bb981e366a8a73d2e14e6c1fc92327069e8f1
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/735080
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-10-24 07:29:43 -07:00
Aseda Aboagye
df3820165f driver: ppc: Add support for TI SN5S330.
This commit adds a basic driver for the TI SN5S330.  This driver just
sets up the IC and provides an API to turn on or off the PP2 FET.

BUG=b:67663166, b:67663124
BRANCH=None
TEST=Enable code for zoombini; Flash a board which has the SN5S330
stuffed; Verify that we're able to perform PD negotiation and negotiate
all the way up to 20V.
TEST=Boot only on AC.  sysjump to RW, verify that board does not
brownout.

Change-Id: I9c147ee8465eed878843cf902db301d62e8f627e
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/722104
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-10-23 04:28:24 -07:00
Aseda Aboagye
61a6a3814f bq24392: Make chip_en active low.
The GPIO that turns on Vbus for the BQ24392 is active low.  This commit
changes the driver to make it clear that the enable is active low.
Additionally, the 5V rail is turned on prior to performing detection and
will be turned off if the AP is off.

For zoombini, since the chipset task can also control the 5V rail,
CONFIG_POWER_PP5000_CONTROL is enabled to do so in a task-safe way.

BUG=b:65992382, b:65991615
BRANCH=None
TEST=Verify that Vbus is turned on and the BQ24392 can output high on
charge detect pin.

Change-Id: Ib96ef9736ccc7fa285a3642ec6f3824a1df8f931
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/676762
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-10-23 04:28:23 -07:00
Nicolas Boichat
ccfc005fa4 isl9238: Add support for providing power using OTG
BRANCH=none
BUG=b:66575472
TEST=Flash lux and wand, wand can provide power to lux.

Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Change-Id: I59091c509b78bacf9f382550ab380a77fbf68ba9
Reviewed-on: https://chromium-review.googlesource.com/725122
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-10-20 06:08:58 -07:00
Philip Chen
4e294f911a scarlet: Lower VMIVR
Lower minimum input voltage regulation from 4.4V to 4V.

BUG=b:67932466
BRANCH=none
TEST=manually poke the register value and confirm VMIVR is 4V

Change-Id: Ia1af423612a35ef48ecdd2987cdcc7d10f81bc28
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/727411
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: David Schneider <dnschneid@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-10-19 21:15:29 -07:00
Nicolas Boichat
7501654d20 chip/stm32/usart: Add flags to usart_config
Allows setting TXINV/RXINV bits.

BRANCH=none
BUG=b:65697962
TEST=make BOARD=wand -j

Change-Id: Ib1bb290cd9758c53b98c8fc1ca1a9369c8cff39e
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/694561
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-10-18 08:30:16 -07:00
Nicolas Boichat
8434ed8f10 isl9237: Fix HW ramp setting in charger_post_init
While introducing support for isl9238, I accidentally used an
incorrect config option (CONFIG_ISL9237), instead of
CONFIG_CHARGER_ISL9237.

BRANCH=none
BUG=b:35585464
TEST=make buildall -j

Fixes: b1101b8ed6 charger: isl923x: Add support for ISL9238

Change-Id: I2f62f3fbefbc60cc9d83726ef88a66c5c9f1b245
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/725121
Reviewed-by: Rong Chang <rongchang@chromium.org>
2017-10-18 06:15:05 -07:00
Shawn Nematbakhsh
b87fe062ec charge_ramp: Move ramp allowed / ilim callbacks to common code
The decision on whether to ramp (and how high) depends on the quirks of
charger identification, so move the decision out of board, into the
drivers that implement usb_charger.

Also, rename CONFIG_CHARGE_RAMP to CONFIG_CHARGE_RAMP_SW, to better
contrast with the existing CONFIG_CHARGE_RAMP_HW.

BUG=None
TEST=Manual on kevin, verify ramp occurs when port plugged into Z840
workstation.
BRANCH=None

Change-Id: I5b395274133837a18a4f4ac34b59b623287be175
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/702681
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-10-06 13:47:12 -07:00
Gwendal Grignou
ad918d6c56 driver: bm160: Fix minimal gyro frequency
Was set in Hz unit instead of mHz.
The minimal frequency of the gyroscope is 25Hz.
By setting it at 25mHz, we make believe that the gyro was also
supporting 5Hz or 10Hz: the test would complain when instead the samples
came with a 25Hz.

Fix up of cl/482703

BUG=b:65000611
TEST=compile
BRANCH=caroline,eve,twinkie

Change-Id: I162d0d2e9b545af82698d8d484875761f426efe4
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/674003
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-09-20 16:37:57 -07:00
Gwendal Grignou
13fcc5ad84 driver: lsm6dsm/lsm6dsl: Fix LSM6DSM_ODR_TO_NORMALIZE macro
Using builtin function in macro.
Compact macros.

BUG=none
BRANCH=master
TEST=Tested on discovery BOARD with LSM6DSM sensor connected
to I2C master interface of target board.
Using accelrate motion sense console command is possible to
test with different data rate: all supported ODR has been tested
for acc and gyro

Change-Id: Icb11f90254521715dfb2abb5bac6eb87ce45b92d
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Reviewed-on: https://chromium-review.googlesource.com/465375
Commit-Ready: mario tesi <mario.tesi@st.com>
Tested-by: mario tesi <mario.tesi@st.com>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-09-20 05:50:22 -07:00
Chun-Ta Lin
e18d9dd530 hammer: Support different IC types in touchpad FW update
Some Elan touchpad ICs have a different firmware sizes (48, 56, or 64
KB). We use CONFIG_TOUCHPAD_VIRTUAL_SIZE, set in the board file, to
determine the appropriate size, and, at runtime, we sanity check the
firmware size according to the IC type reported by the touchpad.

BRANCH=none
BUG=b:65188846
TEST=Manually modify the CONFIG_TOUCHPAD_VIRTUAL_SIZE in hammer,
     executed and verified both (1) "EC_ERROR_UNKNOWN" returned
     (2) ic_type shows 0x09 on EC console
TEST=Successfully flashing 48k firmware using CL:658920 on hammer and
     56k firmware on staff. With success here, we specifically test
     with different firmware version and make sure it reflected in
     hammerd's touchpad info.

Change-Id: Ib30917d8376d4a2e8b6137daabad2341ac48d1f8
Signed-off-by: Chun-Ta Lin <itspeter@google.com>
Reviewed-on: https://chromium-review.googlesource.com/664937
Commit-Ready: Chun-ta Lin <itspeter@chromium.org>
Tested-by: Chun-ta Lin <itspeter@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-09-14 22:25:02 -07:00
Lin Huang
3c2adda326 battery/max17055: update battery remaining capacity message dynamic
kernel will get the battery info through command "ectool battery",
so we need to get the remaining capacity dynamic.

BUG=b:65494883
BRANCH=none
TEST=run "ectool battery" in kernel, and get the battery info.

Change-Id: Idf824f6dc1e72acd17156c03d81c0ca87adc109f
Signed-off-by: Lin Huang <hl@rock-chips.com>
Reviewed-on: https://chromium-review.googlesource.com/658160
Reviewed-by: Philip Chen <philipchen@chromium.org>
2017-09-13 21:47:07 -07:00
Shawn Nematbakhsh
5ec58b35f1 cleanup: Remove lucid and snoball boards
BUG=None
TEST=`make buildall -j`
BRANCH=None

Change-Id: I667e471d4d9187f530da7ae8807c8aa339a17847
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/663817
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-09-12 16:17:07 -07:00
Chun-Ta Lin
b5ff2f599e driver/touchpad_elan: Add support for FW updating
Provides touchpad_update_write functions that fw_update.c uses
to update the FW over the USB updater interface.

BRANCH=none
BUG=b:63993173, b:65188846
TEST=./usb_updater2 -t touchpad.bin
CQ-DEPEND=CL:593373

Change-Id: I5246cbfa65311cd6f0b1872f9bbc164f3a972153
Signed-off-by: Chun-Ta Lin <itspeter@google.com>
Reviewed-on: https://chromium-review.googlesource.com/601814
Commit-Ready: Chun-ta Lin <itspeter@chromium.org>
Tested-by: Chun-ta Lin <itspeter@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-09-12 04:19:32 -07:00
Dino Li
103108ec21 tcpm: it83xx: enable cc voltage detector after vconn is offed
We found a potential risk that voltage might fed back into EC Vcore.
If the CC pin voltage detector is enabled and there is an unexpected
voltage source over 3.3v fed back into EC, this might cause an
exception or unknown reset.

BRANCH=none
BUG=none
TEST=The voltage detector is enabled after vconn is offed.

Change-Id: I78975fa195eef0b96056a39ee3c6d92c3bb6f8c0
Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
Reviewed-on: https://chromium-review.googlesource.com/647673
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-09-08 22:08:54 -07:00
Shawn Nematbakhsh
902706a2eb cleanup: Remove duplicate BD9995X CONFIGs
BUG=chromium:700933
BRANCH=None
TEST=`make buildall -j`

Change-Id: Id76fe93612fcd1ef924d7fa94479c45a52db046b
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/648566
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-09-02 13:01:52 -07:00
Nicolas Boichat
72252db342 touchpad_elan: Discard zero finger clicks
Do not report click events when no finger is present on the touchpad.

BRANCH=none
BUG=b:65098167
TEST=Bend case, hear click, but no event reported in evtest.

Change-Id: I0385213102dab0775e1b6906cb3a45933deac757
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/637288
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-09-01 05:34:58 -07:00
Caveh Jalali
c1e5671e56 anx3429: force chip reset on PD_RESUME
we need to properly restart the anx3429 after a firmware update.
simply initializing the chip doesn't seem to get it to reload its
firmware - at least not the portion of the chip that implements the
firmware version register.  so, we explicitly power down and reset the
chip before reinitializing it to force it to run the new firmware.

the chip also needs a 10ms "off" time so the reset is properly seen by
the chip, so i did a light refactoring of the code paths that reset
the anx3429.

TEST=used 2 different firmware blobs and verified it switches between
	them during software sync.

BRANCH=none
BUG=b:35586895

Change-Id: I967898dd906f21bdc5bc4ce9c1dff9f873d198c1
Signed-off-by: Caveh Jalali <caveh@google.com>
Reviewed-on: https://chromium-review.googlesource.com/631976
2017-08-29 22:08:20 -07:00
Philip Chen
113a561302 charger/rt946x: Fix the function name
BUG=b:63739819
BRANCH=none
TEST=build scarlet when 'CONFIG_CHARGER_ILIM_PIN_DISABLED'
is turned on

Change-Id: I692346031867160774344e67e0a7e936278820a1
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/639917
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-08-29 19:37:03 -07:00
Shawn Nematbakhsh
4e46386877 tcpm: fusb302: Round VNC and Rd thresholds to nearest step
fusb302 determines attach / no-attach (and Rd / Ra) by comparing CC
voltage against an MDAC output (42 mV steps). The previous 'floor'
calculation was particularly bad for 3.0A Rp (2600 / 42 = 61, 61 * 42 =
2562 mV - 21 = 2551 mV actual threshold, ignoring other error sources).
Reduce the chance of error by rounding our thresholds, which also
matches the suggested thresholds in the datasheet.

BUG=chromium:758608
BRANCH=gru
TEST=Attach problematic dingdong, verify we don't enter an attach /
detach loop.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I9211782da0fdad8339246e272952ba1930b69851
Reviewed-on: https://chromium-review.googlesource.com/633276
Reviewed-by: Joe Bauman <joe.bauman@fairchildsemi.com>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
(cherry picked from commit 311b3e4e15fd37ea2ab151edb8b8a468e93355fd)
Reviewed-on: https://chromium-review.googlesource.com/638694
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-08-28 15:24:14 -07:00
Shawn Nematbakhsh
98405d4eae charger: bd9995x: Disable topoff mode
Zero ITERM_SET to keep the charger out of topoff mode, since it has
undesirable side-effects related to dead / low battery charging.

BUG=b:35575421
BRANCH=reef
TEST=Previous testing on kevin with same register setting.

Change-Id: Ic1dd280e1069d410895498c0f72989654a6b8c63
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/636152
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2017-08-28 10:55:40 -07:00
Caveh Jalali
e4997a631e anx3429: read chip firmware version during init
fetching the chip firmware version toward the end of the chip
anx74xx_tcpm_init() sequence is a good place to do this.  we need this
info in any case and this is a safe place to access device registers
and cache the values.  subsequent chip firmware queries typically
return the cached value.  also, tcpci_tcpm_init() is already
structured this way.

TEST=verified with follow-up CL that firmware update succeeds and new
	version is reported

BRANCH=none
BUG=b:35586895

Change-Id: Ic3fd07bbf8a220bfd506d59d8a1f3ea25b14e94c
Signed-off-by: Caveh Jalali <caveh@google.com>
Reviewed-on: https://chromium-review.googlesource.com/634513
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-08-25 12:09:03 -07:00
Caveh Jalali
68dfee896e anx74xx: enable driver "release".
TEST="make buildall" succeeds, "make runtests" passes for reef.

returning SUCCESS instead of UNIMPLEMENTED from .release() means the
pd_task() is allowed to reinitialize the TCPC when coming out of
PD_STATE_SUSPENDED or similar scenario.

TEST=verified anx3429 firmware update succeeds, USB port still usable
	for charging after update.

BRANCH=none
BUG=b:35586895

Change-Id: I1a624ccf25dfa6468de72f8564f936bc0a35edb1
Signed-off-by: Caveh Jalali <caveh@google.com>
Reviewed-on: https://chromium-review.googlesource.com/596797
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-08-24 17:20:42 -07:00
Philip Chen
13f49164ad charger/rt946x: Disable battery thermal protection
We'll handle cell temperature from fuel gauge/battery side.

BUG=b:64806333
BRANCH=none
TEST=monitor charge current through 'battery' console command

Change-Id: I82944de8d1e8834ca1f75c1f616b220e55d94f0e
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/626725
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-08-22 21:34:42 -07:00
Vijay Hiremath
59ce941927 tcpm: Configure board specific post TCPC init
Some boards have TCPC configurations post TCPC initialization.
Added code to support those configurations.

BUG=b:64531818
BRANCH=glkrvp
TEST=Manually verified on GLKRVP. External GPIOs of PTN5110
     are configured properly.

Change-Id: I3da1c171839f22cf183dacf390cf033becddce0f
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/624557
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-08-21 22:03:53 -07:00
Philip Chen
8e7bad0482 battery/max17055: Specify desired charging voltage/current
BUG=b:64821815, b:63870414
CQ-DEPEND=CL:621777
BRANCH=none
TEST=plug in AC, and check 'charger' command on ec console

Change-Id: Ic60bcab7fd0ccc2ea73471ac46e9b0b887f251d9
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/621776
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-08-21 12:52:13 -07:00
Philip Chen
d2108bbcaa battery/max17055: Wait longer for initial config
max17055 sometimes fails to finish configuration due to timeout.
Let's wait longer.

BUG=b:63870414
BRANCH=none
TEST=boot scarlet rev1 10 times and ensure MODELCFG.REFRESH bit is
cleared when retries value > 10.

Change-Id: I62984c19014a244a378180bab6683e2e6f842cd1
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/617653
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-08-18 14:27:19 -07:00
Philip Chen
20f05a3488 battery/max17055: Process negative current/temperature right
On max17055, current/temperature register values are in 2's
complement format.

Therefore we need to consider the case of negative values before
doing bitwise operation.

BUG=b:63870414
BRANCH=none
TEST=run 'battery' command and confirm the reported discharge
current looks reasonable.

Change-Id: Iea0c554aecf2b410fc27b547e01ee7a583a0dd00
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/617654
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-08-18 14:27:19 -07:00
Philip Chen
321625dc11 charger/rt946x: Finish init no matter which CHIP REV it is
When booting scarlet rev1, the initialization of rt9466
is not finished because CHIP REV < 0x05.

Actually, we shouldn't keep the latest CHIP REV in rt946x.h
because it's hard to maintain. And we should try to finish
rt946x_init() no matter what CHIP REV it is.

Also, let's clean up the logging message in rt946x_init()
a bit to make it clear that it's from RT946X.

BUG=chromium:736821, b:63739819
BRANCH=none
TEST=boot scarlet rev1 and confirm the
initialization of rt946x is finished

Change-Id: Ic0b1f837b801cc18744a1222794a055dfe8aa54c
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/612585
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-08-17 20:41:54 -07:00
Caveh Jalali
ee3fb6c6aa ps8xxx: use custom tcpm_drv
the ps8xxx family of TCPCs (ps8751, ps8805) have historically used the
generic tcpci_tcpm_drv functions, but we need to override some of
these entry points because the parade parts need to be woken up before
accessing registers.

in most cases, this doesn't matter because we access the chip in quick
succession where we can "safely" assume the chip is awake -- and the
code is structured to implicitly keep the chip awake.  the new case we
need to address here is where we need to suspend the pd_task and TCPC
at an arbitrary point in time.  the driver's .release method is called
to shut down the chip, and that involves first waking up the chip to
be able to access its regs to mask off interrupts, etc.

BUG=b:35586896
BRANCH=none
TEST=tested from depthcharge - we no longer get errors in the EC
	console logs about TCPC "release" failed.

Change-Id: Ic2a90b71050b3f68c697b1cef48d736ed88b3f41
Signed-off-by: Caveh Jalali <caveh@google.com>
Reviewed-on: https://chromium-review.googlesource.com/616460
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-08-16 20:46:36 -07:00
Nicolas Boichat
fb58920c9e usb_hid_touchpad: Add timestamp field to touch events
We use the unofficial, Windows 8, Relative Scan time HID usage
(Digitizer page, 0x56) to add timestamps to our HID touchpad
events.

The timestamps is a rolling, unsigned, 16-bit integer, with a
resolution of 100us (so it wraps around every 6.5s).

The host will be able to synchronize to that timestamp, resetting
an offset every time the touchpad is quiet a certain amount of
time (e.g. 1 second).

BRANCH=none
BUG=b:63685117
TEST=Flash hammer, timestamps are reported in HID descriptor.

Change-Id: Ie5d56a9df14e464d2cdcd559f550d6e3cc81961f
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/603041
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-08-16 06:03:49 -07:00
Vijay Hiremath
a261390d75 usb_mux: Merge PS8743 & PS8740 as PS874X
Merge PS8743 & PS8740 as PS874X as both the drivers are almost same.

BUG=b:64598680
BRANCH=glkrvp
TEST=make buildall -j
     On GLKRVP, verify mux setting is correct with
     Apple dongle (VGA + USB) and Pluggable adapter.

Change-Id: Ic6d31979936ee213b07c4c71859809102ee91452
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/612209
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-08-11 20:10:23 -07:00