Commit Graph

266 Commits

Author SHA1 Message Date
Shawn Nematbakhsh
5426122466 cleanup: pd: Define VBUS detection source
Previously CONFIG_USB_PD_TCPM_VBUS had two uses which were independent:

- When operating as a TCPC, it indicated that the VBUS level should be
  tracked (through GPIO inputs) and sent to the external TCPM when
  appropriate.
- When operating as a TCPM, it indicated that the VBUS level should be
  obtained by querying the TCPC.

These two independent uses have been split into
CONFIG_USB_PD_TCPC_TRACK_VBUS and CONFIG_USB_PD_VBUS_DETECT_TCPC, which
sould be more clear.

In addition, CONFIG_USB_PD_VBUS_DETECT_* CONFIGs have been added for
other means of VBUS detection.

BUG=chromium:616580
BRANCH=None
TEST=Verify kevin continues to boot + charge.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I936821481d6577e17e3e9c61ff97c037574d6923
Reviewed-on: https://chromium-review.googlesource.com/348950
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-06-02 14:06:53 -07:00
Shawn Nematbakhsh
0b55308198 bd99955: Clear IADP enable bit on init
After the EC is powered, we are no longer concerned with the
IADP-selected current limit, so disable IADP measurement. On some
platforms, this prevents IADP from interfering with register-selected
current limits.

BUG=chrome-os-partner:53693
BRANCH=None
TEST=Verify reef selects a new input current limit when external charger
is plugged.

Change-Id: I1acadc03e3c978368dc96fd478970960106c18fb
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/348520
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Rachel Nancollas <rachelsn@google.com>
2016-06-01 18:16:03 -07:00
Wonjoon Lee
5564c9fae7 driver: Add support bma255 sensor
BMA255 is one of BMA2x2 accel sensor series.
Adding defines,driver from
https://github.com/BoschSensortec/BMA2x2_driver

BUG=chrome-os-partner:52877
BRANCH=none
TEST="accelread 2" is working on kevin, also check accelrate,
accelrange can set proper value on IC

Change-Id: I99932ff75aae91a744fe18dddc010b802085a2da
Signed-off-by: Wonjoon Lee <woojoo.lee@samsung.com>
Reviewed-on: https://chromium-review.googlesource.com/347722
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-05-31 14:14:44 -07:00
Vijay Hiremath
52fdd95321 BD99955: Get the VBUS provided status from individual ports
BUG=chrome-os-partner:53786
BRANCH=none
TEST=Manually tested on Amenia. VBUS provide status is updated
     properly for inividual ports.

Change-Id: I59c41988438543033db2322029169f405f347869
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/347895
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-05-28 00:08:38 -07:00
Vijay Hiremath
313355302b Driver: BD99955: Enable BC1.2 support
BUG=none
BRANCH=none
TEST=Manually tested on Amenia.
     Connected Zinger, Type-C, DCP & CDP chargers. Device can negotiate
     to desired current & voltage and the battery can charge.
     USB2.0 sync device is detected by Kernel.

Change-Id: I58cb69289eef9a966e06bef8fe31d35beaec5e27
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/341030
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-05-24 15:46:01 -07:00
Ryan Zhang
35d534dfb3 COMMON: Add extend function for tmp432 IC
+ create interface to set ALERT# pin as THERM mode
  and set high limit for a selected channel

BUG=None
BRANCH=master
TEST=`make -j runtests`

Change-Id: I7325eb9ddfcaca3ea873e1ee71da74258d7bec72
Signed-off-by: Ryan Zhang <Ryan.Zhang@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/344435
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-05-18 19:44:11 -07:00
Aman Kumar
e9501105c2 TCPM : Added driver for Analogix's anx74xx chips
Driver implements TCPC for ANX74xx chips. Enables Type C
port for USB and DP alt mode. Enable port role swap feature.
 Driver implements TCPC for ANX74xx chips firmware version 1.0 and later.
Please update to ANX74xx firmware to V1.0 or later version to work.

Change list:
1, modify the position of define and struct declare
which response the comment for patch 22.

BUG=chrome-os-partner:49510
BRANCH=none
TEST=tested compiled binary for pdeval-stm32f072 board with this patch.
Power contract establishment, port role swap, DP alt mode works fine.

