summaryrefslogtreecommitdiff
path: root/common/ioexpander.c
Commit message (Collapse)AuthorAgeFilesLines
* Update license boilerplate text in source code filesMike Frysinger2022-09-121-1/+1
| | | | | | | | | | | | | | | Normally we don't do this, but enough changes have accumulated that we're doing a tree-wide one-off update of the name & style. BRANCH=none BUG=chromium:1098010 TEST=`repo upload` works Change-Id: Icd3a1723c20595356af83d190b2c6a9078b3013b Signed-off-by: Mike Frysinger <vapier@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3891203 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* util: remove unused includesYuval Peress2022-08-051-0/+1
| | | | | | | | | | | | | | | | Remove these includes as they're not needed in this header. Instead, the includes should go where they're actually being used. BRANCH=none BUG=b:240574048 TEST=make buildall -j TEST=zmake build -a Signed-off-by: Yuval Peress <peress@google.com> Change-Id: I64b10af3216654b2a20caa1cabd267661a0bca39 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3791980 Reviewed-by: Tristan Honscheid <honscheid@google.com> Commit-Queue: Tristan Honscheid <honscheid@google.com>
* common/ioexpander.c: Format with clang-formatJack Rosenthal2022-06-281-17/+17
| | | | | | | | | | | BUG=b:236386294 BRANCH=none TEST=none Change-Id: Iee0ebda0a5387d804dc95a8e24cf84f170837b16 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3729639 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* ioexpander: Introduce GPIO save and restore functionsRob Barnes2022-01-131-0/+54
| | | | | | | | | | | | | | Add common ioexpander functions for saving a restoring GPIO state. This is useful for restoring GPIO after the ioexpander is reset. BUG=b:211452276 BRANCH=None TEST=ioexpander state restored on nipperkin Change-Id: Id81c5457f1c33fdf7490a963317e11a2b9441831 Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3368321 Reviewed-by: Diana Z <dzigterman@chromium.org>
* ioex: extract shell commands from ioexpander.cMichał Barnaś2021-11-051-142/+12
| | | | | | | | | | | | | | This commit extracts shell commands to manipulate ioex to different file to split generic ioex logic from shell commands. BRANCH=main BUG=b:202701452 TEST=After flashing, ioexget and ioexset should work correctly Change-Id: I8707d1dd32324ca6e7b9163b800e32ded67fdf38 Signed-off-by: Michał Barnaś <mb@semihalf.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3262093 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* IOEX: Fix clobbering of initial flag valuesSam Hurst2021-10-271-1/+2
| | | | | | | | | | | | | | | | | Do not clobber initial io-expander flag values set in board files. BUG=b:203907721 BRANCH=none TEST=ServoV4p1 flags are not clobbered and IO-Expanders are working Signed-off-by: Sam Hurst <shurst@google.org> Change-Id: If5d899de5071d8a8e7594de10e2efd4dfb83e838 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3239014 Tested-by: Sam Hurst <shurst@google.com> Reviewed-by: caveh jalali <caveh@chromium.org> Reviewed-by: Brian J. Nemec <bnemec@chromium.org> Commit-Queue: Sam Hurst <shurst@google.com>
* IOEX: Cleanup: Use IOEX_FLAGS_INITIALIZED flag to get the IOEX statusVijay Hiremath2021-10-121-8/+9
| | | | | | | | | | | | | | | | | | IOEX_FLAGS_DISABLED is replaced with IOEX_FLAGS_DEFAULT_INIT_DISABLED hence use IOEX_FLAGS_INITIALIZED flag to get the initialization status of the IOEXes. BUG=none BRANCH=none TEST=Tested on Brya. 'ioexget' command works and also default init function skips IOEX initialization. Change-Id: I98ff9643223c02388a2fa679b4631e3389fd466e Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3200063 Reviewed-by: Poornima Tom <poornima.tom@intel.com> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* ioex: Skip initializing IOEXes if already initializedfactory-ambassador-14265.B-mainVijay Hiremath2021-10-051-2/+8
| | | | | | | | | | | | | | | | | Some of the IOEXes are needed early than the task is initialized, those IOEXes will be initialized at the board level. This CL skips re-initializing the IOEXes from HOOK function if already initialized. BUG=none BRANCH=none TEST=Tested on ADL RVP, re-initialization of IOEX is skipped Change-Id: I3062c46992a5578bf8f0f0bc2613b6815c28a616 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3183330 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Deepti Deshatty <deepti.deshatty@intel.corp-partner.google.com> Commit-Queue: Keith Short <keithshort@chromium.org>
* ioexpander: Add support to read levels on whole IOEX portMichał Barnaś2021-02-231-0/+10
| | | | | | | | | | | | | | | | In some cases it's needed to read many pins on the same IOEX port. To improve performance and remove redundant calls, it will be easier to read levels on whole IOEX port. To enable this functionality, CONFIG_IO_EXPANDER_SUPPORT_GET_PORT must be defined and driver must support it. BUG=b:168385201 BRANCH=main Signed-off-by: Michał Barnaś <mb@semihalf.com> Change-Id: I472385a4ef4f5db23ce92d017194f8c737b7607e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2700295 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* ioexpander: Fix type error in command_ioex_getRob Barnes2020-11-121-13/+14
| | | | | | | | | | | | | | | | | | | | enum ioex_signal is a uint16. It gets cast to an int32 in command_ioex_get. When find_ioex_by_name returns -1, it gets interpreted as 65535, not -1. Return IOEX_SIGNAL_END from find_ioex_by_name instead of -1. Minor cleanup to make it more clear that enum ioex_signal is not an int. BUG=b:172599383 BRANCH=Zork TEST='ioexget foo' does not crash Change-Id: I92922591b6a657a1d2a0840c3d361a8a909895fb Signed-off-by: Rob Barnes <robbarnes@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2533671 Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* ioex: Initialize IO expander for early sysjumpDaisuke Nojiri2020-05-141-2/+2
| | | | | | | | | | | | | | | | | | When EFS triggers sysjump, IO expander is currently not initialized. This patch will make IO expander initialized in RW if sysjump is triggered by EFS. IO expander initalization should be skipped only for late sysjump. BUG=b:156101251, chromium:1072743 BRANCH=none TEST=Verified the bug is fixed. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I25b173aa4cae9c3de5ae6bac0d5c40216ef466b6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2200244 Reviewed-by: Edward Hill <ecgh@chromium.org>
* common ioex: don't init ioex levels on SysJumpDenis Brockus2020-04-211-2/+9
| | | | | | | | | | | | | | | BUG=b:154174083 BRANCH=none TEST=sysjump RW should leave USB-A connected as USB3 Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I706b2d1593e399c5610156205f4a7dc9dc12dc14 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2157571 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Edward Hill <ecgh@chromium.org> Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org>
* ioexpander: add IOEX_FLAGS_DISABLEDEdward Hill2020-03-201-35/+65
| | | | | | | | | | | | | BUG=b:150349225 BRANCH=none TEST=none Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: Id264d633576ca79b288a435f95de7fda9ca201ad Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2108334 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Paul Ma <magf@bitland.corp-partner.google.com> Tested-by: Paul Ma <magf@bitland.corp-partner.google.com>
* ioexpander: Fix IOEX_INT after ioex_signal numbering changeEdward Hill2020-01-311-1/+1
| | | | | | | | | | | | | | | Fix ioex_is_valid_interrupt_signal() and IOEX_INT() to account for IOEX_SIGNAL_START correctly. BUG=none BRANCH=none TEST=ioex_enable_interrupt() returns success Change-Id: I8f13fa8f2d645aae565ac1062eab4a4d0968c4bc Signed-off-by: Edward Hill <ecgh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2031649 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
* ioexpander: fix out-of-bounds access in last_val_changedMichael Auchter2020-01-241-1/+5
| | | | | | | | | | | | | | | | | | | | | Commit 9f392b0d6 gave unique values to IO signals implemented on an IO expander, but last_val_changed was not updated to remove the newly added offset before indexing the array that tracks changes between `ioexget` invocations. Remove the offset and add an assertion to ensure the array index is valid. BUG=None BRANCH=None TEST=`ioexget` doesn't assert or stomp on memory Signed-off-by: Michael Auchter <michael.auchter@ni.com> Change-Id: If06d300abaeed2905939d9724a1152d4da10035b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2012448 Reviewed-by: Edward Hill <ecgh@chromium.org> Commit-Queue: Edward Hill <ecgh@chromium.org> Tested-by: Edward Hill <ecgh@chromium.org>
* GPIO/IOEX/eSPI: Give different IO signals unique valuesEdward Hill2019-10-251-15/+31
| | | | | | | | | | | | | | | | | There are 3 different IO signal types used by the EC. Ensure they each use a unique range of values so we can tell them apart. 1) Local GPIO => 0 to 0x0FFF 2) IO expander GPIO => 0x1000 to 0x1FFF 3) eSPI virtual wire signals => 0x2000 to 0x2FFF BUG=b:138600691 BRANCH=none TEST=IO expander signals still work on Trembyle Change-Id: I63fadb4bb4573ed3dd121c24e3bd40a00873e29f Signed-off-by: Edward Hill <ecgh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1854778 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* IO Expander: add the interrupt support to IOEX frameworkCHLin2019-08-201-0/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL creates interfaces which bring the IOEX framework to support interrupt feature. To declare an IOEX IO which supports the interrupt function, file its declaration in gpio.inc with the format: IOEX_INT(name, expin, flags, signal) Note: like GPIO, all IOEX IOs with interrupt handlers must be declared at the top of the IOEX's declaration in the gpio.inc The following two APIs are added to enable/disable each IOEX IO's interrupt function: 1. ioex_enable_interrupt 2. ioex_disable_interrupt BRANCH=none BUG=none TEST=No error for "make buildall" TEST=Apply this and related CLs, manually test each IO pins; make sure each pin's interrupt handler is correctly executed. Change-Id: Icbf54c09120e37b68c647c884cd6aa28d9313167 Signed-off-by: CHLin <CHLIN56@nuvoton.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1734947 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: CH Lin <chlin56@nuvoton.com> Commit-Queue: Edward Hill <ecgh@chromium.org>
* IO_Expander: introduce the common interface of IO expanderCHLin2019-07-241-0/+221
Implement the common code to provide a friendly interface to control the IOs of IO expander. It adopts a similar concept to GPIO. 1. Define the IO expander IO in gpio.inc by the format: IOEX(name, EXPIN(ioex, port, offset), flags) - name: the name of this IO pin - EXPIN(ioex, port, offset) - ioex: the IO expander port (defined in board.c) this IO pin belongs to. - port: the port number in the IO expander chip. - offset: the bit offset in the port above. - flags: the same as the flags of GPIO. 2. The following APIs are supported: 1. ioex_get_flags_by_mask 2. ioex_set_flags_by_mask 3. ioex_get_flags 4. ioex_set_flags 5. ioex_get_level 6. ioex_set_level 7. ioex_init 3. The following console commands are supported: 1. ioexget [IO_EXPANDER_PIN_NAME] 2. ioexset IO_EXPANDER_PIN_NAME 0/1 BRANCH=none BUG=none TEST=No error for "make buildall" TEST=Apply this and related CLs, manually test each API, make sure each function works correctly with IO expander chip (NCT3807/NCT3808.) Change-Id: I79c9813abccc67d5554e2ceb5c119dcf549b7dce Signed-off-by: CHLin <CHLIN56@nuvoton.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1657858 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: CH Lin <chlin56@nuvoton.com> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Tested-by: CH Lin <chlin56@nuvoton.com>