Lines Matching full:qmc

3  * QMC driver
10 #include <soc/fsl/qe/qmc.h>
95 /* QMC Global Channel specific base (32 bits, QE only) */
208 struct qmc *qmc; member
252 struct qmc { struct
319 static bool qmc_is_qe(const struct qmc *qmc) in qmc_is_qe() argument
322 return qmc->data->version == QMC_QE; in qmc_is_qe()
334 ret = tsa_serial_get_info(chan->qmc->tsa_serial, &tsa_info); in qmc_chan_get_info()
383 if (chan->qmc->is_tsa_64rxtx) { in qmc_chan_set_ts_info()
392 dev_err(chan->qmc->dev, "Channel rx and/or tx not stopped\n"); in qmc_chan_set_ts_info()
416 qmc_write16(chan->qmc->scc_pram + QMC_GBL_MRBLR, in qmc_chan_set_param()
577 qmc_write16(&bd->cbd_datlen, 0); /* data length is updated by the QMC */ in qmc_chan_read_submit()
596 qmc_write32(chan->s_param + QMC_SPE_RPACK, chan->qmc->data->rpack); in qmc_chan_read_submit()
599 chan->qmc->data->zdstate_transp : in qmc_chan_read_submit()
600 chan->qmc->data->zdstate_hdlc); in qmc_chan_read_submit()
601 qmc_write32(chan->s_param + QMC_SPE_RSTATE, chan->qmc->data->rstate); in qmc_chan_read_submit()
702 dev_err(chan->qmc->dev, "chan %u uses different Rx and Tx TS\n", chan->id); in qmc_chan_setup_tsa_64rxtx()
713 curr = qmc_read16(chan->qmc->scc_pram + QMC_GBL_TSATRX + (i * 2)); in qmc_chan_setup_tsa_64rxtx()
715 dev_err(chan->qmc->dev, "chan %u TxRx entry %d already used\n", in qmc_chan_setup_tsa_64rxtx()
726 qmc_clrsetbits16(chan->qmc->scc_pram + QMC_GBL_TSATRX + (i * 2), in qmc_chan_setup_tsa_64rxtx()
749 curr = qmc_read16(chan->qmc->scc_pram + QMC_GBL_TSATRX + (i * 2)); in qmc_chan_setup_tsa_32rx()
751 dev_err(chan->qmc->dev, "chan %u Rx entry %d already used\n", in qmc_chan_setup_tsa_32rx()
762 qmc_clrsetbits16(chan->qmc->scc_pram + QMC_GBL_TSATRX + (i * 2), in qmc_chan_setup_tsa_32rx()
785 curr = qmc_read16(chan->qmc->scc_pram + QMC_GBL_TSATTX + (i * 2)); in qmc_chan_setup_tsa_32tx()
787 dev_err(chan->qmc->dev, "chan %u Tx entry %d already used\n", in qmc_chan_setup_tsa_32tx()
798 qmc_clrsetbits16(chan->qmc->scc_pram + QMC_GBL_TSATTX + (i * 2), in qmc_chan_setup_tsa_32tx()
811 ret = tsa_serial_get_info(chan->qmc->tsa_serial, &info); in qmc_chan_setup_tsa_tx()
816 if (chan->qmc->is_tsa_64rxtx) in qmc_chan_setup_tsa_tx()
828 ret = tsa_serial_get_info(chan->qmc->tsa_serial, &info); in qmc_chan_setup_tsa_rx()
833 if (chan->qmc->is_tsa_64rxtx) in qmc_chan_setup_tsa_rx()
846 if (!qe_issue_cmd(cmd, chan->qmc->qe_subblock, chan->id, 0)) in qmc_chan_qe_command()
865 ret = qmc_is_qe(chan->qmc) ? in qmc_chan_stop_rx()
869 dev_err(chan->qmc->dev, "chan %u: Send STOP RECEIVE failed (%d)\n", in qmc_chan_stop_rx()
876 if (!chan->qmc->is_tsa_64rxtx || chan->is_tx_stopped) { in qmc_chan_stop_rx()
879 dev_err(chan->qmc->dev, "chan %u: Disable tsa entries failed (%d)\n", in qmc_chan_stop_rx()
904 ret = qmc_is_qe(chan->qmc) ? in qmc_chan_stop_tx()
908 dev_err(chan->qmc->dev, "chan %u: Send STOP TRANSMIT failed (%d)\n", in qmc_chan_stop_tx()
915 if (!chan->qmc->is_tsa_64rxtx || chan->is_rx_stopped) { in qmc_chan_stop_tx()
918 dev_err(chan->qmc->dev, "chan %u: Disable tsa entries failed (%d)\n", in qmc_chan_stop_tx()
962 static int qmc_setup_chan_trnsync(struct qmc *qmc, struct qmc_chan *chan) in qmc_setup_chan_trnsync() argument
971 ret = tsa_serial_get_info(chan->qmc->tsa_serial, &info); in qmc_setup_chan_trnsync()
978 dev_dbg(qmc->dev, "only one or zero ts -> disable trnsync\n"); in qmc_setup_chan_trnsync()
998 dev_dbg(qmc->dev, "chan %u: trnsync=0x%04x, rx %u/%u 0x%llx, tx %u/%u 0x%llx\n", in qmc_setup_chan_trnsync()
1021 dev_err(chan->qmc->dev, "chan %u: Enable tsa entries failed (%d)\n", in qmc_chan_start_rx()
1027 ret = qmc_setup_chan_trnsync(chan->qmc, chan); in qmc_chan_start_rx()
1029 dev_err(chan->qmc->dev, "chan %u: setup TRNSYNC failed (%d)\n", in qmc_chan_start_rx()
1036 qmc_write32(chan->s_param + QMC_SPE_RPACK, chan->qmc->data->rpack); in qmc_chan_start_rx()
1039 chan->qmc->data->zdstate_transp : in qmc_chan_start_rx()
1040 chan->qmc->data->zdstate_hdlc); in qmc_chan_start_rx()
1041 qmc_write32(chan->s_param + QMC_SPE_RSTATE, chan->qmc->data->rstate); in qmc_chan_start_rx()
1066 dev_err(chan->qmc->dev, "chan %u: Enable tsa entries failed (%d)\n", in qmc_chan_start_tx()
1072 ret = qmc_setup_chan_trnsync(chan->qmc, chan); in qmc_chan_start_tx()
1074 dev_err(chan->qmc->dev, "chan %u: setup TRNSYNC failed (%d)\n", in qmc_chan_start_tx()
1187 qmc_write32(chan->s_param + QMC_SPE_TSTATE, chan->qmc->data->tstate); in qmc_chan_reset_tx()
1188 qmc_write32(chan->s_param + QMC_SPE_ZISTATE, chan->qmc->data->zistate); in qmc_chan_reset_tx()
1205 static int qmc_check_chans(struct qmc *qmc) in qmc_check_chans() argument
1214 ret = tsa_serial_get_info(qmc->tsa_serial, &info); in qmc_check_chans()
1219 dev_err(qmc->dev, "Number of TSA Tx/Rx TS assigned not supported\n"); in qmc_check_chans()
1229 dev_err(qmc->dev, "Number of TSA Tx/Rx TS assigned are not equal\n"); in qmc_check_chans()
1237 list_for_each_entry(chan, &qmc->chan_head, list) { in qmc_check_chans()
1239 dev_err(qmc->dev, "chan %u can use TSA unassigned Tx TS\n", chan->id); in qmc_check_chans()
1244 dev_err(qmc->dev, "chan %u can use TSA unassigned Rx TS\n", chan->id); in qmc_check_chans()
1252 static unsigned int qmc_nb_chans(struct qmc *qmc) in qmc_nb_chans() argument
1257 list_for_each_entry(chan, &qmc->chan_head, list) in qmc_nb_chans()
1263 static int qmc_of_parse_chans(struct qmc *qmc, struct device_node *np) in qmc_of_parse_chans() argument
1275 dev_err(qmc->dev, "%pOF: failed to read reg\n", chan_np); in qmc_of_parse_chans()
1280 dev_err(qmc->dev, "%pOF: Invalid chan_id\n", chan_np); in qmc_of_parse_chans()
1285 chan = devm_kzalloc(qmc->dev, sizeof(*chan), GFP_KERNEL); in qmc_of_parse_chans()
1298 dev_err(qmc->dev, "%pOF: failed to read fsl,tx-ts-mask\n", in qmc_of_parse_chans()
1308 dev_err(qmc->dev, "%pOF: failed to read fsl,rx-ts-mask\n", in qmc_of_parse_chans()
1319 dev_err(qmc->dev, "%pOF: failed to read fsl,operational-mode\n", in qmc_of_parse_chans()
1329 dev_err(qmc->dev, "%pOF: Invalid fsl,operational-mode (%s)\n", in qmc_of_parse_chans()
1338 list_add_tail(&chan->list, &qmc->chan_head); in qmc_of_parse_chans()
1339 qmc->chans[chan->id] = chan; in qmc_of_parse_chans()
1342 return qmc_check_chans(qmc); in qmc_of_parse_chans()
1345 static int qmc_init_tsa_64rxtx(struct qmc *qmc, const struct tsa_serial_info *info) in qmc_init_tsa_64rxtx() argument
1355 qmc->is_tsa_64rxtx = true; in qmc_init_tsa_64rxtx()
1359 qmc_write16(qmc->scc_pram + QMC_GBL_TSATRX + (i * 2), 0x0000); in qmc_init_tsa_64rxtx()
1362 qmc_setbits16(qmc->scc_pram + QMC_GBL_TSATRX + ((info->nb_rx_ts - 1) * 2), in qmc_init_tsa_64rxtx()
1366 val = qmc->scc_pram_offset + QMC_GBL_TSATRX; in qmc_init_tsa_64rxtx()
1367 qmc_write16(qmc->scc_pram + QMC_GBL_RX_S_PTR, val); in qmc_init_tsa_64rxtx()
1368 qmc_write16(qmc->scc_pram + QMC_GBL_RXPTR, val); in qmc_init_tsa_64rxtx()
1369 qmc_write16(qmc->scc_pram + QMC_GBL_TX_S_PTR, val); in qmc_init_tsa_64rxtx()
1370 qmc_write16(qmc->scc_pram + QMC_GBL_TXPTR, val); in qmc_init_tsa_64rxtx()
1375 static int qmc_init_tsa_32rx_32tx(struct qmc *qmc, const struct tsa_serial_info *info) in qmc_init_tsa_32rx_32tx() argument
1384 qmc->is_tsa_64rxtx = false; in qmc_init_tsa_32rx_32tx()
1388 qmc_write16(qmc->scc_pram + QMC_GBL_TSATRX + (i * 2), 0x0000); in qmc_init_tsa_32rx_32tx()
1389 qmc_write16(qmc->scc_pram + QMC_GBL_TSATTX + (i * 2), 0x0000); in qmc_init_tsa_32rx_32tx()
1393 qmc_setbits16(qmc->scc_pram + QMC_GBL_TSATRX + ((info->nb_rx_ts - 1) * 2), in qmc_init_tsa_32rx_32tx()
1395 qmc_setbits16(qmc->scc_pram + QMC_GBL_TSATTX + ((info->nb_tx_ts - 1) * 2), in qmc_init_tsa_32rx_32tx()
1399 val = qmc->scc_pram_offset + QMC_GBL_TSATRX; in qmc_init_tsa_32rx_32tx()
1400 qmc_write16(qmc->scc_pram + QMC_GBL_RX_S_PTR, val); in qmc_init_tsa_32rx_32tx()
1401 qmc_write16(qmc->scc_pram + QMC_GBL_RXPTR, val); in qmc_init_tsa_32rx_32tx()
1404 val = qmc->scc_pram_offset + QMC_GBL_TSATTX; in qmc_init_tsa_32rx_32tx()
1405 qmc_write16(qmc->scc_pram + QMC_GBL_TX_S_PTR, val); in qmc_init_tsa_32rx_32tx()
1406 qmc_write16(qmc->scc_pram + QMC_GBL_TXPTR, val); in qmc_init_tsa_32rx_32tx()
1411 static int qmc_init_tsa(struct qmc *qmc) in qmc_init_tsa() argument
1417 ret = tsa_serial_get_info(qmc->tsa_serial, &info); in qmc_init_tsa()
1426 qmc_init_tsa_64rxtx(qmc, &info) : in qmc_init_tsa()
1427 qmc_init_tsa_32rx_32tx(qmc, &info); in qmc_init_tsa()
1430 static int qmc_setup_chan(struct qmc *qmc, struct qmc_chan *chan) in qmc_setup_chan() argument
1437 chan->qmc = qmc; in qmc_setup_chan()
1440 chan->s_param = qmc->dpram + (chan->id * 64); in qmc_setup_chan()
1442 chan->txbds = qmc->bd_table + (chan->id * (QMC_NB_TXBDS + QMC_NB_RXBDS)); in qmc_setup_chan()
1443 chan->rxbds = qmc->bd_table + (chan->id * (QMC_NB_TXBDS + QMC_NB_RXBDS)) + QMC_NB_TXBDS; in qmc_setup_chan()
1459 qmc_write32(chan->s_param + QMC_SPE_TSTATE, chan->qmc->data->tstate); in qmc_setup_chan()
1460 qmc_write32(chan->s_param + QMC_SPE_RSTATE, chan->qmc->data->rstate); in qmc_setup_chan()
1461 qmc_write32(chan->s_param + QMC_SPE_ZISTATE, chan->qmc->data->zistate); in qmc_setup_chan()
1462 qmc_write32(chan->s_param + QMC_SPE_RPACK, chan->qmc->data->rpack); in qmc_setup_chan()
1464 qmc_write32(chan->s_param + QMC_SPE_ZDSTATE, chan->qmc->data->zdstate_transp); in qmc_setup_chan()
1470 ret = qmc_setup_chan_trnsync(qmc, chan); in qmc_setup_chan()
1474 qmc_write32(chan->s_param + QMC_SPE_ZDSTATE, chan->qmc->data->zdstate_hdlc); in qmc_setup_chan()
1508 static int qmc_setup_chans(struct qmc *qmc) in qmc_setup_chans() argument
1513 list_for_each_entry(chan, &qmc->chan_head, list) { in qmc_setup_chans()
1514 ret = qmc_setup_chan(qmc, chan); in qmc_setup_chans()
1522 static int qmc_finalize_chans(struct qmc *qmc) in qmc_finalize_chans() argument
1527 list_for_each_entry(chan, &qmc->chan_head, list) { in qmc_finalize_chans()
1549 static int qmc_setup_ints(struct qmc *qmc) in qmc_setup_ints() argument
1555 for (i = 0; i < (qmc->int_size / sizeof(u16)); i++) in qmc_setup_ints()
1556 qmc_write16(qmc->int_table + i, 0x0000); in qmc_setup_ints()
1559 if (qmc->int_size >= sizeof(u16)) { in qmc_setup_ints()
1560 last = qmc->int_table + (qmc->int_size / sizeof(u16)) - 1; in qmc_setup_ints()
1567 static void qmc_irq_gint(struct qmc *qmc) in qmc_irq_gint() argument
1574 int_entry = qmc_read16(qmc->int_curr); in qmc_irq_gint()
1577 qmc_write16(qmc->int_curr, int_entry & QMC_INT_W); in qmc_irq_gint()
1580 chan = qmc->chans[chan_id]; in qmc_irq_gint()
1582 dev_err(qmc->dev, "interrupt on invalid chan %u\n", chan_id); in qmc_irq_gint()
1590 dev_info(qmc->dev, "intr chan %u, 0x%04x (UN)\n", chan_id, in qmc_irq_gint()
1596 dev_info(qmc->dev, "intr chan %u, 0x%04x (BSY)\n", chan_id, in qmc_irq_gint()
1603 chan->qmc->data->rpack); in qmc_irq_gint()
1606 chan->qmc->data->zdstate_transp : in qmc_irq_gint()
1607 chan->qmc->data->zdstate_hdlc); in qmc_irq_gint()
1609 chan->qmc->data->rstate); in qmc_irq_gint()
1622 qmc->int_curr = qmc->int_table; in qmc_irq_gint()
1624 qmc->int_curr++; in qmc_irq_gint()
1625 int_entry = qmc_read16(qmc->int_curr); in qmc_irq_gint()
1631 struct qmc *qmc = (struct qmc *)priv; in qmc_irq_handler() local
1634 scce = qmc_read16(qmc->scc_regs + SCC_SCCE); in qmc_irq_handler()
1635 qmc_write16(qmc->scc_regs + SCC_SCCE, scce); in qmc_irq_handler()
1638 dev_info(qmc->dev, "IRQ queue overflow\n"); in qmc_irq_handler()
1641 dev_err(qmc->dev, "Global transmitter underrun\n"); in qmc_irq_handler()
1644 dev_err(qmc->dev, "Global receiver overrun\n"); in qmc_irq_handler()
1648 qmc_irq_gint(qmc); in qmc_irq_handler()
1653 static int qmc_qe_soft_qmc_init(struct qmc *qmc, struct device_node *np) in qmc_qe_soft_qmc_init() argument
1661 ret = of_property_read_string(np, "fsl,soft-qmc", &filename); in qmc_qe_soft_qmc_init()
1666 /* fsl,soft-qmc property not set -> Simply do nothing */ in qmc_qe_soft_qmc_init()
1669 dev_err(qmc->dev, "%pOF: failed to read fsl,soft-qmc\n", in qmc_qe_soft_qmc_init()
1676 if (!strstr(qe_fw_info->id, "Soft-QMC")) { in qmc_qe_soft_qmc_init()
1677 dev_err(qmc->dev, "Another Firmware is already loaded\n"); in qmc_qe_soft_qmc_init()
1680 dev_info(qmc->dev, "Firmware already loaded\n"); in qmc_qe_soft_qmc_init()
1684 dev_info(qmc->dev, "Using firmware %s\n", filename); in qmc_qe_soft_qmc_init()
1686 ret = request_firmware(&fw, filename, qmc->dev); in qmc_qe_soft_qmc_init()
1688 dev_err(qmc->dev, "Failed to request firmware %s\n", filename); in qmc_qe_soft_qmc_init()
1696 dev_err(qmc->dev, "Invalid firmware %s\n", filename); in qmc_qe_soft_qmc_init()
1703 dev_err(qmc->dev, "Failed to load firmware %s\n", filename); in qmc_qe_soft_qmc_init()
1713 static int qmc_cpm1_init_resources(struct qmc *qmc, struct platform_device *pdev) in qmc_cpm1_init_resources() argument
1717 qmc->scc_regs = devm_platform_ioremap_resource_byname(pdev, "scc_regs"); in qmc_cpm1_init_resources()
1718 if (IS_ERR(qmc->scc_regs)) in qmc_cpm1_init_resources()
1719 return PTR_ERR(qmc->scc_regs); in qmc_cpm1_init_resources()
1724 qmc->scc_pram_offset = res->start - get_immrbase(); in qmc_cpm1_init_resources()
1725 qmc->scc_pram = devm_ioremap_resource(qmc->dev, res); in qmc_cpm1_init_resources()
1726 if (IS_ERR(qmc->scc_pram)) in qmc_cpm1_init_resources()
1727 return PTR_ERR(qmc->scc_pram); in qmc_cpm1_init_resources()
1729 qmc->dpram = devm_platform_ioremap_resource_byname(pdev, "dpram"); in qmc_cpm1_init_resources()
1730 if (IS_ERR(qmc->dpram)) in qmc_cpm1_init_resources()
1731 return PTR_ERR(qmc->dpram); in qmc_cpm1_init_resources()
1736 static int qmc_qe_init_resources(struct qmc *qmc, struct platform_device *pdev) in qmc_qe_init_resources() argument
1742 qmc->scc_regs = devm_platform_ioremap_resource_byname(pdev, "ucc_regs"); in qmc_qe_init_resources()
1743 if (IS_ERR(qmc->scc_regs)) in qmc_qe_init_resources()
1744 return PTR_ERR(qmc->scc_regs); in qmc_qe_init_resources()
1746 ucc_num = tsa_serial_get_num(qmc->tsa_serial); in qmc_qe_init_resources()
1748 return dev_err_probe(qmc->dev, ucc_num, "Failed to get UCC num\n"); in qmc_qe_init_resources()
1750 qmc->qe_subblock = ucc_slow_get_qe_cr_subblock(ucc_num); in qmc_qe_init_resources()
1751 if (qmc->qe_subblock == QE_CR_SUBBLOCK_INVALID) { in qmc_qe_init_resources()
1752 dev_err(qmc->dev, "Unsupported ucc num %u\n", ucc_num); in qmc_qe_init_resources()
1762 info = devm_qe_muram_alloc(qmc->dev, UCC_SLOW_PRAM_SIZE + 2 * 64, in qmc_qe_init_resources()
1767 if (!qe_issue_cmd(QE_ASSIGN_PAGE_TO_DEVICE, qmc->qe_subblock, in qmc_qe_init_resources()
1769 dev_err(qmc->dev, "QE_ASSIGN_PAGE_TO_DEVICE cmd failed"); in qmc_qe_init_resources()
1772 qmc->scc_pram = qe_muram_addr(info); in qmc_qe_init_resources()
1773 qmc->scc_pram_offset = info; in qmc_qe_init_resources()
1778 qmc->dpram_offset = res->start - qe_muram_dma(qe_muram_addr(0)); in qmc_qe_init_resources()
1779 qmc->dpram = devm_ioremap_resource(qmc->dev, res); in qmc_qe_init_resources()
1780 if (IS_ERR(qmc->scc_pram)) in qmc_qe_init_resources()
1781 return PTR_ERR(qmc->scc_pram); in qmc_qe_init_resources()
1786 static int qmc_init_resources(struct qmc *qmc, struct platform_device *pdev) in qmc_init_resources() argument
1788 return qmc_is_qe(qmc) ? in qmc_init_resources()
1789 qmc_qe_init_resources(qmc, pdev) : in qmc_init_resources()
1790 qmc_cpm1_init_resources(qmc, pdev); in qmc_init_resources()
1793 static int qmc_cpm1_init_scc(struct qmc *qmc) in qmc_cpm1_init_scc() argument
1799 ret = tsa_serial_connect(qmc->tsa_serial); in qmc_cpm1_init_scc()
1801 return dev_err_probe(qmc->dev, ret, "Failed to connect TSA serial\n"); in qmc_cpm1_init_scc()
1805 qmc_write32(qmc->scc_regs + SCC_GSMRH, val); in qmc_cpm1_init_scc()
1807 /* enable QMC mode */ in qmc_cpm1_init_scc()
1808 qmc_write32(qmc->scc_regs + SCC_GSMRL, SCC_CPM1_GSMRL_MODE_QMC); in qmc_cpm1_init_scc()
1811 qmc_write16(qmc->scc_regs + SCC_SCCM, 0x0000); in qmc_cpm1_init_scc()
1812 qmc_write16(qmc->scc_regs + SCC_SCCE, 0x000F); in qmc_cpm1_init_scc()
1817 static int qmc_qe_init_ucc(struct qmc *qmc) in qmc_qe_init_ucc() argument
1823 qmc_write8(qmc->scc_regs + SCC_QE_UCC_GUEMR, in qmc_qe_init_ucc()
1827 ret = tsa_serial_connect(qmc->tsa_serial); in qmc_qe_init_ucc()
1829 return dev_err_probe(qmc->dev, ret, "Failed to connect TSA serial\n"); in qmc_qe_init_ucc()
1831 /* Initialize the QMC tx startup addresses */ in qmc_qe_init_ucc()
1832 if (!qe_issue_cmd(QE_PUSHSCHED, qmc->qe_subblock, in qmc_qe_init_ucc()
1834 dev_err(qmc->dev, "QE_CMD_PUSH_SCHED tx cmd failed"); in qmc_qe_init_ucc()
1839 /* Initialize the QMC rx startup addresses */ in qmc_qe_init_ucc()
1840 if (!qe_issue_cmd(QE_PUSHSCHED, qmc->qe_subblock | 0x00020000, in qmc_qe_init_ucc()
1842 dev_err(qmc->dev, "QE_CMD_PUSH_SCHED rx cmd failed"); in qmc_qe_init_ucc()
1851 val = qmc_read16(qmc->scc_pram + QMC_GBL_RX_S_PTR); in qmc_qe_init_ucc()
1852 qmc_write16(qmc->scc_pram + QMC_GBL_RXPTR, val); in qmc_qe_init_ucc()
1853 val = qmc_read16(qmc->scc_pram + QMC_GBL_TX_S_PTR); in qmc_qe_init_ucc()
1854 qmc_write16(qmc->scc_pram + QMC_GBL_TXPTR, val); in qmc_qe_init_ucc()
1859 qmc_write32(qmc->scc_regs + SCC_GSMRH, val); in qmc_qe_init_ucc()
1861 /* enable QMC mode */ in qmc_qe_init_ucc()
1862 qmc_write32(qmc->scc_regs + SCC_GSMRL, SCC_QE_GSMRL_MODE_QMC); in qmc_qe_init_ucc()
1865 qmc_write16(qmc->scc_regs + SCC_SCCM, 0x0000); in qmc_qe_init_ucc()
1866 qmc_write16(qmc->scc_regs + SCC_SCCE, 0x000F); in qmc_qe_init_ucc()
1871 tsa_serial_disconnect(qmc->tsa_serial); in qmc_qe_init_ucc()
1875 static int qmc_init_xcc(struct qmc *qmc) in qmc_init_xcc() argument
1877 return qmc_is_qe(qmc) ? in qmc_init_xcc()
1878 qmc_qe_init_ucc(qmc) : in qmc_init_xcc()
1879 qmc_cpm1_init_scc(qmc); in qmc_init_xcc()
1882 static void qmc_exit_xcc(struct qmc *qmc) in qmc_exit_xcc() argument
1885 tsa_serial_disconnect(qmc->tsa_serial); in qmc_exit_xcc()
1892 struct qmc *qmc; in qmc_probe() local
1896 qmc = devm_kzalloc(&pdev->dev, sizeof(*qmc), GFP_KERNEL); in qmc_probe()
1897 if (!qmc) in qmc_probe()
1900 qmc->dev = &pdev->dev; in qmc_probe()
1901 qmc->data = of_device_get_match_data(&pdev->dev); in qmc_probe()
1902 if (!qmc->data) { in qmc_probe()
1903 dev_err(qmc->dev, "Missing match data\n"); in qmc_probe()
1906 INIT_LIST_HEAD(&qmc->chan_head); in qmc_probe()
1908 qmc->tsa_serial = devm_tsa_serial_get_byphandle(qmc->dev, np, "fsl,tsa-serial"); in qmc_probe()
1909 if (IS_ERR(qmc->tsa_serial)) { in qmc_probe()
1910 return dev_err_probe(qmc->dev, PTR_ERR(qmc->tsa_serial), in qmc_probe()
1914 ret = qmc_init_resources(qmc, pdev); in qmc_probe()
1918 if (qmc_is_qe(qmc)) { in qmc_probe()
1919 ret = qmc_qe_soft_qmc_init(qmc, np); in qmc_probe()
1925 ret = qmc_of_parse_chans(qmc, np); in qmc_probe()
1929 nb_chans = qmc_nb_chans(qmc); in qmc_probe()
1935 qmc->bd_size = (nb_chans * (QMC_NB_TXBDS + QMC_NB_RXBDS)) * sizeof(cbd_t); in qmc_probe()
1936 qmc->bd_table = dmam_alloc_coherent(qmc->dev, qmc->bd_size, in qmc_probe()
1937 &qmc->bd_dma_addr, GFP_KERNEL); in qmc_probe()
1938 if (!qmc->bd_table) { in qmc_probe()
1939 dev_err(qmc->dev, "Failed to allocate bd table\n"); in qmc_probe()
1942 memset(qmc->bd_table, 0, qmc->bd_size); in qmc_probe()
1944 qmc_write32(qmc->scc_pram + QMC_GBL_MCBASE, qmc->bd_dma_addr); in qmc_probe()
1947 qmc->int_size = QMC_NB_INTS * sizeof(u16); in qmc_probe()
1948 qmc->int_table = dmam_alloc_coherent(qmc->dev, qmc->int_size, in qmc_probe()
1949 &qmc->int_dma_addr, GFP_KERNEL); in qmc_probe()
1950 if (!qmc->int_table) { in qmc_probe()
1951 dev_err(qmc->dev, "Failed to allocate interrupt table\n"); in qmc_probe()
1954 memset(qmc->int_table, 0, qmc->int_size); in qmc_probe()
1956 qmc->int_curr = qmc->int_table; in qmc_probe()
1957 qmc_write32(qmc->scc_pram + QMC_GBL_INTBASE, qmc->int_dma_addr); in qmc_probe()
1958 qmc_write32(qmc->scc_pram + QMC_GBL_INTPTR, qmc->int_dma_addr); in qmc_probe()
1961 qmc_write16(qmc->scc_pram + QMC_GBL_MRBLR, HDLC_MAX_MRU + 4); in qmc_probe()
1963 qmc_write16(qmc->scc_pram + QMC_GBL_GRFTHR, 1); in qmc_probe()
1964 qmc_write16(qmc->scc_pram + QMC_GBL_GRFCNT, 1); in qmc_probe()
1966 qmc_write32(qmc->scc_pram + QMC_GBL_C_MASK32, 0xDEBB20E3); in qmc_probe()
1967 qmc_write16(qmc->scc_pram + QMC_GBL_C_MASK16, 0xF0B8); in qmc_probe()
1969 if (qmc_is_qe(qmc)) { in qmc_probe()
1971 memset_io(qmc->scc_pram + QMC_QE_GBL_RSV_B0_START, 0, in qmc_probe()
1974 qmc_write32(qmc->scc_pram + QMC_QE_GBL_GCSBASE, qmc->dpram_offset); in qmc_probe()
1977 memset_io(qmc->scc_pram + UCC_SLOW_PRAM_SIZE, 0x01, 64); in qmc_probe()
1978 memset_io(qmc->scc_pram + UCC_SLOW_PRAM_SIZE + 64, 0x01, 64); in qmc_probe()
1979 qmc_write16(qmc->scc_pram + QMC_QE_GBL_RX_FRM_BASE, in qmc_probe()
1980 qmc->scc_pram_offset + UCC_SLOW_PRAM_SIZE); in qmc_probe()
1981 qmc_write16(qmc->scc_pram + QMC_QE_GBL_TX_FRM_BASE, in qmc_probe()
1982 qmc->scc_pram_offset + UCC_SLOW_PRAM_SIZE + 64); in qmc_probe()
1985 ret = qmc_init_tsa(qmc); in qmc_probe()
1989 qmc_write16(qmc->scc_pram + QMC_GBL_QMCSTATE, 0x8000); in qmc_probe()
1991 ret = qmc_setup_chans(qmc); in qmc_probe()
1996 ret = qmc_setup_ints(qmc); in qmc_probe()
2001 ret = qmc_init_xcc(qmc); in qmc_probe()
2009 ret = devm_request_irq(qmc->dev, irq, qmc_irq_handler, 0, "qmc", qmc); in qmc_probe()
2014 qmc_write16(qmc->scc_regs + SCC_SCCM, in qmc_probe()
2017 ret = qmc_finalize_chans(qmc); in qmc_probe()
2022 qmc_setbits32(qmc->scc_regs + SCC_GSMRL, SCC_GSMRL_ENR | SCC_GSMRL_ENT); in qmc_probe()
2024 platform_set_drvdata(pdev, qmc); in qmc_probe()
2027 ret = devm_of_platform_populate(qmc->dev); in qmc_probe()
2034 qmc_setbits32(qmc->scc_regs + SCC_GSMRL, 0); in qmc_probe()
2037 qmc_write16(qmc->scc_regs + SCC_SCCM, 0); in qmc_probe()
2040 qmc_exit_xcc(qmc); in qmc_probe()
2046 struct qmc *qmc = platform_get_drvdata(pdev); in qmc_remove() local
2049 qmc_setbits32(qmc->scc_regs + SCC_GSMRL, 0); in qmc_remove()
2052 qmc_write16(qmc->scc_regs + SCC_SCCM, 0); in qmc_remove()
2055 qmc_exit_xcc(qmc); in qmc_remove()
2080 { .compatible = "fsl,cpm1-scc-qmc", .data = &qmc_data_cpm1 },
2083 { .compatible = "fsl,qe-ucc-qmc", .data = &qmc_data_qe },
2091 .name = "fsl-qmc",
2103 struct qmc *qmc; in qmc_chan_get_from_qmc() local
2112 qmc = platform_get_drvdata(pdev); in qmc_chan_get_from_qmc()
2113 if (!qmc) { in qmc_chan_get_from_qmc()
2118 if (chan_index >= ARRAY_SIZE(qmc->chans)) { in qmc_chan_get_from_qmc()
2123 qmc_chan = qmc->chans[chan_index]; in qmc_chan_get_from_qmc()
2186 put_device(chan->qmc->dev); in qmc_chan_put()
2244 MODULE_DESCRIPTION("CPM/QE QMC driver");