Commit Graph

2066 Commits

Author SHA1 Message Date
Mary Ruthven
6672aa1be1 cr50: enable case closed debug
This change adds a ccd console command to control the usb endpoints.
The uart console command is moved into this command so 'ccd uart
[enable|disable]' controls the AP and EC TX signals instead of the
'uart' console command. CCD can be enabled using 'ccd enable'. This
switches the PHY used by the USB controller to be the external PHY.
Changing the PHY exposes the cr50, AP, and EC consoles as well as the
upgrading mechanisms for the AP, EC and cr50. The AP and EC consoles
will be read only until 'ccd uart enable' is called. Cr50 can be updated
using the usb upgrade endpoint. The EC and AP can be updated using the
USB SPI endpoint.

When CCD is disabled the usb controller will switch to using the AP PHY.
None of the endpoints will be visible to the host.

The USB SPI endpoint can be used to flash the EC or AP using
'flashrom -p raiden_debug_spi:target=[AP|EC]'. If CCD is not enabled
running flashrom using the raiden_debug_spi programmer will fail. Cr50
will not forward the commands to the external AP or EC ROM, so flashrom
will not be able to find the chip.

The UART TX signals are now controlled by the 'ccd uart' console
command instead of the 'uart' console command. The UART TX is enabled
separately from CCD, because we want to be able to enable CCD while
servo is connected, and having the cr50 UART TX pins wired directly to
the Servo TX lines could damage both devices. The AP and EC consoles
are be read only until 'ccd uart enable' is called. 'ccd uart disable'
disconnects the AP and EC TX pins from the UART peripheral.

When RDD becomes reliable on cr50, ccd_set_mode will select the PHY
being used by the g chip USB controller.

BUG=chrome-os-partner:49960,chrome-os-partner:52281
BRANCH=none
TEST=manual
	TEST SERVO
	power cycle the DUT

	connect servo and check that the AP and EC consoles still work
	check that both the AP and EC can be flashed using servo.

	TEST SUZY Q
	Attach Suzy Q

	Connect to the all three consoles. Check that the cr50 console
	is in read-write mode and the EC and AP consoles are read only.

	Attach Servo.

	Verify all of the servo functionality described above still
	works with suzy q attached and ccd enabled.

	Disconnect Servo.

	run 'ccd uart enable' on the cr50 console and check both the AP
	and EC consoles can be written to.

	Check that the AP and EC can be programmed using the
	raiden_debug_spi programmer.

Change-Id: I96db2a72fc95086871c9e4c778c19ebd01efb851
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/342563
2016-06-03 20:14:59 -07:00
Kevin K Wong
e4c9e101e2 reef: enable WiFi power control support
add a new config flag to support active low power control signal

BUG=chrome-os-partner:53665
BRANCH=none
TEST=Use multimeter to check for voltage present on the WiFi slot.
     Use gpioget to check GPIO state in S0 (on) and S5 (off).

Change-Id: Ibeca88d16f39eadd7f29589cd3cd15aeef0dd524
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/347085
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2016-06-03 02:59:56 -07:00
Shawn Nematbakhsh
fcc09a2b7d usb_charger: Support inverted 5V_EN GPIO polarity
Kevin uses inverted polarity (low = enable 5V output), so add a new CONFIG
to support this.

BUG=chrome-os-partner:53777
BRANCH=None
TEST=Manual on Kevin. Enable USB charger tasks, verify that VBUS is
properly detected on no-battery case.

Change-Id: Ifb3e5fa9db1973d9826435712711f0cb0fd1d3a5
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/349260
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-06-02 22:25:46 -07:00
Shawn Nematbakhsh
5426122466 cleanup: pd: Define VBUS detection source
Previously CONFIG_USB_PD_TCPM_VBUS had two uses which were independent:

- When operating as a TCPC, it indicated that the VBUS level should be
  tracked (through GPIO inputs) and sent to the external TCPM when
  appropriate.
- When operating as a TCPM, it indicated that the VBUS level should be
  obtained by querying the TCPC.

These two independent uses have been split into
CONFIG_USB_PD_TCPC_TRACK_VBUS and CONFIG_USB_PD_VBUS_DETECT_TCPC, which
sould be more clear.

In addition, CONFIG_USB_PD_VBUS_DETECT_* CONFIGs have been added for
other means of VBUS detection.

