Commit Graph

401 Commits

Author SHA1 Message Date
Wonjoon Lee
ef976e6387 bd9995x: more delay time between chg_en and vsys_set
The nvdc voltage has a kind of deep, so that rarely observed
NVDC down at this point because of back-boosting.
Our sequence to enable charger bit and setting vsysreg
is correct but rohm introduce charger may need some more time
to be stable when between chg_en and vsys_set to start charge

BUG=chrome-os-partner:60380
BRANCH=gru
TEST=Manual on kevin, trigger battery disconnect, re-attach AC, verify
system boots cleanly. and see voltage probing on c54@60380

Change-Id: Ic05091379322ffaac16fe827a47345c76c85f3e5
Signed-off-by: Wonjoon Lee <woojoo.lee@samsung.com>
Reviewed-on: https://chromium-review.googlesource.com/434252
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-01-28 01:52:15 -08:00
Scott
58e18da39f servo_v4: pd: Added Device Test System support
- Modified src attach state to enable vbus when debug accessory is
detected.

- servo_v4 has two pd ports, but each port requires a different default
power role. Port 0 can only ever be a SNK, but port 1 which acts is
intended to be a DTS port should default to a SRC so it can be be a
source debug accessory. It may also act as a sink debug accessory, but
is not intended to toggle automatically but will swap roles if
necessary via pd role swap messaging.

- Add hook for ccd enable/disable for DTS mode

BUG=chrome-os-partner:61878
BRANCH=servo
TEST=Manual Verfied that can still build servo_v4 project. All changes
in this CL are contingent on config option CONFIG_USB_PD_DTS being enabled.

Change-Id: Iab968b6fbdfc8f2d155c4f8618921b32f313b9ec
Signed-off-by: Scott <scollyer@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/428308
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-01-26 23:16:40 -08:00
Daisuke Nojiri
7a4eac1bed Reef: Reduce max battery charge voltage for 0.5% margin
(From CL 431233)

Limit battery charge voltage to prevent battery over-charge, due to
regulation inaccuracy. Since RO FW may charge > 8656 mV, ensure the
battery is not full before charging.

BUG=chrome-os-partner:61906
BRANCH=none
TEST=Manual on Electro, sysjump with battery @ 99%, verify battery
discharges, then re-charges to 100%, before discharging once again.

Change-Id: I28212c83057a442fd75e39f8ad51927a7a1f2817
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/432857
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-01-25 22:12:30 -08:00
Nicolas Boichat
92a79b2bf1 isl9238: Add support for battery discharging BMON current monitor
ISL9238 is able to measure currents when battery is discharging
(like ISL9237), and charging (new feature).

Reverse AMON (OTG output current) is also supported by ISL9238,
but isn't very interesting on our boards.

BRANCH=none
BUG=chrome-os-partner:61166
TEST=Plug charger, "amon" in EC console, check that values match
     current meter + "battery" information. Unplug charger,
     values match "battery" information.

Change-Id: I9ecae6bec9e2049d17ef1a4596dbd4e3ff59919e
Reviewed-on: https://chromium-review.googlesource.com/430474
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-01-24 22:03:50 -08:00
Gwendal Grignou
a8a67a8073 driver: bmi160: Set odr to 0 at init.
When we switch to a state where the sensor is not powered,
we don't call set_data_rate(0), because we may trigger an i2c/spi access
to a sensor already powered off. It has the side effect to leave
data->odr to the last set sensor frequency.
When we init the BMI160, it starts in suspend mode. We will set it to
normal mode only if data->odr is 0. Therefore, we must set odr to 0 in
the init routine.

BUG=chrome-os-partner:61502
BRANCH=reef,kevin
TEST=On reef, without this change. When going to S5 (shutdown -h 0) and
power back up, sensor is stuck (on EC, accelread 1 reads old value).
With this fix, sensor is active and working.
This fix a regression due to CL:411964.
Check others driver do not check odr for setting suspend/normal mode.

Change-Id: Ibc7519d49e55a0b43b4c12ed545bd75ab0260766
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/426766
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-01-10 21:34:32 -08:00
Aseda Aboagye
b3a9e1b64c motion_sense: Add "spoof" mode
This commit adds a "spoof" mode feature to the motionsense stack.  It
allows the user to arbitrarily set the outputs of the sensor in order to
"spoof" the readings of the sensor.  This can be useful in emulating
tablet mode or device rotations.  A command is available from the EC
console named `accelspoof` and there is a corresponding motionsense
command in ectool called `spoof`.

