Commit Graph

3765 Commits

Author SHA1 Message Date
Vincent Palatin
94baa433bc bq2589x: update driver
Update the BQ2589x charger driver to configure properly the boost
used as a VBUS 5V source.
Define the bits used for I2C registers configuration.
Return success in unused charger callbacks to avoid blocking the
charge state machine.

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

BRANCH=none
BUG=chrome-os-partner:38603
TEST=On Ryu P4 reworked with BQ25892, plug a C-A receptacle adapter and
see the 5V VBUS coming up, un-plug it and see VBUS going away,
try several PD/type-C charger and check the selected current limit.

Change-Id: I24b832b6d130ff6dfda1ce47f5e445d65279fa7d
Reviewed-on: https://chromium-review.googlesource.com/266063
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2015-04-21 00:18:50 +00:00
Yunlian Jiang
e4f8b16a62 ec: fix a clang warning by use a unused variable.
This uses the variable 'usage' in an error message to fix a clang
warning.

BUG=chromium:475960
TEST=CC=x86_64-cros-linux-gnu-clang emerge-falco ec-devutils
BRANCH=none
Signed-off-by: yunlian@chromium.org

Change-Id: Ic5703636040805661c7b81b83fc182e127ceab8c
Reviewed-on: https://chromium-review.googlesource.com/266404
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Yunlian Jiang <yunlian@chromium.org>
Commit-Queue: Yunlian Jiang <yunlian@chromium.org>
2015-04-20 23:02:02 +00:00
Aseda Aboagye
d02620a05d lsm6ds0: Cache ODR and range on EC.
For the driver functions get_range and get_data_rate, each call would
end up executing an i2c transaction even if the value had not
changed. Therefore, I modified the lsm6ds0 driver to cache the output
data rate as well as the range. This prevents unecessary i2c
transactions from occuring.

BUG=chromium:476226
TEST=Flashed EC on samus and verified that the accelrange and accelrate
commands still worked and that the sensors were functional.
TEST=Verified Double Tap still worked.
TEST=make -j buildall tests
BRANCH=none

Change-Id: Ie432979266dc4e4892978005de5d1df62cc0654f
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/265933
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
2015-04-20 18:46:08 +00:00
Vincent Palatin
a97af9a8b2 Move target specific GCC code generation options
Move "-fno-delete-null-pointer-checks -fconserve-stack" to the
target-only portion of the CFLAGS as they are no needed for host tools
(and not supported by clang).

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

BRANCH=none
BUG=chromium:475960
TEST=make utils-host V=1
make BOARD=samus_pd V=1
and manually check the compilation flags

Change-Id: I001359621d60b5ad4e020f41fe2e97d4b7edec2a
Reviewed-on: https://chromium-review.googlesource.com/266212
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2015-04-18 01:26:55 +00:00
Yunlian Jiang
908c93bf00 ec: fix duplicate 'const' warning for clang..
It fixes duplicate 'const' warning.

BUG=chromium:475960
TEST=the warning is gone.
BRANCH=none
Signed-off-by: yunlian@chromium.org

Change-Id: I348fbefec4d681bb8b20c6b8cf84acec4561b391
Reviewed-on: https://chromium-review.googlesource.com/266109
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Yunlian Jiang <yunlian@chromium.org>
Tested-by: Yunlian Jiang <yunlian@chromium.org>
2015-04-18 00:13:20 +00:00
Randall Spangler
70be516815 samus_pd: Don't put pstate in a separate erase block
This frees up 4KB of space for EC_RO, so both it and EC_RW can expand
to 64KB instead of 60KB.

Note that if a EC-RW with this change is written on a system with an
old EC-RO without this change, the new EC-RW will be unable to
enable/disable flash protection (because it won't be able to change
the pstate in the separate block used by the old EC-RO).  So this
should NOT be picked to the samus branch.

BUG=chromium:476659
BRANCH=none
TEST=sudo fmap_decode build/samus_pd/ec.bin
     Note that EC_RO is now 0x10000 bytes, not 0xf000 bytes.
     Add a bunch of dummy printf()'s and see that EC_RO code size can go
     past 0xf000 bytes, where without this change it overflows the .rodata
     segment and fails to build.

