Commit Graph

562 Commits

Author SHA1 Message Date
Philip Chen
dc170640c7 charger/rt946x: Disable charge timer
If the charge timer expires, rt946x would stop charging.
We don't need this function.

BUG=b:72571372
BRANCH=scarlet
TEST=read reg 0x12 and confirm TMR_EN == 0

Change-Id: I38137ac39c7e7dfd15f12342428708697f81922c
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/915501
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: David Schneider <dnschneid@chromium.org>
2018-02-14 00:48:26 -08:00
Edward Hill
c1252e71ca sn5s330: Disable vSafe0V interrupts
Turn off vSafe0V interrupts. They were not being handled or
cleared causing the interrupt line to be stuck low after
unplugging a USB device.

Also don't use read-modify-write for INT_STATUS_REG4 since
this would clear the dead battery mode bit before it has
been checked.

BUG=b:73076662
BRANCH=none
TEST=unplug USB device, see USB_C1_SWCTL_INT_ODL=1
TEST=USB2 mouse can be connected multiple times, PPC VBUS
 detection works, BC1.2 chip turns on and off correctly
 (USB_C1_BC12_VBUS_ON_L).

Change-Id: I96980ee330dd6e5f98e447e5e87f11dd60768a5d
Signed-off-by: Edward Hill <ecgh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/909549
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
2018-02-09 16:07:10 -08:00
Philip Chen
85caeb6ccb tcpm/fusb302: Wake charger task on VBUS level change
We need to wake up charger task right after AC is plugged
so that the charge state can be updated immediately.

BUG=b:71520398
BRANCH=none
TEST=Confirm charger task wakes up immediately when AC is
plugged in a Scarlet in G3.

Change-Id: I4a65b3da363cdc204b800bd300824dae616770cb
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/869419
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-02-08 23:42:09 -08:00
Nicolas Boichat
3b33621d2f driver/led/lm3630a: Disable Bank B, avoid race setting brightness
It is not necessary to enable Bank B, as we do not use it.

Also, we have seen a race between enabling the banks and writing
the brightness register to 0xFF, where the chip would reset the
value after it has been set by EC. Adding a short 100us sleep
fixes the issue.

BRANCH=none
BUG=b:69379749
TEST=Flash whiskers, pwm 0 50 works, even after a cold reset.

Change-Id: Ic523a2475c3874c8433eb1b39e927793dd893e8f
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/906165
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Edward Hill <ecgh@chromium.org>
Reviewed-by: Benjamin Gordon <bmgordon@chromium.org>
2018-02-07 21:27:42 -08:00
Philip Chen
c715d81955 charger/rt946x: Set up pre-charge current
We should set up pre-charge current based on the battery pack we use.
By default this parameter is 150mA.

BUG=chromium:809246
BRANCH=none
TEST=confirm IPREC register is written correctly

Change-Id: I2cb0906c74bef144d80c38b5d15519d594ed42f2
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/902945
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2018-02-06 15:41:21 -08:00
Nicolas Boichat
bce23786d0 touchpad_elan: Power off when USB is suspended without wake
touchpad can be powered off when the USB interface is disabled
without setting the remote wake feature
(USB_REQ_FEATURE_DEVICE_REMOTE_WAKEUP), as events would be ignored
anyway.

BRANCH=none
BUG=b:72683995
TEST=touchpad is disabled when lid is closed.

Change-Id: I688fce16ab8c75330e588ec130fb2aa499fc0ed1
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/897069
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-02-05 19:08:22 -08:00
Aseda Aboagye
e127855f27 ppc: Add Vconn and CC polarity settings.
BUG=b:72292985
BRANCH=None
TEST=Flash meowth; Verify with twinkie that Vconn is provided for a sink
that requires it.