The usage is as follows:

- EC console
 > accelspoof [id] [on/off] [X Y Z]

- ectool
 # ectool motionsense spoof -- [id] [0/1] [X Y Z]

If on or off(or 0/1) is not specified, the current spoof mode status of
the sensor is returned.  If on is specified, but no components are
provided, the sensor will lock the current values and provide those as
the spoofed values.  If the components are provided, those will be used
as the spoofed values.

BUG=chromium:675263
BRANCH=cyan,glados,gru,oak
TEST=Flash a DUT with accels.  From AP console, run `ectool motionsense
lid_angle` in a loop, use 'accelspoof' EC console command to set spoofed
values.  Verify that the angle is fixed regardless of the actual angle
of the DUT.
TEST=Flash a DUT with accels.  From AP console, use `ectool motionsense
spoof` to spoof values and verify that `ectool motionsense` reflects the
spoofed values.  Test with both provided component values and no
component values.

Change-Id: Ie30688d22f38054e7243b1af493a3092b2cdfb72
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/421280
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2017-01-07 13:29:52 -08:00
Nicolas Boichat
b1101b8ed6 charger: isl923x: Add support for ISL9238
ISL9237 and ISL9238 are almost identical, with few register changes,
let's make the driver generic, to support both chargers.

BRANCH=none
BUG=chrome-os-partner:61166
TEST=make buildall -j

Change-Id: I029894dd62ab7e45897d877289707ee8c1ff1d09
Reviewed-on: https://chromium-review.googlesource.com/422197
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-01-05 18:39:58 -08:00
Gwendal Grignou
0c7b7f222c driver: als: Add error code UNCHANGED
This error code is used to indicates the data has not changed.
Motion sense task will therefore not add any entry in the sensor FIFO.

BUG=chrome-os-partner:59423
TEST=make -j buildall
BRANCH=reef

Change-Id: I58b9be5675d8949bd682d8c89dadea1dfff9bf2e
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/424856
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-01-05 13:43:39 -08:00
Vijay Hiremath
66ea614158 smart_battery: Cleanup smart battery & SB users code
BUG=chrome-os-partner:61173
BRANCH=none
TEST=Manually tested on Reef. Battery info works.

Change-Id: I6e867eee38885186f8e63a934f52e826f0cf72fd
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/422998
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-01-02 16:16:59 -08:00
Moritz Fischer
73d0b9ca9f driver: temp_sensor: Add support for TI TMP112 sensor
Add support for the Texas Instruments TMP112 I2C temperature
sensor. The sensor provides a single temperature value.

BUG=none
BRANCH=none
TEST=Ran 'temp' console command over and over. Verified values with
    digital thermometer.

Change-Id: Ida4c082309d245c3f7c6282ecea74ce5af746e43
Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
Reviewed-on: https://chromium-review.googlesource.com/418488
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-12-30 18:14:34 -08:00
Gwendal Grignou
1c68913e02 driver: Move sensor private struture definition to boards.
sensor private structure for bmi160 and bmp280 were defined
in the drivers themselves. It worked because there was only one
instance of each sensors on a board. However, this is an error it
should be in board files, as it was done for other sensors like the kionix.

BUG=none
TEST=buildall.
BRANCH=kevin,reef

Change-Id: Ica3aba358d141a7df9a3e97251d4c1e520cbf2c8
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/424218
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-12-28 21:49:29 -08:00
Shawn Nematbakhsh
d00a15a78d tcpm: anx74xx: Remove auto-toggle support
Auto-role toggle on the anx74xx does not function correctly with
e-marked cables and cannot be used.

Also check for TCPC support for auto-toggle at runtime, to allow
auto-toggle supported TCPC to be used alongside an unsupported part.

(from CL:420405)

BUG=chrome-os-partner:60890
BRANCH=reef
TEST=Manual on reef, boot to S0:
`pd 0 state`: Toggling between SRC_DISCONNECTED / SNK_DISCONNECTED
`pd 1 state`: DRP_AUTO_TOGGLE
Also verify port 0 can become sink + source correctly in S0.

Change-Id: Iafdedf31773feef23923cefe1f4fb02fcffda120
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/420866
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-12-20 21:56:45 -08:00
Shawn Nematbakhsh
94d27d9779 tcpm: fusb302: Don't mistake meaningful packets for GOOD_CRC
If a partner port sends a packet at approximately the same time as we
send a packet, we may end up with the initial packet followed by the
GOOD_CRC reply in our HW FIFO. Don't automatically discard the first
packet in the FIFO. Instead, discard the packet only if it's a GOOD_CRC
packet. And, modify our get_message function to automatically discard
GOOD_CRC in search of a meaningful packet.

In addition, due to interrupt latency, we can't rely on receiving one
interrupt per incoming packet. If our Rx FIFO is non-empty, assume that
it contains at least one packet.

BUG=chrome-os-partner:60242
BRANCH=gru
TEST=Manual on kevin, attach Apple dongle with no inputs. Attach zinger,
verify we negotiate to ~20V. Repeat 10x and verify negotiation is
successful each time.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I7e4430fc2b7ed44b1aa4b561d72c8e1e964b245a
Reviewed-on: https://chromium-review.googlesource.com/414927
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
(cherry picked from commit 373f5dfd75e8ea5074d26fc6392eafe83de4f905)
Reviewed-on: https://chromium-review.googlesource.com/419186
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-12-14 20:14:38 -08:00
li feng
e95ce7682e bmp280: handle divided by 0 case
In bmp280 driver bmp280_set_data_rate(), parameter rate may be 0

On reef ISH enabled board, this caused unhandled exception.

BUG=None
BRANCH=None
TEST=On reef ISH enabled board, verified barometer bmp280
sensor initialized succefully.

Change-Id: I7cdae8efbc618fca1551fd9fe809cb69ba0cee34
Signed-off-by: li feng <li1.feng@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/419744
Commit-Ready: Li1 Feng <li1.feng@intel.com>
Tested-by: Li1 Feng <li1.feng@intel.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2016-12-14 02:53:50 -08:00
Gwendal Grignou
e2e875c566 driver: bmi160: Add temperature sensor
Allow BMI160 to report temperature like other device with a temperature
sensor.
Temparature is returned in K. Although BMI160 resolution is 9bits per
degree, we round to the nearest degree.

BUG=chrome-os-partner:58894
BRANCH=reef
TEST=After enabling sensor on Reef, check we can measure the temperature
with EC console commands temp or from user space with 'ectool temps 3'
Check 'ectool tempsinfo 3' returns valid data:
Sensor name: Gyro
Sensor type: 1

Change-Id: Ib48f988e078cdee1dfbc05b23df806bd4eb09931
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/416297
Reviewed-by: Scott Collyer <scollyer@chromium.org>
2016-12-12 18:34:34 -08:00
Nicolas Boichat
9d7d189450 usb_pd_protocol: tcpm_get_message: Check return value
We currently rely on *head == 0 as error condition, which is
fragile and inconsistent across TCPCs implementations.

Instead, let's return a proper return value on all implementations.

BRANCH=none
BUG=chrome-os-partner:60575
TEST=elm FW as of 65fb80d (later version include a fix that would
     hide this issue), cherry-pick this patch, connect j5create
     adapter, then HDMI, then power => no crash

Change-Id: If7235e0491e9f80fdd50ce2605477ee518f8e1aa
Reviewed-on: https://chromium-review.googlesource.com/417443
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-12-08 22:47:02 -08:00
Nicolas Boichat
0d5562fa73 tcpci_tcpm_get_message: TCPC_REG_RX_BYTE_CNT includes header
From TCPC spec:
"""
RECEIVE_BYTE_COUNT: Indicates number of bytes in this register
that are not stale. The TCPM should read the first RECEIVE_BYTE_COUNT
bytes in this register. This is the number of bytes in the
RX_BUFFER_DATA_OBJECTS plus three (for the RX_BUF_FRAME_TYPE and
RX_BUF_HEADER).
"""

We were always reading 3 bytes too many. This is an issue if we
receive a packet followed by a hard reset, as the register value
will be set back to 0, but TCPC_REG_RX_HDR may contain a valid
header, leading to corrupted packets being passed down the stack.

Also update usb_pd_tcpc to match the specification.

BRANCH=none
BUG=chrome-os-partner:60575
TEST=elm FW as of 65fb80d (later version include a fix that would
     hide this issue), cherry-pick this patch, connect j5create
     adapter, then HDMI, then power => no crash

