spi_imx 140 drivers/spi/spi-imx.c static void spi_imx_buf_rx_##type(struct spi_imx_data *spi_imx) \ spi_imx 142 drivers/spi/spi-imx.c unsigned int val = readl(spi_imx->base + MXC_CSPIRXDATA); \ spi_imx 144 drivers/spi/spi-imx.c if (spi_imx->rx_buf) { \ spi_imx 145 drivers/spi/spi-imx.c *(type *)spi_imx->rx_buf = val; \ spi_imx 146 drivers/spi/spi-imx.c spi_imx->rx_buf += sizeof(type); \ spi_imx 149 drivers/spi/spi-imx.c spi_imx->remainder -= sizeof(type); \ spi_imx 153 drivers/spi/spi-imx.c static void spi_imx_buf_tx_##type(struct spi_imx_data *spi_imx) \ spi_imx 157 drivers/spi/spi-imx.c if (spi_imx->tx_buf) { \ spi_imx 158 drivers/spi/spi-imx.c val = *(type *)spi_imx->tx_buf; \ spi_imx 159 drivers/spi/spi-imx.c spi_imx->tx_buf += sizeof(type); \ spi_imx 162 drivers/spi/spi-imx.c spi_imx->count -= sizeof(type); \ spi_imx 164 drivers/spi/spi-imx.c writel(val, spi_imx->base + MXC_CSPITXDATA); \ spi_imx 224 drivers/spi/spi-imx.c struct spi_imx_data *spi_imx = spi_master_get_devdata(master); spi_imx 232 drivers/spi/spi-imx.c if (spi_imx->slave_mode) spi_imx 235 drivers/spi/spi-imx.c if (transfer->len < spi_imx->devtype_data->fifo_size) spi_imx 238 drivers/spi/spi-imx.c spi_imx->dynamic_burst = 0; spi_imx 282 drivers/spi/spi-imx.c static void spi_imx_buf_rx_swap_u32(struct spi_imx_data *spi_imx) spi_imx 284 drivers/spi/spi-imx.c unsigned int val = readl(spi_imx->base + MXC_CSPIRXDATA); spi_imx 289 drivers/spi/spi-imx.c if (spi_imx->rx_buf) { spi_imx 291 drivers/spi/spi-imx.c bytes_per_word = spi_imx_bytes_per_word(spi_imx->bits_per_word); spi_imx 297 drivers/spi/spi-imx.c *(u32 *)spi_imx->rx_buf = val; spi_imx 298 drivers/spi/spi-imx.c spi_imx->rx_buf += sizeof(u32); spi_imx 301 drivers/spi/spi-imx.c spi_imx->remainder -= sizeof(u32); spi_imx 304 drivers/spi/spi-imx.c static void spi_imx_buf_rx_swap(struct spi_imx_data *spi_imx) spi_imx 309 drivers/spi/spi-imx.c unaligned = spi_imx->remainder % 4; spi_imx 312 drivers/spi/spi-imx.c spi_imx_buf_rx_swap_u32(spi_imx); spi_imx 316 drivers/spi/spi-imx.c if (spi_imx_bytes_per_word(spi_imx->bits_per_word) == 2) { spi_imx 317 drivers/spi/spi-imx.c spi_imx_buf_rx_u16(spi_imx); spi_imx 321 drivers/spi/spi-imx.c val = readl(spi_imx->base + MXC_CSPIRXDATA); spi_imx 324 drivers/spi/spi-imx.c if (spi_imx->rx_buf) { spi_imx 325 drivers/spi/spi-imx.c *(u8 *)spi_imx->rx_buf = (val >> (8 * unaligned)) & 0xff; spi_imx 326 drivers/spi/spi-imx.c spi_imx->rx_buf++; spi_imx 328 drivers/spi/spi-imx.c spi_imx->remainder--; spi_imx 332 drivers/spi/spi-imx.c static void spi_imx_buf_tx_swap_u32(struct spi_imx_data *spi_imx) spi_imx 339 drivers/spi/spi-imx.c if (spi_imx->tx_buf) { spi_imx 340 drivers/spi/spi-imx.c val = *(u32 *)spi_imx->tx_buf; spi_imx 341 drivers/spi/spi-imx.c spi_imx->tx_buf += sizeof(u32); spi_imx 344 drivers/spi/spi-imx.c spi_imx->count -= sizeof(u32); spi_imx 346 drivers/spi/spi-imx.c bytes_per_word = spi_imx_bytes_per_word(spi_imx->bits_per_word); spi_imx 353 drivers/spi/spi-imx.c writel(val, spi_imx->base + MXC_CSPITXDATA); spi_imx 356 drivers/spi/spi-imx.c static void spi_imx_buf_tx_swap(struct spi_imx_data *spi_imx) spi_imx 361 drivers/spi/spi-imx.c unaligned = spi_imx->count % 4; spi_imx 364 drivers/spi/spi-imx.c spi_imx_buf_tx_swap_u32(spi_imx); spi_imx 368 drivers/spi/spi-imx.c if (spi_imx_bytes_per_word(spi_imx->bits_per_word) == 2) { spi_imx 369 drivers/spi/spi-imx.c spi_imx_buf_tx_u16(spi_imx); spi_imx 374 drivers/spi/spi-imx.c if (spi_imx->tx_buf) { spi_imx 375 drivers/spi/spi-imx.c val |= *(u8 *)spi_imx->tx_buf << (8 * unaligned); spi_imx 376 drivers/spi/spi-imx.c spi_imx->tx_buf++; spi_imx 378 drivers/spi/spi-imx.c spi_imx->count--; spi_imx 381 drivers/spi/spi-imx.c writel(val, spi_imx->base + MXC_CSPITXDATA); spi_imx 384 drivers/spi/spi-imx.c static void mx53_ecspi_rx_slave(struct spi_imx_data *spi_imx) spi_imx 386 drivers/spi/spi-imx.c u32 val = be32_to_cpu(readl(spi_imx->base + MXC_CSPIRXDATA)); spi_imx 388 drivers/spi/spi-imx.c if (spi_imx->rx_buf) { spi_imx 389 drivers/spi/spi-imx.c int n_bytes = spi_imx->slave_burst % sizeof(val); spi_imx 394 drivers/spi/spi-imx.c memcpy(spi_imx->rx_buf, spi_imx 397 drivers/spi/spi-imx.c spi_imx->rx_buf += n_bytes; spi_imx 398 drivers/spi/spi-imx.c spi_imx->slave_burst -= n_bytes; spi_imx 401 drivers/spi/spi-imx.c spi_imx->remainder -= sizeof(u32); spi_imx 404 drivers/spi/spi-imx.c static void mx53_ecspi_tx_slave(struct spi_imx_data *spi_imx) spi_imx 407 drivers/spi/spi-imx.c int n_bytes = spi_imx->count % sizeof(val); spi_imx 412 drivers/spi/spi-imx.c if (spi_imx->tx_buf) { spi_imx 414 drivers/spi/spi-imx.c spi_imx->tx_buf, n_bytes); spi_imx 416 drivers/spi/spi-imx.c spi_imx->tx_buf += n_bytes; spi_imx 419 drivers/spi/spi-imx.c spi_imx->count -= n_bytes; spi_imx 421 drivers/spi/spi-imx.c writel(val, spi_imx->base + MXC_CSPITXDATA); spi_imx 425 drivers/spi/spi-imx.c static unsigned int mx51_ecspi_clkdiv(struct spi_imx_data *spi_imx, spi_imx 433 drivers/spi/spi-imx.c unsigned int fin = spi_imx->spi_clk; spi_imx 446 drivers/spi/spi-imx.c dev_err(spi_imx->dev, "cannot set clock freq: %u (base freq: %u)\n", spi_imx 453 drivers/spi/spi-imx.c dev_dbg(spi_imx->dev, "%s: fin: %u, fspi: %u, post: %u, pre: %u\n", spi_imx 463 drivers/spi/spi-imx.c static void mx51_ecspi_intctrl(struct spi_imx_data *spi_imx, int enable) spi_imx 476 drivers/spi/spi-imx.c writel(val, spi_imx->base + MX51_ECSPI_INT); spi_imx 479 drivers/spi/spi-imx.c static void mx51_ecspi_trigger(struct spi_imx_data *spi_imx) spi_imx 483 drivers/spi/spi-imx.c reg = readl(spi_imx->base + MX51_ECSPI_CTRL); spi_imx 485 drivers/spi/spi-imx.c writel(reg, spi_imx->base + MX51_ECSPI_CTRL); spi_imx 488 drivers/spi/spi-imx.c static void mx51_ecspi_disable(struct spi_imx_data *spi_imx) spi_imx 492 drivers/spi/spi-imx.c ctrl = readl(spi_imx->base + MX51_ECSPI_CTRL); spi_imx 494 drivers/spi/spi-imx.c writel(ctrl, spi_imx->base + MX51_ECSPI_CTRL); spi_imx 497 drivers/spi/spi-imx.c static int mx51_ecspi_prepare_message(struct spi_imx_data *spi_imx, spi_imx 503 drivers/spi/spi-imx.c u32 cfg = readl(spi_imx->base + MX51_ECSPI_CONFIG); spi_imx 506 drivers/spi/spi-imx.c if (spi_imx->slave_mode) spi_imx 515 drivers/spi/spi-imx.c ctrl |= MX51_ECSPI_CTRL_DRCTL(spi_imx->spi_drctl); spi_imx 524 drivers/spi/spi-imx.c writel(ctrl, spi_imx->base + MX51_ECSPI_CTRL); spi_imx 526 drivers/spi/spi-imx.c testreg = readl(spi_imx->base + MX51_ECSPI_TESTREG); spi_imx 531 drivers/spi/spi-imx.c writel(testreg, spi_imx->base + MX51_ECSPI_TESTREG); spi_imx 538 drivers/spi/spi-imx.c if (spi_imx->slave_mode && is_imx53_ecspi(spi_imx)) spi_imx 561 drivers/spi/spi-imx.c writel(cfg, spi_imx->base + MX51_ECSPI_CONFIG); spi_imx 566 drivers/spi/spi-imx.c static int mx51_ecspi_prepare_transfer(struct spi_imx_data *spi_imx, spi_imx 570 drivers/spi/spi-imx.c u32 ctrl = readl(spi_imx->base + MX51_ECSPI_CTRL); spi_imx 575 drivers/spi/spi-imx.c if (spi_imx->slave_mode && is_imx53_ecspi(spi_imx)) spi_imx 576 drivers/spi/spi-imx.c ctrl |= (spi_imx->slave_burst * 8 - 1) spi_imx 579 drivers/spi/spi-imx.c ctrl |= (spi_imx->bits_per_word - 1) spi_imx 585 drivers/spi/spi-imx.c ctrl |= mx51_ecspi_clkdiv(spi_imx, t->speed_hz, &clk); spi_imx 586 drivers/spi/spi-imx.c spi_imx->spi_bus_clk = clk; spi_imx 588 drivers/spi/spi-imx.c if (spi_imx->usedma) spi_imx 591 drivers/spi/spi-imx.c writel(ctrl, spi_imx->base + MX51_ECSPI_CTRL); spi_imx 613 drivers/spi/spi-imx.c static void mx51_setup_wml(struct spi_imx_data *spi_imx) spi_imx 619 drivers/spi/spi-imx.c writel(MX51_ECSPI_DMA_RX_WML(spi_imx->wml - 1) | spi_imx 620 drivers/spi/spi-imx.c MX51_ECSPI_DMA_TX_WML(spi_imx->wml) | spi_imx 621 drivers/spi/spi-imx.c MX51_ECSPI_DMA_RXT_WML(spi_imx->wml) | spi_imx 623 drivers/spi/spi-imx.c MX51_ECSPI_DMA_RXTDEN, spi_imx->base + MX51_ECSPI_DMA); spi_imx 626 drivers/spi/spi-imx.c static int mx51_ecspi_rx_available(struct spi_imx_data *spi_imx) spi_imx 628 drivers/spi/spi-imx.c return readl(spi_imx->base + MX51_ECSPI_STAT) & MX51_ECSPI_STAT_RR; spi_imx 631 drivers/spi/spi-imx.c static void mx51_ecspi_reset(struct spi_imx_data *spi_imx) spi_imx 634 drivers/spi/spi-imx.c while (mx51_ecspi_rx_available(spi_imx)) spi_imx 635 drivers/spi/spi-imx.c readl(spi_imx->base + MXC_CSPIRXDATA); spi_imx 669 drivers/spi/spi-imx.c static void mx31_intctrl(struct spi_imx_data *spi_imx, int enable) spi_imx 678 drivers/spi/spi-imx.c writel(val, spi_imx->base + MXC_CSPIINT); spi_imx 681 drivers/spi/spi-imx.c static void mx31_trigger(struct spi_imx_data *spi_imx) spi_imx 685 drivers/spi/spi-imx.c reg = readl(spi_imx->base + MXC_CSPICTRL); spi_imx 687 drivers/spi/spi-imx.c writel(reg, spi_imx->base + MXC_CSPICTRL); spi_imx 690 drivers/spi/spi-imx.c static int mx31_prepare_message(struct spi_imx_data *spi_imx, spi_imx 696 drivers/spi/spi-imx.c static int mx31_prepare_transfer(struct spi_imx_data *spi_imx, spi_imx 703 drivers/spi/spi-imx.c reg |= spi_imx_clkdiv_2(spi_imx->spi_clk, t->speed_hz, &clk) << spi_imx 705 drivers/spi/spi-imx.c spi_imx->spi_bus_clk = clk; spi_imx 707 drivers/spi/spi-imx.c if (is_imx35_cspi(spi_imx)) { spi_imx 708 drivers/spi/spi-imx.c reg |= (spi_imx->bits_per_word - 1) << MX35_CSPICTRL_BL_SHIFT; spi_imx 711 drivers/spi/spi-imx.c reg |= (spi_imx->bits_per_word - 1) << MX31_CSPICTRL_BC_SHIFT; spi_imx 722 drivers/spi/spi-imx.c (is_imx35_cspi(spi_imx) ? MX35_CSPICTRL_CS_SHIFT : spi_imx 725 drivers/spi/spi-imx.c if (spi_imx->usedma) spi_imx 728 drivers/spi/spi-imx.c writel(reg, spi_imx->base + MXC_CSPICTRL); spi_imx 730 drivers/spi/spi-imx.c reg = readl(spi_imx->base + MX31_CSPI_TESTREG); spi_imx 735 drivers/spi/spi-imx.c writel(reg, spi_imx->base + MX31_CSPI_TESTREG); spi_imx 737 drivers/spi/spi-imx.c if (spi_imx->usedma) { spi_imx 743 drivers/spi/spi-imx.c spi_imx->base + MX31_CSPI_DMAREG); spi_imx 749 drivers/spi/spi-imx.c static int mx31_rx_available(struct spi_imx_data *spi_imx) spi_imx 751 drivers/spi/spi-imx.c return readl(spi_imx->base + MX31_CSPISTATUS) & MX31_STATUS_RR; spi_imx 754 drivers/spi/spi-imx.c static void mx31_reset(struct spi_imx_data *spi_imx) spi_imx 757 drivers/spi/spi-imx.c while (readl(spi_imx->base + MX31_CSPISTATUS) & MX31_STATUS_RR) spi_imx 758 drivers/spi/spi-imx.c readl(spi_imx->base + MXC_CSPIRXDATA); spi_imx 774 drivers/spi/spi-imx.c static void mx21_intctrl(struct spi_imx_data *spi_imx, int enable) spi_imx 783 drivers/spi/spi-imx.c writel(val, spi_imx->base + MXC_CSPIINT); spi_imx 786 drivers/spi/spi-imx.c static void mx21_trigger(struct spi_imx_data *spi_imx) spi_imx 790 drivers/spi/spi-imx.c reg = readl(spi_imx->base + MXC_CSPICTRL); spi_imx 792 drivers/spi/spi-imx.c writel(reg, spi_imx->base + MXC_CSPICTRL); spi_imx 795 drivers/spi/spi-imx.c static int mx21_prepare_message(struct spi_imx_data *spi_imx, spi_imx 801 drivers/spi/spi-imx.c static int mx21_prepare_transfer(struct spi_imx_data *spi_imx, spi_imx 806 drivers/spi/spi-imx.c unsigned int max = is_imx27_cspi(spi_imx) ? 16 : 18; spi_imx 809 drivers/spi/spi-imx.c reg |= spi_imx_clkdiv_1(spi_imx->spi_clk, t->speed_hz, max, &clk) spi_imx 811 drivers/spi/spi-imx.c spi_imx->spi_bus_clk = clk; spi_imx 813 drivers/spi/spi-imx.c reg |= spi_imx->bits_per_word - 1; spi_imx 824 drivers/spi/spi-imx.c writel(reg, spi_imx->base + MXC_CSPICTRL); spi_imx 829 drivers/spi/spi-imx.c static int mx21_rx_available(struct spi_imx_data *spi_imx) spi_imx 831 drivers/spi/spi-imx.c return readl(spi_imx->base + MXC_CSPIINT) & MX21_INTREG_RR; spi_imx 834 drivers/spi/spi-imx.c static void mx21_reset(struct spi_imx_data *spi_imx) spi_imx 836 drivers/spi/spi-imx.c writel(1, spi_imx->base + MXC_RESET); spi_imx 850 drivers/spi/spi-imx.c static void mx1_intctrl(struct spi_imx_data *spi_imx, int enable) spi_imx 859 drivers/spi/spi-imx.c writel(val, spi_imx->base + MXC_CSPIINT); spi_imx 862 drivers/spi/spi-imx.c static void mx1_trigger(struct spi_imx_data *spi_imx) spi_imx 866 drivers/spi/spi-imx.c reg = readl(spi_imx->base + MXC_CSPICTRL); spi_imx 868 drivers/spi/spi-imx.c writel(reg, spi_imx->base + MXC_CSPICTRL); spi_imx 871 drivers/spi/spi-imx.c static int mx1_prepare_message(struct spi_imx_data *spi_imx, spi_imx 877 drivers/spi/spi-imx.c static int mx1_prepare_transfer(struct spi_imx_data *spi_imx, spi_imx 884 drivers/spi/spi-imx.c reg |= spi_imx_clkdiv_2(spi_imx->spi_clk, t->speed_hz, &clk) << spi_imx 886 drivers/spi/spi-imx.c spi_imx->spi_bus_clk = clk; spi_imx 888 drivers/spi/spi-imx.c reg |= spi_imx->bits_per_word - 1; spi_imx 895 drivers/spi/spi-imx.c writel(reg, spi_imx->base + MXC_CSPICTRL); spi_imx 900 drivers/spi/spi-imx.c static int mx1_rx_available(struct spi_imx_data *spi_imx) spi_imx 902 drivers/spi/spi-imx.c return readl(spi_imx->base + MXC_CSPIINT) & MX1_INTREG_RR; spi_imx 905 drivers/spi/spi-imx.c static void mx1_reset(struct spi_imx_data *spi_imx) spi_imx 907 drivers/spi/spi-imx.c writel(1, spi_imx->base + MXC_RESET); spi_imx 1065 drivers/spi/spi-imx.c static void spi_imx_set_burst_len(struct spi_imx_data *spi_imx, int n_bits) spi_imx 1069 drivers/spi/spi-imx.c ctrl = readl(spi_imx->base + MX51_ECSPI_CTRL); spi_imx 1072 drivers/spi/spi-imx.c writel(ctrl, spi_imx->base + MX51_ECSPI_CTRL); spi_imx 1075 drivers/spi/spi-imx.c static void spi_imx_push(struct spi_imx_data *spi_imx) spi_imx 1079 drivers/spi/spi-imx.c if (spi_imx->dynamic_burst) spi_imx 1082 drivers/spi/spi-imx.c fifo_words = spi_imx_bytes_per_word(spi_imx->bits_per_word); spi_imx 1088 drivers/spi/spi-imx.c if (!spi_imx->remainder) { spi_imx 1089 drivers/spi/spi-imx.c if (spi_imx->dynamic_burst) { spi_imx 1092 drivers/spi/spi-imx.c burst_len = spi_imx->count % MX51_ECSPI_CTRL_MAX_BURST; spi_imx 1097 drivers/spi/spi-imx.c spi_imx_set_burst_len(spi_imx, burst_len * 8); spi_imx 1099 drivers/spi/spi-imx.c spi_imx->remainder = burst_len; spi_imx 1101 drivers/spi/spi-imx.c spi_imx->remainder = fifo_words; spi_imx 1105 drivers/spi/spi-imx.c while (spi_imx->txfifo < spi_imx->devtype_data->fifo_size) { spi_imx 1106 drivers/spi/spi-imx.c if (!spi_imx->count) spi_imx 1108 drivers/spi/spi-imx.c if (spi_imx->dynamic_burst && spi_imx 1109 drivers/spi/spi-imx.c spi_imx->txfifo >= DIV_ROUND_UP(spi_imx->remainder, spi_imx 1112 drivers/spi/spi-imx.c spi_imx->tx(spi_imx); spi_imx 1113 drivers/spi/spi-imx.c spi_imx->txfifo++; spi_imx 1116 drivers/spi/spi-imx.c if (!spi_imx->slave_mode) spi_imx 1117 drivers/spi/spi-imx.c spi_imx->devtype_data->trigger(spi_imx); spi_imx 1122 drivers/spi/spi-imx.c struct spi_imx_data *spi_imx = dev_id; spi_imx 1124 drivers/spi/spi-imx.c while (spi_imx->txfifo && spi_imx 1125 drivers/spi/spi-imx.c spi_imx->devtype_data->rx_available(spi_imx)) { spi_imx 1126 drivers/spi/spi-imx.c spi_imx->rx(spi_imx); spi_imx 1127 drivers/spi/spi-imx.c spi_imx->txfifo--; spi_imx 1130 drivers/spi/spi-imx.c if (spi_imx->count) { spi_imx 1131 drivers/spi/spi-imx.c spi_imx_push(spi_imx); spi_imx 1135 drivers/spi/spi-imx.c if (spi_imx->txfifo) { spi_imx 1139 drivers/spi/spi-imx.c spi_imx->devtype_data->intctrl( spi_imx 1140 drivers/spi/spi-imx.c spi_imx, MXC_INT_RR); spi_imx 1144 drivers/spi/spi-imx.c spi_imx->devtype_data->intctrl(spi_imx, 0); spi_imx 1145 drivers/spi/spi-imx.c complete(&spi_imx->xfer_done); spi_imx 1155 drivers/spi/spi-imx.c struct spi_imx_data *spi_imx = spi_master_get_devdata(master); spi_imx 1157 drivers/spi/spi-imx.c switch (spi_imx_bytes_per_word(spi_imx->bits_per_word)) { spi_imx 1172 drivers/spi/spi-imx.c tx.dst_addr = spi_imx->base_phys + MXC_CSPITXDATA; spi_imx 1174 drivers/spi/spi-imx.c tx.dst_maxburst = spi_imx->wml; spi_imx 1177 drivers/spi/spi-imx.c dev_err(spi_imx->dev, "TX dma configuration failed with %d\n", ret); spi_imx 1182 drivers/spi/spi-imx.c rx.src_addr = spi_imx->base_phys + MXC_CSPIRXDATA; spi_imx 1184 drivers/spi/spi-imx.c rx.src_maxburst = spi_imx->wml; spi_imx 1187 drivers/spi/spi-imx.c dev_err(spi_imx->dev, "RX dma configuration failed with %d\n", ret); spi_imx 1197 drivers/spi/spi-imx.c struct spi_imx_data *spi_imx = spi_master_get_devdata(spi->master); spi_imx 1202 drivers/spi/spi-imx.c spi_imx->bits_per_word = t->bits_per_word; spi_imx 1209 drivers/spi/spi-imx.c if (spi_imx->devtype_data->dynamic_burst && !spi_imx->slave_mode && spi_imx 1210 drivers/spi/spi-imx.c (spi_imx->bits_per_word == 8 || spi_imx 1211 drivers/spi/spi-imx.c spi_imx->bits_per_word == 16 || spi_imx 1212 drivers/spi/spi-imx.c spi_imx->bits_per_word == 32)) { spi_imx 1214 drivers/spi/spi-imx.c spi_imx->rx = spi_imx_buf_rx_swap; spi_imx 1215 drivers/spi/spi-imx.c spi_imx->tx = spi_imx_buf_tx_swap; spi_imx 1216 drivers/spi/spi-imx.c spi_imx->dynamic_burst = 1; spi_imx 1219 drivers/spi/spi-imx.c if (spi_imx->bits_per_word <= 8) { spi_imx 1220 drivers/spi/spi-imx.c spi_imx->rx = spi_imx_buf_rx_u8; spi_imx 1221 drivers/spi/spi-imx.c spi_imx->tx = spi_imx_buf_tx_u8; spi_imx 1222 drivers/spi/spi-imx.c } else if (spi_imx->bits_per_word <= 16) { spi_imx 1223 drivers/spi/spi-imx.c spi_imx->rx = spi_imx_buf_rx_u16; spi_imx 1224 drivers/spi/spi-imx.c spi_imx->tx = spi_imx_buf_tx_u16; spi_imx 1226 drivers/spi/spi-imx.c spi_imx->rx = spi_imx_buf_rx_u32; spi_imx 1227 drivers/spi/spi-imx.c spi_imx->tx = spi_imx_buf_tx_u32; spi_imx 1229 drivers/spi/spi-imx.c spi_imx->dynamic_burst = 0; spi_imx 1232 drivers/spi/spi-imx.c if (spi_imx_can_dma(spi_imx->bitbang.master, spi, t)) spi_imx 1233 drivers/spi/spi-imx.c spi_imx->usedma = 1; spi_imx 1235 drivers/spi/spi-imx.c spi_imx->usedma = 0; spi_imx 1237 drivers/spi/spi-imx.c if (is_imx53_ecspi(spi_imx) && spi_imx->slave_mode) { spi_imx 1238 drivers/spi/spi-imx.c spi_imx->rx = mx53_ecspi_rx_slave; spi_imx 1239 drivers/spi/spi-imx.c spi_imx->tx = mx53_ecspi_tx_slave; spi_imx 1240 drivers/spi/spi-imx.c spi_imx->slave_burst = t->len; spi_imx 1243 drivers/spi/spi-imx.c spi_imx->devtype_data->prepare_transfer(spi_imx, spi, t); spi_imx 1248 drivers/spi/spi-imx.c static void spi_imx_sdma_exit(struct spi_imx_data *spi_imx) spi_imx 1250 drivers/spi/spi-imx.c struct spi_master *master = spi_imx->bitbang.master; spi_imx 1263 drivers/spi/spi-imx.c static int spi_imx_sdma_init(struct device *dev, struct spi_imx_data *spi_imx, spi_imx 1272 drivers/spi/spi-imx.c spi_imx->wml = spi_imx->devtype_data->fifo_size / 2; spi_imx 1292 drivers/spi/spi-imx.c init_completion(&spi_imx->dma_rx_completion); spi_imx 1293 drivers/spi/spi-imx.c init_completion(&spi_imx->dma_tx_completion); spi_imx 1296 drivers/spi/spi-imx.c spi_imx->bitbang.master->flags = SPI_MASTER_MUST_RX | spi_imx 1301 drivers/spi/spi-imx.c spi_imx_sdma_exit(spi_imx); spi_imx 1307 drivers/spi/spi-imx.c struct spi_imx_data *spi_imx = (struct spi_imx_data *)cookie; spi_imx 1309 drivers/spi/spi-imx.c complete(&spi_imx->dma_rx_completion); spi_imx 1314 drivers/spi/spi-imx.c struct spi_imx_data *spi_imx = (struct spi_imx_data *)cookie; spi_imx 1316 drivers/spi/spi-imx.c complete(&spi_imx->dma_tx_completion); spi_imx 1319 drivers/spi/spi-imx.c static int spi_imx_calculate_timeout(struct spi_imx_data *spi_imx, int size) spi_imx 1324 drivers/spi/spi-imx.c timeout = (8 + 4) * size / spi_imx->spi_bus_clk; spi_imx 1333 drivers/spi/spi-imx.c static int spi_imx_dma_transfer(struct spi_imx_data *spi_imx, spi_imx 1339 drivers/spi/spi-imx.c struct spi_master *master = spi_imx->bitbang.master; spi_imx 1347 drivers/spi/spi-imx.c for (i = spi_imx->devtype_data->fifo_size / 2; i > 0; i--) { spi_imx 1355 drivers/spi/spi-imx.c spi_imx->wml = i; spi_imx 1361 drivers/spi/spi-imx.c if (!spi_imx->devtype_data->setup_wml) { spi_imx 1362 drivers/spi/spi-imx.c dev_err(spi_imx->dev, "No setup_wml()?\n"); spi_imx 1365 drivers/spi/spi-imx.c spi_imx->devtype_data->setup_wml(spi_imx); spi_imx 1378 drivers/spi/spi-imx.c desc_rx->callback_param = (void *)spi_imx; spi_imx 1380 drivers/spi/spi-imx.c reinit_completion(&spi_imx->dma_rx_completion); spi_imx 1392 drivers/spi/spi-imx.c desc_tx->callback_param = (void *)spi_imx; spi_imx 1394 drivers/spi/spi-imx.c reinit_completion(&spi_imx->dma_tx_completion); spi_imx 1397 drivers/spi/spi-imx.c transfer_timeout = spi_imx_calculate_timeout(spi_imx, transfer->len); spi_imx 1400 drivers/spi/spi-imx.c timeout = wait_for_completion_timeout(&spi_imx->dma_tx_completion, spi_imx 1403 drivers/spi/spi-imx.c dev_err(spi_imx->dev, "I/O Error in DMA TX\n"); spi_imx 1409 drivers/spi/spi-imx.c timeout = wait_for_completion_timeout(&spi_imx->dma_rx_completion, spi_imx 1413 drivers/spi/spi-imx.c spi_imx->devtype_data->reset(spi_imx); spi_imx 1424 drivers/spi/spi-imx.c struct spi_imx_data *spi_imx = spi_master_get_devdata(spi->master); spi_imx 1428 drivers/spi/spi-imx.c spi_imx->tx_buf = transfer->tx_buf; spi_imx 1429 drivers/spi/spi-imx.c spi_imx->rx_buf = transfer->rx_buf; spi_imx 1430 drivers/spi/spi-imx.c spi_imx->count = transfer->len; spi_imx 1431 drivers/spi/spi-imx.c spi_imx->txfifo = 0; spi_imx 1432 drivers/spi/spi-imx.c spi_imx->remainder = 0; spi_imx 1434 drivers/spi/spi-imx.c reinit_completion(&spi_imx->xfer_done); spi_imx 1436 drivers/spi/spi-imx.c spi_imx_push(spi_imx); spi_imx 1438 drivers/spi/spi-imx.c spi_imx->devtype_data->intctrl(spi_imx, MXC_INT_TE); spi_imx 1440 drivers/spi/spi-imx.c transfer_timeout = spi_imx_calculate_timeout(spi_imx, transfer->len); spi_imx 1442 drivers/spi/spi-imx.c timeout = wait_for_completion_timeout(&spi_imx->xfer_done, spi_imx 1446 drivers/spi/spi-imx.c spi_imx->devtype_data->reset(spi_imx); spi_imx 1456 drivers/spi/spi-imx.c struct spi_imx_data *spi_imx = spi_master_get_devdata(spi->master); spi_imx 1459 drivers/spi/spi-imx.c if (is_imx53_ecspi(spi_imx) && spi_imx 1466 drivers/spi/spi-imx.c spi_imx->tx_buf = transfer->tx_buf; spi_imx 1467 drivers/spi/spi-imx.c spi_imx->rx_buf = transfer->rx_buf; spi_imx 1468 drivers/spi/spi-imx.c spi_imx->count = transfer->len; spi_imx 1469 drivers/spi/spi-imx.c spi_imx->txfifo = 0; spi_imx 1470 drivers/spi/spi-imx.c spi_imx->remainder = 0; spi_imx 1472 drivers/spi/spi-imx.c reinit_completion(&spi_imx->xfer_done); spi_imx 1473 drivers/spi/spi-imx.c spi_imx->slave_aborted = false; spi_imx 1475 drivers/spi/spi-imx.c spi_imx_push(spi_imx); spi_imx 1477 drivers/spi/spi-imx.c spi_imx->devtype_data->intctrl(spi_imx, MXC_INT_TE | MXC_INT_RDR); spi_imx 1479 drivers/spi/spi-imx.c if (wait_for_completion_interruptible(&spi_imx->xfer_done) || spi_imx 1480 drivers/spi/spi-imx.c spi_imx->slave_aborted) { spi_imx 1491 drivers/spi/spi-imx.c if (spi_imx->devtype_data->disable) spi_imx 1492 drivers/spi/spi-imx.c spi_imx->devtype_data->disable(spi_imx); spi_imx 1500 drivers/spi/spi-imx.c struct spi_imx_data *spi_imx = spi_master_get_devdata(spi->master); spi_imx 1503 drivers/spi/spi-imx.c while (spi_imx->devtype_data->rx_available(spi_imx)) spi_imx 1504 drivers/spi/spi-imx.c readl(spi_imx->base + MXC_CSPIRXDATA); spi_imx 1506 drivers/spi/spi-imx.c if (spi_imx->slave_mode) spi_imx 1509 drivers/spi/spi-imx.c if (spi_imx->usedma) spi_imx 1510 drivers/spi/spi-imx.c return spi_imx_dma_transfer(spi_imx, transfer); spi_imx 1539 drivers/spi/spi-imx.c struct spi_imx_data *spi_imx = spi_master_get_devdata(master); spi_imx 1542 drivers/spi/spi-imx.c ret = clk_enable(spi_imx->clk_per); spi_imx 1546 drivers/spi/spi-imx.c ret = clk_enable(spi_imx->clk_ipg); spi_imx 1548 drivers/spi/spi-imx.c clk_disable(spi_imx->clk_per); spi_imx 1552 drivers/spi/spi-imx.c ret = spi_imx->devtype_data->prepare_message(spi_imx, msg); spi_imx 1554 drivers/spi/spi-imx.c clk_disable(spi_imx->clk_ipg); spi_imx 1555 drivers/spi/spi-imx.c clk_disable(spi_imx->clk_per); spi_imx 1564 drivers/spi/spi-imx.c struct spi_imx_data *spi_imx = spi_master_get_devdata(master); spi_imx 1566 drivers/spi/spi-imx.c clk_disable(spi_imx->clk_ipg); spi_imx 1567 drivers/spi/spi-imx.c clk_disable(spi_imx->clk_per); spi_imx 1573 drivers/spi/spi-imx.c struct spi_imx_data *spi_imx = spi_master_get_devdata(master); spi_imx 1575 drivers/spi/spi-imx.c spi_imx->slave_aborted = true; spi_imx 1576 drivers/spi/spi-imx.c complete(&spi_imx->xfer_done); spi_imx 1589 drivers/spi/spi-imx.c struct spi_imx_data *spi_imx; spi_imx 1623 drivers/spi/spi-imx.c spi_imx = spi_master_get_devdata(master); spi_imx 1624 drivers/spi/spi-imx.c spi_imx->bitbang.master = master; spi_imx 1625 drivers/spi/spi-imx.c spi_imx->dev = &pdev->dev; spi_imx 1626 drivers/spi/spi-imx.c spi_imx->slave_mode = slave_mode; spi_imx 1628 drivers/spi/spi-imx.c spi_imx->devtype_data = devtype_data; spi_imx 1651 drivers/spi/spi-imx.c spi_imx->bitbang.chipselect = spi_imx_chipselect; spi_imx 1652 drivers/spi/spi-imx.c spi_imx->bitbang.setup_transfer = spi_imx_setupxfer; spi_imx 1653 drivers/spi/spi-imx.c spi_imx->bitbang.txrx_bufs = spi_imx_transfer; spi_imx 1654 drivers/spi/spi-imx.c spi_imx->bitbang.master->setup = spi_imx_setup; spi_imx 1655 drivers/spi/spi-imx.c spi_imx->bitbang.master->cleanup = spi_imx_cleanup; spi_imx 1656 drivers/spi/spi-imx.c spi_imx->bitbang.master->prepare_message = spi_imx_prepare_message; spi_imx 1657 drivers/spi/spi-imx.c spi_imx->bitbang.master->unprepare_message = spi_imx_unprepare_message; spi_imx 1658 drivers/spi/spi-imx.c spi_imx->bitbang.master->slave_abort = spi_imx_slave_abort; spi_imx 1659 drivers/spi/spi-imx.c spi_imx->bitbang.master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH \ spi_imx 1661 drivers/spi/spi-imx.c if (is_imx35_cspi(spi_imx) || is_imx51_ecspi(spi_imx) || spi_imx 1662 drivers/spi/spi-imx.c is_imx53_ecspi(spi_imx)) spi_imx 1663 drivers/spi/spi-imx.c spi_imx->bitbang.master->mode_bits |= SPI_LOOP | SPI_READY; spi_imx 1665 drivers/spi/spi-imx.c spi_imx->spi_drctl = spi_drctl; spi_imx 1667 drivers/spi/spi-imx.c init_completion(&spi_imx->xfer_done); spi_imx 1670 drivers/spi/spi-imx.c spi_imx->base = devm_ioremap_resource(&pdev->dev, res); spi_imx 1671 drivers/spi/spi-imx.c if (IS_ERR(spi_imx->base)) { spi_imx 1672 drivers/spi/spi-imx.c ret = PTR_ERR(spi_imx->base); spi_imx 1675 drivers/spi/spi-imx.c spi_imx->base_phys = res->start; spi_imx 1684 drivers/spi/spi-imx.c dev_name(&pdev->dev), spi_imx); spi_imx 1690 drivers/spi/spi-imx.c spi_imx->clk_ipg = devm_clk_get(&pdev->dev, "ipg"); spi_imx 1691 drivers/spi/spi-imx.c if (IS_ERR(spi_imx->clk_ipg)) { spi_imx 1692 drivers/spi/spi-imx.c ret = PTR_ERR(spi_imx->clk_ipg); spi_imx 1696 drivers/spi/spi-imx.c spi_imx->clk_per = devm_clk_get(&pdev->dev, "per"); spi_imx 1697 drivers/spi/spi-imx.c if (IS_ERR(spi_imx->clk_per)) { spi_imx 1698 drivers/spi/spi-imx.c ret = PTR_ERR(spi_imx->clk_per); spi_imx 1702 drivers/spi/spi-imx.c ret = clk_prepare_enable(spi_imx->clk_per); spi_imx 1706 drivers/spi/spi-imx.c ret = clk_prepare_enable(spi_imx->clk_ipg); spi_imx 1710 drivers/spi/spi-imx.c spi_imx->spi_clk = clk_get_rate(spi_imx->clk_per); spi_imx 1715 drivers/spi/spi-imx.c if (spi_imx->devtype_data->has_dmamode) { spi_imx 1716 drivers/spi/spi-imx.c ret = spi_imx_sdma_init(&pdev->dev, spi_imx, master); spi_imx 1725 drivers/spi/spi-imx.c spi_imx->devtype_data->reset(spi_imx); spi_imx 1727 drivers/spi/spi-imx.c spi_imx->devtype_data->intctrl(spi_imx, 0); spi_imx 1730 drivers/spi/spi-imx.c ret = spi_bitbang_start(&spi_imx->bitbang); spi_imx 1737 drivers/spi/spi-imx.c if (!spi_imx->slave_mode && master->cs_gpios) { spi_imx 1755 drivers/spi/spi-imx.c clk_disable(spi_imx->clk_ipg); spi_imx 1756 drivers/spi/spi-imx.c clk_disable(spi_imx->clk_per); spi_imx 1760 drivers/spi/spi-imx.c spi_bitbang_stop(&spi_imx->bitbang); spi_imx 1762 drivers/spi/spi-imx.c clk_disable_unprepare(spi_imx->clk_ipg); spi_imx 1764 drivers/spi/spi-imx.c clk_disable_unprepare(spi_imx->clk_per); spi_imx 1774 drivers/spi/spi-imx.c struct spi_imx_data *spi_imx = spi_master_get_devdata(master); spi_imx 1777 drivers/spi/spi-imx.c spi_bitbang_stop(&spi_imx->bitbang); spi_imx 1779 drivers/spi/spi-imx.c ret = clk_enable(spi_imx->clk_per); spi_imx 1783 drivers/spi/spi-imx.c ret = clk_enable(spi_imx->clk_ipg); spi_imx 1785 drivers/spi/spi-imx.c clk_disable(spi_imx->clk_per); spi_imx 1789 drivers/spi/spi-imx.c writel(0, spi_imx->base + MXC_CSPICTRL); spi_imx 1790 drivers/spi/spi-imx.c clk_disable_unprepare(spi_imx->clk_ipg); spi_imx 1791 drivers/spi/spi-imx.c clk_disable_unprepare(spi_imx->clk_per); spi_imx 1792 drivers/spi/spi-imx.c spi_imx_sdma_exit(spi_imx);