Commit Graph

1184 Commits

Author SHA1 Message Date
Vincent Palatin
4d0aad8894 cr50: add USB support
Add a USB device driver for the Synopsys DWC USB device controller.

The common USB protocol stack code still need to be de-duplicated with
the STM32 implementation.

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

BRANCH=none
BUG=chrome-os-partner:33919
TEST=plug Cr50 to a Linux workstation and see USB descriptors using
"lsusb -v -d 18d1:5014"

Change-Id: I4a367241053de2c2d94aa06f82ea4bee51f9f89a
Reviewed-on: https://chromium-review.googlesource.com/231160
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2015-04-02 20:27:46 +00:00
Shamile Khan
c72628b8e7 Strago:Fix I2C Block Read operation.
I2C Block reads were split into two i2c_xfer() calls. However, i2c_xfer() implementation for MEC
does not maintain state in between calls. This was causing block read failures because the
settings for the Control Register got corrupted. Fix this by calling i2c_xfer() only once. This
retrieves both string size and string. Only return the string back to the user.

BUG=None
TEST=Tested on Braswell Ref Design
BRANCH=None

Change-Id: Ife8fcb66425c6198d0dcf10f74e89c001ccac49a
Signed-off-by: Shamile Khan <shamile.khan@intel.com>
Signed-off-by: Divya Jyothi <divya.jyothi@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/260627
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-04-01 19:38:43 +00:00
Steven Jian
d8b0b43bb9 mec1322: Fix the ACPI EC0 BAR setting
Per datasheet, it should be 304.

BUG=None
BRANCH=None
TEST=None

Change-Id: I3f7b82bf2f63ed011183cd72f4e19daa7dd0dcf0
Signed-off-by: Steven Jian <steven.jian@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/262283
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-03-26 22:42:32 +00:00
Shawn Nematbakhsh
6ee7b1e34e ACPI: Support accessing memmap data over ACPI CMD / DATA ports
Some platforms are unable to access the 900h-9ffh region over LPC and
must instead access memmap data through the ACPI CMD / DATA ports. To
avoid racing with data updates, disallow changes to multi-byte memmap
data while in burst mode.

Linux currently enables burst mode when accessing multi-byte data and
disables it immediately afterward, though the ACPI spec defines burst mode
in a more general way.

BUG=chrome-os-partner:38224
TEST=Manual on Samus. Undefine LPC_MEMMAP and modify asl to move memmap
data to ERAM at offset 0x20. Verify system boots cleanly and battery
status is updated immediately on plug / unplug.
BRANCH=None

Change-Id: Ib848bdb491fdfece96ad0cee7a44ba85b4a1a50b
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/262072
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2015-03-25 20:09:52 +00:00
Anton Staaf
a0158dd136 CCD: Add ability to enable and disable SPI bridge
This required changing the USB-SPI implementation slightly
so that all work is done within the deferred callback.  In
particular, this allows the board specific enable and disable
functions to do things that can only be done from a task
context, like sleeping.

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

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

Change-Id: I3f6a01ed9d6f31a3259ba0a0f6b4e123d6d2e718
Reviewed-on: https://chromium-review.googlesource.com/260964
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-03-23 19:23:35 +00:00
Anton Staaf
4002d66297 USB-SPI: Set the interface SubClass to Google SPI
This SubClass will provide a simple mechanism for
host tools to discover SPI bridge enabled devices.

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

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

Change-Id: I0c800ca7b1a2ac58584eab8ba201a6b2a5a894ea
Reviewed-on: https://chromium-review.googlesource.com/260963
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-03-23 19:23:32 +00:00
Dino Li
2c3cf4d1a9 it8380dev: add KBC/KMSC module
1. DLM 16KB.
2. Add KBC/KMSC module for emulation board.

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

BRANCH=none
BUG=none
TEST=EVB + x86 MB can boot into DOS and keyboard works.

Change-Id: Ia5cc2d4f1733ce07879d410b0447b2d48e50cd95
Reviewed-on: https://chromium-review.googlesource.com/259923
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Dino Li <dino.li@ite.com.tw>
Commit-Queue: Dino Li <dino.li@ite.com.tw>
2015-03-22 03:13:58 +00:00
Sheng-Liang Song
c12181d9af cr50: Added PMU driver
- Porting from cosmo code base.
- Support clock initialization

BRANCH=none
BUG=chrome-os-partner:33813
TEST="make buildall -j; Verified on RevA1 Chip"

