Commit Graph

1306 Commits

Author SHA1 Message Date
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
0f18989ef5 Ryu: Add support for the SPI over USB bridge
This enables the USB SPI bridge and adds Ryu specific
functions for enabling and disabling the SPI bridge.

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

BRANCH=None
BUG=None
TEST=make buildall -j
     Verify that a modified flashrom can read and write
     the AP SPI Flash.

Change-Id: I3ed2503e23c360c0de7a3aedd1d256be7e82df1e
Reviewed-on: https://chromium-review.googlesource.com/260965
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-25 16:57:33 +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
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
Vincent Palatin
179972d2f9 honeybuns: fix CC voltage thresholds
The Rp resistor on CC1 is set for a 3.0A capability,
so Vnc (no-connection voltage) is 2.45 V.

CC2 is not connected (captive cable), so for a PD source, it's identical
to being always pulled-up to 3.3V (no sink connection).

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

BRANCH=samus
BUG=chrome-os-partner:37078
TEST=connect to Samus and see PD activity

Change-Id: I8df0561cea59896d65d9be6523d4eed953851129
Reviewed-on: https://chromium-review.googlesource.com/259301
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Scott Collyer <scollyer@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2015-03-12 19:27:34 +00:00
Vincent Palatin
bbdb128eae honeybuns: fix CC line sensing ADC
The CC line is connected to the ADC 1 not 0.

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

BRANCH=samus
BUG=chrome-os-partner:37078
TEST=use the "adc" command and see the pull-up to 3.3V on CC1_PD.

Change-Id: I6327adc8ea166c4fb450c6711e17d8140fd6c71d
Reviewed-on: https://chromium-review.googlesource.com/259300
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Scott Collyer <scollyer@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2015-03-12 19:27:27 +00:00
Vincent Palatin
df8ff35f79 honeybuns: add HX3 hub configuration
Send the Cypress HX3 Hub configuration over I2C.

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

BRANCH=none
BUG=chrome-os-partner:37078
TEST=see the Hub booting in normal mode and enumerating.

Change-Id: I7e32eecd1d69ba0899b726c0405d392602e7d8b7
Reviewed-on: https://chromium-review.googlesource.com/256697
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Scott Collyer <scollyer@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2015-03-12 03:42:18 +00:00
Scott Collyer
23716f05aa honeybuns: Initial /board files
Modified version of /board/fruitpie.
Attempted to capture GPIO definitions. Other changes
consisted of modifying functions to enable compilation.
No real functionality as of yet.

TEST=Serial console and I2C functions have been verified
BUG=chrome-os-partner:37078
BRANCH=samus

Change-Id: Iedfc724a058e4220176193ef0f66e5bf45eabbd9
Signed-off-by: Scott <scollyer@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/252426
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2015-03-12 03:42:12 +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
27199e7b64 spi_flash: Add protect support for W25X40
W25X40 uses a different protection register encoding than our existing
W25Q64 code. Move the SPI ROM option to a config, and add support for
the new part.

BUG=chrome-os-partner:37688
TEST=`make buildall -j`. W25X40 protection code tested in a subsequent
commit.
BRANCH=None

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Iaaeabf42c6c62c20debc91afd2cf8671c14244c8
Reviewed-on: https://chromium-review.googlesource.com/258440
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-03-11 23:18:09 +00:00
Anton Staaf
d32be0292f Ryu: Share SensorHub UART control with Servo
Previously the EC UART connected to the SensorHub console
was being driven push/pull potentially fighting with a
connected servo.  This way servo wins, but at least we
don't drive the line in opposite directions causing a
large current flow.

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

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

Change-Id: I02b8e09af6c902b523494b757f4bc7ea4365df2e
Reviewed-on: https://chromium-review.googlesource.com/255954
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
Trybot-Ready: Anton Staaf <robotboy@chromium.org>
2015-03-10 18:52:10 +00:00
Ben Lok
9e9ccfa24b llama: enable the EC backlight override for mediatek platform.
1. Override the panel backlight enable signal from SoC in llama board,
   force the backlight off on lid close.
2. Revise the function llama_lid_event to mtk_lid_event, makes more sense.

BRANCH=master
BUG=none
TEST=lid switch to open/close, observe the LCD backlight behavior.
     the backlight should be off, when lid is close.
     the backlight should be on, when lid is open.
