Commit Graph

1639 Commits

Author SHA1 Message Date
Shawn Nematbakhsh
e4d6f134ec test: Properly exclude CONFIG_POWER_TRACK_HOST_SLEEP_STATE
CONFIG_POWER_TRACK_HOST_SLEEP_STATE has a dependency on
CONFIG_POWER_COMMON, so remove it from test builds that don't have a
chipset task, rather than heavy-handedly removing it from all test
builds.

BUG=chrome-os-partner:56197
BRANCH=None
TEST=`make BOARD=gru tests`

Change-Id: I86e20b4dccbb01ee285054a47093d6f60abc2166
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/378119
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-09-02 01:28:20 -07:00
Nick Sanders
a4bfc663a3 sweetberry: add dwc usb support
stm32f446 uses a synopsys designware USB block
rather than the typical ST one. This change adds driver support
for the new block, including usb console support.

BUG=chromium:608039
TEST=usb console works
BRANCH=None

Change-Id: I0e143758ae0b5285f1c94ea2ec5aee159e22e00c
Signed-off-by: Nick Sanders <nsanders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/365448
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-09-01 22:56:22 -07:00
Vincent Palatin
02b80c49f4 pd: manage total source current available
Add a policy to handle the case where the device can source the
`CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT` over one of its type-C port if
there is no sink connected on the other ones.

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

BRANCH=none
BUG=chrome-os-partner:56110
TEST=manual: on Kevin, plug and unplug various devices on the 2 ports,
while measuring the type-C pull-up with Twinkie.

Change-Id: Id5961f04d0a1b1073f5ab340068efd9079918209
Reviewed-on: https://chromium-review.googlesource.com/373818
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-09-01 19:52:35 -07:00
Mary Ruthven
e47eaaf2e8 cr50: unlock console
UART0 RX only needs to be disabled on reef. This change uses a system
property instead of a #define to disable UART0 RX that way it can just
be done on Reef not Gru or the dev board.

BUG=chrome-os-partner:55510
BRANCH=none
TEST=manual
	rw 0x4060000c shows a value of 1 for reef and 3 for gru

	gru kevin and reef still boot.

	Connect DIOA13 to DIOA1 on the dev board and verify the console
	can be used.

Change-Id: I5ee3559c2b35f959c0d67f233d1dfa40743b4064
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/378336
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Scott Collyer <scollyer@chromium.org>
2016-09-01 07:39:38 -07:00
Vijay Hiremath
ade0de9881 Revert "ectool: Add ectool command to do AP force shutdown"
There are no actual use cases of this command hence reverting it.
This reverts commit 2324ed47aa.

BUG=chrome-os-partner:56681
BRANCH=none
TEST=make buildall -j

Change-Id: Ibfa6c99d591e7601299236d8ad56451ef5ab20f2
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/377852
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-09-01 05:02:38 -07:00
Bill Richardson
70341959e6 Add console support for restricted commands
This adds support for CONFIG_RESTRICTED_CONSOLE_COMMANDS. If the
appropriate options are configured, restricted commands can be
prevented from running.

Nothing in this CL actually uses that, but it works if you turn
it on.

BUG=chrome-os-partner:55322
BRANCH=none
TEST=make buildall, test on Cr50 hardware

I also tested it manually. If you add this to board.h:

  #define CONFIG_CONSOLE_COMMAND_FLAGS
  #define CONFIG_RESTRICTED_CONSOLE_COMMANDS
  #define CONFIG_CONSOLE_COMMAND_FLAGS_DEFAULT CMD_FLAG_RESTRICTED

and this to board.c:

  static int restricted_state;

  int console_is_restricted(void)
  {
         return restricted_state;
  }

  static int command_lock(int argc, char **argv)
  {
         int enabled;

         if (argc > 1) {
                 if (!parse_bool(argv[1], &enabled))
                         return EC_ERROR_PARAM1;
                 restricted_state = enabled;
         }

         ccprintf("The restricted console lock is %s\n",
                  restricted_state ? "enabled" : "disabled");

         return EC_SUCCESS;
  }
  DECLARE_CONSOLE_COMMAND_FLAGS(lock, command_lock,
                                "[<BOOLEAN>]",
                                "Get/Set the restricted console lock",
                                0);               /* no restrictions */

then you can use the "lock" command to enable and disable every
other console command except for it and "help".

Change-Id: Ic9517f9ea7a9867f15e5d14b302246070163d558
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/376186
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-08-31 17:12:58 +00:00
Bill Richardson
6d805476ba Add configs to add flags to console commands
If we add a .flags field to the console commands data structure,
we can use it to distinguish some commands from others, for
example to mark some commands as safe and others as dangerous.

