i2c: rockchip: Replace driver from kernel repository
Subsystems (2)
PATCH 1/1 i2c: rockchip: Replace driver from kernel repository
The current Rockchip i2c driver was taken from the u-boot repository, so it has minimal functionality and is designed to be the simplest. Development with the Rockchip SOC led to the idea that it is not sufficient to handle some i2c devices (in my case, this i2c EEPROMs and i2c MUXes).
This patch replaces the driver code from the Linux kernel repository to make the driver more flexible with SDA/SCL setup/hold settings and as a result, more stable across boards.
Tested with cusom rk3568-based board.
--- drivers/i2c/busses/Makefile | 2 +- drivers/i2c/busses/i2c-rk3x.c | 1176 +++++++++++++++++++++++++++++ drivers/i2c/busses/i2c-rockchip.c | 462 ------------ 3 files changed, 1177 insertions(+), 463 deletions(-) create mode 100644 drivers/i2c/busses/i2c-rk3x.c delete mode 100644 drivers/i2c/busses/i2c-rockchip.c
drivers/i2c/busses/Makefile +1 -1
@@ -12,5 +12,5 @@ obj-$(CONFIG_I2C_TEGRA) += i2c-tegra.o obj-$(CONFIG_I2C_VERSATILE) += i2c-versatile.o obj-$(CONFIG_I2C_DESIGNWARE) += i2c-designware.o obj-$(CONFIG_I2C_STM32) += i2c-stm32.o -obj-$(CONFIG_I2C_RK3X) += i2c-rockchip.o +obj-$(CONFIG_I2C_RK3X) += i2c-rk3x.o obj-$(CONFIG_I2C_CADENCE) += i2c-cadence.o
drivers/i2c/busses/i2c-rk3x.c new file +1176 -0
1,176 lines not on this page · raw message
drivers/i2c/busses/i2c-rockchip.c deleted +0 -462
462 lines not on this page · raw message
Signature · 1 line
2.38.2
Sascha Hauer
AppliedQuoted 11 lines · Alexander Shiyan
The current Rockchip i2c driver was taken from the u-boot repository, so it has minimal functionality and is designed to be the simplest. Development with the Rockchip SOC led to the idea that it is not sufficient to handle some i2c devices (in my case, this i2c EEPROMs and i2c MUXes).
This patch replaces the driver code from the Linux kernel repository to make the driver more flexible with SDA/SCL setup/hold settings and as a result, more stable across boards.
Tested with cusom rk3568-based board.[...]
Applied, thanks!
[1/1] i2c: rockchip: Replace driver from kernel repository
https://git.pengutronix.de/cgit/barebox/commit/?id=840b074cdab9 (link may not be stable)
Best regards,
Signature · 1 line
Sascha Hauer <[email protected]>
Hi Alexander,
drivers/i2c/busses/i2c-rk3x.c line 945
Quoted 10 lines · Alexander Shiyan
drivers/i2c/busses/i2c-rk3x.c new file +10
-0+ +static int rk3x_i2c_wait_xfer_poll (struct rk3x_i2c *i2c) +{ +uint64_t start =get_time_ns (); + +while (!is_timeout (start,WAIT_TIMEOUT )) { +rk3x_i2c_irq (i2c); +if (i2c->state ==STATE_IDLE ) +return 0 ; +udelay (5 );
While it doesn't really hurt, this delay is unnecessary. We're busy waiting anyway.
Quoted 10 lines
drivers/i2c/busses/i2c-rk3x.c new file +10
-0+ } + +return -ETIMEDOUT ; +} + +static int rk3x_i2c_probe (struct device *dev) +{ +struct device_node *np = dev->of_node; +struct rk3x_i2c_soc_data *data; +struct resource *iores;
drivers/i2c/busses/i2c-rk3x.c line 1088
Quoted 10 lines
drivers/i2c/busses/i2c-rk3x.c new file +10
-0+unsigned long clk_rate; +struct rk3x_i2c *i2c; +int ret; + + i2c =xzalloc (sizeof (*i2c)); + i2c->dev = dev; + + ret =dev_get_drvdata (dev, (const void **)&data); +if (ret <0 ) +return dev_err_probe (dev, ret,"Failed to retrieve driver data\n" );
This function is deprecated:
* DEPRECATED: use device_get_match_data instead, which avoids
* common pitfalls due to explicit pointer casts
I fixed these two things while applying.
Sascha
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |