Commit Graph

1668 Commits

Author SHA1 Message Date
Vic Yang
cbee574e64 Unit test for queue implementation
BUG=chrome-os-partner:19236
TEST=Pass the test.
BRANCH=None

Change-Id: I575e4a9abfd9431e3b74c36da8c3d69285e5c0fb
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/58032
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
2013-06-10 01:48:46 -07:00
Vic Yang
a9541220dc Only waste 1 byte in queue buffer
For simplicity of the code, we don't allow (head == tail) when the queue
is full. But currently we are wasting the size of a single unit, while
we can actually just waste 1 byte. Let's fix this.

BUG=None
TEST=Pass the unit test.
BRANCH=None

Change-Id: Id09c20a9345ebb3ec0cad659afe36e25b422e688
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/58058
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
2013-06-10 01:48:44 -07:00
Vic Yang
8bed9853d7 Bug fix of queue empty slot calculation
Current implementation of queue_has_space doesn't handle the case where
queue tail has wrapped around the end. This CL fixes the bug.

BUG=None
TEST=Pass the test in the following CL.
BRANCH=link

Change-Id: I774f388081af50f0e930a6cbc3a723da1c8283b0
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/58031
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
2013-06-09 21:33:17 -07:00
Bill Richardson
149a8457aa Enable ADC charger current monitor for Slippy
The IOUT pin of the smart battery charger can be used to monitor the AC
adapter current (default) or the battery charging current.

BUG=none
BRANCH=none
TEST=manual

Discharge the battery a bit, and connect to the EC console. With the AC
power plugged in, the "battery" command should show charging status,
including current.

The "adc" command will display the A-D converters, including the current
measurement. For example:

  > battery
    Temp:      0x0b88 = 295.2 K (22.1 C)
    Manuf:     SMP-COS20
    Device:    OC2
    Chem:      LION
    Serial:    0x0005
    V:         0x4130 = 16688 mV
    V-desired: 0x41a0 = 16800 mV
    V-design:  0x39d0 = 14800 mV
    I:         0x008e = 142 mA(CHG)
    I-desired: 0x0080 = 128 mA
    Mode:      0x6001
    Charge:    98 %
      Abs:     94 %
    Remaining: 1871 mAh
    Cap-full:  1923 mAh
      Design:  2000 mAh
    Time-full: 0h:23
      Empty:   0h:0
  >
  > adc
  ADC channel "ECTemp" = 317
  ADC channel "ChargerCurrent" = 455
  >

That current is significantly higher than the "I:" reported by the "battery"
command. But look at the charger options:

  > sbc 0x12
  0x7904 (30980)
  >

Bit 5 controls the IOUT Selection. When clear, it monitors the current from
the AC adapter. Set bit 5 to monitor the current provided to the battery:

  > sbc 0x12 0x7924
  > adc
  ADC channel "ECTemp" = 318
  ADC channel "ChargerCurrent" = 128
  >

That matches what the smart battery sees.

Change-Id: I2fe351304421dfb22d83ef13d416aa44c9f56e8a
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/57940
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-06-07 13:13:48 -07:00
Bill Richardson
f32ad15e37 Fix broken ADC gpio configuration for lm4
The ADC pins were being misconfigured for quite a while now. Let's fix 'em.

BUG=none
BRANCH=link
TEST=none

The effect was that the adc values that measure GPIO pins were less
accurate. Since no one noticed, there's probably not much that can
be done to test it.

Change-Id: I9def4eb95c89f72e5df0721e6153c8caa3ef8e2a
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/57939
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-06-07 12:25:33 -07:00
Bill Richardson
cf5b6daee3 Initial support for Slippy battery
This adds the initial support for Slippy's battery. The data I have is
unclear and incomplete, so this is NOT the final form. It seems to work
right now, and hasn't caught fire or anything, but it will need futher
tweaks.

BUG=chrome-os-partner:19976
BRANCH=none
TEST=manual (and watch it!)

Connect the EC console and watch what happens. You should see the battery
charging, discharging, etc. Keep an eye on it, though, and never leave it
unattended when on AC - we don't have the full data sheets available yet.