This just adds the undefined CONFIG_ options. They aren't used
anywhere, so there's no behavioral difference yet.

BUG=chrome-os-partner:55322
BRANCH=none
TEST=make buildall

Change-Id: I17fdf177dcb4324c77565bd95344da1405ea15ed
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/376185
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-08-31 16:02:36 +00:00
Vijay Hiremath
2324ed47aa ectool: Add ectool command to do AP force shutdown
Added support to do force AP shutdown from kernel console using
the ectools.

BUG=chrome-os-partner:56681
BRANCH=none
TEST=make buildall -j; Manually tested on reef.
     "ectool reboot_ec apshutdown" puts system in G3.

Change-Id: I509678a67a6a54da67de99efb00e1f08a1ed1fea
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/376863
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-08-30 02:50:32 -07:00
Vincent Palatin
e880402f74 pd: select dynamically Rp value
Add API to switch the Rp pull-up value on CC dynamically at runtime.
This is a preparatory work for boards having a more complex maximum
source current policy (eg 2 ports sharing a common pool of power).

For fusb302, update the voltage thresholds for open/Rd/Ra as they depend
on the Rp (was missing from the previous change).

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

BRANCH=none
BUG=chrome-os-partner:56110
TEST=make buildall

Change-Id: Id3c24a31a16217075a398ec21ef58ee07187a882
Reviewed-on: https://chromium-review.googlesource.com/373501
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-08-25 07:32:31 -07:00
Mary Ruthven
613be38789 cr50: connect to AP phy on reef when not in ccd
Cr50 needs to connect to the AP phy when not in ccd so cr50 can be
updated and used as a gnubby. This change uses the strapping options
to detect when it is on reef and modifies the ccd behavior to
initialize usb on the AP phy when ccd is disabled. On gru the cr50
behavior is unchanged.

In RDD this change removes the checks that the current_map is the
correct one based on the detected debug state. rdd_init calls
rdd_interrupt to set up the usb and ccd state correctly. Having that
check prevents that initial rdd_interrupt from calling rdd_detached.
Before rdd_detached just disabled usb and we knew during init it
would already be disabled. Now we want to make sure it is called if a
debug accessory is not attached to initialize usb on the AP PHY.

BUG=chrome-os-partner:56098
BRANCH=none
TEST=manual
	verify ccd still works on gru

	disconnect suzyq and reset reef.

	run lsusb on the AP and verify it shows cr50 as a device.

	connect suzyq and check that the AP no longer sees cr50.

	disconnect suzyq and verify the AP sees it again

Change-Id: I3c1ccc54895835bce12302f3ea43fc2e751b4c97
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/372920
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-08-25 01:46:39 -07:00
Vincent Palatin
7e4564a87e tcpm: workaround TCPC takes longer time to update CC status
when TCPC takes a longer time to update its CC status upon
connection, a legacy C-to-A charger or certain Type-C charger
that presents 5V VBUS by default, TCPM could be mistaken the
charger as a debug accessory.

BUG=chrome-os-partner:55980
BRANCH=none
TEST=Manually tested on Reef. PD, Type-C, BC1.2, non-BC1.2,
     DP, HDMI are working on both C-ports.

Change-Id: Ic3b0ecd3d14109239d8c0ff0064476595b7f93a0
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/367950
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-08-25 01:46:06 -07:00
Shawn Nematbakhsh
6fefca3d6a power: rk3399: Debounce PGOOD_AP signal
PGOOD_AP may go low for a period < 100ms during regulator output voltage
transitions, so ignore such pulses.

BRANCH=None
BUG=chrome-os-partner:54814
TEST=On kevin, verify suspend / resume succeeds for 10 cycles.

Change-Id: I5b6240a570472e1ea74de6e5f2341472ea7afe6b
Reviewed-on: https://chromium-review.googlesource.com/374524
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Douglas Anderson <dianders@chromium.org>
Tested-by: Shunqian Zheng <zhengsq@rock-chips.com>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-08-25 01:45:26 -07:00
Bill Richardson
3071b82b58 Remove unused CONFIG_CONSOLE_RESTRICTED_INPUT option
Nothing has used this config option since Spring and Skate, back
in early 2014. There's nothing in ToT that uses it at all. I want
to add something similar for other purposes, and having two
similar-sounding options will just cause confusion.

NOTE: Although the comments in include/system.h said that the two
functions

  system_get_console_force_enabled()
  system_set_console_force_enabled()