Change-Id: I9ed8f3b500d5733ec7563e31246505e0b8bd48bb
Reviewed-on: https://chromium-review.googlesource.com/417442
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-12-08 22:47:00 -08:00
Vijay Hiremath
f62bec5792 BD9995X: Disable input current limitation for all types of chargers
Charger Operation Control Setting 1 (CHGOP_SET1) has separate bits to
disable input current limitation for DCP, SDP, others. If it is not
disabled, input current is automatically selected, which results in
hard resets on weak chargers hence disable the input current
limitation for all types of chargers.

BUG=chrome-os-partner:60722
BRANCH=none
TEST=Tested on Reef. Input current is not automatically set to all
     types of chargers.

Change-Id: Ideb16ac2a40b403c94c28e85f254043ead7415e0
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/417234
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>
2016-12-08 12:32:38 -08:00
Shawn Nematbakhsh
a9e329864f tcpm: fusb302: Fix BIST mode
Upon request, enter BIST mode 2 (alternating 1/0 output pattern) for
50ms.

BUG=chrome-os-partner:58282
BRANCH=gru
TEST=Verify compliance test runs on kevin.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ie284066eb2fb54d1c567b516670d8bd966dc9a30
Reviewed-on: https://chromium-review.googlesource.com/401700
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
(cherry picked from commit 6686ed576ef9ad5134622f9267f4a1a90b1fac85)
Reviewed-on: https://chromium-review.googlesource.com/415490
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
2016-12-01 19:58:56 -08:00
Shawn Nematbakhsh
f5f3bcfe57 tcpm: fusb302: Remove dead rev.A code
Auto-toggle isn't used on rev. >= B so remove related dead code, and fix
VCONN setting on Rp selection.t

BUG=None.
TEST=Verify charging + DP dongles still work properly on Kevin.
BRANCH=gru.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I2ce98760d3435a5721831864f8ea241151b5a54d
Reviewed-on: https://chromium-review.googlesource.com/397658
(cherry picked from commit 4d42d16fe97d35d1d9ea6200f2343934bba4341e)
Reviewed-on: https://chromium-review.googlesource.com/415487
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-12-01 19:58:52 -08:00
Shawn Nematbakhsh
6598f08930 tcpm: fusb302: Always take hard reset actions when M_HARDSENT received
After sending a hard reset through Control3 SEND_HARD_RESET, packet Tx
will fail until PD_RESET is triggered. Therefore, always do such a reset
when we see an M_HARDSENT interrupt. Previously, it may have been possible
to skip our reset depending on prior Tx packet status, leaving the TCPC
in a wedged state.

BUG=chrome-os-partner:58232
TEST=Manual on kevin, spam 'pd 0 hard' for 10 hours with zinger attached,
verify TCPC is still responsive and negotiating to 20V.
BRANCH=gru.

Change-Id: I42db792a5f51218c58235dc38c2d49795b54986e
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/393769
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
(cherry picked from commit 811534541c263244d2fe9bdf9465de196e1575da)
Reviewed-on: https://chromium-review.googlesource.com/415486
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-12-01 19:58:49 -08:00
Vijay Hiremath
31e1ee1955 reef: BD9995X: Suspend DC-DC converter when discharging on AC
When the battery is fully charged or not charging, upon removal of
the AC, discharge takes long time. To overcome this issue suspend
the DC-DC converter when discharging on AC.

BUG=chrome-os-partner:58969
BRANCH=none
TEST=Manually tested on reef. Discharge is in the permissible range.
     'chgstate' console command prints correct values.

Change-Id: I64afa992e50b6e18daf43edf237fde8cf658a8a2
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/413153
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>
2016-11-28 01:01:16 -08:00
Nicolas Boichat
13f8bb01de driver/touchpad_elan: Report events to USB HID touchpad
Pass reported events to the USB HID touchpad driver.

BRANCH=none
BUG=chrome-os-partner:59083
TEST=make BOARD=hammer -j && util/flash_ec --board=hammer

Change-Id: I234be1a1db8526e615acdd13c5d4dae40be5bdff
Reviewed-on: https://chromium-review.googlesource.com/410960
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-11-22 18:36:39 -08:00
Gwendal Grignou
bcbeb89da1 driver: bmi160: Remove unnecessary delay
Rereading the specification, remove delays when not needed:
- When we move the sensor out of suspend, we need to wait before
using it (BMI160 spec: 2.11.38 Register (0x7E) CMD)
When we do a softreset, we need just need to wait 300us for the
sensor to go in suspend, we will wait only when we change the rate
and enable the sensor.
- The timeout at fifo flush is not needed, it was added for debugging.
- Remove unnecessary printf when initializing the magnetometer.

