Commit Graph

2577 Commits

Author SHA1 Message Date
Vincent Palatin
56e0e67abe move stringify macro to common include
We need to stringify macros arguments in various places in the code,
avoid duplicating this definition.

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

BRANCH=none
BUG=none
TEST=make buildall

Change-Id: I03530c06139fad4c60711d041239b396d9ed321e
Reviewed-on: https://chromium-review.googlesource.com/201576
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-27 23:21:26 +00:00
Vincent Palatin
8c89bcff4d zinger: activate the watchdog.
Ensure we are never stuck somewhere without doing the safety checks by
enabling the watchdog and reloading it in the safaty checks function.

I have kept the default timing constants, so on STM32F0xx the watchdog
period should be between 1.2s (LSI at 30kHz) and 2.0s (LSI at 50kHz).

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

BRANCH=none
BUG=none
TEST=add a 2s loop in the serial port interrupt handler and see the
power supply rebooting.

Change-Id: I000f2a36a31e1166adf63a36c2b7f52999adc928
Reviewed-on: https://chromium-review.googlesource.com/201575
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-27 23:21:21 +00:00
Dominic Chen
f4de7fb005 flash_ec: enclose variable $IMG in quotes to handle whitespace in filename
BRANCH=none
BUG=chromium:346807
TEST=flash firmware image with whitespace in filename

Change-Id: I8aa2ea9439a8f861e617256a63803c278708596e
Signed-off-by: Dominic Chen <ddchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/200995
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-23 05:02:06 +00:00
Vic Yang
ef2fe47070 Keyborg: implement fast scan mode
With fast scan mode, the scan rate can usually go up to 90-100 Hz. In
worst case, the rate still maintains at around 50 Hz.

BUG=None
TEST=Manual test. Check heat map.
BRANCH=None

Change-Id: I2dc25028ffa5b3175b856d3437004c21b84e7df7
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/200829
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-23 04:59:02 +00:00
Alec Berg
d3d2c077f0 pd: when PD sink request is rejected go back to discovery state
When sink receives a power request rejected packet, go back to discovery
state in order to retry transmitting request.

BUG=none
BRANCH=none
TEST=tested with zinger. when zinger has an over current fault, it
rejects requests for power. made sure that when device gets rejected
it goes back to discovery state.

Change-Id: Id532b69f52bd533e5d7ac1171d8833bc993a0e9f
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/201157
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-23 04:53:29 +00:00
Alec Berg
b19bd8f438 pd: detect source disconnection
For non-PD aware source, ensure that we detect their disconnection when
the CC goes back below Vnc.

BUG=none
BRANCH=none
TEST=when zinger gets into state where it is not talking PD, remove
charger and make sure we transition to disconnected state.

Change-Id: I675ff6d3300eda680acdd7814f0163f222eeb516
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/201156
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-23 04:53:24 +00:00
Alec Berg
3dff34e653 samus_pd: add interrupt to detect VBUS transitions quickly
Add interrupt to VBUS signal to detect VBUS transitions
quickly to make sure we transition out of SNK_READY when VBUS
goes away.

BUG=chrome-os-partner:28611
BRANCH=none
TEST=Test on samus 1.9 board. Ran for hours with charger plugged
in, made sure when charger cuts out after missing ping responses,
that it successfully goes to disconnected state and renogiates
power.

Change-Id: I93b2e49891e6a38c98095b7311a9435606cc61ab
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/201155
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-23 04:50:22 +00:00
Alec Berg
113ea43a69 samus: limit input current to 2.5A to prevent over currenting zinger
Set maximum input current limit to ~2.5A to prevent over current
faults on zinger. Note, we still get over current faults sometimes
but it always clears in < 10seconds.

BUG=chrome-os-partner:28611
BRANCH=none
TEST=Test with a samus 1.9 and a zinger. Plug and unplug charger
many times and make sure that we are eventually able to successfully
negotiate for power and start charging.

Change-Id: I5a7adf9fc7f5ed7a0c7dfdb620e0c1474f72a878
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/201154
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-23 04:50:19 +00:00
Bill Richardson
45be37b5d9 Samus: The Silego on proto1b inverts the COL2 output
Without this change, COL2 is dead.

BUG=chrome-os-partner:28721
BRANCH=ToT
TEST=manual

Tried all keys, now they work.

Change-Id: Ie6f6ba342c7dae035d9a1dc6b2d4837146840d95
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/200852
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2014-05-22 05:01:34 +00:00
Vincent Palatin
3d5f117f91 zinger: ensure we re-enable the output once a fault is cleared
When a fault is cleared, reset the PD state and communicate,
so that we re-enable the output and negociate a new voltage.

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

BRANCH=none
BUG=none
TEST=on Zinger connected to Firefly, trigger an OCP (using an electronic load)
and see that the output is re-enabled once the OCP is cleared after 1 second.

Change-Id: I3199d2c8675ab43958321378fd7f65ac383468cc
Reviewed-on: https://chromium-review.googlesource.com/200338
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-05-21 20:36:10 +00:00
Alec Berg
f52b23e964 samus_pd: when sinking power detect loss of VBUS and disconnect
Detect loss of VBUS when acting as PD sink and go to the disconnected
state. This allows us to renegotiate power when power supply drops
and switches to 5V.

BUG=none
BRANCH=none
TEST=On a samus, tested by running for a couple of hours, and verifying
that occasionally when zinger drops from 20V to 5V, we detect it and
go to the disconnected state. Note, this only happens a couple times
every hour.

Change-Id: I237d267824ff564662c9c02e525ce2613ed229e6
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/200365
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-21 20:35:47 +00:00
Vic Yang
ffac23c0ea Add cprints() and ccprints()
Our code base contains a lot of debug messages in this pattern:
  CPRINTF("[%T xxx]\n") or ccprintf("[%T xxx]\n")
The strings are taking up spaces in the EC binaries, so let's refactor
this by adding cprints() and ccprints().

cprints() is just like cprintf(), except that it adds the brackets
and the timestamp. ccprints() is equivalent to cprints(CC_CONSOLE, ...)

This saves us hundreds of bytes in EC binaries.

BUG=chromium:374575
TEST=Build and check flash size
BRANCH=None

Change-Id: Ifafe8dc1b80e698b28ed42b70518c7917b49ee51
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/200490
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-05-21 20:32:17 +00:00
Alec Berg
478361de69 samus: change battery charging current sense resistor value
Correct battery current sense resistor is 5m-ohms.

BUG=none
BRANCH=none
TEST=Still having charging problems, but this should be a little
better.

Change-Id: I54f664a3efa3b3afdc46c2329467cb97ad02a301
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/200751
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-05-21 20:32:13 +00:00
David Hendricks
f7403b11e2 stm32: Enable USART TCIE after clearing TC
After clearing the TC flag, we should re-enable TCIE so that when
the DMA transfer is done we re-interrupt and allow
uart_process_output() to continue printing whatever is in the
circular buffer (in the case of wrap-around) or finish gracefully
if there is nothing left in the buffer.

BUG=chrome-os-partner:28837
BRANCH=nyan
TEST=Commands now reliably print full output whereas before they
might appear truncated until another interrupt was triggered to
finish printing the buffer.

Change-Id: I0a4236139f57812f384e2b99af45195537201a04
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/200499
2014-05-21 04:18:27 +00:00
Vic Yang
876fe28e6f Show success message after 'make buildall'
'make buildall' spews out a long long long message, and when an error
occurs, it's sometimes hard to spot the error message. By adding a
explicit success message after a successful run, one can just look for
that success message to determine if it failed.

BUG=None
TEST=Build and see success message.
TEST=Introduce an error, build, and check there is no success message.
BRANCH=None

Change-Id: Ia5468342ad2eb5378c3e10774ed81c5c91f002a2
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/200618
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-05-21 04:18:23 +00:00
Vincent Palatin
2d4a02759d pd: revert slow traces in PD code
The commit 4ba7a15 has modified the traces resulting in a far larger overhead
(mainly due to %T doing dozen? of 64-bit divisions which is an expensive
operation on a Cortex-M0)
as a result the code is now missing communication deadlines.
for lack of a better solution, revert the modification is this file.

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

BRANCH=none
BUG=none
TEST=run PD communication between Zinger and Firefly,
and between Fruitpie and Samus and see communication
error rate is going down from 30% failure to less than a few percents.

Change-Id: I902b951450bc200baad722ae5d65053ceda5357b
Reviewed-on: https://chromium-review.googlesource.com/200326
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-21 04:17:58 +00:00
Vic Yang
46c6d3dd1b Keyborg: fix a bug in task_wait_event()
The match interrupt is disabled before we actually intend to. Fix it.

