summaryrefslogtreecommitdiff
path: root/common/ioexpander.c
Commit message (Collapse)AuthorAgeFilesLines
* 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>