Commit graph

30 commits

Author SHA1 Message Date
Tim Lin 0967f13c3f ITE: drivers/i2c: Add a property selecting to drive I2C recovery mode
Add a property to select the push-pull GPIO output type to drive the
I2C recovery. The default is open-drain.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2024-04-02 14:30:48 +01:00
Tim Lin 9d9d1ff380 ITE: drivers/i2c/target: Remove hardware reset setting
In the interrupt pending routine, only the interrupt status needs to be
cleared at the end of the interrupt routine. There is no need to do a
hardware reset(HALT) to avoid clearing the next transfer interrupt when
the current transfer is completed.

Test: Testing this function does not cause I2C data/clk to get stuck on
the system platform.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2024-03-19 07:56:19 -04:00
Tim Lin ebbc96534c ITE: drivers/i2c: Change GPIO output type to open-drain in recovery mode
If I2C recovery mode uses GPIO push-pull to drive(3.3v), it will result
leakage in a pull-up voltage of 1.8V on the power rail, leading to
damage to 1.8V devices, including SoC, sensors.
Therefore, the recovery mode should be changed to GPIO open-drain type
to avoid this.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2024-03-14 09:31:50 +01:00
Dino Li 6b0b63b3a7 ITE: drivers/i2c target mode: Fix racing condition
The finish interrupt after the previous transaction is completed may
occur in the next transaction. To do hardware reset at this time could
potentially lead to the failure of the transaction.
Therefore, removing the hardware reset upon completing the transaction
helps to avoid a race condition.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
2024-02-26 11:54:13 +00:00
Tim Lin 9948c29885 ITE: drivers/i2c: Adjust the prescale of I2C SCL low and high period
When adjusting the prescale to increase the I2C SCL low period,
the high period must also be subtracted to maintain a consistent
frequency.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2024-01-18 07:22:55 -05:00
Tim Lin ba11dc8065 ITE: drivers/i2c: Add the property of I2C data hold time
Add a property to adjust the I2C data hold time which will pass
the SI test.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2024-01-18 07:22:55 -05:00
Pisit Sawangvonganan 70c7ac704d drivers: i2c: correct spelling
Employ a code spell checking tool to scan and correct spelling errors
in all files within the drivers/i2c directory.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-01-15 09:59:17 +01:00
Tim Lin f1dc11174c ITE: drivers/i2c: Add a property for I2C located channel
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>
2023-11-08 10:08:28 +01:00
Keith Short 63b8890ad4 ITE: drivers/i2c/i2c_ite_enhance: Fix I2C dump messages
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>
2023-11-07 09:54:06 +01: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
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
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
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
Tim Lin cffcc1901e ITE: drivers/i2c: Fix mutex bug
When an error occurs, the driver will miss unlocking a mutex.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2022-11-03 09:01:07 +00:00
Gerard Marull-Paretas 6a0f554ffa include: add missing kernel.h include
Some files make use of Kernel APIs without including kernel.h, fix this
problem.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-11 18:05:17 +02:00
Gerard Marull-Paretas acc8cb4bc8 include: add missing irq.h include
Some modules use the IRQ API without including the necessary headers.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-11 18:05:17 +02:00
Tim Lin c30ec3ba4d ITE: drivers/i2c: Rename the parameter in data struct
Rename the parameter in data struct to avoid confusion.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2022-09-22 14:58:42 +00:00
Tim Lin de1fc0ca89 ITE: drivers/i2c: Fix the bug of msgs in I2C transfer
1. To explicitly set the MSG_START flag on the first message.
2. Remove redundant declare.
3. Using data->msgs->flags is the correct address instead of
   msgs->flags.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2022-09-22 14:58:42 +00:00
Tim Lin 001aa3a351 ITE: drivers/i2c_enhance: CQ mode isn't allowed to enter power policy
I2C CQ mode cannot enter power policy during transfer.

test: tests\driver\i2c\i2c_api--> pass

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2022-08-22 16:30:45 +00:00
Tim Lin d7ccea6357 ITE: drivers/i2c: Add command queue mode not allowed condition
If the transaction of write or read is divided into two transfers
(not two messages), the command queue mode does not support.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2022-07-20 11:08:56 +02:00
Tim Lin 04c6d7569f ITE: drivers/i2c: Add command queue mode
Adding command queue mode can reduce the time between each byte to
improve the I2C bus clock stretching during I2C transaction.

I2C command queue mode of it8xxx2 can support I2C APIs including:
i2c_write(), i2c_read(), i2c_burst_read.

Test:
1. tests\drivers\i2c\i2c_api --> pass
2. Reading 16 bytes of data through i2c_burst_read() can reduce
   0.72ms(2.54ms->1.82ms) compared to the original pio mode when the
   frequency is 100KHz.
3. krabby platform can boot normally.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2022-07-13 10:15:32 +02:00
Anas Nashif 49b36ead95 drivers: add mising braces to single line if statements
Following zephyr's style guideline, all if statements, including single
line statements shall have braces.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-07-06 11:00:45 -04:00
Tom Burdick 88ca215eed i2c: Update API terminology
Updates the API and types to match updated I2C terminology. Replaces master
with controller and slave with target.

Updates all drivers to match the changed macros, types, and API signatures.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-06-29 17:51:31 +02:00
Tim Lin 19724ba002 ITE: drivers/i2c: Enable I2C interrupt after completing configuration
Fix the flow of I2C enable interrupt. We should enable the interrupt
after I2C configuration is completed to avoid pending interrupts and
cause errors irq.

Test port:
i2c_ite_it8xxx2: i2c0
i2c_ite_enhance: i2c4
Test:
tests\drivers\i2c\i2c_api --> pass

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2022-06-20 10:24:27 +02:00
Gerard Marull-Paretas fb60aab245 drivers: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all drivers to the new
prefix <zephyr/...>. Note that the conversion has been scripted, refer
to #45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-06 19:58:21 +02:00
Tim Lin 64ff1a8efe ITE: drivers/i2c: Use pinctrl instead of pinmux driver
Use pinctrl instead of pinmux driver.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2022-05-06 11:32:40 +02:00
Tim Lin 0b9c0a0b23 ITE: drivers/i2c: implement i2c specified speed option of 50 KHz
Implement i2c specified speed option of 50 KHz in ITE i2c driver.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2022-03-22 20:30:38 -04:00
Tim Lin f2c42663b4 ITE: drivers/i2c: I2C driver divided into two compatibles
As mentioned in #42882, the I2C of IT8XXX2 is designed for two different
IP blocks, so this PR divides this I2C driver into two compatibles.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2022-03-17 15:53:34 -05:00