BUG=None
TEST=Build and boot
BRANCH=None

Change-Id: I8fb171e849809d1e4f35f00bbf6d15c9a8caad74
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/200680
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-21 04:12:45 +00:00
Vic Yang
98d78db982 Keyborg: do not trim response before sending back to master
ADC sampling is slower than SPI communication. If we spend more CPU
cycle trimming the response, we are just wasting time and letting SPI
bus sit idle.

BUG=None
TEST=Build and boot. Check scanning rate.
BRANCH=None

Change-Id: I9a4ece28a29ffd3205931ea71958cbc73642be6b
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/200673
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-21 04:12:39 +00:00
Vic Yang
64e5cc33d9 Keyborg: make a copy of response before transmitting
Before transmitting the response back to the master, the slave should
make a copy of it. Otherwise, if the buffer is reused, we run the risk
of overwriting the last response before it's sent out. We got away with
this before because we didn't overwrite it fast enough. Let's fix this
to be safe.

BUG=None
TEST=Build and boot
BRANCH=None

Change-Id: If3c50692d554119de9ff0f0ae0de450b923b11af
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/200672
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-21 04:09:37 +00:00
Vic Yang
951ee9e379 Keyborg: fix ADC timing and increase sampling rate
This fixes a bug that PMSE_MRCR is changed too early. Also, with this
bug fixed, we can increase the sampling rate to 13.5 cycles/sample.

BUG=None
TEST=Check heat map
BRANCH=None

Change-Id: Id7dc34fd7975ca7153b96443b8d4d28f1557eec4
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/200651
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-21 04:09:34 +00:00
Vic Yang
7dd3ee4db3 Keyborg: Switch to HSE
We have a 16MHz oscillator input, so let's use it to save HSI power.

BUG=None
TEST=Build and boot
BRANCH=None

Change-Id: Ia2d97cfc8b97b7f8661112ebbd84952e41b955f2
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/200650
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-21 04:07:57 +00:00
Vic Yang
724cfbc6c4 Keyborg: fix bug in slave data processing
This fixes two bugs:
  - The row order on the slave is reversed
  - The last value is missed when transferring data to the master

BUG=None
TEST=Build and check the heatmap
BRANCH=None

Change-Id: Ic51ad1132d948ec6ec68dc673288ec6f29c6ebe7
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/200621
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-21 04:07:54 +00:00
Louis Yung-Chieh Lo
9e2fac8390 nyan: don't compile in shorthelp of console commands
Since stm32l has smaller flash size, undef CONFIG_CONSOLE_CMDHELP to
remove short descripton to save 2560 byes.
If you need to read the description, grep that in the code.

BUG=chromium:374575
BRANCH=tot,nyan
TEST=buildall and
% grep hey build/big/ec.RO.map
0x000000000000ef48
After shrink -->
0x000000000000e548

Change-Id: I856e89def6456607ade610134bf318d8522f5e4d
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/200472
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-05-20 07:34:54 +00:00
Louis Yung-Chieh Lo
b287e7b344 reduced the charge v2 debug message size
Remove redudant struct names. Replace 2 spaces with a tab char.
This reduces 128 bytes in flash size.

BUG=chromium:374575
BRANCH=tot,nyan
TEST=Built and verified on big
% grep hey build/big/ec.RO.map
  0x000000000000ef48
After shrink:
  0x000000000000eec8

The output still is easy to read.
> chg
state = charge
ac = 1
chg.*:
        voltage = 13040mV
        current = 256mA
        input_current = 2048mA
        status = 0x10
        option = 0xf912
        flags = 0x0
batt.*:
        temperature = 20C
        state_of_charge = 0%
        voltage = 8253mV
        current = 274mA
        desired_voltage = 13050mV
        desired_current = 256mA
        flags = 0x3
        remaining_capacity = 0mAh
        full_capacity = 4026mAh
        is_present = YES
requested_voltage = 13040mV
requested_current = 256mA
force_idle = 0
manual_mode = 0
user_current_limit = -1mA
battery_seems_to_be_dead = 0
debug output = off

Change-Id: I82a3a5cda3fa96e247355dc90431691015eece6c
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/200470
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
2014-05-20 07:34:10 +00:00
Todd Broch
8b428e2936 Enable flashing of usbpd mcu for samus.
CL manages various dut-control dependencies for readying the STM32
part for programming.