Change-Id: I67ec3e2c787a467f87e52a83d3bd81b79f1ffa61
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/266115
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-04-17 20:53:53 +00:00
Randall Spangler
932eb3ddca flash: Add option to move pstate inside RO image
Currently, ECs with internal flash store the write protect state for
RO in a separate write/erase block of flash.  This is wasteful on
chips where there are not many blocks of flash.

Add a new CONFIG_FLASH_PSTATE_IN_BANK option which is defined by
default.  This is the old behavior, for compatibility.  (And we're
calling it 'bank' because that's what the existing code does, even if
the terminology is somewhat etymologically... bankrupt.)

If that config is #undef'd, then store the write protect flag directly
inside the RO image.  This uses only 4 bytes of the RO image, instead
of an entire erase block.  The magic numbers for the pstate values are
chosen such that when protecting RO, bits are only transitioned away
from their erased state.  Unprotecting RO once it's protected requires
reflashing RO; it's no longer possible to 'flashwp disable'.  But
that's ok, because realistically, the only reason to unprotect RO is
if you're about to flash the RO firmware anyway.

BUG=chromium:476659
BRANCH=none
TEST=Without undefining CONFIG_FLASH_PSTATE_IN_BANK, make sure everything
     still works on samus and samus_pd.  This ensures we didn't break the
     existing functionality:
         flashinfo -> no flags
         flashwp enable
         flashinfo -> ro_at_boot
         reboot
         flashinfo -> ro_at_boot
         flashwp disable
         flashinfo -> no flags
     Then recompile with #undef CONFIG_FLASH_PSTATE_IN_BANK and test:
         flashinfo -> no flags
         flashwp enable
         flashinfo -> ro_at_boot
         reboot
         flashinfo -> ro_at_boot
         flashwp disable -> fails with access denied
         flashinfo -> ro_at_boot
     Then reflash to verify that clears the ro_at_boot flag:
         flashinfo -> no flags

Change-Id: Ie794b8cfed2a10c50b0e36dcf185884070b04666
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/266095
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
2015-04-17 19:38:17 +00:00
Vincent Palatin
0df89000a5 pd: add a connection flag to pd port info for host
Export what the PD protocol stack thinks about the port connection
state. This simplifies getting a meaningful data role/power role from the
host (eg we are not really a UFP if we are simply dual-role toggling but
not connected).

Do not increment the command version as this is mostly
backward-compatible and currently no client actually uses that field.

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

BRANCH=samus
BUG=none
TEST=ectool --name=cros_pd usbpd 0
plug and unplug various accessories on the port and check the result.

Change-Id: Ief3e0d47b6a288bcfc5b8fbb8156f29fd09dd336
Reviewed-on: https://chromium-review.googlesource.com/266120
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Benson Leung <bleung@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2015-04-17 19:38:11 +00:00
Shawn Nematbakhsh
78de9268b7 i2c: Support I2C controllers with multiple ports
Certain chips have I2C ports mapped to the same controller. In this
case, it's necessary to lock out access to the controller during use.
This configuration can be supported by adding CONFIG_I2C_MULTI_PORT_CONTROLLER,
which can be defined at the chip level, along with an API function to
map port index to controller index.

BUG=chrome-os-partner:38335,chrome-os-partner:38945
TEST=Manual with subsequent commit. Verify that i2cscan is functional on
strago.
BRANCH=None

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I37ffa661a2ad6cd2235cef2ee77637cc3ab92523
Reviewed-on: https://chromium-review.googlesource.com/265942
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Kevin K Wong <kevin.k.wong@intel.com>
2015-04-17 19:38:02 +00:00
li feng
bbdf126ef5 strago: Added power/battery LED support.
BUG=None
TEST=Verified LED changes color according to AC and battery status.
BRANCH=none

Change-Id: I83cc8255da385e38f08ee13b1eab90ee494b792d
Signed-off-by: li feng <li1.feng@intel.com>
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/265543
Reviewed-by: Shawn N <shawnn@chromium.org>
Commit-Queue: Divya Jyothi <divya.jyothi@intel.com>
2015-04-17 04:06:31 +00:00
Mike Frysinger
f55a7e5774 clean up x86 i/o checks
Rather than hardcode a specific mips toolchain, do a build-time test to
see if the target is x86 based.