Change-Id: I59e2bb133968d408acde44a3082e1b3b8f4bbbff
Signed-off-by: Sheng-Liang Song <ssl@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/236394
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2015-03-21 00:29:14 +00:00
Sheng-Liang Song
3f061f1864 cr50: Added macros for register read/write
Added macros for register read/write.

BRANCH=none
BUG=chrome-os-partner:33815
TEST="make buildall -j; Verified on RevA1 chip"

Signed-off-by: Sheng-Liang Song <ssl@chromium.org>

Change-Id: I25c6f6b5865c7fdde002b2191b1f2eaaba15f589
Reviewed-on: https://chromium-review.googlesource.com/236402
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Sheng-liang Song <ssl@chromium.org>
Tested-by: Sheng-liang Song <ssl@chromium.org>
2015-03-20 23:06:58 +00:00
Sheng-Liang Song
bdcc496b30 cr50: added cr50 a1 chip
cr50_a1 is for cr50 Rev A1 chip.

BUG=chrome-os-partner:33432
BRANCH=none
TEST=Compile Only

Change-Id: I5490d1a5b89fa66c8e8b969cff7538a293a7d053
Signed-off-by: Sheng-Liang Song <ssl@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/259847
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2015-03-20 23:06:53 +00:00
Shawn Nematbakhsh
90ef8b7006 lm4: stm32: Store panic data in backup registers on hard reset
On hard reset / hibernate, RAM will be erased and panic data will
normally be lost. When software panic data saving is enabled, try to
save this data just before hard reset and restore it when we come back
up.

BUG=chrome-os-partner:37380
TEST=Manual on Samus with WP + SW sync enabled. Boot AP, then run "crash
divzero" on console. After hard reset, verify that "panicinfo" dumps
data and shows divzero exception code.
BRANCH=Samus

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I9516dd4b6db12ef35e512cc4710f9b97d7e663cb
Reviewed-on: https://chromium-review.googlesource.com/255912
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-03-14 03:22:37 +00:00
Shawn Nematbakhsh
07d3b69413 mec1322: Add flash physical interface functions
Add physical flash interface for read / write / protection of external
SPI on mec1322.

BUG=chrome-os-partner:36167
TEST=Manual on glower:
flashread 0xf000 0x200 --> dumps 0xff
flashwrite 0xf000 0x200
flashread 0xf000 0x200 --> dumps write pattern
flasherase 0xf000 0x1000
flashread 0xf000 0x200 --> dumps 0xff
spi_flash_prot 0 0x10000
flashinfo --> shows first 64KB protected
spi_flashwrite 0xf000 0x200 --> access denied
spi_flashwrite 0x1f000 0x200 --> OK
flashread 0x1f000 0x200 --> dumps write pattern
BRANCH=None

Change-Id: I2cb20a49934999fc0dd9b3425eb99708711637c5
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/257132
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-03-12 00:48:20 +00:00
Shawn Nematbakhsh
9894181ee9 mec1322: Remove RO image to save program memory
mec1322 projects are running very low on flash space. We don't yet have
a loader to load either RO or RW at runtime, so remove the RO image
entirely. This is a temporary change and should be reverted once we have
a working loader.

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

Change-Id: I8c502ec2bcabf246d5a3ea939f1a8d0c366acd9f
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/256381
Reviewed-by: Vic Yang <victoryang@chromium.org>
2015-03-06 08:49:01 +00:00
Anton Staaf
e6f6704408 USB Stream: Make RX and TX buffer sizes configurable
Previously the USB Stream buffer sizes were fixed at
USB_MAX_PACKET_SIZE (currently 64 bytes).  But that
ended up using up too much packet RAM, a very limited
resource.  This change makes them configurable and
adds asserts to insure that the sizes are valid for
the underlying hardware.

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

BRANCH=None
BUG=None
TEST=make buildall -j
     Verify that USART forwarding on discovery works

Change-Id: Ib19c0dcfa9b16f23c1d72a5a7fc18026ab103f05
Reviewed-on: https://chromium-review.googlesource.com/255232
Trybot-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2015-03-03 21:39:35 +00:00
Myles Watson
1f6f5d5333 nrf51: Reset clean up.
Use the values from the datasheet to report the reset reason.

TEST=hard reset, soft reset, wake from sleep with a GPIO
BRANCH=NONE
BUG=None

Signed-off-by: Myles Watson <mylesgw@chromium.org>

Change-Id: I2a45741c9c17f0c2e4eb4b8b12d3231f407244dd
Reviewed-on: https://chromium-review.googlesource.com/254112
Tested-by: Myles Watson <mylesgw@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Myles Watson <mylesgw@chromium.org>
2015-03-02 21:37:13 +00:00
Anton Staaf
65f049b977 Producer/Consumer: Convert USART and USB Stream drivers
Previously the USART and USB Stream drivers exposed in_stream
and out_stream interfaces, which don't allow for sharing their
queues easily.  This change converts these drivers over to the
producer/consumer model and updates the two uses.

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

BRANCH=None
BUG=None
TEST=make buildall -j
     Verify that the discovery echo functionality is unchanged.

Change-Id: I29f043ab1712373f638e1621378df98647d736cf
Reviewed-on: https://chromium-review.googlesource.com/252820
Trybot-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2015-03-02 18:48:40 +00:00
Vic Yang
179fcb3f1d Revert "mec1322: Fix LPC interrupt bit mask"
This reverts commit 9ed4434ad8.

According to MEC1322 errata, LRESET# interrupt is indeed GIRQ 19 bit 1.

BRANCH=None
BUG=chrome-os-partner:36326
TEST=None

Change-Id: I9d0dc0ef3abac1ace59b46eafae04f6b9e5c0b9b
Reviewed-on: https://chromium-review.googlesource.com/254771
Reviewed-by: Divya Jyothi <divya.jyothi@intel.com>
Reviewed-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2015-02-28 03:46:47 +00:00
Shawn Nematbakhsh
d1939ee101 stm32f0: Fix RTC read glitch
Reads to RTC_SSR may be invalid if they occur close to the RTCCLK edge.
As suggested by the datasheet, perform consecutive identical reads to
ensure the read is valid.

BUG=chrome-os-partner:37216
TEST=Manual on Samus. Repeatedly call rtc_read in test function, verify
that RTC_SSR never incorrectly ticks up.
BRANCH=Samus

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ib26fbfab4a07263f638c580066e993675dd8c451
Reviewed-on: https://chromium-review.googlesource.com/254725
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-02-28 03:46:35 +00:00
Myles Watson
9bdbc71c45 nrf51: add RNG definitions to registers.h
RNG (Random Number Generator) register definitions from the datasheet

TEST=buildall
BRANCH=NONE
BUG=None

Signed-off-by: Myles Watson <mylesgw@chromium.org>

Change-Id: Id700564edfa8021aa5604ed53f7ccfe8c3c4f6db
Reviewed-on: https://chromium-review.googlesource.com/254111
Tested-by: Myles Watson <mylesgw@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Myles Watson <mylesgw@chromium.org>
2015-02-28 02:26:35 +00:00
Myles Watson
199edf4be1 nrf51: add definitions for RADIO and FICR registers.
TEST=tested that the radio sends and receives packets correctly.
BRANCH=NONE
BUG=None

Signed-off-by: Myles Watson <mylesgw@chromium.org>

Change-Id: I7f59521062558be90c217013e2ea2dae502005c4
Reviewed-on: https://chromium-review.googlesource.com/254110
Tested-by: Myles Watson <mylesgw@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Myles Watson <mylesgw@chromium.org>
2015-02-28 02:26:30 +00:00
Randall Spangler
16eec7f14c Remove unused CONFIG_PSTATE_AT_END option
All current boards in ToT place pstate at the end of the RO section.
Remove the unused option to place it at the end of the RW section;
we'll never do that again.

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

Change-Id: I0d279a4c9786bb33367a7387423481cc9b94e115
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/253636
Reviewed-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2015-02-27 19:56:47 +00:00
Randall Spangler
3ff0be248c npcx: Use SPI status register instead of pstate
The npcx chip and evb use a SPI flash chip to hold the EC image.  They
don't need pstate, and should use the SPI flash status register
directly.

1. Remove CONFIG_FLASH_PSTATE from npcx_evb.
2. Remap WP_L GPIO to GPIO 93 (this should be the same as the write protect
   line to the SPI flash chip).
3. Change the npcx flash driver so that it directly reads/writes the SPI
   status register instead of mucking with pstate.

BUG=chrome-os-partner:34346
BRANCH=none
TEST=manual
   Add a switch or jumper to the EVB so R1 can be closed.
   Toggle the switch and see that WP_L state changes.  Leave enabled.
   flashinfo -> nothing is protected, WP_L is enabled (=0)
      (also do this after each flashwp command to check the protection status)
   flashwp enable -> RO is protected now and at boot.
   reboot
   flashwp enable -> RO is still protected.
   flashwp disable -> RO is still protected. (because WP switch is enabled).
   Toggle the switch so WP_L is disabled (=1)
   flashwp disable -> Succeeds, flash is not protected

Change-Id: Ifa959bce69f8eb4724057ecaa6a6c5075783c19d
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/253633
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-02-26 20:31:58 +00:00
Bill Richardson
dd9c1447ac cr50: enable signed RW images
This signs the RW firmware (with a non-secret key). The RO
firmware will verify the RW firmware and jump to it if it's good.

Note that this isn't the final solution, just the beginning.

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

Build and install it. You'll see something like this:

--- UART initialized after reboot ---
[Reset cause: reset-pin hard]
[Image: RO, cr50_v1.1.2929-27e1b82-dirty 2015-02-24 14:36:29 wfrichar@wfrichar-glaptop]
[0.000444 Verifying RW image...]
[0.423742 RW image verified]
[0.423946 Jumping to image RW[0.428492 UART initialized after sysjump]
[Image: RW, cr50_v1.1.2929-27e1b82-dirty 2015-02-24 14:36:29 wfrichar@wfrichar-glaptop]
[0.428931 Inits done]
Console is enabled; type HELP for help.
>
> sysinfo
Reset flags: 0x00000c02 (reset-pin sysjump hard)
Copy:   RW
Jumped: yes
Flags:  unlocked
>

Change-Id: Icafa554baca135ff1f80cbce4dad5f980e7fc122
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/253081
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-02-25 08:44:58 +00:00
Todd Broch
e20d019fc4 pd: Massage initialization at task start.
Refactoring effort to unify the set of PD intialization tasks that
need to occur.  Those areas include:

  1. host mode as it relates to power & pull-ups/downs
  2. PD tx init
  3. PD mux settings

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

BRANCH=samus
BUG=chrome-os-partner:36481
TEST=manual,

1. compiles and functions on samus_pd
2. If sysjump w/ dongle connected than alternate mode re-entered
   properly including muxing and HPD

Change-Id: I47f32acaeccbd7745e1e01a8b085b1804c4c5000
Reviewed-on: https://chromium-review.googlesource.com/249273
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Alec Berg <alecaberg@chromium.org>
2015-02-25 03:33:12 +00:00
Randall Spangler
c3cd10937e WIP - Nuvoton 30-Jan patch
Issues fixed on 0216:
1.Modified CONFIG_KEYBOARD_COL2_INVERTED support in keyboard_raw.c
2.Modified warm_reset checking in gpio.c
3.Modified system_get_chip_name in system.c for package info.
4.Modified fan.c and pwm.c for:
● If the DCRn value is greater than the CTRn value, the PWM_n signal is always low.
● Fan stall condition event:
  If the measured fan speed is lower than the lowLimit value (unless the Fan Speed Low Limit value is 0) or in case of erroneous measurement, the userCallback is called.
5. Change cycle_pluses to 480 in board.c

Issues fixed:
1. Jump data at top of RAM is getting corrupted.  Changed the flag to
RESET_FLAG_RESET_PIN.  Added a workaround method to fix VCC1_RST
issue.

2. Hibernate wake need to report whether wake reason was GPIO or RTC

3. Hibernate wake must be distinguishable from watchdog reset.  The
booter will log reset reason in Code RAM.  I copy the log data to
battery-backup RAM in little FW.  And system driver will refer this
data to distinguish if it's watchdog reset or not.

4. Watchdog reset flag is not set.  Same fix as 3.

5. Should return error if unable to clear SPI flash status register.

6. Remove chip_temp_sensor.c

7. Remove use of pstate from flash driver

8. Remove support for watchdog warm reset

9. Keyboard raw driver must support COL2 inverted

10. LPC memory mapped data must be read-only from host

11. LPC should support PLTRST# signal

12. Problems reading chip type/version.  Use core registers and ROM data to read IDs.

13. When chip type/version is unknown, report hex value.

14. Watchdog does not consistently print panic information.

15. Remove console force enable logic.

16. Enable only the peripheral clocks that are needed.  Please notice
user should add bit mask in CGC_XXX_MASK if they want to enable
additional module.  For example, if user wants to enable PWM3, he must
add PWDWN_CTL2_PWM3_PD bit in CGC_PWM_MASK.

Please see HOOK_FREQ_CHANGE and HOOK_INIT these two hook functions.
If I turn off all I2C modules in system_pre_init and turn on the
modules I need in i2c_init, I found its freq is not correct.  The root
cause is hook_notify(HOOK_FREQ_CHANGE) is executed first (in
clock_init) before i2c_init.  At this time, i2c modules are power-down
and writing to freq register is useless.  I re-execute freq-changed
hook function after turning on modules again.

17. MPU properly configured to prevent code execution from data RAM

18. Partial nvcontext implementation.  Copy these 16 bytes in our battery-backup RAM.

Additional items we also modified:

1. pwm.c: Support open-drain IO type of PWM.  (PWM IO-Type cannot by
determined by GPIO, we use bit 1 & 2 of function byte of gpio_alt_func
array to support it)

2. ec_npcxflash.c: Use definition to replace constant value.  Stop
watchdog during flash programing.

3. npcx_cmds.tcl: Adjust script sequence for robustness.  Add unlock
MPU commands for Data RAM.

BUG=chrome-os-partner:34346
BRANCH=none
TEST=manually verify changes

Change-Id: I722a77d29e7543b054819480c7b7477af4263119
Signed-off-by: Ian Chao <mlchao@nuvoton.com>
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/248670
2015-02-25 03:33:08 +00:00
Anton Staaf
d2964ba0cf USART: Add STM32F3 support and fix STM32F baud rate bug
Previously the STM32F3 support was non-functional due to
it being a cut and paste of the STM32F0, and the clocks
are not set up the same way on the two platforms.  Also,
the STM32F initialization code was incorrectly calling
the F0/L buad rate setup code.

This change has the variant specific USART code pass the
input frequency to the baud rate divisor clock to the
baud rate setup code, instead of that code calling
clock_get_freq() to determine the input clock frequency.
This is required because the STM32F3 is not configured
such that the clock_get_freq value and the input to
the USART baud rate divisor match.

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

BRANCH=None
BUG=None
TEST=make buildall -j
     Verify USART works on discovery as well as Ryu

Change-Id: I71248d83b53969d0e7020747a9bb9570803f30ac
Reviewed-on: https://chromium-review.googlesource.com/250920
Reviewed-by: Vic Yang <victoryang@chromium.org>
Trybot-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2015-02-24 03:08:07 +00:00
Alec Berg
3dffafac68 stm32f0: fix handling of RTC alarm 24 hour rollover
Fix bug in RTC module for stm32f0 in which it doesn't handle the
24 hour rollover appropriately and can cause a watchdog reset
if in deep sleep during rollover.

BUG=chrome-os-partner:36920
BRANCH=samus
TEST=add line to rtc_init()
STM32_RTC_TR = 0x00235952
This initializes RTC clock to 8 seconds before rollover. Using samus
make sure unit is allowed to go to deep sleep (S3/S5 and not charging)
and see that without this CL we watchdog most of the time, and with
this CL we don't watchdog ever.

Change-Id: I3f4b4b1ab7b2be1d4e344477d5eaaa0dc916773a
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/251852
Reviewed-by: Alexandru Stan <amstan@chromium.org>
2015-02-22 01:45:29 +00:00
Vic Yang
1ef0f27e65 stm32f3: Allow per-board ADC sampling time
Depending on the hardware, each ADC channel may need a different
sampling time. To keep things simple, let's allow per-board ADC sampling
time configuration instead of per-channel configuration.

BRANCH=Ryu
BUG=None
TEST=Configure sampling time to 3 and measure IADP on Ryu P4 and check
it's more accurate.

Change-Id: I3c1eeea22439c0340f84fdeb3624fc84450358ca
Signed-off-by: Vic Yang <victoryang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/251701
Tested-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
2015-02-21 09:19:57 +00:00
Bill Richardson
02013f6aa3 cr50: Separate ARM core GPIOs from pinmux configuration
This separates the configuration of the ARM core GPIOs from the
routing of internal peripherals to external pins. Both are still
described in the gpio.inc file, but are less dependent on each
other.

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

Before this CL, running "sysjump rw" or trying to use more than 8
GPIOs caused hangs and reboots. Now it doesn't.

Change-Id: If962a7c5ad4136837b2ea00ae016a440f07d7e23
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/251015
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-02-20 03:00:04 +00:00
Alexandru M Stan
3ae7240410 hwtimer/hwtimer32: Remove task_resched_if_needed from watchdog help
Remove task_resched_if_needed, since we don't do any task scheduling
modifications. Just return instead.

This makes it work on F0 as well, where we don't have task_resched_if_needed

BUG=None
TEST=With series, see watchdog help work on any veyron
BRANCH=veyron

Change-Id: I93cce722b6d53008b015c7cdd56b7e77dc07bbff
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/242713
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
(cherry picked from commit 8363dfb14cb36fca412132ab14d2c9451de7d94e)
Reviewed-on: https://chromium-review.googlesource.com/250671
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
2015-02-18 23:52:44 +00:00
Vincent Palatin
4b774f07d3 make idlestats console command optional
To save flash space, disable "idlestats" console command on samus_pd.
This saves 384 B of flash

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

BRANCH=samus
BUG=chrome-os-partner:34489
TEST=make buildall and check firmware size.
=== build/samus_pd/ BASELINE ===
FLASH 57.8k / 60.0k  [ text 48.0k rodat  9.7k data  0.1k ]
RAM   11.8k / 16.0k  [ data  0.1k bss   11.7k ]

=== #undef CONFIG_CMD_IDLE_STATS ===
FLASH 57.4k / 60.0k  [ text 47.9k rodat  9.4k data  0.1k ]
RAM   11.8k / 16.0k  [ data  0.1k bss   11.7k ]

Change-Id: Iba9654a88ec195026945881bc2687a1e67747706
Reviewed-on: https://chromium-review.googlesource.com/241452
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Alec Berg <alecaberg@chromium.org>
Tested-by: Alec Berg <alecaberg@chromium.org>
2015-02-18 04:52:49 +00:00
Anton Staaf
6c83a4d3a5 USB: fix memcpy_to_usbram
A change to the toolchain or environment surfaced an issue where the writes to
packet RAM were being split into two 16-bit writes.  This was interacting
poorly with the AHB2APB bridge.

Marking the packet RAM destination pointer volatile forces the compiler to use
full 32-bit writes.

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

BRANCH=None
BUG=None
TEST=make buildall -j
     Check that Ryu's console is accessible over USB

Change-Id: I0c3db08c704389a627570b90ef97bce81ab553fa
Reviewed-on: https://chromium-review.googlesource.com/248840
Trybot-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2015-02-17 18:19:14 +00:00
Alec Berg
2e6bee5642 stm32f0: Change idle task warning printf to save stack space
Change the idle task overslept warning printf to save stack space.
The current warning uses CPRINTF which adds too much to the stack
and overflows the idle stack.

BUG=chrome-os-partner:33138, chrome-os-partner:36636
BRANCH=samus
TEST=comment out the if (margin_us < 0) check and always print
warning message. Without this CL stack overflows. With this CL,
stack does not overflow and gets to 168/256, which is plenty of
headroom considering the task doesn't do much.

Change-Id: I19a8336b8584d2a1342e7b9290aad471d326a060
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/250300
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2015-02-16 23:58:11 +00:00
Alexandru M Stan
80778ad0eb cortex-m0: Add deferred scheduler
If 2 interrupts happen at the same time, there is a chance that the nested
interrupt will not call svc_handler when it needs to. In extreme cases this
could lead to tasks not getting woken up when they're supposed to and watchdog
resetting.

The reason stuff worked was because there were enough other interrupts
around to eventually call the scheduler and switch to the ready task.

This change modifies the interrupt calls to not call the scheduler directly
(because in nested interrupt situation this causes problems), but defer the
call to scheduling until after the irq finishes by triggering a low priority
interrupt which will for sure call svc_host at the end. The PendSV irq was
used for this purpose.

BUG=chrome-os-partner:36193
TEST=No more SPI errors caused by scheduler problems
TEST=usleeps now are more accurate, they're guaranteed to not take forever now
BRANCH=veyron

Change-Id: I42acde6b3eb7be2540a0de9a8562dee2ea2be7ab
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/248902
Tested-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Alec Berg <alecaberg@chromium.org>
2015-02-12 06:44:04 +00:00
Anton Staaf
41ee615c0b USB: Fix cut and paste bug for board specific disconnection
Signed-off-by: Anton Staaf <robotboy@chromium.org>

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

Change-Id: I8ec4396370b7e3068d29d569b73fddc648e1f76f
Reviewed-on: https://chromium-review.googlesource.com/247720
Trybot-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2015-02-10 23:07:09 +00:00
Vic Yang
049463f8ad stm32: Add delay after enabling peripheral clock
We need a dummy read after enabling AHB peripheral clock before we can
access the peripheral. For APB, we also need a dummy read for STM32F3.

BRANCH=All affected
BUG=chrome-os-partner:33007
TEST=make buildall

Change-Id: I47f4a024dca294f555428c3f2053c1d32835ebe0
Signed-off-by: Vic Yang <victoryang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/246181
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
2015-02-10 10:47:07 +00:00
Vic Yang
9ed4434ad8 mec1322: Fix LPC interrupt bit mask
LRESET# interrupt should be GIRQ19 bit 0 instead of bit 1.

BRANCH=None
BUG=chrome-os-partner:36326
TEST=Run on Glower and doesn't see LRESET# interrupt storm.

Change-Id: I1adedea63e9ec2851e1e09fc8c0eb8185070dad1
Signed-off-by: Vic Yang <victoryang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/247790
Tested-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
2015-02-10 06:47:44 +00:00
Myles Watson
4ada7739f9 nrf51: implement soft reset and hard reset
TEST=manual test with the console command.  Reset flags are set correctly.
BRANCH=NONE
BUG=None

Change-Id: I3ea4301206be6fe4e79a4b49c002c020980c516d
Signed-off-by: Myles Watson <mylesgw@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/242901
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-01-24 00:32:25 +00:00
Myles Watson
ad06ead062 nrf51: add the watchdog registers.
The definitions for the watchdog registers are needed for hard reset.

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

Change-Id: Ief73b98fbe6fc198c3eda28394e76bdf05568fef
Signed-off-by: Myles Watson <mylesgw@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/242900
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-01-24 00:32:21 +00:00
Vincent Palatin
ad03068620 lm4: workaround to force __enter_hibernate in SRAM
The new toolchain is putting again the __enter_hibernate function in
flash (.text) rather than in SRAM (.iram.text) after inlining both the
hibernate() and __enter_hibernate() function.
Workaround this issue by forcing "noinline" on __enter_hibernate().

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

BRANCH=all
BUG=chrome-os-partner:35774
TEST=make BOARD=samus dis
and check the disassembly, the __enter_hibernate is called in SRAM
through a veneer.

Change-Id: I015928ebe18ba8fd93252eece3e8a0fcf4b2a037
Reviewed-on: https://chromium-review.googlesource.com/242691
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2015-01-23 19:56:32 +00:00
Vincent Palatin
da733f3aae lm4: ignore overlapping LPC commands
If the AP ignores the LPC_ST_BUSY bit (which is software-defined) and
tries to send a second host command while the first one is still
processed, we discard it.
This doesn't prevent the host to re-write the command arguments stored
in LPC shared mem (aka LPC_POOL_CMD_DATA) but when we will call
host_packet_receive, we will have either the old arguments or the new
arguments (or even a mix of both, which is less unlikely to pass the
checksum check), and we will copy them once before calling the HOSTCMD
task. So the host command task will have a single coherent (not
changing) view of the arguments when performing its input validation.

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

BRANCH=samus
BUG=chrome-os-partner:31492 chrome-os-partner:23806
TEST=Boot Samus and play with ectool

Change-Id: I9aa1b8cdac05e323b91998188bd873826e83c274
Reviewed-on: https://chromium-review.googlesource.com/242593
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
2015-01-23 00:28:45 +00:00
Vic Yang
f2518b9f2d mec1322: Move default header location to 0x0
The current header location is too large for small SPI flash chips.
Since this value is only used for private EC SPI, it doesn't really
matter what it is. Let's just move it to 0x0.

Note that this doesn't affect shared SPI case, as we need a more
sophisticated packer for that.

BRANCH=None
BUG=chrome-os-partner:35308
TEST=Build for Glower and check the size of ec.spi.bin.

Change-Id: I96871d1677999e7cc1c7385b749563b8c09a318a
Signed-off-by: Vic Yang <victoryang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/241114
Tested-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
2015-01-17 01:00:12 +00:00
Vic Yang
1d0a7f8713 mec1322: Fix I2C interrupt bug
On boot, we shouldn't enabled I2C interrupt. The interrupt is only
enabled when we are waiting for data or transfer completion.

BRANCH=None
BUG=chrome-os-partner:35308
TEST=Boot on Glower and do i2cscan.

Change-Id: I534302ac057f2592f52d80d85cee66c35c6121d2
Signed-off-by: Vic Yang <victoryang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/241113
Tested-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
2015-01-17 01:00:07 +00:00
Vic Yang
7e8567fd5e mec1322: Clear interrupt status before enabling GPIO interrupt
Before enabling GPIO interrupts on boot, we should clear pending
interrupt status to make sure the interrupts don't fire unexpectedly.

BRANCH=None
BUG=chrome-os-partner:35308
TEST=Boot on Glower and make sure GPIO interrupts aren't triggered on
boot.

Change-Id: I2729b4a5046063e4ee4c08dcb7084a329bfdf042
Signed-off-by: Vic Yang <victoryang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/241112
Tested-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
2015-01-17 01:00:02 +00:00
Vic Yang
535bbbb774 mec1322: Specify SPI flash size in KB
For boards without a shared SPI, it's reasonable to use a SPI flash
smaller than 1MB. Change the script to allow this.

BRANCH=None
BUG=chrome-os-partner:35308
TEST=Build strago and check the size of ec.spi.bin.

Change-Id: Iabf7065d158be5f82c55e182e430858a12b18b6e
Signed-off-by: Vic Yang <victoryang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/241111
Tested-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
2015-01-16 22:58:02 +00:00
Alexandru M Stan
fe294979d6 I2C: Increase priority of i2c_init
Chipset sometimes needs I2C, therefore i2c_init should have a higher priority
than power_common_init so i2c is available by the time the chipset might be
talking to the battery.

BUG=chrome-os-partner:35502, chrome-os-partner:35173
TEST=There is no "battery not responding" message at startup on veyron
TEST=EC boot takes less than 1 second on veyron
BRANCH=none

Change-Id: Ib10b653decc7703e706d4dd1976abf0fdbc25ac2
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/241102
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-01-16 20:37:07 +00:00
Vincent Palatin
34f927724f stm32: remove useless modulo
The RTC delay is always less than a day (see the assert at the beginning
of set_rtc_alarm), so remove the useless module to save a few bytes of
flash.

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

BRANCH=samus
BUG=none
TEST=make buildall
and see the zinger firmware is smaller by 16 bytes
(more than the 8 bytes I need to submit the following CL)

Change-Id: If0374ff5897f13e69574018d2123428075b2264e
Reviewed-on: https://chromium-review.googlesource.com/240564
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2015-01-14 21:50:06 +00:00
Myles Watson
16eaf5cfde nrf51: Fix a race condition in hwtimer.c
The check for overflow was originally in __hw_clock_source_read()

If it got interrupted, it would frequently see an overflow, because
"prev_read" would be less than "now".

1 - Use the comparator to check for overflow.
2 - Only check for overflow in the interrupt handler.

BUG=chrome-os-partner:35312
BRANCH=none
TEST=make buildall -j
use the keyboard code to type
use a console command "forcetime", to force the system time to overflow soon.

Signed-off-by: Myles Watson <mylesgw@chromium.org>

Change-Id: I7005724222289ba967e89af0ce8b9ef8f90a4ae4
Reviewed-on: https://chromium-review.googlesource.com/239967
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Myles Watson <mylesgw@chromium.org>
Commit-Queue: Myles Watson <mylesgw@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-01-14 03:16:18 +00:00
Ian Chao
4ee50837a0 nuc: Add all IC specific drivers of NPCX5M5G
Add npcx_evb in board folder for testing
Add shared-spi arch support in common layer.

Modified drivers for
1. Fan.c: console command “pwmduty”.
2. Pwm.c: for the issue when set duty to 0.
3. System.c: for hw reset only during system reset.
4. Flash.c: Fixed access denied bug of the flash driver for host command.
5. Comments from Patch Set 1
6. Comments from Patch Set 3 (except sha256.c)
7. Add openocd and flash_ec support for npcx_evb
8. Add little FW and spi-flash upload FW in chip folder
9. Add optional make rules for PROJECT_EXTRA
10.Replace CONFIG_SHRSPI_ARCH with CONFIG_CODERAM_ARCH and remove changes
   in common layer sources for shared-spi arch. (except sysjump)
11.Find the root cause of JTAG issue and use workaround method
   with SUPPORT_JTAG in clock.c
12 Execute hibernate in low power RAM for better power consumption
13 Add workaround method for version console command
14 Modified coding style issues by checkpatch.pl tool

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

Change-Id: I5e383420642de1643e2bead837a55c8c58481786
Signed-off-by: Ian Chao <mlchao@nuvoton.com>
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/233742
2015-01-14 03:16:10 +00:00
Vincent Palatin
3951165fe9 hoho/dingdong: support unprotected RO partition
If the RO firmware has a different view of the protection than
the RW copy, we should not change the option bytes (write protection
settings) in RW else we will trigger a reboot loop : RW protects and reset,
then RO unprotects, resets and jump to RW, RW protects and reset again ...

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

BRANCH=samus
BUG=chrome-os-partner:35383
TEST=craft a firmware image whose RO partition doesn't include commit
42d0104 (no virtual WP, no RDP set) and RW partition has everything
including this patch, see that HoHo no longer reboots in a loop.

Change-Id: I4cbdbf25a96cb6fb7cbabc7f2d1dc76d3a2a9e36
Reviewed-on: https://chromium-review.googlesource.com/240561
Reviewed-by: Todd Broch <tbroch@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-01-14 03:16:02 +00:00