BUG=chrome-os-partner:59188
BRANCH=glados, reef, strago
TEST=On reef, check the EC boot faster: time spend initializing the
sensors
decreased from 240ms to 133ms

Change-Id: Ia80232da42aa705df819a4988da483a344ffcbb4
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/411964
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2016-11-21 18:22:56 -08:00
Vijay Hiremath
7f8ad649dd BD9995X/reef/snappy/pyro: Boot from the shipmode battery
Charger BGATE is off on POR hence the voltage to the battery pack is
not applied immediately from the VBUS. To overcome this issue, BGATE
is turned on (CHG_EN) at charger initialization. If the voltage across
VBATT is high but I2C is still failing, battery is booting from ship
mode hence overwrite the battery as not present till I2C on battery
is success and INIT bit is set.

BUG=chrome-os-partner:59308
BRANCH=none
TEST=Reef can boot to OS from shipmode battery.

Change-Id: If1b212612e27fd65a822675a9609f0a8c03d8add
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Signed-off-by: Divya Sasidharan <divya.s.sasidharan@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/411360
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>
2016-11-18 20:07:47 -08:00
Shawn Nematbakhsh
c7574ffbe7 tcpm: fusb302: Mask BC_LVL interrupt when PD is enabled
Avoid needless alerts due to CC lines toggling during PD communication.

BUG=chrome-os-partner:58298
BRANCH=gru
TEST=Manual on kevin. Verify PD communication with Apple USB-C dongle is
functional. Verify Source caps are sent with 100ms-200ms delay. Verify
Rp change on Donette is still detected.

Signed-off-by; Shawn Nematbakhsh <shawnn@chromium.org>

Change-Id: I83fcd1b3235969c8462d23c5159564db2c6a8392
Reviewed-on: https://chromium-review.googlesource.com/409693
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
(cherry picked from commit ae9691d0225c78bb183774d585d34de0e7399d7d)
Reviewed-on: https://chromium-review.googlesource.com/412033
Commit-Ready: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-11-17 16:09:37 -08:00
Martin Roth
897ce78bdd Fix various misspellings in comments
No functional changes.

BUG=none
BRANCH=none
TEST=make buildall passes

Change-Id: Ie852feb8e3951975d99dce5a49c17f5f0e8bc791
Signed-off-by: Martin Roth <martinroth@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/403417
Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
2016-11-15 17:41:53 -08:00
Mario Tesi
64b57efebd accel: add accel driver for LSM6DSM
This add basics for acc and gyro sensor ST lsm6dsm
Still need to add interrupt management for embedded
functions and FIFO

BUG=none
BRANCH=master
TEST=Tested on discovery BOARD with sensor connected on
EC i2c master bus. Added motion sense task on discovery
board task list, added gpio info in board configuration
file and tested with motion sense console commands. Data
for acc/gyro seems ok, can successfully change ODR and
full scale range for acc and gyro.

Change-Id: Ie50c8c0ee366994ed97f7ff3252633893b813ac2
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Reviewed-on: https://chromium-review.googlesource.com/406947
Commit-Ready: mario tesi <mario.tesi@st.com>
Tested-by: mario tesi <mario.tesi@st.com>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2016-11-15 07:04:30 -08:00
Divya Sasidharan
af848fcce3 anx74xx: Fix typo in anx74xx_check_cc_type function
BRANCH=none
BUG=none
TEST=manual, On Reef connected hoho and made sure it is
properly detected instead of as an accessory.

Change-Id: I1c271a8c5c2800dd88bf0e63a7c7aa2e23551510
Signed-off-by: Divya Sasidharan <divya.s.sasidharan@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/411382
Commit-Ready: Kevin K Wong <kevin.k.wong@intel.com>
Tested-by: Divya S Sasidharan <divya.s.sasidharan@intel.com>
Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2016-11-14 22:47:43 -08:00
Vijay Hiremath
98402bb466 smart_battery: Add console command to read ManufacturerAccess() data
Added console command to read ManufacturerAccess() data on a given
register block.