Change-Id: Iae6322510605a08d3bdd08446116ef5f9e4f7a7c
Signed-off-by: Aman Kumar <akumar@analogixsemi.com>
Signed-off-by: Junhua Xia <jxia@analogixsemi.com>
Reviewed-on: https://chromium-review.googlesource.com/322433
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-05-18 18:11:32 -07:00
Shawn Nematbakhsh
a4ef740391 usb_charger: Move part-specific code to usb_switch driver
Previously usb_charger.c supported only pi3usb9281, but now support for
additional parts is required. Move pericom-specific code (including the
usb_charger tasks that handles various quirks of that part) to the
pi3usb9281 usb_switch driver.

Going forward, usb_switch drivers must implement
usb_charger_set_switches() and must have some method (such as a task or
interrupt handler) to update charge_manager with information about
attached chargers.

BUG=chrome-os-partner:53363
BRANCH=None
TEST=`make buildall -j`

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I4df74e043d8cf2e532d48c39c73b7dc2930f7d3b
Reviewed-on: https://chromium-review.googlesource.com/344289
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-05-13 23:34:51 -07:00
Shawn Nematbakhsh
7d8964614d cleanup: Remove usb_switch_tsu6721 driver
This driver is not in use for any recent board and doesn't implement the
soon-to-be standard usb_switch interface routine.

BUG=chrome-os-partner:53363
BRANCH=None
TEST=`make buildall -j`

Change-Id: I7469dab42e52d9d02425ad4e7bacb81b2489ffc4
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/344417
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-05-13 23:34:51 -07:00
Wonjoon Lee
0f6dce9fe4 driver: bmi160: Add support bmi168
BMI168 is twins sensor with BMI160. Adding chip ID.

BUG=chrome-os-partner:52844
TEST="accelread 0" is working on kevin

Change-Id: Iadb5aeb9bc7be7fb2c6bc23e48ea2510b4bf84df
Signed-off-by: Wonjoon Lee <woojoo.lee@samsung.com>
Reviewed-on: https://chromium-review.googlesource.com/341578
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-05-10 09:34:54 -07:00
Stefan Reinauer
65bca9b9fd kionix: Initialize rv in all cases
Signed-off-by: Stefan Reinauer <reinauer@chromium.org>
BRANCH=none
BUG=none
TEST=compile tested for Samus

Change-Id: Ib7a0a75a2d63cf8f55d0b59f4a3225da2cb4e70b
Reviewed-on: https://chromium-review.googlesource.com/343282
Commit-Ready: Stefan Reinauer <reinauer@chromium.org>
Tested-by: Stefan Reinauer <reinauer@chromium.org>
Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
2016-05-09 09:59:42 -07:00
james_chao
1d8ff93a49 driver/accelgyro_bmi160.c: fix the error handle in read()
The function raw_read_n() return the status, and then check it
it should be saved to the variable ret.

BUG=none
BRANCH=tot
TEST=make buildall -j
Signed-off-by: james_chao <james_chao@asus.com>

Change-Id: I4d2bd200fc49892ae95c63aaeca3af75f7338bec
Reviewed-on: https://chromium-review.googlesource.com/342809
Commit-Ready: BoChao Jhan <james_chao@asus.com>
Tested-by: BoChao Jhan <james_chao@asus.com>
Reviewed-by: BoChao Jhan <james_chao@asus.com>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2016-05-06 15:01:44 -07:00
Shawn Nematbakhsh
2aadcea461 fusb302: Delay after enabling CC measurement switches
Delay after enabling CC measurements, before checking CC levels, in
order to improve accuracy.

BUG=None
TEST=Manual on Kevin. Verify CC levels are consistent with a specific
charger.
BRANCH=None

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ib9abab2abd68b071fb22200bcac36bea6e361d67
Reviewed-on: https://chromium-review.googlesource.com/340885
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Joe Bauman <joe.bauman@fairchildsemi.com>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-04-27 18:12:28 -07:00
Shawn Nematbakhsh
539e261d72 pd: Fix port enable check for low power idle
BUG=chrome-os-partner:52734
BRANCH=glados
TEST=Plug 2 PD chargers on sentry, remove the first, verify that
SLEEP_MASK_USB_PD is not briefly cleared.