BUG=chromium:616580
BRANCH=None
TEST=Verify kevin continues to boot + charge.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I936821481d6577e17e3e9c61ff97c037574d6923
Reviewed-on: https://chromium-review.googlesource.com/348950
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-06-02 14:06:53 -07:00
Nicolas Boichat
c3463c7f5d common/i2c: Fix I2C protection for i2c read/write commands
i2cread/i2cwrite takes 8-bit addresses, while i2cxfer takes 7-bit
addresses, make sure we filter on the correct address.

BRANCH=none
BUG=chrome-os-partner:52431
TEST=Book elm-rev1

Change-Id: I84dbc8468d7a8401673c90118f5799b3ff75c2e1
Signed-off-by: Nicolas Boichat <drinkcat@google.com>
Reviewed-on: https://chromium-review.googlesource.com/348153
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-06-01 11:25:46 -07:00
Vadim Bendebury
d9f0c13447 nvmem: provide a function to wipe out nvmem contents
It is important to be able to wipe out the non-volatile memory for
various reasons. This patch adds this ability for both when NV memory
is kept in SRAM and in flash.

Also a minor clean up to eliminate some code duplication and to have
normal flow messages printed out with time stamps.

BRANCH=none
BUG=chrome-os-partner:44745
TEST=just makeall at this time.

Change-Id: I59c1909669aeaa9e8ffb3d8ef81b02fa0facb6ab
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/348291
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-05-31 19:38:20 -07:00
Wonjoon Lee
5564c9fae7 driver: Add support bma255 sensor
BMA255 is one of BMA2x2 accel sensor series.
Adding defines,driver from
https://github.com/BoschSensortec/BMA2x2_driver

BUG=chrome-os-partner:52877
BRANCH=none
TEST="accelread 2" is working on kevin, also check accelrate,
accelrange can set proper value on IC

Change-Id: I99932ff75aae91a744fe18dddc010b802085a2da
Signed-off-by: Wonjoon Lee <woojoo.lee@samsung.com>
Reviewed-on: https://chromium-review.googlesource.com/347722
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-05-31 14:14:44 -07:00
Vijay Hiremath
dc3de2c826 reef: Initialize charge suppliers after change manager is initialized
Initialize the charge suppliers after change manager is initialized,
otherwise charge supplier current & voltage values will be overwritten
to -1 by the charge manager ini function.

BUG=chrome-os-partner:53788
BRANCH=None
TEST=Observed there are no "CL: p(port) s(supplier) i-1 v-1" prints
     on the EC console.

Change-Id: Id0212c502d5833c016ac79ee15d21304d6d7ceb2
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/347896
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-05-28 00:08:38 -07:00
Shawn Nematbakhsh
d1beddc463 pwm: Modify new PWM host commands to take 16-bit duty cycle
EC_CMD_PWM_SET_DUTY / EC_CMD_PWM_GET_DUTY were recently added and are
not yet in use. Future-proof these commands by taking a 16-bit duty
cycle parameter and converting it between the [0-100] percent used by
internal EC functions.

BUG=chromium:615109
BRANCH=None
TEST=Manual on chell.
`ectool pwmsetduty kb 65535` - Verify KB backlight goes to 100%
`ectool pwmgetduty kb` - Prints 65535
`ectool pwmgetduty 0` - Prints 65535
`ectool pwmsetduty 0 0` - Verify KB backlight goes to 0%
`ectool pwmgetduty kb` - Prints 0
`ectool pwmgetduty disp` - Error res 3 (unsupported PWM type)
`ectool pwmsetduty 1` - Error res 3 (non-existent PWM index)
`ectool pwmsetduty kb 6550` +
`ectool pwmgetduty kb` - Prints 6553 (round up)
`ectool pwmsetduty kb 6560` +
`ectool pwmgetduty kb` - Prints 6553 (round down)

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ic6996fc6e1e69359274b2f9a1120ee7002db991c
Reviewed-on: https://chromium-review.googlesource.com/347608
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Tested-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Brian Norris <briannorris@chromium.org>
2016-05-27 18:08:58 -07:00
Mary Ruthven
1d7984ad20 cr50: monitor the state of Servo, the EC, and AP
There are a couple of issues that cr50 has when it cannot know the state
of servo, the EC, and the AP. This change adds support so we can detect
when the AP or EC has been powered on and when servo has been connected.
It uses the UART RX signals to monitor the power state of the AP and EC.
The TX signals are used to monitor the state of servo.

