Lines Matching +full:slave +full:- +full:mode

1 // SPDX-License-Identifier: GPL-2.0
3 * i2c slave support for Atmel's AT91 Two-Wire Interface (TWI)
13 #include "i2c-at91.h"
25 /* slave address has been detected on I2C bus */ in atmel_twi_interrupt_slave()
28 i2c_slave_event(dev->slave, in atmel_twi_interrupt_slave()
30 writeb_relaxed(value, dev->base + AT91_TWI_THR); in atmel_twi_interrupt_slave()
34 i2c_slave_event(dev->slave, in atmel_twi_interrupt_slave()
44 i2c_slave_event(dev->slave, I2C_SLAVE_READ_PROCESSED, &value); in atmel_twi_interrupt_slave()
45 writeb_relaxed(value, dev->base + AT91_TWI_THR); in atmel_twi_interrupt_slave()
50 value = readb_relaxed(dev->base + AT91_TWI_RHR); in atmel_twi_interrupt_slave()
51 i2c_slave_event(dev->slave, I2C_SLAVE_WRITE_RECEIVED, &value); in atmel_twi_interrupt_slave()
59 i2c_slave_event(dev->slave, I2C_SLAVE_STOP, &value); in atmel_twi_interrupt_slave()
65 static int at91_reg_slave(struct i2c_client *slave) in at91_reg_slave() argument
67 struct at91_twi_dev *dev = i2c_get_adapdata(slave->adapter); in at91_reg_slave()
69 if (dev->slave) in at91_reg_slave()
70 return -EBUSY; in at91_reg_slave()
72 if (slave->flags & I2C_CLIENT_TEN) in at91_reg_slave()
73 return -EAFNOSUPPORT; in at91_reg_slave()
76 pm_runtime_get_sync(dev->dev); in at91_reg_slave()
78 dev->slave = slave; in at91_reg_slave()
79 dev->smr = AT91_TWI_SMR_SADR(slave->addr); in at91_reg_slave()
84 dev_info(dev->dev, "entered slave mode (ADR=%d)\n", slave->addr); in at91_reg_slave()
89 static int at91_unreg_slave(struct i2c_client *slave) in at91_unreg_slave() argument
91 struct at91_twi_dev *dev = i2c_get_adapdata(slave->adapter); in at91_unreg_slave()
93 WARN_ON(!dev->slave); in at91_unreg_slave()
95 dev_info(dev->dev, "leaving slave mode\n"); in at91_unreg_slave()
97 dev->slave = NULL; in at91_unreg_slave()
98 dev->smr = 0; in at91_unreg_slave()
102 pm_runtime_put(dev->dev); in at91_unreg_slave()
124 rc = devm_request_irq(&pdev->dev, dev->irq, atmel_twi_interrupt_slave, in at91_twi_probe_slave()
125 0, dev_name(dev->dev), dev); in at91_twi_probe_slave()
127 dev_err(dev->dev, "Cannot get irq %d: %d\n", dev->irq, rc); in at91_twi_probe_slave()
131 dev->adapter.algo = &at91_twi_algorithm_slave; in at91_twi_probe_slave()
139 if (dev->slave_detected && dev->smr) { in at91_init_twi_bus_slave()
140 at91_twi_write(dev, AT91_TWI_SMR, dev->smr); in at91_init_twi_bus_slave()