Skip to content

Commit 9f3e065

Browse files
Luis OliveiraWolfram Sang
authored andcommitted
i2c: designware: add SLAVE mode functions
- Changes in Kconfig to enable I2C_DESIGNWARE_SLAVE support - Slave functions added to core library file - Slave abort sources added to common source file - New driver: i2c-designware-slave added - Changes in the Makefile to compile the I2C_DESIGNWARE_SLAVE module when supported by the architecture. All the SLAVE flow is added but it is not enabled via platform driver. Signed-off-by: Luis Oliveira <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Acked-by: Jarkko Nikula <[email protected]> [wsa: made a function static and one-lined a message] Signed-off-by: Wolfram Sang <[email protected]>
1 parent 86766a3 commit 9f3e065

File tree

5 files changed

+418
-1
lines changed

5 files changed

+418
-1
lines changed

drivers/i2c/busses/Kconfig

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,14 +483,26 @@ config I2C_DESIGNWARE_CORE
483483
config I2C_DESIGNWARE_PLATFORM
484484
tristate "Synopsys DesignWare Platform"
485485
select I2C_DESIGNWARE_CORE
486+
select I2C_DESIGNWARE_SLAVE
486487
depends on (ACPI && COMMON_CLK) || !ACPI
487488
help
488489
If you say yes to this option, support will be included for the
489-
Synopsys DesignWare I2C adapter. Only master mode is supported.
490+
Synopsys DesignWare I2C adapter.
490491

491492
This driver can also be built as a module. If so, the module
492493
will be called i2c-designware-platform.
493494

495+
config I2C_DESIGNWARE_SLAVE
496+
bool "Synopsys DesignWare Slave"
497+
select I2C_SLAVE
498+
depends on I2C_DESIGNWARE_PLATFORM
499+
help
500+
If you say yes to this option, support will be included for the
501+
Synopsys DesignWare I2C slave adapter.
502+
503+
This is not a standalone module, this module compiles together with
504+
i2c-designware-core.
505+
494506
config I2C_DESIGNWARE_PCI
495507
tristate "Synopsys DesignWare PCI"
496508
depends on PCI

drivers/i2c/busses/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ obj-$(CONFIG_I2C_CPM) += i2c-cpm.o
4242
obj-$(CONFIG_I2C_DAVINCI) += i2c-davinci.o
4343
obj-$(CONFIG_I2C_DESIGNWARE_CORE) += i2c-designware-core.o
4444
i2c-designware-core-objs := i2c-designware-common.o i2c-designware-master.o
45+
ifeq ($(CONFIG_I2C_DESIGNWARE_SLAVE),y)
46+
i2c-designware-core-objs += i2c-designware-slave.o
47+
endif
4548
obj-$(CONFIG_I2C_DESIGNWARE_PLATFORM) += i2c-designware-platform.o
4649
i2c-designware-platform-objs := i2c-designware-platdrv.o
4750
i2c-designware-platform-$(CONFIG_I2C_DESIGNWARE_BAYTRAIL) += i2c-designware-baytrail.o

drivers/i2c/busses/i2c-designware-common.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ static char *abort_sources[] = {
5656
"trying to use disabled adapter",
5757
[ARB_LOST] =
5858
"lost arbitration",
59+
[ABRT_SLAVE_FLUSH_TXFIFO] =
60+
"read command so flush old data in the TX FIFO",
61+
[ABRT_SLAVE_ARBLOST] =
62+
"slave lost the bus while transmitting data to a remote master",
63+
[ABRT_SLAVE_RD_INTX] =
64+
"incorrect slave-transmitter mode configuration",
5965
};
6066

6167
u32 dw_readl(struct dw_i2c_dev *dev, int offset)

drivers/i2c/busses/i2c-designware-core.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,11 @@ u32 i2c_dw_func(struct i2c_adapter *adap);
305305
void i2c_dw_disable(struct dw_i2c_dev *dev);
306306
void i2c_dw_disable_int(struct dw_i2c_dev *dev);
307307
int i2c_dw_init(struct dw_i2c_dev *dev);
308+
int i2c_dw_init_slave(struct dw_i2c_dev *dev);
308309

309310
extern u32 i2c_dw_read_comp_param(struct dw_i2c_dev *dev);
310311
extern int i2c_dw_probe(struct dw_i2c_dev *dev);
312+
extern int i2c_dw_probe_slave(struct dw_i2c_dev *dev);
311313

312314
#if IS_ENABLED(CONFIG_I2C_DESIGNWARE_BAYTRAIL)
313315
extern int i2c_dw_probe_lock_support(struct dw_i2c_dev *dev);

0 commit comments

Comments
 (0)