Change-Id: I8168d2e4c46e04810dcf5c2898b2c337424eefec
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/888224
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Edward Hill <ecgh@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
2018-02-01 18:08:36 -08:00
Aseda Aboagye
61b602d292 isl923x: Don't initialize ICL on sysjump.
The ISL923x init function would initialize the charger's input current
to the board's defined default.  For some boards like meowth and
zoombini, the default input current was set quite low, 128mA.  When
sysjumping, all HOOK_INITs are called again and therefore the input
current limit would be reset even thought it would have been set
correctly prior to jumping.  Setting the current limit so low, without a
battery, would cause a power failure and the PMIC would drop its power
OK signal and go into emergency shutdown.

This commit simply adds a check to whether the EC jumped to this image.
If it has, the charger input current limit is left unchanged.  It will
be updated to the correct value by charge manager later on after
determine the attached charge supplier.

BUG=b:72129338
BRANCH=None
TEST=Flash meowth; Boot to S0 without a battery; Verify that PMIC_DPWROK
remains high.
TEST=Repeat above test for zoombini.

Change-Id: I7e5bbbbf3ec604c876cc4fa0163f8bb7feff4cc9
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/896960
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Caveh Jalali <caveh@google.com>
2018-02-01 02:41:55 -08:00
Jett Rink
d138e4dc63 cleanup: Correcting VBUS discharge comment
BRANCH=none
BUG=none
TEST=none

Change-Id: I0e7f21bd56a796d2261ffafa26f603924ac0d66d
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/896395
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2018-02-01 02:41:54 -08:00
Edward Hill
11bda19561 sn5s330: Enable VBUS interrupts
If the sn5s330 PPC is being used to detect VBUS presence
(CONFIG_USB_PD_VBUS_DETECT_PPC), then enable interrupts and call
usb_charger_vbus_change when VBUS_GOOD changes.

BUG=b:72007153,b:72007492
BRANCH=none
TEST=Connect 3A and 1A USB-A chargers to each of Grunt's USB-C ports,
check that BC1.2 detection is working:
	With 1A:
	> chgsup
	port=0/1, type=7, cur=500mA, vtg=5000mV, lsm=1
	With 3A:
	> chgsup
	port=0/1, type=7, cur=2400mA, vtg=5000mV, lsm=1
TEST=Boot Grunt to OS, then connect USB2 mouse or USB3 flash drive to each
of Grunt's USB-C ports. Devices do not work due to b:71772180, but gpioget
shows EC is setting USB_C0/1_BC12_VBUS_ON_L correctly.

Change-Id: Iffc352105a321997adb364b9fbb8bafef248c224
Signed-off-by: Edward Hill <ecgh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/887938
Reviewed-by: Jett Rink <jettrink@chromium.org>
2018-01-31 22:38:56 -08:00
Jett Rink
760caca89b usb pd: Adding PPC vbus discharge path
Boards with a PPC will use the PPC to discharge the VBUS line instead
of the TCPC or GPIO discharge path.

BRANCH=none
BUG=b:72179253
TEST=Fall time after device removal on grunt within spec now

Change-Id: I822923a1cedb32a20efc3610cce4437ade3387f0
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/886563
Reviewed-by: Edward Hill <ecgh@chromium.org>
2018-01-31 11:14:01 -08:00
Philip Chen
5e63c7b22e charger/rt946x: Reset VBUS by default
In the system, RT946x is always powered by the battery.
So even in battery cutoff mode, the reg values on RT946X are not reset.

We don't want RT946x to supply VBUS when DUT boots, which could mess up
PD state. So we need to disable VBUS output when RT946x initializes.

BUG=b:72228350
BRANCH=none
TEST=Confirm OPA_MODE (bit0 in reg 0x01) is clear after RT946x
finishes initialization

Change-Id: I32795b3bea64860b164c14b06aa1cd2551ebd8a0
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/890028
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Brian Norris <briannorris@chromium.org>
2018-01-30 17:47:15 -08:00
Philip Chen
df229ee8e6 charger/rt946x: Clear irq flags correctly
rt946x_block_read() is not implemented right.
It not only makes rt946x_init_irq() fail but also put
RT946x i2c module in an erroneous state temporarily.