BUG=chromium:443783
TEST=link still includes comm-lpc
TEST=arm64 omits comm-lpc
BRANCH=none

Change-Id: I0253df6cbe89bee231ec643dd6bb3498eb040708
Reviewed-on: https://chromium-review.googlesource.com/265793
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
2015-04-17 01:47:34 +00:00
Kevin K Wong
a5b3bb0f97 strago: Added temperature reading for battery.
BUG=none
TEST=Verified `temps` prints the battery temperature.
BRANCH=none

Change-Id: Ied6eb5c6c01f7bd4b5f397cb59e165fc7bd7024f
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/265900
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-04-16 03:55:42 +00:00
Icarus Sparry
4fce69d394 mec1322: Changed to generate ec.bin for the firmware binary.
Previously for the mec1322 chip an ec.bin file was created in the normal way
and then it was "packed" in a post-processing stage to produce ec.spi.bin.

This change allows a chip or board build.mk file to specify the rules used to
produce ec.bin, and uses this for the mec1322 to do the packing. This means
that we can use the standard "ec.bin" name, and do not need to alter other
scripts, such as the script which creates chromeos-firmwareupdate.

BUG=None
TEST=buildall -j, flash on strago and see it still works.
BRANCH=NONE

Change-Id: I3f880d64e60d14f82cb1d21c8b3f2d4ae5e0dfef
Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/265544
Tested-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Kevin K Wong <kevin.k.wong@intel.com>
2015-04-15 22:58:27 +00:00
Bill Richardson
6ab1f5b703 usb: Remove unnecessary alignment for descriptors
This was causing the amount of data sent to be larger than the
total size of the descriptors.

Before this CL, connecting the Cr50 through USB gave this kernel
message:

  usb 2-1.4.7: config 1 descriptor has 1 excess byte, ignoring

When the host requests the descriptor, the code in chip/*/usb.c
that handles it looks like this:

	case USB_DT_CONFIGURATION: /* Setup : Get configuration desc */
		desc = __usb_desc;
		len = USB_DESC_SIZE;
                break;

But include/usb.h has this:

    #define USB_DESC_SIZE (__usb_desc_end - __usb_desc)

And both __usb_desc and __usb_desc_end come from the linker
script.

BUG=none
BRANCH=none
TEST=manual

Before this change, I built the Cr50 firmware from m/master,
tried it, and got the dmesg complaint on the host.

After this change, the dmesg complaint doesn't show up anymore.

Change-Id: I83ae2333a9e76af7acb18bd2f0e4cef5c095862a
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/265765
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-04-15 21:39:08 +00:00
Kevin K Wong
5654dedc87 strago: Enabled accelerometer support.
BUG=none
TEST=Verified lid angle value via accelinfo console command.
BRANCH=none

Change-Id: I7857fadeb6ffbd83c55d00649437c52ac3f204ba
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/265595
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-04-15 04:50:45 +00:00
li feng
26c777c5e0 Strago: Enable and config charger BQ24770
BUG=None
BRANCH=None
TEST=Battery Charging was valitated.
1.Tested with a Dead Battery
and saw it charging.
2.Battery Full charge condition was validated.

Signed-off-by: li feng <li1.feng@intel.com>

Change-Id: If81d700aff2b929f8f8fc183fea4bdece00c4a46
Signed-off-by: Divya Jyothi <divya.jyothi@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/265541
Tested-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
Commit-Queue: Kevin K Wong <kevin.k.wong@intel.com>
2015-04-14 19:08:06 +00:00
Todd Broch
84e85bd6f0 pd: Qualify modep pointer before use.
If UFP sends invalid VDM responses to the DFP its possible that modep
pointer may be NULL.  CL qualifies all uses of modep to guarantee that
these invalid responses don't cause samus_pd to crash.

BRANCH=samus
BUG=chromium:476773
TEST=manual,
1. Still successfully negotiate alternate mode (both DP & GFU) with
   hoho.
2. passes usbpd_DisplayPortSink autotest.

