Searched refs:alg_data (Results 1 - 1 of 1) sorted by relevance

/linux-4.1.27/drivers/i2c/busses/
H A Di2c-pnx.c101 static inline void i2c_pnx_arm_timer(struct i2c_pnx_algo_data *alg_data) i2c_pnx_arm_timer() argument
103 struct timer_list *timer = &alg_data->mif.timer; i2c_pnx_arm_timer()
104 unsigned long expires = msecs_to_jiffies(alg_data->timeout); i2c_pnx_arm_timer()
111 dev_dbg(&alg_data->adapter.dev, "Timer armed at %lu plus %lu jiffies.\n", i2c_pnx_arm_timer()
115 timer->data = (unsigned long)alg_data; i2c_pnx_arm_timer()
128 struct i2c_pnx_algo_data *alg_data) i2c_pnx_start()
130 dev_dbg(&alg_data->adapter.dev, "%s(): addr 0x%x mode %d\n", __func__, i2c_pnx_start()
131 slave_addr, alg_data->mif.mode); i2c_pnx_start()
135 dev_err(&alg_data->adapter.dev, i2c_pnx_start()
137 alg_data->adapter.name, slave_addr); i2c_pnx_start()
142 if (wait_timeout(alg_data)) { i2c_pnx_start()
144 dev_err(&alg_data->adapter.dev, i2c_pnx_start()
146 alg_data->adapter.name, slave_addr, i2c_pnx_start()
147 ioread32(I2C_REG_CTL(alg_data)), i2c_pnx_start()
148 ioread32(I2C_REG_STS(alg_data))); i2c_pnx_start()
150 } else if (ioread32(I2C_REG_STS(alg_data)) & mstatus_afi) { i2c_pnx_start()
152 dev_err(&alg_data->adapter.dev, i2c_pnx_start()
154 alg_data->adapter.name, slave_addr); i2c_pnx_start()
162 iowrite32(ioread32(I2C_REG_STS(alg_data)) | mstatus_tdi | mstatus_afi, i2c_pnx_start()
163 I2C_REG_STS(alg_data)); i2c_pnx_start()
165 dev_dbg(&alg_data->adapter.dev, "%s(): sending %#x\n", __func__, i2c_pnx_start()
166 (slave_addr << 1) | start_bit | alg_data->mif.mode); i2c_pnx_start()
169 iowrite32((slave_addr << 1) | start_bit | alg_data->mif.mode, i2c_pnx_start()
170 I2C_REG_TX(alg_data)); i2c_pnx_start()
172 dev_dbg(&alg_data->adapter.dev, "%s(): exit\n", __func__); i2c_pnx_start()
183 static void i2c_pnx_stop(struct i2c_pnx_algo_data *alg_data) i2c_pnx_stop() argument
188 dev_dbg(&alg_data->adapter.dev, "%s(): entering: stat = %04x.\n", i2c_pnx_stop()
189 __func__, ioread32(I2C_REG_STS(alg_data))); i2c_pnx_stop()
192 iowrite32(0xff | stop_bit, I2C_REG_TX(alg_data)); i2c_pnx_stop()
196 (ioread32(I2C_REG_STS(alg_data)) & mstatus_active)) { i2c_pnx_stop()
202 dev_dbg(&alg_data->adapter.dev, "%s(): exiting: stat = %04x.\n", i2c_pnx_stop()
203 __func__, ioread32(I2C_REG_STS(alg_data))); i2c_pnx_stop()
212 static int i2c_pnx_master_xmit(struct i2c_pnx_algo_data *alg_data) i2c_pnx_master_xmit() argument
216 dev_dbg(&alg_data->adapter.dev, "%s(): entering: stat = %04x.\n", i2c_pnx_master_xmit()
217 __func__, ioread32(I2C_REG_STS(alg_data))); i2c_pnx_master_xmit()
219 if (alg_data->mif.len > 0) { i2c_pnx_master_xmit()
221 val = *alg_data->mif.buf++; i2c_pnx_master_xmit()
223 if (alg_data->mif.len == 1) i2c_pnx_master_xmit()
226 alg_data->mif.len--; i2c_pnx_master_xmit()
227 iowrite32(val, I2C_REG_TX(alg_data)); i2c_pnx_master_xmit()
229 dev_dbg(&alg_data->adapter.dev, "%s(): xmit %#x [%d]\n", i2c_pnx_master_xmit()
230 __func__, val, alg_data->mif.len + 1); i2c_pnx_master_xmit()
232 if (alg_data->mif.len == 0) { i2c_pnx_master_xmit()
233 if (alg_data->last) { i2c_pnx_master_xmit()
235 if (wait_timeout(alg_data)) i2c_pnx_master_xmit()
236 dev_err(&alg_data->adapter.dev, i2c_pnx_master_xmit()
240 iowrite32(ioread32(I2C_REG_CTL(alg_data)) & i2c_pnx_master_xmit()
242 I2C_REG_CTL(alg_data)); i2c_pnx_master_xmit()
244 del_timer_sync(&alg_data->mif.timer); i2c_pnx_master_xmit()
246 dev_dbg(&alg_data->adapter.dev, i2c_pnx_master_xmit()
250 complete(&alg_data->mif.complete); i2c_pnx_master_xmit()
252 } else if (alg_data->mif.len == 0) { i2c_pnx_master_xmit()
254 i2c_pnx_stop(alg_data); i2c_pnx_master_xmit()
257 iowrite32(ioread32(I2C_REG_CTL(alg_data)) & i2c_pnx_master_xmit()
259 I2C_REG_CTL(alg_data)); i2c_pnx_master_xmit()
262 del_timer_sync(&alg_data->mif.timer); i2c_pnx_master_xmit()
263 dev_dbg(&alg_data->adapter.dev, i2c_pnx_master_xmit()
267 complete(&alg_data->mif.complete); i2c_pnx_master_xmit()
270 dev_dbg(&alg_data->adapter.dev, "%s(): exiting: stat = %04x.\n", i2c_pnx_master_xmit()
271 __func__, ioread32(I2C_REG_STS(alg_data))); i2c_pnx_master_xmit()
282 static int i2c_pnx_master_rcv(struct i2c_pnx_algo_data *alg_data) i2c_pnx_master_rcv() argument
287 dev_dbg(&alg_data->adapter.dev, "%s(): entering: stat = %04x.\n", i2c_pnx_master_rcv()
288 __func__, ioread32(I2C_REG_STS(alg_data))); i2c_pnx_master_rcv()
293 if (ioread32(I2C_REG_STS(alg_data)) & mstatus_rfe) { i2c_pnx_master_rcv()
298 if (alg_data->mif.order) { i2c_pnx_master_rcv()
299 dev_dbg(&alg_data->adapter.dev, i2c_pnx_master_rcv()
303 if (alg_data->mif.order == 1) { i2c_pnx_master_rcv()
311 ctl = ioread32(I2C_REG_CTL(alg_data)); i2c_pnx_master_rcv()
314 iowrite32(ctl, I2C_REG_CTL(alg_data)); i2c_pnx_master_rcv()
322 iowrite32(val, I2C_REG_TX(alg_data)); i2c_pnx_master_rcv()
323 alg_data->mif.order--; i2c_pnx_master_rcv()
329 if (alg_data->mif.len > 0) { i2c_pnx_master_rcv()
330 val = ioread32(I2C_REG_RX(alg_data)); i2c_pnx_master_rcv()
331 *alg_data->mif.buf++ = (u8) (val & 0xff); i2c_pnx_master_rcv()
332 dev_dbg(&alg_data->adapter.dev, "%s(): rcv 0x%x [%d]\n", i2c_pnx_master_rcv()
333 __func__, val, alg_data->mif.len); i2c_pnx_master_rcv()
335 alg_data->mif.len--; i2c_pnx_master_rcv()
336 if (alg_data->mif.len == 0) { i2c_pnx_master_rcv()
337 if (alg_data->last) i2c_pnx_master_rcv()
339 if (wait_timeout(alg_data)) i2c_pnx_master_rcv()
340 dev_err(&alg_data->adapter.dev, i2c_pnx_master_rcv()
344 ctl = ioread32(I2C_REG_CTL(alg_data)); i2c_pnx_master_rcv()
347 iowrite32(ctl, I2C_REG_CTL(alg_data)); i2c_pnx_master_rcv()
350 del_timer_sync(&alg_data->mif.timer); i2c_pnx_master_rcv()
351 complete(&alg_data->mif.complete); i2c_pnx_master_rcv()
355 dev_dbg(&alg_data->adapter.dev, "%s(): exiting: stat = %04x.\n", i2c_pnx_master_rcv()
356 __func__, ioread32(I2C_REG_STS(alg_data))); i2c_pnx_master_rcv()
363 struct i2c_pnx_algo_data *alg_data = dev_id; i2c_pnx_interrupt() local
366 dev_dbg(&alg_data->adapter.dev, i2c_pnx_interrupt()
369 ioread32(I2C_REG_STS(alg_data)), i2c_pnx_interrupt()
370 ioread32(I2C_REG_CTL(alg_data)), i2c_pnx_interrupt()
371 alg_data->mif.mode); i2c_pnx_interrupt()
372 stat = ioread32(I2C_REG_STS(alg_data)); i2c_pnx_interrupt()
377 alg_data->mif.ret = -EIO; i2c_pnx_interrupt()
380 ctl = ioread32(I2C_REG_CTL(alg_data)); i2c_pnx_interrupt()
383 iowrite32(ctl, I2C_REG_CTL(alg_data)); i2c_pnx_interrupt()
386 del_timer_sync(&alg_data->mif.timer); i2c_pnx_interrupt()
387 complete(&alg_data->mif.complete); i2c_pnx_interrupt()
390 dev_dbg(&alg_data->adapter.dev, i2c_pnx_interrupt()
393 i2c_pnx_stop(alg_data); i2c_pnx_interrupt()
396 ctl = ioread32(I2C_REG_CTL(alg_data)); i2c_pnx_interrupt()
399 iowrite32(ctl, I2C_REG_CTL(alg_data)); i2c_pnx_interrupt()
402 alg_data->mif.ret = -EIO; i2c_pnx_interrupt()
405 del_timer_sync(&alg_data->mif.timer); i2c_pnx_interrupt()
406 complete(&alg_data->mif.complete); i2c_pnx_interrupt()
418 if (alg_data->mif.mode == I2C_SMBUS_WRITE) { i2c_pnx_interrupt()
419 i2c_pnx_master_xmit(alg_data); i2c_pnx_interrupt()
420 } else if (alg_data->mif.mode == I2C_SMBUS_READ) { i2c_pnx_interrupt()
421 i2c_pnx_master_rcv(alg_data); i2c_pnx_interrupt()
427 stat = ioread32(I2C_REG_STS(alg_data)); i2c_pnx_interrupt()
428 iowrite32(stat | mstatus_tdi | mstatus_afi, I2C_REG_STS(alg_data)); i2c_pnx_interrupt()
430 dev_dbg(&alg_data->adapter.dev, i2c_pnx_interrupt()
432 __func__, ioread32(I2C_REG_STS(alg_data)), i2c_pnx_interrupt()
433 ioread32(I2C_REG_CTL(alg_data))); i2c_pnx_interrupt()
440 struct i2c_pnx_algo_data *alg_data = (struct i2c_pnx_algo_data *)data; i2c_pnx_timeout() local
443 dev_err(&alg_data->adapter.dev, i2c_pnx_timeout()
445 ioread32(I2C_REG_STS(alg_data)), i2c_pnx_timeout()
446 ioread32(I2C_REG_CTL(alg_data))); i2c_pnx_timeout()
449 ctl = ioread32(I2C_REG_CTL(alg_data)); i2c_pnx_timeout()
451 iowrite32(ctl, I2C_REG_CTL(alg_data)); i2c_pnx_timeout()
454 iowrite32(ctl, I2C_REG_CTL(alg_data)); i2c_pnx_timeout()
455 wait_reset(alg_data); i2c_pnx_timeout()
456 alg_data->mif.ret = -EIO; i2c_pnx_timeout()
457 complete(&alg_data->mif.complete); i2c_pnx_timeout()
460 static inline void bus_reset_if_active(struct i2c_pnx_algo_data *alg_data) bus_reset_if_active() argument
464 if ((stat = ioread32(I2C_REG_STS(alg_data))) & mstatus_active) { bus_reset_if_active()
465 dev_err(&alg_data->adapter.dev, bus_reset_if_active()
467 alg_data->adapter.name); bus_reset_if_active()
468 iowrite32(ioread32(I2C_REG_CTL(alg_data)) | mcntrl_reset, bus_reset_if_active()
469 I2C_REG_CTL(alg_data)); bus_reset_if_active()
470 wait_reset(alg_data); bus_reset_if_active()
475 iowrite32(ioread32(I2C_REG_CTL(alg_data)) | mcntrl_reset, bus_reset_if_active()
476 I2C_REG_CTL(alg_data)); bus_reset_if_active()
477 wait_reset(alg_data); bus_reset_if_active()
479 iowrite32(ioread32(I2C_REG_CTL(alg_data)) | mcntrl_reset, bus_reset_if_active()
480 I2C_REG_CTL(alg_data)); bus_reset_if_active()
481 wait_reset(alg_data); bus_reset_if_active()
498 struct i2c_pnx_algo_data *alg_data = adap->algo_data; i2c_pnx_xfer() local
499 u32 stat = ioread32(I2C_REG_STS(alg_data)); i2c_pnx_xfer()
501 dev_dbg(&alg_data->adapter.dev, i2c_pnx_xfer()
503 __func__, num, ioread32(I2C_REG_STS(alg_data))); i2c_pnx_xfer()
505 bus_reset_if_active(alg_data); i2c_pnx_xfer()
515 dev_err(&alg_data->adapter.dev, i2c_pnx_xfer()
517 alg_data->adapter.name); i2c_pnx_xfer()
522 alg_data->mif.buf = pmsg->buf; i2c_pnx_xfer()
523 alg_data->mif.len = pmsg->len; i2c_pnx_xfer()
524 alg_data->mif.order = pmsg->len; i2c_pnx_xfer()
525 alg_data->mif.mode = (pmsg->flags & I2C_M_RD) ? i2c_pnx_xfer()
527 alg_data->mif.ret = 0; i2c_pnx_xfer()
528 alg_data->last = (i == num - 1); i2c_pnx_xfer()
530 dev_dbg(&alg_data->adapter.dev, "%s(): mode %d, %d bytes\n", i2c_pnx_xfer()
531 __func__, alg_data->mif.mode, alg_data->mif.len); i2c_pnx_xfer()
533 i2c_pnx_arm_timer(alg_data); i2c_pnx_xfer()
536 init_completion(&alg_data->mif.complete); i2c_pnx_xfer()
539 iowrite32(ioread32(I2C_REG_CTL(alg_data)) | mcntrl_afie | i2c_pnx_xfer()
541 I2C_REG_CTL(alg_data)); i2c_pnx_xfer()
544 rc = i2c_pnx_start(addr, alg_data); i2c_pnx_xfer()
549 wait_for_completion(&alg_data->mif.complete); i2c_pnx_xfer()
551 if (!(rc = alg_data->mif.ret)) i2c_pnx_xfer()
553 dev_dbg(&alg_data->adapter.dev, i2c_pnx_xfer()
558 if ((stat = ioread32(I2C_REG_STS(alg_data))) & mstatus_tdi) { i2c_pnx_xfer()
559 dev_dbg(&alg_data->adapter.dev, i2c_pnx_xfer()
561 alg_data->adapter.name); i2c_pnx_xfer()
562 iowrite32(stat, I2C_REG_STS(alg_data)); i2c_pnx_xfer()
564 if ((stat = ioread32(I2C_REG_STS(alg_data))) & mstatus_afi) { i2c_pnx_xfer()
565 dev_dbg(&alg_data->adapter.dev, i2c_pnx_xfer()
567 alg_data->adapter.name); i2c_pnx_xfer()
568 iowrite32(stat, I2C_REG_STS(alg_data)); i2c_pnx_xfer()
572 bus_reset_if_active(alg_data); i2c_pnx_xfer()
575 alg_data->mif.buf = NULL; i2c_pnx_xfer()
576 alg_data->mif.len = 0; i2c_pnx_xfer()
577 alg_data->mif.order = 0; i2c_pnx_xfer()
579 dev_dbg(&alg_data->adapter.dev, "%s(): exiting, stat = %x\n", i2c_pnx_xfer()
580 __func__, ioread32(I2C_REG_STS(alg_data))); i2c_pnx_xfer()
601 struct i2c_pnx_algo_data *alg_data = dev_get_drvdata(dev); i2c_pnx_controller_suspend() local
603 clk_disable(alg_data->clk); i2c_pnx_controller_suspend()
610 struct i2c_pnx_algo_data *alg_data = dev_get_drvdata(dev); i2c_pnx_controller_resume() local
612 return clk_enable(alg_data->clk); i2c_pnx_controller_resume()
626 struct i2c_pnx_algo_data *alg_data; i2c_pnx_probe() local
631 alg_data = devm_kzalloc(&pdev->dev, sizeof(*alg_data), GFP_KERNEL); i2c_pnx_probe()
632 if (!alg_data) i2c_pnx_probe()
635 platform_set_drvdata(pdev, alg_data); i2c_pnx_probe()
637 alg_data->adapter.dev.parent = &pdev->dev; i2c_pnx_probe()
638 alg_data->adapter.algo = &pnx_algorithm; i2c_pnx_probe()
639 alg_data->adapter.algo_data = alg_data; i2c_pnx_probe()
640 alg_data->adapter.nr = pdev->id; i2c_pnx_probe()
642 alg_data->timeout = I2C_PNX_TIMEOUT_DEFAULT; i2c_pnx_probe()
644 alg_data->adapter.dev.of_node = of_node_get(pdev->dev.of_node); i2c_pnx_probe()
654 * &alg_data->timeout); i2c_pnx_probe()
658 alg_data->clk = devm_clk_get(&pdev->dev, NULL); i2c_pnx_probe()
659 if (IS_ERR(alg_data->clk)) i2c_pnx_probe()
660 return PTR_ERR(alg_data->clk); i2c_pnx_probe()
662 init_timer(&alg_data->mif.timer); i2c_pnx_probe()
663 alg_data->mif.timer.function = i2c_pnx_timeout; i2c_pnx_probe()
664 alg_data->mif.timer.data = (unsigned long)alg_data; i2c_pnx_probe()
666 snprintf(alg_data->adapter.name, sizeof(alg_data->adapter.name), i2c_pnx_probe()
671 alg_data->ioaddr = devm_ioremap_resource(&pdev->dev, res); i2c_pnx_probe()
672 if (IS_ERR(alg_data->ioaddr)) i2c_pnx_probe()
673 return PTR_ERR(alg_data->ioaddr); i2c_pnx_probe()
675 ret = clk_enable(alg_data->clk); i2c_pnx_probe()
679 freq = clk_get_rate(alg_data->clk); i2c_pnx_probe()
695 iowrite32(tmp, I2C_REG_CKH(alg_data)); i2c_pnx_probe()
696 iowrite32(tmp, I2C_REG_CKL(alg_data)); i2c_pnx_probe()
698 iowrite32(mcntrl_reset, I2C_REG_CTL(alg_data)); i2c_pnx_probe()
699 if (wait_reset(alg_data)) { i2c_pnx_probe()
703 init_completion(&alg_data->mif.complete); i2c_pnx_probe()
705 alg_data->irq = platform_get_irq(pdev, 0); i2c_pnx_probe()
706 if (alg_data->irq < 0) { i2c_pnx_probe()
708 ret = alg_data->irq; i2c_pnx_probe()
711 ret = devm_request_irq(&pdev->dev, alg_data->irq, i2c_pnx_interrupt, i2c_pnx_probe()
712 0, pdev->name, alg_data); i2c_pnx_probe()
717 ret = i2c_add_numbered_adapter(&alg_data->adapter); i2c_pnx_probe()
724 alg_data->adapter.name, res->start, alg_data->irq); i2c_pnx_probe()
729 clk_disable(alg_data->clk); i2c_pnx_probe()
735 struct i2c_pnx_algo_data *alg_data = platform_get_drvdata(pdev); i2c_pnx_remove() local
737 i2c_del_adapter(&alg_data->adapter); i2c_pnx_remove()
738 clk_disable(alg_data->clk); i2c_pnx_remove()
127 i2c_pnx_start(unsigned char slave_addr, struct i2c_pnx_algo_data *alg_data) i2c_pnx_start() argument

Completed in 52 milliseconds