BUG=b:72228350
BRANCH=none
TEST=manually on scarlet rev3:
1)Insert Plugable USB-C hub w/o AC
2)Run cutoff command on ec console
3)Hold Pwr button for a few seconds to wake up DUT
4)Repeat 2 - 3 for 10 times without seeing PD loops

Change-Id: I9304617f924e44288483afca5ab1b2923eb68ff0
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/890027
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Brian Norris <briannorris@chromium.org>
2018-01-30 17:47:14 -08:00
Philip Chen
3a95a68292 charger/rt946x: Log the init failure
BUG=b:72228350
BRANCH=none
TEST=See the error message when init fails

Change-Id: Ib9b1906cb2d0b2427a96ea4823eb3325912f344b
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/890026
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Brian Norris <briannorris@chromium.org>
2018-01-30 14:54:24 -08:00
Elmo_Lan
e46d0fcbc8 Nami: Update for ALS and temperture sensor
Implement ALS code and add a new thermal sensor
(Fintek, F75303)

BUG=b:71839392
BRANCH=none
TEST=Verify Nami can read ALS and thermal data via I2C by ec console.

Change-Id: I0f8fd486f62508bbca30a57f435b9f26621cf34b
Signed-off-by: Elmo_Lan <elmo_lan@compal.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/863350
Commit-Ready: Elmo Lan <elmo_lan@compal.corp-partner.google.com>
Tested-by: Elmo Lan <elmo_lan@compal.corp-partner.google.com>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Elmo Lan <elmo_lan@compal.corp-partner.google.com>
2018-01-28 21:17:06 -08:00
Benjamin Gordon
d258f8a788 driver/led: Add LM3630A driver
This chip controls the keyboard backlight.  The backlight level is set
through PWM, but the chip needs to be enabled and configured before PWM
settings are recognized.  This will be initially used for grunt and
zoombini.

BUG=b:69379749
BRANCH=none
TEST=In EC console for grunt: kblight 100; kblight 0

Change-Id: I5576d709687d8f61b5757485baa239ffd6b41a74
Signed-off-by: Benjamin Gordon <bmgordon@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/879082
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Edward Hill <ecgh@chromium.org>
2018-01-25 19:23:37 -08:00
Scott Collyer
f793f81b8b bd9995x: Clear VSYS_PRIORITY when Vbat > Vbat_min
VSYS_PRIORITY in the register VIN_CTRL_SET is set during bd9995x
initialization to ensure VSYS remains up and stable during deeply
discharged battery conditions. However, outside of this case, this bit
should remain cleared.

If set, there the input current limit is disabled between the time
that the boost converter is enabled (USB_SUS = 0) and charging is
enabled (CHG_EN = 1). This can lead to too much current being drawn
which results in the connecting port shutting off VBUS due to its
overcurrent protection. This has been observed when attempting to
charge one DUT from another chromebook port, or with a Type C only
charger.

This CL adds a check in the bd99965x driver implementation of
charger_get_voltage() that compares the current battery voltage to
its minimum voltage. If it's higher, then it's not a deeply discharged
battery and VSYS_PRIORITY can be cleared.

BUG=chromium:69143827,71814128
BRANCH=coral,eve
TEST=Tested with 2 Coral DUTs. Verified that VSYS_PRIORITY gets
cleared when the charger state machine gets the charger
parameters. Also verified that I can repeatedly initated charging from
one Coral device to another. Without this fix, this would fail most of
the of the time. Also tested Eve with deeply discharged battery to
make sure the startup conditon still works.