Change-Id: If4a611182b5e659c5534c2206132ef76d4e023db
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/265620
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-04-14 17:56:08 +00:00
Kevin K Wong
3779b8ccbe strago: Added support for TMP432 temperature sensor.
BUG=none
TEST=Verified tmp432 console command is returnning correct temperature.
BRANCH=none

Change-Id: Ic43af17961361e4c971a343a0d24d310c3aaf2ac
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/265540
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-04-14 01:15:49 +00:00
li feng
356695da35 panic: Fix unaligned memory access panic
Unaligned memory access would not cause reboot on some
processors. Additional condition was needed.

BUG=none
TEST=Verified that "crash unaligned" causes a panic on mec1322.
BRANCH=none

Change-Id: Icdc1b5e11634b14890755301346183e0dba723c9
Signed-off-by: li feng <li1.feng@intel.com>
Signed-off-by: Divya Jyothi <divya.jyothi@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/263949
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-04-14 01:15:43 +00:00
Kevin K Wong
e4006bbace mec1322: Updated code to only clear the interrupt status bit of LPC_RESET#.
Interrupt Source register is R/WC, so |= should not be used.

BUG=none
TEST=Verified LPC_RESET# is detected by interrupt handler via EC console.
BRANCH=none

Change-Id: Ib553c839e1311538b17a4d9fbc10c9df5b7e6b44
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/265502
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-04-14 01:15:38 +00:00
Kevin K Wong
8580227b40 mec1322: Added CONFIG_SWITCH support.
This allows switch status to be updated to EC MemMap.

BUG=none
TEST=Verified mmapinfo console command is reporting the correct info.
BRANCH=none

Change-Id: I3b6683be8b92b59dffb3227e0a72a122dcda56a2
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/265493
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-04-13 21:31:58 +00:00
Anton Staaf
af27fe8983 CCD: Switch PD_NO_DEBUG logic to use system_is_locked
The system_is_locked function encompases the required checks
for asserting PD_NO_DEBUG.  It also supports forcing a
system to be unlocked at build time, as well as handling
systems without flash.

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

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

Change-Id: I676acb5a2ae169f9739a19910a760706f69f5b7b
Reviewed-on: https://chromium-review.googlesource.com/265463
Trybot-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2015-04-13 20:01:05 +00:00
Anton Staaf
8c0cef2607 USB: Fix memcpy routines
The memcpy like routines for moving to and from usb packet
RAM couldn't deal with all unaligned uses, this fixes their
behavior.  In particular, a previous caller might assume
that the packet RAM addresses were contiguous and attempt
to break up a call into two separate chunks (as the queue
insertion/removal code does).  But this can lead to invalid
pointers passed to these memcpy routines.  A much cleaner
solution is to make the packet RAM address space contiguous.
To do so the memcpy routines take packet RAM addresses
instead of AHB address space mapped addresses and
__usb_ram_start needed to change to be of type usb_uint so
that pointer arithmatic on it worked correctly on all platforms,
this also allowed the usb_sram_addr macro to be simplified.

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

BRANCH=None
BUG=None
TEST=make buildall -j
     Verify that USB still works on Ryu and discovery-stm32f072

Change-Id: I479461f07a3203f1e6e0cf9705f512a5a43c4646
Reviewed-on: https://chromium-review.googlesource.com/264764
Trybot-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Anton Staaf <robotboy@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2015-04-13 20:00:58 +00:00
Todd Broch
0016de8250 plankton: Initialize re-driver.
Host's single lane training algorithm in kernel (intel_dp_is_reversed)
appears to confuse the re-driver's auto training algorithm.  If
however its manually configured the algorithm succeeds.

NOTE, this does present risk on the DPsrc (re-driver) to DPsink
(external monitor) side as voltage levels & pre-emphasis will NOT be
adjusted.

This may be acceptable in the short-term while determining if
additional functionality needs to be added on host side to account for
re-driver's presence

Signed-off-by: Todd Broch <tbroch@chromium.org>

BRANCH=none
BUG=chrome-os-partner:35153
TEST=manual, plankton drives 4K monitor in both polarities