were only useful when CONFIG_CONSOLE_RESTRICTED_INPUT is defined,
they were being used in chip/stm32/system.c. But since the
bkpdata registers are only accessible to the EC, there was no way
to initialize or modify the one relevant bit that those functions
cared about, so they almost certainly had no effect.

BUG=chrome-os-partner:55322
BRANCH=none
TEST=make buildall

Change-Id: Id41541193d4559f5c507bdd0268b049166af4497
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/374525
2016-08-24 17:41:12 -07:00
Johnnie Chan
dbd62c36da Modified flash API batch write logic to respect row boundaries.
* Added MACRO for specifying row size of flash device.
* Set chip/g specific values for flash row size.

The flash API for g/chip will segment large write operations into a
maximum of 32 word blocks for batch writes to flash memory. Prior to
the change in this commit, the segmentation will adhere to avoiding
crossing page boundaries (2048B) but will not respect row boundaries
(256B). The flash controller will reject any write op that crosses a
row boundary and set a row boundary violation code on its error
register.

BRANCH=none
BUG=b:30819377
TEST=make BOARD=haven_dev
Change-Id: I489122ec0f0db6374dd373a1385c3012bdface20
Reviewed-on: https://chromium-review.googlesource.com/371003
Commit-Ready: Bill Richardson <wfrichar@chromium.org>
Commit-Ready: Johnnie Chan <johnniec@google.com>
Tested-by: Johnnie Chan <johnniec@google.com>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-08-24 17:40:39 -07:00
Divya Sasidharan
1bebf37965 barometer: Add barometer driver for BMP280 in EC
BMP280 driver API is designed to work with motion
sensor task. The sensor sampling parameters are
configured optimally for handheld device in accordance
with BMP280 spec recommendation.

BUG=None
BRANCH=master
TEST=Tested on amenia; with appropriate .odr in board file
     test command "accelread 4" returns raw pressure
     value in Pa; accelinfo on 4000 shows Pa value.

Change-Id: I3f4c0c33a77dd317aa1425624d3cc7f4ec6b45a1
Signed-off-by: Divya Sasidharan <divya.s.sasidharan@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/351660
Commit-Ready: Divya S Sasidharan <divya.s.sasidharan@intel.com>
Tested-by: Divya S Sasidharan <divya.s.sasidharan@intel.com>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2016-08-24 17:40:34 -07:00
Gwendal Grignou
671613ec4a motion_lid: Fix include file.
Add math_util, as matrix and vectors are used in this file.

BRANCH=none
BUG=none
TEST=compile when caller does not include math_util.

Change-Id: Ic8f6ada4f24a0f9d3c91dbf14bea98546089a08f
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/373039
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-08-24 17:40:32 -07:00
Bill Richardson
bb15561db5 cleanup: DECLARE_CONSOLE_COMMAND only needs 4 args
Since pretty much always, we've declared console commands to take
a "longhelp" argument with detailed explanations of what the
command does. But since almost as long, we've never actually used
that argument for anything - we just silently throw it away in
the macro. There's only one command (usbchargemode) that even
thinks it defines that argument.

We're never going to use this, let's just get rid of it.

BUG=none
BRANCH=none
CQ-DEPEND=CL:*279060
CQ-DEPEND=CL:*279158
CQ-DEPEND=CL:*279037
TEST=make buildall; tested on Cr50 hardware

Everything builds. Since we never used this arg anyway, there had
better not be any difference in the result.

Change-Id: Id3f71a53d02e3dc625cfcc12aa71ecb50e35eb9f
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/374163
Reviewed-by: Myles Watson <mylesgw@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-08-24 16:30:10 +00:00
Levi Oliver
1e2148249a btle: Accepts and maintains connections
Can now accept and maintain a single connection indefinitely by
sending empty packets at every connection interval to keep the
connection alive.

TEST=BTLE dongle sending connect requests and connecting to NRF51
running this code. Connection was established and ran for at least
48 hours until manual termination.
BUG=None
BRANCH=None

Change-Id: Iad4bd434ecd1edd6c5c8dfe8b72ca41fd82d0bb4
Signed-off-by: Levi Oliver <levio@google.com>
Reviewed-on: https://chromium-review.googlesource.com/370839
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-08-23 15:36:55 -07:00
Vijay Hiremath
61c45fb33e BD99955: Map PD port number to charge port number
Charger port number may differ from PD port number hence added
a macro to select appropriate port numbers during compilation.

BUG=chrome-os-partner:54970
BRANCH=none
TEST=Reef can negotiate on both the ports.

