Commit Graph

1010 Commits

Author SHA1 Message Date
Francois Ramu c79c0d7cf2 drivers: i2c: stm32 driver has get_config api
Add the get_config API to the stm32 I2C driver.
It will return the value of the Clock  Control register for i2C V1 bus
or the TIMING register for the I2C V2 bus.
This is hold by a i2c_config_timing structure of the device data
Add a bool to check if the I2C is configured or not.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2023-10-31 09:00:18 +01:00
Bartosz Bilas 8487aad003 drivers: i2c: i2c_nrfx_twi*: don't print errors in case of transfer failure
Let the caller decide what should be done in case of the transfer failure.
It will reduce the number of error log prints when the i2c scan is
called for the bus where nothing is connected.

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2023-10-27 12:29:29 +02:00
Erwan Gouriou c2715b1fa5 drivers: i2c: stm32: Don't abuse of pm_device_runtime_get/put
In driver runtime configuration function, calling
calling pm_device_runtime_get/put() will have the effect of performing
pinctrl change from sleep to default and back from default to sleep
which is useless and in turn enables and disables GPIO clocks two times.

Stop this crazyness and purely enable/disable clock, which might be
superfluous in some cases but which remains much more reasonable than
than the previous implementation.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2023-10-25 17:33:56 +02:00
Erwan Gouriou b6fa34f1d3 drivers: i2c: stm32: Simplify device init
pm_device_runtime_enable() will call i2c_stm32_suspend() if
pm_device_init_suspended() isn't called.
Since the aim is to perform suspension, just need to call
pm_device_runtime_enable().

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2023-10-25 17:33:56 +02:00
Erwan Gouriou 85fb82e1d6 drivers: stm32: Don't use pm_device_busy for configure
During i2c_configure API execution, there is no way core
can go in low power mode. Hence, call to pm_device_busy_set/get API
is useless.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2023-10-25 17:33:56 +02:00
Adam Wojasinski 97b351fb66 drivers: i2c: i2c_nrfx_twim: Add support for new instances
This patch intoduces new instances in TWIM SHIM for i2c driver.

Signed-off-by: Adam Wojasinski <adam.wojasinski@nordicsemi.no>
2023-10-20 15:04:10 +02:00
Dmytro Semenets d912be1c51 drivers/i2c: remove unnecessary includes
i2c_rcar.c includes soc.h header which doesn't need for this source
and exists not for all boards. soc.h header doesn't exist for rcar-gen3
soc based on arm64 core.
soc.h consists soc-depended defenitions and need to be included
by soc-depended sources.

Signed-off-by: Dmytro Semenets <dmytro_semenets@epam.com>
2023-10-13 09:46:34 +01:00
Kai Meinhard 06f35916e1 i2c: silabs: Fix I2C target crash on long ISR execution
Long I2C target callback functions could lead to an unresponsive
I2C peripheral. This commit ports the official ISR implementation
from Silicon labs to Zephyr:
https://github.com/SiliconLabs/peripheral_examples/blob/master/series2/i2c/i2c_follower/src/main.c

Signed-off-by: Kai Meinhard <meinhard@gessler.de>
2023-10-09 10:15:37 +02:00
Mario Jaun 01bdd845db drivers: i2c: stm32: disable reload mode at the end of a transfer
Fixes an issue that reload mode is not disabled in case of an error.
From this case the driver could not recover because in msg_init()
no new transfer could be initialized.

Signed-off-by: Mario Jaun <mario.jaun@gmail.com>
2023-10-04 20:25:20 +02:00
Fabio Baltieri 6f0a5961e3 drivers: i2c: i2c_nrfx_twim: fail gracefully on dma max size
Different nRF52 devices have different maximum TWI DMA transfer size,
and it's easy to hit the limit with i2c displays on nrf52832 (8 bit) and
nrf52810 (10 bit). Currently neither the driver or the hal validate the
limit, leading to random NACK errors when trying to transfer more data.

Add a check on the driver to fail gracefully when going over the limit.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-10-04 16:17:15 +01:00
Sylvio Alves b7fbec7920 drivers: i2c: esp32: check busy line before transfer
I2C scan might fail as peripheral is still busy completing last
operation. This makes sure transfer call waits for free line.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2023-10-02 16:57:39 +01:00
Wouter Horré 3bc531e9c6 drivers: i2c: stm32: Support wakeup from STOP
This commit adds support for wakeup from STOP mode when the i2c device is
configured as a target.