Change-Id: I62309194d8b5a694487282434fc63b5f39301ba3
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/340564
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-04-25 21:04:41 -07:00
Koro Chen
f00d4621a4 elm: kionix: allow dynamic selection of SPI or I2C transport
This CL ports c9832e04f1 to Kionix accel driver. And also enables SPI
access of Elm's base kx022.

BUG=none
BRANCH=none
TEST=manual

Change-Id: I0c1de028c82fc62a124bb5b930a3882c4b368d71
Signed-off-by: Koro Chen <koro.chen@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/331851
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
2016-04-20 01:40:00 -07:00
Dino Li
69668a0443 chip: it83xx: add USBPD module
Add USBPD module for it8320 emulation board

BRANCH=none
BUG=none
TEST=manual
     plug zinger adapter, connect uart console and type commands:
       pd 1 dev [20|12|5]
       pd 1 charger
       pd 1 swap power
     and check PD states

Change-Id: I9ca1822deeb4b4dce1279a09490ed4175890cf3a
Signed-off-by: Leon-Lee <leon.lee@ite.com.tw>
Signed-off-by: Dino Li <dino.li@ite.com.tw>
Reviewed-on: https://chromium-review.googlesource.com/326230
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-04-18 17:32:41 -07:00
Anton Staaf
068cd08506 Deferred: Use deferred_data instead of function pointer
Previously calls to hook_call_deferred were passed the function to call,
which was then looked up in the .rodata.deferred section with a linear
search.  This linear search can be replaced with a subtract by passing
the pointer to the deferred_data object created when DECLARE_DEFERRED
was invoked.

Signed-off-by: Anton Staaf <robotboy@chromium.org>

BRANCH=None
BUG=None
CQ-DEPEND=CL:*255812
TEST=make buildall -j

Change-Id: I951dd1541302875b102dd086154cf05591694440
Reviewed-on: https://chromium-review.googlesource.com/334315
Commit-Ready: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-04-18 17:32:40 -07:00
Kevin K Wong
b10d12f1c9 tcpm: update code to support multiple tcpm driver
BUG=chromium:593822
BRANCH=none
TEST=make buildall

Change-Id: Ic30c1b890da7639aa80a53040ecc5bebfb4be2e8
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/336030
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-04-17 12:23:07 -07:00
Kyoung Kim
e6902404a2 Kunimitsu: remove console commands for code size
Remove following EC console commands to reduce code size:
- battfake
- apthrottle
And none of commands above are used in 'auto test'.

This is a squash of
- https://chromium-review.googlesource.com/337657
- https://chromium-review.googlesource.com/338018

BUG=none
BRANCH=firmware-glados-7820.B
TEST=make -j buildall

Change-Id: I11d2c5514f2714f0a46416feec2b2c47666fb462
Signed-off-by: Kyoung Kim <kyoung.il.kim@intel.com>
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/338893
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-04-14 17:28:17 -07:00
Vijay Hiremath
013a47740d Driver: BD99955: Add code to enable both VBUS_EN & VCC_EN for PG3
In Pseudo G3 if both VBUS_EN & VCC_EN are disabled, on plugging the AC
on either of the ports, ACOK pin is not asserted because the charger
cannot detect the voltage on either of the ports. Hence the device cannot
boot until the power button is pressed.
Enable both the VBUS_EN & VCC_EN before entering pseudo G3 at the board
level functions so that the board can boot to S0 on plugging the AC on
either of the ports.

BUG=none
BRANCH=none
TEST=Manually tested on Amenia. Enter PG3, plug in the AC, charger ACOK
     is asserted and the device boots to S0.

Change-Id: Idbae2306948a470592219edfe475dc9b45c1df58
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/338825
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-04-13 18:37:18 -07:00
Vijay Hiremath
55032aa123 Driver: BD99955: Set minimum charge current & charge voltage values
If the charge current or charge voltage registers are set to zero then the
charger cuts the power to board. BD99955 does not support 0mA charge current
& 0mV charge voltage values hence set the charge current & charge voltage
to charger's minimum values.

BUG=chrome-os-partner:52050
BRANCH=none
TEST=Manually tested on Amenia. Board can boot without the battery.
     Battery does not discharge when the charger current or charger
     voltage is sent to 0 from the charger manager.