Change-Id: I83ea80c44d36ad1afad56528c80ec5b8a138b5be
Reviewed-on: https://chromium-review.googlesource.com/263138
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
2015-04-13 17:38:11 +00:00
Anton Staaf
0f6335451d USB-Stream: Switch to handling packets in a deferred hook
Previously the TX and RX queues were being accessed from two
different locations without locking, which is wrong.  This
moves the access to a single location in a deffered hook and
calls that hook from the old locations.  The result is
correct, simpler, and not much slower.  It also reduces time
in the USB interrupt handler by moving the memcpy from packet
to queue out to the deferred hook.

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

BRANCH=None
BUG=None
TEST=make buildall -j
     Verify that USB streams still work on Ryu and discovery-stm32f072

Change-Id: I6ea53d7c40b42c6112e86a7886f3b888408f72b7
Reviewed-on: https://chromium-review.googlesource.com/264763
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
Trybot-Ready: Anton Staaf <robotboy@chromium.org>
2015-04-13 16:32:14 +00:00
Anton Staaf
676a995cb3 Ryu: Add PD_NO_DEBUG logic
Signed-off-by: Anton Staaf <robotboy@chromium.org>

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

Change-Id: I79f831c8a0b581561472470986b86c77b7f824a1
Reviewed-on: https://chromium-review.googlesource.com/264796
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
Trybot-Ready: Anton Staaf <robotboy@chromium.org>
2015-04-13 15:27:11 +00:00
Alec Berg
f224ae87bd pd: samus: support vconn swap and enable on Samus when in S0/S3
Support VCONN swap on samus and always accept VCONN swap when in
S0 or S3. In S5, we can't provide VCONN, so reject VCONN swap
requests.

BUG=chrome-os-partner:34978
BRANCH=samus
TEST=load on two samus' and use "pd 1 swap vconn" to swap which
side is source vconn. also run in S5 and verify swap request is
rejected.

Change-Id: I04be8d1d910a2d6c5ad8b27a790f8e33121c86ee
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/264856
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-04-11 04:32:33 +00:00
Vincent Palatin
007fadda59 stm32f0: make ADC watchdog feature modular
The ADC watchdog is about 2/3 of the ADC code size and it is not
optimized out when not used because adc_read_channel() needs to
stop/restart the watchdog if somebody is using it.

The feature is enabled by default to keep the current behavior on
STM32F0 platform, and it is turned off on samus_pd :
This is saving 448 bytes of flash (and 8 bytes of RAM).

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

BRANCH=none
BUG=none
TEST=make buildall and check the firmware size before and after.
when CONFIG_ADC_WATCHDOG is disabled, adc_enable_watchdog() is not
compiled if there is any user the build will fail.

Change-Id: Ie2450bc2a8fd97662322fd3ce87e93c3fece6c6f
Reviewed-on: https://chromium-review.googlesource.com/265303
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2015-04-11 03:11:02 +00:00
Vincent Palatin
72ca4cc9f9 util: workaround warm_reset issue in flash_ec
The warm_reset_l signal is an open drain output on the servo side and
its input value can be read back as on (level 0) when the AP power rails
are off on the DUT side and not pulling it up.

So the current mechanism of reading the warm_reset input value with
dut-control at the beginning, then restoring it at the end is sometimes
broken because when the AP is OFF, we are reading input == on (while we
had actually set output to "off" but we have no pull-up) and then
restoring a "hard" on (drive low on the servo side).

In this workaround, just assume we don't want to pull warm_reset after
flashing the EC and restore it to off.
A better solution might be to have a mechanism in dut-control to read
the output register rather than the input value for GPIO, so we can save
and restore them safely.

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

BRANCH=none
BUG=chrome-os-partner:30738
TEST=On Ryu P5 with the AP off, run ./util/flash_ec --board=ryu
then boot the AP properly with the power button.

Change-Id: I96e65c2fec5e6d604445af3fe26fce73678b1d3b
Reviewed-on: https://chromium-review.googlesource.com/265223
Reviewed-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
2015-04-11 00:36:08 +00:00
Vincent Palatin
b5f2ca5dac ryu: remove lightbar traces by default
The lightbar traces are quite verbose when going through AP power cycles
and prevent people from debugging the current power issues.
Let's turn them off by default, real lightbar lovers can still use
the "chan" command to re-enable them.

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

