Commit Graph

253 Commits

Author SHA1 Message Date
Shawn Nematbakhsh
0e532c6044 cleanup: Remove SHIFT_CODE_FOR_TEST handling
SHIFT_CODE_FOR_TEST images were used for an old FAFT test but is no
longer in use today.

BUG=chromium:616806
BRANCH=None
TEST=`make buildall -j`
CQ-DEPEND=CL:349281

Change-Id: I1b4e8c2560e2a7ff507cf2275dbbbdabf435866b
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/349272
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Tom Tam <waihong@google.com>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-06-03 03:00:08 -07:00
Stefan Reinauer
b5c56aba6f core: cortex-m0: Fix task routine prototypes
The task routines are void func(void), not int func(void *).

BUG=none
BRANCH=none
TEST=compile tested on chell
Signed-off-by: Stefan Reinauer <reinauer@chromium.org>

Change-Id: I599ff2433d821bfb446fbb4f84a803c6feffa0b3
Reviewed-on: https://chromium-review.googlesource.com/343213
Commit-Ready: Stefan Reinauer <reinauer@chromium.org>
Tested-by: Stefan Reinauer <reinauer@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-06-03 03:00:06 -07:00
Dino Li
f817140c3e chip: it83xx: Optimize interrupt usage of LPC access
LPC access interrupt only enabled when EC entering deep doze mode. This
will reduce interrupt of LPC access. Also, this interrupt is always
enabled for LPC platform to support "CONFIG_LOW_POWER_S0".

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

BRANCH=none
BUG=none
TEST=Tested ectool command 'version' x 10000.

Change-Id: I9053c4018b38a8a852c3c6254e1fcde625f3fa3a
Reviewed-on: https://chromium-review.googlesource.com/336112
Commit-Ready: Dino Li <dino0303@gmail.com>
Tested-by: Dino Li <dino0303@gmail.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-05-18 19:44:09 -07:00
Anton Staaf
95858f385c Deferred: Remove hard coded number of deferreds
Previously the maximum number of deferred routines was specified by the
the default maximum number of deferred routines you had to override
this, and if you wanted fewer, you still payed the price of having the
defer_until array statically allocated to be the maximum size.

This change removes that define and instead creates the RAM state of
the deferred routine (the time to wait until to call the deferred) when
the deferred is declared.

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

BRANCH=None
BUG=None
TEST=make buildall -j
     manually test on discovery-stm32f072

Change-Id: Id3db84ee1795226b7818c57f68c1f637567831dc
Reviewed-on: https://chromium-review.googlesource.com/335597
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-04-19 12:23:52 -07:00
Kevin K Wong
1102e46ecf core: fix unaligned access
without this, there could be unaligned access of __flash_lpfw_start
variable in system_hibernate function which causes exception.

BUG=none
BRANCH=none
TEST=make buildall, able to enter/exit EC hibernate