Change-Id: I5230560fa98e5bf16921eb4f2c70802eb962e7f3
Signed-off-by: Scott Collyer <scollyer@google.com>
Reviewed-on: https://chromium-review.googlesource.com/875178
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-22 22:07:17 -08:00
Nicolas Boichat
d9f4ce13f2 touchpad_elan: Add retry logic if the touchpad does not respond
After 3 tries, the touchpad is reset by power-cycling it.

BRANCH=none
BUG=b:71688150
TEST=Short SDA/SCL lines, press on touchpad, see that touchpad tasks
     retries transaction, and then resets the touchpad power.
TEST=Do ESD discharge, and see that touchpad always recovers.

Change-Id: If0b5eb936d4d2feb3d34a7ec8748869a1b915c34
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/872131
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-01-21 22:20:48 -08:00
Philip Chen
bffb196a07 scarlet: Use TCPC to detect if AC is present
After VBUS is up, there is a delay of ~500ms for rt946x to determine
'VBUS is ready'.
But we need charger_task to detect AC presence and then set a proper
sleep time immediately.
When using fusb302 to detect VBUS, I almost don't see any delay.

BUG=b:71520398
BRANCH=none
TEST=Confirm BATTERY LED turns on immediately when AC is
plugged in a Scarlet in G3.

Change-Id: If1d6d40081b5822eeb9e012115f8deef172def37
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/869420
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-18 17:40:46 -08:00
Ruben Rodriguez Buchillon
51e9e69f38 power: introducing pwr_avg console command
pwr_avg provides an average voltage, current, and power over the last
1 minute. It's up to the battery drivers to implement this
functionality.
This change allows us to have better power tracking while minimizing
the power impact on the EC, because
- the pwr_avg command only needs to be called once every minute, and is
short, thus less expensive to parse on ECs without a UART buffer
- the work done to keep the avg is partially done by the batteries
already and it's just a question of retrieving it.

undefined on wheatley since no power debugging planned on that board.

usage:
> pwr_avg
mv = 7153
ma = -605
mw = -4327

BUG=chromium:752320
BRANCH=None
TEST=make buildall -j

Change-Id: Id1a3479d277aedf90dfa965afb4ee9136654b1cf
Signed-off-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/823884
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-01-16 04:08:26 -08:00
Nicolas Boichat
31e68a035b driver/charger/isl923x: Make sure CONFIG_CHARGER_NARROW_VDC is set
Without this, the battery will discharge if we disallow battery
charging (e.g. calling charge_request with either voltage == 0 or
current == 0, either by policy, or when the battery is full).

Also update config.h to set the option whenever isl923x is used.

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

Change-Id: Id5515d5ea82a393a3693a3da44cbdc2778296a95
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/856538
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2018-01-10 06:02:13 -08:00
Nicolas Boichat
1caa2788c5 charger/isl923x: Implement charger_get_system_power from PSYS
On ISL923x, PSYS output is always enabled when the AP is on
(provided CONFIG_CHARGER_PSYS is enabled).

We add support for charger_get_system_power function, reading PSYS
value, when CONFIG_CHARGER_PSYS_READ is defined. This will be used
by the charging algorithm on lux.

We also rename CONFIG_CMD_CHARGER_PSYS to CONFIG_CHARGER_PSYS_READ
as CONFIG_CHARGER_PSYS_READ provides both "psys" console command
and the new function. We also cleanup unneeded undefs in board
files.

Note that this does not implement the function on bd9995x, but this
could be done without too much effort.

BRANCH=none
BUG=b:71520677
TEST=On lux, without AC connected, check that "psys" output roughly
     matches the output current from the battery.

Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>

Change-Id: Ie1ce8e0ac103daacc5a08b8ccae604d1d83551b8
Reviewed-on: https://chromium-review.googlesource.com/848487
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-10 06:02:13 -08:00
Nicolas Boichat
f14879eae1 charger/isl923x: Protect CONTROL1 read-modify-write with a mutex
CONTROL1 bits can be modified from multiple tasks:
 - charger_enable_otg_power (charger or pd task)
 - charger_discharge_on_ac (host command or console)
 - charger_enable/disable_psys (chipset task)
 - print_amon_bmon (console)