BUG=chrome-os-partner:59660
BRANCH=none
TEST=Enabled config on Reef.
     Successfully able to read ManufacturerAccess() data

Change-Id: Ic86ae1b44ca8016634c48b54b1130d30fdd2d3fa
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/409638
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>
2016-11-12 23:55:08 -08:00
Vijay Hiremath
3f728b4ca6 bd9995x: Battery charging profile settings
Added battery charging profile settings as given in the datasheet.

BUG=chrome-os-partner:58553
BRANCH=none
TEST=Manually verified on reef. VBAT is equal to battery voltage.
     Previous/current Charge status is equal to the conditions given
     in the datasheet.

Change-Id: Ie04619a122fe52d6768c03ff5156b368e3f2d340
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/398080
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2016-11-12 01:50:27 -08:00
Kevin K Wong
7300bc56c0 reef: enable tcpc low power mode
BUG=chrome-os-partner:55158,chrome-os-partner:55889,chrome-os-partner:55890
BRANCH=none
TEST=on reef use ina (pp3300_pd_a_mw) to check tcpc power consumption

Change-Id: I5a2904f4e549b7da22242848bb3b1887331ecadd
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/399882
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2016-11-11 23:11:43 -08:00
Nicolas Boichat
de0f53afef driver/touchpad_elan: Basic elan touchpad driver
BRANCH=none
BUG=chrome-os-partner:59083
TEST=make BOARD=hammer -j && bash flash_hammer

Change-Id: I0ff4f48ff1399e054f745ac13ffacf81dffedeab
Reviewed-on: https://chromium-review.googlesource.com/407740
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-11-08 23:24:52 -08:00
Gwendal Grignou
bf4e1db093 driver: sensor: Remove set_interrupt
Remove set_interrupt(), was always a noop.
Unused, interrupt is done inside the init routine.

BUG=none
BRANCH=none
TEST=buildall

Change-Id: I0ff4843212ea8140be41dcd17af130991117e3da
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/407968
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-11-08 17:12:18 -08:00
Wonjoon Lee
b044fba33c bd9995*: maintain VBAT voltage as battery maximum
BUG=chrome-os-partner:54248
BRANCH=gru
TEST=Manual on kevin, high temperature chamber(60C),
battery will require 0 voltage because of high temp,
then check 'chgstate' vbat maintained at 8688 mV.

Change-Id: I3b5835701c42a0cd861400ba921b3d3797152bbd
Signed-off-by: Wonjoon Lee <woojoo.lee@samsung.com>
Reviewed-on: https://chromium-review.googlesource.com/400088
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-11-08 02:53:54 -08:00
Scott
4555fe63f5 anx74xx: Modifed tcpm_get_cc function to fix check for 3.0 A type
When attaching a dump (not PD protocol) TypeC charger, the incorrect
charger type was being selected and therefore it was not enabling 3A
charging. I tracked this issue down to the anx74xx_tcpm_get_cc()
function returning a incorrect value. The expected value was
TYPEC_CC_VOLT_SNK_3_0, but instead it was returning
TYPEC_CC_VOLT_SNK_DEF.

The reason the incorrect cc type was being returned is because the if,
else if, construct didn't work properly for the 3A case where the
upper 2 bits are set. Modified this routine to use a case statement
and consolidated the checks for both cc1 and cc2 into one helper
function.

BRANCH=none
BUG=chrome-os-partner:58738
TEST=manual
Connected zinger and guppy chargers and verified correct cc type was
being returned. In addition tested hoho/dingdong adapters as well as
suzyq. Tested both cable orientations to verify that cc1 and cc2
returned the correct values.

With guppy connected, now see this output on ec console:
C0 HARD RST TX
C0 st5
C0 st36
C0 st37
C0 HARD RST TX
C0 st5
[1921.980074 AC on]
[1922.008140 charge_request(8688mV, 9280mA)]
C0 st6
[1922.910539 Ramp p0 st5 3000mA 3000mA]

Change-Id: I8b31c7ce366f383dfcc2f6e850b76a83340a02a1
Signed-off-by: Scott <scollyer@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/406642
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-11-04 18:31:56 -07:00
Kevin K Wong
180ac77e16 reef: enable tcpc-controlled drp toggle
BUG=chrome-os-partner:54668
BRANCH=none
TEST=Verified SNK is detected in S0 (toggle on), S3 (toggle off),
and S5 (force sink). SRC is detect in S0 only, stays detected when
entered S3, but unplug/plug while in S3 will not re-detect until
system back in S0. When go to S5, SRC will get disconnected until
back in S0, and hotplug SRC in S5 will not get detected. Checked
power role swap with another chromebook in the above scenario also.