Change-Id: I6c0400fd88f3b815a42a70c2983a8f8ecd79b398
Signed-off-by: Divya Sasidharan <divya.s.sasidharan@intel.com>
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/331653
Reviewed-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-03-11 15:17:28 -08:00
Patrick Georgi
e7b5e7b050 core/*/ec.lds.S: quote paths containing OUTDIR
If OUTDIR brings in a "@", the build breaks because that delimits the
path, leading to invalid file names.
This can happen (and happened) when building on a Jenkins CI instance
which uses jobname@number as path for parallel checkouts on a
single build node.

BRANCH=none
BUG=none
TEST=build with make out=foo@bar ... failed and works now.

Change-Id: Id0594f0d7312419110091443755ec11b5f8ee2d8
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://chromium-review.googlesource.com/327110
Commit-Ready: Patrick Georgi <pgeorgi@chromium.org>
Tested-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-by: Martin Roth <martinroth@chromium.org>
2016-02-10 12:44:15 -08:00
Mulin Chao
f700e3bb0e nuc: Add support for CONFIG_LOW_POWER_S0.
To get better power consumption in S0, we add FW support for
CONFIG_LOW_POWER_S0.

Before entering deep idle in S0, we must enable Host interrupt to wake up
EC if it needs to service LPC bus.

This version also add a new bit of sleep_mask (SLEEP_MASK_FAN) in system.h
to prevent EC enter deep idle if fan's duty isn't zero. Normally, the freq of
PWM fan is 25 kHz. It means we must select apb2 clock as the source clock of
PWM fan. Or fan would stop when ec enters deep idle because of no PWM signal.

In hwtimer.c, we reset the preload counter to maximum value in ITEI32's ISR
since preload counter is changed by __hw_clock_source_set all the time.
We also found there're no event set if it's deadline is over 32 bits but
current source clock isn't. To prevent ec doesn't wake-up in deep-idle even if
ITIM32 expires, FW set an event for ITIM32 after process_timers().

Modified sources:
1. wheatley/board.h: Add CONFIG_LOW_POWER_S0 definition.
2. clock.c: Enable Host interrupt for LPC.
3. clock.c: Disable LP_WK_CTL for better power consumption.
4. gpio.c: Add ISR for Host interrupt.
5. uart.c: Introduce bit 6 of USTAT to make sure transmitting is completed.
6. register.h: Add uart_clear_pending_wakeup function.
7. hwtimer.c: Fixed watchdog issue when ITIM32 is closed to overflow.
8. fan.c: Enable deep sleep if duty cycle is zero.
9. include/system.h: Add SLEEP_MASK_FAN for fan control loop.
10. core/cortex-m/task.c: Add "isb" to flash the garbage data in the
    instruction pipeline.

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

Change-Id: Ibe3630d0d68cf3f32206adb2afa1b5958916a2be
Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/324651
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-02-06 01:57:58 -08:00
Dino Li
a313fc9b1a chip: it83xx: fix EC interrupt vector registers issue
We have a limitation for EC interrupt vector registers.
System may read incorrect interrupt number in ISR so we need to add
a workaround to prevent it.

The following is a example that got incorrect interrupt number:
1. REG IVCTx = 0x10. (no interrupt pending)
2. EC INT6 interrupt occurs (IVCTx = 0x16) and jump to ISR.
3. Read interrupt vector register to determine interrupt number.
4. Higher priority interrupt of same interrupt group occurs
   (for example: INT134, IVCTx = 0x96) while the system is reading the
   interrupt vector register for EC INT6, we may end up with an incorrect
   interrupt number between 0x16 and 0x96.

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

BRANCH=none
BUG=none
TEST=1. EC interrupts work normally: WUI (GPIO interrupt), timer, uart,
        LPC, I2C, and PECI.
     2. Console command 'taskinfo'.

Change-Id: I54e61f417ad506eb3b4cd5d0652f64eed9a28a17
Reviewed-on: https://chromium-review.googlesource.com/322097
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-01-28 00:02:03 -08:00
Duncan Laurie
97713dba84 ec: Add a chipset reset hook
There are hooks for chipset power sequencing but not one to indicate
that the system has reset at runtime.  Add a hook for this and
implement for lm4 and mec1322.  The hook is notified on any platform
reset, including those that happen on the way into S3/S5 state.

There is a new config variable added because the hook is notified in
the interrupt handler and needs a deferrable function that needs to
be added to every board.

BUG=chrome-os-partner:46049
BRANCH=none
TEST=tested on glados and samus

Change-Id: I3be639414e18586344e0ec84632a50dfc1df586b
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/315221
Commit-Ready: Aaron Durbin <adurbin@chromium.org>
Tested-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-01-25 21:46:48 -08:00
Dino Li
0c8a1b8d39 core: nds32: add task_wait_event_mask() function to nds32 core
[task]
1. Copy task_wait_event_mask() function of cortex-m0.
[system]
2. Include host_command.h for host_command_pd_request_hibernate().
[i2c]
3. Update i2c handler to use task_wait_event_mask.

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

BRANCH=none
BUG=chromium:435611,chromium:435612
TEST=1. console commands: i2cscan, i2cxfer, and battery.

Change-Id: If5bb4407460d28c0b021ab133ca4b635ff7bc3c9
Reviewed-on: https://chromium-review.googlesource.com/320440
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-01-05 23:39:11 -08:00
Icarus Sparry
077e545662 cortex-m: proper handling of input parameters to SVC handler
According to section 2.7 of Cortex-M3 Application Note 179: A Cortex-M3
processor can get a "late arriving exception" and this will corrupt the
values of the r0, r1, r2 and r3 registers passed in an svc call.

http://infocenter.arm.com/help/topic/com.arm.doc.dai0179b/AppsNote179.pdf

The fix is to reload the two registers we care about, r0 and r1, from
the stack to ensure the input parameters to SVC handler, desched (r0)
and resched (r1), are valid.

BUG=chrome-os-partner:48499
BRANCH=none
TEST=Used assert to verify resched is a valid TASK ID.

Change-Id: Ie2229472e709febe16eee3c2cd986e3815fda076
Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/319849
Commit-Ready: Icarus W Sparry <icarus.w.sparry@intel.com>
Tested-by: Icarus W Sparry <icarus.w.sparry@intel.com>
Reviewed-by: Icarus W Sparry <icarus.w.sparry@intel.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-01-05 17:26:10 -08:00
Dino Li
11c2c92236 nds32: start_irq_handler() use system stack
[symptom]
The 'vboot_hash_start()' always return busy error and variable 'in_progress'
got a strange value(should be 0 or 1).

'start_irq_handler()' causes scratchpad overflow in first context switch.
It must be called after SP switch to system stack in ISR.

NOTE:
The scratchpad is still also need more size even if
'start_irq_handler()' is using system stack. following is detail:

1. uint32_t scratchpad[19] 0x81d34 ~ 0x81d7f
[__task_start:]
2. /* put the dummy stack pointer at the top of the stack in scratchpad */
   addi $sp, $r3, 4 * 18
   -> SP 0x81d7c
3. syscall push return address (-4)
   -> SP 0x81d78
[ISR:]
4. push r15, fp, lp, and sp (-0x10)
   -> SP 0x81d68
5. push r0 ~ r5 (-0x18)
   -> SP 0x81d50
[__switch_task:]
6. /* save ipsw, ipc, r6, r7, r8, r9, r10 on the current process stack */ (-0x1C)
-> SP 0x81d34

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

BRANCH=none
BUG=none
TEST=1. hash done.
     2. console command 'taskinfo'.
     3. the scratchpad does not overflow after first context switch.

Change-Id: If5d89ff5c945a777010492fcfb54bf41f434ed69
Reviewed-on: https://chromium-review.googlesource.com/317468
Commit-Ready: Dino Li <dino.li@ite.com.tw>
Tested-by: Dino Li <dino.li@ite.com.tw>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-12-16 21:49:34 -08:00
Vadim Bendebury
432ea75d92 cr50: add ability to include two identical RW sections in the EC image
A typical EC image includes two similar in their functionality
subsections, RO and RW. CR50 has a small RO subsection, all it does -
detects a proper RW image to run and starts it up. To provide for
reliable firmware updates, the CR50 image needs to include two RW
sections, while the code is running from one RW subsection, the other
one can be upgraded.