Change-Id: I8049525594d107d7ad1ff2f17e8df757ee86458c
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/337404
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-04-07 04:06:59 -07:00
Shawn Nematbakhsh
a536bdb1cd charger: bd99955: Disable BC1.2 detection
bd99955 enables BC1.2 detection by default and auto-sets current limit
based upon the detection results. This is undesirable because it races
against our external current limit settings (eg. USB-C / PD detection).

BUG=chrome-os-partner:51766
BRANCH=None
TEST=Manual on kevin. Plug zinger 10 times, verify that battery charges
at ~1500mA on each plug, except for cases where Zinger falls into reset
/ OC loop (a separate issue).

Change-Id: I787b2434c30b89fe78bbe50666075c694bf64503
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/336970
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2016-04-05 17:48:04 -07:00
Kevin K Wong
bf24d5b264 temp sensor: add support for G782
modify g781.c/.h to g78x.c/.h to suppor both G781/G782 temp sensor
based on CONFIG_TEMP_SENSOR_G781 or CONFIG_TEMP_SENSOR_G782

BUG=none
BRANCH=none
TEST=make buildall; able to get temperature data on board with G782

Change-Id: Ia32c85e9964bfd7c0c5263f04368bc001a27fe10
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/334228
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-04-03 10:27:40 -07:00
Vijay Hiremath
e79b32eb3d Charger: BD99955: Implement charger interfaces
BUG=none
BRANCH=none
TEST=Manually tested on Amenia prototype.
     Used 'charger' console command to get the details.

Change-Id: I131c8501a4e1cedc2b7073eb43f4735a27c1a55f
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/336286
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-04-03 10:27:38 -07:00
Kevin K Wong
6711629163 sensor: update sensor driver to use I2C port from motion_sensor_t
this allow motion sensor devices to be locate on different I2C port

BUG=none
BRANCH=none
TEST=make buildall

Change-Id: Ia7ba2f5729ebb19561768ec87fdb267e79aafb6a
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/334269
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-03-31 21:35:56 -07:00
Shawn Nematbakhsh
55bd1930f1 charger: bd99955: Add support for extended features
Add support for charge port switching and extpower detection, which are
not part of the standard charger API.

In addition, add a console command for dumping all regs, which is
helpful for debug.

BUG=chrome-os-partner:51722
TEST=Manual with subsequent commit. Verify kevin charges at 3A input current
when zinger is inserted, and verify battery actually charges.
BRANCH=None

Change-Id: I98a0c0142d26facc0e0b9ef7f1dcd003ebffd9c1
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/335537
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2016-03-31 14:53:52 -07:00
Vijay Hiremath
4826d592ce Driver: bd99955: Add ROHM bd99955 initial charger driver
BUG=none
BRANCH=none
TEST=Manually tested on Amenia prototype.
     Used 'charger' console command to check the charger properties.
     Used 'battery' console command to check the battery charging.

Change-Id: Ic8787bfa3e0e3a615542b9cf72e6404fccc96e18
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/334021
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-03-22 19:54:44 -07:00
Shawn Nematbakhsh
719f5d6d01 charger: isl9237: Report nominal current limit as ramp current
isl9237 uses HW ramping but has no way to monitor the ramp current. Zero
is not a good estimate of the ramp current and scares users into
thinking their device isn't charging, so use the nominal current limit
instead.

BUG=chrome-os-partner:51286
BRANCH=Glados
TEST=Verify "ectool usbpdpower" on chell reports "14xxxmV / 2668mA"
rather than "... / 0mA" with stock charger attached.

Change-Id: I0a29c8092b4994fda68dc3db8e02be2e0f234fd9
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/334237
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
(cherry picked from commit cef36e872f72db9e060dd0cc7e5bced3062fbfd1)
Reviewed-on: https://chromium-review.googlesource.com/334395
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-03-22 19:54:40 -07:00
Joe Bauman
28334368a8 fusb302: update driver for FUSB302B
Update pull-ups code
Manage BIST Test Data bit

BUG=none
BRANCH=none
TEST=PD contract established with various devices

Signed-off-by: Joe Bauman <joe.bauman@fairchildsemi.com>

