summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
* pd: zinger: add sending hard reset on pd_board_check() falutAlec Berg2014-07-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Add back in sending hard reset on board fault. BUG=none BRANCH=none TEST=Using zinger and firefly, create an overvoltage error by down stepping with a 0 VOLTAGE_DOWN_STEP_TIME, and make sure that a hard reset is received by firefly and that we re-establish negotiation after the OVP fault is cleared. Also tested with zinger and samus. On samus I set the input current to 3.5A, which immediately triggers an OCP, and verified that we get a HARD RESET from zinger and that after the reset we negotiate correctly and get back to normal (note that when VBUS goes down, the EC resets the input current limit to default 2A, so that's why we don't continue getting OCP). Change-Id: I991b15411c4ce05c1086851b1e2e56e2effab749 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/209865 Reviewed-by: Vic Yang <victoryang@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* pd: allow sink to request new voltage w/o dropping negotiationAlec Berg2014-07-292-26/+63
| | | | | | | | | | | | | | | | | | | | Allow a sink to request a new voltage without dropping the established negotiation. For this to work the sink must save the last received source cap packet and use that to make a new RDO from the SNK_READY state. BUG=chrome-os-partner:30389 BRANCH=none TEST=Tested on a firefly connected to zinger. made sure we can press buttons to change voltage and we don't lose the existing negotiation. Also tested on samus, ports 0 and 1, using pd x dev 5/12/20 to switch between voltages and verified we don't lose existing negotiation. Change-Id: I5a550b667f3aff7975185e091f3caac4555a907e Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/209864 Reviewed-by: Vic Yang <victoryang@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* zinger: fix down voltage transitions to keep output enabledAlec Berg2014-07-291-6/+29
| | | | | | | | | | | | | | | | | | | Fix bug in which output was disabled on down voltage transitions. This also changes the behavior of the OVP protection. On down-step transitions, the OVP threshold is not lowered for a specified amount of time after the transition to allow the output to dissipate down to the new voltage. This will still catch a problem if the voltage goes up instead of down, but avoid OVPing immediately on a normal down transition. BUG=chrome-os-partner:30389 BRANCH=none TEST=Attach to firefly and probe output voltage. Make sure we transition smoothly going down in voltage. Change-Id: I7f3a0c17cc8b392a25d24d56d2b7155b806acb64 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/209863
* hadoken: initial commit.Louis Yung-Chieh Lo2014-07-2915-0/+964
| | | | | | | | | | | | | | | Board bring up. GPIO / UART / timer / console / task / hook are working now. BRANCH=tot BUG=none TEST=run on evaluation board and see LED 0/1 are blinking. Console commands are available to use. Change-Id: If93a2c94b8abe1c2c931c03a7a12ddd2bed9d9f6 Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/209403 Reviewed-by: Vic Yang <victoryang@chromium.org>
* ryu: limit input current to 1AVincent Palatin2014-07-291-1/+1
| | | | | | | | | | | | | | | | | | | Limit the total input current to 1A, so we can power the board from a workstation USB port when doing update with A-A cable. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=connect the Ryu type-C port to a Z620 workstation USB port, and verify that VBUS is not browning out Change-Id: I05e65bd7feeb5e18f48c99bca9db43284e91251c Reviewed-on: https://chromium-review.googlesource.com/207352 Reviewed-by: Vic Yang <victoryang@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Vic Yang <victoryang@chromium.org> Commit-Queue: Vic Yang <victoryang@chromium.org>
* tegra: Support firmware long-press power off timerVincent Palatin2014-07-292-0/+16
| | | | | | | | | | | | | | | | | | | | Some PMIC chip (e.g. TPS65913) doesn't support the 8-second long key press power-off. For this, we have to check the state of the power button in firmware, and do not assert PMIC_PWRON during the shutdown sequence to prevent the AP from restarting. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=with the next CL, on Ryu, do a long power button key press, and see the AP powering off and not restarting. Change-Id: I03f703b4ff6d86edea150dfa32f60d30f1ddffd9 Reviewed-on: https://chromium-review.googlesource.com/207381 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Vic Yang <victoryang@chromium.org> Commit-Queue: Vic Yang <victoryang@chromium.org>
* Bug fixes for USB PD policiesVic Yang2014-07-293-3/+3
| | | | | | | | | | | | | | | | We used the incorrect src_caps index when choosing PD voltage. Let's fix it to ask for all available power until we are able to ask only for what we need. BUG=None TEST=make buildall BRANCH=None Change-Id: I068264246c2586b8192220eff47838da438899b0 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/207802 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* ryu: Lower battery charging voltageVic Yang2014-07-291-1/+1
| | | | | | | | | | | | | | The design voltage is 4.35V and the current charging voltage, 4.4V, is too high. Let's lower this to 4.34V to meet the designed voltage. BUG=none BRANCH=none TEST=none Change-Id: Id5ab111d7ef390fe509adbb75112c78de1aab8a9 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/207687 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* ryu: add power sequencingVincent Palatin2014-07-294-11/+36
| | | | | | | | | | | | | | | | | | Update the Ryu board configuration to re-use the Tegra power state machine. Add the new HOLD GPIO which is wired to PE14 (TP2). Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=on Ryu, use the power button to switch on and off the AP. Change-Id: I310438e0b923956d1539fb919c266a94909e3461 Reviewed-on: https://chromium-review.googlesource.com/206854 Reviewed-by: Vic Yang <victoryang@chromium.org> Tested-by: Vic Yang <victoryang@chromium.org> Commit-Queue: Vic Yang <victoryang@chromium.org>
* power_button: allow to modify the active levelVincent Palatin2014-07-292-1/+10
| | | | | | | | | | | | | | | | | | | On most platforms, the power button is active low, but the power button on Ryu is active high. Add CONFIG_POWER_BUTTON_ACTIVE_STATE to override the default active state. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=on Ryu, use the servo pwr_button to start and stop the AP. Change-Id: I11c6bb3c700bccd3606ce1fa1a69905671792990 Reviewed-on: https://chromium-review.googlesource.com/207274 Reviewed-by: Vic Yang <victoryang@chromium.org> Tested-by: Vic Yang <victoryang@chromium.org> Commit-Queue: Vic Yang <victoryang@chromium.org>
* battery: fix BQ27541/BQ27741 gas gauge driverVincent Palatin2014-07-291-6/+21
| | | | | | | | | | | | | | | | | | | | | | Update the code to be compatible with charge v2 expectations : never return EC_ERROR_UNIMPLEMENTED for battery information else the charge code continuously tries to read them again. Fix the State Of Charge reading : on BQ27741 the gas gauge gets confused if we do a 16-bit I2C read while a 8-bit read works perfectly. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=run a Ryu connected to a Kirby battery and check the output of the "battery" command. Change-Id: Ic1d6128dc02efa47662fa5ca5b9e5de62420ebe8 Reviewed-on: https://chromium-review.googlesource.com/207273 Reviewed-by: Vic Yang <victoryang@chromium.org> Tested-by: Vic Yang <victoryang@chromium.org> Commit-Queue: Vic Yang <victoryang@chromium.org>
* stm32f0: Fix EC slave I2C interruptVic Yang2014-07-291-2/+10
| | | | | | | | | | | | | | The interrupt handler is hardcoded to I2C1. We should choose between I2C1 and I2C2 based on I2C_PORT_EC. BUG=chrome-os-partner:30707 TEST=On Ryu, ectool hello and see ACK. BRANCH=None Change-Id: I07055b0ee7459e6cac5585737e200ff2d5814a34 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/209960 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* pd: sink change sending getSourceCap to hard reset after timeoutAlec Berg2014-07-291-23/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changes to match this part of the spec: The Sink shall support the SinkWaitCapTimer. When a Sink observes an absence of Source Capabilities messages, after VBUS is present, for a duration of tTypeCSinkWaitCap for the Type-C connector and tSinkWaitCap after VBUS is present,for all other connectors the Sink shall issue Hard Reset signaling in order to restart the sending of Source Capabilities messages by the Source (see Section 6.6.4). tTypeCSinkWaitCap shall be between 210 and 250 ms Also set send source cap period appropriately: tTypeCSendSourceCap shall be between 100 and 200 ms This should help avoid transmission collisions during negotiation. BUG=chrome-os-partner:30135 BRANCH=none TEST=load onto zinger and samus and verify they negotiate correctly 10 times. Then loaded custom code to zinger to not send source cap and verified we send hard reset. Also tested plankton to samus negotiation works. Change-Id: Idd6118e3e0a9f7a96ebeae9518c8b10457232c70 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/209558 Reviewed-by: Vic Yang <victoryang@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* plankton: Support 5V only modeVic Yang2014-07-296-7/+53
| | | | | | | | | | | | | | | | When Plankton is in 5V only mode, we should only advertise 5V capability. BUG=None TEST=Connect to Samus. Check the PDO received on Samus. BRANCH=None Change-Id: Ia2b65c1b202aba291a008511801ede4d5c93aac5 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/209481 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Alec Berg <alecaberg@chromium.org> Tested-by: Alec Berg <alecaberg@chromium.org>
* Plankton: console command for USB-C port controlVic Yang2014-07-281-8/+83
| | | | | | | | | | | | | | | | The console commands will be used by the test host to control USB-C port. BUG=None BRANCH=None TEST=Manually verify the console command are working. Change-Id: I4b229d9486bd970f6b73e9166ae1cb137d3530c6 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/209347 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Alec Berg <alecaberg@chromium.org>
* Add board support for PlanktonAlec Berg2014-07-288-1/+573
| | | | | | | | | | | | | | | Board support for Planton, the Raiden testing board for type-C functional testing. BUG=none BRANCH=none TEST=make BOARD=plankton, load onto a plankton, and verify buttons are read correctly, and connect raiden to samus and verify that PD communication is successful Change-Id: I40922d5627d62f7f3540ac6a307596428d40baf5 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/207724
* veyron: Sharing the single bicolor LED to also display power statusAlexandru M Stan2014-07-281-36/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Veyron only has one bicolor led (green and orange) near the AC connector. I dedicated the green channel for displaying power status: * Power on: Green * Suspend: Green in breeze mode ( 1 sec on/ 3 sec off) * Power off: OFF Charging is now displayed only on the orange channel: * Fully charged / idle: Off * Under charging: Orange * Battery low (10%): Orange in breeze mode (1 sec on, 3 sec off) * Battery critical low (less than 3%) or abnormal battery situation: Orange in blinking mode (1 sec on, 1 sec off) * Using battery or not connected to AC power: OFF The unfortunate side effect is that they have to share. So while the laptop is charging in standby the led will blink orange(1s)-yellow(3s). While it's a little ugly (it would have been nice to have 2 separate leds), it still provides more information than how it was done before (where there was no indication of power state). BUG=None TEST=Go through the various states (charging on/off/low and power on/off/ /suspend (warning: kernel doesn't report suspend to the EC properly yet, one can still test this by reverting c/209668 "veyron: fixed SUSPEND_L line")) BRANCH=None Change-Id: I8ca0fb0909da1a186e4e5c451d8868e977b3ca1b Signed-off-by: Alexandru M Stan <amstan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/209911 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Chris Zhong <zyw@rock-chips.com> Commit-Queue: Doug Anderson <dianders@chromium.org>
* usb: fix bug with multiple usb interfacesDominic Chen2014-07-281-1/+1
| | | | | | | | | | | | | | | | for interface specific requests, the interface number is equivalent to (wIndex & 0xff). this corresponds to ep0_buf_rx[2], since the setup packet has format: bmRequestType (1), bRequest (1), wValue (2), wIndex (2), wLength (2). BUG=none BRANCH=none TEST=verify stm32 does not panic with multiple interfaces Change-Id: Ied7750035f87fa81f9a6c03c6e73ae606c110398 Signed-off-by: Dominic Chen <ddchen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/209903 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* zinger: do not trigger OCP on transientsVincent Palatin2014-07-281-5/+22
| | | | | | | | | | | | | | | | | | | Ensure that the slow OCP (thermal/power protection) is not triggering for power spikes below 20us, by sampling 4 times (with a 5us sampling period). Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:28331 TEST=connect Zinger to Firefly+electronic load, test with various current pulse widths and amplitudes. Change-Id: Ic8150dbbf191c002bba9e8d3f70beb47af4577b9 Reviewed-on: https://chromium-review.googlesource.com/204588 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Alec Berg <alecaberg@chromium.org>
* samus: include a force source mode for dual-role portsAlec Berg2014-07-282-27/+60
| | | | | | | | | | | | | | | Include a force source mode for dual-role ports to allow us to force a dual-role port into being a source. BUG=chrome-os-partner:28782 BRANCH=none TEST=tested on plankton, verified using the pd 0 dualrole console command. Change-Id: Ic4c2a9e11984b34b1dec09d5c71e1fd15ed9198c Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/209071 Reviewed-by: Vic Yang <victoryang@chromium.org>
* samus: pd: dual USB-PD port support for samusAlec Berg2014-07-2823-664/+951
| | | | | | | | | | | | | | | | | | | | | | | | | Adds dual USB-PD port support for samus. Both ports are in dual-role and can perform either role. Both ports work fine when only one of the ports is in use. But, still having problems with PD errors on the lower priority port (port 0). If you have a charger plugged into port 0, and a type-C USB dongle plugged into port 1, then port 1 has higher priority, and in the SRC_DISCONNECTED state, every 1.5 seconds when it sends source cap packet, we occasionally drop pings on port 0, which results in a lot of start/stop charging. BUG=chrome-os-partner:28585 BRANCH=none TEST=Tested on samus to make sure both ports work when I plug in a charger and a type-C USB dongle with a pull-down on the CC line. Tested on plankton and zinger to make sure PD works as expected. Change-Id: Ie7bde3e258f5cd23a0b82b626c0993a45b0df074 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/200750 Reviewed-by: Vic Yang <victoryang@chromium.org> Tested-by: Vic Yang <victoryang@chromium.org>
* [ryu_sh] Add option to flash the sensor hubGwendal Grignou2014-07-281-1/+11
| | | | | | | | | | | | | | | servo is already aware of the sensor hub. Using samus_pd as an example, set the proper argument to flash an image to the sensor hub. BUG=chrome-os-partner:30801 BRANCH=None TEST=None Change-Id: I0c8465d1e34d515224675957c3e8482392585a56 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/209232 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* stm32f07x: increase RAM space to 16kBAlec Berg2014-07-261-1/+1
| | | | | | | | | | | | | | | | | Increase RAM_SIZE for all stm32f07x chips to 16kB to use all of on chip SRAM. BUG=none BRANCH=none TEST=added 4000 byte array, verified in ec.RO.map that we are using the new RAM space (bss size over 0x2000), loaded on samus and verified that we could read and write to the 4000 byte array. Change-Id: Ided3ce7c5fb353c9c37a01e6ed64f03786717e9b Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/209847 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Vic Yang <victoryang@chromium.org>
* veyron: fixed SUSPEND_L lineAlexandru M Stan2014-07-261-1/+2
| | | | | | | | | | | | | | | Pulled down line so it's not so erratic. Fixes the issue where the EC doesn't know what state the AP is in. BUG=None TEST=EC should report S0 correctly(not S3 all the time). `power on` and `power off` will also work correctly(instead of doing absolutelly nothing). BRANCH=None Change-Id: I69bd17b39d2bd8f7f0456c4babc4ad9f8f34c8bd Signed-off-by: Alexandru M Stan <amstan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/209668 Reviewed-by: Chris Zhong <zyw@rock-chips.com>
* veyron: renamed PMIC_THERM_H -> PMIC_SOURCE_PWR_HAlexandru M Stan2014-07-252-2/+2
| | | | | | | | | | | | | | It is now the proper name. BUG=None TEST=None, only name changed. EC should work as expected still. BRANCH=None Change-Id: Ia63db6fa0dc41750ebf31423c9870f8a463bf392 Signed-off-by: Alexandru M Stan <amstan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/209814 Reviewed-by: Chris Zhong <zyw@rock-chips.com> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* ryu: Kick battery out of disconnect state when AC is attachedstabilize-6092.BVic Yang2014-07-252-0/+50
| | | | | | | | | | | | | | | | Like Samus, the battery can be placed into a disconnect state. This CL implements the necessary function to determine if it is so and kick it out of this state when possible. BUG=chrome-os-partner:30633 TEST=Put a battery in this state. Plug in AC. Verify the battery is revived. BRANCH=None Change-Id: I074a72a2efe3844cbdfb0eda16a25fd8d1755a9b Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/209634 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* zinger: fix USART register macro bugAlec Berg2014-07-253-8/+9
| | | | | | | | | | | | | | | Fix bug in which we were using the wrong index to the USART register macros. This bug was recently introduced in: https://chromium-review.googlesource.com/208488 BUG=none BRANCH=none TEST=load code on zinger and verify serial console works Change-Id: I03142a8cafb68e0cbbcba4b720e7ec89fe20110b Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/209557 Reviewed-by: Anton Staaf <robotboy@chromium.org>
* Disable building test binaries for samus_pdVic Yang2014-07-251-0/+4
| | | | | | | | | | | | | | | | We are running out of RAM space for samus_pd. Let's disable test binaries for now. Note that this has nothing to do with unit tests. BUG=None TEST=make BOARD=samus_pd tests. Nothing happens. BRANCH=None Change-Id: I39db9b914e8539b4585a93a8732dc42248a9a6bf Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/209781 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Alec Berg <alecaberg@chromium.org>
* veyron: copy battery info from rambizyw2014-07-231-279/+20
| | | | | | | | | | | | | | | Fixed "un-recognized battery Manuf:Simplo, Device:0C9". BUG=None TEST=Read the correct battery info in the log BRANCH=None Change-Id: I960729541203705c15157aae61833457b727efa4 Signed-off-by: zyw <zyw@rock-chips.com> Reviewed-on: https://chromium-review.googlesource.com/209402 Reviewed-by: Alexandru Stan <amstan@google.com> Commit-Queue: Alexandru Stan <amstan@google.com> Tested-by: Alexandru Stan <amstan@google.com>
* samus_pd: stm32f0: check warm reboot before initializing ADCAlec Berg2014-07-231-0/+7
| | | | | | | | | | | | | | | | | | | Check for warm reboot before initializing ADC. Part of the initialization process involves calibration of the ADC, which can only be done when the ADC peripheral is disabled. This fixes a bug on samus_pd where jumping to RW causes a watchdog because ADC reads hang. BUG=chrome-os-partner:30079 BRANCH=none TEST=on samus_pd, without this change running sysjump rw causes us to jump to RW and then causes a watchdog. With this change sysjump rw works. Also verified that PD communication works in RW, which means ADC channels are being read correctly after jumping to RW. Change-Id: Iaa41da4795c3d15a6db56b0d715e36c29417d9b6 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/209331 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* spi_flash: add error checking for dma timeoutsDominic Chen2014-07-231-3/+8
| | | | | | | | | | | BUG=none BRANCH=none TEST=verify timeouts are caught by spi_transaction_*() Change-Id: I2e28ccbce58e555262bc4448a1c2e1a50253613e Signed-off-by: Dominic Chen <ddchen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/209116 Reviewed-by: Vic Yang <victoryang@chromium.org>
* veyron: Modify board configzyw2014-07-2310-99/+684
| | | | | | | | | | | | | | | | This patch is base on new hardware board, veyron has not some stuff, such as power led, charge en BUG=None TEST=Read log with servo board, it has reponse when type some commends BRANCH=None Change-Id: I45502fd1278f69db5e46fc9ab1deaee02fc8708f Signed-off-by: zyw <zyw@rock-chips.com> Reviewed-on: https://chromium-review.googlesource.com/209231 Reviewed-by: Alexandru Stan <amstan@google.com> Commit-Queue: Alexandru Stan <amstan@google.com> Tested-by: Alexandru Stan <amstan@google.com>
* samus: Kick battery out of disconnect state when AC is attachedShawn Nematbakhsh2014-07-236-0/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Samus battery can be placed into a disconnect state by asserting a disconnect input signal. In this state, the battery will not function until a charging current is applied. This patch adds detection of the disconnect state. If a battery in disconnect state is found, a current is force-applied to the battery to kick it out of disconnect. BRANCH=None TEST=Manual on Samus. 1. Put battery into disconnect state 2. Pull AC, then reattach AC 3. Verify "found battery in disconnect state" is seen on the EC console. 4. Pull AC and verify that EC console is still accessable Also verify that battery gets out of reset state: 1. Pull AC 2. Issue "i2cxfer w16 0 0x16 0x0 0x12" command on EC console 3. Re-attach AC 4. Pull AC and verify that EC console is still accessable BUG=chrome-os-partner:29465 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: Ib4268887fb483094ac4e641749200268160d3014 Reviewed-on: https://chromium-review.googlesource.com/209013 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Alec Berg <alecaberg@chromium.org> Tested-by: Alec Berg <alecaberg@chromium.org>
* i2c: Add variable to set slave address of the EC.stabilize-6082.BGwendal Grignou2014-07-204-1/+17
| | | | | | | | | | | | | | | | Only one EC was an i2c slave, samus_pd. Now we have 2 more, ryu and ryu_sh (sensor hub). Define a new variable: CONFIG_HOSTCMD_I2C_SLAVE_ADDR TEST=Compiled BRANCH=None BUG=chrome-os-partner:30740 Change-Id: I484aaf5ca72f14a91ce261b91fbe600dca3474dc Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/208978 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* stm32f0: Fix repeated start for I2CVic Yang2014-07-181-4/+3
| | | | | | | | | | | | | | | | We want repeated start instead of stop+start. Apparently, we need to set START bit along with read configuration. Otherwise, the I2C module generates a STOP condition. BUG=None TEST=Monitor I2C with a logic analyzer. See repeated start instead of stop+start. BRANCH=All using stm32f0. Change-Id: I47491e240f2543e5d023e950d15468ec0e3c301b Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/208760 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* I2C console command bug fixVic Yang2014-07-171-1/+1
| | | | | | | | | | | | | | We are now using argv[5] even if the user only gives 5 arguments. Fix it. BUG=None TEST=Read with i2cxfer command and doesn't see "Invalid param 5" BRANCH=None (this can be worked around by adding a dummy param) Change-Id: Ice13fec4ad53c71b6529daa3510fa6fc1d7f8c00 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/208489 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* stm32: change USART register macros to take a base addressAnton Staaf2014-07-172-56/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously these macros took a small integer to identify the USART to access. This integer was token concatenated to form the macro name that resolved to the base address. This made it imposible to use these macros in a driver that could manage more than one USART because there was no runtime way to go from base address (or other unique identifier) to register address. This change makes it possible to pass either a static compile time known base address or a runtime variable with the base address, thus supporting either sort of driver. The existing USART driver has been updated to compute the base address of the console USART and pass that at compile time, resulting in no increase in code size. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=none TEST=make buildall -j Followed by manual testing of console over UART functionality on the STM32F072 based discovery board. Change-Id: I06547a173b1e5cf625a57019ea4b8a84d1768444 Reviewed-on: https://chromium-review.googlesource.com/208488 Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org> Tested-by: Anton Staaf <robotboy@chromium.org>
* firefly: fix bug, correctly set CC transmit to a high speed outputAlec Berg2014-07-171-2/+2
| | | | | | | | | | | | | Correctly set CC1 transmit pin to a high speed output. BUG=none BRANCH=none TEST=make -j buildall Change-Id: I54d0d8ae3ea485728e340430bbb63ecf24c10bd6 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/207995 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* usb: add USB console driverVincent Palatin2014-07-175-15/+356
| | | | | | | | | | | | | | | | | Provide access to the EC console through 2 USB bulk endpoints. (which can be used through the usbserial driver) Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=run on Fruitpie and use the console over USB Change-Id: Ia897764f3a030972ee2ed323f293c5fca899765a Reviewed-on: https://chromium-review.googlesource.com/204167 Reviewed-by: Anton Staaf <robotboy@chromium.org> Commit-Queue: Vic Yang <victoryang@chromium.org> Tested-by: Vic Yang <victoryang@chromium.org>
* GPIO: Move definition of alternate functions to gpio.incAnton Staaf2014-07-1746-270/+190
| | | | | | | | | | | | | | | | | | | | | This is a straightforward conversion of existing tables into X-Macro style definitions for the GPIO alternate functions. This change in itself, is not particularly powerful, but having all GPIO settings in a single file makes a board easier to understand. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=none TEST=make buildall -j Followed by manual testing of interrupt on change and UART functionality on STM32F0 based discovery board. Change-Id: Ib7f1f014f4bd289d7c0ac3100470ba2dc71ca579 Reviewed-on: https://chromium-review.googlesource.com/207987 Reviewed-by: Randall Spangler <rspangler@chromium.org> Tested-by: Anton Staaf <robotboy@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org>
* GPIO: Reduce code duplication in STM32 gpio driverAnton Staaf2014-07-177-558/+303
| | | | | | | | | | | | | | | | | | | | Previously the F0 and L variants had almost identical driver files and the F variant shared about half of its driver. This refactor moves the shared code into gpio.c and gpio-f0-l.c, the latter is for code shared between the F0 and L variants. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=none TEST=make buildall -j Followed by manual testing of interrupt on change and UART functionality on STM32F0 based discovery board. Change-Id: I920babd1861548272af2857c8bd3e4f9dac4985c Reviewed-on: https://chromium-review.googlesource.com/207986 Tested-by: Anton Staaf <robotboy@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org>
* USB Power: Add config option to set default charge modeDave Parker2014-07-172-2/+12
| | | | | | | | | | | | | | | BUG=chrome-os-partner:29053 BRANCH=ToT TEST=Set a default change mode other than SDP2 in a board config. Verify the 'usbchargemode' console command indicates the ports are operating in that mode. Change-Id: I0d572df726c4bb42d0ff5f40c06d8ea73e406283 Signed-off-by: Dave Parker <dparker@chromium.org> Origianl-Change-Id: I4a65d8b6ad14ff3d1f12b644960bbf401027f8df Reviewed-on: https://chromium-review.googlesource.com/205812 Reviewed-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/208162
* USB Power: Invert ILIM control line with 'smart simple' chargingDave Parker2014-07-171-3/+3
| | | | | | | | | | | | | | | | | | | The ILIM control line is inverted before reaching the USB charge controllers when they are cross-connected to allow only one port to deliver the HIGH current limit at a time. BUG=chrome-os-partner:29053 BRANCH=ToT TEST=Verify, with a multimeter, that ILIM (pin 4) on a TPS2546 is 3.3V when the chargemode is set to CDP Change-Id: I2f720d04b959417ae96687d7e30ee60270eeccb9 Original-Change-Id: Idd89dcfc117f1f3393ded1887e8d1cb27ba367ad Signed-off-by: Dave Parker <dparker@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/205811 Reviewed-by: Vic Yang <victoryang@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/208161
* disable tests for ryuAaron Durbin2014-07-161-0/+3
| | | | | | | | | | | | | | | | When emerging chromeos-ec for ryu the build blows up when doing tests. Remove all tests for RYU so that we can start building the EC code through the build system. BUG=chrome-os-partner:30659 BRANCH=None TEST=Can emerge-rush_ryu chromeos-ec Change-Id: I293f2640891f42cfea0eb8aeb1ff1de603db9a93 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/208063 Reviewed-by: Vic Yang <victoryang@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Samus: Reduce S3S0 signal delay to 5ms.Bill Richardson2014-07-161-2/+6
| | | | | | | | | | | | | | | | | With only mini-PCIe devices, we don't need to wait for the full 99ms that PCIe devices require. BUG=chrome-os-partner:25530 BRANCH=ToT TEST=manual Log in, connect to the web via WiFi. Close the lid, wait a bit, open the lid. WiFi should resume and still work. Change-Id: I24d6ae95607f8f9a0fa70aebf5eaa0ebd68260f6 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/200084 Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
* samus: add options for device passthru and interfaceRandall Spangler2014-07-168-27/+84
| | | | | | | | | | | | | | | | | | | | | | This allows sending host commands to the PD chip through the EC. The --interface option allows forcing a particular host interface. This is necessary at present because the crosec device driver doesn't support host protocol v3 so only has 8-bit command numbers. BUG=chrome-os-partner:30079 BRANCH=none TEST=from EC console, ectool version -> prints EC version ectool --interface=lpc --dev=0 version -> prints EC version ectool --interface=lpc --dev=1 version -> prints PD version ectool --interface=lpc --dev=2 version -> prints error ectool --interface=i2c version -> can't find EC ectool --interface=dev version -> prints EC version Change-Id: I9dd10578dac77e3e104d19e2f37759814eec6ca2 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/207948
* Refactor STM32 SPI flash driverVic Yang2014-07-158-330/+383
| | | | | | | | | | | | | | | | | This CL factors out the SPI flash driver to be a STM32-specific SPI master driver and a common SPI flash driver. BUG=None TEST=Verify on Fruitpie BRANCH=None Change-Id: I9cca918299bc57a6532c85c4452e73f04550a424 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/206582 Reviewed-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Daming Chen <ddchen@chromium.org> Tested-by: Daming Chen <ddchen@chromium.org>
* Add getopt support to ectoolRandall Spangler2014-07-151-17/+65
| | | | | | | | | | | | | | | | | | | | This is needed for supporting device passthru. Right now, the --dev option simply prints an error. BUG=chrome-os-partner:30079 BRANCH=none TEST=manual ectool -> prints an error ectool help -> prints list of commands ectool version -> prints EC version ectool --dev=0 version -> prints EC version ectool --dev=1 version -> prints error about bad device 1 ectool --dev=0 -> prints an error (because there's no command) ectool --dev=0 foo -> prints 'unknown command foo' Change-Id: I0f431a4789428cd6cc8ef48b396b38237935282a Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/207904
* pd: support for dual-role portAlec Berg2014-07-144-11/+198
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for toggling between source and sink as dual-role port. When transitioning to S0, we turn toggling on, when transitioning to S3, we turn toggling off but remain in the same PD state, and when transitioning to S5, we turn toggling off and force the PD role to a sink. Note, when toggling is off, the source disconnected state is allowed to transition to sink disconnected, but not vice versa. This means that if you go into S3 as a source, it will remain a source until the device is unplugged, at which point it will transition to a sink until the next transition to S0. The spec specifies: tDRP: 50ms - 100ms, Period a DRP shall complete a DFP to UFP and back dcDRP: 30% - 70%, Percent of time that a DRP shall advertise DFP tDRPHold: 100ms - 150ms, time to hold VBUS on after a DRP detects a UFP tDRPLock: 100ms - 150ms, time to stay in DFP after detecting loss of UFP This CL uses 40ms for time as a UFP (sink), 30ms for time as a DFP (source), and 120ms for hold and lock times. Also, if advertising as a DFP (source) and VBUS is detected, this automatically switches to a UFP (sink). BUG=chrome-os-partner:28782 BRANCH=none TEST=test on samus, make sure we are toggling between source and sink when disconnected. make sure plugging in zinger switches state machine through to sink_ready and make sure plugging in a USB switches to source_discovery. tested on a fruitpie by scoping the CC line and verifying the timing (except the hold time which I can't easily test). tested that dual role toggling is off in s3 and s5. also verified that going into s3 as a source keeps the port as a source and going into s5 switches it to a sink. Change-Id: I478634861f694164301d71359da35142ee7ebf75 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/207154 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* samus: Add passthru for host commandsRandall Spangler2014-07-142-8/+55
| | | | | | | | | | | | | | | | | | | | Host commands in the range 0x4000-0x7fff will be passed thru the EC to the PD MCU as 0x0000-0x3fff. BUG=chrome-os-partner:30079 BRANCH=samus TEST=manual. On PD console: hcdebug params On EC console: hostcmd 2 0 -> hex string of EC version hostcmd 0x4002 0 -> hex string of PD version, and PD console shows host command 2 was received. The hex response shown on the PD console matches the one printed by the EC Change-Id: Icc2d97c5977145a0c3ad2630d2b5a19e876a36d0 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/207821 Reviewed-by: Bill Richardson <wfrichar@chromium.org>