BRANCH=none
BUG=none
TEST=mkae buildall

Change-Id: Ia91f1f9ea2c62a35a0d64e06d377f137ba69fc5e
Reviewed-on: https://chromium-review.googlesource.com/265145
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
2015-04-11 00:36:05 +00:00
Vincent Palatin
68f65494c7 ryu: rework the workaround for the EN_PP3300 issue
When shutting down the MAX77620 PMIC by asserting its SHDN pin, the
EN_PP3300 output of the PMIC (GPIO3) is not driving low keeping the PP3300
rail up. Workaround that issue by removing the pull-up on EN_PP3300 when
we assert SHDN.

Revert the previous CL 263958 aka "ryu: workaround MAX77620 shutdown issue",
in order to use a better workaround which ensures that the power rails
sequencing at startup

Detect the PP1800 rail going up and down by reading the HPD_IN gpio
state (which has a pull-up tied to PP1800), then enable/disable
EN_PP3300 in sequence.

The code using an interrupt on HPD_IN is enabled only on P5,
and as a downside, it is killing the base charging on those boards.
Indeed HPD_IN(C1) is hijacking the EXTINT1 which used to be connected
to the LID_OPEN (E1) GPIO used for the base detection.

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

BRANCH=none
BUG=chrome-os-partner:38689
TEST=on both P4 and P5 boards, do various power cycling sequences of the
AP using the "apshutdown" and "powerbtn" commands.

Change-Id: Icad6e9ae6a08d76cbfd19f97dd7c129bf43037d8
Reviewed-on: https://chromium-review.googlesource.com/265186
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-04-11 00:35:59 +00:00
Vincent Palatin
15391709fd twinkie: add simple text tracing mechanism
When using the Twinkie dongle without a protocol decoder on the host,
add a simple text tracing mechanism, so the user can get the timestamped traces
of the packets on the wire (in a best effort fashion).

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

BRANCH=none
BUG=none
TEST=On Twinkie command-line, type "tw trace on"
then plug a DingDong to Samus through Twinkie and
see the PD message traces on the console.

Change-Id: I4fa35d6783cc6279c95209c86f37e6d717de7301
Reviewed-on: https://chromium-review.googlesource.com/237222
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2015-04-10 23:29:31 +00:00
Vincent Palatin
686a23585e optimize printf size without the common runtime
When a platform is built without the common runtime to optimize for
flash size, remove the 64-bit support in printf to save more space
(mainly by getting rid of the uint64divmod helper).

This saves 376 bytes of flash on Zinger/MiniMuffin.

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

BRANCH=none
BUG=none
TEST=make buildall and compare flash size with and without the change.
the common runtime binaries are identical excepted the version
information.

Change-Id: I1e7237e693df9ea23291c8c0fe414c3b5c716848
Reviewed-on: https://chromium-review.googlesource.com/265052
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2015-04-10 23:29:27 +00:00
Vincent Palatin
8d47a1de0a stm32f0: fix adc_read_all_channels()
We need to clear DMA status before starting another transaction.
Otherwise, we get incorrect values.

Same fix as the one Vic did in CL 240282 for STM32F1xx and STM32F3xx.

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

BRANCH=none
BUG=chrome-os-partner:38902
TEST=On the twinkie USB console (without anything connected), do "tw res
rd rd" then "adc". We now always get "CC1_PD = 0 CC2_PD = 0" rather than
some fancy values for CC2_PD such as "CC2_PD = 29097".

Change-Id: I065b2f8f74ba39f805445bab96b45819322a7da3
Reviewed-on: https://chromium-review.googlesource.com/264981
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
2015-04-10 23:29:21 +00:00
Alec Berg
c7ad72693e pd: combine src/snk dr_swap states into one dr_swap state
Combine source and sink data role swap states into one data
role swap state. This saves 128B of flash.

Also add DUAL_ROLE_IF_ELSE macro to clean up all the places
we check our role and need to know if we are DUAL_ROLE or not.

BUG=none
BRANCH=samus
TEST=load onto two samus' and try data swaps from both sink and
source sides and make sure they get rejected and go back to the
correct ready state. load onto zinger and make sure we successfully
data swap when connected to samus.

