Lines Matching refs:id

114 	struct cami2c *id = ptr;  in sh7760_i2c_irq()  local
115 struct i2c_msg *msg = id->msg; in sh7760_i2c_irq()
119 msr = IN32(id, I2CMSR); in sh7760_i2c_irq()
120 fsr = IN32(id, I2CFSR); in sh7760_i2c_irq()
124 OUT32(id, I2CMCR, 0); in sh7760_i2c_irq()
125 OUT32(id, I2CSCR, 0); in sh7760_i2c_irq()
126 OUT32(id, I2CSAR, 0); in sh7760_i2c_irq()
127 id->status |= IDS_DONE | IDS_ARBLOST; in sh7760_i2c_irq()
139 OUT32(id, I2CFCR, FCR_RFRST | FCR_TFRST); in sh7760_i2c_irq()
140 OUT32(id, I2CMCR, MCR_MIE | MCR_FSB); in sh7760_i2c_irq()
141 OUT32(id, I2CFIER, 0); in sh7760_i2c_irq()
142 OUT32(id, I2CMIER, MIE_MSTE); in sh7760_i2c_irq()
143 OUT32(id, I2CSCR, 0); in sh7760_i2c_irq()
144 OUT32(id, I2CSAR, 0); in sh7760_i2c_irq()
145 id->status |= IDS_NACK; in sh7760_i2c_irq()
153 id->status |= IDS_DONE; in sh7760_i2c_irq()
159 OUT32(id, I2CMCR, MCR_MIE); in sh7760_i2c_irq()
161 fier = IN32(id, I2CFIER); in sh7760_i2c_irq()
164 len = IN32(id, I2CRFDR); in sh7760_i2c_irq()
166 if (id->flags & IDF_STOP) { in sh7760_i2c_irq()
167 OUT32(id, I2CMCR, MCR_MIE | MCR_FSB); in sh7760_i2c_irq()
168 OUT32(id, I2CFIER, 0); in sh7760_i2c_irq()
173 id->status |= IDS_DONE; in sh7760_i2c_irq()
182 *data++ = IN32(id, I2CRXTX); in sh7760_i2c_irq()
191 OUT32(id, I2CFCR, FCR_TFRST | ((len & 0xf) << 4)); in sh7760_i2c_irq()
194 } else if (id->flags & IDF_SEND) { in sh7760_i2c_irq()
196 if (id->flags & IDF_STOP) { in sh7760_i2c_irq()
197 OUT32(id, I2CMCR, MCR_MIE | MCR_FSB); in sh7760_i2c_irq()
199 id->status |= IDS_DONE; in sh7760_i2c_irq()
208 while (msg->len && (IN32(id, I2CTFDR) < FIFO_SIZE)) { in sh7760_i2c_irq()
209 OUT32(id, I2CRXTX, *data++); in sh7760_i2c_irq()
215 OUT32(id, I2CFIER, fier); in sh7760_i2c_irq()
218 OUT32(id, I2CFCR, in sh7760_i2c_irq()
224 if (id->status & IDS_DONE) { in sh7760_i2c_irq()
225 OUT32(id, I2CMIER, 0); in sh7760_i2c_irq()
226 OUT32(id, I2CFIER, 0); in sh7760_i2c_irq()
227 id->msg = NULL; in sh7760_i2c_irq()
228 complete(&id->xfer_done); in sh7760_i2c_irq()
231 OUT32(id, I2CMSR, ~msr); in sh7760_i2c_irq()
232 OUT32(id, I2CFSR, ~fsr); in sh7760_i2c_irq()
233 OUT32(id, I2CSSR, 0); in sh7760_i2c_irq()
240 static void sh7760_i2c_mrecv(struct cami2c *id) in sh7760_i2c_mrecv() argument
244 id->flags |= IDF_RECV; in sh7760_i2c_mrecv()
247 OUT32(id, I2CSAR, 0xfe); in sh7760_i2c_mrecv()
248 OUT32(id, I2CMAR, (id->msg->addr << 1) | 1); in sh7760_i2c_mrecv()
251 if (id->msg->len >= FIFO_SIZE) in sh7760_i2c_mrecv()
254 len = id->msg->len - 1; /* trigger before all received */ in sh7760_i2c_mrecv()
256 OUT32(id, I2CFCR, FCR_RFRST | FCR_TFRST); in sh7760_i2c_mrecv()
257 OUT32(id, I2CFCR, FCR_TFRST | ((len & 0xF) << 4)); in sh7760_i2c_mrecv()
259 OUT32(id, I2CMSR, 0); in sh7760_i2c_mrecv()
260 OUT32(id, I2CMCR, MCR_MIE | MCR_ESG); in sh7760_i2c_mrecv()
261 OUT32(id, I2CMIER, MIE_MNRE | MIE_MALE | MIE_MSTE | MIE_MATE); in sh7760_i2c_mrecv()
262 OUT32(id, I2CFIER, FIER_RXIE); in sh7760_i2c_mrecv()
266 static void sh7760_i2c_msend(struct cami2c *id) in sh7760_i2c_msend() argument
270 id->flags |= IDF_SEND; in sh7760_i2c_msend()
273 OUT32(id, I2CSAR, 0xfe); in sh7760_i2c_msend()
274 OUT32(id, I2CMAR, (id->msg->addr << 1) | 0); in sh7760_i2c_msend()
277 if (id->msg->len >= FIFO_SIZE) in sh7760_i2c_msend()
282 OUT32(id, I2CFCR, FCR_RFRST | FCR_TFRST); in sh7760_i2c_msend()
283 OUT32(id, I2CFCR, FCR_RFRST | ((len & 3) << 2)); in sh7760_i2c_msend()
285 while (id->msg->len && IN32(id, I2CTFDR) < FIFO_SIZE) { in sh7760_i2c_msend()
286 OUT32(id, I2CRXTX, *(id->msg->buf)); in sh7760_i2c_msend()
287 (id->msg->len)--; in sh7760_i2c_msend()
288 (id->msg->buf)++; in sh7760_i2c_msend()
291 OUT32(id, I2CMSR, 0); in sh7760_i2c_msend()
292 OUT32(id, I2CMCR, MCR_MIE | MCR_ESG); in sh7760_i2c_msend()
293 OUT32(id, I2CFSR, 0); in sh7760_i2c_msend()
294 OUT32(id, I2CMIER, MIE_MNRE | MIE_MALE | MIE_MSTE | MIE_MATE); in sh7760_i2c_msend()
295 OUT32(id, I2CFIER, FIER_TEIE | (id->msg->len ? FIER_TXIE : 0)); in sh7760_i2c_msend()
298 static inline int sh7760_i2c_busy_check(struct cami2c *id) in sh7760_i2c_busy_check() argument
300 return (IN32(id, I2CMCR) & MCR_FSDA); in sh7760_i2c_busy_check()
307 struct cami2c *id = adap->algo_data; in sh7760_i2c_master_xfer() local
310 if (sh7760_i2c_busy_check(id)) { in sh7760_i2c_master_xfer()
319 id->flags = ((i == (num-1)) ? IDF_STOP : 0); in sh7760_i2c_master_xfer()
320 id->status = 0; in sh7760_i2c_master_xfer()
321 id->msg = msgs; in sh7760_i2c_master_xfer()
322 init_completion(&id->xfer_done); in sh7760_i2c_master_xfer()
325 sh7760_i2c_mrecv(id); in sh7760_i2c_master_xfer()
327 sh7760_i2c_msend(id); in sh7760_i2c_master_xfer()
329 wait_for_completion(&id->xfer_done); in sh7760_i2c_master_xfer()
331 if (id->status == 0) { in sh7760_i2c_master_xfer()
336 if (id->status & IDS_NACK) { in sh7760_i2c_master_xfer()
343 if (id->status & IDS_ARBLOST) { in sh7760_i2c_master_xfer()
356 id->msg = NULL; in sh7760_i2c_master_xfer()
357 id->flags = 0; in sh7760_i2c_master_xfer()
358 id->status = 0; in sh7760_i2c_master_xfer()
360 OUT32(id, I2CMCR, 0); in sh7760_i2c_master_xfer()
361 OUT32(id, I2CMSR, 0); in sh7760_i2c_master_xfer()
362 OUT32(id, I2CMIER, 0); in sh7760_i2c_master_xfer()
363 OUT32(id, I2CFIER, 0); in sh7760_i2c_master_xfer()
369 OUT32(id, I2CSCR, 0); in sh7760_i2c_master_xfer()
370 OUT32(id, I2CSAR, 0); in sh7760_i2c_master_xfer()
371 OUT32(id, I2CSSR, 0); in sh7760_i2c_master_xfer()
436 struct cami2c *id; in sh7760_i2c_probe() local
446 id = kzalloc(sizeof(*id), GFP_KERNEL); in sh7760_i2c_probe()
447 if (!id) { in sh7760_i2c_probe()
459 id->ioarea = request_mem_region(res->start, REGSIZE, pdev->name); in sh7760_i2c_probe()
460 if (!id->ioarea) { in sh7760_i2c_probe()
466 id->iobase = ioremap(res->start, REGSIZE); in sh7760_i2c_probe()
467 if (!id->iobase) { in sh7760_i2c_probe()
476 id->irq = ret; in sh7760_i2c_probe()
478 id->adap.nr = pdev->id; in sh7760_i2c_probe()
479 id->adap.algo = &sh7760_i2c_algo; in sh7760_i2c_probe()
480 id->adap.class = I2C_CLASS_HWMON | I2C_CLASS_SPD; in sh7760_i2c_probe()
481 id->adap.retries = 3; in sh7760_i2c_probe()
482 id->adap.algo_data = id; in sh7760_i2c_probe()
483 id->adap.dev.parent = &pdev->dev; in sh7760_i2c_probe()
484 snprintf(id->adap.name, sizeof(id->adap.name), in sh7760_i2c_probe()
487 OUT32(id, I2CMCR, 0); in sh7760_i2c_probe()
488 OUT32(id, I2CMSR, 0); in sh7760_i2c_probe()
489 OUT32(id, I2CMIER, 0); in sh7760_i2c_probe()
490 OUT32(id, I2CMAR, 0); in sh7760_i2c_probe()
491 OUT32(id, I2CSIER, 0); in sh7760_i2c_probe()
492 OUT32(id, I2CSAR, 0); in sh7760_i2c_probe()
493 OUT32(id, I2CSCR, 0); in sh7760_i2c_probe()
494 OUT32(id, I2CSSR, 0); in sh7760_i2c_probe()
495 OUT32(id, I2CFIER, 0); in sh7760_i2c_probe()
496 OUT32(id, I2CFCR, FCR_RFRST | FCR_TFRST); in sh7760_i2c_probe()
497 OUT32(id, I2CFSR, 0); in sh7760_i2c_probe()
505 OUT32(id, I2CCCR, ret); in sh7760_i2c_probe()
507 if (request_irq(id->irq, sh7760_i2c_irq, 0, in sh7760_i2c_probe()
508 SH7760_I2C_DEVNAME, id)) { in sh7760_i2c_probe()
509 dev_err(&pdev->dev, "cannot get irq %d\n", id->irq); in sh7760_i2c_probe()
514 ret = i2c_add_numbered_adapter(&id->adap); in sh7760_i2c_probe()
518 platform_set_drvdata(pdev, id); in sh7760_i2c_probe()
521 pd->speed_khz, res->start, id->irq); in sh7760_i2c_probe()
526 free_irq(id->irq, id); in sh7760_i2c_probe()
528 iounmap(id->iobase); in sh7760_i2c_probe()
530 release_resource(id->ioarea); in sh7760_i2c_probe()
531 kfree(id->ioarea); in sh7760_i2c_probe()
533 kfree(id); in sh7760_i2c_probe()
540 struct cami2c *id = platform_get_drvdata(pdev); in sh7760_i2c_remove() local
542 i2c_del_adapter(&id->adap); in sh7760_i2c_remove()
543 free_irq(id->irq, id); in sh7760_i2c_remove()
544 iounmap(id->iobase); in sh7760_i2c_remove()
545 release_resource(id->ioarea); in sh7760_i2c_remove()
546 kfree(id->ioarea); in sh7760_i2c_remove()
547 kfree(id); in sh7760_i2c_remove()