Additionally deprecated the short-lived --uart_prefix argument as
user's defining this could be problematic without knowledge of
necessary modifications to h/w & s/w.

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

CQ-DEPEND=CL:200146
BRANCH=none
BUG=chrome-os-partner:28826
TEST=manual,

  util/flash_ec --board=samus_pd succeeds.
  util/flash_ec --board=spring succeeds.

Change-Id: I7627c77293da187700aeddf7382dbb12e163a2ef
Reviewed-on: https://chromium-review.googlesource.com/200148
Tested-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
2014-05-19 20:28:46 +00:00
Todd Broch
d67b9f3955 Implicitly decide uart_prefix based on board.
Signed-off-by: Todd Broch <tbroch@chromium.org>

BRANCH=none
BUG=chrome-os-partner:28826
TEST=manual
  util/flash_ec --board=samus_pd
  - See uart_prefix is 'usbpd'
  util/flash_ec --board=rambi
  - See uart_prefix is 'ec'

Change-Id: Iba14fd0635d72413e48d45992c852393301b3f6b
Reviewed-on: https://chromium-review.googlesource.com/199939
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
2014-05-19 20:25:43 +00:00
Todd Broch
1fc8e63681 Add uart_prefix flag to control which uart is used to flash.
There are CrOS devices that have multiple embedded controllers and
therefore multiple uarts that can be used for programming.

This CL allows user to set the uart_prefix to access the alternate
uarts via the --uart_prefix argument.  Default is still 'ec'.

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

BRANCH=none
BUG=chrome-os-partner:28826
TEST=util/flash_ec --board=samus_pd --uart_prefix=usbpd

Change-Id: I9fbe8d13067b7f514447645b2587dda706445661
Reviewed-on: https://chromium-review.googlesource.com/199900
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
2014-05-19 20:25:40 +00:00
Vic Yang
4cb6971daf Keyborg: encode the scanned heat map to fit into RAM
A single frame of the scanned heat map is too big to fit into RAM. Let's
encode it so that we can get the whole frame.

BUG=None
TEST=Touch on various places on the panel and see corresponding results.
BRANCH=None

Change-Id: I8c7c72d5d4a83ebc2018c0abd57075697c931bef
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/199940
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-18 02:41:39 +00:00
Alec Berg
09ad49c2bd samus_pd: PD configuration bug fixes
Fix bug to get PD transmit working. Fix config bug
for reading the CC ADCs.

BUG=chrome-os-partner:28350
BRANCH=none
TEST=connect fruitpie and samus via USB-C and run
pd dev on samus and pd charger on fruitpie.

Change-Id: Ic981a1f1e621ef4b69dedc61a02751346274aa4e
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/200159
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-18 00:52:02 +00:00
Alec Berg
98af4df0dc samus_pd: remove battery config
Remove battery config since PD chip doesn't talk to battery.

BUG=chrome-os-partner:28350
BRANCH=none
TEST=load on samus and make sure console running normally.

Change-Id: I97174aa3796eaa10b3a5a2bf0aa79a39ba8640ac
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/200142
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-18 00:51:59 +00:00
Vincent Palatin
dc37d4a1d5 zinger: fast over-current protection
When the supply output is enabled, ensure that we detect quickly any
over-current situation by setting an analog watchdog in continuous
conversion mode.

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

BRANCH=none
BUG=chrome-os-partner:28331
TEST=plug an electronic load to Zinger and see the OCP triggered
quickly when we go above the current threshold.

Change-Id: I7da50ef242addbd2f4f48f624494daa321ac22b2
Reviewed-on: https://chromium-review.googlesource.com/199924
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-05-17 20:17:25 +00:00
Vincent Palatin
5fd3341077 zinger: add support to flash RW firmware
Allow flashing the RW firmware by sending Vendor-Defined Messages over
the USB-PD link.

This is not the secure update whose design is still under discussion,
it's a simple update with integrity check.

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

BRANCH=none
BUG=chrome-os-partner:28330
TEST=using the following CLs,
./util/flash_pd.py ./build/zinger/ec.RW.flat
and see Zinger booting on RW, repeat the operations with different
builds of the RW firmware.

Change-Id: Icd90eb92f7321ccd66341a50b9dabd73c59c68c1
Reviewed-on: https://chromium-review.googlesource.com/197948
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2014-05-17 20:14:23 +00:00
Vincent Palatin
00cf957832 Add SHA-1 hash
Imported code from VBoot firmware cryptolib and slightly reformat it for
the EC code base.