Since we use I2C read, modify, then I2C write access pattern,
there is a small chance of races between these accesses:
let's protect them with a mutex.

Also, the current code sometimes uses charger_get_option/set_option
instead of manipulating CONTROL0 directly: fix those to regain
a bit of the extra code size caused by the mutex.

BRANCH=none
BUG=b:67029560
TEST=Flash lux, battery charges, amon works fine.
TEST=Flash elm, battery charges.

Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>

Change-Id: If375d9922db53dd582582bfa44d6218fe0b416ec
Reviewed-on: https://chromium-review.googlesource.com/848486
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-04 21:52:05 -08:00
Nicolas Boichat
6bbb5adab1 charge_state_v2: Add charge_set_output_current_limit function
This function sets up and enables "OTG" mode on the charger chip
(i.e. use the charger to provide power from the battery).

It also records the output current in curr.output_current, to
make sure that the charger loop is aware that current is provided
externally.

We also add a CONFIG_CHARGER_OTG to remove these functions on
boards that do not require it.

BRANCH=none
BUG=b:65697962
TEST=On wand, when discharging, battery status is updated every
     5 seconds (and not every 60 seconds).

Change-Id: Ibf93933436f3eb24552a8e1eb9d97522fca2ce79
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/842743
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-04 21:52:01 -08:00
Nicolas Boichat
eb781cc377 driver/bc12/pi3usb9281: Make a few functions static
Old oak boards that still use these functions have long been
deprecated, let's make the unneeded functions static.

BRANCH=none
BUG=b:35573263
TEST=make buildall -j => makes newsizes: up to 64 bytes saved on
     a few boards.

Change-Id: I8f2503ce324e34b87b3bbfa3c509079357880c9e
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/848574
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-03 22:43:02 -08:00
Alec Thilenius
27f92a378a Add SB-TSI temp sensor driver
This adds the driver for the SB-TSI temp sensor.

This is a sensor on the AMD AP SOC (Stoney Ridege FT2) that acts like an
8-pin temp sensor with an I2C interface.

BUG=b:69379715
BRANCH=None
TEST=Build

Change-Id: Iaafe6c7beb3e02e4e341617e8f117c03c0a882a2
Signed-off-by: Alec Thilenius <athilenius@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/833346
Commit-Ready: Alec Thilenius <athilenius@google.com>
Tested-by: Alec Thilenius <athilenius@google.com>
Reviewed-by: Edward Hill <ecgh@chromium.org>
2018-01-03 16:54:31 -08:00
Scott Worley
940dd625b9 ec_driver: Add ADT7481 and TMP411 I2C sensors
Added I2C sensors ADT7481 and TMP411 with config
items and build rules.

BRANCH=none
BUG=
TEST=Define CONFIG_TEMP_SENSOR_ADT7481 or _TMP411
and build board.

Change-Id: I4d1eb55ee56ad3f42787538bb839193e683d0a60
Signed-off-by: Scott Worley <scott.worley@microchip.corp-partner.google.com>
2017-12-28 14:50:31 -08:00
Philip Chen
f889d14d4e charger/rt946x: Increase boost current threshold
We should at least be able to source 1.5A.

BUG=b:70524967
BRANCH=none
TEST=Confirm reg 0x0a is set correctly

Change-Id: Ia21af18d72138b5ab81f683df5aaa92c50981694
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/830896
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-12-18 20:33:07 -08:00
Aseda Aboagye
1ca59fb7b1 meowth: zoombini: Mask off 5V PGOOD and COMP_C.
The boards need to have 5V masked off from the power good tree.
Additionially, Meowth needs to have the COMP_C fault masked from the
fault mask because its enable is connected and not grounded like on
Zoombini.

BUG=b:69935563
BRANCH=None
TEST=flash zoombini; Verify that we can boot to S0.

