Fixes the routing of the events associated with a secondary
i2c target address being routed to the primary config. The
i2c_target_config/slave_cfg was being selected from the
driver address match but then over written by the primary.
This change fully implements the if/else of 10bit addressing
and includes a assert if the slave_cfg is NULL, and explains
why dual 10bit addresses on STM32 won't work.
Signed-off-by: Tim Woolliscroft <tim@opteran.com>
Do not enable subsystem/driver shell modules by default and stop abusing
CONFIG_SHELL_MINIMAL, which is internal to the shell subsystem, to decide
when to enable a driver shell.
The list of shell modules has grown considerably through the
years. Enabling CONFIG_SHELL for doing e.g. an interactive debug session
leads to a large number of shell modules also being enabled unless
explicitly disabled, which again leads to non-negligible increases in
RAM/ROM usage.
This commit attempts to establish a policy of subsystem/driver shell
modules being disabled by default, requiring the user/application to
explicitly enable only those needed.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
Use GPIO_OUTPUT_INACTIVE to initialize the pin so that the ACTIVE_LOW DT
flag is honored and use the gpio_pin_set_dt functions to set the
(logical) value of the pin instead of gpio_pin_configure_dt, that
tries to reconfigure the pin each time.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
We need to do a build assert for the fifo enable status of 'I2C2'.
There is a problem with using instance to obtain property when
any one I2C port is not enabled.
Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
Add drivers for gpio_i2c_switch which is present in beagleconnect freedom
Signed-off-by: Vaishnav Achath <vaishnav@beagleboard.org>
Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
Add a property for I2C channel switch selection. This property will
write to the SMBxxCHS register according to the I2C node you selected,
which can make channel swapping.
Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
The ISR for CQ mode was unconditionally writing into the I2C message
buffer for all transfer types. The correct data was transferred on the
I2C interface, but the clobber caused CONFIG_I2C_LOG_LEVEL_DBG to
display incorrect data for I2C writes.
This change will also help performance of large I2C write transactions.
Signed-off-by: Keith Short <keithshort@google.com>
Move the syscall_handler.h header, used internally only to a dedicated
internal folder that should not be used outside of Zephyr.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Remove unwanted "pm_device_runtime_get" lock which makes i2c power
management working incorrectly.
Fixes: #62790
Signed-off-by: Petr Hlineny <development@hlineny.cz>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
- 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>
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>
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>
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>
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>
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>
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>
- 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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
- 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>
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>
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>
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>
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>
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>