BUG=chrome-os-partner:52056,chrome-os-partner:52322
BRANCH=none
TEST=verify device states are correct when the AP and EC are powered on
	or off and when Servo is attached or detached

Change-Id: Id0a2281b65cb367ecc8d0ca2f9a576672318a5fb
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/344019
2016-05-27 18:08:50 -07:00
Stefan Reinauer
641b02a46c common: Hide hcdebug_mode_names behind CONFIG_CMD_HCDEBUG
Signed-off-by: Stefan Reinauer <reinauer@chromium.org>
BUG=none
BRANCH=none
TEST=compile tested for Samus

Change-Id: I4e11f61a8f0171a3b5db64358619d8fcb0784591
Reviewed-on: https://chromium-review.googlesource.com/343241
Commit-Ready: Stefan Reinauer <reinauer@chromium.org>
Tested-by: Stefan Reinauer <reinauer@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-05-26 22:25:17 -07:00
Scott
7184144012 Cr50: NvMem: Connected function stubs in /board/tpm2/NVMem.c
Used #define CONFIG_FLASH_NVMEM to have functions in
/board/tpm2/NVMem.c utlitize on chip Nvmem functions.
On chip NV Memory availability is tied to an internal nvmem
error state which itself only depends on finding at least one
valid partition.

Added nvmem_is_different and nvmem_move functions which were
needed to complete the tpm2 platform interface. In addition,
added unit tests to support these two new functions.

BUG=chrome-os-partner:44745
BRANCH=none
TEST=manual
make runtests TEST_LIST_HOST=nvmem and verify that all tests pass.
Tested with tcg_test utility to test reads/writes using the
command "build/test-tpm2/install/bin/compliance --ntpm
localhost:9883 --select CPCTPM_TC2_3_33_07_01".

Change-Id: I475fdd1331e28ede00f9b674c7bee1536fa9ea48
Signed-off-by: Scott <scollyer@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/346236
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-05-26 18:08:57 -07:00
Scott
d80a5837c4 NvMem: Added NV Memory module to ec/common/
Full implementation of NvMem read, write, and commit functions.
Includes partition definitions, shared memory allocation, and
initialization function.

Includes a set of unit tests located in ec/test/nvmem.c which
verify functionality.

This module is required by Cr50, however this CL does not
include any Cr50 specific code.

BUG=chrome-os-partner:44745
BRANCH=none
TEST=manual
make runtests TEST_LIST_HOST=nvmem and verify that all tests pass

Change-Id: I515b094f2179dbcb75dd11ab5b14434caad37edd
Signed-off-by: Scott <scollyer@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/345632
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-05-26 16:17:27 -07:00
Nick Sanders
56ee8aefc3 servo_micro: add programmable serial number
This change provides a console command for setting,
and loading a usb serial number from flash. This
feature adds CONFIG_USB_SERIALNO, and currently only
has a useful implementation when PSTATE is present.

BUG=chromium:571477
TEST=serialno set abcdef; serialno load; reboot
BRANCH=none

Change-Id: I3b24cfa2d52d54118bc3fd54b276e3d95412d245
Signed-off-by: Nick Sanders <nsanders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/337359
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-05-26 16:17:26 -07:00
Nick Sanders
5cc3cac589 servo_v4: Fix ADC console command
The console adc command prints adc values in the
order they appear in hardware, however they are lableled
in the order they are enumerated in board.h, which is not
necessarily the same.

This prints the correct name and value pairs, and removes
the adc_read_all_channels function which is not otherwise
used.

BUG=chromium:571476
BRANCH=None
TEST="adc" command associates correct values with names now.

Change-Id: I688641953d20082224b4120eaefe0d634ad4c74c
Signed-off-by: Nick Sanders <nsanders@google.com>
Reviewed-on: https://chromium-review.googlesource.com/340892
Commit-Ready: Nick Sanders <nsanders@chromium.org>
Tested-by: Nick Sanders <nsanders@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-05-26 16:17:26 -07:00
Nicolas Boichat
f5bba241fd common/i2c: Add I2C passthru_protect command
This allows the AP to protect a I2C passthru bus. A board-specific
function then defines what I2C commands are allowed, so that we
can white/black list some addresses (e.g. I2C address allowing
PD chip FW updating).