Change-Id: Ia51004a131e7c31d0e5ee59d87ab13455b822779
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/807632
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-12-18 20:33:00 -08:00
Philip Chen
6aa967e4bb charger/rt946X: Set boost current threshold correctly
rt946x_closest_reg_via_tbl() is buggy and doesn't
return the right reg value because of misuse of ARRAY_SIZE().
We should fix it.

Meanwhile, since rt946x_closest_reg_via_tbl() is only called in
rt946x_set_boost_current(), let's just delete rt946x_closest_reg_via_tbl()
and move its code to rt946x_set_boost_current().

BUG=b:70524967
BRANCH=none
TEST=Confirm reg 0x0a is set correctly

Change-Id: Ie9c90ebf63596a52f864ff5809488731edc41fff
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/830895
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-12-18 17:55:00 -08:00
Nicolas Boichat
b9939cf42b touchpad_elan: Add support for debugging mode
We add 2 hashes that each map to a list of allowed commands
(command list is secret, and provided by Elan).

UPDATE_EXTRA_CMD_TOUCHPAD_DEBUG on the USB interface have the
following format for the parameter:
- param[0]: must be 0xff
- param[1]: offset of the I2C command in data
- param[2]: command length
- param[3-4]: read-back length (MSB first) over I2C, can be 0
- param[5-49]: data, is verified using SHA-256 hash.

The I2C command pointed at by param[1-2] is then sent over
I2C, and the data is read back into a shared buffer of size
param[3-4].

The data can be fetched over USB by a single byte USB update
touchpad debug command (indicating an offset in 64-bytes unit),
fetching data from the shared buffer in blocks of 64 bytes.

BRANCH=none
BUG=b:63993891
TEST=Elan can run debugging commands using their proprietary tool.

Change-Id: Idb19bcb940b7f030c3b3aeaf39d6b725fcb9ef34
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/763576
Reviewed-by: Chun-ta Lin <itspeter@chromium.org>
2017-12-14 18:11:52 -08:00
Aseda Aboagye
755517e2cf ppc: Add API to set Vbus source ILIM.
The PPC needs to update its Vbus source current limits whenever our
policy changes on the PD ports.  This commit simply adds and API to do
so.

BUG=None
BRANCH=None
TEST=With some extra code to enable 3A out, flash zoombini; Plug in a PD
device to a port, verify that it gets 5V @ 3A.  Plug in a second device,
verify that we re-send new source caps of 5V @ 1.5A.
TEST=Repeat above for meowth.

Change-Id: Ifa4bc8b7df87f7730f2bcded842906d43171394b
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/818335
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-12-13 22:33:22 -08:00
Aseda Aboagye
02e4c2ea9a ppc: sn5s330: Add interrupt handler.
Right now, the only events that are unmasked by default are overcurrent
conditions on PP1.  This commit adds a simple interrupt handler and
introduces a board specific callback when the overcurrent status changes
on a port.  This way, a board can take whatever action it desires with
the notification.

BUG=b:69139844
BRANCH=None
TEST=Flash zoombini with SN5S330 stuffed.  Verify that board boots okay.
TEST=With some extra code to setup the interrupt handler, attempt to
exceed the current limit set, verify that interrupt handler is called.
Reduce the current pulled to under the current limit, verify that the
condition is no longer present.

CQ-DEPEND=CL:797937

Change-Id: Id3321c5703f9608da895be0ed5841f2fb76e734e
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/797936
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-12-12 01:05:25 -08:00
Philip Chen
40a693aea8 battery/max17055: Support advanced config with battery profile
We've been using the basic configuration (EZ config) to
initialize max17055.
It doesn't require battery profile, but the accuracy of fuel gauge
is not the best.

With a full battery profile in place, we should extend our driver
to import the battery profile for advanced config.
It should boost the accuracy.

BUG=b:69634899
CQ-DEPEND=CL:812481
BRANCH=none
TEST=manually test on Scarlet rev2, 'battery' command shows reasonable
reading no matter is_ez_config is set as 0 or not.

Change-Id: Iaea2d3e20f5de4207a86d4fff5f1561aaba4d362
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/813038
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-12-11 19:37:46 -08:00
Nicolas Boichat
48cb289e0c isl923x: Add support for reverse AMON ("OTG")
Also refactor amon_bmon command to save a bit of flash space.

BUG=b:66575472
BRANCH=none
TEST=amon in EC console

Change-Id: I8badcab1ccf14fd413c6713e418cc71f123754c8
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/818851
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-12-11 05:32:14 -08:00
Nicolas Boichat
f60de076e1 isl923x: Use ccprintf in print_amon_bmon
Makes sure output is still shown even when we set "chan 0".

BRANCH=none
BUG=none
TEST=chan 0; amon => data is printed.

Change-Id: Ic2bf525174b451e3f25868a0a77e0174687b6262
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/818850
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-12-11 05:32:14 -08:00
YB.Ha
47a6acca3a motion: Add bh1730 as a motion sensor
- Add ROHM ambient light sensor driver
    - Add als sensor to motion sensors

    BRANCH=glados
    BUG=b:67022366
    TEST=This driver is tested in caroline
    Signed-off-by: yb.ha <ybha@samsung.com>

Change-Id: Ic73c50e17b412975f7850b7348ce310180f7a6eb
Reviewed-on: https://chromium-review.googlesource.com/784659
Commit-Ready: YongBeum Ha <ybha@samsung.com>
Tested-by: YongBeum Ha <ybha@samsung.com>
Reviewed-by: Gwendal Grignou <gwendal@google.com>
2017-12-08 00:37:03 -08:00
Aseda Aboagye
eff4baf03f sn5s330: Add support for Vbus detection.
The SN5S330 has support for detecting when Vbus is present on a port.
This commit simply adds an API to query the PPC.

BUG=None
BRANCH=None
TEST=`make -j buildall`.
TEST=Flash a board with the SN5S330, with some extra code, verify that
Vbus can be detected with this API.

Change-Id: I45bf7ff24bcdc447efe12932f51f8094108e29d5
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/791502
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Edward Hill <ecgh@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-12-06 17:30:46 -08:00
Aseda Aboagye
0dd7716c4f ppc: sn5s330: Fix current limit setting.
The default sourcing current limit can be set by the following config
option:

  CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT

However, the way that this macro was being used was incorrect for the
SN5S330 driver.  Since, enum values are not known at compile time, the
check needs to happen during runtime.  This commit makes this change.

BUG=None
BRANCH=None
TEST=Enable CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT on a board that uses
the SN5S330, verify that there are no build errors.

Change-Id: I04a1fa1e2e42c2f4ba49f1769857a8796b2f0a6f
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/791501
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-12-06 17:30:45 -08:00
Vincent Palatin
d757f9bf3b eve_fp: update fingerprint architecture
split the common FP sensor code and use the updated private driver.

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

BRANCH=none
BUG=b:69460856
TEST=do a finger capture on Eve EVT.
CQ-DEPEND=CL:*520759

Change-Id: I8b46762218eed0773a4c49a02c2ee6c3966cfa60
Reviewed-on: https://chromium-review.googlesource.com/806166
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-12-06 14:28:56 -08:00
Aseda Aboagye
fb32b6d30c ppc: Create generic PPC driver framework.
This commit introduces a driver framework for power path controllers.
It provides some common PPC APIs as well as allowing a board to use
multiple different PPCs drivers/parts.  This should make it easier to
add PPC drivers in the future.

BUG=None
BRANCH=None
TEST=`make -j buildall`
TEST=Flash zoombini; verify PPC works as expected.
TEST=Flash meowth; verify PPC works as expected.