Change-Id: Id9bf93dc04a1399a9cdbc2156b3fac74be62038f
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/57814
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-06-07 10:52:14 -07:00
Bill Richardson
710cadde7c Improve 'sb' command, add 'sbc' command
The sbc command can be used to get/set registers from the smart battery
controller. The sb command already does that for the smart battery itself.

BUG=none
BRANCH=none
TEST=manual

Try it out.

Change-Id: Idaea451e58988ab2d6bc40164721cb5577d903af
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/57813
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-06-07 10:52:13 -07:00
Bill Richardson
c848e32161 Add some debugging messages for unresponsive batteries
BUG=none
BRANCH=none
TEST=none

Change-Id: Id56c2b180c670115819dd29c85ecc3d0e96bd26f
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/57812
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-06-07 10:52:12 -07:00
Bill Richardson
124b2f1492 Add support for TI's Smart Battery Charger BQ24707A
This is very similar to the BQ24725. There are just enough differences to
require a separate file.

BUG=chrome-os-partner:19976
BRANCH=none
TEST=none

Nothing to test until it's enabled.

Change-Id: I3247fcfde93ac75f5f9790acadc7feca28038608
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/57811
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-06-07 10:52:11 -07:00
Bill Richardson
0fdfcda963 Separate battery selection from charging logic
Just tweaking the build.mk file so that other batteries can be specified
for use by the same charging logic.

BUG=none
BRANCH=none
TEST=none

Change-Id: I01b39a6ffc4091b9b7824cf1759b36168f6f5701
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/57810
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-06-07 09:46:10 -07:00
Bill Richardson
57c7d4103f Change i2c port configs to make BDS the special case, not Link.
This matches our reference design for the EC's i2c GPIOs.

BUG=none
BRANCH=none
TEST=none

Change-Id: I8320b6234e2db8d645d0c4d4e982e3817da9f5e7
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/57809
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-06-06 14:42:25 -07:00
Bill Richardson
4ff299e29d Send STOP to clear bus when I2C encounters an error.
Reading from a nonexistant/nonresponsive smart battery fails (as it should).
But then it leaves the i2c clock line low, so that subsequent i2cscan
commands fail too.

This change just sends a STOP to clear the bus when an i2c error occurs.

BUG=chromium:247037
BRANCH=none
TEST=none

Change-Id: I599bed7149ed3dd3748f1a939c2ea8fdf65e3d72
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/57808
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-06-06 14:42:25 -07:00
Bill Richardson
d0d1564434 ectool prefers /dev/cros_ec, then falls back to i2c, lpc
This is preparation for the common userspace EC interface. If/when that
appears, this will be ready.

BUG=chromium:239197
BRANCH=all
TEST=manual

Build, install, run it. Shouldn't be any change.

Change-Id: I9fa78515ec5443ba659f10a66bbaadcb7f4802b0
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56131
2013-06-05 14:12:23 -07:00
Randall Spangler
26475135b5 Pit stays on HSI instead of using PLL with the same 16MHz frequency.
Leaving the PLL turned off saves about 0.5 mW (and also presumably
speeds up boot a tiny amount, since we don't need to wait for the PLL
to lock).

BUG=chrome-os-partner:19951
BRANCH=none
TEST=system boots normally.  power consumption on P1.8V_MICOM rail is lower.

Change-Id: I93dc1efabbf6c6b0b5a43ffebe1068d18c689bef
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/57645
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-06-05 14:12:13 -07:00
Randall Spangler
d5fece8ce5 Re-enable task profiling on pit
This costs 232 bytes RAM; we still have over 6KB free.

BUG=chrome-os-partner:19945
BRANCH=none
TEST=taskinfo shows timing and interrupt counts

Change-Id: I1c4e4eac44b48c66b075b8ea209b4748c55b7fcb
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/57511
2013-06-05 14:12:12 -07:00
Vic Yang
ea32f132f7 spring: Guard battery cut-off command with lock
The two I2C commands for battery cut-off must be sent out back to back.
Thus we need to guard them with I2C port lock to prevent being
preempted.