BRANCH=none
BUG=chrome-os-partner:52431
TEST=Book elm-rev1

Change-Id: Ib106924418b16388ea8ea53c7b6bda6ef92e1d09
Signed-off-by: Nicolas Boichat <drinkcat@google.com>
Reviewed-on: https://chromium-review.googlesource.com/345761
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Randall Spangler <rspangler@google.com>
2016-05-24 19:23:27 -07:00
Nicolas Boichat
d2bbc229f3 common/i2c: Add get_i2c_port function
Also, remove port_is_valid which essentially does the same thing,
and is now redundant.

BRANCH=none
BUG=chrome-os-partner:52431
TEST=Book elm-rev1

Change-Id: I8e13e18b58fbb185de1e354fdd45acf7c6be39bf
Signed-off-by: Nicolas Boichat <drinkcat@google.com>
Reviewed-on: https://chromium-review.googlesource.com/345760
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Randall Spangler <rspangler@google.com>
2016-05-24 19:23:27 -07:00
Vijay Hiremath
313355302b Driver: BD99955: Enable BC1.2 support
BUG=none
BRANCH=none
TEST=Manually tested on Amenia.
     Connected Zinger, Type-C, DCP & CDP chargers. Device can negotiate
     to desired current & voltage and the battery can charge.
     USB2.0 sync device is detected by Kernel.

Change-Id: I58cb69289eef9a966e06bef8fe31d35beaec5e27
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/341030
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-05-24 15:46:01 -07:00
David Hendricks
5219d2f86b spi_flash: Add protect_range table for W25Q40
BUG=chrome-os-partner:53035
BRANCH=none
TEST=needs testing

Change-Id: I4b2bc758a22c2c19ddf0438a2af26f8c76093081
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/339291
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2016-05-19 18:18:05 -07:00
ZhengShunQian
77e23a4fc9 LED: add green/red support for host commands
The host command(ectool) to set led colors will read the brightness
range and then set as requested. If brightness range is 0, then it will just
return INVALID_PARAM.

BUG=chrome-os-partner:35416
TEST=build and run on veyron
       ectool led battery green
       ectool led battery red
       ectool led battery red=1 green=1 #this gives amber
       ectool led battery off
       ectool led power white
       ectool led power off
       ectool led battery auto
       ectool led power auto
BRANCH=veyron

Change-Id: I65a73275741ada5c01e041ae2c11efe3aa2d8c38
(cherry picked from commit ba88b6d6b35959d7ff33cdf075e494406a2f4b5f)
Reviewed-on: https://chromium-review.googlesource.com/345693
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-05-18 15:08:28 -07:00
Shawn Nematbakhsh
a4ef740391 usb_charger: Move part-specific code to usb_switch driver
Previously usb_charger.c supported only pi3usb9281, but now support for
additional parts is required. Move pericom-specific code (including the
usb_charger tasks that handles various quirks of that part) to the
pi3usb9281 usb_switch driver.

Going forward, usb_switch drivers must implement
usb_charger_set_switches() and must have some method (such as a task or
interrupt handler) to update charge_manager with information about
attached chargers.

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

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I4df74e043d8cf2e532d48c39c73b7dc2930f7d3b
Reviewed-on: https://chromium-review.googlesource.com/344289
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-05-13 23:34:51 -07:00
Shawn Nematbakhsh
7d8964614d cleanup: Remove usb_switch_tsu6721 driver
This driver is not in use for any recent board and doesn't implement the
soon-to-be standard usb_switch interface routine.

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

Change-Id: I7469dab42e52d9d02425ad4e7bacb81b2489ffc4
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/344417
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-05-13 23:34:51 -07:00
Shawn Nematbakhsh
9494fc0dd1 pwm: Add generic PWM control host commands
Add generic PWM host commands for setting + getting duty cycle. PWMs can
be controlled through index (board-specific meaning) or by type
(currently KB backlight and display backlight are supported, more can be
added as needed).

BUG=chrome-os-partner:52002
BRANCH=None
TEST=Manual on chell.
`ectool pwmsetduty kb 100` - Verify KB backlight goes to 100%
`ectool pwmgetduty kb` - Prints 100
`ectool pwmgetduty 0` - Prints 100
`ectool pwmsetduty 0 0` - Verify KB backlight goes to 0%
`ectool pwmgetduty kb` - Prints 0
`ectool pwmgetduty disp` - Error res 3 (unsupported PWM type)
`ectool pwmsetduty 1` - Error res 3 (non-existent PWM index)

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I607c92a291e6c2e3af8238eaf22ad2bb81ffc805
Reviewed-on: https://chromium-review.googlesource.com/344012
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2016-05-11 18:24:30 -07:00
Stefan Reinauer
8321eed87b common: Drop unused data structure
SHA256_digestinfo[] is never used but declared static and const.