Change-Id: Icfb99f384610590b431456cfd28d4aff18442cb2
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/807630
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Edward Hill <ecgh@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-12-06 01:08:24 -08:00
Aseda Aboagye
9c4008e35c ppc: Add common APIs.
It'll be easier to add support for new PPCs if we make a generic API.

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

Change-Id: I9aac1750eb4c163eb2b94aa8975c797f86d0a25a
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/791499
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-12-05 22:43:45 -08:00
Aseda Aboagye
0a5e908467 ppc: sn5s330: Add API to determine if FET is on.
It will be useful to determine if a FET is enabled or not.  For example,
to determine if we are sourcing power to a downstream device.  This
commit simply adds an API to check if a FET is enabled or not.

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

Change-Id: I1f8198342cf225ce9a10d218607bcfbe6aef618c
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/791498
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Edward Hill <ecgh@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-12-05 18:00:36 -08:00
Aseda Aboagye
864b0b6616 sn5s330: Clear interrupts and setup masks at init.
When the SN5S330 is powered initially, there will be certain events set
that will assert its interrupt line.  As part of the initialization for
this part, we should clear all the pending interrupts and setup the
masks for the events that we care about.

This commit clears all interrupts at init time and masks all interrupts
except for overcurrent condition for PP1.

BUG=b:69139844
BRANCH=None
TEST=Flash zoombini; With nothing plugged in, verify that the interrupt
line is deasserted at boot.
TEST=Repeat the above test with a charger plugged in.

Change-Id: I7acc030184b76d6c38a729cb64658f71e376c819
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/783510
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-12-05 18:00:35 -08:00
Shawn Nematbakhsh
6d2f73e3dd tcpm: fusb302: Wake PD task on VBUS level change
If VBUS toggles between 'present' and 'not-present', and fusb302 is the
arbiter of VBUS presence, wake the PD task so that it can take the
necessary protocol actions (eg. transition out of HARD_RESET_RECOVER).

BUG=b:69482362
BRANCH=None
TEST=On scarlet, issue EC reset with CableCreation source dock plugged,
verify we don't end up in hard reset loop.

Change-Id: I88d6102a6b5f4bd5151bae117c70f0a3ac0c09e7
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/804660
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-12-04 17:33:54 -08:00
Edward Hill
d22f5518f0 grunt: Initial USB PD board code.
Add USB PD tasks and start of board code.
Update GPIOs to match V1.2 schematics.

Grunt V1.2 USB HW:
	C0: TCPC ANX3429, Switch SN5S330, BC1.2 BQ24392
	C1: TCPC PS8751,  Switch SN5S330, BC1.2 BQ24392
	A0: SN1702001
	A1: SN1702001
	Charger: ISL9238

BUG=b:69378796
BRANCH=none
TEST=make BOARD=grunt

Change-Id: I66918abe3e9452c8d60e51245e730d1bcc168fd3
Signed-off-by: Edward Hill <ecgh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/777407
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-11-30 14:18:40 -08:00
Rong Chang
96bc7cd9b5 charger: add sy21612 buck-boost converter driver
SY21612 is buck-boost converter with selectable source/sink mode.

BRANCH=none
BUG=none
TEST=none

Signed-off-by: Rong Chang <rongchang@chromium.org>
Change-Id: I71248eedd9be775790d71010f69dfae41cd64a27
Reviewed-on: https://chromium-review.googlesource.com/673964
Reviewed-by: Benson Leung <bleung@chromium.org>
2017-11-29 04:04:12 -08:00
Furquan Shaikh
d33eb02aef sb_fw_update: Get rid of CONFIG_SB_FIRMWARE_UPDATE
CONFIG_SB_FIRMWARE_UPDATE is dead on ToT. So, get rid it completely.

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

Change-Id: Ic1eedff21d82f729a73ec9a7c1d554b6b571e827
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/792013
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-11-28 17:56:29 -08:00
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