Change-Id: I57744593ce291e512cb254b08745115de365cab4
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/264855
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-04-10 22:08:35 +00:00
Alec Berg
a90f4dd25e samus_pd: disable timerinfo command to save space
Disable the timerinfo command on samus_pd to save flash space

BUG=none
BRANCH=samus
TEST=make -j buildall
From .map file, 256 bytes saved

Change-Id: I6731967741cb28268499126f1753916319a1dcb4
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/264939
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-04-10 22:08:31 +00:00
Aseda Aboagye
e9883124ff gpio: Refactor IRQ handler pointer out of gpio_list
In the gpio_info struct, we had a irq_handler pointer defined even
though a majority of the GPIOs did not have irq handlers associated. By
removing the irq_handler pointer out of the struct, we can save some
space with some targets saving more than others. (For example, ~260
bytes for samus_pd).

This change also brings about a new define:

     GPIO_INT(name, port, pin, flags, signal)

And the existing GPIO macro has had the signal parameter removed since
they were just NULL.

     GPIO(name, port, pin, flags)

In each of the gpio.inc files, all the GPIOs with irq handlers must be
defined at the top of the file. This is because their enum values from
gpio_signal are used as the index to the gpio_irq_handlers table.

BUG=chromium:471331
BRANCH=none
TEST=Flashed ec to samus and samus_pd, verified lightbar tap, lid, power
button, keyboard, charging, all still working.
TEST=Moved a GPIO_INT declaration after a GPIO declaration and watched the build
fail.
TEST=make -j BOARD=peppy tests
TEST=make -j BOARD=auron tests
TEST=make -j BOARD=link tests

Change-Id: Id6e261b0a3cd63223ca92f2e96a80c95e85cdefb
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/263973
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Trybot-Ready: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-04-10 22:08:25 +00:00
Aseda Aboagye
0b043fed03 spring: Move interrupt enabled gpios to top
All GPIOs with interrupt handlers should be together at the top of the gpio.inc
file.

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

Change-Id: I4174e96acc35268fc77c477191b3ad1ef347a2e3
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/264505
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Commit-Queue: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Trybot-Ready: Aseda Aboagye <aaboagye@chromium.org>
2015-04-10 20:48:29 +00:00
Aseda Aboagye
aa98b2dca5 snow: Move interrupt enabled gpios to top
All GPIOs with interrupt handlers should be together at the top of the gpio.inc
file.

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

Change-Id: I6810a793cc16c38c8dde86f9cbec57a3f82aebfc
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/264504
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Commit-Queue: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Trybot-Ready: Aseda Aboagye <aaboagye@chromium.org>
2015-04-10 20:48:22 +00:00
Shawn Nematbakhsh
50bea9d35f mec1322: Add EC_CMD_GET_PROTOCOL_INFO handler
Add EC_CMD_GET_PROTOCOL_INFO handler to return info about supported
EC protocols.

BUG=chrome-os-partner:38224
TEST=Manual on Glower. Verify EC driver successfully loads on 3.14
kernel.
BRANCH=None

Change-Id: Ib5195ed720875320e9bd07c1c92a198fd34b842e
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/264455
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-04-10 18:48:59 +00:00
Shawn Nematbakhsh
52791fc2ac mec1322: Setup EMI unit at base address 0x800
Use EMI unit for access to host command / memmap data.

BUG=chrome-os-partner:38224
TEST=Manual on glower. Verify system boots + ectool works.
BRANCH=None

Change-Id: I06768a68fdf43f09d5e7425c293efff6a69a8878
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/264454
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-04-10 18:48:46 +00:00
Shawn Nematbakhsh
2e19bcb0cf util: Remove mec1322 comm driver
The mec1322 LPC / EMI comm driver is no longer functional due to recent
EC changes. Rather than re-implementing a working driver across user
space tools, the plan of action is to use the kernel device driver
(through comm-dev) for all access.

BUG=chrome-os-partner:38103
TEST=Manual on glower with pending kernel cros_ec_lpc changes. Verify
"ectool version" and "ectool gpioget" succeed.
BRANCH=None