Signed-off-by: Stefan Reinauer <reinauer@chromium.org>
BRANCH=none
BUG=none
TEST=compile tested
Change-Id: I0bcf419bf63fac3e6eadd9efad10fc05b7be9158
Reviewed-on: https://chromium-review.googlesource.com/342484
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-05-05 19:16:50 -07:00
Wonjoon Lee
d6546857da charge_manager: Always set active charge port on first pass
Always call board_set_active_charge_port() on the first pass through
charge_manager_refresh(), in case actions must be taken once the
CHARGE_PORT_NONE selection is confirmed.

BUG=None
BRANCH=None
TEST=Attach unpowered peripheral without AC and powerbtn, make sure ap boot-up

Change-Id: I4bcf1d548d7a8c80f4395fc90ff499fce33c8373
Signed-off-by: Wonjoon Lee <woojoo.lee@samsung.com>
Reviewed-on: https://chromium-review.googlesource.com/341076
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-05-05 01:12:24 -07:00
Vadim Bendebury
3093a8da7f tpm_regs: clean up debug messages
Some debug messages were a bit ambiguous, and some just wrong, this
patch fixes the wrong one and disambiguates the other two.

BRANCH=none
BUG=none
TEST=observed the new generated message.

Change-Id: I2b58ec050816ecdfe4b20dd8410910569767830d
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/340536
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-04-27 18:12:25 -07:00
Nick Sanders
4e52ae607c servo_micro: add gpio mode get and set
GPIO console commands currently only show input voltage level,
and can only set level on predefined outputs.

This change allows GPIOs to be cycled between output, input,
and alternate function, as well as displaying the mode and
asserted level (if any) in gpioget.

This change creates CONFIG_CMD_GPIO_EXTENDED
as the internal gpio interface needs to be changed to support
this, and I can't test the other architectures. It may be
worthwhile to add this for all, or not.

This change is also necessary also for servo micro JTAG and PD
UART support, as several pins are tied together on the flex
and stm32 outputs need to be variously active or in high-z
depending on mode.

BUG=chromium:571477
TEST=gpioget <0|1|IN|A|ALT>; gpioget;
BRANCH=None

Change-Id: Iba32992db6244ee1e654db840d1c9c11dd2a0993
Signed-off-by: Nick Sanders <nsanders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/338885
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-04-27 14:04:07 -07:00
Anton Staaf
7a78cc918c UART: Remove X-on/X-off flow control
This doesn't appear to be used anymore, and the EC3PO replacement
console doesn't support this yet.  This also makes changing the UART
driver API more difficult, so let's remove it.

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

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

Change-Id: Ia6d9cf4c89e34683f38169dbec612a417c6ba630
Reviewed-on: https://chromium-review.googlesource.com/340842
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-04-27 10:10:02 -07:00
Shawn Nematbakhsh
539e261d72 pd: Fix port enable check for low power idle
BUG=chrome-os-partner:52734
BRANCH=glados
TEST=Plug 2 PD chargers on sentry, remove the first, verify that
SLEEP_MASK_USB_PD is not briefly cleared.

Change-Id: I62309194d8b5a694487282434fc63b5f39301ba3
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/340564
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-04-25 21:04:41 -07:00
Anton Staaf
95858f385c Deferred: Remove hard coded number of deferreds
Previously the maximum number of deferred routines was specified by the
the default maximum number of deferred routines you had to override
this, and if you wanted fewer, you still payed the price of having the
defer_until array statically allocated to be the maximum size.

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

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

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

Change-Id: Id3db84ee1795226b7818c57f68c1f637567831dc
Reviewed-on: https://chromium-review.googlesource.com/335597
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-04-19 12:23:52 -07:00
Anton Staaf
068cd08506 Deferred: Use deferred_data instead of function pointer
Previously calls to hook_call_deferred were passed the function to call,
which was then looked up in the .rodata.deferred section with a linear
search.  This linear search can be replaced with a subtract by passing
the pointer to the deferred_data object created when DECLARE_DEFERRED
was invoked.

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