Change-Id: Id3b4b639a5f8698c27341be037bb09370910cac5
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/357836
Commit-Ready: Martin Roth <martinroth@chromium.org>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-08-22 23:27:16 -07:00
Bill Richardson
9a59b5ea9c g: Remove unused CONFIG_RBOX_DEBUG feature
This feature is not enabled, is awkwardly written, and shouldn't
be left lying around to use as a bad example. This CL doesn't
change any compiled code.

A followup CL will add a working RBOX interrupt handler.

BUG=none
BRANCH=none
TEST=make buildall; test on Cr50 hardware

Change-Id: I5d0701f55ab9521bf1f29e7ec18994c4401d68fb
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/373600
Tested-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-08-22 14:52:26 -07:00
Vincent Palatin
1b9096116c pd: support Rp/Rp debug accessories
Support Rp/Rp debug accessories in the USB PD state machine
including detecting the polarity and the available type-C current.

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

BRANCH=none
BUG=chrome-os-partner:52592
TEST=manual, plug a Suzy-Q reworked with Rp3A0/Rp1A5 resistors
on a Kevin, and see the PD state machine is going to
PD_STATE_SNK_ACCESSORY (and leaving it on unplug).
Re-verify a few existing accessories (Rd/Rd SuzyQ, legacy RpUSB cable,
Rp3A0 power supply).

Change-Id: Icef6c90027105d7c633f2785210ab9dae74fc33c
Reviewed-on: https://chromium-review.googlesource.com/368700
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-08-22 05:03:26 -07:00
Shawn Nematbakhsh
62751ab886 pd: Support GPIO-controlled 5v discharge
Enable 5v discharge when power swapping out of source role.

BUG=chrome-os-partner:54923
BRANCH=None
TEST=Verify power swap succeeds on kevin when connected to Samus.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I2f57c4dd7d0fdbf70a0ffed659489f752811ea1b
Reviewed-on: https://chromium-review.googlesource.com/362760
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: David Schneider <dnschneid@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-08-19 14:21:06 -07:00
Nick Sanders
6fcd163da5 stm32f446e-eval: add support for stm32f446
This adds basic support for the stm32f446.
This consists of:
* New DMA model for stm32f4
* New clock domain support.
* MCO oscillator gpio export support.
* Flash support for irregular blocks.

BUG=chromium:608039
TEST=boots w/ correct clock, stm32f0 also boots.
BRANCH=None

Change-Id: I1c5cf6ddca09009c9dac60da8a3d0c5ceedfcf4d
Signed-off-by: Nick Sanders <nsanders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/363992
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-08-17 16:19:07 -07:00
Aseda Aboagye
6fad4f8588 ec_commands.h: Reserve 0x200-0x2FF for Rotor.
BUG=None
BRANCH=None
TEST=make -j buildall tests

Change-Id: I82fd750c83e6f653b22a006eb6235573c5bb28bc
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/371298
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-08-17 12:49:26 -07:00
Levi Oliver
31f297da0b btle: Timeout of ble_rx now based on chip time
Previously, timeout meant the number of attempts taken to receive. Now,
it means the number of microseconds before timing out.

TEST=printouts displaying time before and after rx attempt. Not included
in CL.
BUG=None
BRANCH=None

Change-Id: I00ccfc4bbf15f77c2777f35c911dceacaff98e4f
Signed-off-by: Levi Oliver <levio@google.com>
Reviewed-on: https://chromium-review.googlesource.com/368471
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-08-12 20:49:45 -07:00
Shawn Nematbakhsh
de4d25964d mkbp_event: Allow host to report sleep state for non-wake event skipping
Allow the host to self-report its sleep state through
EC_CMD_HOST_SLEEP_EVENT, which will typically be sent with SUSPEND
param when the host begins its sleep process. While the host has
self-reported that it is in SUSPEND, don't assert the interrupt
line, except for designated wake events.

BUG=chrome-os-partner:56156
BRANCH=None
TEST=On kevin, run 'ectool hostsleepstate suspend', verify that
interrupt assertion is skipped for battery host event. Run 'ectool
hostsleepstate resume' and verify interrupt is again asserted by the
battery host event.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I74288465587ccf7185cec717f7c1810602361b8c
Reviewed-on: https://chromium-review.googlesource.com/368391
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-08-12 13:45:35 -07:00
Divya Sasidharan
6b6ed79a56 Amenia/Reef: Present 1.5A Pullup
Enable config to choose the Rp pullup
strength to advertise the desired current
from USB-C while providing power.

BUG=chrome-os-partner:54452
BRANCH=none
TEST=Boot and check appropriate register
     settings in Reef.
     For Parade: i2cxfer r 1 0x16 0x1A -> 0x15