Change-Id: I770cb06ca534a7c31794e6b37c226e952361ee32
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/265031
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-04-10 18:48:39 +00:00
Shawn Nematbakhsh
0b20fa1e0d glower: Add alternate LPC pin configs
BUG=chrome-os-partner:36326
TEST=Manual on Glower. Verify LPC reset becomes deasserted and AP boots.
BRANCH=None

Change-Id: I2a70a384b501eeabff6d976b62cbec3b15b152aa
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/264453
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-04-09 19:19:17 +00:00
Aseda Aboagye
29c7407c3d cyan: Move interrupt enabled gpios to top
All GPIOs with interrupt handlers should be together at the top of the gpio.inc
file.

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

Change-Id: I54926d81c55f25e1ec5ed9a286579cd40b47063c
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/264953
Trybot-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
2015-04-09 09:26:53 +00:00
Shamile Khan
0c74006a0a mec1322: Enable HW control of KBC aux buffer
This turns on hardware controlled update of bit 5 (AUXOBF) in Keyboard
Status Read Register. Previously, this bit was in user-defined mode and
not reliable.

BUG=None
TEST=Tested that keyboard becomes functional on Braswell Ref Design.
BRANCH=None

Change-Id: I192383ebebb25a027d58da9fc1ef7f3bb3e8da66
Signed-off-by: Shamile Khan <shamile.khan@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/263948
Reviewed-by: Shawn N <shawnn@chromium.org>
Commit-Queue: Kevin K Wong <kevin.k.wong@intel.com>
2015-04-09 07:49:24 +00:00
Kevin K Wong
55c739b9a4 mec1322: Added CONFIG_KEYBOARD_KSO_BASE to align KBD KSO00 pin to board design
MEC1322 KSO00~03 pin has an alternate JTAG function. For board that needs JTAG
function, this #define allows hardware to use a different set of KSO pins.
For example - Uses KSO04~16 instead of KSO00~KSO12.

BUG=none
TEST=Verified keyboard is functional with all keys detected
BRANCH=none

Change-Id: I1e3c1c2b6a4420cb6296b6bc921affa8c0ed5800
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/264610
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-04-09 04:45:23 +00:00
Aseda Aboagye
e369986c6e host: Move interrupt enabled gpios to top
All GPIOs with interrupt handlers should be together at the top of the gpio.inc
file.

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

Change-Id: I6a91e6ba88cf2c63826530f6989b6920349da4c5
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/264498
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Trybot-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
2015-04-09 03:18:59 +00:00
Aseda Aboagye
4b2bc9600d link: Move interrupt enabled gpios to top
All GPIOs with interrupt handlers sholud be together at the top of the gpio.inc
file.

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

Change-Id: I2c36a3e1f16152b85e01893f3e17fd69571d175f
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/264540
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Trybot-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-04-09 03:18:53 +00:00
Lee Leahy
55d7fbd47c cyan: Initial EC
BUG=none
TEST=Booted on cyan
BRANCH=none

Change-Id: Ibc7fe6b797fffc00613e13912868fa4d8b14091f
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/260684
Reviewed-by: Eric Caruso <ejcaruso@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
Commit-Queue: Divya Jyothi <divya.jyothi@intel.com>
2015-04-09 01:45:44 +00:00
Scott
d98b588c98 pd: Modify BIST mode according to ECR#PD2.0.1.0.004
- Changed TX BIST mode so that it transmits for 50 msec instead
      of transmitting forever.
    - Added console command to initiate TX BIST mode.
    - Fixed an issue with circular DMA mode which was causing watchdog.
    - Modified RX BIST to account for shorter TX BIST duration.

BUG=chrome-os-partner:36335
TEST=Manual on Samus to Samus, manual on Zinger to Samus
BRANCH=Samus

Signed-off-by: Scott Collyer <scollyer@chromium.org>

Change-Id: I666347de47c81b5b7a1e82c2b99345ff3ebbb7d4
Reviewed-on: https://chromium-review.googlesource.com/256194
Tested-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Scott Collyer <scollyer@chromium.org>
Trybot-Ready: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Alec Berg <alecaberg@chromium.org>
2015-04-09 01:45:38 +00:00