This patch adds the ability to generate two identical RW sections,
mapped half flash size apart, and include them into the resulting EC
image.

To keep things simple the previously existing RW section's name is not
being changed, while the new (identical) RW section is named RW_B.

Two configuration options need to be defined to enable building of the
new image type: CONFIG_RW_B to enable the feature and
CONFIG_RW_B_MEM_OFF to define where RW_B should be mapped into the
flash.

A new rule added to Makefile.rules allows to generate a different lds
file from the same source (core/cortex-m/ec.lds.S) by defining a
compile time variable to pick a different base address for the
rewritable section, when RW_B is built.

BRANCH=none
BUG=chromium:43025
TEST=as follows:
    - make buildall -j still succeeds
    - verified that regular CR50 image starts successfully

    - modified chip/g/loader/main.c to launch RW_B first, re-built and
      re-run the image, observed on the console:

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
  cr50 bootloader, 20151118_11218@80881, no USB, full crypto
  Valid image found at 0x00084000, jumping

  --- UART initialized after reboot ---
  [Reset cause: power-on]
  [Image: unknown, cr50_v1.1.4160-4c8a789-dirty 2015-12-07 18:54:27 vbendeb@eskimo.mtv.corp.google.com]
  [0.001148 Inits done]
  This FPGA image has no USB support
  Console is enabled; type HELP for help.
  > [0.002212 task 2 waiting for events...]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    (note that the image base address is 0x840000, which is RW_B).

Change-Id: Ia2f90d5e5b7a9f252ea3ecf3ff5babfad8a97444
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/316703
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-12-09 06:36:22 -08:00
Shawn Nematbakhsh
6e4848c200 task: Don't discard events on mutex contention
On mutex contention, call task_wait_event_mask(), which will wait for
a mutex event without clearing other pending events.

BUG=chrome-os-partner:47918,chromium:435611,chromium:435612
BRANCH=None
TEST=Manual on snoball. Verify samus can successfully negotiate PD power
contract when attached to snoball.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I85cd32f2670246da9e4787025390aba2c93f9c36
Reviewed-on: https://chromium-review.googlesource.com/314492
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-11-30 12:27:58 -08:00
Vadim Bendebury
a8f2e3625e add the 'extension' command framework
This patch introduces a facility which would allow to compile in
callbacks for arbitrary commands passed over various communication
protocols.

Typically this will be used for testing, when various test commands
are multiplexed over an existing protocol.

The callbacks are associated with 16 bit command codes. On input the
callback receives a buffer, containing the command's argument, the
size of the command argument and the maximum size of the buffer. On
output the callback stores processing result in the same buffer and
updates the size to the actual amount of returned data.

Callback descriptors are stored in a dedicated read only section which
is scanned by extension_route_command() to find a callback associated
with a certain command code.

A console channel is also being introduced to allow controlling
console output generated by extension commands handlers.

BRANCH=none
BUG=chrome-os-partner:47524
TEST=none yet

Change-Id: I8ae16a78ca7d72176a5e7f74dd7a232078e7c06c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/312586
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-11-17 14:40:26 -08:00
Dino Li
21c0f8e69c nds32: fix lds
symptom:
.bss.slow won't be cleared during initialization.

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

BRANCH=none
BUG=none
TEST=.bss.slow = 0.

Change-Id: I6a8b84807b36a64f29732f09f56947e17d5ba898
Reviewed-on: https://chromium-review.googlesource.com/312155
Commit-Ready: Dino Li <dino.li@ite.com.tw>
Tested-by: Dino Li <dino.li@ite.com.tw>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-11-12 17:55:02 -08:00
Aseda Aboagye
fe3189a56f cortex-m0: Ensure .bss.slow section is cleared.
The .bss.slow input section needs to be included before __bss_end,
otherwise it won't get cleared to zero.

BUG=None
BRANCH=None
TEST=Build jerry.  Verify that __bss_end is at the end of the .bss.slow
section.
TEST=make -j buildall tests

Change-Id: I41d028ee166d05b34a889499cdcb0254341be1b6
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/312404
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-11-12 16:13:51 -08:00
Shawn Nematbakhsh
1ade79a8e6 cleanup: Fix gcc 5.2.1 compile errors
BUG=chromium:552006
BRANCH=None
TEST=`make buildall -j` and also verify panic reporting works on
glados_pd.

Change-Id: Ic9f1ec6b5297389df0d46bb38a67c156901ed956
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/311253
Commit-Ready: Shawn N <shawnn@gmail.com>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-11-11 11:00:56 -08:00
Vadim Bendebury
b895b9e933 cr50: allocate signature headers in both RO and RW images
With the proper RO in place, RW must be signed in the same manner, as
RO. This patch makes sure that there is room in the RW header for the
signature.

BRANCH=none
BUG=chrome-os-partner:43025
TEST=with the rest of the patches applies the RO successfully boots up
     the RW.