Change-Id: I2a487fca5cb04c45524aa3efde84fcd10ff0579e
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/396918
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2016-11-02 06:42:04 -07:00
Gwendal Grignou
cd30d638ab driver: bmi160: Autocalibrate Accelerometer properly.
Take into account the rotation matrix to do calibration.
In particular the Z axis: if board is upside down, we need to use
MINUS_1G instead of PLUS_1G when setting online calibration.

BRANCH=kevin
BUG=none
TEST=Before, calibration would not work on the Z axis.

Change-Id: Ifaec331aac40a4be0e34fcab5dd3752d2d59b91f
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/405854
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-11-02 04:23:07 -07:00
Scott
e2305b6af9 BD9995X: Fix disable case in bd9995x_select_input_port
The 'else' was missing in the for the check of
port == BD9995X_CHARGE_PORT_BOTH. So if it wasn't this port type then
it would always hit the panic.

BUG=chrome-os-partner:59189
BRANCH=none
TEST=Manual
Verfied the failure case using a type C to type A adapter. After
applying the fix verified that it no longer panics.

Change-Id: Ia5a16c39e226d5e648c20d0c8675d6433d083f22
Signed-off-by: Scott <scollyer@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/405747
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-11-01 12:48:48 -07:00
Scott
e852d78bc2 anx74xx: Added check for hard reset done bit in IRQ status
The check for hard reset complete was missing. Because of this, the
USB PD protocol state machine would get stuck in state 36
PD_STATE_HARD_RESET_SEND waiting for the pd_task to be woken following
the tx_complete. Instead it would always trip the 100 msec timeout.

BRANCH=none
BUG=chrome-os-partner:58738
TEST=manual
Without this CL, connect to a Guppy TypeC charger and observe:
> C0 st3
[101.946607 event set 0x00200000]
C0 st15
C0 st3
C0 st6
C0 st36
[102.466846 New chg p0]
[102.470376 Ramp reset: st1]
[102.470905 CL: p0 s2 i2000 v5000]
[103.543623 AC on]

After adding the fix for checking hard reset done:
> C0 st3
[32.880946 event set 0x00200000]
C0 st15
C0 st3
C0 st6
C0 st36
[33.410038 New chg p0]
C0 st37
[33.415641 Ramp reset: st1]
[33.416160 CL: p0 s2 i2000 v5000]
C0 HARD RST TX
C0 st5
C0 st36
C0 st37
C0 HARD RST TX
C0 st5
[34.489611 AC on]
[34.489965 event set 0x00000008]
[34.520457 event set 0x00400000]
[34.520876 charge_request(8688mV, 4608mA)]
C0 st6
[35.419391 Ramp p0 st2 500mA 0mA]

Change-Id: I6822983002fa387c85f7e55af5fe1e142c7b88e2
Signed-off-by: Scott <scollyer@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/404878
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-10-31 11:49:29 -07:00
Vijay Hiremath
cbc14b38f4 reef: Enable BD9995X power save mode when hibernated
Turn off the charger BGATE when the system is hibernated to
save maximum power.

BUG=chrome-os-partner:59001
BRANCH=none
TEST=Manually verified on the Reef.
     System can boot from hibernate wake sources.
     Following are the power measurement values at Battery
     voltage = 8.3V & temperature = 23 deg C.
     a. Normal operation 540uA, 3.500mW
     b. BGATE OFF        80uA, 0.592mW

Change-Id: Ia30655ccefbf0dded623246150d53b2a815df2de
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/404685
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>
2016-10-28 21:07:46 -07:00
Gwendal Grignou
f0adf18c91 driver: bma2x2/kionix remove unused fields
Remove fields that are not used anymore.

BRANCH=gru
BUG=none
TEST=make buildall

Change-Id: If4128a5db05e14314bba6c1d367774f098854ac5
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/404913
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-10-28 21:06:51 -07:00
Vijay Hiremath
799c272e28 BD9995X: Disable input to port when sourcing
POR has both VCC & VBUS enabled. If the port is sourcing VBUS it will
also act as sync and AC_OK pin gets enabled. Hence disable the input
to the port when sourcing.

