Commit Graph

3263 Commits

Author SHA1 Message Date
Dawid Niedzwiecki f96f176c30 task_set_event: remove the wait argument
There is an option in the task_set_event function which force
the calling task to wait for an event. However, the option is never
used thus remove it.

This also will help in the Zephyr migration process.

BUG=b:172360521
BRANCH=none
TEST=make buildall

Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com>
Change-Id: Ic152fd3d6862d487bcc0024c48d136556c0b81bc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2521599
Reviewed-by: Jett Rink <jettrink@chromium.org>
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
2020-12-14 19:59:09 +00:00
Scott Collyer ff4f8fd9a4 stm32g4: ucpd: Add support for USB-PD messaging
This CL adds routines required to support USB-PD messaging to the UCPD
driver. UCPD is performs TCPC type functions, but is not a TCPC. UCPD
does utilize the common TCPCI APIs as entry points called from the
port's PD task. In addition, UCPD has its own task to manage more
easily transmit requests from TCPM layer and GoodCRC messages which
must be intiated in the UCPD driver itself.

BUG=b:167601672
BRANCH=None
TEST=verfied type-c attaches properly on quiche

Signed-off-by: Scott Collyer <scollyer@google.com>
Change-Id: I0c02bee4badc479125832a6b5a6fa156e998c201
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2247117
Tested-by: Scott Collyer <scollyer@chromium.org>
Auto-Submit: Scott Collyer <scollyer@chromium.org>
Commit-Queue: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Diana Z <dzigterman@chromium.org>
2020-12-13 02:56:49 +00:00
Dossym Nurmukhanov 52863374ad COIL: Standardize i2c peripheral language
BUG=none
TEST=validate volteer build (i2c_peripheral.c is not used by any boards)
BRANCH=none

Signed-off-by: dossym@chromium.org
Change-Id: Ib2d78dc3fc9f4f189f84409cf43ab96788c429be
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2587227
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2020-12-12 20:15:38 +00:00
Dossym Nurmukhanov c03b3d8174 COIL: Rename i2c_peripheral files
BUG=none
TEST=build and run on volteer
BRANCH=none

Signed-off-by: dossym@chromium.org
Change-Id: I11a75e4954e918b2d4ff575dee14dec621a619b3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2587226
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2020-12-12 20:15:35 +00:00
Tzung-Bi Shih bcdb3009b6 chip/mt8192_scp: expose PMU-related functions
Exposes PMU-related functions so that we can call the functions to study
some part of cache performance.

BRANCH=none
BUG=b:172988651
TEST=make BOARD=asurada_scp

Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org>
Change-Id: I27182e3d2af52d8761f45359f3627d70c5acf28c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2567517
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
2020-12-10 05:33:12 +00:00
Tzung-Bi Shih ed30c7ca76 chip/mt8192_scp: invalidate all I/D cache when resetting PMU
When resetting PMU, also:
- invalidates I-cache
- flushes D-cache

> enable_pmu i
select "I"
> show_pmu
cycles: 1228599543
retired instructions: 80706
I-cache:
  access: 55089
  miss: 179 (0.32%)
non-cacheable I: 0

> enable_pmu d
select "D"
> show_pmu
cycles: 970961198
retired instructions: 32638
D-cache:
  access: 12598
  miss: 80 (0.63%)
non-cacheable D: 972

Expect to see the increasing "miss" counts.

BRANCH=none
BUG=b:172988651
TEST=make BOARD=asurada_scp

Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org>
Change-Id: Ib779bd224cd39ff8de05d1568028ef63b189ecb4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2567516
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
2020-12-10 05:33:11 +00:00
Edward Hill 527cde4475 npcx: Don't delay hibernate wake by 2 seconds
Waking from PSL hibernate is power-on for EC but not for H1, so
we should not add the 2 second delay for CONFIG_BOARD_RESET_AFTER_POWER_ON
in this case.

BUG=b:173180800
BRANCH=zork
TEST=no 2 second delay on wake from hibernate

