Lines Matching refs:adap
41 struct i2c_adapter adap; member
55 static int wait_xfer_done(struct i2c_au1550_data *adap) in wait_xfer_done() argument
60 for (i = 0; i < adap->xfer_timeout; i++) { in wait_xfer_done()
61 if (RD(adap, PSC_SMBSTAT) & PSC_SMBSTAT_TE) in wait_xfer_done()
70 static int wait_ack(struct i2c_au1550_data *adap) in wait_ack() argument
74 if (wait_xfer_done(adap)) in wait_ack()
77 stat = RD(adap, PSC_SMBEVNT); in wait_ack()
84 static int wait_master_done(struct i2c_au1550_data *adap) in wait_master_done() argument
89 for (i = 0; i < 2 * adap->xfer_timeout; i++) { in wait_master_done()
90 if ((RD(adap, PSC_SMBEVNT) & PSC_SMBEVNT_MD) != 0) in wait_master_done()
99 do_address(struct i2c_au1550_data *adap, unsigned int addr, int rd, int q) in do_address() argument
104 stat = RD(adap, PSC_SMBSTAT); in do_address()
105 WR(adap, PSC_SMBEVNT, PSC_SMBEVNT_ALLCLR); in do_address()
108 WR(adap, PSC_SMBPCR, PSC_SMBPCR_DC); in do_address()
109 while ((RD(adap, PSC_SMBPCR) & PSC_SMBPCR_DC) != 0) in do_address()
124 WR(adap, PSC_SMBTXRX, addr); in do_address()
125 WR(adap, PSC_SMBPCR, PSC_SMBPCR_MS); in do_address()
126 if (wait_ack(adap)) in do_address()
128 return (q) ? wait_master_done(adap) : 0; in do_address()
131 static int wait_for_rx_byte(struct i2c_au1550_data *adap, unsigned char *out) in wait_for_rx_byte() argument
135 if (wait_xfer_done(adap)) in wait_for_rx_byte()
138 j = adap->xfer_timeout * 100; in wait_for_rx_byte()
144 if ((RD(adap, PSC_SMBSTAT) & PSC_SMBSTAT_RE) == 0) in wait_for_rx_byte()
150 *out = RD(adap, PSC_SMBTXRX); in wait_for_rx_byte()
155 static int i2c_read(struct i2c_au1550_data *adap, unsigned char *buf, in i2c_read() argument
169 WR(adap, PSC_SMBTXRX, 0); in i2c_read()
170 if (wait_for_rx_byte(adap, &buf[i])) in i2c_read()
177 WR(adap, PSC_SMBTXRX, PSC_SMBTXRX_STP); in i2c_read()
178 if (wait_master_done(adap)) in i2c_read()
181 buf[i] = (unsigned char)(RD(adap, PSC_SMBTXRX) & 0xff); in i2c_read()
185 static int i2c_write(struct i2c_au1550_data *adap, unsigned char *buf, in i2c_write() argument
197 WR(adap, PSC_SMBTXRX, data); in i2c_write()
198 if (wait_ack(adap)) in i2c_write()
206 WR(adap, PSC_SMBTXRX, data); in i2c_write()
207 if (wait_master_done(adap)) in i2c_write()
215 struct i2c_au1550_data *adap = i2c_adap->algo_data; in au1550_xfer() local
219 WR(adap, PSC_CTRL, PSC_CTRL_ENABLE); in au1550_xfer()
223 err = do_address(adap, p->addr, p->flags & I2C_M_RD, in au1550_xfer()
228 err = i2c_read(adap, p->buf, p->len); in au1550_xfer()
230 err = i2c_write(adap, p->buf, p->len); in au1550_xfer()
238 WR(adap, PSC_CTRL, PSC_CTRL_SUSPEND); in au1550_xfer()
243 static u32 au1550_func(struct i2c_adapter *adap) in au1550_func() argument
320 priv->adap.nr = pdev->id; in i2c_au1550_probe()
321 priv->adap.algo = &au1550_algo; in i2c_au1550_probe()
322 priv->adap.algo_data = priv; in i2c_au1550_probe()
323 priv->adap.dev.parent = &pdev->dev; in i2c_au1550_probe()
324 strlcpy(priv->adap.name, "Au1xxx PSC I2C", sizeof(priv->adap.name)); in i2c_au1550_probe()
329 ret = i2c_add_numbered_adapter(&priv->adap); in i2c_au1550_probe()
343 i2c_del_adapter(&priv->adap); in i2c_au1550_remove()