diff options
author | Juergen Fitschen <jfi@ssv-embedded.de> | 2019-02-22 10:25:22 +0100 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2019-03-24 22:41:51 +0100 |
commit | 9d3ca54b550ca070d3e3ed0c137ed1655fcf2772 (patch) | |
tree | 5b02bd1a480a674ff5a826d0931d85ecdc0d8a98 /drivers/i2c/busses/i2c-at91-core.c | |
parent | ad7d142f8951ce00e0366ba54bfaf8ab086eb4b9 (diff) | |
download | linux-9d3ca54b550ca070d3e3ed0c137ed1655fcf2772.tar.gz linux-9d3ca54b550ca070d3e3ed0c137ed1655fcf2772.tar.bz2 linux-9d3ca54b550ca070d3e3ed0c137ed1655fcf2772.zip |
i2c: at91: added slave mode support
Slave mode driver is based on the concept of i2c-designware driver.
Signed-off-by: Juergen Fitschen <me@jue.yt>
[ludovic.desroches@microchip.com: rework Kconfig and replace IS_ENABLED
by defined]
Signed-off-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers/i2c/busses/i2c-at91-core.c')
-rw-r--r-- | drivers/i2c/busses/i2c-at91-core.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/i2c/busses/i2c-at91-core.c b/drivers/i2c/busses/i2c-at91-core.c index 6cb22341fa81..8d55cdd69ff4 100644 --- a/drivers/i2c/busses/i2c-at91-core.c +++ b/drivers/i2c/busses/i2c-at91-core.c @@ -56,8 +56,10 @@ void at91_init_twi_bus(struct at91_twi_dev *dev) { at91_disable_twi_interrupts(dev); at91_twi_write(dev, AT91_TWI_CR, AT91_TWI_SWRST); - - at91_init_twi_bus_master(dev); + if (dev->slave_detected) + at91_init_twi_bus_slave(dev); + else + at91_init_twi_bus_master(dev); } static struct at91_twi_pdata at91rm9200_config = { @@ -239,7 +241,12 @@ static int at91_twi_probe(struct platform_device *pdev) dev->adapter.timeout = AT91_I2C_TIMEOUT; dev->adapter.dev.of_node = pdev->dev.of_node; - rc = at91_twi_probe_master(pdev, phy_addr, dev); + dev->slave_detected = i2c_detect_slave_mode(&pdev->dev); + + if (dev->slave_detected) + rc = at91_twi_probe_slave(pdev, phy_addr, dev); + else + rc = at91_twi_probe_master(pdev, phy_addr, dev); if (rc) return rc; |