Signed-off-by: Edward Hill <ecgh@chromium.org>
Change-Id: Ib0c8f2ca7f197626b20a11e21ace44a5046db18b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2576439
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
2020-12-07 21:38:40 +00:00
Vincent Palatin d29bdc9913 stm32: low power configuration for STM32F4
As most of the peripherals were not implemented to support switching to
16-MHz HSI (e.g. high speed serial port requires a clock input > 24
Mhz), implement a simpler clock scheme than the dynamic between HSI and
PLL used other platforms:
- the PLL is disabled only when entering the low-power idle and the PLL
  locking time is added to wake-up time.
- when the host is running (not suspended) we stay in a high power mode
  (~20mW).

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

BUG=b:130561737
TEST=manual, on bloonchipper, check we can still capture fingerprint.
read the MCU power consumption: pp3300_dx_mcu_mw is 2.367 mW.
BRANCH=fpmcu-bloonchipper

Change-Id: Ic1fe015b2501bdea9779a2f63fab296f8812c315
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2555162
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2020-12-02 09:39:18 +00:00
Vincent Palatin 8d98b0e5dc stm32: add STOP mode on STM32F4
Implement a low power idle mode using the STM32F4 STOP mode.

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

BUG=b:130561737
TEST=manual, on bloonchipper, check we can still capture fingerprint.
read the MCU power consumption.
BRANCH=fpmcu-bloonchipper

Change-Id: I11249e9b68c989033263e34e1cde3f19ffe7c54c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2537631
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2020-12-02 09:39:15 +00:00
Vincent Palatin aba388b656 stm32: fix RTC rounding error breaking alarms
On STM32F4, when converting micro-seconds to the RTC sub-second counter
value, the current computation in the us_to_rtcss() routine has a large
rounding error which can even led to generate a negative value.
When such a negative value is output and then programmed in the
(unsigned) RTC_ALRMASSR register used to set the alarm precise
sub-second timestamp, it might put a wrong value in the past.
As a consequence when the RTC alarm is used a wake-up mechanism for the
low power idle, it might never fired and trigger a watchdog reboot.

