Commit Graph

1889 Commits

Author SHA1 Message Date
Bill Richardson
094a81f5de cleanup: Handle signed RW images a bit cleaner
For signed EC RW images (CONFIG_RWSIG), there's no point in
embedding the public key or signature into the image itself since
it will just be replaced by the signer (either as the next step
in the build process, or after the fact for MP releases). This
takes that out and just points to where the pubkey and signature
will be placed.

BUG=none
BRANCH=none
TEST=make buildall

I also checked the signatures with

  futility show -t build/*/ec.bin

They still look good, and the one signed image I booted (Cr50)
works as before.

Change-Id: Ib39b7c508914851f81a1bebb2450e08ef0def76c
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/302630
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-09-25 19:36:37 -07:00
Bill Richardson
e9000b22cb cleanup: Remove superfluous #defines
This just removes a couple places where a perfectly good CONFIG
macro is simply renamed to something else.

BUG=none
BRANCH=none
TEST=make buildall

Change-Id: I97a4abe95736504fe97c468336426d0ecc48d62c
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/302597
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-09-25 18:05:27 -07:00
Alec Berg
f53c8fd9fa lightbar: clear all segments before starting tap for battery
This makes sure to clear all segments before turning on lightbar
for tap for battery. Without this, the previous colors are stored
and flash briefly before starting the tap for battery pattern.

BUG=chrome-os-partner:45835
BRANCH=smaug
TEST=tested on ryu. go to s5, type 'lightbar seq tap' and see that
the tap sequence starts without first blinking google colors.

note that this doesn't affect samus because for samus in s5, the
lightbar is not powered, so when we do tap for battery, we first
power the lightbar and the registers are cleared.

Change-Id: Ic7ae8c580005e786ba35656d8feeedac56e35cfd
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/302147
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
(cherry picked from commit 962d0b2595b1dbb5ef162b7e6b4db7ce8a65e6c5)
Reviewed-on: https://chromium-review.googlesource.com/302447
2015-09-25 09:13:34 -07:00
Alec Berg
e5ec074dfa ryu: fix max lightbar brightness
Fix max brightness for Ryu. The max brightness must be less than
0x80 because the top bit in the lightbar current registers is
reserved. Writing the top bit seems to have undefined behavior.

This fixes the hiccups in the tap for battery sequence which was
ramping brightness to above 0x80 and producing weird results.

BUG=chrome-os-partner:45835, chrome-os-partner:44029
BRANCH=smaug
TEST=test tap for battery looks smooth.
test that the google colors match the desired current levels:
> lightbar
 ...
 15     0f     06
 16     0f     20
 17     16     08
 18     06     21
 19     26     11
 1a     1d     0b

Change-Id: Iecf1c770f986064b9b4d2d3d54fab0ea1242af01
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/302146
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
(cherry picked from commit 133dab0c36160d0e54820cce9e97071df34340f8)
Reviewed-on: https://chromium-review.googlesource.com/302446
2015-09-25 09:13:34 -07:00
Furquan Shaikh
f4ef486fc2 motion_sense: Fix issues in SET_ACTIVITY / LIST_ACTIVITIES
1. ret always evaluated to INVALID_PARAM and so SET_ACTIVITY bailed out
early and returned an error to host command.

2. No need to verify sensor id since SET_ACTIVITY / LIST_ACTIVITIES
identify the correct sensor to operate on.

BUG=chrome-os-partner:45710
BRANCH=None
TEST=Compiles successfully. Disable double-tap works as expected.

Change-Id: I58ae9cd5009fadedb3ea78a4eec0452124747707
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://chromium-review.googlesource.com/301990
Trybot-Ready: Furquan Shaikh <furquan@chromium.org>
Tested-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Commit-Queue: Furquan Shaikh <furquan@chromium.org>
(cherry picked from commit 2a3a120c8f7cca1e032f4be2a198748f0e8b5fb1)
Reviewed-on: https://chromium-review.googlesource.com/302409
Commit-Ready: Gwendal Grignou <gwendal@chromium.org>
Tested-by: Gwendal Grignou <gwendal@chromium.org>
2015-09-25 00:19:00 -07:00
Bill Richardson
5d138b379d Make builds repeatable.
We have been using the time of compilation to determine the
version string. This CL will keep doing that if the git repo has
uncommitted changes, but if the repo is clean we'll just use the
author date of the last commit. This ensures that the same source
will produce bitwise-identical builds (assuming no toolchain
changes, of course).

BUG=chrome-os-partner:45616
BRANCH=none
TEST=manual

  cd src/platform/ec
  make buildall
  mv build build.one
  make buildall
  md5sum build{,.one}/*/ec.bin | sort

Observe that successive builds produce identical binaries.

Change-Id: Ie2ef44b216586097589c9c15f12e05c87a53f991
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/302140
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-09-24 12:46:28 -07:00
Gwendal Grignou
dac76cc8d0 common: add command spixfer
Similar to i2c_xfer: allow access to a SPI device registers.
We assume the protocol use is set MSB bit to the offset for read
operation.
id is the index of the device in spi_devices.

BRANCH=smaug
TEST=Read/Write SPI registers.
BUG=none

Change-Id: Id4aaffbb6f514fd47086aee240b556ea23298d33
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/289857
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-09-23 21:26:22 -07:00
Alec Berg
c6deb91139 tcpc: don't allow tcpc write command until initialized
Don't act on a TCPC write command until we are done initializing.
This fixes an issue where if the TCPC reboots while the TCPM (EC
in our case) is still functioning, then we can get into a weird
state where we are changing the CC termination as we are still
initializing, which can cause us to get stuck with a phantom
connection (we apply one CC termination, but think we are applying
the opposite termination, causing us to 'see' a connected device).

BUG=none
BRANCH=none
TEST=load on glados. make sure dual-role toggling is on on the EC
and reboot PD MCU a bunch of times and make sure the EC doesn't
detect a phantom connection.

Change-Id: I2dffc3c2a1ca70903e17db0e012e994835cb9962
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/300681
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-09-21 22:12:41 -07:00
Mulin Chao
95ea672601 nuc: Fixed flash layout issue for npcx
Fixed flash layout issue for npcx

Modified drivers:
1. config_flash_layout.h: Fixed layout issue for npcx
2. flash_ec: add flashrom support for boards without JTAG in servo
connector

BUG=chrome-os-partner:34346
TEST=make buildall -j; test nuvoton IC specific drivers
BRANCH=none

Change-Id: I0b9b679c52b8a8e2a26c278b5024d0350fb77338
Reviewed-on: https://chromium-review.googlesource.com/300392
Commit-Ready: Mulin Chao <mlchao@nuvoton.com>
Tested-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-09-21 20:50:56 -07:00
Shawn Nematbakhsh
b03f92fbcc cleanup: Fix mapped storage accesses
1. Don't assume that images are present in program memory, just because
storage is mapped (npcx case).
2. Use CONFIG_MAPPED_STORAGE_BASE correctly, rather than
PROGRAM_MEMORY_BASE.

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

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I99c2b382def2a211241d401bbdc39a88ceedca5b
Reviewed-on: https://chromium-review.googlesource.com/300254
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Mulin Chao <mlchao@nuvoton.com>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-09-21 11:23:31 -07:00
Shawn Nematbakhsh
85110d5bcb gpio: i2c: Correctly restore pins after i2cunwedge
Set pins as inputs when going to hi-Z, and restore them to default when
returning to functional.

BUG=chrome-os-partner:45520
TEST=`i2cunwedge` on samus, verify that i2c bus is still functional
BRANCH=None

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ie19d4e5afdee7f0b2437afdfaa8175ff77b73c78
Reviewed-on: https://chromium-review.googlesource.com/300785
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2015-09-21 11:23:28 -07:00
Gwendal Grignou
4e8120a364 common: motion: Add double tap gesture host interface
Allow the host to enable/disable double tap.
Send event when double tap is present.
Also fix a bug when scanning for gestures.

BRANCH=smaug
BUG=chrome-os-partner:44754
TEST=compile. Check on Ryu.

Change-Id: I50d008cd3823072ab1c1e2d21f1276cd2185d797
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/298683
2015-09-21 01:13:55 -07:00
Gwendal Grignou
1d8fcfcd0d common: Add __fls function
Returns the most significant bit set.
Replace 31 - __builtin_clz(x), so x must be different from 0.
Use get_next_bit when not on the performance path,
on performance path set the bit field just after reading it.

BRANCH=smaug
BUG=none
TEST=compile, check Ryu still works.

Change-Id: Ie1a4cda4188f45b4bf92d0549d5c8fb401a30e5d
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/301300
2015-09-21 01:13:54 -07:00
Gwendal Grignou
b98e33c950 common: motion: Fix oversampling calculation.
Was setting frequency radix at 1 mHz.
That would limit frequency to 32Hz, which is not enough for
accelerometor.
Set radix as a fixed point or float variable, to calculate
the rate properly.

BRANCH=smaug
BUG=None
TEST=Check that when Ryu set accelerometer to 100Hz internally (for
double tap), that AP gets data when requested frequency is 15Hz.

Change-Id: I84e0ea784f8bd04566aa91bc4300cf4ff30b350c
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/298688
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-09-19 15:18:09 -07:00
Gwendal Grignou
33046e7d51 common: accel: Add error code for irq handler
When IRQ handler is not processing any event raised,
return NOT_HANDLED.

Without this change, any event would set the light sensor
process timestamp and, if the light sensor frequency was lower
than BM160 fifo interrupt frequency, we would never read from
the light sensor.

BRANCH=smaug
BUG=chrome-os-partner:43800
TEST=Compile. Check that light sensor data get updated.

Change-Id: I302f80c5cd9b4f3c926362fdafdc8b5074cabb60
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/298686
2015-09-19 15:18:08 -07:00
Gwendal Grignou
e24cca580e common: lightbar: put multiple commands under i2c_lock
If other i2c traffic happens around the time the light bar is
initialized, the i2c bus is wedged.

Instead of waiting 500ms in the motion task loop for the tap sequence to
complete, set under i2c lock the lp power and init sequence.

BRANCH=smaug, samus
BUG=chrome-os-partner:45223
TEST=With msleep(500) removed and With lb_power + lb_init + 100ms, I don't see the wedge at TAP
sequence.

Change-Id: I931eb25bcc5e3237b6c569f2330f72f9fc415964
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/299543
Reviewed-by: Bill Richardson <wfrichar@google.com>
2015-09-19 12:27:21 -07:00
Alec Berg
c7eaa0a81c pd: add more flags to USB_PD_CONTROL host command
Add more flags to EC_CMD_USB_PD_CONTROL including whether
the port partner is PD capable, and if the port partner has
any of the following flags set in its capabilities: dual-role
power, dual-role data, USB comms capable, and externally
powered.

BUG=none
BRANCH=smaug
TEST=tested on samus using 'ectool --dev=1 usbpd 0'. Tested
with zinger, guppy, another samus, and other third party
devices to verify the flags are set as advertised in src/snk
capabilities packet

Change-Id: I4d78d1880073fdacce57516111ac6cab37b93f27
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/300953
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-09-18 20:57:38 -07:00
Gwendal Grignou
6b5a49ef15 motion: Add Gesture Interface
Add an interface with the host to set up gesture recognition.
Today, only significant motion is supported.

Add a virtual sensor for concentrating gesture support from host.

BRANCH=smaug
BUG=b:23570481
TEST=On ryu, enable significant motion from host.

Change-Id: I906fa2d2d7b4ca2771ea2f58b91de8d97bf4e2e3
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/296213
2015-09-18 20:57:22 -07:00
Gwendal Grignou
13a7ae7b6f motion: Add wake up sensor support.
Add a flag in the FIFO event to tell that the sensor
want to wake up the AP.
Use this flag in the EC and let it reach the AP
for debugging.
Move fifo_flush as well, use only when FIFO present.

BRANCH=smaug
TEST=compile.
BUG=b:23570481

Change-Id: I5ff567b0f9f1e37a3dae16bfa7859c341f1a9b17
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/296212
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-09-18 19:21:12 -07:00
Aseda Aboagye
4ef6aabe07 common: Move tps65090 PMIC driver to driver/.
The driver directory is the natural place for drivers.

BUG=chromium:472173
BRANCH=None
TEST=make buildall tests

Change-Id: Iba85b643f20eb9607db16c7e6ad9a67443d78a3d
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/300789
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-09-18 17:55:35 -07:00
Gwendal Grignou
bde89ebc20 common: motion: move gesture actions in motion task.
Change the IRQ interface to allow adding events.
Move code to send the lightbar sequence from gesture.c to motion task.

TEST=compile, works on Ryu.
BRANCH=smaug
BUG=chrome-os-partner:44754

Change-Id: I981ea123ebef0e8e3d6aa320eade89f10e83b6fc
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/296822
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-09-18 17:55:32 -07:00
Gwendal Grignou
a2ef386ee7 common: motion: print return of drv->init()
In motion_sense_init, gather the result of the sensor init routine.

BUG=none
BRANCH=smaug
TEST=Get the result of init() when calling accelinit.

Change-Id: I8d0219a2b81fdf6d512976db5a28646ee5f6b994
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/299946
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2015-09-18 17:55:31 -07:00
Shawn Nematbakhsh
542a95c87b cleanup: Fix npcx build
The previous commits left npcx in a bad state. Change
CONFIG_PROGRAM_MEMORY_BASE to point to the actual start of code memory
and correct the linker file.

This still results in a non-working npcx image (more changes
forthcoming) but it does build.

BUG=chrome-os-partner:23796
TEST=make clean; make buildall -j
BRANCH=None

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ia300c5d18695dccd8d9fd9a6122cd7d30353adfa
Reviewed-on: https://chromium-review.googlesource.com/300295
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-09-17 19:00:54 -07:00
Alec Berg
5717b3150c motion: add config option to use the old accelerometer ref frame
Add config option to use the old accelerometer reference frame,
which is used on samus and products using 3.14 or earlier kernel.

This fixes samus so that the lid angle calculation is correct
again.

This also moves the accel_orientation structure out of the board
directory and into common code, since it purely is a function of
the reference frame being used.

BUG=chrome-os-partner:43494
BRANCH=none
TEST=test on samus, verify lid angle calculation is correct once
again. also, enable the motion_lid test and verify that it passes.

Change-Id: I948a74a71964b54c68be66e828a030ddd0418947
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/300510
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2015-09-17 19:00:53 -07:00
Alec Berg
7a87dae5c7 motion: fix task to guarantee task never exits
Fix motion_sense task to make sure the task never exits. Note,
before this change a task_wake(TASK_ID_MOTIONSENSE) would end
the task because task_wait_event() would return 0.

BUG=none
BRANCH=smaug
TEST=with following CL, run motion_lid test and make sure it
passes

Change-Id: I67bd2e535d67215baa0cc1dfd0010b8199152dbd
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/300630
Commit-Ready: Gwendal Grignou <gwendal@chromium.org>
Tested-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2015-09-17 17:35:14 -07:00
Ben Lok
c15faa4c2c usb_pd: Add TODO for pd soft reset process.
Just add comments, no code.

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

Change-Id: I75bf98c7f920ddfa70fc9a3ce939131c57470d5c
Signed-off-by: Ben Lok <ben.lok@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/299102
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Rong Chang <rongchang@chromium.org>
2015-09-17 03:23:20 -07:00
Bill Richardson
248e1a8a31 md console command can dump memory in more formats
This adds optional format designations to the "md" console
command. By default it dumps memory in 32-bit words, but with
this change it can also display 16-bit words, bytes, and strings.

BUG=none
BRANCH=none
TEST=manual

For example:

> md 0x5c400 32

0005C400: 6d6d6f63 20646e61 75626564 756f2067
0005C410: 74757074 646f6d20 6f6e0065 6c616d72
0005C420: 65766500 70007972 6d617261 41550073
0005C430: 69205452 6974696e 7a696c61 61206465
0005C440: 72657466 73797320 706d756a 2d0a0a00
0005C450: 55202d2d 20545241 74696e69 696c6169
0005C460: 2064657a 65746661 65722072 746f6f62
0005C470: 2d2d2d20 525b000a 74657365 75616320

> md .h 0x5c400 32

0005C400: 6f63 6d6d 6e61 2064 6564 7562 2067 756f
0005C410: 7074 7475 6d20 646f 0065 6f6e 6d72 6c61
0005C420: 6500 6576 7972 7000 7261 6d61 0073 4155
0005C430: 5452 6920 696e 6974 6c61 7a69 6465 6120

> md .b 0x5c400 32

0005C400: 63 6f 6d 6d 61 6e 64 20 64 65 62 75 67 20 6f 75
0005C410: 74 70 75 74 20 6d 6f 64 65 00 6e 6f 72 6d 61 6c

> md .s 0x5c400 32

0005C400: command debug output mode\x00normal
>

Change-Id: Ic0dec9a1a3942acc66c88f46c5b02a80a8110817
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/300020
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-09-16 14:49:59 -07:00
Alec Berg
c8d95f8a6d tcpc: update to tcpci RC3
Update TCPCI to match specification version RC3.

BUG=none
BRANCH=none
TEST=tested on glados and samus by plugging in a zinger with
both polarities and verifying we make a power contract.

Change-Id: I9cd6d8db7b7149995847ec1b071fba1f4d4cd5a3
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/299713
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-09-16 14:49:47 -07:00
Shawn Nematbakhsh
fe77303bec cleanup: Remove redundant FLASH_SIZE CONFIGs
Since there is no more concept of a flash region belonging only to the
EC, we only need one FLASH_SIZE config, which represents the actual
physical size of flash.

BRANCH=None
BUG=chrome-os-partner:23796
TEST=With entire patch series, on both Samus and Glados:
- Verify 'version' EC console command is correct
- Verify 'flashrom -p ec -r read.bin' reads back EC image
- Verify software sync correctly flashes both EC and PD RW images

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I18a34a943e02c8a029f330f213a8634a2ca418b6
Reviewed-on: https://chromium-review.googlesource.com/297824
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-09-16 14:49:33 -07:00
Shawn Nematbakhsh
1167cad6a8 cleanup: Change meaning of storage offset CONFIGs
In order to support architectures with non-contiguous writable and
protected regions, change storage offsets to be relative to writable and
protected regions, rather than relative to "the start of the region of
storage belonging to the EC".

Spec doc available at https://goo.gl/fnzTvr.

BRANCH=None
BUG=chrome-os-partner:23796
TEST=With entire patch series, on both Samus and Glados:
- Verify 'version' EC console command is correct
- Verify 'flashrom -p ec -r read.bin' reads back EC image
- Verify software sync correctly flashes both EC and PD RW images

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I796f8e7305a6336495bd256a78774595cb16a2e4
Reviewed-on: https://chromium-review.googlesource.com/297823
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-09-16 14:49:32 -07:00
Shawn Nematbakhsh
558c465165 cleanup: Remove CDRAM / CODERAM CONFIGs
CDRAM / CODERAM configs were previously used for chips which copied code
from external SPI to program memory prior to execution, and were used
inconsistently between npcx and mec1322.

These CONFIGs are now completely redundant given new configs like
CONFIG_MAPPED_STORAGE_BASE and CONFIG_EXTERNAL_STORAGE.

BRANCH=None
BUG=chrome-os-partner:23796
TEST=With entire patch series, on both Samus and Glados:
- Verify 'version' EC console command is correct
- Verify 'flashrom -p ec -r read.bin' reads back EC image
- Verify software sync correctly flashes both EC and PD RW images

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I0e054ab4c939f9dcf54abee8e5ebd9b2e42fe9c4
Reviewed-on: https://chromium-review.googlesource.com/297804
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-09-16 14:49:32 -07:00
Shawn Nematbakhsh
d58e54730c cleanup: Rename geometry constants
Rename and add geometry constants to match spec doc -
https://goo.gl/fnzTvr.

CONFIG_FLASH_BASE becomes CONFIG_PROGRAM_MEMORY_BASE
CONFIG_FLASH_MAPPED becomes CONFIG_MAPPED_STORAGE

Add CONFIG_INTERNAL_STORAGE, CONFIG_EXTERNAL_STORAGE and
CONFIG_MAPPED_STORAGE_BASE where appropriate.

This CL leaves chip/npcx in a broken state -- it's fixed in a follow-up
CL.

BRANCH=None
BUG=chrome-os-partner:23796
TEST=With entire patch series, on both Samus and Glados:
- Verify 'version' EC console command is correct
- Verify 'flashrom -p ec -r read.bin' reads back EC image
- Verify software sync correctly flashes both EC and PD RW images

Change-Id: Idb3c4ed9f7f6edd0a6d49ad11753eba713e67a80
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/297484
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-09-16 14:49:31 -07:00
jongpil19.jung
4b3c13ddfe Celes: Add define to support GD25Q41B for External EC ROM.
MEC1322 use external spi rom. Now, we support W25X40 and W25Q64.
Celes will use GD25Q41B for external EC ROM.
So, we need to add define for GD25Q41B.

BUG=chrome-os-partner:45246
BRANCH=master
TEST=emerge-strago chromeos-ec

Change-Id: Idec79955306b2dd79027fa57afc15ed8474413e6
Signed-off-by: jongpil19.jung <jongpil19.jung@samsung.com>
Reviewed-on: https://chromium-review.googlesource.com/299576
Commit-Ready: Jongpil Jung <jongpil19.jung@samsung.com>
Tested-by: Jongpil Jung <jongpil19.jung@samsung.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-09-15 19:17:53 -07:00
Gwendal Grignou
2bff01f1ca common: math: Stop using FP_BITS directly.
To be able to use hardware FPUs, use fp_ functions instead of FP_BITS in
application code.

BRANCH=smaug
BUG=chrome-os-partner:39900
TEST=compile.

Change-Id: I8a1339140eb5ddab32dd3edc58fb5d3ccaef52e2
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/299515
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-09-15 17:56:17 -07:00
Vincent Palatin
552e3ceaee pd: restart toggling immediatly when dual role mode is re-enabled
Kick the PD task when the dual role toggling is enabled to ensure we
start toggling immediatly and detect a UFP (USB device).
The issue was visible with the CONFIG_USB_PD_LOW_POWER change where the
task was waking up only every minute when the toggling was disabled,
the whole system would take up to a minute after resume to detect a peripheral
connected while in S3.

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

BRANCH=smaug
BUG=chrome-os-partner:45347
TEST=On Smaug, put the system into S3, plug a USB device (e.g. a USB
key), transition to S0 and verify that the kernel is receiving
immediatly the "host mode" notification.

Change-Id: I12d10941f9d2cefdfe711847ba0aec9f269e9bcd
Reviewed-on: https://chromium-review.googlesource.com/299796
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
(cherry picked from commit 6a0e8ec3b9b1a7a0eb222a9e6c132d88d33f60e2)
Reviewed-on: https://chromium-review.googlesource.com/299807
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
2015-09-15 12:21:35 -07:00
Aseda Aboagye
16a18a5e0e driver: Refactor Kionix Accelerometer drivers.
This commit adds a new basic driver for the Kionix KX022 Accelerometer.
Currently, the driver is capable of reading the sensor data and
manipulating its ODR, resolution, and range.

This sensor also has integrated support for Directional
Tap/Double-Tap(TM), however that functionality is not yet implemented in
the driver.

Lastly, since this accelerometer is very similar to the previous KXCJ9,
this commit tries to combine the drivers.

Note, the variant of the Kionix accelerometer MUST be specified in the
private data structure.

BUG=chrome-os-partner:43494
BRANCH=None
TEST=Build GLaDOS EC with driver enabled and verify that valid
accelerometer data is read, and that range, resolution, and odr can all
be modified.
TEST=Build samus EC image and verify that the lid still
works. Additionally, verify that I can change the odr, rate, and
resolution.
TEST=make buildall tests

Change-Id: I238ff1dc13f5342a93f8f701a0da85c52f25d214
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/299013
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2015-09-15 11:02:43 -07:00
Vincent Palatin
a8d71bdb5b pd: add option to save power in S5
When we are in sink mode and not dual-role toggling, add the option to
disable the CC lines polling every 10 ms (thus waking up on the VBUS
transition or the 1-minute slow polling).

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

BRANCH=smaug
BUG=chrome-os-partner:44229
TEST=on Smaug DVT, measure power consumption in S5 and wake-up time when
plugging a power supply.

Change-Id: Idee6581af550de01760feffe604d7bd453a625a8
Reviewed-on: https://chromium-review.googlesource.com/299022
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>
(cherry picked from commit d14a0045568e61a36695ffee48ed39ddc60ebb3a)
Reviewed-on: https://chromium-review.googlesource.com/299023
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
2015-09-14 18:53:32 -07:00
Rong Chang
2eabf6fe8c oak_pd: tcpm_power_status: Update power status on init
Oak board relies on TCPCI power status. When board init, PD should
update it's VBUS status and TCPM needs to get power status after enable
TCPC power status mask.

BRANCH=none
BUG=chrome-os-partner:44952
TEST=manual
  build and load on oak, disconnect battery.
  power on system with zinger, and check PD state.

Signed-off-by: Rong Chang <rongchang@chromium.org>
Change-Id: Ic0d4b50d38ac39ff31b3a257c4b3b5dde0ebda4b
Reviewed-on: https://chromium-review.googlesource.com/297871
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-09-14 00:48:39 -07:00
Alec Berg
fd92f9bfeb pd: add swap commands to USB_PD_CONTROL host command
Add all swap commands to USB_PD_CONTROL host command: data,
power, and vconn swap.

BUG=none
BRANCH=smaug
TEST=tested on both samus and ryu while connected to each other.

Change-Id: I280a0da2d3c5a5436243134ab3f2ec353ebf6ab8
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/299290
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-09-11 13:51:00 -07:00
Gwendal Grignou
17296409d8 common: Add variable to enable software gesture recognition.
Gesture recognition can be done in software (by the EC) or in
hardware, by the sensor itself.
Add variable to compile gesture.c only in the software case.

BRANCH=smaug
TEST=compile.
BUG=b:23570481

Change-Id: I22bef0bf744516df267020d9458e0299a4da3d72
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/296211
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-09-11 13:50:56 -07:00
Gwendal Grignou
3b1847d810 motion: Fix a bug in accelrate
Allow accelrate to suspend a sensor, even if the AP is using it.
For debugging only.

BRANCH=smaug
TEST=before accelrate 0 0 would not suspend the accelerometer in SO,
the AP is using it.
BUG=b:23570481

Change-Id: Iea4f616d0a0d1b4a0b0fa2bc942d05b2a2425926
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/296210
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-09-11 13:50:56 -07:00
Duncan Laurie
8900884cad als: Disable task when host is not running
If the ALS is not enabled in S3/S5 states then it will generate
errors when trying to read so should be gated.

This could be done with a check for chipset_state or adding a
new CONFIG_ALS_POWER_GPIO to check.  However the ALS is also not
needed when the host is in S3/S5 yet the task continues to run
in the background every 1 second.

This commit adds a new task enable/disable hook to disable the
task when the system is suspended and enable the task when it
is resumed.

In order to fit this new task in glados the als console command
is guarded by a new config option.  Since this is not a very
frequently used/needed console command it is disabled by default.

And finally the kunimitsu and strago boards try to enable ALS
but they never actually enabled the ALS task so this new code was
failing to build because TASK_ID_ALS did not exist.  Also samus
was enabling it but as TASK_NOTEST so tests will fail, though
they are disabled globally on samus.

BUG=chrome-os-partner:43493
BRANCH=none
TEST=enable ALS on glados and successfully build and use it,
also successfully build EC and tests for kunimitsu, strago,
and samus which are the other boards that use the ALS task.

