i2c: Add support for DesignWare controllers
PATCH 1/1 i2c: Add support for DesignWare controllers
Add a driver for DesignWare I2C controller IP block found on several SoCs including Altera SoC products
Tested using Terrasic SoCKit board and GPIO expander board with I2C EEPROM on it
--- drivers/i2c/busses/Kconfig | 6 + drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-designware.c | 576 ++++++++++++++++++++++++++++++++++++ 3 files changed, 583 insertions(+) create mode 100644 drivers/i2c/busses/i2c-designware.c
drivers/i2c/busses/Kconfig +6 -0
@@ -25,6 +25,12 @@ config I2C_IMX for many i.MX ARM based SoCs, for MPC85xx and MPC5200 PowerPC based SoCs. +config I2C_DESIGNWARE + bool "Synopsys DesignWare I2C Master driver" + help + If you say yes to this option, support will be included for the + Synopsys DesignWare I2C adapter. Only master mode is supported. + config I2C_MV64XXX bool "Marvell mv64xxx I2C Controller" depends on HAVE_CLK && OFDEVICE
drivers/i2c/busses/Makefile +1 -0
@@ -5,3 +5,4 @@ obj-$(CONFIG_I2C_MV64XXX) += i2c-mv64xxx.o obj-$(CONFIG_I2C_OMAP) += i2c-omap.o obj-$(CONFIG_I2C_TEGRA) += i2c-tegra.o obj-$(CONFIG_I2C_VERSATILE) += i2c-versatile.o +obj-$(CONFIG_I2C_DESIGNWARE) += i2c-designware.o
drivers/i2c/busses/i2c-designware.c new file +576 -0
576 lines not on this page · raw message
--
2.1.4
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH 1/1 memtest: Fix reference to non-existing function
It looks like commit c674e2d5847069ff34fb05e012ff1464cc0a6b37 replaced mem_test_moving_inversions() with mem_test_moving_inversions_pattern() but did not include the code of the latter function. Revert that portion of the change in order to fix the build
--- commands/memtest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
commands/memtest.c +1 -1
@@ -47,7 +47,7 @@ static int do_test_one_area(struct mem_test_resource *r, int bus_only,if (bus_only)return 0 ; - ret =mem_test_moving_inversions_pattern (r->r->start, r->r->end,0xdeadbeef ); + ret =mem_test_moving_inversions (r->r->start, r->r->end);if (ret <0 )return ret;printf ("done.\n\n" );
--
2.1.4
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 8 lines · Andrey Smirnov
Add a driver for DesignWare I2C controller IP block found on several SoCs including Altera SoC products
Tested using Terrasic SoCKit board and GPIO expander board with I2C EEPROM on it
Signed-off-by Andrey Smirnov <[email protected]>---
Looks mostly fine. Two small nitpicks inside.
drivers/i2c/busses/i2c-designware.c line 482
Quoted 10 lines
drivers/i2c/busses/i2c-designware.c new file +10
-0+static int i2c_dw_probe (struct device_d *pdev) +{ +struct dw_i2c_dev *dw; +struct i2c_platform_data *pdata; +int ret, bitrate; +uint32_t ic_con, ic_comp_type_value; + + pdata = pdev->platform_data; + + dw =kzalloc (sizeof (*dw),GFP_KERNEL );
kzalloc can fail. You should use xzalloc here which cannot fail.
Quoted 67 lines
drivers/i2c/busses/i2c-designware.c new file +67
-0+ +if (IS_ENABLED (CONFIG_COMMON_CLK )) { + dw->clk =clk_get (pdev,NULL ); +if (IS_ERR (dw->clk)) { + ret =PTR_ERR (dw->clk); + goto fail; + } + } + + dw->adapter.master_xfer = i2c_dw_xfer; + dw->adapter.nr = pdev->id; + dw->adapter.dev.parent = pdev; + dw->adapter.dev.device_node = pdev->device_node; + + dw->base =dev_request_mem_region (pdev,0 ); +if (IS_ERR (dw->base)) { + ret =PTR_ERR (dw->base); + goto fail; + } + + ic_comp_type_value =readl (dw->base +DW_IC_COMP_TYPE ); +if (ic_comp_type_value !=DW_IC_COMP_TYPE_VALUE ) { +dev_err (pdev, +"unknown DesignWare IP block 0x%08x" , + ic_comp_type_value); + ret = -ENODEV ; + goto fail; + } + +i2c_dw_enable (dw, false); + +if (IS_ENABLED (CONFIG_COMMON_CLK )) +i2c_dw_setup_timings (dw); + + bitrate = (pdata && pdata->bitrate) ? pdata->bitrate :DW_I2C_BIT_RATE ; + +/* +* We have to clear 'ic_10bitaddr_master' in 'ic_tar' +* register, otherwise 'ic_10bitaddr_master' in 'ic_con' +* wouldn't clear. We don't care about preserving the contents +* of that register so we set it to zero. +*/ +writel (0 , dw->base +DW_IC_TAR ); + +switch (bitrate) { +case 400000 : + ic_con =DW_IC_CON_SPEED_FAST ; +break ; +default : +dev_warn (pdev,"requested bitrate (%d) is not supported." +" Falling back to 100kHz" , bitrate); +case 100000 :/* FALLTHROUGH */ + ic_con =DW_IC_CON_SPEED_STD ; +break ; + } + + ic_con |=DW_IC_CON_MASTER |DW_IC_CON_SLAVE_DISABLE ; + +writel (ic_con, dw->base +DW_IC_CON ); + +/* +* Since we will be working in polling mode set both +* thresholds to their minimum +*/ +writel (0 , dw->base +DW_IC_RX_TL ); +writel (0 , dw->base +DW_IC_TX_TL ); +
drivers/i2c/busses/i2c-designware.c line 559
Quoted 10 lines
drivers/i2c/busses/i2c-designware.c new file +10
-0+/* Disable and clear all interrrupts */ +writel (0 , dw->base +DW_IC_INTR_MASK ); +readl (dw->base +DW_IC_CLR_INTR ); + +i2c_dw_enable (dw, true); + + ret =i2c_add_numbered_adapter (&dw->adapter); +fail: +if (ret <0 ) { +dev_err (pdev,"registration failed\n" );
This message is unnecessary. The driver core will warn you when probe fails anyway.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox