Commit Graph

1389 Commits

Author SHA1 Message Date
Vincent Palatin
939d07fc4e charge_state_v2: add option to cut-off battery when level is critical
Add a build option CONFIG_BATTERY_CRITICAL_SHUTDOWN_CUT_OFF to perform a
battery cut-off when we reach the battery critical low level.

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

BRANCH=smaug
BUG=none
TEST=Discharge a Ryu device down to the critical level, see the message
and verify we cannot restart with the power button. Also check that
plugging the charger revives the device and starts charging.

Change-Id: Ic132a658de5c5131a6a1dd1ce343196b68d480f6
Reviewed-on: https://chromium-review.googlesource.com/303549
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
(cherry picked from commit 80b3c99319771312d5733b126b6b3eb839addde9)
Reviewed-on: https://chromium-review.googlesource.com/303812
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
2015-10-02 17:49:16 -07:00
Vijay Hiremath
229094b245 ALS: Disable the ALS task if all the ALS inits fail
BUG=none
TEST=Manually tested on Kunimitsu & Strago.
     Removed the ALS sensor from DUT, using "taskinfo" console command
     observed that the ALS task is not running.
BRANCH=none

Change-Id: I96cb720bd8d70033d433cdc2cd9cea9b56a3b389
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/301753
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>
2015-10-02 12:55:51 -07:00
Vijay Hiremath
5cbd9fa7bb Driver: ISL9237: Monitor system power consumption
Added code to enable the system power monitoring functionality to get the
details of the system power consumption.
And also added EC console command "psys" to get the system power consumption.

BUG=none
TEST=Manually tested on Kunimitsu.
     Power = Voltage * Current, reading is equal to the power readings
     from the psys command.
BRANCH=none

Change-Id: I62519ac96800363b67cab23cd9eb0dcac229cb47
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/302472
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>
2015-10-02 03:28:30 -07:00
Shawn Nematbakhsh
29162aeecc system: Add i2c slave sleep mask
Add i2c slave sleep mask bit so that deep sleep can be inhibited from
the i2c slave interface independently of the i2c master interface.

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

Change-Id: I21755f72a24fedf332e707abf609dc5f8b57e5be
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/303403
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-09-30 23:19:53 -07:00
Vijay Hiremath
dbef9a6fed Rename gpio_is_reboot_warm() to system_is_reboot_warm()
BUG=chrome-os-partner:40788
TEST=make buildall -j
BRANCH=none

Change-Id: I4fb248da4656374e1218af98678cfb694f4c9176
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/302674
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>
2015-09-29 21:11:40 -07:00
Gwendal Grignou
d0e1c2394c common: motion: Separate motion task interval from AP configuration
Some sensors are in forced mode, motion sense must be scheduled at
their ODR. However the host may not want the data right away,
so motion task may not wake up the host that often.

Add a new variable motion_int_interval that defines the maximum interval
between FIFO host event.

BRANCH=smaug
BUG=chrome-os-partner:43800
TEST=Check that light sensor is polled at ODR frequency.
Check that when AP does not want any event, no FIFO host event are
requested.
Check CTS tests work as before.
Reenable motion_lid unit test.

Change-Id: Ie25e6cbe28fed899073856057855ffa03c0cd9fd
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/301134
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-09-29 19:38:21 -07:00
Shawn Nematbakhsh
42062110b7 cleanup: Remove redundant CONFIG_RAM_* configs
RAM need not be preserved between jumps from the loader to RO/RW images,
so there is no need for a separate region of loader RAM. Remove
redundant CONFIGs which define this unneeded region.

BUG=None
TEST=Verify glados boots and sysjumps successfully.
BRANCH=None

Change-Id: I2567f17a973c6f9f00bcfd97a4581d6c4b6fd6f0
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/302586
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-09-29 11:28:28 -07:00
Aseda Aboagye
747056ec93 gpio: Merge config_module into config_pins.
gpio_config_module() and gpio_config_pins() had very similar code.  This
commit moves the functionality of gpio_config_module into
gpio_config_pins. That is, gpio_config_pins() can now configure an
entire module.  This is accomplished by passing in GPIO_CONFIG_ALL_PORTS
as the port parameter.

BUG=chromium:533539
BRANCH=None
TEST=Build and flash on samus. Verify that lightbar, charging, power
button, sensors, all functional.
TEST=make -j buildall tests

Change-Id: I7c9122ebf7b0e2716af2d55b842c4806d8099a63
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/302479
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-09-26 01:07:39 -07:00
Aseda Aboagye
823d3a2d51 ec_commands: Add "hibdelay" as an EC host command.
Currently, the only way to prevent a system from hibernating is via the
EC console command "hibdelay".  This commit adds the host command
equivalent so that it can be set elsewhere.  The host command takes the
amount of time in seconds to delay hibernation by and responds with the
current time in the G3 power state, the time remaining before
hibernation should be invoked, and the current setting of the
hibernation delay.

BUG=chrome-os-partner:45608
BUG=chrome-os-partner:44831
BRANCH=None
TEST=Build and flash on samus. Issue the host command from EC
console. Verify that the hibernation delay was updated by checking with
the hibdelay command.

Change-Id: I34725516507995c3c0337d5d64736d21a472866c
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/302197
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-09-25 21:09:25 -07:00
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
Shawn Nematbakhsh
854d5a6e7f cleanup: Remove CONFIG_FW_IMAGE_SIZE
Since CONFIG_RO_SIZE and CONFIG_RW_SIZE now exist (which may
theoretically be different sizes), it is no longer useful to globally
define the size of an image.

BUG=chromium:535027
BRANCH=None
TEST=`make buildall -j`. Also, verify glados / glados_pd continue to
function as expected.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ie29959923bc5d02b4d7d6d507ff2191bcb7d24c8
Reviewed-on: https://chromium-review.googlesource.com/301743
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2015-09-24 18:07:01 -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
Bill Richardson
7323fd8fda cleanup: Put chip-specific configs in config_chip.h
include/config_std_internal_flash.h is an optional header that
can be used to implement the most common EC flash layout.

However, CONFIG_INTERNAL_STORAGE, CONFIG_MAPPED_STORAGE, and
CONFIG_MAPPED_STORAGE_BASE are fixed by the SoC, so they belong
in config_chip.h, not in the optional header.

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

Refactoring only, no behavioral differences.

Change-Id: I114c3e194837041920e6f228a2bed6747be8231c
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/301330
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-09-21 10:04:35 -07:00
Gwendal Grignou
8839b30b25 common: motion: Fix accelgyro interface
Use const struct motion_sensor when needed.

BRANCH=smaug
BUG=chrome-os-partner:44754
TEST=compile

Change-Id: Ib1e92b91439e6af83aa7b6b49ac9e6271d4ed3d9
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/298684
2015-09-21 01:13:56 -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
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
Gwendal Grignou
d896a005d4 common: math: Use float when CONFIG_FPU is set.
When hardware FPU is set, use it.

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

Change-Id: I5b42bd23a7ee7549e538eff075756b58f79756f2
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/299516
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-09-18 19:21:08 -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
Bill Richardson
1b34f4bae7 Cr50: Add support for flash write & erase
This adds flash support for the SoC.

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

Pick an unused section of flash and use the flasherase and
flashwrite commands to test it. The flashwrite command fills a
buffer with bytes, counting up (0x00, 0x01, 0x02, 0x03, ...),
then writes that buffer to the address given.

Note that the "md" command uses the absolute address, while the
flash commands use the offset address within the flash memory.

For example:

Test bank 0:

  > md 0x7b000 16

  0007B000: 00000000 00000000 00000000 00000000
  0007B010: 00000000 00000000 00000000 00000000
  0007B020: 00000000 00000000 00000000 00000000
  0007B030: 00000000 00000000 00000000 00000000

  > flasherase 0x3b000 0x800
  Erasing 2048 bytes at 0x3b000...

  > md 0x7b000 16

  0007B000: ffffffff ffffffff ffffffff ffffffff
  0007B010: ffffffff ffffffff ffffffff ffffffff
  0007B020: ffffffff ffffffff ffffffff ffffffff
  0007B030: ffffffff ffffffff ffffffff ffffffff
  >

  > flashwrite 0x3b000 0x800
  Writing 2048 bytes to 0x3b000...

  > md 0x7b000 16

  0007B000: 03020100 07060504 0b0a0908 0f0e0d0c
  0007B010: 13121110 17161514 1b1a1918 1f1e1d1c
  0007B020: 23222120 27262524 2b2a2928 2f2e2d2c
  0007B030: 33323130 37363534 3b3a3938 3f3e3d3c

  > md .b 0x7b000 16

  0007B000: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f

Test bank 1:

  > md 0xbb000 16

  000BB000: ffffffff ffffffff ffffffff ffffffff
  000BB010: ffffffff ffffffff ffffffff ffffffff
  000BB020: ffffffff ffffffff ffffffff ffffffff
  000BB030: ffffffff ffffffff ffffffff ffffffff

  > flasherase 0x7b000 0x800
  Erasing 2048 bytes at 0x7b000...

  > md 0xbb000 16

  000BB000: ffffffff ffffffff ffffffff ffffffff
  000BB010: ffffffff ffffffff ffffffff ffffffff
  000BB020: ffffffff ffffffff ffffffff ffffffff
  000BB030: ffffffff ffffffff ffffffff ffffffff

  > flashwrite 0x7b000 0x800
  Writing 2048 bytes to 0x7b000...

  > md 0xbb000 16

  000BB000: 03020100 07060504 0b0a0908 0f0e0d0c
  000BB010: 13121110 17161514 1b1a1918 1f1e1d1c
  000BB020: 23222120 27262524 2b2a2928 2f2e2d2c
  000BB030: 33323130 37363534 3b3a3938 3f3e3d3c

  > md .b 0xbb000 16

  000BB000: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
  >

Change-Id: I956e813871949faed8d85ad9e46bdc64dee1a9e9
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/299757
2015-09-18 01:25:55 -07:00
Dino Li
ad8efdee3f it8380dev: fix idle task and chip id
1. Fix system_get_chip_name() and system_get_chip_revision().
2. Fix EC doze mode.
3. Enable LPC cycle wake-up EC from doze / deep doze function.

Signed-off-by: Dino Li <dino.li@ite.com.tw>

BRANCH=none
BUG=none
TEST=1. console "version".
            Chip:    ite it8390 cx
     2. EC doze mode is normally.
     3. ectool "version" command x 2000.

Change-Id: I167dbfb965e557eb86ed83f45a945e4315f5fa9f
Reviewed-on: https://chromium-review.googlesource.com/299110
Commit-Ready: Dino Li <dino.li@ite.com.tw>
Tested-by: Dino Li <dino.li@ite.com.tw>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-09-18 01:25:52 -07:00
Dino Li
62ea7121f8 it8380dev: fix ec2i and uart
1. Host access to the PNPCFG registers is disabled.
2. UART2 for host if necessary.

Signed-off-by: Dino Li <dino.li@ite.com.tw>

BRANCH=none
BUG=none
TEST=1. host can't access the PNPCFG registers.
     2. out I/O port 0x2f8 '0x30, 0x31, 0x32, 0x33, and 0x34'
        will have console message '01234'.

Change-Id: If07bdc129105f5248661d929e6858d4063c452ee
Reviewed-on: https://chromium-review.googlesource.com/300266
Commit-Ready: Dino Li <dino.li@ite.com.tw>
Tested-by: Dino Li <dino.li@ite.com.tw>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-09-17 23:52:32 -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
Gwendal Grignou
c2c02249a0 host: mock i2c_xfer
Instead of mocking i2c_read8/16/32, mock i2c_xfer.
We can now test code that call i2c_xfer directly and
test common/i2c.c

BRANCH=samus, ryu
BUG=chrome-os-partner:45223
TEST=Unit tests pass.

Change-Id: Iaa772515c40cf55d2050d0019e2062d63278adc0
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/299768
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-09-16 14:49:46 -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
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
Alec Berg
39c422597a usb_charge: fix custom event mask
Fix custom event mask, which should be a power of 2.

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

Change-Id: Iaeacf9b07817ee94452c58beb6a794a5a9733355
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/299262
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-09-11 13:51:07 -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
Wonjoon Lee
8acda59faa driver/temp_sensor: Add support thermistor on EC's own ADC
Add support for ADC / thermistor reads on the EC's ADC
This will support now only ncp15wb but we can expand it
at future time.

BUG=chrome-os-partner:44764
TEST=make buildall -j
Manual on celes with subsequent commit. Boot to S0, run "temps".
Verify that temperatures are. See temperature is changing
BRANCH=None

Change-Id: If26d24b803dcff00c4c24e4e1f71d3b0de8e6738
Signed-off-by: Wonjoon Lee <woojoo.lee@samsung.com>
Reviewed-on: https://chromium-review.googlesource.com/296872
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-09-11 00:45:38 -07:00
Wonjoon Lee
502dc50f04 temp_sensor: Separate ADC interface and thermistor maths
Separate the bd99992gw ADC interface from the NCP15WB thermistor
adc-to-temp maths so that the thermistor can be used with various
other interfaces.

BUG=chrome-os-partner:44764
TEST=make buildall -j
Manual on Glados. Boot to S0, run "temps".
Verify that temperatures start around 28C and begin to increase after
system is powered-on for a long duration.
BRANCH=None

Change-Id: I3e72e9f390feebaac2440dbe722485f8d1cf8c56
Signed-off-by: Wonjoon Lee <woojoo.lee@samsung.com>
Reviewed-on: https://chromium-review.googlesource.com/296871
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-09-11 00:45:37 -07:00
Vijay Hiremath
dda0704bf9 Driver: ISL9237: Enable trickle charging
Enabled the trickle charging mode by setting the MinSystemVoltage
register[0x3EH] to board specific battery voltage minimum value.
When the battery voltage drops below the battery voltage minimum
value, trickle charging enabled.

BUG=none
TEST=Manually tested on Kunimitsu FAB4 prototype.
     Drained the battery below voltage minimum value. Using the
     i2cxfer command observed Trickle charging mode is active in
     the information register[0x3AH].
BRANCH=none

Change-Id: Id6416f2b0b74fda8cf3eafb95e044586f90b8a8e
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/298143
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Rong Chang <rongchang@chromium.org>
2015-09-10 12:35:39 -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
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
4876ab900b I2C: Remove unused arbitration support
The i2c_claim and i2c_release routines are no longer in use, removing
this code removes one odd usecase of the panic printing routines.

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

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

Change-Id: I76c1d90738e1e39b4b3226c31085513a20bbd769
Reviewed-on: https://chromium-review.googlesource.com/296732
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
Gwendal Grignou
84ed699ac9 driver: bmi160: Prevent crash when FIFO is not valid
When all BMI160 sensors are suspended, FIFO is invalid.
Put the test to check if all sensors are disable within the processing
loop: otherwise, the FIFO can become invalid while we are processing it.

Add printf to be sure we are not processing invalid FIFO.

Add a macro around ODR to really check the ODR rate, excluding the
roundup flag.

BRANCH=smaug
BUG=chrome-os-partner:44381
TEST=Using a special patch (see 44381#14) add delay
to simulate a loaded EC (like at resume).
Using a script flip-flop sensors frequency (to simulate suspend/resume).
Check that:
- we are not crashing anymore (we were before this patch)
- the driver is not hitting invalid FIFO content.

Change-Id: I7c9e86f5dcfc231ab89472a6ea03af22e2c2ac32
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/297178
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-09-07 15:16:47 -07:00
Rong Chang
229bac23f1 oak: handle USB BC 1.2 status change
Before oak rev4, BC 1.2 status change was polled on VBUS change. The
designed is changed to use a single interrupt pin for both ports.

BRANCH=none
BUG=chrome-os-partner:42610
TEST=manual
  make EXTRA_CFLAGS=-DBOARD_REV=3 BOARD=oak -j
  emerge-oak chromeos-ec
  load on oak rev3 and check BC 1.2 charging current

Change-Id: I9e6cdbb83468b5e4086cc86caadf7f2e3cbe6e48
Signed-off-by: Rong Chang <rongchang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/294442
2015-09-03 04:24:34 -07:00