BRANCH=None
BUG=None
CQ-DEPEND=CL:*255812
TEST=make buildall -j

Change-Id: I951dd1541302875b102dd086154cf05591694440
Reviewed-on: https://chromium-review.googlesource.com/334315
Commit-Ready: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-04-18 17:32:40 -07:00
Kevin K Wong
b10d12f1c9 tcpm: update code to support multiple tcpm driver
BUG=chromium:593822
BRANCH=none
TEST=make buildall

Change-Id: Ic30c1b890da7639aa80a53040ecc5bebfb4be2e8
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/336030
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-04-17 12:23:07 -07:00
Kyoung Kim
e6902404a2 Kunimitsu: remove console commands for code size
Remove following EC console commands to reduce code size:
- battfake
- apthrottle
And none of commands above are used in 'auto test'.

This is a squash of
- https://chromium-review.googlesource.com/337657
- https://chromium-review.googlesource.com/338018

BUG=none
BRANCH=firmware-glados-7820.B
TEST=make -j buildall

Change-Id: I11d2c5514f2714f0a46416feec2b2c47666fb462
Signed-off-by: Kyoung Kim <kyoung.il.kim@intel.com>
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/338893
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-04-14 17:28:17 -07:00
Divya Sasidharan
e353ab0363 pd: Fix multiple reboot for battery cut-off
In case of boot after battery is cut-off without this
change the battery is assumed to be present even though it
is not initialized and ready to provide power in try source
enable function. With this assumption charger is disconnected
momentarily which causes reboot.
Also make sure that try source enable is updated after battery
is ready by notifying hook call HOOK_BATTERY_SOC_CHANGE.

BUG=chrome-os-partner:51753
BRANCH=firmware-glados-7820.B
TEST=Enter battery cutoff command from EC console to enter into ship
     mode and plug-in AC, verified no reboots happen.

Change-Id: I6f7656125717f85851f5ad4e37dfd953a52799c6
Signed-off-by: Divya Sasidharan <divya.s.sasidharan@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/335913
Reviewed-by: Shawn N <shawnn@chromium.org>
(cherry picked from commit 10040ac6284efe88b74193bdbb0c05ec92b563b4)
Reviewed-on: https://chromium-review.googlesource.com/336697
Commit-Ready: Divya S Sasidharan <divya.s.sasidharan@intel.com>
Tested-by: Divya Jyothi <divya.jyothi@intel.com>
2016-04-13 18:37:18 -07:00
Kevin K Wong
f7ae91a590 charger_state_v2: force static battery info update on battery change
BUG=none
BRANCH=none
TEST=on system which has different static battery info based on
battery present, when the present status has changed, verify the
battery info is also changed.

Change-Id: Id58c545e3315dc63c6dd6b59141b6302d767bfb7
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/331655
Reviewed-by: Li1 Feng <li1.feng@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-04-13 16:49:54 -07:00
Shawn Nematbakhsh
d2e77ddbc9 pd: Add config to disable PD communication in locked RO
The scheme to disable PD communication in locked RO needs to be
implemented on other platforms, so move it to common code, behind
CONFIG_USB_PD_COMM_LOCKED.

BUG=chrome-os-partner:52157
BRANCH=glados
TEST=Manual on chell. Lock system and boot to recovery, then verify PD
communication is functional. Enable CONFIG_USB_PD_COMM_LOCKED and verify
PD communication isn't functional under the same test conditions.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I8d1f24c0b60cf1c54e329af003b7083ee55ffc40
Reviewed-on: https://chromium-review.googlesource.com/338064
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2016-04-11 14:36:40 -07:00
Bill Richardson
2c26cad2ad Support RW_B in sysjump command when applicable
If we #define CONFIG_RW_B, the firmware image can have two RW
components. This CL expands the "sysinfo" command so that we can
see which image we're running from when RW_B is also a
possibility.

BUG=chrome-os-partner:50701
BRANCH=none
TEST=make buildall; test RW update on Cr50

Using test/tpm_test/tpmtest.py, update the RW firmware and reboot
several times to switch between RW_A and RW_B. Note that the
"sysjump" command reports the correct image each time.