We already have SHA-256, but for updates over PD, the maximum payload
size is 192 bits, so SHA-1 seems a better trade-off.

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

BRANCH=none
BUG=chrome-os-partner:28336
TEST=none

Change-Id: I6da7b71a9af03c6689accfa3c59cfcf7776fcfc6
Reviewed-on: https://chromium-review.googlesource.com/199553
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2014-05-17 20:14:17 +00:00
Vincent Palatin
006a3f58b0 firefly: update VBUS voltage sensing
The voltage divider resistor values have changes to 10K/100K,
update the code to take this into account.

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

BRANCH=none
BUG=none
TEST=none

Change-Id: I2a1469e3441c4bea2bfe3f3a3b7f8ac2225cca51
Reviewed-on: https://chromium-review.googlesource.com/200343
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-17 06:48:23 +00:00
Vincent Palatin
f025bb66cc firefly: voltage button debouncing
Add a debouncing period on the mechanical switches event detection to
avoid issues in the noisy factory environment.

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

BRANCH=none
BUG=none
TEST=none

Change-Id: I40316c8e32948f92cb92f8743003d5be8cbe8e11
Reviewed-on: https://chromium-review.googlesource.com/200342
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-17 06:48:20 +00:00
Alec Berg
a8688f5e14 samus_pd: fix DMA init bug
Enable clock to syscfg in order to write DMA remapping
registers in pre_init().

BUG=chrome-os-partner:28350
BRANCH=none
TEST=test on a samus board.

Change-Id: I71b7f9b2bdc45f138f404997ccde65f54a1125d0
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/200039
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-16 01:56:59 +00:00
Bill Richardson
65df2fd6e4 Add "debug" option to charge_state_v2.c
This is useful for testing battery charge profiles. When enabled, a dump of
all battery, charger, and charge state information will be printed whenever
the battery charge percentage changes.

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

On the EC console:

  chg debug on

then watch the console while either charging or discharging the battery.

Disable with

  chg debug off

Change-Id: I6725c461461f90fcd812873f97490e980ab47bc6
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/199816
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-05-15 05:28:08 +00:00
Bill Richardson
10aecec841 Replace magic numbers with #defines for charger bq24773.c
BUG=none
BRANCH=none
TEST=buildall -j

Change-Id: I125fbe7716f6c8b78011c3a39745ec4992074795
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/199796
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-05-15 05:26:35 +00:00
Bill Richardson
c46f569a39 Add standalone lightbar simulation tool
This adds an "extra/" directory to hold various experiments and optional
programs. With this change, we add a tool that can simulate the lightbar
behavior on the build machine. That can be used to experment with variations
in the lightbar pattern code without needing to reflash a Pixel with a new
EC to see the effect.

There is no functional change to the EC code, just a couple of #ifdefs to
allow common/lightbar.c to be compiled separately from the EC.

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

  cd extra
  make
  ./lightbar

You may need to install the libxcb1-dev package on your build machine.

Change-Id: I847ce7ea97cae792b1de1b91f488819e873b6555
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/199883
2014-05-15 05:20:14 +00:00
Bill Richardson
53eb009d52 Put the lightbar IC controls and pattern logic into separate files
This puts the code that talks to the lightbar hardware in one file, and the
code that implements the pretty patterns and behavior into another. This
will let us make improvements or changes to the patterns without requiring
detailed knowledge of the controller chips.

BUG=chrome-os-partner:28596
BRANCH=ToT
TEST=make buildall -j

Refactoring only. There is no new functionality.

Change-Id: I4e5fe8943385ddeab26bbd7e66c20e2dccd3dc43
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/199882
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-05-15 05:20:11 +00:00
Bill Richardson
9d3286301d Add GET_RGB, GET_BRIGHTNESS, and GET_DEMO subcommands to lightbar
This adds three new lightbar subcommands to the EC_CMD_LIGHTBAR_CMD host
command, allowing the AP to read the current brightness level, the
current lightbar LED values, and the state of demo mode.

Because this is new, also update LIGHTBAR_IMPLEMENTATION_VERSION. All the
previous commands are unchanged, though.

BUG=chrome-os-partner:28596
BRANCH=ToT
TEST=manual

From the AP, run these commands to see the changes:

  ectool version
  ectool lightbar brightness
  ectool lightbar 0
  ectool lightbar 1
  ectool lightbar 2
  ectool lightbar 3
  ectool lightbar demo

The version output is different, the other commands used to just emit
errors.

Change-Id: If32a5d2388217edc3ae7b9b091d66e9d2cf753be
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/199881
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-05-15 05:18:16 +00:00
Bill Richardson
485554aea3 Rearrange lightbar.c to separate IC control from pattern logic
Just refactoring the code to make it neater. No functional changes.

BUG=chrome-os-partner:28596
BRANCH=ToT
TEST=make buildall -j

Change-Id: Ib436369c2242de3b0fdacf65404eaba4a309e73b
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/199880
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-05-15 05:18:11 +00:00
Alec Berg
0869221e4f samus: add PD MCU interrupt signal to gpio list
Add PD MCU interrupt signal to gpio list, currently with a dummy
interrupt function which prints a message to let us know it is
occuring.

BUG=chrome-os-partner:28721
BRANCH=none
TEST=none

Change-Id: I1fab016b84b1abaced905e0ea0bd35dbd67b30bb
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/199792
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-14 22:53:49 +00:00
Alec Berg
6d01f2e169 samus: add PD MCU board
Initial patch for samus PD board. This configures GPIOs to match
samus 1.9.

BUG=chrome-os-partner:28350
BRANCH=none
TEST=none, no boards yet.

Change-Id: Ibc9d67325a1d9699b4e76e2998ab830ddbd0fb98
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/199660
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-14 22:53:44 +00:00
Alec Berg
ac78a35cf1 fruitpie: disable battery charging chip ILIM pin
Typically bq24xxx charging chip limits input current to minimum of
register value and ILIM pin. For fruitpie, the current limit will
be decided solely in software, and the hardware pin will be ignored.

BUG=chrome-os-partner:28611,chrome-os-partner:28311
BRANCH=none
TEST=Tested on fruitpie. Verified that current limit can be set
above the ILIM pin value of 500mA.

Change-Id: Ia687446f95f9d18fde9d2b4ebb0e1c093aebf885
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/198940
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-14 20:53:03 +00:00
Alec Berg
ca55e1a6bb samus: disable battery charging chip ILIM pin
Ignore ILIM pin for charging which allows EC to set the input
current limit to anything it desires. This is necessary for
1.9 build because the hardware sets the ILIM to something
like 0.5A.

BUG=chrome-os-partner:28611
BRANCH=none
TEST=none
CQ-DEPEND=CL:198940

Change-Id: I43c57d0040e341e091ee36c97ec601d6bd174606
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/199661
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-14 20:52:58 +00:00
Vincent Palatin
aa115bca43 zinger: increase OCP threshold
As per hardware team request, use a higher over-current limit to avoid
false positives due to measurement precision margin.

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

BRANCH=none
BUG=chrome-os-partner:28331
TEST=use a Zinger connected to an electronic load and trigger the
protection.

Change-Id: If031f6f58b9b7119c6fa3fa3273c08f16cbbbebb
Reviewed-on: https://chromium-review.googlesource.com/199552
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-14 18:09:36 +00:00
Bill Richardson
18dcf0989e Samus: Punt on BQ_IBAT measurements for now
Nothing looks at this except for an EC console command, so leave it at unity
gain until we've confirmed that it's working correctly.

BUG=chrome-os-partner:28721
BRANCH=ToT
TEST=make buildall

Change-Id: I81085743535f4664ac8bf1d016bb7562046ab49b
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/199243
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-05-12 20:02:38 +00:00
Bill Richardson
3f94eba930 Samus: Update configuration for proto1.9
Start of changes to Samus' board.h and board.c to support proto1.9

BUG=chrome-os-partner:28721
BRANCH=ToT
TEST=make buildall

Change-Id: I70590c1f9845430801a6c2939ac92be289750ca3
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/199242
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-05-12 20:02:34 +00:00
Bill Richardson
9e0cd7b162 Samus: Move single-use constant into the file that uses it.
There's a constant defined in board/samus/board.h that's only used in
board/samus/panel.c. Let's just put it in that file, so it doesn't clutter
up the config.

BUG=chrome-os-partner:28721
BRANCH=ToT
TEST=make buildall

Change-Id: I23d61aff16726a11a0408957cd109b49c3bf954c
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/199241
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-05-12 20:02:31 +00:00