Change-Id: I5c1b7a45bf483333d7b411aad402fc95e4fa05de
Signed-off-by: Divya Sasidharan <divya.s.sasidharan@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/353038
Commit-Ready: Divya S Sasidharan <divya.s.sasidharan@intel.com>
Tested-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Kevin K Wong <kevin.k.wong@intel.com>
2016-08-11 16:52:00 -07:00
Levi Oliver
25c7cc0e4f btle: Cleanup: Moved constants, renamed functions
Moved link layer-specific constants into link layer .h file.
Renamed data channel function to better represent its function.

TEST=make BOARD=hadoken
BUG=None
BRANCH=None

Change-Id: I239d535cf3725bf003443fc211fc802bc8aee13f
Signed-off-by: Levi Oliver <levio@google.com>
Reviewed-on: https://chromium-review.googlesource.com/367805
Commit-Ready: Myles Watson <mylesgw@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-08-11 14:46:33 -07:00
Levi Oliver
bf302b55e9 btle: Add framework for parsing data packets
Re-wrote ble_radio_init to work with both data and
advertising packets. Updated all calls to refactored function.

RADIO_PCNF0_ADV renamed because it applies to advertisement and
data packet formats. Updated all references to this value.

TEST=make BOARD=hadoken
BUG=None
BRANCH=None

Change-Id: I0fdbe0eb146ce5cbc40e3ac67bf4d0e5465dcc2f
Signed-off-by: Levi Oliver <levio@google.com>
Reviewed-on: https://chromium-review.googlesource.com/367732
Commit-Ready: Myles Watson <mylesgw@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Myles Watson <mylesgw@chromium.org>
2016-08-11 14:46:32 -07:00
Mulin Chao
ef6e93dc1b npcx: Add espi driver of npcx5mng for x86-based platform.
Add espi driver for x86-based platform which support espi interface such
as skylake and so on.

Added source:
1. espi.c: Add drivers which supports the utilities of peripheral and
           virtual-wire channels so far.
2. espi.h: Add espi virtual-wire declaration for power sequence FW.

Modified sources:
1. lpc.c: Add interrupts and initialization steps for espi.
2. gpio.c: Add interrupt handler of espi reset.

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

Change-Id: Ie80afe79d85aba47fc0b72898a8374c2898ec114
Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/366181
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-08-10 22:16:57 -07:00
Shawn Nematbakhsh
d54387c18e kevin / gru: Notify host of HPD IRQ status
If an HPD IRQ event is seen, make note of it and keep the status set
until informing the host.

BUG=chrome-os-partner:55925
BRANCH=None
TEST=Manual on kevin, trigger HPD event, verify that event bit is set in
reply to first host command and not subsequent host commands.

Change-Id: I0900a683dcb344d5d4d03a1fa6e3d8de913597b2
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/366990
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Chris Zhong <zyw@rock-chips.com>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
2016-08-10 20:07:32 -07:00
james_chao
c144822368 Acpi: Notify host when orientation changes
1. EC send EC_HOST_EVENT_MODE_CHANGE(29/0x1D) when mode changes
2. Host read current "physical mode" from EC ERAM
3. Host Nodify DPTF object

BUG=chrome-os-partner:53526
BRANCH=master
TEST=make buildall

Change-Id: I3ede1ffd203024199884b3a0c56347ae630e6062
Signed-off-by: james_chao <james_chao@asus.com>
Reviewed-on: https://chromium-review.googlesource.com/363220
Commit-Ready: BoChao Jhan <james_chao@asus.com>
Tested-by: BoChao Jhan <james_chao@asus.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2016-08-09 22:11:09 -07:00
Vadim Bendebury
3b24f8ac3f cr50: try recovering from rolling reboots
Sometimes a perfectly sane image enters rolling reboot mode in case
some data change triggered a bug which prevents the normal startup and
causes a reset.

The most likely task causing in in case of cr50 would be the tpm task.

Let's add another check of the restart counter: should it reach the
value of 50, do not start the TPM task.

BRANCH=none
BUG=chrome-os-partner:55708

TEST=with this code plus an unaligned access introduced in tpm
     initialization sequence in both RW_A and RW_B, program the full
     image on the dev board.

     Observe the device reset 50 time is rapid succession and then
     stop with the following message on the console:

  Bldr |511709
  retry|50
  Himg =4F992103..408D193E
  Hfss =384E4655..EE13EBD0
  Hinf =44D21600..B70529BD
  jump @00044000

  --- UART initialized after reboot ---
  [Reset cause: rtc-alarm]
  [Image: RW, cr50_v1.1.5044-8d6f7a2+ private-cr51:v0.0.68-633229c ...
  + cryptoc:v0.0.4-5319e83 2016-08-07 19:37:16 vbendeb@kvasha]
  [0.004130 Inits done]
  [0.006919 Active NVram partition set to 0]
  Console is enabled; type HELP for help.
  > system_rolling_reboot_suspected: roling reboots suspected. Try \
   powercycling to clear
   this condition.
  [0.010502 Task 2 (TPM) exited!]