BOARD=llama

Change-Id: Id1bff440c8bb6cee19c82615e916b8a2f2aa62ac
Signed-off-by: Ben Lok <ben.lok@mediatek.com>
(cherry picked from commit a90516b0a5493a55536e29d550f65cc743156710)
Reviewed-on: https://chromium-review.googlesource.com/255441
Reviewed-by: Rong Chang <rongchang@chromium.org>
2015-03-09 10:41:36 +00:00
yh.huang
9eb1380d63 llama: implement battery ship shutdown mode
Support battery cut-off as host command and console command.

BUG=none
BRANCH=master
TEST=tested "cutoff" console command cuts off battery
BOARD=llama

Change-Id: Id5c67d296b7ecfac99389d5cfcdcaa79da9ad4f3
Signed-off-by: Ben Lok <ben.lok@mediatek.com>
(cherry picked from commit 0274ffd14a35b478b8efa74cdd2d3303da96ec54)
Reviewed-on: https://chromium-review.googlesource.com/255440
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-03-09 06:15:46 +00:00
Alec Berg
d09405203f samus: ryu: allow charge ramp on CDP and proprietary chargers
Modify charge ramp so that when it ramps it ramps from 500mA and
up to the maximum allowed by that supplier. Also modify Samus and
Ryu to use charge ramping for CDP and proprietary chargers due
to the possibility that they may not be able to supply the amount
that is supposed to be guaranteed by their advertisement.

BUG=chrome-os-partner:37549
BRANCH=samus
TEST=test on a proprietary charger, make sure we can ramp. test
a DCP and make sure we also ramp as before.

Change-Id: I08fd43c8f0b21aa54d114fbe5a1296c9556357e4
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/256972
Reviewed-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
2015-03-07 03:38:38 +00:00
Alec Berg
91524aca91 samus: limit input current when batt near full and 5V charger
Limit input current to 2A when battery is near full and we are using
a charger below the boost bypass threshold in order to prevent
charging noise from the charge circuit.

This also changes the threshold at which 5V ramping is allowed to
90% because this is roughly the threshold at which the battery stops
drawing full current.

BUG=chrome-os-partner:36534
BRANCH=samus
TEST=load onto samus. use battfake EC console command to test
various battery states of charge:

- With zinger, verify that at 20V we never limit input current based
on battery SOC.
- With zinger at 5V, verify that >= 90% we limit input current to
2A, and < 90% it's still 3A.
- With 5V BC1.2 DCP, verify that >= 90% we don't ramp, <90% we do.

Change-Id: I868828b5807572736ea58f62bf3596f6416533d2
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/256072
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-03-06 08:48:46 +00:00
Alec Berg
7cbc5a0186 samus_pd: disable i2cxfer console command to save space
Disable the i2cxfer console command by default to save space

BUG=chrome-os-partner:37167
BRANCH=samus
TEST=make -j buildall
From .map file, 576 bytes of flash saved

Change-Id: I0b50161ef0a49231e45c422da5042db77874aed1
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/256071
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
2015-03-06 03:50:43 +00:00
Anton Staaf
7f48c9a6b3 Ryu: Add support for AP and SH console forwarding over USB
Signed-off-by: Anton Staaf <robotboy@chromium.org>

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

Change-Id: I28c593ebd242712df00863443d96830fa06b4d6b
Reviewed-on: https://chromium-review.googlesource.com/255233
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-04 04:40:58 +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
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
4e5c20fb07 plankton: always run as UFP when in USB hub mode
When Plankton is in USB hub mode, running as DFP doesn't make sense. In
this case, ask for a data swap.

BRANCH=None
BUG=chrome-os-partner:37079
TEST=With Ryu, check Plankton is always UFP no matter it's sink or
source.

Change-Id: I7752b8c1255234a5ea726138708fe52c5fcd47b2
Signed-off-by: Vic Yang <victoryang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/254713
Tested-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Benson Leung <bleung@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
2015-03-02 10:06:24 +00:00
Alec Berg
8fe9304ae2 samus: don't unwedge charging when purposely discharging on AC
For factory testing, when purposely discharging on AC, don't
automatically detect and unwedged charge circuit.