Change-Id: I1538195e0181c23c874ddd300887cf5da8c5a867
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/311421
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2015-11-10 06:54:43 -08:00
Aseda Aboagye
260e85cd07 system: Copy the loader lastly before jumping.
The point at which we reloaded the loader was too early.  When items are
placed into .bss.slow via CONFIG_REPLACE_LOADER_WITH_BSS_SLOW, other
tasks could still access their variables that may have been in that
region after we had replaced those contents with the loader.  This
commit moves the reloading of the loader to as late as possible once all
tasks have done their HOOK_SYSJUMP work.

Also, fixed a bug with the .bss.slow section.  If a board is not using
the config option but items are placed in that section, that part of RAM
would not be cleared out.

BUG=chrome-os-partner:46056
BRANCH=None
TEST=Enable config option on GLaDOS and add a few variables to the
.bss.slow section.  'sysjump' between RO and RW and verify that no data
bus error is encountered.
TEST=make -j buildall tests

Change-Id: I3084700b9d5c144e86e2e408b72d2e3075a67413
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/306173
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-11-08 07:59:39 -08:00
Dino Li
032846bc32 it8380dev: modify hwtimer and LPC wake up
1. In combinational mode and clock source is 8MHz,
   if timer 3 counter register always equals to 7, then timer 4 will be a
   32-bit MHz free-running counter.
2. Fix TIMER_32P768K_CNT_TO_US(), each count should be 30.5175 us,
   not 32.768us.
3. Fix TIMER_CNT_8M_32P768K().
4. Make sure LPC wake up interrupt is enabled before entering doze /
   deep doze mode.

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

BRANCH=none
BUG=none
TEST=1. Console commands: 'gettime', 'timerinfo', 'waitms', and 'forcetime'.
     2. Enabled Hook debug, no warning message received (48hrs).
     3. Tested ectool command 'version' x 2000.

Change-Id: I796d985361d3c18bc5813c58705b41923e28c5b1
Reviewed-on: https://chromium-review.googlesource.com/310039
Commit-Ready: Dino Li <dino.li@ite.com.tw>
Tested-by: Dino Li <dino.li@ite.com.tw>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-11-05 11:10:30 -08:00
Dino Li
2ea7b194d9 nds32: fix interrupt
1. To enable INT_PRI (hardware interrupt priority level 0~3)
   register, bit0@INT_CTRL = 0.
2. GIE need to be enabled before UART is initialized.
   [symptom]
   To define CONFIG_RWSIG / CONFIG_RSA / CONFIG_SHA256, then power on:
   after RW image is verified, firmware stuck in uart_flush_output().

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

BRANCH=none
BUG=none
TEST=1. bit0@INT_CTRL = 0.
     2. The RW image is verified and jump to image RW.

Change-Id: I393a3d5f87ea257885b872c91bfce43aecbaea8b
Reviewed-on: https://chromium-review.googlesource.com/309400
Commit-Ready: Dino Li <dino.li@ite.com.tw>
Tested-by: Dino Li <dino.li@ite.com.tw>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-11-01 19:45:58 -08:00
Dino Li
ad1d33778f it8380dev: Increase DLM size
1. Total DLM size is 48KB.

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

BRANCH=none
BUG=none
TEST=DLM 0x84000 ~ 0x8BFFF read/write OK.

Change-Id: I2340aeefca60ad59062254ddd363c703c30cfd24
Reviewed-on: https://chromium-review.googlesource.com/307006
Commit-Ready: Dino Li <dino.li@ite.com.tw>
Tested-by: Dino Li <dino.li@ite.com.tw>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-10-25 07:40:31 -07:00
Dino Li
19c1e9905d it8380dev: fix clock module
1. Implement deep doze mode for CONFIG_LOW_POWER_IDLE.

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

BRANCH=none
BUG=none
TEST=test the following items in deep doze mode.
     1. WUI interrupts wake-up OK. (For example, power button, lid,
        uart rx, keyboard ksi, and so on)
     2. LPC access interrupt wake-up OK.
     3. Enabled Hook debug, no warning message received (48hrs).

Change-Id: I8702a112632cb6c1c0fa75d682badf272130a7d4
Reviewed-on: https://chromium-review.googlesource.com/307060
Commit-Ready: Dino Li <dino.li@ite.com.tw>
Tested-by: Dino Li <dino.li@ite.com.tw>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-10-25 04:34:36 -07:00
Aseda Aboagye
9ed620f04b system: Add support to reclaim space from loader.
Certain ECs which cannot load both the RO and RW images into memory
simultaneously have a little firmware (LFW) loader that is loaded into
the beginning of the program memory.  This loader is responsible for
loading the RO/RW images, however once we begin executing code from
main(), the loader has already completed it's purpose.  We can reuse
this space by allocating portions of the .bss section here.  This
currently saves us 3k for mec1322.  This section is .bss.slow.

To use this feature simply define the following config option in
board.h.

  #define CONFIG_REPLACE_LOADER_WITH_BSS_SLOW

In some cases, such as the mec1322, this region of RAM is optimized for
code and not data.  Therefore, ideally infrequently used data should go
into this region.

BUG=chrome-os-partner:46056
BUG=chrome-os-partner:46063
BRANCH=None
TEST=Flash GLaDOS; sysjump rw; Verify that we are in rw; sysjump ro;
Verify we are back in ro.
TEST=Build GLaDOS, check output memory map for LDR_REGION and .bss.slow
section.
TEST=make -j buildall tests

Change-Id: I5b95cacc211278cf780a857b5a2ecfc1a0a28c45
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/305254
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Andrey Petrov <andrey.petrov@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-10-13 21:58:01 -07:00
Gwendal Grignou
828b55a735 common: Add magnetometer online calibration.
Code for hard iron calibration: Every seconds (or faster if enough
samples), find a sphere that fit the compass data.

