summaryrefslogtreecommitdiff
path: root/zephyr/projects/nissa/src/nereid/usbc.c
Commit message (Collapse)AuthorAgeFilesLines
* zephyr: add a zephyr/ prefix to all zephyr includesFabio Baltieri2022-05-091-1/+1
| | | | | | | | | | | | | | | | | | | This adds a zephyr/ prefix to all #include path pointing to Zephyr header files, so that we could drop LEGACY_INCLUD_PATH once all upstream code has been converted. Generated using something similar to the script in: c7b5b3c419 samples: migrate includes to contain <zephyr/...> prefix BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I5ba2c859fe10a34ea8d3a49a612132ea4d02f2cb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3634345 Reviewed-by: Yuval Peress <peress@google.com>
* nissa/nereid: poll type-C interrupts on startupPeter Marheine2022-04-041-0/+19
| | | | | | | | | | | | | | | | | | | | | | If a charger interrupt triggers before the EC starts up, then it's possible for the IRQ to get stuck because nothing will ever notify the charger driver to run and clear the IRQ. This breaks most type-C functionality on the port because the TCPC and charger share the IRQ line. To ensure interrupts that are requested before the EC is ready to act on them are processed, this change adds an initialization hook that polls the lines and triggers regular interrupt handling if the IRQ is asserted. BUG=b:227562556 TEST=`gpioget usb_c0_int_odl` now returns 1 (deasserted) after waking the system from hibernate by plugging a charger into port C0, where it was previously stuck asserted. BRANCH=none Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: I29fe2bacf5f0a1ed105b0fc7398b74673db25fa4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3568006 Reviewed-by: Andrew McRae <amcrae@google.com>
* Revert "nissa/nereid: run sub-board I2C at 1.8V"Peter Marheine2022-04-011-30/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit b1281f53d17c498a1b61fc27c73789b8d32569b4. Reason for revert: Nivviks I2C is to be changed to 1.8V; Nereid will stay at 3.3. Original change's description: > nissa/nereid: run sub-board I2C at 1.8V > > Board revisions 1 and later will run sub-board I2C at 1.8V to improve bus > timing characteristics. Since it's safe to configure the EC for 1.8V > operation with the 3.3V bus on board version 0, we'll always set the I2C > pins to 1.8V. > > BUG=b:227517811 > TEST=USB-C1 continues to function, and manual inspection of the voltage > selection bits (GPE0VS and GPE7VS) in GCR20 indicate 1.8V operation: > `rw .b 0xf016e5` reads 0x92 with bits 3 and 5 set for GPE7 and GPE0, > respectively. > BRANCH=none > > Signed-off-by: Peter Marheine <pmarheine@chromium.org> > Change-Id: Ib2f937fb450088b5154007e4c90d03366297bb2f > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3561601 > Reviewed-by: Andrew McRae <amcrae@google.com> Bug: b:227517811 Change-Id: Idc5be71f49131413b3de8f503ee9d3f81a11bbce Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3565063 Reviewed-by: Andrew McRae <amcrae@google.com> Tested-by: Peter Marheine <pmarheine@chromium.org> Auto-Submit: Peter Marheine <pmarheine@chromium.org> Commit-Queue: Peter Marheine <pmarheine@chromium.org>
* nissa/nereid: run sub-board I2C at 1.8VPeter Marheine2022-03-311-1/+30
| | | | | | | | | | | | | | | | | | | Board revisions 1 and later will run sub-board I2C at 1.8V to improve bus timing characteristics. Since it's safe to configure the EC for 1.8V operation with the 3.3V bus on board version 0, we'll always set the I2C pins to 1.8V. BUG=b:227517811 TEST=USB-C1 continues to function, and manual inspection of the voltage selection bits (GPE0VS and GPE7VS) in GCR20 indicate 1.8V operation: `rw .b 0xf016e5` reads 0x92 with bits 3 and 5 set for GPE7 and GPE0, respectively. BRANCH=none Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: Ib2f937fb450088b5154007e4c90d03366297bb2f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3561601 Reviewed-by: Andrew McRae <amcrae@google.com>
* nissa: deduplicate common board_config codePeter Marheine2022-03-311-0/+18
| | | | | | | | | | | | | | | | | | | | | | | The sub-board configuration had diverged between Nivviks and Nereid, with each having some disjoint improvements. This change moves all of the code out of board-specific board_config files and into a common file consisting of the sum of the two boards, and the few functions that differ between boards are moved to existing board-specific source files. Specifically, the divergence was: * Nereid configured HDMI as needed * Nereid fixed incorrect USB-A configuration for the LTE board * Nivviks disabled the C1 charger task if the port was not present BUG=b:226513609,b:214858346 TEST=HDMI board still behaves correctly on Nereid, and USB ports still work with the C+A board on both Nivviks and Nereid. BRANCH=none Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: Iec0fac5c4fc880193a871ad302ea6752e02d8c01 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3559690 Reviewed-by: Andrew McRae <amcrae@google.com>
* nissa/nereid: increase C1 charger interrupt priorityPeter Marheine2022-03-291-1/+23
| | | | | | | | | | | | | | | | | Drawcia uses the same general topology on USB-C where chargers and TCPCs share an interrupt line, which was found to cause problems with excessive interrupt latency and fixed in commit e858299538e00490ccbab65e199307c455a7d1c8. This change does the same prioritization for Nereid. BUG=b:226669197 TEST=PD is no longer flaky on C1 with some partners sending hard resets BRANCH=none Change-Id: Ied32abc07f1b1c9b3c89130941f87cd469435630 Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3554376 Reviewed-by: Andrew McRae <amcrae@google.com>
* nissa: nivviks: Enable port 1 redriverAndrew McRae2022-03-161-1/+1
| | | | | | | | | | | | | Enable port 1 redriver for Nivviks BUG=b:219898719 TEST=zmake build nivviks BRANCH=none Signed-off-by: Andrew McRae <amcrae@google.com> Change-Id: I6012855cceb44efd34469b70199ccd70897ba6d4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3527894 Reviewed-by: Peter Marheine <pmarheine@chromium.org>
* nissa/nereid: handle charger interrupts on port C1Peter Marheine2022-03-101-0/+1
| | | | | | | | | | | | | | | | The SM5803 charger on this port is connected to the IRQ line, in addition to the BC1.2 and TCPC. BUG=b:220775658 TEST=Port 1 now comes up as a sink regardless of battery presence or state at boot; charger plug and unplug works as expected both at runtime and at cold start. BRANCH=none Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: I54a509042901753d63f0f35034017ee70dd713b2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3511921 Reviewed-by: Andrew McRae <amcrae@google.com>
* nissa/nereid: implement support for setting type-C current limitsPeter Marheine2022-03-011-0/+12
| | | | | | | | | | | | | | | | The implemented function is called by USB-C code as a board-specific way to set the current limit when sourcing VBUS. This implementation delegates to the SM5803 driver, since that chip is responsible for VBUS on Nereid. BUG=b:219891340 TEST=builds BRANCH=None Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: I1c12cda52e22acee5fe2ab51704b7679cfcd0abd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3496242 Reviewed-by: Andrew McRae <amcrae@google.com>
* nissa/nereid: use PS8xxx driver for the C1 TCPCPeter Marheine2022-02-241-3/+3
| | | | | | | | | | | | | | | | Parade say that the PS8745 should be treated the same as a PS8815, for which the ps8xxx driver contains some customizations to the standard TCPCI functionality. BUG=b:216085548 TEST=builds and C1 initialization succeeds (functional testing is blocked by b:220775658) BRANCH=none Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: I67bf46935fd6400f8dcab0ebfe043db91f5a863f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3483143 Reviewed-by: Andrew McRae <amcrae@google.com>
* nissa/nereid: implement VBUS sourcingPeter Marheine2022-02-221-4/+36
| | | | | | | | | | | | | | pd_set_power_supply_ready is the board function that turns on VBUS when requested by the PD state machine; implement it for Nereid. BUG=b:201000844 TEST=builds BRANCH=none Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: I6b092080ba383b6d48767ed6c4e8341a1b13e35a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3478974 Reviewed-by: Andrew McRae <amcrae@google.com>
* nissa/nereid: implement board_set_active_charge_portPeter Marheine2022-02-141-1/+50
| | | | | | | | | | | | | | | This change makes the Nereid charger actually be enabled when the charger task requests it, allowing the battery to charge. BUG=b:201000844 TEST=battery now charges at ~4400 mA when charging from port C0 with PD contract for 3A at 20V, stops charging with `chgoverride -2` BRANCH=none Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: If22f10954c71a2d2f7f5007eeb115770a9723a02 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3449990 Reviewed-by: Andrew McRae <amcrae@google.com>
* nissa/nereid: implement pd_check_vbus_levelPeter Marheine2022-02-141-3/+23
| | | | | | | | | | | | | | | | | This function is used by USB-C code to poll whether VBUS is present on the port, and is polled in some states so it uses the cached vbus present bit provided by the charger (and actuated via interrupts) rather than doing a I2C transaction to read the analog voltage on each call. BUG=b:218747760 TEST=Nereid operates normally BRANCH=none Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: Iad45c084727bd4b148de423d64c92955290535c0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3459584 Reviewed-by: Andrew McRae <amcrae@google.com>
* nissa: use Zephyr logging APIsPeter Marheine2022-02-141-1/+3
| | | | | | | | | | | | | | Rather than EC-OS-style CPRINTS macros, use Zephyr logging. The module is defined as all of the Nissa project code. BUG=none TEST=Sub-board messages still appear when running on Nereid BRANCH=none Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: Ifccc4c7442e4de2296019b8d5d1dd8a8d62c6ee0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3459583 Reviewed-by: Andrew McRae <amcrae@google.com>
* nissa/nereid: implement pd_power_supply_resetPeter Marheine2022-02-141-0/+16
| | | | | | | | | | | | | | | This safely resets the charger for a port when requested by the policy engine, including discharging VBUS. The implementation is borrowed from dedede. BUG=b:201000844 TEST=build and flash nereid BRANCH=none Change-Id: I6bae0828ab4e24aaeadf5ff84c888c6c52148f08 Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3449991 Reviewed-by: Andrew McRae <amcrae@google.com>
* TCPM: Change the PS8xxx I2C flags name to match the driverSam Hurst2022-02-101-1/+1
| | | | | | | | | | | | | | | | Change the PS8xxx I2C flags name from PS8751_I2C_ADDR to PS8XXX_I2C_ADDR. BRANCH=main BUG=b:194432779 TEST=make -j buildall Signed-off-by: Sam Hurst <shurst@google.org> Change-Id: Ie8ac1c922c46bb425b7e7b1a39173872d48f6353 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3449669 Tested-by: Sam Hurst <shurst@google.com> Reviewed-by: Wai-Hong Tam <waihong@google.com> Commit-Queue: Sam Hurst <shurst@google.com>
* nissa: merge common kconfig options into prj.confPeter Marheine2022-02-091-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's easy to update configuration for one board variant without touching the other when a given change is actually applicable to both. This change merges the common kconfig options used by Nissa to avoid duplicating them, which should help ensure the feature set for the two variants doesn't diverge significantly. Where config is expected to vary by board, they are not merged. The output changes are: * CONFIG_FPU is left at default (=y) for Nivviks, rather than enabled explicitly * PWM shell is enabled on nivviks * Sensor support is enabled on nereid The board_is_sourcing_vbus function is also removed from nereid because it was unused: it is only called when CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM is enabled, which it is not on nereid. BUG=none TEST=diff of old .config against new only shows expected changes BRANCH=none Change-Id: I02d61a8d71ff730c442e60fa2e1ef24ff46c7095 Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3426245 Reviewed-by: Andrew McRae <amcrae@google.com>
* nissa: Use aliases for sub-board GPIOsAndrew McRae2022-02-011-2/+2
| | | | | | | | | | | | | Use GPIO aliases for sub-board GPIOs BUG=none TEST=zmake configure -b {nivviks,nereid} BRANCH=none Signed-off-by: Andrew McRae <amcrae@google.com> Change-Id: I9816ba1b44f209e10a8f5235498d43e5626d95e6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3428599 Reviewed-by: Peter Marheine <pmarheine@chromium.org>
* nissa: Consolidate common code into a single file.Andrew McRae2022-01-311-68/+0
| | | | | | | | | | | | | Consolidate common code for nivviks/nereid into a common file BUG=b:217091028 TEST=zmake configure -b {nereid,nivviks} BRANCH=none Signed-off-by: Andrew McRae <amcrae@google.com> Change-Id: I87d49f63073a861455f7a868e3ce18d4fc46fc68 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3426244 Reviewed-by: Peter Marheine <pmarheine@chromium.org>
* nissa/nereid: configure USB-C1 TCPCPeter Marheine2022-01-281-6/+36
| | | | | | | | | | | | | | | It was configured as an EC-internal TCPC, but that was incorrect: that port (if present) is controlled by a PS8745 combination TCPC and redriver on the sub-board. BUG=b:201000844,b:215650649 TEST=zmake build BRANCH=none Change-Id: I0304625cf2ea980fe6e43d18721a0d300f4d9e67 Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3422857 Reviewed-by: Andrew McRae <amcrae@google.com>
* nereid: add PD negotiate to high voltage supportScott Chao2022-01-271-0/+9
| | | | | | | | | | | | | | With this change, EC can negotiate to 20v. BUG=b:216581716 BRANCH=none TEST=zmake configure -b nereid TEST=verified on total phase Signed-off-by: Scott Chao <scott_chao@wistron.corp-partner.google.com> Change-Id: Idd0c9b7e2a5dc04c4fb2c1217a6b72170f03732f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3419125 Reviewed-by: Andrew McRae <amcrae@google.com>
* nissa: Add USB-C config to NereidAndrew McRae2022-01-271-0/+221
Add type C USB config to Nereid BUG=b:201000844 TEST=zmake configure -b nereid BRANCH=none Cq-Depend: chromium:3411679 Signed-off-by: Andrew McRae <amcrae@google.com> Change-Id: I75b53549a284a984067b894c421bd840bd46d372 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3411680 Reviewed-by: Peter Marheine <pmarheine@chromium.org>