Signed-off-by: Wouter Horré <wouter@versasense.com>
2023-09-29 09:48:04 +02:00
Francois Ramu 1d29a8c3c2 drivers: i2c: stm32 i2c driver supports 10-bit addressing
When slave_address is 10 bits, data type should be
uint16_t instead of uint8_t,
like the data typeof data->slave_cfg->address.
https://github.com/zephyrproject-rtos/zephyr/issues/55987

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2023-09-28 09:27:09 +02:00
Jonas Otto 1402d2d8b4 drivers: i2c_ll_stm32_v2: add warning about i2c speeds above fast
The i2c_ll_stm32_v2 driver requires manual timing configuration for
"fast mode plus" speed.
This adds an error message linking to the appropriate documentation.

Signed-off-by: Jonas Otto <jonas@jonasotto.com>
2023-09-27 09:13:31 +02:00
Bindu S 877208dc78 drivers: i2c: i2c_dw: Added intel lpss dma support for I2C
Enabled intel LPSS DMA interface using dw common to support
usage of internal DMA in LPSS I2C to transfer and
receive data.

Signed-off-by: Bindu S <bindu.s@intel.com>
2023-09-26 12:02:23 +02:00
Petr Hlineny b2fb3d49bf drivers: i2c: stm32: Fix for i2c PM
Remove unwanted "pm_device_runtime_get" lock which makes i2c power
management working incorrectly.

Fixes: #62790
Signed-off-by: Petr Hlineny <development@hlineny.cz>
2023-09-22 09:27:46 +02:00
Gerard Marull-Paretas 0660719346 drivers: nrf: select PINCTRL
Drivers for nRF SoCs using pinctrl did not select PINCTRL. This means
boards are forced to enable PINCTRL.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-09-20 08:57:09 +02:00
Gerard Marull-Paretas 691facc20f include: always use <> for Zephyr includes
Double quotes "" should only be used for local headers.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-09-14 13:49:58 +02:00
TOKITA Hiroshi e2f47c0c38 drivers: i2c: i2c_dw: Add capability for handling reset device
Reset the device on initializing if reset-node is available in dts.
`snps,desingware-i2c` does not define reset-node itself.
Add more of an element that inherits `reset-device.yaml` to
the `compatible` section to allow defining the reset-node
for using this feature.

For example.

```
compatible = "reset-device-inherit-node", "snps,designware-i2c";
```

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2023-09-11 11:10:12 +02:00
Tim Lin 8a779fc706 ITE: drivers/i2c/target: Introduce I2C target transfer using PIO mode
Introduce I2C target transfer using the PIO mode. Add an option
"target-pio-mode" in the yaml file, determined by the DTS, to dictate
whether I2C target transfer uses the PIO mode.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2023-09-07 09:43:06 +02:00
Tim Lin 3ae9a358fb ITE: drivers/i2c/target: Disable the timeout setting
Disable the timeout setting when both the clock and data are
in a low state. This allows for I2C host clock stretching
without a timeout limit.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2023-09-07 09:43:06 +02:00
Tim Lin 5de9203af3 ITE: drivers/i2c/target: Cleanup the clear status flow of I2C target
IT8XXX2_I2C_STR is a register of read-only, non-writable to clear.
Here we can set hardware reset bit in the IT8XXX2_I2C_CTR register
to clear the status of IT8XXX2_I2C_STR.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2023-09-07 09:43:06 +02:00
Michał Barnaś 2bc7dcdc2e i2c: add filtering of i2c dumped messages
This commit adds option to dump i2c messages of only specified
devices. It makes it easier to debug communication of specific
i2c device instead of logging all i2c communication.
The filter of devices is specifiec in device-tree using the
node with "zephyr,i2c-dump-filter" compatible string.

Example of device-tree node:
i2c-dump-filter {
	compatible = "zephyr,i2c-dump-filter";
	devices = < &display0 >, < &sensor3 >;
};

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-09-06 17:54:53 +02:00
Michał Barnaś 4c49d095fc i2c: improve the message dumps messages
This commit changes the format of printed messages to align the
following strings and make it more readable.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-09-06 17:54:53 +02:00
Michał Barnaś 4aac1756a9 i2c: use device instead of name for i2c dump messages
This commit changes the parameter of i2c_dump_msgs function from
string name to pointer to the device structure.
It allows for comparison of device pointers and allow to use
the printed device name in i2c shell commands.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-09-06 17:54:53 +02:00
Sreeram Tatapudi 09a07e42c0 drivers: cat1: Updates to support latest version of HAL/PDL
- Refactoring to support latest versions of HAL/PDL

Signed-off-by: Sreeram Tatapudi <sreeram.praveen@infineon.com>
2023-09-01 09:52:25 +02:00
Dong Wang 64e8411527 drivers: i2c_sedi: correct pending check condition
Previous check is wrong, need to reverse.

Signed-off-by: Dong Wang <dong.d.wang@intel.com>
2023-08-30 21:02:45 -04:00
Nick Ward 2d65acca3a drivers: gpio: use gpio_is_ready_dt helper function
Update `struct gpio_dt_spec` use with gpio_is_ready_dt()

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-08-28 08:48:35 -05:00
Mateusz Sierszulski 47d0e79444 drivers: i2c: Add Ambiq I2C driver
This commit adds I2C master driver for Apollo4 SoCs.

Signed-off-by: Mateusz Sierszulski <msierszulski@antmicro.com>
2023-08-17 15:15:45 +02:00
Andriy Gelman d330d97997 dts: bindings: Rename compatible infineon,xmc4-i2c->infineon,xmc4xxx-i2c
To be consistent with other xmc4xxx drivers.

A few other device tree changes:
- Rename clock signal option as it's handled by DX1.
- Remove clock-frequency option as it's already added in
  i2c-controller.yaml, and interrupts is already defined as array
  in base.yaml.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2023-08-16 20:43:50 +02:00
Andriy Gelman 16c40b16f3 drivers: i2c: i2c_ifx_xmc4: Configure I2C and other small fixes
Currently the driver is not configured as controller during initialization.
Any use of I2C in controller mode without an explicit i2c_configure() will
not work.

In this commit the driver is automatically configured.
But, delay the configuraition until first use instead of during init
because otherwise tests/drivers/i2c/i2c_target_api hangs without any
errors on xmc47_relax_kit (when internal pulls are used). This issue
needs to be investigated.

There are a few other fixes/cleanups:
- Change the default master_frequency from XMC4_I2C_SPEED_STANDARD to
  I2C_SPEED_STANDARD.
- Use devicetree clock frequency for target configuration instead of
  I2C_SPEED_STANDARD.
- Rename master_frequency to bitrate as it's also used by the target
  configuration now.
- Remove several uneeded casts.
- Forward backup config in get_config().

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2023-08-16 20:43:50 +02:00
Tom Burdick dae2f33e5e rtio: Remove references to simple executor
The simple executor was removed with the usage of the spsc queue but
some stray references remained. Remove those.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-08-16 20:41:18 +02:00
Dong Wang b774b97ff9 drivers: i2c: Add Intel SEDI driver
Adds a new I2C shim driver for Intel SoCs. Builds upon the SEDI bare
metal I2C driver in the hal-intel module.

Signed-off-by: Dong Wang <dong.d.wang@intel.com>
2023-08-04 10:46:24 +02:00
Tim Lin 159fa4888b ITE: drivers/i2c: Channel C/i2c2 cannot use FIFO mode
Sometimes, channel C may write wrong register to the target device.
This issue occurs when FIFO2 is enabled on channel C. The problem
arises because FIFO2 is shared between channel B and channel C.
FIFO2 will be disabled when data access is completed, at which point
FIFO2 is set to the default configuration for channel B.
The byte counter of FIFO2 may be affected by channel B. There is a
chance that channel C may encounter wrong register being written due
to the FIFO2 byte counter wrong write after channel B's write operation.

The current workaround is that channel C cannot use FIFO mode.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2023-08-04 10:45:48 +02:00
Cong Nguyen Huu 3d1285bc40 drivers: i2c_mcux: update to compatible with S32K344
Update to shim driver compatible with the hardware block
in S32K344. Configure the pins before initializing I2C
to avoid happening bus busy.

Signed-off-by: Cong Nguyen Huu <cong.nguyenhuu@nxp.com>
2023-07-27 12:32:07 -05:00
Adam Wojasinski 368acbe2d1 drivers: i2c: i2c_nrfx_twim: Utilize memory-region prop from devicetree
This commit aligns TWIM shim to utilize memory-region property.
The memory-region is not required property that enables user
to specify placement of dma buffers in memory region.
It is done by assigning to memory-region property,
phandle to node with zephyr,memory-region and mimo-sram compatible.

When memory-region property is not specified for given
instance, buffer is placed in default RAM region with other data.

Signed-off-by: Adam Wojasinski <adam.wojasinski@nordicsemi.no>
2023-07-26 09:36:31 +02:00
Adam Wojasinski 905a8ae402 drivers: i2c: i2c_nrfx_twim: remove redundant buffer size from config
There are two different i2c node properites `zephyr,flash-buf-max-size`
and `zephyr,concat-buf-size`. In the end max value of that two is used
to define size of the message buffer.
It's redundant to store both values in device config structure.
Changed config structure to contain only bigger value.

Signed-off-by: Adam Wojasinski <adam.wojasinski@nordicsemi.no>
2023-07-26 09:36:31 +02:00
Marek Matej 6b57b3b786 soc: xtensa,riscv: esp32xx: refactor folder structure
Refactor the ESP32 target SOCs together with
all related boards. Most braking changes includes:

- changing the CONFIG_SOC_ESP32* to refer to
  the actual soc line (esp32,esp32s2,esp32s3,esp32c3)
- replacing CONFIG_SOC with the CONFIG_SOC_SERIES
- creating CONFIG_SOC_FAMILY_ESP32 to embrace all
  the ESP32 across all used architectures
- introducing CONFIG_SOC_PART_NUMBER_* to
  provide a SOC model config
- introducing the 'common' folder to hide all
  commonly used configs and files.
- updating west.yml to reflect previous changes in hal

Signed-off-by: Marek Matej <marek.matej@espressif.com>
2023-07-25 18:12:33 +02:00
Andrzej Głąbek fb7d40c757 drivers: i2c: nrfx: Clean up driver instantiation
- use CONFIG_HAS_HW_NRF_* symbols consistently in nRF multi-instance
  drivers when creating particular driver instances
- remove unnecessary hidden Kconfig options that indicated the type of
  peripheral to be used by a given instance (e.g. SPI, SPIM, or SPIS)
  and enabled proper nrfx driver instance; instead, use one option per
  peripheral type and include the corresponding shim driver flavor into
  compilation basing on that option (not the one that enables the nrfx
  driver as it was incorrectly done so far in some cases)

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2023-07-25 13:41:51 +02:00
Kai Meinhard ea846e12bf i2c: Applied clang-format to i2c_gecko.c
Minor formatting changes in i2c_gecko.c with the
clang-format tool.

Signed-off-by: Kai Meinhard <kaimeinhard@hotmail.de>
2023-07-25 10:44:47 +02:00
Kai Meinhard f345d6d1d8 i2c: add target mode to Silicon Labs Gecko I2C driver
This commits adds the ability to use Silicon Lab chips as an I2C
target. This could be used together with the EEPROM target
driver.

Signed-off-by: Kai Meinhard <kaimeinhard@hotmail.de>
2023-07-25 10:44:47 +02:00
Nicolas Pitre 531aa5786d drivers: move to timepoint API
Remove sys_clock_timeout_end_calc() usage.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2023-07-25 09:12:26 +02:00
Tim Lin 995444d5a9 ITE: drivers/i2c: Modify the condition of assert
Channel B or C do not necessarily have to use FIFO mode.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2023-07-21 10:30:42 +00:00
Wei-Tai Lee f2e0f787bf drivers: i2c: add error handling
Return errors when failing at consecutive transactions and
missing targets.

Signed-off-by: Wei-Tai Lee <wtlee@andestech.com>
2023-07-13 09:23:39 +02:00
Wei-Tai Lee fc89a85c29 drivers: i2c: add thread-safe semaphore
Add a semaphore to ensure that only one transaction
happens at a time when threads want to transfer
simultaneously.

Signed-off-by: Wei-Tai Lee <wtlee@andestech.com>
2023-07-13 09:23:39 +02:00
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