Based on Android code.

BRANCH=smaug
BUG=chrome-os-partner:39900
TEST=Check hard-iron bias is removed. Works better outside.

Change-Id: Iab479d5113b6560b4f01b0fd87373d2eecdb9b54
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/299583
Reviewed-by: Anton Staaf <robotboy@chromium.org>
2015-10-13 05:28:54 -07:00
Dino Li
4bb7c3e2f1 nds32: fix panic
Support saving panic data for nds32 core.

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

BRANCH=none
BUG=none
TEST=1. console commands 'crash' and 'panicinfo'.
     2. ectool command 'panicinfo'

crash assert

ASSERTION FAILURE '0' in command_crash() at common/panic_output.c:162
=== EXCEP: ITYPE=1 ===
R0  00000000 R1  000000a2 R2  00000060 R3  00000000
R4  00080c40 R5  00000000 R6  dead6663 R7  000000a2
R8  00000002 R9  00000000 R10 00081960 R15 00000000
FP  00000000 GP  000818d8 LP  0000079a SP  00080c60
IPC 000007a2 IPSW   70009
SWID of ITYPE: 0
Software panic reason PANIC_SW_ASSERT
Software panic info 0xa2

Rebooting...

panicinfo
Saved panic data: (NEW)
=== EXCEP: ITYPE=1 ===
R0  00000000 R1  000000a2 R2  00000060 R3  00000000
R4  00080c40 R5  00000000 R6  dead6663 R7  000000a2
R8  00000002 R9  00000000 R10 00081960 R15 00000000
FP  00000000 GP  000818d8 LP  0000079a SP  00080c60
IPC 000007a2 IPSW   70009
SWID of ITYPE: 0
Software panic reason PANIC_SW_ASSERT
Software panic info 0xa2

> crash divzero
=== EXCEP: ITYPE=10003 ===
R0  00000000 R1  00f02705 R2  00000060 R3  00081a09
R4  00000000 R5  00000000 R6  00000001 R7  00080cc0
R8  00000002 R9  00000000 R10 00081961 R15 00000000
FP  00000000 GP  000818d8 LP  00009bce SP  00080c90
IPC 00009bee IPSW   70009
SWID of ITYPE: 1
Exception type: General exception [Arithmetic]
Exception is caused by a data memory access

Rebooting...

panicinfo
Saved panic data: (NEW)
=== EXCEP: ITYPE=10003 ===
R0  00000000 R1  00f02705 R2  00000060 R3  00081a09
R4  00000000 R5  00000000 R6  00000001 R7  00080cc0
R8  00000002 R9  00000000 R10 00081961 R15 00000000
FP  00000000 GP  000818d8 LP  00009bce SP  00080c90
IPC 00009bee IPSW   70009
SWID of ITYPE: 1
Exception type: General exception [Arithmetic]
Exception is caused by a data memory access

> crash stack
+1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17

Stack overflow in CONSOLE task!
=== EXCEP: ITYPE=8 ===
R0  00000002 R1  00000002 R2  00000060 R3  00080458
R4  0000ebdd R5  00000000 R6  dead6661 R7  00000002
R8  00000bc8 R9  00000002 R10 00000000 R15 00000000
FP  00000000 GP  000818d8 LP  0000079a SP  00080448
IPC 00000a92 IPSW   70009
SWID of ITYPE: 0
Software panic reason PANIC_SW_STACK_OVERFLOW
Software panic info 0x2

Rebooting...

panicinfo
Saved panic data: (NEW)
=== EXCEP: ITYPE=8 ===
R0  00000002 R1  00000002 R2  00000060 R3  00080458
R4  0000ebdd R5  00000000 R6  dead6661 R7  00000002
R8  00000bc8 R9  00000002 R10 00000000 R15 00000000
FP  00000000 GP  000818d8 LP  0000079a SP  00080448
IPC 00000a92 IPSW   70009
SWID of ITYPE: 0
Software panic reason PANIC_SW_STACK_OVERFLOW
Software panic info 0x2

> crash watchdog
Pre-watchdog warning! IPC: 00009c6c

panicinfo
Saved panic data: (NEW)
=== EXCEP: ITYPE=0 ===
R0  00000000 R1  00000000 R2  00000000 R3  00000000
R4  00000000 R5  00000000 R6  dead6664 R7  00000000
R8  00000000 R9  00000000 R10 00000000 R15 00000000
FP  00000000 GP  00000000 LP  00000000 SP  00000000
IPC 00009c6c IPSW   00000
SWID of ITYPE: 0
Software panic reason PANIC_SW_WATCHDOG
Software panic info 0x0
>

Change-Id: I3d491ecd0789335db4633f9bf2ca09cf85503ed9
Reviewed-on: https://chromium-review.googlesource.com/303286
Commit-Ready: Dino Li <dino.li@ite.com.tw>
Tested-by: Dino Li <dino.li@ite.com.tw>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-10-07 17:51:36 -07:00
Dino Li
692428e1a6 it8380dev: fix hw timer and related function.
[chip config]
    1. No hardware specific udelay().
    2. Enable watchdog.
[watchdog]
    3. Watchdog period is "CONFIG_WATCHDOG_PERIOD_MS" of config.h.
    4. Watchdog auxiliary timer period is "CONFIG_AUX_TIMER_PERIOD_MS".