BUG=chrome-os-partner:19901
TEST=Check battery cutoff still works.
BRANCH=spring

Change-Id: Iac51037432b108d4cac29d5c73cafa9ce2310b12
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/57598
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-06-05 11:25:10 -07:00
Vic Yang
3e0e15d185 Accept a command if it's a full match
On Spring, we now have commands 'i2c' and 'i2cscan'. Currently if we
type 'i2c', it's rejected as it's also the prefix of 'i2cscan'. Since
'i2c' is a full match of a legal command, we should accept it.

BUG=None
TEST=On Spring, check 'i2c' invokes 'i2c' command, and 'i2cs'/'i2cscan'
invokes 'i2cscan' command. Also check 'i2' is still rejected.
BRANCH=all

Change-Id: I65c4c148a5a3e9b025554fa8165ba76da7bc312f
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/57576
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-06-05 11:25:09 -07:00
Vic Yang
127b053109 Reset TSU6721 on initialization
Sometimes TSU6721 falls into a weird state where video dongle is
recognized as non-standard charger. Let's reset TSU6721 when EC boots,
so that we are guaranteed to have a clean state after initialization.

BUG=None
TEST=Keep doing Power+F3 reset. Doesn't see weird state anymore.
BRANCH=spring

Change-Id: Id09bb1721ae79804dc9b3300a2f3def850c2f70a
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/57575
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-06-05 11:25:08 -07:00
Vic Yang
d07b0d5a5f spring: Update device type on video power change
This is needed to properly notify kernel of power changes.

BUG=chrome-os-partner:19925
TEST=Attach/remove power from video dongle, and see device type changes.
BRANCH=spring

Change-Id: Ic91ad43ed934be021689c4c4557914e6163e06f8
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/57569
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-06-05 11:25:07 -07:00
Aaron Durbin
72a69f6669 haswell: fix driving of WAKE# pin on power button press
The WAKE# pin was being driven low when the power button was
pressed and no other events were occuring. This causes a PCIE
wake event to be observed on the host. This is incorrect. Therefore
only assert the WAKE# pin when any other event but the power button
has occured.

The implementation introduces a board-specific callback,
board_process_wake_events(), which handles the specific logic
for the wake events.

BUG=chrome-os-partner:19810
BRANCH=None
TEST=Manual. Both power button wakeup and lid events were tested. The
     presence of PCIE Wake no longer exists for S5->S0 transitions.

Change-Id: If1311ccc36629b04d2d9e021c3e103e379836a3a
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56970
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2013-06-04 10:08:30 -07:00
Dave Parker
7abe696281 Peppy: Add GPIOs for power and battery LEDs
Based on 2013-05-23 schematic.

BUG=chrome-os-partner:19640
BRANCH=none
TEST=none

Signed-off-by: Dave Parker <dparker@chromium.org>

Change-Id: Iacb3bf09e7fc6b0d58148f014bc8e4e721151228
Reviewed-on: https://gerrit.chromium.org/gerrit/56502
Tested-by: Dave Parker <dparker@chromium.org>
Reviewed-by: Shawn Nematbakhsh <shawnn@chromium.org>
Commit-Queue: Dave Parker <dparker@chromium.org>
2013-06-03 15:30:41 -07:00
Dave Parker
b4a9589187 Add LED GPIOs for slippy.
BUG=None
TEST=Manual. From ec console:
  gpioset BAT_LED0_L 0
  gpioset BAT_LED1_L 0
BRANCH=slippy
Signed-off-by: Dave Parker <dparker@chromium.org>

Change-Id: Icd4bf714f738507227d3476696eb8e17eff7d685
Reviewed-on: https://gerrit.chromium.org/gerrit/57282
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Dave Parker <dparker@chromium.org>
Tested-by: Dave Parker <dparker@chromium.org>
2013-06-03 14:34:16 -07:00
Vic Yang
80105a9556 Enable flash unit test on emulator
BUG=chrome-os-partner:19236
TEST=Pass all tests
BRANCH=None

