Commit Graph

320 Commits

Author SHA1 Message Date
Nicolas Boichat
76927bdc5a stm32/usb: Add HOOK_USB_PM_CHANGE, called when USB is resumed/suspended
In particular, this will allow touchpad driver and keyboard matrix
scanning to be powered off/disabled when the USB interface is
disabled without setting the remote wake feature
(USB_REQ_FEATURE_DEVICE_REMOTE_WAKEUP), as events would be
ignored anyway.

BRANCH=none
BUG=b:72683995
TEST=With next CLs, touchpad and keyboard matrix scanning are disabled
     when lid is closed.

Change-Id: I3750bfaf8c31cde075adf9da4fef39753b8981c5
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/897067
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-02-02 10:17:30 -08:00
Shawn Nematbakhsh
8d29b3dae7 stm32: Fix bkpdata accounting
stm32f0 has 20 bytes (not 20 words) of VBAT-backed RAM. Make more
efficient use of our limited storage to prevent trying to use storage
that doesn't exist.

BUG=b:71333840
BRANCH=None
TEST=Negotiate PD, run "reboot" on scarlet EC console, verify reset path
is taken in pd_partner_port_reset().

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ie4c303b74a1b82b84ec971cdcc19c2b21a0032e7
Reviewed-on: https://chromium-review.googlesource.com/885461
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-01-30 14:54:17 -08:00
Vadim Bendebury
57bb4ddf41 cr50: fix annoying LD warnings
The compiler marks data put into the TPM2_common.bss section as
PROGBITS, which the linker does not like. Changing the section name
prevents the marking and keeps linker happy.

BRANCH=cr50
BUG=chromium:799385
TEST=verified that local_state is still in where it belongs:
    $ egrep '(local_state|__bss_libtpm2)' build/cr50/RW/ec.RW.smap
    00010400 B __bss_libtpm2_start
    00015d0c b local_state
    00015d18 B __bss_libtpm2_end

Change-Id: I48f7d2cb08c7ccb2ef3b3159eaf4d66e2b8720b4
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/852793
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-05 14:28:47 -08:00
Philip Chen
0037fb8dfc system: Log PC and task id on watchdog
For debug, in common code let's log the watchdog PC
and task id as our SW panic params.

BUG=chromium:790006
BRANCH=none
TEST=manually test scarlet rev2 from a1-a3, b1-b2:

(a1) Add 'while(1);' in button ISR
(a2) Boot and press the button
(a3) When watchdog is triggeried, check with 'panicinfo'
that saved R5 is the PC for button ISR.

(b1) 'crash watchdog' in EC console
(b2) Check with 'panicinfo' that CONSOLE task id is saved in
EXCEPTION and PC is saved in R5.

Change-Id: I64d2fcf594dd24b0951e002ab8e80ebcac2d1def
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/803618
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-12-11 15:16:23 -08:00
Dino Li
0b1cea4aff nds32: enable GCC LTO
- We have more flash space to use with nds32 toolchain GCC6.3.0,
  so we enable a few console commands that were disabled previously.
  And we also enable LTO to reduce the size of FW image.

- Put "__wait_evt" function into ram_code section to
  fill the gap of flash and improving performance of code-fetch.

BUG=none
BRANCH=none
TEST=boot to kernel on reef_it8320.

Change-Id: I3b745ff80a57ef1163794864c39c22f7e1f86634
Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
Reviewed-on: https://chromium-review.googlesource.com/788712
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-11-30 07:09:47 -08:00
Gwendal Grignou
2590ce9538 common: Add software CTZ implementation when needeed
CTZ - Count Trailing Zero - is not implemented in hardware on cortex0 or
nds32.

Used in ST sensor drivers.

BUG=none
BRANCH=none
TEST=compile

Change-Id: I2d62fd60f05169189b24ba2a3308bec69ed9de9c
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/767609
Commit-Ready: Ely Vazquez <nadia198877@gmail.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-11-16 23:32:11 -08:00
Dino Li
2bb1811f07 it83xx: add espi module
Add espi control module for it83xx.

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

BRANCH=none
BUG=none
TEST=1. it8390+Intel SKL-Y RVP3 and boot to shell.
     2. console command "kbpress 1 4" to test keyboard data.
     (board code for espi module test on CL:392587)

Change-Id: I1b32bd16f7e01abf07b9c9a68ebef2399cc9828d
Reviewed-on: https://chromium-review.googlesource.com/394471
Commit-Ready: Dino Li <Dino.Li@ite.com.tw>
Tested-by: Dino Li <Dino.Li@ite.com.tw>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-11-14 21:52:39 -08:00
Shawn Nematbakhsh
b6991dd96d cortex-m: mpu: Support unaligned regions and protect code RAM
Support protection of regions that aren't aligned to a power of 2 by
using two MPU entries, and taking advantage of the sub-region feature.
Also protect code RAM from being overwritten, on parts that use external
storage.

BUG=chromium:782244
BRANCH=None
TEST=On kevin, call:
mpu_protect_data_ram();
mpu_protect_code_ram();
mpu_enable();
Verify that first call results in the following update_region params:
addr: 0x200c2000 size: 0xc01d
Decoded: Protect 24K region
Verify that second call results in the following params:
addr: 0x100a8000 size: 0xc021
Decoded: Protect 96K region
addr: 0x100c0000 size: 0xf01b
Decoded: Protect remaining 8K region
Also verify that writes to beginning and end of code ram region trigger
data access violation after enabling protection.
Also verify that sysjump fails.

Change-Id: Ieb7a4ec3a089e8a2d29f231e1e3acf2e78e560a1
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/757721
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-11-14 10:11:18 -08:00
Dino Li
e64f9b258a nds32: use coreboot-sdk as the default toolchain for local build
With this change, we can pass "make buildall" at local
after it83xx based boards were removed from skip_boards.

BRANCH=none
BUG=none
TEST=- Passed "make buildall -j"
     - CROSS_COMPILE_nds32=nds32le-cros-elf- make BOARD=it83xx_evb -j,
       build ec image by using nds32le-cros-elf toolchain.
     - make BOARD=it83xx_evb -j, coreboot-sdk is used.