Change-Id: I192940d7f306a1663c7cb789c313151bbb5f2b90
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/298156
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-09-10 12:35:37 -07:00
Ben Lok
4ddce257da pd: increasing the waiting time after pd soft reset.
The original waiting time is 5 mesc, but it isn't enough for Oak during
sysjump from RO to RW, so, increase to 8 msec.

BUG=chrome-os-partner:44584, chrome-os-partner:44952
BRANCH=none
TEST=tested on Oak with a battery, with zinger attached,
Issue EC console commands:
> reboot
> sysjump RW (EC_SYNC isn't enabled in bootloader)
And check the PD status:
> pd 0 state
or
> pd 1 state

Change-Id: I846866a95d7730eef679ea9090883b33313d5007
Signed-off-by: Ben Lok <ben.lok@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/298420
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-09-10 05:29:50 -07:00
Alec Berg
8d109d19c0 charge_manager: do not allow overlapping charge override commands
Fix override host command so that if we are in the middle of
power swapping to handle one override command, that we return
an error if another override command is received.

BUG=chrome-os-partner:44958
BRANCH=smaug
TEST=make -j buildall

Change-Id: I2503120aed76b82166dd36a45c410f2b6ea921bd
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/297837
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-09-09 11:17:45 -07:00
Alec Berg
550f5e67d3 pd: make sure attention command is treated as an SVDM
Make sure attention command is treated as a standard
VDM.

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

Change-Id: I7b181cbae9836b13bd461efd15c96f5cb414d0c0
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/297971
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
2015-09-08 23:32:47 -07:00
Alec Berg
3963d3b77d charge_manager: ensure we source power when not charging
Move asking for a power swap to become a source to happen
anytime we stop charging from a dual-role port. We used to
ask for a power swap when a dual-role override port was
cancelled, but with CONFIG_CHARGE_MANAGER_DRP_CHARGING we
can be charging from a dual-role port without having chosen
it as the override port, so this guarantees that we always
ask to become the source when we stop charging from a port.

BUG=chrome-os-partner:44958
BRANCH=smaug
TEST=build and run unit tests

Change-Id: I009178b479a4626888d11a9993c8738d928fbaf9
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/297880
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-09-08 21:58:21 -07:00
Alec Berg
ebfdb59702 charge_manager: add option to charge from dual-role devices
Add option to charge automatically from dual-role devices. This
also changes the charge override behavior such that any new
device attached will clear the override because any new source
is a potential device we might charge from.

BUG=chrome-os-partner:44958
BRANCH=smaug
TEST=tested charge_manager unittests with
CONFIG_CHARGE_MANAGER_DRP_CHARGING both defined and undefined

Change-Id: Iac77ff0c501826d5fb5a9d50f88399ebc3955b87
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/297789
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-09-08 21:58:21 -07:00
Anton Staaf
490e8a482f eoption: Remove unused eeprom option storage code
Signed-off-by: Anton Staaf <robotboy@chromium.org>

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

Change-Id: I2174a904df160d19d47f1aa2d053349356cb4291
Reviewed-on: https://chromium-review.googlesource.com/297805
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-09-08 18:43:47 -07:00
Vincent Palatin
96093145cb update case closed debugging partial mode policy
When a debug accessory is connected to the type-C port while the write
protection is enabled, put the case closed debugging in "partial" mode
rather than "full".

Update the "partial" mode to provide read-only access to the AP and EC
consoles.

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

BRANCH=smaug
BUG=chrome-os-partner:44700
TEST=check the EC console input/output over USB is still working with SuzyQ
on a write-protected system, verify that the console input is disabled.

Change-Id: I5baa03d6e738d06437c45469f46b286e76a755a4
Reviewed-on: https://chromium-review.googlesource.com/297141
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-09-08 13:49:09 -07:00
Anton Staaf
7bdb69c464 UART: Remove unused uart.h header includes
Signed-off-by: Anton Staaf <robotboy@chromium.org>

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

Change-Id: Ife068807f79f6435292643c49afa1a9a30ae7080
Reviewed-on: https://chromium-review.googlesource.com/296733
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-09-08 10:38:20 -07:00