BUG=chrome-os-partner:37171
BRANCH=samus
TEST=plug in AC and run: "ectool chargecontrol discharge". check
on ec console that battery is discharging. let sit for 3 minutes
and make sure charge circuit unwedge code never runs. run
"ectool chargecontrol normal" and make sure battery starts charging
again.

Also force discharge with "ectool chargecontrol discharge" and then
unplug and replug AC, make sure battery is not charging nor
discharging, then set mode back to normal and make sure we start
charging again.

Tested without this CL and everytime you force discharge the charge
unwedge is activated and messes everything up.

Change-Id: Icc7a504c148e1e08777e7aafce64ff4cc38a32c5
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/254722
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2015-02-28 03:46:30 +00:00
Shawn Nematbakhsh
28b1446813 samus_pd: Skip pericom detection if we're sourcing VBUS
If we're sourcing VBUS, there is no need to proceed with the pericom
debounce / reset procedure, since we know that we're not charging.

BUG=chrome-os-partner:37137
TEST=Manual on Samus. Insert USB keyboard, verify that pericom reset
doesn't occur. Insert SDP port + Apple charger, verify that pericom
reset / redetection still occurs.
BRANCH=Samus

Change-Id: I1a616f6e2287cd474b94e8fb61c19514d2ec2042
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/254140
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-02-27 02:21:31 +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
Alec Berg
f6cff1fa6b samus: make sure EC sends battery percentage to PD on change
Make sure the EC sends the battery state of charge to the PD every
time it changes.

BUG=none
BRANCH=samus
TEST=create command to fake battery percentage in
driver/battery/smart.c:

static int cmd_battfake(int argc, char **argv)
{
       char *e;
       if (argc > 1)
               batt_fake = strtoi(argv[1], &e, 0);

       return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(battfake, cmd_battfake, NULL, "", NULL);

and in battery_get_params():
       if (batt_cap > -1)
               batt_new.remaining_capacity = batt_cap;

On samus use battfake command to change battery percentage back and
forth every few seconds for minutes and make sure the PD receives
host command 0x100 and that it is still happy.

Change-Id: Ic69ab2af900fa2a38e3d2f6562675684487f556e
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/252350
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-02-25 03:32:50 +00:00
Vic Yang
accd0da789 Remove ryu_p1 board
P1 boards are not used anymore. We haven't built ryu_p1 EC for a while.
Let's get rid of it.

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

Change-Id: Ie0c0b91ce0af99a0975050935af920503ca7383a
Signed-off-by: Vic Yang <victoryang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/252340
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-02-24 03:07:59 +00:00
Alec Berg
fc144e940c samus_pd: make shmem command optional, disable on samus_pd
To save flash space, disable "shmem" console command on samus_pd
to save 128 bytes.

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

Change-Id: I0d0277a0c4a80dffd90dcbf2c3ee77eba2408c57
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/251911
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-02-24 00:27:42 +00:00
Alec Berg
72c49fc0e7 samus: change USB type-A ports to default to CDP
Change USB type-A ports to default to CDP. The port will
automatically revert back to SDP if it needs to.

BUG=chrome-os-partner:36876
BRANCH=samus
TEST=load on samus, make sure ports advertise as CDP by
connecting A to C port to charge itself (note this causes
other problems, but good enough to make sure we detect
CDP).

Change-Id: Ic09b31788557d2c6ff4292c62a2ac0168b136c64
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/251834
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2015-02-23 21:22:18 +00:00
Alec Berg
777867a40f ryu: add charge ramp module
Add charge ramp module to samus. For BC1.2 DCPs allow ramping
up to 2A, and for BC1.2 SDPs allow ramping to 1A.

BUG=chrome-os-partner:34946
BRANCH=none
TEST=tested with a variety of BC1.2 chargers, type-C only chargers,
and PD chargers to make sure we always stabilize charging at an
appropriate current limit.

Change-Id: I63d4ba38f2e137aff32831386f1bde2cc7c57850
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/249934
Commit-Queue: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2015-02-21 09:20:03 +00:00
Alec Berg
e9c6a03c8a samus_pd: remove resetting pericom 30 sec after detecting SDP
Remove resetting pericom 30 seconds after detecting SDP. This
is not helpful anymore since we have fixed pericom detection
problems and have a charge ramp for SDPs.

BUG=chrome-os-partner:36813
BRANCH=samus
TEST=connect samus A port to samus C port. this detects as
SDP and ramps to 1A, but every 30 seconds resets the pericom.
with this change it detects SDP, ramps to 1A and stays constant.

Change-Id: I2400a06d237cef8c03f921960954dcf54d93de1e
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/251583
Reviewed-by: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
2015-02-21 02:02:09 +00:00
Duncan Laurie
44adcf4dd7 samus: Only enable VCORE_PGOOD interrupt when it is valid
The VCORE_PGOOD signal to the EC goes through a buffer which is
powered by PP1050_VCCST that itself is gated by SLP_S3.  Until
this point the input is invalid and may be oscillating so only
enable it as an interrupt once we are in S3->S0 state.

BUG=chrome-os-partner:36864
BRANCH=samus
TEST=boot on samus to ensure power sequencing still works properly

Change-Id: I90ad3b578297a5194c110407be1cba2d65226290
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/251324
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-02-20 20:51:26 +00:00
Shawn Nematbakhsh
79dbd92802 samus: samus_pd: Increase task stack sizes
Since we have RAM to spare, increase the stack sizes of certain tasks
that may come close to stack overflow.

BUG=chrome-os-partner:36914
TEST=Manual on samus / samus_pd. Run task_info, verify new task stack
sizes.
BRANCH=Samus

Change-Id: Id667f963bffbf7776e7cbe07b7e7d34f4ac27398
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/251420
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-02-20 18:05:21 +00:00
Alec Berg
279e2c6386 samus: add i2c retries to backlight control
Add i2c retries to backlight control. Also check return value,
if i2c transfer fails, do not continue.

Also modified backlight control so that we only send I2C commands
when backlight chip is enabled (in S0 and lid is open).

BUG=chrome-os-partner:36803
BRANCH=samus
TEST=test suspend/resume and booting and make sure panel always
comes up.

Change-Id: I0dd71c12d0c3f64a08fb389c37f64b1b0ac16fb8
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/250670
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2015-02-20 03:00:07 +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
Alec Berg
59e366ef63 samus: initiailze boostin_voltage in extpower module
Fix complile bug, initialize local var boostin_voltage.

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

Change-Id: Ie178d3bfe164fc900b1c52a05412f75d5a090ddd
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/250820
(cherry picked from commit 54f01a6c030ed7608a4bf0d673740a0dca24a52f)
Reviewed-on: https://chromium-review.googlesource.com/250821
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-02-18 23:52:39 +00:00
Alec Berg
02d0ce1526 samus: panic reboot EC if PD MCU crashes
Use the EC to check if PD MCU has crashed. The EC knows this
by checking the PD status bits: if PD MCU was in RW, and is
now in RO, AND it did not get to RO via a sysjump, then it
must have crashed. When the EC detects this, the EC will also
panic and reboot the entire system, so that we can software
sync to a known good state.

Also, when EC panics due to PD crash, it will log panic info.

BUG=chrome-os-partner:36636
BRANCH=samus
TEST=load onto samus EC and PD, try sysjump'ing back and forth
on PD MCU console and verify EC does not do anything. Crash
the PD MCU when in RW by reboot command and crash divzero command,
and make sure the EC panics with PD crash panic message. Crash
the PD MCU when in RO (before sysjumping to RW) and make sure
EC does not panic.

Change-Id: I57961028e6b23a878b8e477a9d8e180cb121a742
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/250100
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-02-18 04:53:59 +00:00
Alec Berg
9cb03971f6 samus: add charge ramp module
Add charge ramp module to samus. For BC1.2 DCPs allow ramping
up to 2A, and for BC1.2 SDPs allow ramping to 1A.

Charge ramp is disabled when in RO and write protected.

BUG=chrome-os-partner:34946
BRANCH=samus
TEST=tested with a variety of BC1.2 chargers, type-C only chargers,
and PD chargers to make sure we always stabilize charging at an
appropriate current limit.

tested in RO and write protected, BC1.2 chargers do not ramp. when
you jump to RW it does ramp.

Change-Id: I7c36c8fb0a34139c69a475307c325f891099b3dd
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/249933
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-02-18 04:53:44 +00:00
Bill Richardson
d64bb99149 samus: Only update fan speeds every N seconds
This adds CONFIG_FAN_UPDATE_PERIOD to limit the frequency at which
the fan speeds are updated. Short version: the CPU core temp
fluctuates rapidly, causing the fans turn off and on annoyingly
often (assuming you have good hearing and are in a quiet room).

With this CL, we limit the speed changes to only once every N
seconds. N should be long enough to be less annoying, yet short
enough that the CPU doesn't overheat while we're not looking.

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

Let it sit quietly, then visit a busy webpage, then let it sit a
while. The fan speed should only change every 10 seconds or so,
not every second.

Change-Id: Id985350394f24d56dc4a1e51af09487ac643285b
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/250501
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2015-02-18 04:53:30 +00:00
Alec Berg
ac5f11bf84 pd: charge_manager: make new VBUS charge supplier
Make new VBUS charge supplier for Samus and Ryu which allows
default 500mA charging when VBUS is present. Before this was
accomplished via the type-C supplier, but type-C supplier should
only be used for 1.5A and 3A pull-up. VBUS supplier is lowest
priority so that any other supplier will take precedence over
the default charging rate.

This work is done in preparation for charge_ramp module where
we don't want to ramp for typeC supplier.

BUG=chrome-os-partner:34946
BRANCH=samus
TEST=make sure we can boot without battery on samus, and test
other chargers including legacy chargers, zinger, and donette.

Change-Id: I89f1e9520e4bf9e5debbaf8dd2de1262154eecf8
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/250312
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-02-18 04:53:12 +00:00
Alec Berg
f41d33b1d7 samus: avoid attempting unwedge charge circuit if VBUS is at 5V
Change unwedge code to not attempt unwedging circuit if VBUS is
at 5V because the circuit can't wedge itself at 5V. If BQ PROCHOT
is high, we should just read it to clear it, and move on.

BUG=chrome-os-partner:36081
BRANCH=samus
TEST=test with ramp code. make sure ramp never gets stuck at
minimum value because we are in the middle of unwedging the
circuit when ramp starts.

also test that manually wedging charge circuit with zinger using
"charger voltage 7000" is still recovered from.

Change-Id: I209bf324eab39bdca1948b7764870a909ea480c8
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/250463
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2015-02-18 04:53:05 +00:00
Alec Berg
aaa7625681 samus: disable i2cscan console command to save space
Disable the i2cscan console command by default to save space

BUG=none
BRANCH=samus
TEST=make -j buildall
From .map file, 512 bytes of flash saved

Change-Id: I4bcb50b00e843abbc3523a3e0d4cc599a1e01d3a
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/249850
Reviewed-by: Vic Yang <victoryang@chromium.org>
2015-02-18 04:52:56 +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
Alec Berg
275606d104 samus: avoid waking extpower task until task has been initialized
Fix booting without battery by avoiding waking the extpower task
until it has run extpower_board_hacks() the first time.

The problem was if there was no battery and AC was attached,
extpower_board_hacks() would run twice on boot, once in extpower
task initialization, before the while(1) loop, and a second time
due to the AC_PRESENT interrupt. This would cause
extpower_board_hacks() to think that AC had transitioned from 1
to 1, which represents a glitch on ACOK, so it would disable
charging, thus causing us to lose power.

BUG=chrome-os-partner:35570
BRANCH=samus
TEST=load on a samus and boot with and without battery

Change-Id: Idf6d0022f7dbedbb66a2fbe1c2b7dd885eabc43b
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/250301
Reviewed-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2015-02-17 20:53:05 +00:00
Alec Berg
ada0cc90a4 samus: increase extpower task stack size
Increase extpower task stack size due to occasional stack
overflow in extpower task on plugging/unpluggin AC.

BUG=chrome-os-partner:36760
BRANCH=samus
TEST=load onto samus, connect/disconnect a bunch of times
and check high water mark on stack usage: 368/512

Change-Id: I4531176ce6f15356a2267cdecf907a7694567da9
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/249920
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-02-14 20:21:30 +00:00
Shawn Nematbakhsh
96536de3f4 pd_log: Add command to request PD MCU to write a log
When we find that charging is in a wedged state, we may wish to write a
PD log entry, but the PD MCU cannot detect such a state on its own.
Therefore, add a new command to ask the PD MCU to write a log of a given
type, and add a new board-specific custom log event.

BUG=chrome-os-partner:36668
TEST=Manual on samus:
./ectool --dev=1 pdwritelog charge 0
./ectool --dev=1 pdwritelog charge 1
./ectool --dev=1 pdwritelog 1 0
./ectool --dev=1 pdwritelog 2 0
./ectool --dev=1 pdlog
Verify log output matches expectation:
2015-02-12 11:12:49.290 P0 SRC
2015-02-12 11:12:49.296 P1 SNK Charger PD 20286mV max 20000mV / 3000mA
2015-02-12 11:12:49.303 P0 New connection
2015-02-12 11:12:49.310 P0 Board-custom event
--- END OF LOG --
Also, verify kernel logging of wedged event:
[  181.378420] PDLOG 2015/02/12 19:13:44.019 P0 Event 02 (0000) []
Also, trigger wedged state on Samus and verify log entry is written.
BRANCH=Samus
Change-Id: I55c7c839cf8300fcd3931dccdaaf16c1065e31a8
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/248981
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-02-12 23:08:45 +00:00
Alec Berg
abbcf41529 samus: unwedge charge circuit if not charging for long time
This is another workaround for charge circuit wedging. It appears
that the BQ PROCHOT is not entirely reliable at detecting charge
circuit wedged, so let's take a big hammer to this and say if
we have a >5V charger and we haven't been charging for a while,
then attempt to unwedge the charge circuit. Only impact on user
is the battery won't charge quite as fast since we stop charging
briefly to unwedge the circuit.

BUG=chrome-os-partner:36081, chrome-os-partner:36620
BUG=chrome-os-partner:36636
BRANCH=samus
TEST=remove the PROCHOT check and wedge the circuit using "charger
voltage 7000" and make sure that we unwedge after 10s (or 2min
if we never recovered from last time).