Change-Id: I6b08c5c1a02da9edf9bdf394e57cc56d2e595ad1
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/366892
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-08-08 20:19:46 -07:00
Vadim Bendebury
37784e1e86 cr50: fix nvmem calculations
The nvmem space defined in the ec code base for the cr50 board is used
by the TPM2 library, which has its own nvram size definition. The two
definitions must match.

On top of the fact that the definitions are not locked to each other,
there is a third completely unrelated nvram size definition in
board/cr50/board.c.

This patch unifies nvmem size definitions between cr50 and tpm2
repositories by adding a compile time check for the size to be the
same on both sides.

Also, it turns out that two certificates (RSA and ECC) together do not
quite fit into the cr50 TPM nvram. Hence the total allocated nvmem
space is being increased to 20K (note that the actual nvram size
available to the TPM is less than half of this).

BRANCH=none
BUG=chrome-os-partner:55898
TEST=tpm does not lock up any more when 'tpm_client --own' is ran on the
     Kevin-tpm2 command line

CQ-DEPEND=CL:367010
Change-Id: I20b4f54118bd2fa12e5bd5741d6c58fbe91f65d1
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/366796
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-08-08 20:19:44 -07:00
Nick Sanders
3e42a3b059 servo_v4: servo_micro: cr50: fix usb power declaration
Servo_micro sets usb config maxpower to 100mA.

Servo_v4 is set to self powered as it's powered by a
shared vbus and not be the bub it's connected to.

cr50 is self powered as no power is transmitted as part of CCD.

* Add CONFIG_USB_MAXPOWER_MA to define USB maximum power draw requested
per board.
* Add CONFIG_USB_SELF_POWERED to indicate that a device is not
powered by allocated USB power.

BUG=chromium:631302
TEST=lsusb reports 100mA bMaxPower (micro), Self powered (v4)
BRANCH=None

Change-Id: I79b8ce46f32d94f16104a4a8080104e30dce7f2c
Signed-off-by: Nick Sanders <nsanders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/363153
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-08-08 18:22:30 -07:00
Myles Watson
4820a97ad5 btle: Add the HCI layer
Add a case statement to handle HCI commands.
Add a test commands.
Try to match the hcitool syntax, so the same commands
can be executed on a Linux host.
Added lcmd (long cmd) to pass more parameters in fewer arguments

BUG=None
BRANCH=None
TEST=Use HCI commands to configure an advertiser and listen for
it using `hcitool lescan` on the host.

Change-Id: Ie28038847c9549eb1c27a605aa0fbad5efd3b2c7
Signed-off-by: Myles Watson <mylesgw@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/362145
Commit-Ready: Dan Shi <dshi@google.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-08-08 01:48:45 -07:00
Myles Watson
9ee1b4a767 btle: Add common link layer code
BUG=None
BRANCH=None
TEST=make BOARD=hadoken

Add a task that is responsible for the state of the link layer.

Change-Id: Ifc79bf1e4c57f5de448ab05b3a8d3a1aca5a58e2
Signed-off-by: Myles Watson <mylesgw@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/362144
Commit-Ready: Dan Shi <dshi@google.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-08-08 01:48:43 -07:00
Bill Richardson
73701c4637 cr50: Rename EXTENSION_EC to EXTENSION_ECC
I keep thinking this refers to "Embedded Controller" instead of
"Elliptic Curve Cryptography". Make it clearer.

There's no functional change, I'm just renaming a constant.

BUG=none
BRANCH=none
TEST=make buildall; run tests on Cr50 dev board

make -C test/tpm_test && sudo ./test/tpm_test/tpmtest.py

Change-Id: Iaf2e2839e88fdbbcb1a712934be56a0dd47e4a70
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/366752
Reviewed-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-08-07 23:48:38 -07:00
Carl Hamilton
6cee50001b ec_commands: Reserve command ids for CR51 firmware.
BRANCH=none
BUG=none
TEST=make -j buildall

Change-Id: I423d1eb450b8191f959733ab205b0c700916e88f
Reviewed-on: https://chromium-review.googlesource.com/366241
Commit-Ready: Carl Hamilton <carlh@chromium.org>
Tested-by: Carl Hamilton <carlh@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-08-05 13:56:39 -07:00
Bill Richardson
f1bd67dedc g: Decode more reasons for chip reset
There are few reasons why the SoC may reboot which we haven't
been reporting (they just show up as "[Reset cause: other]").
This adds a bit of decoding to explain some of those "other"
reasons.

