lpi2c_imx 117 drivers/i2c/busses/i2c-imx-lpi2c.c static void lpi2c_imx_intctrl(struct lpi2c_imx_struct *lpi2c_imx, lpi2c_imx 120 drivers/i2c/busses/i2c-imx-lpi2c.c writel(enable, lpi2c_imx->base + LPI2C_MIER); lpi2c_imx 123 drivers/i2c/busses/i2c-imx-lpi2c.c static int lpi2c_imx_bus_busy(struct lpi2c_imx_struct *lpi2c_imx) lpi2c_imx 129 drivers/i2c/busses/i2c-imx-lpi2c.c temp = readl(lpi2c_imx->base + LPI2C_MSR); lpi2c_imx 133 drivers/i2c/busses/i2c-imx-lpi2c.c writel(temp, lpi2c_imx->base + LPI2C_MSR); lpi2c_imx 141 drivers/i2c/busses/i2c-imx-lpi2c.c dev_dbg(&lpi2c_imx->adapter.dev, "bus not work\n"); lpi2c_imx 150 drivers/i2c/busses/i2c-imx-lpi2c.c static void lpi2c_imx_set_mode(struct lpi2c_imx_struct *lpi2c_imx) lpi2c_imx 152 drivers/i2c/busses/i2c-imx-lpi2c.c unsigned int bitrate = lpi2c_imx->bitrate; lpi2c_imx 166 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx->mode = mode; lpi2c_imx 169 drivers/i2c/busses/i2c-imx-lpi2c.c static int lpi2c_imx_start(struct lpi2c_imx_struct *lpi2c_imx, lpi2c_imx 174 drivers/i2c/busses/i2c-imx-lpi2c.c temp = readl(lpi2c_imx->base + LPI2C_MCR); lpi2c_imx 176 drivers/i2c/busses/i2c-imx-lpi2c.c writel(temp, lpi2c_imx->base + LPI2C_MCR); lpi2c_imx 177 drivers/i2c/busses/i2c-imx-lpi2c.c writel(0x7f00, lpi2c_imx->base + LPI2C_MSR); lpi2c_imx 180 drivers/i2c/busses/i2c-imx-lpi2c.c writel(temp, lpi2c_imx->base + LPI2C_MTDR); lpi2c_imx 182 drivers/i2c/busses/i2c-imx-lpi2c.c return lpi2c_imx_bus_busy(lpi2c_imx); lpi2c_imx 185 drivers/i2c/busses/i2c-imx-lpi2c.c static void lpi2c_imx_stop(struct lpi2c_imx_struct *lpi2c_imx) lpi2c_imx 190 drivers/i2c/busses/i2c-imx-lpi2c.c writel(GEN_STOP << 8, lpi2c_imx->base + LPI2C_MTDR); lpi2c_imx 193 drivers/i2c/busses/i2c-imx-lpi2c.c temp = readl(lpi2c_imx->base + LPI2C_MSR); lpi2c_imx 198 drivers/i2c/busses/i2c-imx-lpi2c.c dev_dbg(&lpi2c_imx->adapter.dev, "stop timeout\n"); lpi2c_imx 207 drivers/i2c/busses/i2c-imx-lpi2c.c static int lpi2c_imx_config(struct lpi2c_imx_struct *lpi2c_imx) lpi2c_imx 214 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx_set_mode(lpi2c_imx); lpi2c_imx 216 drivers/i2c/busses/i2c-imx-lpi2c.c clk_rate = clk_get_rate(lpi2c_imx->clk); lpi2c_imx 217 drivers/i2c/busses/i2c-imx-lpi2c.c if (lpi2c_imx->mode == HS || lpi2c_imx->mode == ULTRA_FAST) lpi2c_imx 223 drivers/i2c/busses/i2c-imx-lpi2c.c clk_cycle = clk_rate / ((1 << prescale) * lpi2c_imx->bitrate) lpi2c_imx 235 drivers/i2c/busses/i2c-imx-lpi2c.c if (lpi2c_imx->mode == ULTRA_FAST) lpi2c_imx 241 drivers/i2c/busses/i2c-imx-lpi2c.c if (lpi2c_imx->mode == ULTRA_FAST) lpi2c_imx 244 drivers/i2c/busses/i2c-imx-lpi2c.c writel(temp, lpi2c_imx->base + LPI2C_MCFGR1); lpi2c_imx 248 drivers/i2c/busses/i2c-imx-lpi2c.c writel(temp, lpi2c_imx->base + LPI2C_MCFGR2); lpi2c_imx 255 drivers/i2c/busses/i2c-imx-lpi2c.c if (lpi2c_imx->mode == HS) lpi2c_imx 256 drivers/i2c/busses/i2c-imx-lpi2c.c writel(temp, lpi2c_imx->base + LPI2C_MCCR1); lpi2c_imx 258 drivers/i2c/busses/i2c-imx-lpi2c.c writel(temp, lpi2c_imx->base + LPI2C_MCCR0); lpi2c_imx 263 drivers/i2c/busses/i2c-imx-lpi2c.c static int lpi2c_imx_master_enable(struct lpi2c_imx_struct *lpi2c_imx) lpi2c_imx 268 drivers/i2c/busses/i2c-imx-lpi2c.c ret = pm_runtime_get_sync(lpi2c_imx->adapter.dev.parent); lpi2c_imx 273 drivers/i2c/busses/i2c-imx-lpi2c.c writel(temp, lpi2c_imx->base + LPI2C_MCR); lpi2c_imx 274 drivers/i2c/busses/i2c-imx-lpi2c.c writel(0, lpi2c_imx->base + LPI2C_MCR); lpi2c_imx 276 drivers/i2c/busses/i2c-imx-lpi2c.c ret = lpi2c_imx_config(lpi2c_imx); lpi2c_imx 280 drivers/i2c/busses/i2c-imx-lpi2c.c temp = readl(lpi2c_imx->base + LPI2C_MCR); lpi2c_imx 282 drivers/i2c/busses/i2c-imx-lpi2c.c writel(temp, lpi2c_imx->base + LPI2C_MCR); lpi2c_imx 287 drivers/i2c/busses/i2c-imx-lpi2c.c pm_runtime_mark_last_busy(lpi2c_imx->adapter.dev.parent); lpi2c_imx 288 drivers/i2c/busses/i2c-imx-lpi2c.c pm_runtime_put_autosuspend(lpi2c_imx->adapter.dev.parent); lpi2c_imx 293 drivers/i2c/busses/i2c-imx-lpi2c.c static int lpi2c_imx_master_disable(struct lpi2c_imx_struct *lpi2c_imx) lpi2c_imx 297 drivers/i2c/busses/i2c-imx-lpi2c.c temp = readl(lpi2c_imx->base + LPI2C_MCR); lpi2c_imx 299 drivers/i2c/busses/i2c-imx-lpi2c.c writel(temp, lpi2c_imx->base + LPI2C_MCR); lpi2c_imx 301 drivers/i2c/busses/i2c-imx-lpi2c.c pm_runtime_mark_last_busy(lpi2c_imx->adapter.dev.parent); lpi2c_imx 302 drivers/i2c/busses/i2c-imx-lpi2c.c pm_runtime_put_autosuspend(lpi2c_imx->adapter.dev.parent); lpi2c_imx 307 drivers/i2c/busses/i2c-imx-lpi2c.c static int lpi2c_imx_msg_complete(struct lpi2c_imx_struct *lpi2c_imx) lpi2c_imx 311 drivers/i2c/busses/i2c-imx-lpi2c.c timeout = wait_for_completion_timeout(&lpi2c_imx->complete, HZ); lpi2c_imx 316 drivers/i2c/busses/i2c-imx-lpi2c.c static int lpi2c_imx_txfifo_empty(struct lpi2c_imx_struct *lpi2c_imx) lpi2c_imx 322 drivers/i2c/busses/i2c-imx-lpi2c.c txcnt = readl(lpi2c_imx->base + LPI2C_MFSR) & 0xff; lpi2c_imx 324 drivers/i2c/busses/i2c-imx-lpi2c.c if (readl(lpi2c_imx->base + LPI2C_MSR) & MSR_NDF) { lpi2c_imx 325 drivers/i2c/busses/i2c-imx-lpi2c.c dev_dbg(&lpi2c_imx->adapter.dev, "NDF detected\n"); lpi2c_imx 330 drivers/i2c/busses/i2c-imx-lpi2c.c dev_dbg(&lpi2c_imx->adapter.dev, "txfifo empty timeout\n"); lpi2c_imx 340 drivers/i2c/busses/i2c-imx-lpi2c.c static void lpi2c_imx_set_tx_watermark(struct lpi2c_imx_struct *lpi2c_imx) lpi2c_imx 342 drivers/i2c/busses/i2c-imx-lpi2c.c writel(lpi2c_imx->txfifosize >> 1, lpi2c_imx->base + LPI2C_MFCR); lpi2c_imx 345 drivers/i2c/busses/i2c-imx-lpi2c.c static void lpi2c_imx_set_rx_watermark(struct lpi2c_imx_struct *lpi2c_imx) lpi2c_imx 349 drivers/i2c/busses/i2c-imx-lpi2c.c remaining = lpi2c_imx->msglen - lpi2c_imx->delivered; lpi2c_imx 351 drivers/i2c/busses/i2c-imx-lpi2c.c if (remaining > (lpi2c_imx->rxfifosize >> 1)) lpi2c_imx 352 drivers/i2c/busses/i2c-imx-lpi2c.c temp = lpi2c_imx->rxfifosize >> 1; lpi2c_imx 356 drivers/i2c/busses/i2c-imx-lpi2c.c writel(temp << 16, lpi2c_imx->base + LPI2C_MFCR); lpi2c_imx 359 drivers/i2c/busses/i2c-imx-lpi2c.c static void lpi2c_imx_write_txfifo(struct lpi2c_imx_struct *lpi2c_imx) lpi2c_imx 363 drivers/i2c/busses/i2c-imx-lpi2c.c txcnt = readl(lpi2c_imx->base + LPI2C_MFSR) & 0xff; lpi2c_imx 365 drivers/i2c/busses/i2c-imx-lpi2c.c while (txcnt < lpi2c_imx->txfifosize) { lpi2c_imx 366 drivers/i2c/busses/i2c-imx-lpi2c.c if (lpi2c_imx->delivered == lpi2c_imx->msglen) lpi2c_imx 369 drivers/i2c/busses/i2c-imx-lpi2c.c data = lpi2c_imx->tx_buf[lpi2c_imx->delivered++]; lpi2c_imx 370 drivers/i2c/busses/i2c-imx-lpi2c.c writel(data, lpi2c_imx->base + LPI2C_MTDR); lpi2c_imx 374 drivers/i2c/busses/i2c-imx-lpi2c.c if (lpi2c_imx->delivered < lpi2c_imx->msglen) lpi2c_imx 375 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx_intctrl(lpi2c_imx, MIER_TDIE | MIER_NDIE); lpi2c_imx 377 drivers/i2c/busses/i2c-imx-lpi2c.c complete(&lpi2c_imx->complete); lpi2c_imx 380 drivers/i2c/busses/i2c-imx-lpi2c.c static void lpi2c_imx_read_rxfifo(struct lpi2c_imx_struct *lpi2c_imx) lpi2c_imx 386 drivers/i2c/busses/i2c-imx-lpi2c.c data = readl(lpi2c_imx->base + LPI2C_MRDR); lpi2c_imx 390 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx->rx_buf[lpi2c_imx->delivered++] = data & 0xff; lpi2c_imx 397 drivers/i2c/busses/i2c-imx-lpi2c.c if (lpi2c_imx->block_data) { lpi2c_imx 398 drivers/i2c/busses/i2c-imx-lpi2c.c blocklen = lpi2c_imx->rx_buf[0]; lpi2c_imx 399 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx->msglen += blocklen; lpi2c_imx 402 drivers/i2c/busses/i2c-imx-lpi2c.c remaining = lpi2c_imx->msglen - lpi2c_imx->delivered; lpi2c_imx 405 drivers/i2c/busses/i2c-imx-lpi2c.c complete(&lpi2c_imx->complete); lpi2c_imx 410 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx_set_rx_watermark(lpi2c_imx); lpi2c_imx 413 drivers/i2c/busses/i2c-imx-lpi2c.c if (lpi2c_imx->block_data) { lpi2c_imx 414 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx->block_data = 0; lpi2c_imx 417 drivers/i2c/busses/i2c-imx-lpi2c.c writel(temp, lpi2c_imx->base + LPI2C_MTDR); lpi2c_imx 418 drivers/i2c/busses/i2c-imx-lpi2c.c } else if (!(lpi2c_imx->delivered & 0xff)) { lpi2c_imx 421 drivers/i2c/busses/i2c-imx-lpi2c.c writel(temp, lpi2c_imx->base + LPI2C_MTDR); lpi2c_imx 424 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx_intctrl(lpi2c_imx, MIER_RDIE); lpi2c_imx 427 drivers/i2c/busses/i2c-imx-lpi2c.c static void lpi2c_imx_write(struct lpi2c_imx_struct *lpi2c_imx, lpi2c_imx 430 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx->tx_buf = msgs->buf; lpi2c_imx 431 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx_set_tx_watermark(lpi2c_imx); lpi2c_imx 432 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx_write_txfifo(lpi2c_imx); lpi2c_imx 435 drivers/i2c/busses/i2c-imx-lpi2c.c static void lpi2c_imx_read(struct lpi2c_imx_struct *lpi2c_imx, lpi2c_imx 440 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx->rx_buf = msgs->buf; lpi2c_imx 441 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx->block_data = msgs->flags & I2C_M_RECV_LEN; lpi2c_imx 443 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx_set_rx_watermark(lpi2c_imx); lpi2c_imx 446 drivers/i2c/busses/i2c-imx-lpi2c.c writel(temp, lpi2c_imx->base + LPI2C_MTDR); lpi2c_imx 448 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx_intctrl(lpi2c_imx, MIER_RDIE | MIER_NDIE); lpi2c_imx 454 drivers/i2c/busses/i2c-imx-lpi2c.c struct lpi2c_imx_struct *lpi2c_imx = i2c_get_adapdata(adapter); lpi2c_imx 458 drivers/i2c/busses/i2c-imx-lpi2c.c result = lpi2c_imx_master_enable(lpi2c_imx); lpi2c_imx 463 drivers/i2c/busses/i2c-imx-lpi2c.c result = lpi2c_imx_start(lpi2c_imx, &msgs[i]); lpi2c_imx 471 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx->delivered = 0; lpi2c_imx 472 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx->msglen = msgs[i].len; lpi2c_imx 473 drivers/i2c/busses/i2c-imx-lpi2c.c init_completion(&lpi2c_imx->complete); lpi2c_imx 476 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx_read(lpi2c_imx, &msgs[i]); lpi2c_imx 478 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx_write(lpi2c_imx, &msgs[i]); lpi2c_imx 480 drivers/i2c/busses/i2c-imx-lpi2c.c result = lpi2c_imx_msg_complete(lpi2c_imx); lpi2c_imx 485 drivers/i2c/busses/i2c-imx-lpi2c.c result = lpi2c_imx_txfifo_empty(lpi2c_imx); lpi2c_imx 492 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx_stop(lpi2c_imx); lpi2c_imx 494 drivers/i2c/busses/i2c-imx-lpi2c.c temp = readl(lpi2c_imx->base + LPI2C_MSR); lpi2c_imx 499 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx_master_disable(lpi2c_imx); lpi2c_imx 501 drivers/i2c/busses/i2c-imx-lpi2c.c dev_dbg(&lpi2c_imx->adapter.dev, "<%s> exit with: %s: %d\n", __func__, lpi2c_imx 510 drivers/i2c/busses/i2c-imx-lpi2c.c struct lpi2c_imx_struct *lpi2c_imx = dev_id; lpi2c_imx 513 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx_intctrl(lpi2c_imx, 0); lpi2c_imx 514 drivers/i2c/busses/i2c-imx-lpi2c.c temp = readl(lpi2c_imx->base + LPI2C_MSR); lpi2c_imx 517 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx_read_rxfifo(lpi2c_imx); lpi2c_imx 520 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx_write_txfifo(lpi2c_imx); lpi2c_imx 523 drivers/i2c/busses/i2c-imx-lpi2c.c complete(&lpi2c_imx->complete); lpi2c_imx 547 drivers/i2c/busses/i2c-imx-lpi2c.c struct lpi2c_imx_struct *lpi2c_imx; lpi2c_imx 551 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx = devm_kzalloc(&pdev->dev, sizeof(*lpi2c_imx), GFP_KERNEL); lpi2c_imx 552 drivers/i2c/busses/i2c-imx-lpi2c.c if (!lpi2c_imx) lpi2c_imx 555 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx->base = devm_platform_ioremap_resource(pdev, 0); lpi2c_imx 556 drivers/i2c/busses/i2c-imx-lpi2c.c if (IS_ERR(lpi2c_imx->base)) lpi2c_imx 557 drivers/i2c/busses/i2c-imx-lpi2c.c return PTR_ERR(lpi2c_imx->base); lpi2c_imx 565 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx->adapter.owner = THIS_MODULE; lpi2c_imx 566 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx->adapter.algo = &lpi2c_imx_algo; lpi2c_imx 567 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx->adapter.dev.parent = &pdev->dev; lpi2c_imx 568 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx->adapter.dev.of_node = pdev->dev.of_node; lpi2c_imx 569 drivers/i2c/busses/i2c-imx-lpi2c.c strlcpy(lpi2c_imx->adapter.name, pdev->name, lpi2c_imx 570 drivers/i2c/busses/i2c-imx-lpi2c.c sizeof(lpi2c_imx->adapter.name)); lpi2c_imx 572 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx->clk = devm_clk_get(&pdev->dev, NULL); lpi2c_imx 573 drivers/i2c/busses/i2c-imx-lpi2c.c if (IS_ERR(lpi2c_imx->clk)) { lpi2c_imx 575 drivers/i2c/busses/i2c-imx-lpi2c.c return PTR_ERR(lpi2c_imx->clk); lpi2c_imx 579 drivers/i2c/busses/i2c-imx-lpi2c.c "clock-frequency", &lpi2c_imx->bitrate); lpi2c_imx 581 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx->bitrate = LPI2C_DEFAULT_RATE; lpi2c_imx 584 drivers/i2c/busses/i2c-imx-lpi2c.c pdev->name, lpi2c_imx); lpi2c_imx 590 drivers/i2c/busses/i2c-imx-lpi2c.c i2c_set_adapdata(&lpi2c_imx->adapter, lpi2c_imx); lpi2c_imx 591 drivers/i2c/busses/i2c-imx-lpi2c.c platform_set_drvdata(pdev, lpi2c_imx); lpi2c_imx 593 drivers/i2c/busses/i2c-imx-lpi2c.c ret = clk_prepare_enable(lpi2c_imx->clk); lpi2c_imx 605 drivers/i2c/busses/i2c-imx-lpi2c.c temp = readl(lpi2c_imx->base + LPI2C_PARAM); lpi2c_imx 606 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx->txfifosize = 1 << (temp & 0x0f); lpi2c_imx 607 drivers/i2c/busses/i2c-imx-lpi2c.c lpi2c_imx->rxfifosize = 1 << ((temp >> 8) & 0x0f); lpi2c_imx 609 drivers/i2c/busses/i2c-imx-lpi2c.c ret = i2c_add_adapter(&lpi2c_imx->adapter); lpi2c_imx 616 drivers/i2c/busses/i2c-imx-lpi2c.c dev_info(&lpi2c_imx->adapter.dev, "LPI2C adapter registered\n"); lpi2c_imx 630 drivers/i2c/busses/i2c-imx-lpi2c.c struct lpi2c_imx_struct *lpi2c_imx = platform_get_drvdata(pdev); lpi2c_imx 632 drivers/i2c/busses/i2c-imx-lpi2c.c i2c_del_adapter(&lpi2c_imx->adapter); lpi2c_imx 642 drivers/i2c/busses/i2c-imx-lpi2c.c struct lpi2c_imx_struct *lpi2c_imx = dev_get_drvdata(dev); lpi2c_imx 644 drivers/i2c/busses/i2c-imx-lpi2c.c clk_disable_unprepare(lpi2c_imx->clk); lpi2c_imx 652 drivers/i2c/busses/i2c-imx-lpi2c.c struct lpi2c_imx_struct *lpi2c_imx = dev_get_drvdata(dev); lpi2c_imx 656 drivers/i2c/busses/i2c-imx-lpi2c.c ret = clk_prepare_enable(lpi2c_imx->clk);