Change-Id: I09276292499b94b2d4810830de51e4c63a9b7342
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56704
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-06-03 14:34:10 -07:00
Vic Yang
1806f52195 Print error message before PMU hard reset
Hard-reset triggers a pulse on the PMIC_RESET pin but this is hard to
see when debugging. By printing error message explicitly before
resetting the board, it's easier to tell why the board is resetting.

BUG=chrome-os-partner:19778
TEST=Trivial change. Build and boot on Spring. Make sure system is
alive.
BRANCH=spring

Change-Id: I26b749af2f8760339373c3e4db46c59d7b0d039e
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/57101
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-06-03 14:32:49 -07:00
Randall Spangler
a47bda8042 Make flash_ec capable of writing to an incorrectly-protected STM32
If EC-RO protects itself via the WRPx option bytes, flash_ec will fail
to reprogram it.  And if EC-RO is broken/unbootable, it won't be able
to clear the WRPx option bytes itself when it sees the write protect
GPIO is not asserted.

Add the -u flag to stm32mon so that it will automatically attempt to
unprotect the flash via the option bytes.

BUG=chrome-os-partner:19723
BRANCH=none
TEST=enable write protect GPIO.  Then from console, 'flashwp enable'.
     Then from the chroot:
        ./util/flash_ec --board=pit --ro --image=build/pit/ec.RO.flat
     That should successfully reflash the board.

Change-Id: Ic356d29104294d04d5e2a36dc75fd0206b89bd34
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56659
2013-06-03 14:32:39 -07:00
Randall Spangler
b490e866dc Clean up flash section defines and increase lm4 image size
The firmware defines had two almost-identical sets.  Coalesce into one
consistent set.

Link had 256 KB flash, but only allowed 2 80KB images.  Future
LM4-based platforms (slippy/peppy/falco/etc) will now use the entire
flash, with RO=124KB, pstate=4KB, RW=128KB.  This matches what the
STM32 platforms do, where pstate is contiguous with the RO firmware.

No functional change to STM32-based platforms.

BUG=chrome-os-partner:19176
BRANCH=none
TEST=build all platforms and dump_fmap ec.bin.
  - stm32-based platforms should report RO=61440@0, RW=65536@0x10000
  - link should report RO=81920@0, RW=81920@0x14000
  - slippy should report RO=129024@0, RW=131072@0x20000

Change-Id: I20b1d95c16250d9a5d228ead06eef03d96548823
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56655
2013-06-03 14:32:38 -07:00
Vic Yang
e52aba6eca Make ectool LED command more generic
This adds the option to specify which LED to control as well as the
ability to query the supported LED color on the board.

BUG=chrome-os-partner:19745
TEST=On Spring:
       - ectool led 0 query  -> See the max value for R, G, Y is 0x80.
       - ectool led 1 query  -> See error message.
       - ectool led 0 yellow -> See LED turns yellow.
       - ectool led 0 green=0x40 red=0x40 -> See green and red lit up.
       - ectool led 0 auto   -> See LED turns off (without charger.)
BRANCH=spring

Change-Id: Ibdde2f7450122f59383dad1030a0a2a985386f73
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56877
2013-06-03 14:32:16 -07:00
Duncan Laurie
d6d3b7cbc5 Add wireless switch control for WWAN
Haswell devices have EC control of the WWAN power rail.
Expose a new wireless switch enable flag for this under
the existing wirless enable command.

This change also abstracts the wireless enable function
to call a per-board handler so the different boards can
do the right thing based on their GPIO setup.

The haswell boards will switch WLAN radio and WWAN power
rails based on the switch inputs.  These boards do not have
EC control of bluetooth radio/rail power.

WLAN (power and radio) still defaults to enabled.  Disabling
with ectool will turn off the radio but keep the power enabled
in order to prevent the PCIe device from disappearing.

WWAN (power) still defaults to disabled.  Disabling with
ectool will turn off the power rail.

BUG=chrome-os-partner:19871
BRANCH=none
TEST=manual: boot on slippy

DEFAULT:

> ectool gpioget pp3300_wlan_en
GPIO pp3300_wlan_en = 1
> ectool gpioget wlan_off_l
GPIO wlan_off_l = 1
> ectool gpioget pp3300_lte_en
GPIO pp3300_lte_en = 0