[task and irq]
    5. Write 1 to clear interrupt pending status, no |.
    6. A global variable for store interrupt number of software interrupt.
[uart]
    7. Always reset UART module before config it.
[hwtimer]
    8. Use more external timers for HW timer module.
[task]
    9. Fix task profiling.

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

BRANCH=none
BUG=none
TEST=[watchdog]
        1. console "waitms 1100", only pre-watchdog warning message.
        2. console "waitms 1600", warning message and watchdog reset.
     [hwtimer]
        3. console commands "gettime", "timerinfo", and "forcetime".
        4. enable hook debug and there is no delayed by more than 10%
           warning message over 48 hours.
        5. There is no watchdog reset too.
     [task]
        6. console 'taskinfo'
Task Ready Name         Events      Time (s)  StkUsed
   0 R << idle >>       00000000   32.927724  308/512
   1   HOOKS            00000000    0.034267  372/768
   2 R CONSOLE          00000000    0.116763  468/768
   3   HOSTCMD          00000000    0.000641  372/512
   4   KEYPROTO         00000000    0.000042  212/512
   5   KEYSCAN          00000000    0.000908  356/512
IRQ counts by type:
  38     2932
 155        1
 158      261
 160       67
Service calls:                   87
Total exceptions:              3348
Task switches:                  167
Task switching started:    0.001999 s
Time in tasks:            33.282819 s
Time in exceptions:        0.164717 s

Change-Id: I234085cec231cd855d2a5e639ea1b0966c61d796
Reviewed-on: https://chromium-review.googlesource.com/296939
Commit-Ready: Dino Li <dino.li@ite.com.tw>
Tested-by: Dino Li <dino.li@ite.com.tw>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-10-01 01:55:26 -07:00
Bill Richardson
094a81f5de cleanup: Handle signed RW images a bit cleaner
For signed EC RW images (CONFIG_RWSIG), there's no point in
embedding the public key or signature into the image itself since
it will just be replaced by the signer (either as the next step
in the build process, or after the fact for MP releases). This
takes that out and just points to where the pubkey and signature
will be placed.

BUG=none
BRANCH=none
TEST=make buildall