Change-Id: I689b67ed50ac5c80e7526f157ba28733d7216e14
Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
Reviewed-on: https://chromium-review.googlesource.com/762807
Commit-Ready: Patrick Georgi <pgeorgi@chromium.org>
Tested-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
2017-11-10 04:45:04 -08:00
CHLin
16f4c65daf npcx: fixed the assembly code of deep idle bypass
The original assembly code of deep sleep bypass will cause build error
if both CONFIG_LOW_POWER_IDLE and CONFIG_LTO are defined when buildiing
board glkrvp/zoombini. This CL fixed it by change the bypass assembly code
from:
            asm ("push {r0-r5}\n"
                 "ldr r0, =0x100A8000\n"
                 "wfi\n"
                 "ldm r0, {r0-r5}\n"
                 "pop {r0-r5}\n"
                 "isb\n"
            );
to:
            asm ("push {r0-r5}\n"
                 "wfi\n"
                 "ldm %0, {r0-r5}\n"
                 "pop {r0-r5}\n"
                 "isb\n" :: "r" (0x100A8000)
            );

BRANCH=none
BUG=none
TEST=No build errors for "make buildall".
TEST=build zoombini/glkrvp with CONFIG_LOW_POWER_IDLE and CONFIG_LTO,
no build errors.
TEST=build npcx7_evb/npcx_evb and do stress test for deep idle->wakeup
on EVB, no symptom observed.

Change-Id: I90b13b4baf418e3f4b3234d4811e3978b6436aac
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
Signed-off-by: CHLin <CHLIN56@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/756535
Commit-Ready: CH Lin <chlin56@nuvoton.com>
Tested-by: CH Lin <chlin56@nuvoton.com>
2017-11-09 21:46:07 -08:00
li feng
9442982a9b ish: mutex_lock() fix
old_val may change value after cmpxchg, need to reset to 0 for next loop
comparison.

BUG=None
BRANCH=master
TEST=On Soraka modified for ISH board, running more than 4 hours sensor
data fetching by host command, and no problem.

Change-Id: I720230e196771071c8ba204458da6c4788d374ea
Signed-off-by: li feng <li1.feng@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/738914
Commit-Ready: Li1 Feng <li1.feng@intel.com>
Tested-by: Li1 Feng <li1.feng@intel.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-10-26 15:57:46 -07:00
Dino Li
54034c0b8a nds32: add built-in function
A built-in function (__builtin_ffs) is missing after we sync down
the source code to latest.

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

BRANCH=none
BUG=none
TEST=We use the CL:730246 to verify this change, and
     no error was received after running the test.

Change-Id: I5210f85db05650545c9924940e8b24e350b82f71
Reviewed-on: https://chromium-review.googlesource.com/730245
Commit-Ready: Dino Li <Dino.Li@ite.com.tw>
Tested-by: Dino Li <Dino.Li@ite.com.tw>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-10-26 02:33:46 -07:00
Nicolas Boichat
ab9084fd2a chip/npcx: Add support for pad-switching UART
NPCX5* only has one UART controller, which can be switched
between 2 pads. We keep the default pad for EC console,
however, we allow switching to the alternate pad for short,
infrequent, transactions. Both pads are assumed to use the
same baudrate and other line settings.

When switching pad, we first configure the new pad, then switch
off the old one, to avoid having no pad selected at a given time,
see b/65526215#c26.

Because of the added complexity of npcx_gpio2uart (and the fact
that it uses the global variable "pad" define in uart.c), we
move the implementation to uart.c (npcx_uart2gpio is also moved
for consistency).

When the pad is switched to alternate pad, characters input
and output on the EC console (default pad) would be lost. To
compensate for this, we:
 - Switch back to main pad in case of EC panic, so that output
   is shown on EC console.
 - Immediately abort current alternate pad transaction if a
   character is received on the default pad. Note, however,
   that the first character will be lost (this can be worked
   around by telling user to press enter, and have servod/FAFT
   always send 2 blank lines (instead of just one) before
   sending a command).
 - Inhibit pad switching for 500ms after receiving a character
   on default pad. Assuming a reasonable typing speed, this
   should allow developers to type console commands relatively
   comfortably, while not starving the alternate pad communication
   for too long.

The logic above could be simplified significantly by implementing
software flow control (XON/XOFF, see b/67026316).

BRANCH=none
BUG=b:65526215
TEST=While follow-up CL that writes long 1k buffers, the following
     works fine:
     - type 'uart' in EC console
     - Read battery power consumption from servod, which "types" in
     the EC console:
     while true; do dut-control ppvar_vbat_mw; sleep 1; done
     no failure is seen.
TEST=Add this test code in uart_alt_pad_read_write, after the pad
     has been switched, and check that panic information is
     consistently printed correctly:
	{
		static int t;
		if (t++ > 20)
			t = t / ret;
	}

Change-Id: I18feed2f8ca4eb85f40389f77dac3a46315310e7
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/659458
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-10-25 03:58:50 -07:00
Vadim Bendebury
6b516eda69 tpm2: add nvmem data to the right segment
Modules in board/cr50/tpm2 are part of the TPM task, and their .bss
segment needs to be wiped out along with other TPM modules' when TPM
is reset.

The only module from this directory which has static variables is
NVMem.c. This patch groups the variables into a structure, and makes
sure that the structure is stored in the part of .bss which is zeroed
when TPM is reset.

BRANCH=none
BUG=none
TEST=verified that TPM wipeout happening during RMA reset is
     successful.

Change-Id: I5f80dc5e4f5f7cdce2d1a1ed59e0fbac354c5bf6
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/733814
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Scott Collyer <scollyer@chromium.org>
2017-10-23 22:39:02 -07:00
Shawn Nematbakhsh
0898c7a63a cleanup: Remove jtag_pre_init()
Use our newly-created chip_pre_init() for doing JTAG initialization.

BUG=chromium:747629
BRANCH=None
TEST=`make buildall -j`

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ic5771895a214a9f1aa9bd289eef576f52adf973f
Reviewed-on: https://chromium-review.googlesource.com/629676
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-09-07 15:01:05 -07:00
Mulin Chao
ebe3caeb69 npcx: bypass for CSAE issue if CONFIG_LOW_POWER_IDLE is disabled
In order to prevent keeping the CSAE bit at 1 forever impacts the eSPI
performance, the npcx driver enables host access wakeup functionality
before ec enters deep sleep or wfi. But this bypass also should be added
in __idle() of core/cortex-m/task.c if CONFIG_LOW_POWER_IDLE is
disabled.

This CL also narrows the bypass only when host interface is eSPI.

BRANCH=eve
BUG=b:64730183
TEST=No build errors for make buildall. Disable CONFIG_LOW_POWER_IDLE
functionality on poppy and use following script "count=0; while :;
do echo "--- iteration --- $count"; time flashrom -p ec -r ec.bin; sleep
1; count=$((${count}+1)); done" to test eSPI performances over 300
times. No errors occur and all tests' efficiency are the same as
removing CSAE bypass.

Change-Id: I8b6b69e37318208c185747151c06b3e6bdfd2f4e
Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/644967
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2017-09-05 02:23:00 -07:00
Randall Spangler
29d8cc67c3 Clean up CONFIG_CASE_CLOSED_DEBUG usage
CCD_CHANGE_HOOK should use CONFIG_CASE_CLOSED_DEBUG_V1.

All boards which use chip/g either use both CONFIG_USB_SERIALNO and
CONFIG_CASE_CLOSED_DEBUG or neither of them, so just depend on
CONFIG_USB_SERIALNO.

This is in preparation for making common/case_closed_debug refer only
to the usb_pd_protocol version (with mode=disabled/partial/enabled),
and cr50 will have its own version (with only enabled/disabled, and
tied more closely to CCD config).

No functionality changes.

BUG=none
BRANCH=cr50
TEST=make buildall -j; boot cr50 and see change hook called

Change-Id: I1985c8c48c1a85fed4549402a7b47b8a9cf135d7
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/648067
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-09-01 16:41:55 -07:00
Kyoung Kim
17bb1fbaa9 ISH: added UART port selection
added uart port debug selection.
in board.h, add "#define CONFIG_ISH_UART_0" for UART Port 0.
For port1, use "#define CONFIG_ISH_UART_1"

BUG=None
BRANCH=None
Test='make -j buildall'

Change-Id: I5426b1d228ac715574e2ff4f28526232d375221f
Reviewed-on: https://chromium-review.googlesource.com/566593
Commit-Ready: Kyoung Il Kim <kyoung.il.kim@intel.com>
Tested-by: Kyoung Il Kim <kyoung.il.kim@intel.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-09-01 03:04:54 -07:00
Paul Kocialkowski
e5c69151df cortex-m0: Use assembly exception handlers for task switching
The way Cortex processors handle exceptions allows writing exception
routines directly in C, as return from exception is handled by providing
a special value for the link register.

However, it is not safe to do this when doing context switching. In
particular, C handlers may push some general-purpose registers that
are used by the handler and pop them later, even when context switch
has happened in the meantime. While the processor will restore {r0-r3}
from the stack when returning from an exception, the C handler code
may push, use and pop another register, such as r4.

It turns out that GCC 4.8 would generally only use r3 in svc_handler and
pendsv_handler, but newer versions tend to use r4, thus clobbering r4
that was restored from the context switch and leading up to a fault
when r4 is used by the task code.

An occurrence of this behaviour takes place with GCC > 4.8 in __wait_evt,
where "me" is stored in r4, which gets clobbered after an exception
triggers pendsv_handler. The exception handler uses r4 internally, does
a context switch and then restores the previous value of r4, which is
not restored by the processor's internal, thus clobbering r4.
This ends up with the following assertion failure:
'tskid < TASK_ID_COUNT' in timer_cancel() at common/timer.c:137

For this reason, it is safer to have assembly routines for exception
handlers that do context switching.

BUG=chromium:631514
BRANCH=None
TEST=Build and run speedy EC with a recent GCC version

Change-Id: Ib068bc12ce2204aee3e0f563efcb94f15aa87013
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Reviewed-on: https://chromium-review.googlesource.com/362830
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-08-28 10:55:41 -07:00
li feng
dd1f41a03b core/minute-ia: add __image_size
For system using core/minute-ia, build will fail since __image_size is
not defined. If later this variable is used, should adjust its value
properly.

BUG=none
BRANCH=None
TEST=Build passed for Soarka ISH which uses core/minute-ia.

Change-Id: I8e179e0bac551a46d93ca10ba8b61b4ebade74fc
Signed-off-by: li feng <li1.feng@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/595151
Commit-Ready: Li1 Feng <li1.feng@intel.com>
Tested-by: Li1 Feng <li1.feng@intel.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-08-24 23:06:40 -07:00
Stefan Reinauer
9939855231 Fix inconsistent task function declarations
Tasks are defined inconsistently across the code base.

Signed-off-by: Stefan Reinauer <reinauer@google.com>
BRANCH=none
TEST=make buildall -j, also verify kevin boots to OS
BUG=none

Change-Id: I19a076395a9a8ee1e457e67a89d80d2f70277c97
Reviewed-on: https://chromium-review.googlesource.com/602739
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-08-08 14:56:13 -07:00
Daisuke Nojiri
5f72f0a085 npcx: Define CONFIG_DATA_RAM_SIZE
This patch defines CONFIG_DATA_RAM_SIZE, which indicates the size
of the RAM used for data, thus can be marked as non-executable.

If it's not defined, it defaults to CONFIG_RAM_SIZE. Thus, other chips
are not affected.

BUG=b:36037354
BRANCH=none
TEST=buildall. Run 'sysjump disable' on Reef and verify mpu_protect_ram
is successful.

Change-Id: I54d74fd1dabff7e1013fff2542fd02c3646803d1
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/596518
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-08-07 19:29:13 -07:00
Randall Spangler
4809c70bbe cr50: Add case closed debugging V1 configuration
This adds the CCD configuration module, and the console commands to
control it.  It is not wired up to any of the CCD capabilities; that's
coming in the next CL.

Briefly:
* CCD configuration is persistently stored in nvmem_vars.  Use ccdinfo to
  print it.
* CCD can be Locked, Unlocked (some capabilities), or Opened
  (all capabilities), using the ccdlock / ccdunlock / ccdopen commands.
* CCD config can be restricted by setting a password via ccdpass.
* Individual config capabilities can be set via ccdset.  Some of those will
  be used to gate access to things like write protect and UARTs.  Others
  affect the requirements for ccdunlock / ccdopen (for example, is physical
  presenc required).
* The entire config can be reset via ccdreset.  If only unlocked, config
  that is restricted to Opened is not reset.
* If CR50_DEV=1, ccdoops will force-reset and open the config.

See go/cr50-ccd-wp for more information.

BUG=b:62537474
BRANCH=none
TEST=manual with CR50_DEV=1 build
	gpioget # make sure GPIO_BATT_PRES_L=0

	ccdlock # lock, because CR50_DEV=1 builds start unlocked

	ccdinfo # locked, flags=0, all capabilities default
	ccdpass # access denied (we're locked)
	ccdreset # access denied
	ccdset flashap always # access denied

	ccdunlock
	ccdinfo # unlocked
	ccdpass foo
	ccdinfo # flags=2 (password set when unlocked)
	ccdset flashap always # access denied
	ccdset uartectx unlesslocked
	ccdinfo # yes, uartectx permission changed
	ccdlock

	ccdunlock # fails without password
	ccdunlock bar # wrong password
	ccdunlock foo # busy
	(wait 3 sec)
	ccdunlock foo
	ccdreset
	ccdinfo # no password, flags 0, capabilities all default

	ccdopen # requires physical presence; tap power or use 'pp'
	ccdset uartectx unlesslocked
	ccdset batterybypasspp ifopened
	ccdpass baz
	ccdinfo # password set, flag 0, ccdset changes worked

	ccdunlock
	ccdreset
	ccdinfo # uartectx back to ifopened, password still set

	ccdopen baz # still requires physical presence
	ccdset opennolongpp always
	ccdlock
	ccdopen baz # no pp required
	ccdset unlocknoshortpp unlesslocked
	ccdlock
	ccdopen baz # short pp sequence required (3 taps)
	ccdlock
	ccdunlock baz # short pp sequence required
	ccdopen baz # pp not required
	ccdset unlocknoshortpp always
	ccdlock

	testlab open # access denied
	testlab enable # access denied
	ccdunlock baz
	testlab open # access denied
	testlab enable # access denied
	ccdopen baz
	testlab enable # requires short pp
	ccdinfo # flags 1

	ccdreset
	ccdinfo # no password, flags=1, caps all default
	ccdlock
	testlab open
	ccdinfo # opened
	testlab disable # requires short pp; let it time out
	ccdinfo # still opened, flags=1

	ccdlock
	ccdoops # backdoor in CR50_DEV images to force-reset CCD
	ccdinfo # opened, flags=0, all defaults (yes, oops wipes out testlab)

	ccdreset rma
	ccdinfo # flags = 0x400000, everything but Cr50FullConsole always
	ccdreset # back to flags=0, all default

Change-Id: I24e8d8f361874671e6e94f27492ae00db919bea9
Reviewed-on: https://chromium-review.googlesource.com/569439
Commit-Ready: Randall Spangler <rspangler@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2017-07-20 15:00:40 -07:00
Patrick Georgi
1a67ac2ad6 Allow core code to request its cross compiler
Instead of having to pass in both the board and the arch used there
(which might be complicated in the light of different ECs with different
arches), allow passing in the board and a set of cross compilers.

The core/*/build.mk then pick the compiler that is responsible for them.
The current method works just the same: If you've already set
CROSS_COMPILE, no override happens. If you set neither CROSS_COMPILE nor
CROSS_COMPILE_$arch, the same default as before this CL is set.

BUG=none
BRANCH=none
TEST=emerge-{samus,kevin} chromeos-ec behave reasonably with adapted
ebuild

Change-Id: Icf1866f296412dd92ecfe134394224c49f7c3df5
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://chromium-review.googlesource.com/549344
Commit-Ready: Patrick Georgi <pgeorgi@chromium.org>
Tested-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-by: Stefan Reinauer <reinauer@google.com>
2017-07-19 05:01:02 -07:00
Nicolas Boichat
d68b1ca803 core/cortex-m0/curve25519: Remove unused variants
Remove code related to DH_SWAP_BY_POINTERS and
DH_REPLACE_LAST_THREE_LADDERSTEPS_WITH_DOUBLINGS, as they are
not really worth it (code size increase of 60/100 bytes respectively
for 1000/500 us time gain).

BRANCH=none
BUG=b:62813194
TEST=make BOARD=hammer PROJECT=x25519 TEST_BUILD=y
     ./util/flash_ec --board=hammer --image=build/hammer/x25519.bin
     EC console: runtest, taskinfo

Change-Id: If21948bb2c7c20f97ba8b321dd2688cd3d0ba74a
Reviewed-on: https://chromium-review.googlesource.com/554440
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-07-04 06:51:00 -07:00
Nicolas Boichat
edc668ea6c core/cortex-m0/curve25519: Integrate fast curve25519 implementation
- Move generic implementation to curve25519-generic.o
- Always use optimized version on cortex-m0.

- Rename .s files to .S, remove unnecessary lines in assembly files.
- Rename crypto_scalarmult_curve25519 to x25519_scalar_mult to match
  the signature provided by the generic implementation.
- Replace some handcoded memcpy with function calls
- Remove unnecessary "volatile" specifications in the code.

BRANCH=none
BUG=b:62813194
TEST=To test old implementation only:
        - Increase CONFIG_RO_SIZE to 60kb
        - Increase console stack size to 2048
     make BOARD=hammer PROJECT=x25519 TEST_BUILD=y
     ./util/flash_ec --board=hammer --image=build/hammer/x25519.bin
     EC console: runtest, taskinfo
     => Used to takes ~4'17" to run (X25519 duration 256347 us).
        1496/2048 stack size usage in CONSOLE task
     => Now takes ~1'25" to run (X25519 duration 84520 us)
        732/2048 stack size usage in CONSOLE task
TEST=In test/x25519.c, uncomment #define TEST_X25519_1M_ITERATIONS
     make BOARD=hammer PROJECT=x25519 TEST_BUILD=y
     ./util/flash_ec --board=hammer --image=build/hammer/x25519.bin
     EC console: runtest, wait ~23 hours, test passes.
TEST=- Define CONFIG_CURVE25519_CORTEXM0 (next patch)
     makes newsizes
     build/hammer/RW/ec.RW.flat shrank by 1888 bytes: (52208 to 50320)

Change-Id: Icce38d3c32f431a85ac0f951cf34456b490dc665
Reviewed-on: https://chromium-review.googlesource.com/540962
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-07-03 21:44:34 -07:00
Dino Li
52fa37a801 nds32: add software floating point library routines
We need to add a few library routines for sensor task.
Routines added are taken from nds32's library.

BRANCH=none
BUG=none
TEST=Add sensor task to reef_it8320 board.
     Test screen rotation functionality on reef_it8320.

Change-Id: I2eee33f897b38e05bddd30b16f875944259b2c0d
Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
Reviewed-on: https://chromium-review.googlesource.com/527537
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-06-23 03:14:51 -07:00
Nicolas Boichat
6d912fa841 core/cortex-m0/curve25519: Import fast curve25519 implementation
Import finely tuned curve25519 implementation from
https://munacl.cryptojedi.org/curve25519-cortexm0.shtml
(http://munacl.cryptojedi.org/data/curve25519-cortexm0-20150813.tar.bz2)
which is released in the public domain for some files, CC0 for others.

This is a plain copy (only doing a pass of dos2unix conversion
and removing trailing tabs/spaces), later patches integrate the
code with the rest of the EC code.

BRANCH=none
BUG=b:62813194
TEST=None (see next patch)

Change-Id: Ibd394d031433c31d4755a880b0e8d74b63540fbf
Reviewed-on: https://chromium-review.googlesource.com/540961
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-06-22 03:34:46 -07:00
Shawn Nematbakhsh
8a16e6483a task: Wait for HOOK_INIT completion before scheduling tasks
Until HOOK_INIT has completed, do not allow any tasks other than HOOKS
or IDLE to be scheduled. Programmers often make the assumption that
a HOOK_INIT function is guaranteed to be run before task code that depends
on it, so let's make it so.

BUG=chromium:649398
BRANCH=None
TEST=Manual on kevin, compare boot without patch:

...
[0.004 power state 0 = G3, in 0x0008] <-- from chipset task
RTC: 0x00000000 (0.00 s)
[0.004 power state 4 = G3->S5, in 0x0008]
RTC: 0x00000000 (0.00 s)
[0.005 clear MKBP fifo]
[0.006 clear MKBP fifo]
[0.006 KB init state: ... <-- from keyscan task
[0.012 SW 0x05]
[0.155 hash start 0x00020000 0x00019a38]
[0.158 HOOK_INIT DONE!]

... to boot with patch:

...
RTC: 0x58cc614c (1489789260.00 s)
[0.004 clear MKBP fifo]
[0.005 clear MKBP fifo]
[0.010 SW 0x05]
[0.155 hash start 0x00020000 0x000198e0]
[0.157 HOOK_INIT DONE!]
...

Also, verify kevin boots to OS and is generally functional through
sysjump and basic tasks, and verify elm (stm32f0 / cortex-m0) boots.

Change-Id: If56fab05ce9b9650feb93c5cfc2d084aa281e622
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/456628
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-06-19 15:33:10 -07:00
Shawn Nematbakhsh
90167c1764 math_util: Use HW instruction for int_sqrtf when available
Cortex-M4 supports a floating point square root function that takes 14
cycles to execute, which is a speed improvement over the existing binary
search, and saves flash space.

BUG=chromium:687624
BRANCH=None
TEST=On kevin, verify that both sqrtf methods (binary search vs HW
instruction) have identical results for fractional input (eg.
sqrt(15.999999) = 3), except when floating point representation of
square root rounds up to an integer. Verify identical results for all
integers [-100, 16793602). Note that 16793602 is the first integer for
which the floating point representation of sqrt rounds up to an integer.
Also verify basic motion sense functions on kevin.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I8521c9a28c958b340ca83c37342253e424df0c91
Reviewed-on: https://chromium-review.googlesource.com/537734
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-06-19 15:33:09 -07:00
Dino Li
c35fad0f2b chip: it83xx: add support for floating point unit
Because N8 CPU doesn't have floating point unit,
so we implement an extra floating point engine
(single-precision addition, subtraction, multiplication,
and division) into it8320 to improve performance of
floating point operation.

To make CPU's instruction compatible, we use register (DLMB)
to switch ALU (Arithmetic Logic Unit). eg:
Instruction 'ADD45' adds the contents of two registers then
writes the result to the source register.
But if we switch ALU to floating point operation mode,
this instruction will do a floating-point addition instead.

For the other FPU that we don't support as far,
we have to use soft float library routines of nds32.

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

BRANCH=none
BUG=none
TEST=add the following console command and test different
scenarios by changing variable a and b.

#define PRINTF_FLOAT(x)  ((int)((x) * 1000.0f))
static int it83xx_fpu_test(int argc, char **argv)
{
	volatile float a = 1.23f;
	volatile float b = 4.56f;
	volatile float c;

	c = a + b;
	ccprintf("__addsf3: (%d)\n", PRINTF_FLOAT(c));
	c = a - b;
	ccprintf("__subsf3: (%d)\n", PRINTF_FLOAT(c));
	c = a * b;
	ccprintf("__mulsf3: (%d)\n", PRINTF_FLOAT(c));
	c = a / b;
	ccprintf("__divsf3: (%d)\n", PRINTF_FLOAT(c));

	return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(fpu, it83xx_fpu_test, "", "");

Change-Id: I4fc1c08d8c2376156bec9f098491187675c4a88f
Reviewed-on: https://chromium-review.googlesource.com/427640
Commit-Ready: Dino Li <Dino.Li@ite.com.tw>
Tested-by: Dino Li <Dino.Li@ite.com.tw>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-05-29 21:49:05 -07:00
Mulin Chao
375b607761 npcx: system: Add support for npcx7 series ec
This CL implements two methods for hibernating on npcx7 ec. One is using
PSL (Power Switch Logic) circuit to cut off ec's VCC power rail. The
other is turning off the power of all ram blocks except the last code
ram block. In order to make sure hibernate utilities are located in the
last code ram block and work properly, we introduce a new section called
'after_init' in ec.lds.S.

We also moved the hibernate utilities, workarounds for sysjump and so on
which are related to chip family into system-npcx5/7.c. It should be
easier to maintain.

It also includes:
1. Add CONFIG_HIBERNATE_PSL to select which method is used on npcx7 for
   hibernating.
2. Add new flag GPIO_HIB_WAKE_HIGH to configure the active priority of
   wake-up inputs during hibernating.
3. Add DEVICE_ID for npcx796f.

BRANCH=none
BUG=none
TEST=No build errors for all boards using npcx5 series.
     Build poppy board and upload FW to platform. No issues found. Make
     sure AC_PRESENT and POWER_BUTTON_L can wake up system from
     hibernate. Passed hibernate tests no matter CONFIG_HIBERNATE_PSL is
     enabled or not on npcx796f evb.

Change-Id: I4e045ebce4120b6fabaa582ed2ec31b5335dfdc3
Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/493006
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-05-09 23:20:11 -07:00
Nicolas Boichat
629c3964a2 common: Split rwsig parts from rsa.h header
We're going to add more rwsig-related functions, and adding them
to rsa.h seems increasingly incorrect.

BRANCH=none
BUG=b:35587171
TEST=make buildall -j

Change-Id: I334c1774ce9a6ed8e219140f65ebe94d653e22d2
Reviewed-on: https://chromium-review.googlesource.com/468708
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-04-11 20:22:32 -07:00
Dino Li
75602486bb nds32: lds: compute image size at link time
Signed-off-by: Dino Li <dino.li@ite.com.tw>

BRANCH=none
BUG=b:36228568
TEST=Check '__image_size' of map file and binary size
     for both RO and RW images.

Change-Id: I43b58a199a30827293531505de30f0ddfb72b917
Reviewed-on: https://chromium-review.googlesource.com/456664
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>
2017-03-20 23:12:05 -07:00
Shawn Nematbakhsh
e025e17b33 system: Use stored size in image_data for determining image_used
Image used size is now part of the image_data struct present in all
images at a fixed offset, so use it rather than scanning from the end of
the image.

BUG=chromium:577915
TEST=Verify on kevin + lars + lars_pd that system_get_image_used() returns
the same value as the old implementation, for both RO and RW images.
BRANCH=None

Change-Id: I35f0aa87f5ab1371dbd8b132f22b9d0044358223
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/450859
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-03-16 00:11:41 -07:00
Shawn Nematbakhsh
3c4c83b8c3 version: Store image size data in version struct
Store our image size (known at build time) in our version struct (now
renamed to image_data). This will allow us to more efficiently determine
the size of an image in a follow-up CL.

Note that compatibility is broken for old ROs that do not include this
CL.

BUG=chromium:577915
TEST=Verify on kevin + lars + lars_pd that stored image size matches
output of system_get_image_used() for both RO and RW images.
BRANCH=None

Change-Id: I7b8dc3ac8cf2df3184d0701a0e0ec8032de8d81b
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/450858
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-03-16 00:11:41 -07:00
Nick Sanders
31b5ce49c6 stm32: never pad usb descriptor length
This marks decriptor length as byte accurate, by
aligning the "__usb_desc_end" label by byte rather
than short or word.

BUG=chrome-os-partner:62873
TEST=servo_v4 doesn't crash adb anymore
BRANCH=None

Change-Id: I643bae2c59e81ce0c03d9026f4a5d7933ba4c891
Reviewed-on: https://chromium-review.googlesource.com/442012
Commit-Ready: Nick Sanders <nsanders@chromium.org>
Tested-by: Nick Sanders <nsanders@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-02-23 16:02:05 -08:00
Sam Hurst
edf46467b9 cleanup: Remove charge_state_v1
All boards have been transitioned to charge_state_v2.c
So charge_state_v1.c, HOOK_CHARGE_STATE_CHANGE, and
CONFIG_CHARGER_TIMEOUT_HOURS can be removed

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

Change-Id: I3f20c5198ea75185f9894deb792575a1be31432a
Reviewed-on: https://chromium-review.googlesource.com/435467
Commit-Ready: Sam Hurst <shurst@google.com>
Tested-by: Sam Hurst <shurst@google.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-02-06 14:50:32 -08:00
Vadim Bendebury
11704ae6e9 Revert "version: Store image size data in version struct"
This is a dependency of the uderlyaing patch which breaks header
composition of g chip based boards.

This reverts commit 7cbb815732.

Change-Id: I4d94647cf5cb09fd338e5a581c956df6b5d83081
Reviewed-on: https://chromium-review.googlesource.com/435551
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Vadim Bendebury <vbendeb@chromium.org>
2017-02-01 06:36:18 +00:00
Vadim Bendebury
9fc399a0aa Revert "system: Use stored size in image_data for determining image_used"
This breaks header composition of g chip based boards.

This reverts commit 93951a491d.

Change-Id: Ia52cf1d9c56fbb588317cec73487b2c9e89b7234
Reviewed-on: https://chromium-review.googlesource.com/435550
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Vadim Bendebury <vbendeb@chromium.org>
2017-02-01 06:35:57 +00:00
Shawn Nematbakhsh
93951a491d system: Use stored size in image_data for determining image_used
Image used size is now part of the image_data struct present in all
images at a fixed offset, so use it rather than scanning from the end of
the image.

BUG=chromium:577915
TEST=Verify on kevin + lars + lars_pd that system_get_image_used() returns
the same value as the old implementation, for both RO and RW images.
BRANCH=None

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ic8db5c706d82f7ca2ded2e90129747e7fbefdb38
Reviewed-on: https://chromium-review.googlesource.com/427959
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-01-30 16:48:41 -08:00
Shawn Nematbakhsh
7cbb815732 version: Store image size data in version struct
Store our image size (known at build time) in our version struct (now
renamed to image_data). This will allow us to more efficiently determine
the size of an image in a follow-up CL.

Note that compatibility is broken for old ROs that do not include this
CL.

BUG=chromium:577915
TEST=Verify on kevin + lars + lars_pd that stored image size matches
output of system_get_image_used() for both RO and RW images.
BRANCH=None

Change-Id: I49ea5fc27a7f11f66daba485a87d0dfe7d0c770f
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/427408
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-01-30 16:48:40 -08:00
Dino Li
6de8d02fa8 nds32: Add fabsf and sqrtf function
The magnetometer online calibration requires these two
functions and taken from newlib.

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

BRANCH=none
BUG=none
TEST=fabsf():
fabsf(1.23) = 1.23
fabsf(-1.23) = 1.23

sqrtf():
sqrtf(4.56) = 2.135
sqrtf(0.123) = 0.350
sqrtf(-0.123) = an exception is triggered.

Change-Id: I808ca7f1bd03c6d6c1b32861ede4ecbfeeaa3da6
Reviewed-on: https://chromium-review.googlesource.com/429730
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>
2017-01-18 22:50:54 -08:00
Kyoung Kim
166d7a72df ISH: Added UART Rx/Tx interrupt mode
Added UART Tx/Rx interrupt mode related code.

BUG=None
BRANCH=None
TEST=On ISH enabled Reef board, check if Tx message is working
and tested Rx input from console with console command.

Change-Id: I5067304dc74abc29bbbea983b22db3e193e36e6b
Signed-off-by: Kyoung Kim <kyoung.il.kim@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/424322
Commit-Ready: Kyoung Il Kim <kyoung.il.kim@intel.com>
Tested-by: Kyoung Il Kim <kyoung.il.kim@intel.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Kyoung Il Kim <kyoung.il.kim@intel.com>
2017-01-11 14:46:29 -08:00
Kyoung Kim
1765faf803 minute-ia: fix floating point inline assembly
change inline assembly for fsqrt and fabs

BUG=none
BRANCH=None
TEST=`make buildall -j`
1. Compare sqareroot(2) from calculator and from sqrtf(2.0f) by multiplying
   1.0 x 10E8 for both values to convert int32_t and check the difference.
2. read timestampt before and after 'sqrtf()' and calculate execution
   time.

Change-Id: I62694d8b084a3a74040dc298354b4fd685e77729
Signed-off-by: Kyoung Kim <kyoung.il.kim@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/404927
Commit-Ready: Kyoung Il Kim <kyoung.il.kim@intel.com>
Tested-by: Kyoung Il Kim <kyoung.il.kim@intel.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Kyoung Il Kim <kyoung.il.kim@intel.com>
2017-01-09 23:47:24 -08:00
Sam Hurst
a7bf207add iec: Improve efficiency of host command dispatcher
Use binary search in host command lookup dispatcher

BUG=chromium:570895
TEST=manual testing on kevin
      - Kevin boots
      - ectool hello
      make buildall -j
      Verify *.smap hcmds section is sorted:

      BOARD with host commands and private host commands
      0004d0ec R __hcmds
      0004d0ec R __host_cmd_0x00000x0000
      0004d0f8 R __host_cmd_0x00000x0001
      0004d104 R __host_cmd_0x00000x0002
      0004d110 R __host_cmd_0x00000x0003
      0004d11c R __host_cmd_0x00000x0004
      0004d128 R __host_cmd_0x00000x0005
      0004d134 R __host_cmd_0x00000x0007
      0004d140 R __host_cmd_0x00000x0008
      0004d14c R __host_cmd_0x00000x000a
      0004d158 R __host_cmd_0x00000x000d
      0004d164 R __host_cmd_0x00000x0010
      0004d170 R __host_cmd_0x00000x0011
      0004d17c R __host_cmd_0x00000x0012
      0004d188 R __host_cmd_0x00000x0013
      0004d194 R __host_cmd_0x00000x0015
      0004d1a0 R __host_cmd_0x00000x0016
      0004d1ac R __host_cmd_0x00000x0017
      0004d1b8 R __host_cmd_0x00000x0087
      0004d1c4 R __host_cmd_0x00000x008c
      0004d1d0 R __host_cmd_0x00000x008f
      0004d1dc R __host_cmd_0x00000x0092
      0004d1e8 R __host_cmd_0x00000x0093
      0004d1f4 R __host_cmd_0x00000x0097
      0004d200 R __host_cmd_0x00000x0098
      0004d20c R __host_cmd_0x00000x00b6
      0004d218 R __host_cmd_0x00000x00d2
      0004d224 R __host_cmd_0x00000x00d3
      0004d230 R __host_cmd_0x3E000x0000
      0004d23c R __host_cmd_0x3E000x0002
      0004d248 R __evt_src_EC_MKBP_EVENT_HOST_EVENT
      0004d248 R __hcmds_end

      BOARD with host commands only
      100bc888 R __hcmds
      100bc888 R __host_cmd_0x00000x0000
      100bc894 R __host_cmd_0x00000x0001
      100bc8a0 R __host_cmd_0x00000x0002
      100bc8ac R __host_cmd_0x00000x0003
      100bc8b8 R __host_cmd_0x00000x0004
      100bc8c4 R __host_cmd_0x00000x0005
      100bc8d0 R __host_cmd_0x00000x0006
      100bc8dc R __host_cmd_0x00000x0007
      100bc8e8 R __host_cmd_0x00000x0008
      100bc8f4 R __host_cmd_0x00000x0009
      100bc900 R __host_cmd_0x00000x000a
      100bc90c R __host_cmd_0x00000x000b
      100bc918 R __host_cmd_0x00000x000d
      100bc924 R __host_cmd_0x00000x0010
      100bc930 R __host_cmd_0x00000x0011
      100bc93c R __host_cmd_0x00000x0012
      100bc948 R __host_cmd_0x00000x0013
      100bc954 R __host_cmd_0x00000x0015
      100bc960 R __host_cmd_0x00000x0016
      100bc96c R __host_cmd_0x00000x0017
      100bc978 R __host_cmd_0x00000x0025
      100bc984 R __host_cmd_0x00000x0026
      100bc990 R __host_cmd_0x00000x0029
      100bc99c R __host_cmd_0x00000x002a
      100bc9a8 R __host_cmd_0x00000x002b
      100bc9b4 R __host_cmd_0x00000x002c
      100bc9c0 R __host_cmd_0x00000x0044
      100bc9cc R __host_cmd_0x00000x0045
      100bc9d8 R __host_cmd_0x00000x0046
      100bc9e4 R __host_cmd_0x00000x0047
      100bc9f0 R __host_cmd_0x00000x0061
      100bc9fc R __host_cmd_0x00000x0062
      100bca08 R __host_cmd_0x00000x0064
      100bca14 R __host_cmd_0x00000x0065
      100bca20 R __host_cmd_0x00000x0067
      100bca2c R __host_cmd_0x00000x0087
      100bca38 R __host_cmd_0x00000x008c
      100bca44 R __host_cmd_0x00000x008d
      100bca50 R __host_cmd_0x00000x008f
      100bca5c R __host_cmd_0x00000x0092
      100bca68 R __host_cmd_0x00000x0093
      100bca74 R __host_cmd_0x00000x0096
      100bca80 R __host_cmd_0x00000x0097
      100bca8c R __host_cmd_0x00000x0098
      100bca98 R __host_cmd_0x00000x0099
      100bcaa4 R __host_cmd_0x00000x009e
      100bcab0 R __host_cmd_0x00000x00a0
      100bcabc R __host_cmd_0x00000x00a1
      100bcac8 R __host_cmd_0x00000x00a8
      100bcad4 R __host_cmd_0x00000x00a9
      100bcae0 R __host_cmd_0x00000x00b6
      100bcaec R __host_cmd_0x00000x00b7
      100bcaf8 R __host_cmd_0x00000x00d2
      100bcb04 R __host_cmd_0x00000x00d3
      100bcb10 R __host_cmd_0x00000x00db
      100bcb1c R __host_cmd_0x00000x0101
      100bcb28 R __host_cmd_0x00000x0102
      100bcb34 R __host_cmd_0x00000x0103
      100bcb40 R __host_cmd_0x00000x0104
      100bcb4c R __host_cmd_0x00000x0110
      100bcb58 R __host_cmd_0x00000x0111
      100bcb64 R __host_cmd_0x00000x0112
      100bcb70 R __host_cmd_0x00000x0113
      100bcb7c R __host_cmd_0x00000x0114
      100bcb88 R __host_cmd_0x00000x0115
      100bcb94 R __host_cmd_0x00000x0116
      100bcba0 R __host_cmd_0x00000x0117
      100bcbac R __host_cmd_0x00000x0118
      100bcbb8 R __host_cmd_0x00000x011a
      100bcbc4 R __evt_src_EC_MKBP_EVENT_KEY_MATRIX
      100bcbc4 R __hcmds_end
BRANCH=none

Change-Id: I5d13d2a7fe7fa9a0fbeed43177cc612f572a58bb
Reviewed-on: https://chromium-review.googlesource.com/419702
Commit-Ready: Sam Hurst <shurst@google.com>
Tested-by: Sam Hurst <shurst@google.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-01-06 11:10:03 -08:00
Dino Li
c6928bce0b nds32: lds: reduce gap of flash
- Before the change was made, the "__ro_end" was at 00013520h.
  We change to 00012760h.
- Rename "CONFIG_IT83XX_ILM_BLOCK_SIZE" to "IT83XX_ILM_BLOCK_SIZE"
  this is because we don't support reconfiguration at board-level.
- Put some task functions into "__ram_code" section to
  fill the gap and improving performance of code-fetch.

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

BRANCH=none
BUG=none
TEST=console commands: flasherase, flashwrite, and flashread.

Change-Id: I2f2906a2a0b6971aadd00120c282801161447808
Reviewed-on: https://chromium-review.googlesource.com/424248
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>
2017-01-05 23:47:15 -08:00
Mulin Chao
266b36d54b core: Fix bug will cause tasks sleep forever by mutex_unlock in task.c.
If there's a task switching occurred between loading waiter and
unlocking the lock, the task with higher priority won't wake up since
the local variable, waiter, doesn't contain its ID bit before task
switching. In this situation, the higher priority task only can be
awakened when the other tasks execute mutex_unlock() again.

But consider the following conditions: (For example, the driver of
charger bd9995x.)
1. There are more than one mutex for the usage path of i2c port.
2. There are more than one task access this usage path of i2c port and
   one of these tasks, task A, met the situation above.
3. The other tasks have no chance to execute mutex_unlock() of i2c since
   the task A still occupied the mutex of charger.

All the tasks used the same i2c port or the other hardware will sleep
forever. This CL makes loading waiter and unlocking the lock as atomic
to solve this issue.

BRANCH=none
BUG=chrome-os-partner:60617
TEST=make BOARD=snappy; make BOARD=oak; Executed charger factory test on
4 units of snappy for 3 days and no symptom occurred.

Change-Id: Id976fc47955b33ca83bb2182b197d9f2781c341b
Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/423285
Commit-Ready: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-01-05 11:01:54 -08:00
Dino Li
38282956e0 nds32: pre-fix for the latest official toolchain
We use the latest nde32 official toolchain to verify the bug of
GP-related instruction was fixed (we can remove "-mno-gp-direct" flag to
save code space), and code optimization.

We got some error on official toolchain, so we fix them as well:
- "break" instead of "trap".
  N8 CPU does not support "trap" instruction to generate an unconditional
  trap exception, but no error occurred while compiling by using current
  GCC toolchain (this will trigger a reserved instruction exception,
  so "ASSERT()" still work).
  We use "break" to generate a exception in this change.

- "li" instead of "la".
  To fix the error: "Error: la must use with symbol".

Also fix:
- The "_bss_start" has to be word-aligned because we use "lwi" instruction
  to load a word from the memory into the general register.

BRANCH=none
BUG=none
TEST=1. console command "crash assert".
     2. check registers settings: f02030h, f0203eh, and f02044h.

Change-Id: I33404a1d60eeebfa135bf43d3a7d5e73ab35c678
Reviewed-on: https://chromium-review.googlesource.com/422608
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>
2016-12-20 21:55:54 -08:00
Vadim Bendebury
b3a9852122 Revert "ec: Improve efficiency of host command dispatcher"
This reverts commit c459c8278e 
as the fix is not straightforwad, some host command codes in 
private repos are expressed using C preprecessor which 
breaks the assumption of this patch that all host commands 
are expressed as four digit hex numbers.

Change-Id: I922de9ae8dbab6eef048463c5c09b1f338152083
Reviewed-on: https://chromium-review.googlesource.com/414492
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Vadim Bendebury <vbendeb@chromium.org>
2016-11-26 01:29:24 +00:00