ENABLE WWAN:

> ectool wireless 0x7
Success.
> ectool gpioget pp3300_lte_en
GPIO pp3300_lte_en = 1

DISABLE WLAN (radio):

> ectool wireless 0x7
Success.
> ectool gpioget pp3300_wlan_en
GPIO pp3300_wlan_en = 1
> ectool gpioget wlan_off_l
GPIO wlan_off_l = 0

Change-Id: I6f760b8cf5ab47d8f7f0dd8cd4d3e6563464043e
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/57215
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2013-06-03 14:32:07 -07:00
Duncan Laurie
f8e12df9df slippy/falco: Add back in flash and hiberantion setup code
These were tested to make sure they are not responsible for
bricking boards.

The flash code is necessary for software sync, and it is
essential to be able to update boards without servo.

The hibernate setup code was breaking jumping between images
and the passing of data between the images -- needed for
SW SYNC but also needed for things like "reboot ap-off".

BUG=chrome-os-partner:19366
BRANCH=none
TEST=manual: emerge-slippy chromeos-ec, flash+boot, update again via SW Sync

Change-Id: Ib1363b353f18b21e0cad3209783e1e0b4ff24e86
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56820
2013-06-03 14:32:06 -07:00
Vic Yang
6759fdc3e6 Extend TSU6721 BCD timer to 3.6 seconds
If the user plug in the charger really slowly, VBUS and GND will make
contact before ID pin. Currently timer is set to fire in 0.6 seconds,
which means ID pin need to make contact within 0.6 seconds after VBUS
make contact. This is causing chargers to be recognized as non-standard
charger. Let's extend this to 3.6 seconds.

BUG=chrome-os-partner:19765
TEST=Plug in a charger half-way through and see device type 0x20000.
     Wait for 3.6 seconds, and see it changes to 0x60000.
TEST=Plug in a charger half-way through, wait for 2 seconds, and then
     plug it in all the way. See device type 0x20010.
TEST=Plug in a charger to the end. See device type 0x20010 immediately.
BRANCH=spring

Change-Id: I46c408e7bc733fe4f3655db253f4065a4f12ee1a
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56772
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-05-28 12:54:03 -07:00
Vic Yang
5d66f23d21 spring: Keep system power on sysjump
If the AP is already on, the kernel should handle low-power event. We
shouldn't power off the system on sysjump.

BUG=chrome-os-partner:18318
TEST=None
BRANCH=spring

Change-Id: I4e80c61a25d2fa503d0c97e22dc2f4ad9c44f716
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56706
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-05-28 12:54:02 -07:00
Vic Yang
eb18f65941 spring: Fix a bug that 3.3V output is on after video dongle detached
Also remove the TODO for using ADC watchdog, which proves to cause ID
voltage shift.

BUG=None
TEST=None
BRANCH=spring

Change-Id: Ic664c478c3c6751f84ad1aacd81a8c286deebeb9
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56677
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-05-28 12:54:01 -07:00
Vic Yang
f4654f6d99 Support emulator reboot
When emulator exits with reboot exit code, we should run the emulator
again.

BUG=chrome-os-partner:19235
TEST=Enable flash test on emulator. See it reboots.
BRANCH=None

Change-Id: Id0b4c21c1be7ae978be8b336a3498181d881c715
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56701
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-05-28 12:53:55 -07:00
Vic Yang
a46d5e7f37 Fix a bug in emulator persistent storage
The path string is not terminated properly, causing occasional crashes.

BUG=chrome-os-partner:19235
TEST=Dump the path and check it's correct.
BRANCH=None

Change-Id: I9ccbd565ce68ffdad98f2dd90ecf19edf9805ec0
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56700
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-05-28 12:53:55 -07:00
Vic Yang
83ea309f44 Add assertion support to emulator
This enables ASSERT() for easier debugging.

BUG=chrome-os-partner:19235
TEST=Add ASSERT(0) in lid_sw test and see error message:
        ASSERTION FAIL: test/lid_sw.c:91:run_test - 0
BRANCH=None