Change-Id: Iba3778579587f6df198728d3783cb848b4fd199d
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/337664
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-04-08 12:34:29 -07:00
Mary Ruthven
fa643a9fc7 cr50: add support for creating multiple serial endpoints
CR50 will need three serial endpoints for the streaming AP and EC UART
and exporting its own console through USB. This change adds a macro to
create endpoints that can be recognized by the usb_serial driver.

BUG=chrome-os-partner:50702
BRANCH=none
TEST=Verify "/dev/google/Cr50*/serial/Blob" prints capital letters when
lower case letters are input.

Change-Id: Iddf2c957a00dc3cd5448a6a00de2cf61ef5dd84c
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/336441
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-04-07 13:00:39 -07:00
Shawn Nematbakhsh
33fd731ca1 charge_manager: Report UNKNOWN USB charger for 2 seconds after change
After a charger is attached, we may set a charge limit based upon BC1.2
or USB-C Rp before PD negotiation completes. Therefore, allow 2 seconds
for all negotiation to complete. Previously this behavior was implicit
when using SW charge ramp.

BUG=chrome-os-partner:51280
BRANCH=glados
TEST=Manual on chell. Insert stock charger, verify that it is detected
as TYPE_UNKNOWN until timeout.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I52f02de46fa92b66a9fbaddb94a062310688f028
Reviewed-on: https://chromium-review.googlesource.com/334312
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-04-03 10:27:36 -07:00
Shawn Nematbakhsh
257dab7491 console: Put additional console commands behind CONFIGs
Allow boards to save flash space by undef'ing CONFIGs which gate
'hcdebug' and 'md' console commands.

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

Change-Id: I583b98ff1e4d9d6a26958c6895fb0c0305dddceb
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/336813
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-04-03 10:27:36 -07:00
Devn Lu
93be0c3b0a ectool: Support keyboard factory scanning
This is keyboard test mechanism request for "multiple key press test",
we can thru the testing to scan out kso ksi pins shortting or keyboard has
multiple key pressing, below was the testing steps:

1. Turn off internal keyboard scan function.
2. Set all scan & sense pins to input and internal push up.
3. Set start one pin to output low.
4. check other pins status if any sense low level.
5. repeat step 3~4 for all keyboard KSO/KSI pins.
6. Turn on internal keyboard scan function.

BUG=chrome-os-partner:49235
BRANCH=ToT
TEST=manual
  Short any KSO or KSI pins and excute "ectool kbfactorytest", it shows failed.
  if no pins short together, it shows passed.

Change-Id: Id2c4310d45e892aebc6d2c0795db22eba5a30641
Signed-off-by: Devin Lu <Devin.Lu@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/332322
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-04-01 00:21:35 -07:00
Bill Richardson
70378b86b4 Cr50: Include low-power exit triggers in reset causes
Some of the reset causes are found in another register when
resuming from a low-power state. We know we'll need to
distinguish among them eventually, so we might as well decode
them now.

BUG=chrome-os-partner:49955
BRANCH=none
TEST=make buildall; test on Cr50

I forced the system into deep sleep and observed that the reset
cause is accurately recorded on resume. Doing that requires a
fair amount of hacks and manual effort, and can't happen by
accident. Future CLs will make use of this.

The current, normal behavior is completely unaffected.

Change-Id: I5a7b19dee8bff1ff1703fbbcc84cff4e374cf872
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/336314
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-03-30 20:38:13 -07:00
Naresh G Solanki
06ea3b5b00 spi_flash: print spi flash size in proper unit
Spi flash size is calculated in the units of kB
but is printed as MB. correcting it to kB unit.

Change-Id: If71681fc868a5974b44d135055c01f9184c71602
Signed-off-by: Naresh G Solanki <naresh.solanki@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/332732
Commit-Ready: Naresh Solanki <naresh.solanki@intel.com>
Tested-by: Naresh Solanki <naresh.solanki@intel.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Divya Jyothi <divya.jyothi@intel.com>
2016-03-30 17:10:17 -07:00
Keith Tzeng
4377df7b5b Fan: enable fan after system resume
Fan will disable when S3 and S5 by pwm_fan_s3_s5,
which call set_enabled(fan, 0) to disable it.
But the pwn_fan_resume called fan_set_enabled() which not setting
GPIO_FAN_PWR_DIF_L to 1, we should use set_enabled() instead.

BUG=chrome-os-partner:50372
BRANCH=master
TEST=check fan enable after system resume
Signed-off-by: Keith Tzeng <Keith.Tzeng@quantatw.com>