BUG=chrome-os-partner:59020
BRANCH=none
TEST=Manually verified on Reef. Connected HoHo and AC_OK is not
     enabled.

Change-Id: Ic51b81f45759d7dddb2c9744d1c24dbafd1e1293
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/404168
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>
2016-10-27 19:28:53 -07:00
Kevin K Wong
080c566cc8 anx74xx: update usage with its CC_STATUS register
Existing get_cc function depends on set_cc function which marks a
"pull" variable to indicate if anx74xx is setting Rp or Rd. However,
if DRP auto toggle is used, this "pull" variable is unknown, but
CC_STATUS register can differentiate between SRC and SNK, so this
"pull" variable is actually not needed.

BUG=none
BRANCH=none
TEST=verify Type-C functionality did not change on Reef.

Change-Id: I6cab8d7fcee20ec6e8414b6b2591c5d975d85293
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/396428
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-10-13 04:32:04 -07:00
Vijay Hiremath
bc34c98edd smart_battery: Remove smart charger unreachable code
Smart battery code has I2C read/write code for smart chargers
which is an unreachable code for few boards hence removed it.

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

Change-Id: I79933f61893c66447c686a81073c92f6a16e2d48
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/396279
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>
2016-10-11 01:47:52 -07:00
Gwendal Grignou
09f90a3b8f kionix: Add reading whoami to be sure device has booted.
From the specs, "KX022-1020 Specifications Rev4.0", the power up time
can be as long as 10ms.
Add a loop to be sure the device is responsive before initalizing it.

BRANCH=reef,glados,oak,veyron,cyan
BUG=none
TEST=After putting a KX022 accel as first in the list, it would not
initialize properly. After adding the loop, it initializes properly.

Change-Id: I3194a5d1deb0c2eb2a04a459aab3b4269e479af3
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/394750
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-10-08 18:34:36 -07:00
Gwendal Grignou
f11271c8ee driver: bmi160: Fix logic issue when accelerometer is not first sensor
BMI160 driver assumes accel, gyro, compass are next to each other.
It was also assuming accel was sensor 0, which is wrong.

BUG=none
BRANCH=glados
TEST=On Cave, check sensors 1 (accel) and 2 (gyro) are working properly.

Change-Id: I37402e1d48070caaecbd7e32bbf53754616ee8cb
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/394067
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-10-07 21:51:24 -07:00
Gwendal Grignou
0ea4603143 driver: bmi160: Add config variable for INT2 setting
BMI INT2 can be input or output.
It is not used currently, but configure it properly nevertheless.

BUG=none
BRANCH=none
TEST=On cave, (int2 is output), ensure FIFO headers are free of
interrupt information.

Change-Id: I9c058689a8676593aad542e33601cc11da105838
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/394066
2016-10-07 21:51:22 -07:00
Sam Hurst
ece9996136 ec: Remove fusb302 rev.A support
We're using fusb302 rev. >= B now, so let's remove rev. A support.

BUG=chrome-os-partner:57492
BRANCH=none
TEST=Manuel
- plug USBC->DP cable into TV then into kevin
localhost ~ # ectool usbpdmuxinfo
Port 0: DP INV

- plug USBC->DP cable into kevin then into TV
localhost ~ # ectool usbpdmuxinfo
Port 0: DP INV

- unplug USBC->DP cable from TV
Port 0: OPEN INV

- plug USBC->ETHERNET into kevin and verified that network
displayed ethernet

Change-Id: Ia84dc2480c1a8b003ab8dfdcdaa9f82f6d429e4b
Reviewed-on: https://chromium-review.googlesource.com/388925
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Sam Hurst <shurst@google.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-09-29 19:14:52 -07:00
Shawn Nematbakhsh
7f70ae4585 charger: bd9995x: Reset map command set on failed set operation
If BD9995X_CMD_MAP_SET fails, the charger's internal map command set
may be the old set (if the charger failed to process the command) or the
new set (if the EC failed to receive the response). Therefore, reset the
EC's known map command state on failure, so that it will always be
re-set on the next transaction.

BUG=None
TEST=Build + boot kevin.
BRANCH=Kevin

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Id16273ccf2e39b5aae7776d626aae8863e713df5
Reviewed-on: https://chromium-review.googlesource.com/390318
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-09-28 22:09:27 -07:00