Change-Id: I7df7d5984e5d787fdc5ad2b6b24fec669e95c97e
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56691
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-05-28 12:53:54 -07:00
Vic Yang
dcc9d9d735 Remove breathing LED effect from LP5562 LED driver
We are now using solid yellow for both charging and battery assist mode.
No need to use breathing yellow effect anymore.

BUG=chrome-os-partner:19747
TEST=Manual
BRANCH=spring

Change-Id: I9574ac7ef7137fc1d0ebe84316756fa28e9a84aa
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56732
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-05-28 12:53:52 -07:00
Vic Yang
3501ccffdb spring: Prevent showing green LED when we are actually charging
When we use about the same amount of power as what the charger provides,
we sometimes show green LED. We should avoid this when the battery is
not full.

BUG=chrome-os-partner:19746
TEST=Manual
BRANCH=spring

Change-Id: Id31762aefe22535de64f63a023c35995a3725ef8
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56724
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-05-28 12:53:52 -07:00
Vic Yang
87d8f8e5b1 Add ectool command to control LED color
This provides a way to control LED color with ectool. We can either set
the color or switch back to automatic control.

BUG=chrome-os-partner:19745
TEST=ectool led red   -> LED turns red.
     ectool led green -> LED turns green.
     Unplug charger   -> LED turns off.
     ectool led green -> LED turns of and shows green.
     ectool led auto  -> LED back to normal.
BRANCH=spring

Change-Id: I0b455f34cea448660fe44a5fecaac1cb084f8144
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56721
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-05-28 12:53:51 -07:00
Vic Yang
99e3fc93e6 Cache LP5562 LED color
When we try to set LP5562 LED to the same color as it is currently, we
should just skip the I2C commands. Let's cache its current color so that
we don't waste time on unnecessary I2C transactions.

BUG=chrome-os-partner:19705
TEST=Set LED color manually on spring and doesn't see it change. Unplug
and plug in the charger, and see LED goes back to yellow after few
seconds.
BRANCH=spring

Change-Id: I87e3cf7d53bccc45048ea64dad9925a362cddab7
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56716
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-05-28 12:53:50 -07:00
Vic Yang
455fc92b19 spring: Avoid over-current on the same PWM duty cycle
While in fast mode, we step on the same PWM duty cycle which caused
over-current. We should avoid this.

BUG=chrome-os-partner:18301
TEST=None
BRANCH=spring

Change-Id: Ib22eb7244d1f6173d4486dce7b85a55678318490
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56674
2013-05-25 21:51:08 -07:00
Shawn Nematbakhsh
006731860e falco / peppy: Fix EC build.
Falco / Peppy EC builds were previously broken because the board
creation came after I502ab033c3eb36661cc3ee97320874b3fbf6fc0d was put up
for review, but before it landed. Apply the same changes as slippy board
to fix the build.

BUG=chrome-os-partner:15613
BRANCH=none
TEST=emerge-{falco/peppy} chromeos-ec

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>

Change-Id: I7299343835ef8d08c6a2d2c7b4f797dc968a15d7
Reviewed-on: https://gerrit.chromium.org/gerrit/56668
Reviewed-by: Dave Parker <dparker@chromium.org>
Tested-by: Shawn Nematbakhsh <shawnn@chromium.org>
Commit-Queue: Shawn Nematbakhsh <shawnn@chromium.org>
2013-05-25 21:51:07 -07:00
Randall Spangler
c2dec85151 More low-level flash interface cleanup
Setting at-boot protection always used the same start/range
(RO+PSTATE), so no point in passing that to the physical layer as
params.

flash_dataptr() should take a pointer to const data.

No functional changes; just rearranging code.

BUG=chrome-os-partner:15613
BRANCH=none
TEST=build pit, link, spring

     - flashinfo -> (no flags)
     - enable WP (via screw or dut-control)
     - flashinfo -> wp_gpio_asserted
     - flashwp enable
     - flashinfo -> wp_gpio_asserted ro_at_boot
     - flashwp now
     - flashinfo -> wp_gpio_asserted ro_at_boot all_now (and possibly ro_now)
     - flashwp disable -> fails
     - flashinfo -> wp_gpio_asserted ro_at_boot all_now
     - reboot ap-off
     - flashinfo -> wp_gpio_asserted ro_at_boot ro_now
     - disable WP (via screw or dut-control)
     - reboot
     - flashinfo -> ro_at_boot
     - flashwp disable
     - flashinfo -> (no flags)