Change-Id: Id0bd4dd0afc7e02bcfa6e20401d6e9dfe8a81423
Reviewed-on: https://chromium-review.googlesource.com/335693
Commit-Ready: Keith Tzeng <keith.tzeng@quantatw.com>
Tested-by: Keith Tzeng <keith.tzeng@quantatw.com>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2016-03-30 04:37:39 -07:00
Shamile Khan
ef561a293f spi_flash: Reload watchdog before writing a flash page
When EC receives many flash write requests from host and
PDCMD, CHARGE and USB_CHG_P0 tasks are all ready to run, the
HOOK task may not get scheduled in time to pet the watchdog
resulting in an EC reset.

BUG=chrome-os-partner:51438
BRANCH=None
TEST=Manual on lars, determine two EC versions that have enough
differences so that replacing one image with the other will
require all or most of the flash pages to be updated. Alternate
between flashing the two images with flashrom using a script.
Atleast 1000 iterations should pass.

Change-Id: I8b5c8b680a2935b945f3740e371dee2d218ec4c5
Signed-off-by: Shamile Khan <shamile.khan@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/334457
Reviewed-by: Stefan Reinauer <reinauer@google.com>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
(cherry picked from commit a537d1ac44c40e7f6e1131e8cc852b030ccdba52)
Reviewed-on: https://chromium-review.googlesource.com/334903
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
2016-03-25 18:51:44 -07:00
Bill Richardson
6f24b75a15 Cr50: cleanup: Clarify a few comments
BUG=none
BRANCH=none
TEST=make buildall; try on Cr50

No code changes, just comments.

Change-Id: I3eccccb024b4a319920a8252cd7d5d3829bf21da
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/334820
Reviewed-by: Scott Collyer <scollyer@chromium.org>
2016-03-24 22:24:07 +00:00
chris wang
2295467659 usb_port_power_smart: Support variable port count
Use CONFIG_USB_PORT_POWER_SMART_PORT_COUNT to support more usb ports
(default 2).

BUG=None
BRANCH=firmware-strago-7287.B
TEST=build&flash ec,verify on wizpig,usb function work
Signed-off-by: Chris Wang <chriswang@ami.com.tw>

Change-Id: I2460d4a5755ef457249d728169c27fc6d00625d2
Reviewed-on: https://chromium-review.googlesource.com/333232
Reviewed-by: Shawn N <shawnn@chromium.org>
Tested-by: lehai deng <denglehai@ithaier.com>
Commit-Queue: Chris Wang <chriswang@ami.com.tw>
Tested-by: Chris Wang <chriswang@ami.com.tw>
(cherry picked from commit 1e7d3554f1bedbb839a0f4800286c9db0d27e4f1)
Reviewed-on: https://chromium-review.googlesource.com/334510
Commit-Ready: Chris Wang <chriswang@ami.com.tw>
2016-03-24 00:03:07 -07:00
Anton Staaf
57244d7708 Console: Fix channel enum values
The channel enum and string name array were out of sync (when
CONFIG_EXTENSION_COMMAND is defined).  This was caused by the two lists
being specified separately.  I argue that this is a good reason to merge
the lists into a separate X-Macro include file.

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

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

Change-Id: I81d143f550a0fe6ef0c64e3c8357ed18aee4bfdc
Reviewed-on: https://chromium-review.googlesource.com/334381
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-03-22 19:54:46 -07:00
Shawn Nematbakhsh
d36e177f9f smbus: Re-write smbus driver
Re-write smbus driver to fix arbitrary length read and improve code
organization.

BUG=chromium:576911
BRANCH=None
TEST=Manual on sentry. Verify that smbus communication with battery is
functional.

Change-Id: I63c4bc3df40755cd41b3d9956af0ab9d2145a253
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/333787
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-03-21 16:35:33 -07:00
Shawn Nematbakhsh
952b2a54e1 crc8: Support crc calculation across non-contiguous data
Building a single buffer for crc calculation is often inefficient, so
add a new function that calculates crc8 from an existing crc8.

BUG=chromium:576911
BRANCH=None
TEST=Manual on sentry with subsequent commit. Verify that smbus
communication with battery is functional.

Change-Id: I05ffedb81ffcf0c126acda5f6212b3147b1580a1
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/333786
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-03-18 22:16:53 -07:00