summaryrefslogtreecommitdiff
path: root/zephyr/shim/include/i2c
Commit message (Collapse)AuthorAgeFilesLines
* zephyr/shim/include/i2c/i2c.h: Format with clang-formatJack Rosenthal2022-07-011-3/+4
| | | | | | | | | | | BUG=b:236386294 BRANCH=none TEST=none Change-Id: I6042445a98fda2c8b3bd8a521cbf73f57d50260c Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3730584 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* zephyr: add a zephyr/ prefix to all zephyr includesFabio Baltieri2022-05-091-2/+2
| | | | | | | | | | | | | | | | | | | 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>
* zephyr: mchp: Add shim i2cmartin yan2022-03-281-0/+2
| | | | | | | | | | | | | | Add shim layer i2c function BUG=none BRANCH=main TEST=zmake testall Signed-off-by: martin yan <martin.yan@microchip.corp-partner.google.com> Change-Id: If6dc893ae720587b74db44ae22ff1747af158cc9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3546983 Reviewed-by: Aaron Massey <aaronmassey@google.com> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* zephyr: it8xxx2: Compatible with the I2C enhance driverTim Lin2022-03-101-0/+5
| | | | | | | | | | | | | | | | | | | The following is Zephyr PR link, which is separated out I2C enhance driver to create another compatible. so pinmux and I2C_DEVICE_COUNT need to be compatible with the I2C enhance driver. Zephyr PR: https://github.com/zephyrproject-rtos/zephyr/pull/43357 BUG=none BRANCH=none TEST=zmake testall Change-Id: Ibaedf158f1a9fd9970000db8b11dc8e8593c5c03 Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3499246 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* zephyr: optimize I2C mutexesDawid Niedzwiecki2021-10-111-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | I2C_PORT_COUNT is bigger than the actual physical I2C number in Zephyr. Since the access to I2C has to be controlled per physical port, limit the size of the port_mutex array. Introduce the I2C_DEVICE_COUNT define to represent the number of the physical I2C ports. It is not possible to automate it fully with the current devicetree macros. A new I2C_COPMAT defines will have to be introduced for new chips. The general assumption is that there is only one type of I2C port per chip pointed by the compatible property e.g. "nuvoton,npcx-i2c-port". BUG=b:199918263 BRANCH=none TEST=zmake testall; Make sure there is no "Access I2C without lock!" message in console. Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: Ie7b0570eb5629ebd4adabc8a47d0d802d847a773 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3211976 Tested-by: Dawid Niedźwiecki <dn@semihalf.com> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Dawid Niedzwiecki <dawidn@google.com>
* zephyr: Replace DT_ENUM_TOKEN with DT_STRING_TOKENJack Rosenthal2021-09-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In Zephyr v2.7, DT_ENUM_TOKEN is deprecated in favor of DT_STRING_TOKEN. Additionally, DT_ENUM_UPPER_TOKEN is deprecated in favor of DT_STRING_UPPER_TOKEN. See the v2.7 release notes for details: https://docs.zephyrproject.org/latest/releases/release-notes-2.7.html Since we backported the DT_STRING_* macros to our v2.6 branch, let's switch to them ahead of time to prepare for the v2.7 uprev. Note: the DT_STRING_* macros are compatible with Zephyr's device tree enums, but also allow non-enum properties to be used in the same fashion. This commit does the bare minimum for compatibility with v2.7, i.e., just swap the macros without dropping enum properties anywhere. We should investigate whether we want to continue using the enum properties or abandon some of them for any string in the future. BUG=b:198824039 BRANCH=none TEST=zmake testall Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I1efd8f99bc7d93504c0ab94510406cd36ad24cd3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3144536 Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr: Fix I2C_PASSTHRU host commandDawid Niedzwiecki2021-06-081-0/+12
| | | | | | | | | | | | | | | | | | | | ZephyrEC uses different I2C port numbers than CrosEC does, so convert the received remote port via I2C_PASSTHRU command into a proper one. The conversion is done based on a new property remote-port, which tells what port number is used by external components like kernel. The change fixes an issue with unexpected entering OTG mode by the charger. BUG=b:188885798 BRANCH=none TEST=Flash Lazor and make sure that no "charge problem" prints are displayed. Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: Id00265a3abf286ca59cbecb38ff7933d75e0d361 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2933296 Reviewed-by: Yuval Peress <peress@chromium.org>
* zephyr: i2c: remove scl and sda referencesYuval Peress2021-05-141-1/+1
| | | | | | | | | | | | | | | The SDA and SCL components of the struct i2c_port_t are only used in and for the i2c_wedge.c logic. This isn't needed in Zephyr. Remove the values and functions that use them from the Zephyr build. BRANCH=none BUG=b:188179405 TEST=build volteer and trogdor Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I71a26fbd9bc51def744ef1f16a540728482c5a2b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2896235 Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com>
* zephyr: config: add a dts node for the CBI EEPROMFabio Baltieri2021-04-091-5/+0
| | | | | | | | | | | | | | | | | This makes a separate dts node for the CBI EEPROM. The node uses the existing at24 dts binding and defines all the required properties, even though right now only the address is used. BUG=b:184739382 BRANCH=none TEST=build and flash on volteer TEST=cbi shell command Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I8a3ed6f3dc504118fa6d61bc78e2b4c46d6c4840 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2814621 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Yuval Peress <peress@chromium.org>
* zephyr: i2c mapping using an enumYuval Peress2021-04-081-3/+10
| | | | | | | | | | | | | | | | | | | | Currently, every project will need to provide a custom mapping header for i2c as well as gpios. We'd like to move that overhead to the dts files, which will make the board dts a lot more reusable as well as clean up the bringup of new boards. Add to the i2c_ports enum from the dts named i2c port list. Each enum is only added if a node exists using that enum. This also allowes for verifying that the enum is only used once. BRANCH=none BUG=b:184786824 TEST=build and flashed volteer TEST=zmake testall Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I42cc098a9badac57a3781fa9dfaf32c0ec0c5aca Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2780838
* zephyr: remove dependency on chip specific code for npcxYuval Peress2020-12-101-7/+2
| | | | | | | | | | | | | BRANCH=none BUG=b:175249000 TEST=zmake testall Cq-Depend: chromium:2583272 Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: Ie50e56df60e060c3741013912ab46d807fc5e417 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2582819 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
* zephyr: Sort the options a bitSimon Glass2020-12-051-0/+17
| | | | | | | | | | | | | | | | | | | We have quite a few options already and plan to add more. Sort them to make it easier to see what is there. The I2C enum isn't really connected with the basic CONFIG munging done in config_chip.h so move it to i2c.h instead. Fix the 'keybaord' typo while we are here. BRANCH=none BUG=none TEST=build and boot on volteer Change-Id: Id03fe44ff859736f1e2f86231ca1e8d9dc4c50af Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2575198 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* Add chip-specific shim along with i2c moduleYuval Peress2020-11-081-0/+28
This change accomplishes 2 things: 1. It refactors the zephyr/shim directory to structure around chip specific compilation. In this example, we're focusing on npcx7m6fb which is used in volteer but others can be added easily. 2. It shims the common/i2c_master.c by providing an alternate implementation of i2c_xfer_unlocked that calls down to the Zephyr API i2c_write_read instead of the chip specific i2c_xfer_no_retry or chip_i2c_xfer_with_notify. The shim layer is made possible by the addition of zephyr/shim/include/i2c/i2c.h which adds a functions that needs to be implemented per chip (npcx7 family in this case) and allows us to map the current port int which is defined in chip/${CHIP}/registers.h (chip/npcx/registers-npcx7.h in our case). This function (i2c_get_device_for_port) maps the platform/ec port int to a const struct device * which is needed in the Zephyr I2C APIs. BRANCH=none BUG=b:171302975 TEST=clean_build.sh projects/experimental/volteer/ and make BOARD=eve Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: I210f4758337bf384d0d6f103eef8b89126887d11 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2504285 Reviewed-by: Simon Glass <sjg@chromium.org> Commit-Queue: Simon Glass <sjg@chromium.org>