I also checked the signatures with

  futility show -t build/*/ec.bin

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

Change-Id: Ib39b7c508914851f81a1bebb2450e08ef0def76c
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/302630
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-09-25 19:36:37 -07:00
Shawn Nematbakhsh
854d5a6e7f cleanup: Remove CONFIG_FW_IMAGE_SIZE
Since CONFIG_RO_SIZE and CONFIG_RW_SIZE now exist (which may
theoretically be different sizes), it is no longer useful to globally
define the size of an image.

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

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ie29959923bc5d02b4d7d6d507ff2191bcb7d24c8
Reviewed-on: https://chromium-review.googlesource.com/301743
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2015-09-24 18:07:01 -07:00
Bill Richardson
4ae115e145 Fix typo when building with CONFIG_SHAREDLIB
The board-specific board.h defines things like this:

  #define CONFIG_RO_SIZE 1000
  #define CONFIG_RW_SIZE 1000
  #define CONFIG_SHAREDLIB_SIZE 200

And in the linker scripts we define some preprocessor macros like
so:

  #define FW_SIZE_(section) CONFIG_##section##_SIZE
  #define FW_SIZE(section) FW_SIZE_(section)

So that we can say things like this:

    FLASH (rx) : ORIGIN = FW_OFF(SECTION), LENGTH = FW_SIZE(SECTION)

Note that we have to use FW_SIZE, not FW_SIZE_

The difference is only noticeable when SECTION is #defined. If
${CFLAGS} has

  -DSECTION=RW

Then the expansion is this:

  FW_SIZE_(SECTION)    =>   CONFIG_SECTION_SIZE
  FW_SIZE_(RW)         =>   1000

There's no difference in the output for this particular CL, but
we should use the correct macro anyway to avoid confusion.

BUG=none
BRANCH=none
TEST=make buildall

Change-Id: I61edc76a1aaeb1c675b384371700f37dda39ed47
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/302150
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2015-09-23 21:26:21 -07:00
Mulin Chao
95ea672601 nuc: Fixed flash layout issue for npcx
Fixed flash layout issue for npcx

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

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

Change-Id: I0b9b679c52b8a8e2a26c278b5024d0350fb77338
Reviewed-on: https://chromium-review.googlesource.com/300392
Commit-Ready: Mulin Chao <mlchao@nuvoton.com>
Tested-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-09-21 20:50:56 -07:00
Gwendal Grignou
1d8fcfcd0d common: Add __fls function
Returns the most significant bit set.
Replace 31 - __builtin_clz(x), so x must be different from 0.
Use get_next_bit when not on the performance path,
on performance path set the bit field just after reading it.

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

Change-Id: Ie1a4cda4188f45b4bf92d0549d5c8fb401a30e5d
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/301300
2015-09-21 01:13:54 -07:00
Dino Li
ad8efdee3f it8380dev: fix idle task and chip id
1. Fix system_get_chip_name() and system_get_chip_revision().
2. Fix EC doze mode.
3. Enable LPC cycle wake-up EC from doze / deep doze function.

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

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

Change-Id: I167dbfb965e557eb86ed83f45a945e4315f5fa9f
Reviewed-on: https://chromium-review.googlesource.com/299110
Commit-Ready: Dino Li <dino.li@ite.com.tw>
Tested-by: Dino Li <dino.li@ite.com.tw>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-09-18 01:25:52 -07:00
Gwendal Grignou
c2c02249a0 host: mock i2c_xfer
Instead of mocking i2c_read8/16/32, mock i2c_xfer.
We can now test code that call i2c_xfer directly and
test common/i2c.c

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

Change-Id: Iaa772515c40cf55d2050d0019e2062d63278adc0
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/299768
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-09-16 14:49:46 -07:00
Shawn Nematbakhsh
558c465165 cleanup: Remove CDRAM / CODERAM CONFIGs
CDRAM / CODERAM configs were previously used for chips which copied code
from external SPI to program memory prior to execution, and were used
inconsistently between npcx and mec1322.

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

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

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

CONFIG_FLASH_BASE becomes CONFIG_PROGRAM_MEMORY_BASE
CONFIG_FLASH_MAPPED becomes CONFIG_MAPPED_STORAGE

Add CONFIG_INTERNAL_STORAGE, CONFIG_EXTERNAL_STORAGE and
CONFIG_MAPPED_STORAGE_BASE where appropriate.

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

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

Change-Id: Idb3c4ed9f7f6edd0a6d49ad11753eba713e67a80
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/297484
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-09-16 14:49:31 -07:00
Bill Richardson
15fcbc9596 Cleanup: Remove COMPILE_FOR_RAM option from linker scripts
This option was added way back in January 2012 for early EC
bringup, and never used since. We can probably remove it.

BUG=none
BRANCH=none
TEST=make buildall

Change-Id: Idc8c3099388f2e28d620848a0e78b555b02fba9c
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/297334
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-09-08 10:38:21 -07:00
Anton Staaf
7bdb69c464 UART: Remove unused uart.h header includes
Signed-off-by: Anton Staaf <robotboy@chromium.org>

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

Change-Id: Ife068807f79f6435292643c49afa1a9a30ae7080
Reviewed-on: https://chromium-review.googlesource.com/296733
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-09-08 10:38:20 -07:00
Bill Richardson
0860b19a97 cortex-m: CONFIG_RO_HEAD_ROOM should only affect RO image
When we add head room to the RO image, it's generally to provide
a chip-specific boot header of some sort. That header is only
needed for the RO image, not the RW image. The macro name implies
this, but this CL makes it so.

BRANCH=none
BUG=chrome-os-partner:43025, chrome-os-partner:44625
TEST=the cr50 image validates *and jumps to* the RW image at boot.

Change-Id: I0e5b2c32e232418970e01c7409ddcbbabd4786d5
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/296451
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2015-08-31 17:38:01 -07:00
Vadim Bendebury
6f8637a6df cortex-m: provide ability to insert free space into RO image base
Some platforms might expect the header of the image to be a certain
platform specific blob. This patch adds an ability to insert an
arbitrary size header in the binary blob, if so desired, the intention
is to have the platform specific tools to postprocess the image and
replace the header with sensible data.

Ideally we should be able to produce an image which is mapped to start
at an offset to the FLASH_BASE, but the macros in ec.S.lds files are
way too smart for this.

BRANCH=none
BUG=chrome-os-partner:43025
TEST=with this and other changes the latest cr50 image gets signed and
     booted properly.

Change-Id: Icabf00c6b90657b0ae3370ddad3567ccedf3ff49
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295200
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-08-22 01:37:31 +00:00
Dino Li
911de4d175 nds32: use INT_MASK instead of GIE
When there is an interrupt event, N8 CPU will save PSW register to IPSW
register and clear GIE then jump to interrupt service routine. N8 will
restore PSW from IPSW after "iret" instruction (the above are purely
hardware mechanism).

Nested interrupt will occur if we set GIE again in interrupt context.

symptom:
    power button pressed while LID open -> exception or unknown reset.

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

BRANCH=none
BUG=none
TEST=1. Manually pressed power button x200.
     2. Console "eflash" erase and write eflash OK.

Change-Id: Ic04a23d473ebc6417dffea814a27583cb8d63a1f
Reviewed-on: https://chromium-review.googlesource.com/289437
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Dino Li <dino.li@ite.com.tw>
Tested-by: Dino Li <dino.li@ite.com.tw>
2015-08-20 01:37:56 +00:00
Dino Li
26984c7de4 it8380dev: add __muldi3.S
symptom:
Enable debugging and profiling statistics for hook functions
(#define CONFIG_HOOK_DEBUG), and __muldi3 function is missing
while link.

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

BRANCH=none
BUG=none
TEST=1. compile successful and hook_notify starting to print message.
     2. console "hookstats"

Change-Id: Ia2815bcefd0f9ac06dab9c75ea6ee06312878ca2
Reviewed-on: https://chromium-review.googlesource.com/293432
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Dino Li <dino.li@ite.com.tw>
Tested-by: Dino Li <dino.li@ite.com.tw>
2015-08-14 14:34:26 +00:00
Anton Staaf
fba4f335a9 cortex-m0: Constrain target register in atomic read
One more register constaint needed to be added to the cortex-m0 atomic
inline assembly.  Vincent fixed all the others.  The requirement for
ARMv6-m includes that the target load register be one of the low
registers as well.

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

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

Change-Id: Ie44e824cafcc9b862ade664e3016cc34886cdf6e
Reviewed-on: https://chromium-review.googlesource.com/292435
Trybot-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2015-08-11 19:52:40 +00:00
Vadim Bendebury
9968fb3966 cortex-m: catch misconfigured interrupts early
The code in core/cortex-m/init.S limits the number of installed
vectors to CONFIG_IRQ_COUNT. But the DECLARE_IRQ macro installing
interrupt servicing routines does not care about this limitation. This
results in corrupted interrupt configuration, which is hard to debug.

This patch makes sure that there is a compilation error in case
DECLARE_IRQ is passed interrupt number which out of bounds.

A similar change needs to be introduced for cortex-m0.

BRANCH=none
BUG=chromium:518898
TEST=tried building cr50 with one of interrupt numbers exceeding
     CONFIG_IRQ_COUNT, observed a compilation error.

Change-Id: Ie7bc623da6bf7371579b2242064f81a83053df17
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/291843
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-08-11 00:06:18 +00:00
Anton Staaf
4626177c3b Atomic: Mark the modified uint32_t volatile
The atomic_* functions are often used in contexts where the data they
will operate on are volatile (due to being shared between tasks or a
task and an interrupt handler).  Adding volatile here makes using the
atomic_* functions a little easier in those cases and removes a cast
from the call sites (which could be obscuring a bug, if for instance
the variable was modified to be a uint16_t).

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

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

Change-Id: I71356eb3cf2c0506df38532eee767c7d78f9240e
Reviewed-on: https://chromium-review.googlesource.com/287516
Trybot-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2015-07-27 19:30:44 +00:00
Ian Chao
14bd917343 nuc:
Add ECST tool to modify the header used by npcx booter.

Modified drivers:
1. i2c.c: Modify for i2c_port design.
2. i2c.c: Fixed bugs when mutil-tasks use the same i2c port and pull-up issue.
3. hwtimer.c: Fixed bug whcih event expired time is behide current timer.
4. lpc.c: Add intializing host settings after pltrst is deasserted.
5. uart.c/clock.c/register.h: Fixed bug which cannot enter deep-idle
   when gpio is any-edge trigger mode.
6. task.c: Add workaround method for hard fault issue.
7. keyboard_raw.c: Modified for support CONFIG_KEYBOARD_KSO_BASE
8. lpc.c: Modified for support CONFIG_KEYBOARD_IRQ_GPIO
9. lpc.c: fixed obe interrupt bug during 8042 initialization
10.Adjust path of flat files for new Makefile rules
11.Fixed build error on lpc.c without CONFIG_KEYBOARD_IRQ_GPIO

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

Change-Id: Icf9494174b245b4026e396be877d578f36b6f6a5
Signed-off-by: Ian Chao <mlchao@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/284036
Reviewed-by: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Commit-Queue: Shawn N <shawnn@chromium.org>
2015-07-25 01:22:32 +00:00
Kyoung Kim
0e53f9d425 mec1322: heavysleep in idle task and console deepsleep
Implemented mec1322's heavysleep in idle task to
reduce further EC power down on S3.
MEC1322 needs sleep-enabled for all blocks to
acheive max power down including UART.
Real heavysleep will be effective only when
console/uart is not active.

To enable this commit, board-specific commit is required.
For example, check commit, "Enabling heavysleep idle task at S3".

Test:
1. Put device into S3 mode by typing 'powerd_dbus_suspend" in Linux
   shell.
2. wait at least 1 min till EC console sleeps
3. measure EC power.
   Since idle task is continuously scheduled, EC will enters/exits
   to/from heavy sleep mode frequently in S3 and power consumption
   will be changed dynamically.
   For acurate power measurement, high-sampling-rate measurement
   system might be required and using DMM might not give accurate
   number.

BUG=None
TEST=Tested on evt1p0/evt1p7/DVT
BRANCH=None

Change-Id: I435ca347cab2f4d51cefeee802c3bf30fb393fa1
Signed-off-by: Kyoung Kim <kyoung.il.kim@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/283603
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Alec Berg <alecaberg@chromium.org>
2015-07-17 18:09:55 +00:00
Aseda Aboagye
ce063e0829 build-infr: Add support for shared RO library.
This commit introduces the build infrastructure changes needed for
creating a shared RO library. (libsharedobjs).  The end goal is for the
library to contain various objects that can be shared with both the RO
and RW EC images.

Now, there are 3 make goals: ro, rw, and libsharedobjs.

In order for changes that are only specific to a single image (ie: RW
only) to be applied correctly, the object files are now built separately
for the RO, RW, shared objects library targets.

NOTE: Certain EC targets are incompatible with this model due to the
fact that only one image is present within flash at a time.

BRANCH=none
BUG=None
TEST=make -j buildall tests
TEST=make -j BOARD=cr50 xrefs
TEST=make BOARD=samus dis
TEST=Built samus EC image and compared that the final EC image was
identical to the upstream version (except for the git SHAs & version
strings).

CQ-DEPEND=CL:285934

Change-Id: I8e67f089710be9c6d7017718109262394bdad2f5
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/274079
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
2015-07-17 03:17:50 +00:00
Aseda Aboagye
a21650f05f emulator: Fix handling of early IRQs.
Since the interrupt generator is now spawned right after the hooks task
and the generator can generate interrupts whenever it wants, it's
possible for an interrupt to fire before task switching is enabled.
When this happens, the main thread needs to be suspended so that the IRQ
can be serviced.

BRANCH=None
BUG=None
TEST="make clobber && make -j buildall tests" several times."

Change-Id: I5fb4f17666e3db9c670c4352bb36b84e4606dfa0
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/285634
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Trybot-Ready: Aseda Aboagye <aaboagye@chromium.org>
2015-07-17 00:05:46 +00:00