Commit graph

965 commits

Author SHA1 Message Date
Tristan Honscheid 8fd1ce7579 emul: Only add enabled DT nodes to bus emulators
The eSPI, I2C, and SPI emulators use devicetree macros to build an array
of devices on the virtual bus. Currently, they will add device nodes that
are not status-okay. This leads to linker errors because the respective
device drivers would not have instantiated device structs for these
nodes --assuming the driver was even compiled. This can be frustrating
if nodes need to be disabled for debugging or configuration purposes.

Update the bus emulators to only consider status-okay nodes by changing
the macros used to iterate over bus devices.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2023-07-12 09:25:18 +02:00
Tim Lin 0960bb3066 ITE: drivers/i2c: Add I2C target driver used buffer mode
Add I2C target driver used buffer mode. The maximum accessible buffer
is 2044 bytes, the default is 256 bytes.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2023-07-11 15:50:13 +02:00
Tim Lin 42e9dd8fe9 drivers/i2c/target/eeprom_target: Add buffer mode callback function
Add the callback functions of buf_write_received and buf_read_requested
to support buffer mode.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2023-07-11 15:50:13 +02:00
Tim Lin 27e2ec8a95 drivers/i2c: Add callback functions to support buffer mode in header file
Add buf_write_received and buf_read_requested callback functions
to support buffer mode.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2023-07-11 15:50:13 +02:00
Aymeric Aillet 1ddc41e7dd drivers: i2c: tca954x: Add build assert avoiding prio issues
In order for TCA954X driver to work well, we know that
mux root must be initialized before channels.
(see #37786).

This commit is:
- Ensuring that this condition is met at build.
- Document needed values for menuconfig to help user.
- Edit these values for TCA954X test sample

Fixes #40833

Signed-off-by: Aymeric Aillet <aymeric.aillet@iot.bzh>
2023-07-11 14:46:23 +02:00
Bill Waters 541482ff20 driver: i2c: infineon: Adding XMC4 I2C driver
- This includes the driver, test app, and sample app
- Only the boards\arm\xmc47_relax_kit board is supported for now

Signed-off-by: Bill Waters <bill.waters@infineon.com>
2023-07-11 09:43:19 +02:00
Conor Paxton a810d27935 drivers: i2c: add Microchip PolarFire SoC I2C driver
This patch adds driver support for Microchip's PolarFire SoC I2C. This
initial support implements the Controller API only.

Signed-off-by: Conor Paxton <conor.paxton@microchip.com>
2023-06-23 12:31:36 -04:00
Michael Grand 78d3f2a6a0 stm32,i2c: Fix large I2C transactions on I2C V1
Previous commit added support of large transactions on I2C v2,
this commit implements some changes to also add support
of large transactions on I2C v1. Some refactoring is also done
to put the code in the right source files.

Fixes zephyrproject-rtos#58866

Signed-off-by: Michael Grand <m.grand@trustngo.tech>
2023-06-20 10:43:36 +00:00
Sahaj Sarup c7af24a065 drivers: i2c: target: Virtual EEPROM add ability to change i2c address
This patch adds the ability to change virtual i2c eeprom target address
at runtime using a single function.
Added CONFIG_I2C_EEPROM_TARGET_RUNTIME_ADDR as an optional Kconfig.

Signed-off-by: Sahaj Sarup <sahaj.sarup@linaro.org>
2023-06-17 08:02:29 -04:00
Daniel Leung 26ecaba4af drivers: syscalls: use zephyr_syscall_header
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-06-17 07:57:45 -04:00
Gerard Marull-Paretas 49c4973d8e drivers: i2c: cc32xx: enable I2C module clock
The I2C driver clock was initialized in board specific code, move it to
the driver as it is part of its responsabilities.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-17 07:55:43 -04:00
Gerard Marull-Paretas a3ab08b7ce drivers: i2c: cc32xx: add support for pinctrl
Driver will configure pins using the pinctrl API now.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-17 07:55:43 -04:00
Fabio Baltieri c56a3615ee driver: npcx: i2c: set a dedicated priority for the port driver
The NPCX I2C controller has a port-controller hierarchy and the driver
is split in two files, with separate device struct and init functions.

These are currently initialized at the same level and priority, so the
actual order depends on what the linker does.

To avoid relying on the linking order, add a dedicated priority option
for the port that is set to go after the normal I2C one by default.

Found this by building with CONFIG_CHECK_INIT_PRIORITIES.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-05-26 14:08:12 -04:00
Mulin Chao 42a509b812 driver: npcx: i2c: add i2c target mode support for npcx i2c drivers
Add I2C target mode support for NPCX i2c driver. Verified with
i2c_target_api test suite on npcx9m6_evb.

Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
2023-05-25 16:32:07 -04:00
Benjamin Björnsson bbbfc0a96d drivers: i2c: stm32: Add I2C support for STM32C0-series
Add STM32C0 SOC to combined interrupt config in order to
make it support the I2C driver.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2023-05-24 16:40:07 +02:00
Vincent Geneves 2a97a0a95c drivers: i2c_ll_stm32_v2: Fix logic in target_unregister
Logic was wrong when testing if a slave is still attached. And i2c
driver was never disabled.

Test if one of the two slave_cfg pointer is not NULL to return
immediately.

Signed-off-by: Vincent Geneves <vgeneves@kalray.eu>
2023-05-22 15:26:35 +02:00
Vincent Geneves b8b1d75a54 drivers: i2c_ll_stm32_v2: Test slave_cfg pointer before using it
Since the introduction of the second slave address support, slave_cfg
pointer may be NULL when entering slave event function.
It happens when both targets are registered and then the first one is
unregsitered.

Test the pointer vs NULL before using it.

Signed-off-by: Vincent Geneves <vgeneves@kalray.eu>
2023-05-22 15:26:35 +02:00
Fabio Baltieri e3a429e27e driver: i2c: npcx_controller: use the non I2C device init macro
The i2c_npcx_controller does not actually implement the i2c API, that's
implemented in the port driver and the controller one is in support of
that. This means there's no need to use the I2C specific instance
define, as that would end up adding the stats structure that would never
get used.

This was originally added in 7b1349cfe6.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-05-22 10:16:39 +02:00
Tom Burdick a106a5e606 i2c: SAM Add RTIO support for I2C
Support i2c with a seperate driver for sam twihs that implements RTIO.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-05-19 16:10:51 +02:00
Tom Burdick a560d47078 i2c: Add RTIO support to the I2C API
Adds the needed calls and macros required to enable supporting RTIO
with an I2C bus.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-05-19 16:10:51 +02:00
Gaël PORTAY 2be2fa8bd6 i2c: shell: Fix shell error output
The i2c shell write command outputs the error "Failed to read from
device" while it tries to write data to device.

This fixes the error by outputting "Failed to write to device" instead.

Fixes:

	uart:~$ i2c write i2c@3ff53000 23 01
	Failed to read from device: 23

Signed-off-by: Gaël PORTAY <gael.portay@rtone.fr>
2023-05-19 10:06:38 +02:00
Sylvio Alves e7665bf75a driver: i2c: esp32: fix I2C statistics
I2C driver overwrites i2c_msgs buffers, which
causes statistics to fail counting.
This creates new variables to hold msg buffer information.

Fixes #57532

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2023-05-10 16:53:27 +09:00
yeongnam chu 5a6813519e drivers: add mutex to the i2c-gpio driver.
Mutexs  were added to improve the overlapping phenomenon
because there is a part that shares the i2c line.

Signed-off-by: yeongnam chu <yeongnam.chu@assaabloy.com>
2023-05-10 16:51:14 +09:00
Aaron Massey 3cc74f1140 emul: Make ESPI/I2C_EMUL depend on EMUL
The emulated espi and i2c bus controllers do not depend on CONFIG_EMUL
being enabled. When these fake bus controllers are enabled by their
assoicated compatible in the devicetree without CONFIG_EMUL it results in
linker failures for underlying peripheral emulators which may be difficult
to understand. The SPI config already depends on EMUL.

Make the ESPI and I2C emulated controllers depend on CONFIG_EMUL. Note:
This still allows linker failures if CONFIG_EMUL=n, but the linker failures
will be consistently at device driver instantiation due to a missing bus
controller. Regardless, this will be easier to debug when someone forgets
to enable CONFIG_EMUL.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
2023-05-08 16:20:52 +02:00
Maximilian Deubel cbaa136e26 drivers: i2c: nrfx: add multithreading dependency
This patch adds MULTITHREADING as a dependency to the nrfx i2c driver.
The driver uses semaphores internally and can result in linker errors
if MULTITHREADING is not enabled.

Signed-off-by: Maximilian Deubel <maximilian.deubel@nordicsemi.no>
2023-05-05 16:17:00 +02:00
Manimaran A 519477fbf1 drivers: i2c: microchip: I2C reset fix
Updated the code to to invoke reset using PCR block
z_mchp_xec_pcr_periph_reset()  instead of resetting
using I2C Configuration register

Signed-off-by: Manimaran A <manimaran.a@microchip.com>
2023-05-05 16:16:01 +02:00
Tim Lin 1a2874affb ITE: drivers/i2c: Disable pre-detect on IT82xx2 family
Disable the hardware I2C target detection on the IT82xx2 SoC family.

Note: The register setting of I2C target detection is different in
IT81XX2 and IT82XX2 SOC.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2023-04-26 12:55:02 +02:00
Mariusz Skamra 6a92ebfc8e drivers: i2c: rv32m1: Fix compilation errors
This fixes compilation errors caused by using invalid macro parameters.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-25 08:55:57 +00:00
Gerard Marull-Paretas c66f594c41 drivers: all: rv32m1: remove conditional support for pinctrl
The rvm32m1 platform always uses pinctrl, there's no need to keep
extra macrology around pinctrl. Also updated driver's Kconfig to `select
PINCTRL`.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-24 13:34:22 +02:00
Gerard Marull-Paretas 989d103d53 drivers: all: mcux: remove conditional support for pinctrl
The MCUX platform always uses pinctrl, there's no need to keep extra
macrology around pinctrl. Also updated driver's Kconfig options to
`select PINCTRL` (note that some already did).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-24 13:34:22 +02:00
Kumar Gala fdf78377cd i2c: i2c_xilinx_axi: Fix armclang compile warning
Use PRIxPTR macros to fix compiler warnings of the form:

i2c_xilinx_axi.c:266:50: warning: format specifies type 'unsigned long'
but the argument has type 'mem_addr_t' (aka 'unsigned int') [-Wformat]
        LOG_INF("Configuring %s at 0x%08lx", dev->name, config->base);
                                     ~~~~~              ^~~~~~~~~~~~
                                     %08x

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-21 16:28:09 +02:00
Sreeram Tatapudi 185aa1c2c5 drivers: i2c: Add Infineon CAT1 i2c driver
- Add initial version of Infineon CAT1 i2c driver.
 - Add initial version of binding file for Infineon
   CAT1 I2C driver

Signed-off-by: Sreeram Tatapudi <sreeram.praveen@infineon.com>
2023-04-20 10:44:18 +02:00
Gerard Marull-Paretas 1eb683a514 device: remove redundant init functions
Remove all init functions that do nothing, and provide a `NULL` to
*DEVICE*DEFINE* macros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-19 10:00:25 +02:00
Robert Hancock b1c0bf8499 drivers: i2c: add Xilinx AXI I2C driver
Add a driver to support the Xilinx AXI IIC Bus Interface logic core, as
described in Xilinx document PG090. This can be configured for use on
most Xilinx FPGA-based platforms such as the Digilent Arty.

Both the 2.00a and 2.1 versions of the core are supported. The 2.00a
revision has a bug causing dynamic read mode to not be reliable. With
this version of the core the driver falls back to reading only 1 byte
per interrupt.

Signed-off-by: Robert Hancock <robert.hancock@calian.com>
2023-04-17 11:39:21 +02:00
Martin Jäger d52f6ab025 drivers: i2c: ite: use correct I2C init priority
Use CONFIG_I2C_INIT_PRIORITY instead of
CONFIG_KERNEL_INIT_PRIORITY_DEVICE as introduced in
c8f9f53322.

Looks like the priority was accidentally changed in
f2c42663b4.

Signed-off-by: Martin Jäger <martin@libre.solar>
2023-04-12 20:35:08 -04:00
Ben Lauret 6cf3fe1d3f drivers: i2c: Add driver for smartbond DA1469x device family
This adds the i2c driver for the Renesas SmartBond(tm) MCU family.
It supports blocking transfers and callback transfers.
Currently only supports controller mode.

Co-authored-by: Stan Geitel <stan@geitel.nl>

Signed-off-by: Ben Lauret <ben.lauret.wm@renesas.com>
2023-04-07 10:09:37 -05:00
Corey Wharton 46ba5e5518 drivers: i2c: i2c_dw: add bus mutex
This change adds a mutex to protect against simultaneous access to the bus
instead of returning an error during transfers. Since most I2C code doesn't
handle retries (especially with a -EIO code) not blocking on a mutex can
cause a number of problems.

Signed-off-by: Corey Wharton <xodus7@cwharton.com>
2023-04-07 13:17:43 +02:00
Pieter De Gendt 6b532ff43e treewide: Update clock control API usage
Replace all (clock_control_subsys_t *) casts with (clock_control_subsys_t)

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-04-05 10:55:46 +02:00
Pieter De Gendt 9b36e723f4 drivers: i2c: Add NXP SC18IM704 I2C support
Implement external I2C controller driver with NXP's SC18IM704 device.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-04-03 20:02:51 +02:00
Henrik Brix Andersen c41dd36de2 drivers: kconfig: unify menuconfig title strings
Unify the drivers/*/Kconfig menuconfig title strings to the format
"<class> [(acronym)] [bus] drivers".

Including both the full name of the driver class and an acronym makes
menuconfig more user friendly as some of the acronyms are less well-known
than others. It also improves Kconfig search, both via menuconfig and via
the generated Kconfig documentation.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-03-28 15:06:06 +02:00
Gerson Fernando Budke c4f1d98ef6 drivers: i2c: sam: Update to use clock control
This update Atmel SAM twi, twihs and twim drivers to use clock control
driver.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2023-03-21 14:12:25 -07:00
Gerard Marull-Paretas aced3bb2ac drivers: i2c: gpio: cast io context to void*
i2c_bitbang_init takes a context as void *, so discarding const
qualifier of the driver's config. Explicitely cast to void * to fix the
problem.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-03-10 12:20:22 -08:00
Attie Grande cf20ff0765 drivers: i2c: sam0: add support for I2C_MSG_RESTART
This support was accidentally removed in the re-shuffle in de18f97

Signed-off-by: Attie Grande <attie.grande@argentum-systems.co.uk>
2023-03-09 09:22:02 +01:00
Maxmillion McLaughlin 2f9335d20a drivers: i2c: stm32: add bus recovery support
Add I2C bus recovery support to the STM32 v1 and v2 driver. The STM32 i2c
peripheral does not natively support I2C bus recovery so recovery is
performed using GPIO bitbanging. This mirrors the bus recovery
implementation for NXP MCUX LPI2C driver.

Fixes: zephyrproject-rtos#54917

Signed-off-by: Maxmillion McLaughlin <github@maxmclau.com>
2023-03-03 09:18:29 +01:00
Gerard Marull-Paretas 27b73a116f soc: arm: nordic_nrf: replace NRF_DT_CHECK_PIN_ASSIGNMENTS
Since PINCTRL and pinctrl-0 is now required, there's no point in doing
extra validation at driver level. Modify the macro to just check that
sleep state is present when needed, since it was the only remaining
assertion that was not covered. Renamed the macro to make it more clear
what it does: NRF_DT_CHECK_NODE_HAS_PINCTRL_SLEEP

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-02-28 08:42:05 -08:00
Gerard Marull-Paretas dea028a0da drivers: i2c: nrfx_twi/m: drop -pin support
TWI/M drivers will use pinctrl now.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-02-28 08:42:05 -08:00
Lucas Tamborrino be577cfef0 drivers: i2c: esp32xx: Remove direct REG access
Remove direct register access and use hal functions instead.

Signed-off-by: Lucas Tamborrino <lucas.tamborrino@espressif.com>
2023-02-28 14:44:47 +01:00
Bartosz Bilas 2b4a6e52d5 drivers: i2c: eeprom_target: switch to dedicated driver compatible
Create and use a new `zephyr,i2c-target-eeprom` compatible
within I2C  eeprom target driver that allows to use
that driver along with real atmel at24 EEPROM simultaneously.

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2023-02-21 18:03:11 -05:00
Tim Lin 6ae75b6d00 ITE: drivers/i2c: Mutex issue in I2C transfer
These global variables should be under the mutex lock, otherwise they
will be overwritten by other transfers.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2023-02-20 09:50:36 +01:00
Trent Piepho 43781ba2a0 i2c: Add an option to dump all I2C messages to the log
When turned on, the existing i2c dump code is use to log every I2C
transaction at debug level.

This can be very useful for detecting problems with I2C peripherals.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2023-01-26 14:55:44 -05:00