An example of bad values on a STM32F412 with the RTC driven by the
32-kHz LSI:
- RTC_PREDIV_A = 1
- RTC_FREQ = (STM32F4_LSI_CLOCK / (RTC_PREDIV_A + 1) = 16000 /* Hz */
- RTC_PREDIV_S = (RTC_FREQ - 1) = 15999
- US_PER_RTC_TICK = 1000000 / RTC_FREQ = 62 /* rounded from 62.5 */
When converting 996000 us,
 us_to_rtcss(996000) = RTC_PREDIV_S - (us / US_PER_RTC_TICK)
                     = 15999 - (996000 / 62)
                     = -65
 returned as a uint32_t as 0xfffffffb.

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

BUG=b:130561737
TEST=manual, with the STOP mode enabled, we no longer see watchdog
reboot due to the RTC alarm being set in the past and never firing.
TEST=manual, verify that the output of the 'gettime' console command is not
drifting compared to the wall clock when the low power idle using the
RTC time is used.
BRANCH=fpmcu-bloonchipper

Change-Id: I53869539828bed9a5900d29407b5feba140b8217
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2563684
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2020-12-02 09:39:09 +00:00
Vincent Palatin 876bd4056b stm32: add dynamic clocking for STM32F4
Allow to transition between the PLL to run at full speed
and the bare HSI (internal RC oscillator at 16Mhz) to save power.

On HSI, as our sysclk frequency is low, we run all peripheral clocks
undivided at the same frequency.

Keep the configuration for other platforms running from the HSE
(external crystal)

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

BUG=b:130561737
TEST=manual, verify the timers are working by checking the output of the
'gettime' console command against the wall clock.
TEST=manual, verify the UART console works as expected.
TEST=measure MCU power on bloonchipper in various modes through the INA:
PLL 19.20 mW HSI 4.73 mW STOP 2.10 mW
BRANCH=fpmcu-bloonchipper

Change-Id: I1185e04c9a7819fec05dd643b7026116b146f3b8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2527049
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2020-12-02 09:38:58 +00:00
Vincent Palatin 696492499f stm32: update the timer pre-scaler on STM32F4
Add support for changing for the timer source clock frequency on
STM32F4 by re-computing the timer pre-scaler value in the
HOOK_FREQ_CHANGE callback.
Preparatory work to implement power management switching between PLL and
HSI as sysclk.

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

BUG=b:130561737
TEST=manual, verify the output of the 'gettime' console command against
the wall clock.
BRANCH=fpmcu-bloonchipper

Change-Id: Ia7dc24d3b1dbff816b1cebbc87492e678b987dfd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2527048
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2020-12-02 09:38:56 +00:00
Tzung-Bi Shih d0775dff76 chip/mt8192_scp: support PMU counter
Supports performance monitor unit counters.

Introduces new console commands:
- enable_pmu
- disable_pmu
- show_pmu

> enable_pmu X
Parameter 1 invalid
Usage: enable_pmu [I | D | C]

> enable_pmu i
select "I"
> show_pmu
cycles: 842443131
retired instructions: 32855
I-cache:
  access: 22324
  miss: 0 (0.0%)
non-cacheable I: 0

> enable_pmu d
select "D"
> show_pmu
cycles: 1137656582
retired instructions: 36619
D-cache:
  access: 13779
  miss: 0 (0.0%)
non-cacheable D: 1072

> enable_pmu c
select "C"
> show_pmu
cycles: 2656349519
retired instructions: 74746
control transfer instruction:
  total: 20767
  miss-predict: 13346 (64.26%)
interrupts: 262

BRANCH=none
BUG=b:172988651
TEST=define DEBUG && make BOARD=asurada_scp

Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org>
Change-Id: I461ae51b84badb25e9b50ef1af7e3a81139cea47
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2562910
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2020-11-27 13:41:44 +00:00
Ting Shen d1df46fd72 usb_hid_keyboard: implement vivaldi top row feature
This CL implements a feature report defined in [1] that describes the
keyboard's top row layout.

[1] http://doc/1NTxSGv3WA2Vn4dlPLOcvKBvPytWOF0UAcIYQaFctTug

BUG=b:171156337
TEST=Verify feature report content using test code in CL:2530156.
BRANCH=none

Signed-off-by: Ting Shen <phoenixshen@google.com>
Change-Id: I28a93f1b926d58602eb66d1b090e89384cb09f77
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2522641
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Commit-Queue: Ting Shen <phoenixshen@chromium.org>
Tested-by: Ting Shen <phoenixshen@chromium.org>
2020-11-27 06:21:32 +00:00
Dino Li 7b6455ac96 it83xx/i2c: adjust Tlow and Thigh of 400kHz clock
This CL increased clock's Tlow to 1.51 us (1.3 us minimum) and
reduced Thigh to 1.087 us (0.6 us minimum).

BUG=b:163384683
BRANCH=none
TEST=i2c clock meet timing at 400kHz.

Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
Change-Id: Id62b2370018ba2d41e0dbc715a4c40629260d66b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2557281
Reviewed-by: Diana Z <dzigterman@chromium.org>
Reviewed-by: Mike Goodey <mgoodey@google.com>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2020-11-25 02:53:32 +00:00
Tzung-Bi Shih 998ddb3f4a chip/it83xx: move __RAM_CODE_SECTION_NAME
Moves __RAM_CODE_SECTION_NAME from registers.h to config_chip.h.  Or
switch.S cannot see the macro.

BRANCH=none
BUG=none
TEST=1. make BOARD=asurada
     2. grep __switch_task build/asurada/RW/ec.RW.smap

Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org>
Change-Id: I1ef272c2e2181a88e4f53dc3024330a1a26c0688
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2549342
Reviewed-by: Dino Li <Dino.Li@ite.com.tw>
Reviewed-by: Diana Z <dzigterman@chromium.org>
2020-11-20 02:02:53 +00:00
Caveh Jalali 82a761da1b npcx: avoid checking value of undefined symbol
This sets a default value of 0 for NPCX_UART_MODULE2 and
NPCX9_PWM1_SEL so that board files don't need to set these.

BRANCH=none
BUG=b:173575131
TEST=buildall

Change-Id: Ief84ed558bb5431f13fb01b963db3bd97fc8d659
Signed-off-by: Caveh Jalali <caveh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2546639
Reviewed-by: CH Lin <chlin56@nuvoton.corp-partner.google.com>
Reviewed-by: Keith Short <keithshort@chromium.org>
2020-11-19 20:52:54 +00:00
Tzung-Bi Shih f4fb445737 core/riscv-rv32i: move essential code to ram_code only if supports
Commit "it83xx: pull more functions into __ram_code section"
(https://crrev.com/c/2535899) breaks Asurada SCP.  It moves
some essential code to .ram_code section but only IT8XXX2
family includes .ram_code in linker script.

Moves the context switch code to ram_code only if it supports.

BRANCH=none
BUG=none
TEST=make BOARD=asurada_scp && make BOARD=asurada

Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org>
Change-Id: I8602f7ef0103282feeddbfe1757f7cf7fb5512dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2546722
Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
2020-11-19 08:53:27 +00:00
Dino Li 1dcfc09283 it83xx: pull more functions into __ram_code section
Because we have space in the section, so we pulled more functions
into the section. If a function is cached in __ram_code section
(static cache), we can save latency of fetching code of the function
from flash. (Fetching 64 bytes code from flash takes about 4us latency)

BUG=none
BRANCH=none
TEST=buildall.
     Asurada and Drawcia are both able to boot to kernel.

Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
Change-Id: I8b413bd577c4e5b73a5c67018d17955da1ed0c55
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2535899
Reviewed-by: Diana Z <dzigterman@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
2020-11-18 02:57:08 +00:00
Ting Shen 8f8d017fb3 i2c_master: extend i2c_xfer_no_retry to also support large write
This CL extends CONFIG_I2C_XFER_LARGE_READ to also support large
(greater than 255 bytes) write.
Related config name is also updated to reflect the behavior change,

BUG=b:169651794
TEST=flash fw successfully on Zed.
BRANCH=none

Signed-off-by: Ting Shen <phoenixshen@google.com>
Change-Id: Icb889013da01f48708cd0227207561b8186bac63
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2537412
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Commit-Queue: Ting Shen <phoenixshen@chromium.org>
Tested-by: Ting Shen <phoenixshen@chromium.org>
2020-11-17 18:00:39 +00:00
Tzung-Bi Shih 15b590a099 chip/mt8192_scp: update memory map
Updates memory maps.

SCP view 0x1000_0000 maps to AP view 0x5000_0000.
SCP view 0xf000_0000 maps to AP view 0x6000_0000.

BRANCH=none
BUG=b:156222459
TEST=make BOARD=asurada_scp

Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org>
Change-Id: Ia837af7ee00bd6d4ec21be7533037667f680d29d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2531754
Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
2020-11-17 12:08:05 +00:00
Tzung-Bi Shih 0895e190d9 chip/mt8192_scp: remove confusing comments
BRANCH=none
BUG=b:156222508
BUG=b:156222459
TEST=make BOARD=asurada_scp

Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org>
Change-Id: Icda539485e630c2e14a38e182f3b3c3a2959cec8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2534435
Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
2020-11-17 12:08:00 +00:00
Tzung-Bi Shih eaaa616041 chip/mt8192_scp: support RAM cache
Supports RAM cache for:
- L2TCM
- System DRAM

BRANCH=none
BUG=b:156222459
BUG=b:156222508
BUG=b:172886808
TEST=manually check assembly code

Signed-off-by: Tzung-Bi Shih <tzungbi@chromium.org>
Change-Id: I3fd3d8f858a172bf26dfec6a5c6c403d73164039
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2513414
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2020-11-17 12:07:50 +00:00
Scott Collyer 90d57a15d9 ucpd: Fix merge error with clock constants
This CL fixes an issue with a rebase merge, UCPD_IFRGAP_HBIT_CNT had
been changed to UCPD_IFRGAP_CNT in a previous CL. This CL removes
HBIT.

BUG=b:167601672
BRANCH=None
TEST=make BOARD=quiche

Signed-off-by: Scott Collyer <scollyer@google.com>
Change-Id: Ideff65872d744bc7e3b3cdfa8c5af37f4725be36
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2522649
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Diana Z <dzigterman@chromium.org>
Commit-Queue: Scott Collyer <scollyer@chromium.org>
2020-11-12 06:45:52 +00:00
Ting Shen decb6363e9 hammer: support vivaldi keyboard
This CL implements vivald function row config for hammer keyboard.

If CONFIG_USB_HID_KEYBOARD_VIVALDI defined, STM32 HID keyboard now returns
an extra 32-bit data represents the status of action keys. Additionally,
if board_vivaldi_keybd_config returns a non-null pointer, driver will
convert function keys to action key according to the given config.

BUG=b:171156337
TEST=verify keycode is correct in `evtest`
BRANCH=none

Signed-off-by: Ting Shen <phoenixshen@google.com>
Change-Id: Ide3289fd2c1bb8859a74e97134e6113441cfb967
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2508848
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Commit-Queue: Ting Shen <phoenixshen@chromium.org>
Tested-by: Ting Shen <phoenixshen@chromium.org>
2020-11-10 07:56:46 +00:00
Yuval Peress 25ae7edffc Add chip-specific shim along with i2c module
This change accomplishes 2 things:
1. It refactors the zephyr/shim directory to structure around
   chip specific compilation. In this example, we're focusing
   on npcx7m6fb which is used in volteer but others can be
   added easily.
2. It shims the common/i2c_master.c by providing an alternate
   implementation of i2c_xfer_unlocked that calls down to the
   Zephyr API i2c_write_read instead of the chip specific
   i2c_xfer_no_retry or chip_i2c_xfer_with_notify.

   The shim layer is made possible by the addition of
   zephyr/shim/include/i2c/i2c.h which adds a functions that
   needs to be implemented per chip (npcx7 family in this case)
   and allows us to map the current port int which is defined
   in chip/${CHIP}/registers.h (chip/npcx/registers-npcx7.h in
   our case). This function (i2c_get_device_for_port) maps the
   platform/ec port int to a const struct device * which is
   needed in the Zephyr I2C APIs.

BRANCH=none
BUG=b:171302975
TEST=clean_build.sh projects/experimental/volteer/ and make BOARD=eve

Signed-off-by: Yuval Peress <peress@chromium.org>
Change-Id: I210f4758337bf384d0d6f103eef8b89126887d11
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2504285
Reviewed-by: Simon Glass <sjg@chromium.org>
Commit-Queue: Simon Glass <sjg@chromium.org>
2020-11-08 03:41:10 +00:00
Diana Z e609f07eef COIL: Rename CONFIG_I2C_PERIPHERAL
Rename CONFIG_I2C_PERIPHERAL and related comments.

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

Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: I3f148e976f3a4d6a1dc6c58686368c056290d5d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2518660
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2020-11-05 01:28:40 +00:00
Diana Z 899412aaf6 COIL: Rename CONFIG_I2C_CONTROLLER
Rename CONFIG_I2C_CONTROLLER and related comments.

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

Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: Ied6a1829bf54a5c9a32e6772982a4b8aa31aaf23
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2518659
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2020-11-05 01:28:37 +00:00
Diana Z 1044b2dfac COIL: Rename local i2c variables in stm32f4
Rename local i2c variables and related comments to the new
controller/peripheral naming scheme.

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

Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: Ibb6a2bdfe47824be6412d999e6c4eb0303e6b421
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2518658
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2020-11-05 01:28:35 +00:00
Diana Z 23150c06ba COIL: Rename CONFIG_BOARD_I2C_ADDR_FLAGS
Rename CONFIG_BOARD_I2C_ADDR_FLAGS and related comments.

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

Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: I45d4945b5c1fa26c72d233fb9def4d9bdee1c9c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2518657
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2020-11-05 01:28:33 +00:00
Yuval Peress 13323e77ff Replace I2C_GET_ADDR with I2C_STRIP_FLAGS
The new I2C_STRIP_FLAGS macro was added to avoid conflict with
Zephyr's macro. This CL performs the migration to that new API.

BRANCH=none
BUG=b:172067439
TEST=make runtests -j and built for various boards: eve, volteer,
     arcada_ish, atlas, hatch, kohaku, nocturne, samus, and scarlet

Change-Id: I0583b647435db96ec268f186252b367bdc4118a6
Signed-off-by: Yuval Peress <peress@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2511097
Reviewed-by: Jett Rink <jettrink@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Commit-Queue: Jett Rink <jettrink@chromium.org>
2020-11-02 19:15:23 +00:00
Dawid Niedzwiecki 7106989353 atomic: rename atomic_read_clear to atomic_clear
Rename atomic_read_clear to atomic_clear to be consistent with the rest
of the atomic functions, which return the previous value of the
variable.

BUG=b:169151160
BRANCH=none
TEST=buildall

Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com>
Change-Id: I2588971bd7687879a28ec637cf5f6c3d27d393f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2505143
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
2020-11-02 10:17:27 +00:00
Wai-Hong Tam 3ccc2b066c npcx: Explicitly disable alt-function for unused pins
Make the unused pins as GPIO and disable any alt-function.

BRANCH=None
BUG=b:169595541
TEST=make buildall -j

Change-Id: I6b7c16dd68654b38c8a12654207438315fe86c2c
Signed-off-by: Wai-Hong Tam <waihong@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2508862
Reviewed-by: CH Lin <chlin56@nuvoton.com>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
2020-10-31 02:15:41 +00:00
Diana Z c52033d763 COIL: Rename SLEEP_MASK_I2C_PERIPHERAL
Rename SLEEP_MASK_I2C_PERIPHERAL and related comments.

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

Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: Idaeefda102c603a38f128d820ed1f647069eaeea
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2511094
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2020-10-31 01:06:10 +00:00
Diana Z 63e4dcbe22 COIL: Rename CONFIG_HOSTCMD_I2C_ADDR_FLAGS
Rename for CONFIG_HOSTCMD_I2C_ADDR_FLAGS and surrounding comments.

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

Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: I49dc12753957da7baa1bb387e212d75c75e81d86
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2511093
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2020-10-31 01:06:05 +00:00
Diana Z f77cdd2fea COIL: Re-name local variables and references in i2c-stm32f0.c
Re-name i2c references to terms controller/peripheral

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

Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: I2afa76596890bd9d7e0c51cced76b0f7cc76257b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2493114
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
2020-10-31 01:06:03 +00:00
Tom Hughes 9eda976fbf chip/stm32: Fix transport detection in RO.
The FPSENSOR task only runs in RW, not RO, so
IS_ENABLED(HAS_TASK_FPSENSOR) is false in RO. As a result, we were
returning the wrong protocol information for bloonchipper boards with
UART when running in RO.

BRANCH=none
BUG=b:171370392
TEST=none
TEST=Using dragonclaw v0.2 and servo_micro:
     ./test/run_device_tests.py -t fpsensor_uart_ro
     ./test/run_device_tests.py -t fpsensor_uart_rw
     ./test/run_device_tests.py -t fpsensor_spi_ro
     ./test/run_device_tests.py -t fpsensor_spi_rw

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: Iccf801ef453a5dc6d8a21df11af41c60818781b5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2508861
Reviewed-by: Bhanu Prakash Maiya <bhanumaiya@google.com>
Reviewed-by: Yicheng Li <yichengli@chromium.org>
2020-10-30 20:27:39 +00:00
Dino Li deef4e1aa7 it83xx/adc: ADC read is successful if valid bit is set
In task_wait_event_mask(), if task woke up by an event which isn't
what we want (events |= __wait_evt(time_remaining_us, TASK_ID_IDLE)),
and timeout occurs (time_remaining_us = deadline - get_time().val).
EC will post timeout event to task even if the event we want
((eg.TASK_EVENT_ADC_DONE)) has been set.

We fix this symptom with checking data valid bit of ADC's register.
So we won't miss ADC read.

BUG=b:171731189
BRANCH=none
TEST=No ADC read error on RunInStressCountdown

Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
Change-Id: I56b301a0f58b64833ae17e2b6e789c879e48cc5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2501091
Reviewed-by: Jett Rink <jettrink@chromium.org>
Reviewed-by: Diana Z <dzigterman@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2020-10-30 04:55:21 +00:00
Diana Z 3c79b8fbb9 COIL: Re-name to TCPCI_I2C_PERIPHERAL
Boards which don't use a TCPM will define TCPCI_I2C_PERIPHERAL.

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

Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: If93e533e059888e8ad5166b29c37bc2243f46947
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2481940
Reviewed-by: Jett Rink <jettrink@chromium.org>
2020-10-28 19:14:28 +00:00
tim 50d3642d81 it83xx/spi: clean up unnecessary configuration
Rx valid length interrupt has been set as default, so the
configuration of IT83XX_SPI_RX_VALID_INT can be removed.

BUG=none
BRANCH=none
TEST=Boot to kernel on HAYATO and no error on
     the transaction of host command with EC.

Change-Id: I92ab78b3e821f566053c816f51bf609394f3b199
Signed-off-by: tim <tim2.lin@ite.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2497366
Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
2020-10-28 07:00:05 +00:00
Dino Li d7d600d94e it83xx: add support for IT81202BX and IT81302BX
This CL applies A version's configurations to B version.
They have the same HW except for new added function
(eg. SPI emulate eMMC "Alternative Boot Mode") on B version.

We can add new chip config option for B version in other CL
if needed.

BUG=none
BRANCH=none
TEST=Building asurada's EC image with selecting BX chip variant.
     Flashing the image into reworked asurada (change EC to IT81202BX)
     and boot to kernel.

Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
Change-Id: I796a622df21842998ad8f808bfa189b924710649
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2501802
Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
2020-10-28 06:00:05 +00:00
Dawid Niedzwiecki a05f7b9f46 tree: Use new atomic_* implementation
It is done as a part of porting to Zephyr.
Since the implementation of atomic functions is done for all architectures
use atomic_* instead of deprecated_atomic_*.

Sometimes there was a compilation error "discards 'volatile' qualifier"
due to dropping "volatile" in the argument of the functions, thus
some pointers casts need to be made. It shouldn't cause any issues,
because we are sure about generated asm (store operation will be
performed).

BUG=b:169151160
BRANCH=none
TEST=buildall

Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com>
Change-Id: I98f590c323c3af52035e62825e8acfa358e0805a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2478949
Tested-by: Jett Rink <jettrink@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
2020-10-27 09:35:49 +00:00
Wai-Hong Tam 9973e58604 npcx: Configure unused GPIOs as INPUT with PU to save power
According to Power Consumption Investigation Guide, by Nuvoton, setting
the disconnected/unused pins as input with an internal pull-up gets
better power number. Do it automically for all GPIOs defined through
the UNUSED() macro.

BRANCH=None
BUG=b:169595541
TEST=make buildall -j

Change-Id: I929c139e73d8253c79e0b9a3445217a300dc98cb
Signed-off-by: Wai-Hong Tam <waihong@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2488214
Reviewed-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2020-10-22 07:06:01 +00:00
Ruibin Chang a6b7fb3d3d it83xx/espi: re-enable port80 after espi reset
Our HW design is that Vcc on->off transition will disable port80.
Once we reset espi module, then Vcc has on -> off transition and
this cause port80 disabled. I re-enable port80 after espi reset.

BUG=b:163100497
BRANCH=none
TEST=On drawcia, check port80 values and SPCTRL1 register (= 0xc2)
after "reboot" and "power on" reset

Signed-off-by: Ruibin Chang <ruibin.chang@ite.com.tw>
Change-Id: I2c6b0542cf08bee324e38886d1ce5909cd0b3776
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2479442
Tested-by: Ruibin Chang <Ruibin.Chang@ite.com.tw>
Tested-by: Divagar Mohandass <divagar.mohandass@intel.com>
Reviewed-by: Diana Z <dzigterman@chromium.org>
2020-10-16 19:25:37 +00:00
tim 0064badd26 it83xx/flash: handle AP's command of get status while erasing
This change makes EC handle get status command from AP while erasing.

BUG=b:168869304
BRANCH=none
TEST=Software sync works on Asurada.

Signed-off-by: tim <tim2.lin@ite.corp-partner.google.com>
Change-Id: I261ce1a82c89b4f8917e8156aa142e2ea327c368
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2465605
Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
2020-10-14 10:31:15 +00:00
Dino Li 19d0edf872 it83xx/keyboard: support keyboard_raw_is_input_low()
Support keyboard_raw_is_input_low() for enable CONFIG_KEYBOARD_FACTORY_TEST.

BUG=b:170699805
BRANCH=none
TEST=The function works as expected.

Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
Change-Id: I30ff914bdaf3fe47949227fa0a5cee327408913e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2463037
Tested-by: Ruibin Chang <Ruibin.Chang@ite.com.tw>
Reviewed-by: Diana Z <dzigterman@chromium.org>
2020-10-14 06:10:49 +00:00
Ruibin Chang a57076ce03 it83xx/KB/GPIO: support keyboard GPIO output mode
These pins could be used as GPIO input, and they can
be configured as GPIO output as well. So we made this
patch to support it.

BRANCH=none
BUG=b:170699805
TEST=On board it8xxx2_evb
     1.GPIO only: set/get level properly at GPIO mode.
     2.GPIO and alternate mix: KSI input low and KSO GPIO level
       not change
     On board reef_it8320
     1.keyboard scan function still work fine.

Change-Id: I2098812649f2e3ee9a8718d0d75e541ce3f14338
Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
Signed-off-by: Ruibin Chang <ruibin.chang@ite.com.tw>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2182128
Tested-by: Ruibin Chang <Ruibin.Chang@ite.com.tw>
Reviewed-by: Diana Z <dzigterman@chromium.org>
Commit-Queue: Ruibin Chang <Ruibin.Chang@ite.com.tw>
2020-10-14 06:10:48 +00:00
CHLin 0f12014ad5 npcx9: support SHA256 hardware accelerator
There is the hardware accelerator for SHA computation inside npcx9. This
CL wraps the Nuvoton SHA library APIs (which are in the ROM) to Chromium
EC's SHA256_* APIs to speed up the SHA256 computation.
With the help of the hardware accelerator, the hash computation runs
several times faster than the software method (see b:155771688 for more
detailed evaluation data.) Also, we can gain ~840 bytes of code size.

BRANCH=none
BUG=b:165777478
BUG=b:155771688
TEST=pass "make buildall"
TEST=flash the same RW image; #define/#undef CONFIG_SHA256_HW_ACCELERATE
; verify the RW hash value is the same in the console message.
TEST=with the following test CL, move test patterns in test/sha256.c
to board/npcx9_evb/test_sha256.c; pass all test patterns.

Signed-off-by: CHLin <CHLin56@nuvoton.com>
Change-Id: I45ca609889bd73573d67d15f3e561614201e60f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2455021
Tested-by: CH Lin <chlin56@nuvoton.com>
Auto-Submit: CH Lin <chlin56@nuvoton.com>
Reviewed-by: caveh jalali <caveh@chromium.org>
Commit-Queue: caveh jalali <caveh@chromium.org>
2020-10-13 11:29:46 +00:00
Dino Li 7ae6bda8bd it83xx/flash: add reload watchdog to prevent the reset
If requested erase size is too large at one time on KGD flash,
we need to reload watchdog to prevent the reset.

BUG=b:168869304
BRANCH=none
TEST=ectool flasherase 0x80000 0x80000

Change-Id: I9a34b8132e17e4ee0a90874d6341ac1e4a3b60c1
Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
Signed-off-by: tim <tim2.lin@ite.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2438072
Reviewed-by: Jett Rink <jettrink@chromium.org>
2020-10-13 05:21:46 +00:00
Tom Hughes 19260e5851 chip/stm32: Only use a mutex when not in interrupt context
Mutexes shouldn't be used in interrupt context. An ASSERT was added in
mutex_lock to verify this commit
e695620911.

There are cases where bkpdata_write can be called from an interrupt
context, such as this stack trace that occurs when adding entropy from
RO on dartmonkey/icetower (stack captured with Segger J-Trace):

> rollbackaddent 1234

panic_assert_fail panic_output.c:132
mutex_lock task.c:889
bkpdata_write bkpdata.c:35
bkpdata_write bkpdata.c:24
bkpdata_write_reset_flags bkpdata.c:86
chip_save_reset_flags system.c:366
system_reset system.c:366
panic_reboot panic_output.c:114
report_panic panic.c:339
exception_panic panic.c:350

Validation of the fix was checked with the "rollback_region1" unit test,
which failed before the change and works after.

BRANCH=none
BUG=b:170147314
TEST=./test/run_device_tests.py -b dartmonkey -t rollback_region1

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: Ie5509ec024e94b48c786199ccbb81ce93fafe547
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2462545
Reviewed-by: Edward Hill <ecgh@chromium.org>
2020-10-09 23:34:52 +00:00