Change-Id: Ifd6553dc907fa6fafce81b56af0c648ac6d6bee1
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56628
2013-05-24 16:27:49 -07:00
Randall Spangler
1d28ca7cf1 Move flash_get_protect() and flash_set_protect() to flash_common.c
Much more flash code is now common between platforms, for more
consistent behavior and easier testing.

Also change STM32L to use pstate, the same way LM4 and STM32F do.

BUG=chrome-os-partner:15613
BRANCH=none
TEST=build pit, link, spring; do

 - flashinfo -> (no flags)
 - enable WP (via screw or dut-control)
 - flashinfo -> wp_gpio_asserted
 - flashwp enable
 - flashinfo -> wp_gpio_asserted ro_at_boot
 - flashwp now
 - flashinfo -> wp_gpio_asserted ro_at_boot all_now (and possibly ro_now)
 - flashwp disable -> fails
 - flashinfo -> wp_gpio_asserted ro_at_boot all_now
 - reboot ap-off
 - flashinfo -> wp_gpio_asserted ro_at_boot ro_now
 - disable WP (via screw or dut-control)
 - reboot
 - flashinfo -> ro_at_boot
 - flashwp disable
 - flashinfo -> (no flags)

Change-Id: Iccd098786454ad9b72b4e5f9f312d86819a0c8eb
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56109
2013-05-24 16:27:49 -07:00
Randall Spangler
b144a584af Remove 64-byte workaround from STM32L flash writing
This was left over from ancient code where host commands only had a
64-byte payload, and page writes need to happen in 128-byte
increments.  This is no longer an issue with SPI host interface.

Also added capability for word writes, since that'll be necessary for
writing pstate (in the next CL).

BUG=chrome-os-partner:9526
BRANCH=none
TEST=hack flashwrite command in flash_common.c to allow write size = 4 bytes
    flasherase 0x1fc00 0x400
    flashwrite 0x1fc00 0x100 -> success; uses fast path
    flashwrite 0x1fd00 4 -> success; uses word-write path

Change-Id: I61434d8f714ea46deb65cadd82c45a61ad0ce68b
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56627
Reviewed-by: Simon Glass <sjg@chromium.org>
2013-05-24 16:27:48 -07:00
Dave Parker
3443478d76 Create board configuration for peppy bringup
This change copies the slippy board configuration as a starting
point for peppy. This change is essentially the same as
https://gerrit.chromium.org/gerrit/55820

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

Tested on slippy as there are no peppy-specific changes yet.

  cros_workon --board peppy start chromeos-ec
  emerge-peppy chromeos-ec
  ~/trunk/src/platform/ec/util/flash_ec --board peppy

Signed-off-by: Dave Parker <dparker@chromium.org>

Change-Id: I4c5f7a77fa55a6364effe838f7a656d56bfad9fb
Reviewed-on: https://gerrit.chromium.org/gerrit/56332
Reviewed-by: Olof Johansson <olofj@chromium.org>
Commit-Queue: Dave Parker <dparker@chromium.org>
Tested-by: Dave Parker <dparker@chromium.org>
2013-05-23 15:58:51 -07:00
Randall Spangler
a1006865e7 Move write protect GPIO handling to flash module
Write protect signal naming is now consistent across boards.

New CONFIG_WP_ACTIVE_HIGH is present on systems where the write
protect signal is active-high (e.g. Link).  This will be used in the
next CL, which moves flash_get_protect() to flash_common.c

BUG=chrome-os-partner:15613
BRANCH=none
TEST=flashinfo properly reports WP signal status

Change-Id: I502ab033c3eb36661cc3ee97320874b3fbf6fc0d
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56087
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-05-23 11:08:44 -07:00
Randall Spangler
bd8fec9bae Move flash persistent state to flash_common
Persistent state is needed by all platforms to hold the
protect-ro-at-boot flag.  STM32F100 and LM4 implementations were
near-identical, and are now common code (with one #ifdef to handle the
single place where they weren't).

STM32L doesn't use pstate yet, but it'll need to.  I can't simply
store the protect-ro-at-boot flag inside the WRP registers themselves
because they're still writable in EC-RW.  The change to STM32L to use
pstate is coming next.

BUG=chrome-os-partner:15613
BRANCH=none
TEST=build pit, link, spring; on link and spring, do

 - flashinfo -> (no flags)
 - enable WP (via screw or dut-control)
 - flashinfo -> wp_gpio_asserted
 - flashwp enable
 - flashinfo -> wp_gpio_asserted ro_at_boot
 - flashwp now
 - flashinfo -> wp_gpio_asserted ro_at_boot all_now (and possibly ro_now)
 - flashwp disable -> fails
 - flashinfo -> wp_gpio_asserted ro_at_boot all_now
 - reboot ap-off
 - flashinfo -> wp_gpio_asserted ro_at_boot ro_now
 - disable WP (via screw or dut-control)
 - reboot
 - flashinfo -> ro_at_boot
 - flashwp disable
 - flashinfo -> (no flags)

(Note that on Spring you'll need to 'forceen on' before enabling WP,
or the console will be disabled once you enable ro_at_boot and reboot.)

Change-Id: I415388b98ec8bf1d149803aaaa7fe8c7f3076c36
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56064
2013-05-23 11:08:44 -07:00
Randall Spangler
aa419b29ac Clean up option byte register definitions for STM32L
No functional changes, just renaming and defining a few additional regs.

BUG=chrome-os-partner:15613
BRANCH=none
TEST=build pit

Change-Id: I67b2a96608431ffc418e6d4c81009d497f34568b
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/55813
2013-05-23 11:08:43 -07:00
Randall Spangler
e8ecda5e8d Support flash write protect on STM32L
This adds support for write protecting the RO code at boot, and the
entire flash on demand.

Implementation if WP# is not asserted is currently a little different
than STM32F and LM4; RO is still protected at boot if ro_at_boot, but
can be unprotected and the change will commit on the next reboot.
This saves the bank of flash which we use for pstate on LM4 and
STM32F.  I think I can use one of the unused option bits (WRP2 bit 0)
to hold the RO-at-boot flag, in which case I can more closely match
the behavior of the other chips, but I'd like to do that (or give up
and implement pstate) in a separate CL so it's clearer what I'm doing.

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

- flashinfo -> (no flags)
- enable WP (via screw or dut-control)
- flashinfo -> wp_gpio_asserted
- flashwp enable
- flashinfo -> wp_gpio_asserted ro_at_boot
- flashwp now
- flashinfo -> wp_gpio_asserted ro_at_boot all_now
- flashwp disable -> fails
- flashinfo -> wp_gpio_asserted ro_at_boot all_now
- flasherase 0x1fc00 0x400 -> fails
- reboot
- flashinfo -> wp_gpio_asserted ro_at_boot ro_now
- flasherase 0xfc00 0x400 -> fails
- flasherase 0x1fc00 0x400 -> succeeds
- disable WP (via screw or dut-control)
- reboot
- flashinfo -> ro_at_boot ro_now
- flashwp disable
- flashinfo -> ro_now
- reboot
- flashinfo -> (no flags)
- flasherase 0xfc00 0x400 -> succeeds
- flasherase 0x1fc00 0x400 -> succeeds

Change-Id: Id1b6b099a44a1985a5ab9387feb882a8f26e3aa1
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/55594
2013-05-22 19:15:56 -07:00
Duncan Laurie
6592036c6c usb: Disable ports on entry to S5
The "dumb" port power code was setting ports to enabled on S5
when it should be setting them to disabled.  This changes it
to match the behavior of the "smart" port power code and its
own comment.

BUG=chrome-os-partner:19398
BRANCH=none
TEST=manual: poweroff slippy and watch USB ports get disabled

Change-Id: Ibc68450a973477341d9ca096ac5a6ddd08cef273
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56262
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2013-05-22 12:29:20 -07:00