Change-Id: Ib2e5f7f5e29f280835ae890148f5c3dd2504a2f9
Reviewed-on: https://chromium-review.googlesource.com/329034
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-03-03 17:04:47 -08:00
li feng
c7b96d514d Driver: isl9237: configures ACOK assertion to switching time
Isl9237 default setting sets 1.3s debounce time from ACOK assertion
to switching. It's too long for EC being notified AC is present.
Change the value to 150ms.

BUG=none
BRANCH=glados
TEST=In Kunimitsu system, plug in Zinger and capture timestamp when EC
receive AC_PRESENT interrupt, it's reduced by ~1.2s.

Change-Id: I2b027eef816949527138f7b8b53d5408fc823093
Signed-off-by: li feng <li1.feng@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/326844
Commit-Ready: Li1 Feng <li1.feng@intel.com>
Tested-by: Li1 Feng <li1.feng@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-02-09 19:51:00 -08:00
Stefan Reinauer
bc404c94b4 Enforce compilation without system headers
This patch introduces HOST_CPPFLAGS to be used for all
objects being compiled with HOSTCC rather then the target
compiler.

Since glibc is not linked into the EC, no glibc include files
should be included in the EC code base. Hence, create local
definitions for clock_t and wchar_t that match what the glibc
include would have done, and remove some unneeded includes.

Due to very eager optimization, we have to give gcc a little
notch to not kick out memset.

Signed-off-by: Stefan Reinauer <reinauer@chromium.org>
BUG=chrome-os-partner:43025
BUG=chrome-os-partner:49517
BRANCH=none
TEST=compile tested

Change-Id: Idf3a2881fa8352756b0927b09c6a97473358f239
Reviewed-on: https://chromium-review.googlesource.com/322435
Commit-Ready: Patrick Georgi <pgeorgi@chromium.org>
Tested-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
2016-02-03 15:00:50 -08:00
Vincent Palatin
7d0152a78b tcpc: add support for TCPC with integrated high-speed muxes
The TCPCI specification defines ane optional register
18h 'CONFIG_STANDARD_OUTPUT' providing a standardized way
of steering the high-speed muxes.

Implement the feature as a usb_mux_driver, under the conditional flag
CONFIG_USB_PD_TCPM_MUX.
The USB PD port index should be set in the port_addr field of the
'usb_mux' structure.

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

BRANCH=none
BUG=chrome-os-partner:49605
TEST=run pdeval-stm32f072 connected to a Parade PS8751 board and test USB/DP
muxing.

Change-Id: I7e5f0b8ec70b1910b2cff9d106514baca8c899e5
Reviewed-on: https://chromium-review.googlesource.com/322956
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-01-27 14:52:18 -08:00
Vijay Hiremath
dda6f888dc Driver: ISL9237: Configure Prochot# Debounce time to maximum
Configured the Prochot# Debounce time to maximum (1ms) to avoid false
triggers on the Prochot pin.

BUG=none
TEST=Manually tested on Kunimitsu, Prochot pin in not triggered when
     the battery current ripples or the adapter current ripples are
     less than 1ms.
BRANCH=none

Change-Id: I3ccebcfbced2285dcacff8a3750090c0500a102c
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/322292
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-01-15 00:36:52 -08:00
Alec Berg
a9d7417951 tcpc: add 2 bytes into TX byte count register
Add 2 bytes into the TX byte count register used in
TCPC interface.

BUG=chrome-os-partner:48256
BRANCH=none
TEST=load on glados and attach zinger, make sure
PD negotiation successful.

Change-Id: Ie57d79f20def861c22f6e2e023545a65825ab3b4
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/315879
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-12-05 02:05:44 -08:00
Mary Ruthven
bf91b00486 Smart battery: wait for any battery response
Currently the EC waits until it reads a battery status with the flag
STATUS_INITIALIZED set, but the EC does not use this flag for charging
or any other battery operation. If this flag is not set, it does not
mean that the battery is unusable, it just means that its values may not
be trustworthy.

This change will remove the check for STATUS_INITIALIZED and just check
that the battery responds. The battery response shows that the battery
is connected and can be used by the EC.

BRANCH=none
BUG=chromium:564893
TEST=see that device without STATUS_INITIALIZED set will exit
battery_wait_for_stable() without timing out.