Change-Id: I6a0d83aef5fcfdecaeb85367d8207aeea7a99c06
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/248940
Reviewed-by: Shawn N <shawnn@chromium.org>
Commit-Queue: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
2015-02-12 23:08:41 +00:00
Todd Broch
7c1f189edc pd: DRP: VCONN should be off at start of pd task.
VCONN should be off at the start of pd task.  This is handled
initially by the defaults in gpio.inc.  However in the case of a
sysjump after a RW only firmware update the previous state would be
preserved.

This in turn would allow us to evaluate polarity incorrectly if an
accessory was connected in the CC2 polarity and subsequently enable
both VCONNs which would leave the port with both CCx lines at 3.3V.

This change adds a new function, pd_config_init, which initializes
VCONN(s) to off.  Future CLs will evaluate other PD related GPIOs that
may be left unitialized as a result of sysjump.

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

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

1. Boot samus w/ samus_pd in RO
2. connect hoho | dingdong in CC2 polarity to type-C port
3. sysjump to RW
4. unplug / plug hoho | dingdongs

No longer see both VCONNs enabled.

Change-Id: Ia53c06ea8face4da6829f9667f4f44a9034183be
Reviewed-on: https://chromium-review.googlesource.com/248831
Trybot-Ready: Todd Broch <tbroch@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Alec Berg <alecaberg@chromium.org>
2015-02-12 23:08:37 +00:00
Alec Berg
98345fdfc1 samus: fix won't charge after zinger plugged in during EC reboot
Fix bug recently introduced in 1ab9aac that causes some units to not
charge after an EC reboot with zinger plugged in. The problem is that
we don't log the previous state of ACOK on initialization of the
extpower task. So, the PD MCU gets stuck in charge state NONE when
you unplug zinger because the EC thinks that ACOK transitioned from
low to low.

Fixed in two ways: first, the EC stores the initial state of ACOK when
extpower task first runs. second, changed extpower_board_hacks() to
run the same code when ACOK goes from low to low as it does when it
goes high to low.

BUG=chrome-os-partner:36596
BRANCH=samus
TEST=Found a unit that reliably shows the problem. loaded this fix in
RO and ToT in RW. sysjump RW with AC plugged in, then when you unplug
AC, the PD goes to chgstate NONE and won't ever charge on subsequent
attaches. sysjump RO with AC plugged in, then when you unplug AC, the
PD acts as normal and goes to chgstate NONE and then 5V, and will
allow charging every time AC is subsequently attached.

Change-Id: I4124535b17d43a5711586ff2894df67a3bd49ec6
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/248170
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-02-10 23:07:20 +00:00