BUG=none
BRANCH=none
TEST=make buildall; try on Cr50

I tested one of the new reasons using "crash hang". It shows up
correctly as "{Reset cause: security]". I haven't specifically
tested all of the new reasons, but since this is basically just a
change to console message they should work too. I'll double-check
those cases once some blocking bugs are fixed.

Change-Id: I46daed29d7e37bda9034a3486127bed0ea25f803
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/366400
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-08-05 11:45:25 -07:00
Vijay Hiremath
d93cbcff8d reef: Add code to read battery temperature
Reef doesn't have the battery temperature sense pin connected to
the charger, hence reading the battery temperature from the battery
registers.

BUG=chrome-os-partner:55834
BRANCH=none
TEST=Using 'battery' & 'temps' console command verified,
     temperature readings are same from both the commands.

Change-Id: I897e453296151f31344f3e0434202baa67c7025d
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/365970
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2016-08-03 19:41:02 -07:00
Scott
d67f3aa1f6 Cr50: Sample slave configuration pins at POR
There is just one version of Cr50 firmware for all boards
that it's used on. However, on some boards the AP communicates
to the TPM via a SPI interface (i.e. Kevin) and on others, the
AP communicates via an I2C interface (i.e. Reef). In order to
dynamically discover which interface to configure, there are
strapping resistors added to the board which enables the Cr50
to detect which configuration to implement.

This CL is a first pass and is only looking at DIOA1 which is
pulled high for SPI and pulled low for I2C configurations.
The strapping resistor should be read when the AP is in reset
prior to it attempting to drive any of the lines used for
strapping. To ensure this condition is met, Cr50 will only
check the strapping options following a POR (power on reset).
Once the configuration type is discovered, a 'long_life'
register is used to hold the result so that the result can
always be available. The long_life register contents remain
unchanged until a subsequent power down event.

BRANCH=none
BUG=chrome-os-partner:50728
TEST=manual
Tested on Kevin and Reef. Verfifed by reading the stored value
that the SPI configuraiton is detected for Kevin and the I2C
interface is detected on Reef. In addition, verified on Kevin
that the Cr50 FW version is correctly reported to the AP which
means that TPM register reads via the slave SPI are functioning.

Change-Id: Ibd7624ad8e3b4126f6346dce0bc72f62a3cc6d18
Signed-off-by: Scott <scollyer@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/363014
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-08-03 19:40:55 -07:00
Myles Watson
ef137bdecc common: Add Bluetooth LE support
Add data structures, defines, and helper functions to parse
packets and implement frequency hopping.

BUG=None
BRANCH=None
TEST=None

Change-Id: I0f7a7d4bee55e00343f6f87f304fb2ba57cb6ec0
Signed-off-by: Myles Watson <mylesgw@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/362174
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Levi Oliver <levio@google.com>
2016-08-02 23:20:41 -07:00
Ravi Chandra Sadineni
78a875eadb separate dptf logic from existing thermal logic.
Signed-off-by: Ravi Chandra Sadineni <ravisadineni@chromium.org>

BRANCH=none
BUG=chromium:631848
TEST=make buildall -j

Change-Id: I718a29b067d37af477306f9bebfcb8e71d84d4ee
Reviewed-on: https://chromium-review.googlesource.com/363008
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@google.com>
2016-07-30 01:24:52 -07:00
Vadim Bendebury
3d01f46a5b HACK tpm: reset fallback counter when ready
As a temp measure until a proper solution is implemented, reset the
restart counter when the PCR_Read command is issued by the host.

This is a good indication that Chrome OS is through the boot process,
as PCR value is used to determine the boot mode.

BRANCH=none
BUG=chrome-os-partner:55667
TEST=installed the new image on a Kevin cr50 and rebooted it in normal
     and recovery modes, observed on the cr50 console the message like
  > system_process_retry_counter:retry counter 1

Change-Id: Ib55e161d5edbf8f6e2d387fd756b94aa53c20ed8
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/364311
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-07-29 19:22:04 -07:00
Daisuke Nojiri
d3d6814b2d printf: Add sign ('+') flag
'+' flag can be used with signed integer type (%d) and causes positive
integers to be prefixed with '+' (e.g. +1745). This emphasizes output
values as a signed value. It can be mixed with left-justification flag
'-': %-+8d. It's ignored when used with unsigned integer or non-integer
types: %u, %x, %p, %s, %c, etc.