Change-Id: I07778e8570b6d9400b61beec6b2e222984a40692
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/315200
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-12-03 02:22:03 -08:00
Gwendal Grignou
53fa1d1f09 driver: si114x: Unlock the device if stuck
It is possible for the ALS state machine and the chip to not
agree: The EC thinks the device is busy making a measurement,
while the chip is waiting for the IRQ status register to be written.
It is not clear how it happened, an IRQ must have been lost.

Reinitiliazed the chip is stuck for 10s.

BRANCH=smaug
BUG=chrome-os-partner:45627
TEST=With an extra patch that force the IRQ handler to not do anything
every 100th, check the device recovers.
Use andro sensor to monitor light/proximity outputs.

Change-Id: I80d50bf92af127f85f82dc5c0ae318d4cfe06812
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/313668
2015-12-01 03:46:34 -08:00
Gwendal Grignou
02ddede08e device: si114x: Address overflow condition
If proximity overflow (daylight), we would still assume the data was valid
and consider there is an object very very close.
That would prevent the light to be measured. (cl/312982)

Leave the value as max range for the HAL to handle.

BRANCH=smaug
BUG=b:25573958
TEST=Check in daylight that light is still measured

Change-Id: I684e6f4a9aecd3fd6b338a9939f7ede26752ecb8
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/314921
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-12-01 01:11:11 -08:00
Shawn Nematbakhsh
326bff520b fusb302: Don't flush RX FIFO on GoodCRC
Depending on timing, additional important messages may reside on our RX
FIFO at the time we process GoodCRC. Therefore, rather than flushing the
RX FIFO, simply read and discard the GoodCRC message.

BUG=chrome-os-partner:314492
BRANCH=None
TEST=Manual on Snoball with subsequent PWM changes. Verify PD contact
can be established with samus.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I4f4fab1bc318d1bce1effffad9a792c5b4a43761
Reviewed-on: https://chromium-review.googlesource.com/314871
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-12-01 01:11:07 -08:00
Duncan Laurie
3df2228c14 ps8740: Add a function to tune USB EQ settings
This adds a new function that can be use to apply USB EQ settings
to the mux.  It currently only exposes the Tx and Rx channel
loss compensation.

BUG=chrome-os-partner:47074
BRANCH=none
TEST=build and boot on chell

Change-Id: I1ec83cdcbb17da8e7289e6633509b64f01b14348
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/313747
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-11-24 11:02:49 -08:00
Duncan Laurie
1ea9dece80 usb_mux: Add a callback for board specific init
This adds a callback for board specific initialization that is called
after the driver init function.  This will allow a board to apply
port-specific tuning (such as USB EQ settings) to the mux chip.

BUG=chrome-os-partner:47074
BRANCH=none
TEST=build and boot on chell

Change-Id: Ib162f9a2c5239678c46b80e5517823b336f6b66c
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/313746
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-11-24 11:02:49 -08:00
Gwendal Grignou
2c8817117a common: spi: Add a delay after write commands.
Some SPI slave devices need a delay to digest write commands. (BMI160).
Add a 1ms delay in the write command.

BRANCH=smaug
BUG=none
TEST=Check on the logic analyzer that there is ~1.5ms delay between back
to back spixfer w ... commands.

Change-Id: I7cc6ed0da9ae39550e58457b9431eb01b5ab36d8
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/305379
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-11-19 02:18:10 -08:00
Gwendal Grignou
cfae64d5de driver: si114x: Do not read light when proximty is low
If the proximity sensor indicates there is an object very close
(<= 5cm), ignore light sensor readings.

Otherwise, when someone put their finger on the sensor, the light
sensor would most likely report dark condition and the screen brightness
will be lowered unexpectedly.

BUG=b:25573958
BRANCH=smaug
TEST=check light report does not change when proximity sensor reports
< 5cm, using androsensor apps.

Change-Id: I16db40766a71a7925e28372ebb54ae43f60a4989
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/312982
2015-11-18 13:33:26 -08:00
Shawn Nematbakhsh
7f1baece0a fusb302: Move i2c slave address defines to common header
BUG=None
TEST=`make buildall -j`
BRANCH=None

Change-Id: I51000b3ad32ebef8d19a685b8adbbbe2a42301f5
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/312797
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-11-17 22:06:57 -08:00
Alec Berg
f0489dc275 pd: initialize tcpc when tcpm boots
Always initialize TCPC when TCPM boots. This guarantees
that our TCPM driver is synced up with the TCPC reg values.

BUG=chrome-os-partner:47608
BRANCH=none
TEST=test on glados. reboot EC and PD MCUs independently
with and without external power.

Change-Id: I2d989e8a85ba8a72fe1a8edaef8da9c51651d240
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/312951
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-11-17 22:06:49 -08:00
Shawn Nematbakhsh
1ade79a8e6 cleanup: Fix gcc 5.2.1 compile errors
BUG=chromium:552006
BRANCH=None
TEST=`make buildall -j` and also verify panic reporting works on
glados_pd.

Change-Id: Ic9f1ec6b5297389df0d46bb38a67c156901ed956
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/311253
Commit-Ready: Shawn N <shawnn@gmail.com>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-11-11 11:00:56 -08:00
Alec Berg
75f740fa23 glados: isl9237: add HW charge ramping
Add HW charge ramping option and enable on glados.
Modify charge_manager to enable/disable HW charge ramping
when option is defined.

Unfortunately, the isl9237 doesn't have a way to determine
what the input current limit has settled on, so the EC will
always report the max input current for that supplier.

BUG=chrome-os-partner:47335
BRANCH=none
TEST=plug in CDP, SDP, DCP, type-C, and PD charger. Make sure
we ramp to a reasonable value for the correct suppliers.
Make sure we don't ramp for type-C and PD chargers.

Change-Id: Ib541fa0be48d8f4d261c71b853b0ee72b2adbf6b
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/311301
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-11-09 12:49:30 -08:00
Shawn Nematbakhsh
92a65427d3 tcpm: Add configuration struct for tcpc i2c params
Add a new configuration struct tcpc_config_t that initially defines the
i2c host port and i2c slave address of all TCPCs present on the board.
This will allow us to create boards with multiple TCPCs on different i2c
ports, with arbitrary i2c slave addresses.

BUG=chromium:551078
TEST=Manual on glados. Verify PD communication / charging is still
functional on both PD ports.
BRANCH=None

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I9b2bde85d7f1642e8727c052e064371be7967619
Reviewed-on: https://chromium-review.googlesource.com/311000
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-11-08 17:31:12 -08:00
Gabe Noblesmith
e3554f39d7 Initial commit of TCPM driver for FUSB302.
BUG=none
BRANCH=none
TEST=PD contract established with various devices

Change-Id: I4b452befe9ccd9d67bd6ad5c8cf77ae58320f6af
Signed-off-by: Gabe Noblesmith <gabe.noblesmith@fairchildsemi.com>
Reviewed-on: https://chromium-review.googlesource.com/294924
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-11-04 07:08:36 -08:00
Alec Berg
4f090ad68e oak_pd: change oak_pd to be a sym link to glados_pd
Make oak_pd a sym link to glados_pd. A few small changes
necessary to make this possible:
- glados_pd now sets the VBUS present power status bit as oak_pd
does and as is appropriate for TCPCI spec.
- oak_pd now has watchdog enabled (not sure why it was
previously disabled).
- add a flag in gpio.inc to define EC_INT pin on B5 for oak_pd
and A14 for glaods_pd (and all other boards pointing to
glados_pd). Note: this breaks oak board rev 1, where EC_INT was
on A14.

BUG=none
BRANCH=none
TEST=make -j buildall
Load on glados and make sure zinger works.

Change-Id: I28f4ee106e44e2819919f1826508fc1fc05bb2a1
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/310193
2015-11-04 07:08:35 -08:00
Gwendal Grignou
21c46e7b13 motion: Remove duplicate shutdown code
Call shutdown() entry point at init() and remove duplicate code.
shutdown would init the sensor so they would be ready if needed.
Set S5 flag to include G3 (hard off) state, not only S5 (soft off).

BUG=chrome-os-partner:45722
BRANCH=smaug
TEST=When doing a RO->RW transition while AP is in G3, check the sensors
are initialized properly. This issue was found while testng the magic
sequence code.

Change-Id: I647f83580240bf5ba0c340fca3184220abe4c12e
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/308561
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-10-28 00:23:48 -07:00