BUG=none
BRANCH=none
TEST=make buildall &&
int32_t d = 1745;
CPRINTS("'%-+8d'", -d);     /* '-1745    ' */
CPRINTS("'%-+8d'", d);      /* '+1745    ' */
CPRINTS("'%d'", d);         /* '1745' */
CPRINTS("'%+08d'", -d);     /* '000-1745' */
CPRINTS("'%+08d'", d);      /* '000+1745' */
CPRINTS("'%+d'", -d);       /* '-1745' */
CPRINTS("'%+d'", d);        /* '+1745' */
CPRINTS("'%+s'", "foo");    /* 'foo' */
CPRINTS("'%-+8s'", "foo");  /* 'foo     ' */
CPRINTS("'%+08x'", d);      /* '000006d1' */
CPRINTS("'%+u'", d);        /* '1745' */

Change-Id: I8dcd34b0cf03dbefc500b9c98fea235d85bde8d3
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/363924
2016-07-29 10:51:22 -07:00
Vincent Palatin
c48408f0ba pd: support CCD provided by an external chip
When the case close debug (CCD) feature is provided by an external chip
(e.g security chip or TCPC), we still need to be able to detect debug
accessory with Rd/Rd (by setting Rp/Rp when VBUS is detected without
seeing Rp).
Add a CONFIG_CASE_CLOSED_DEBUG_EXTERNAL configuration parameter for this
case.

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

BRANCH=none
BUG=chrome-os-partner:55410
TEST=manual:on Kevin, enable CONFIG_CASE_CLOSED_DEBUG_EXTERNAL,
plug a SuzyQ (with Rd/Rd) and verify that the device in debug mode
when transitioning to S5.

Change-Id: Ie04a000a7b0eb670e3808f7bca1180298dfcd9db
Reviewed-on: https://chromium-review.googlesource.com/363400
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-07-27 02:03:49 -07:00
Bill Richardson
20a6d75aee g: Improve version info for dual RO & RW images
The SoC looks for two RO images at reset, and is typically
configured for two RW images as well. This CL reports version
strings for all those images, as well as identifying the active
RO and RW copies.

Since the RO image doesn't contain a version string, we create
one using the epoch_, major_, minor_, and img_chk_ members of its
signed header.

BUG=chrome-os-partner:55558
BRANCH=none
TEST=make buildall; run on Cr50 hardware

The "version" command now includes information like this:

  RO_A:  * 0.0.2/a3c3d5ea
  RO_B:    0.0.2/8895c9eb
  RW_A:    cr50_v1.1.4965-a6c1c73-dirty
  RW_B:  * cr50_v1.1.4959-2f49d5c

The '*' indicates the active image.

The test/tpm_test/tpmtest.py program has been updated to request
the version information at startup, and it also now reports
similar information, just all on one line:

  RO_A:* 0.0.2/a3c3d5ea RO_B: 0.0.2/8895c9eb RW_A: cr50_v1.1 ...

The active images are marked with a '*' following the ':', so
that the same regexp can match either format:

  ($ro, $rw) = m/RO_[AB]:\s*\*\s+(\S+).*RW_[AB]:\s*\*\s+(\S+)/s;

Change-Id: Ic27e295d9122045b2ec5a638933924b65ecc8e43
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/362861
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-07-26 12:27:33 -07:00
Myles Watson
698777d4e3 include: Add HCI include files from NewBlue
Copied with permission from Dmitry Grinberg, the original author.

Add HCI_SUCCESS, some minor fixes.

BUG=None
BRANCH=None
TEST=None

Change-Id: Ia4f6f0d092674fca1297e94a16edbc14399d2c63
Signed-off-by: Myles Watson <mylesgw@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/362348
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Levi Oliver <levio@google.com>
2016-07-22 20:37:17 -07:00
nagendra modadugu
e819881b8c CR50: add endorsement certificate flow
This change implements logic for installing
endorsement certificates in the RW section.

The endorsement certificates are initially
provisioned in a fixed RO flash region and
are copied in the RW TPM data region (once
this region has been initialized).

Also add code for reading from the info bank,
which is where the endorsement seed is
initially stored.

BRANCH=none
BUG=chrome-os-partner:43025,chrome-os-partner:47524
BUG=chrome-os-partner:50115
TEST=TCG tests running

Change-Id: Id8c16d399202eee4ac0c4e397bdd29641ff9d2f3
Signed-off-by: nagendra modadugu <ngm@google.com>
Reviewed-on: https://chromium-review.googlesource.com/362402
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Vadim Bendebury <vbendeb@chromium.org>
2016-07-23 02:18:49 +00:00