Lines Matching full:fman

21 #include "fman.h"
267 /* Defines used for enabling/disabling FMan interrupts */
322 u32 fmfp_fcev[4]; /* FPM FMan-Controller Event 1-4 0x20-0x2f */
324 u32 fmfp_cee[4]; /* PM FMan-Controller Event 1-4 0x40-0x4f */
465 /* Structure that holds current FMan state.
509 /* Structure that holds FMan initial configuration */
548 static irqreturn_t fman_exceptions(struct fman *fman, in fman_exceptions() argument
551 dev_dbg(fman->dev, "%s: FMan[%d] exception %d\n", in fman_exceptions()
552 __func__, fman->state->fm_id, exception); in fman_exceptions()
557 static irqreturn_t fman_bus_error(struct fman *fman, u8 __maybe_unused port_id, in fman_bus_error() argument
562 dev_dbg(fman->dev, "%s: FMan[%d] bus error: port_id[%d]\n", in fman_bus_error()
563 __func__, fman->state->fm_id, port_id); in fman_bus_error()
568 static inline irqreturn_t call_mac_isr(struct fman *fman, u8 id) in call_mac_isr() argument
570 if (fman->intr_mng[id].isr_cb) { in call_mac_isr()
571 fman->intr_mng[id].isr_cb(fman->intr_mng[id].src_handle); in call_mac_isr()
611 static void set_port_liodn(struct fman *fman, u8 port_id, in set_port_liodn() argument
616 iowrite32be(liodn_ofst, &fman->bmi_regs->fmbm_spliodn[port_id - 1]); in set_port_liodn()
620 tmp = ioread32be(&fman->dma_regs->fmdmplr[port_id / 2]); in set_port_liodn()
628 iowrite32be(tmp, &fman->dma_regs->fmdmplr[port_id / 2]); in set_port_liodn()
680 static int dma_init(struct fman *fman) in dma_init() argument
682 struct fman_dma_regs __iomem *dma_rg = fman->dma_regs; in dma_init()
683 struct fman_cfg *cfg = fman->cfg; in dma_init()
744 fman->cam_size = in dma_init()
745 (u32)(fman->cfg->dma_cam_num_of_entries * DMA_CAM_SIZEOF_ENTRY); in dma_init()
746 fman->cam_offset = fman_muram_alloc(fman->muram, fman->cam_size); in dma_init()
747 if (IS_ERR_VALUE(fman->cam_offset)) { in dma_init()
748 dev_err(fman->dev, "%s: MURAM alloc for DMA CAM failed\n", in dma_init()
753 if (fman->state->rev_info.major == 2) { in dma_init()
756 fman_muram_free_mem(fman->muram, fman->cam_offset, in dma_init()
757 fman->cam_size); in dma_init()
759 fman->cam_size = fman->cfg->dma_cam_num_of_entries * 72 + 128; in dma_init()
760 fman->cam_offset = fman_muram_alloc(fman->muram, in dma_init()
761 fman->cam_size); in dma_init()
762 if (IS_ERR_VALUE(fman->cam_offset)) { in dma_init()
763 dev_err(fman->dev, "%s: MURAM alloc for DMA CAM failed\n", in dma_init()
768 if (fman->cfg->dma_cam_num_of_entries % 8 || in dma_init()
769 fman->cfg->dma_cam_num_of_entries > 32) { in dma_init()
770 dev_err(fman->dev, "%s: wrong dma_cam_num_of_entries\n", in dma_init()
776 fman_muram_offset_to_vbase(fman->muram, in dma_init()
777 fman->cam_offset); in dma_init()
779 (32 - fman->cfg->dma_cam_num_of_entries)) - 1), in dma_init()
783 fman->cfg->cam_base_addr = fman->cam_offset; in dma_init()
825 /* FMan is not halted upon external halt activation */ in fpm_init()
928 static int enable(struct fman *fman, struct fman_cfg *cfg) in enable() argument
942 iowrite32be(BMI_INIT_START, &fman->bmi_regs->fmbm_init); in enable()
944 &fman->qmi_regs->fmqm_gc); in enable()
949 static int set_exception(struct fman *fman, in set_exception() argument
956 tmp = ioread32be(&fman->dma_regs->fmdmmr); in set_exception()
962 iowrite32be(tmp, &fman->dma_regs->fmdmmr); in set_exception()
967 tmp = ioread32be(&fman->dma_regs->fmdmmr); in set_exception()
972 iowrite32be(tmp, &fman->dma_regs->fmdmmr); in set_exception()
975 tmp = ioread32be(&fman->fpm_regs->fmfp_ee); in set_exception()
980 iowrite32be(tmp, &fman->fpm_regs->fmfp_ee); in set_exception()
983 tmp = ioread32be(&fman->fpm_regs->fmfp_ee); in set_exception()
988 iowrite32be(tmp, &fman->fpm_regs->fmfp_ee); in set_exception()
991 tmp = ioread32be(&fman->fpm_regs->fmfp_ee); in set_exception()
996 iowrite32be(tmp, &fman->fpm_regs->fmfp_ee); in set_exception()
999 tmp = ioread32be(&fman->qmi_regs->fmqm_ien); in set_exception()
1004 iowrite32be(tmp, &fman->qmi_regs->fmqm_ien); in set_exception()
1007 tmp = ioread32be(&fman->qmi_regs->fmqm_eien); in set_exception()
1012 iowrite32be(tmp, &fman->qmi_regs->fmqm_eien); in set_exception()
1015 tmp = ioread32be(&fman->qmi_regs->fmqm_eien); in set_exception()
1020 iowrite32be(tmp, &fman->qmi_regs->fmqm_eien); in set_exception()
1023 tmp = ioread32be(&fman->bmi_regs->fmbm_ier); in set_exception()
1028 iowrite32be(tmp, &fman->bmi_regs->fmbm_ier); in set_exception()
1031 tmp = ioread32be(&fman->bmi_regs->fmbm_ier); in set_exception()
1036 iowrite32be(tmp, &fman->bmi_regs->fmbm_ier); in set_exception()
1039 tmp = ioread32be(&fman->bmi_regs->fmbm_ier); in set_exception()
1044 iowrite32be(tmp, &fman->bmi_regs->fmbm_ier); in set_exception()
1047 tmp = ioread32be(&fman->bmi_regs->fmbm_ier); in set_exception()
1052 iowrite32be(tmp, &fman->bmi_regs->fmbm_ier); in set_exception()
1055 tmp = ioread32be(&fman->fpm_regs->fm_rie); in set_exception()
1058 enable_rams_ecc(fman->fpm_regs); in set_exception()
1065 disable_rams_ecc(fman->fpm_regs); in set_exception()
1068 iowrite32be(tmp, &fman->fpm_regs->fm_rie); in set_exception()
1071 tmp = ioread32be(&fman->fpm_regs->fm_rie); in set_exception()
1074 enable_rams_ecc(fman->fpm_regs); in set_exception()
1081 disable_rams_ecc(fman->fpm_regs); in set_exception()
1084 iowrite32be(tmp, &fman->fpm_regs->fm_rie); in set_exception()
1175 pr_err("Unsupported FMan version\n"); in fill_soc_specific_params()
1184 /* Checks if FMan driver parameters were initialized */ in is_init_done()
1191 static void free_init_resources(struct fman *fman) in free_init_resources() argument
1193 if (fman->cam_offset) in free_init_resources()
1194 fman_muram_free_mem(fman->muram, fman->cam_offset, in free_init_resources()
1195 fman->cam_size); in free_init_resources()
1196 if (fman->fifo_offset) in free_init_resources()
1197 fman_muram_free_mem(fman->muram, fman->fifo_offset, in free_init_resources()
1198 fman->fifo_size); in free_init_resources()
1201 static irqreturn_t bmi_err_event(struct fman *fman) in bmi_err_event() argument
1204 struct fman_bmi_regs __iomem *bmi_rg = fman->bmi_regs; in bmi_err_event()
1218 ret = fman->exception_cb(fman, FMAN_EX_BMI_STORAGE_PROFILE_ECC); in bmi_err_event()
1220 ret = fman->exception_cb(fman, FMAN_EX_BMI_LIST_RAM_ECC); in bmi_err_event()
1222 ret = fman->exception_cb(fman, FMAN_EX_BMI_STATISTICS_RAM_ECC); in bmi_err_event()
1224 ret = fman->exception_cb(fman, FMAN_EX_BMI_DISPATCH_RAM_ECC); in bmi_err_event()
1229 static irqreturn_t qmi_err_event(struct fman *fman) in qmi_err_event() argument
1232 struct fman_qmi_regs __iomem *qmi_rg = fman->qmi_regs; in qmi_err_event()
1247 ret = fman->exception_cb(fman, FMAN_EX_QMI_DOUBLE_ECC); in qmi_err_event()
1249 ret = fman->exception_cb(fman, in qmi_err_event()
1255 static irqreturn_t dma_err_event(struct fman *fman) in dma_err_event() argument
1260 struct fman_dma_regs __iomem *dma_rg = fman->dma_regs; in dma_err_event()
1290 hw_port_id_to_sw_port_id(fman->state->rev_info.major, port_id); in dma_err_event()
1294 ret = fman->bus_error_cb(fman, relative_port_id, addr, tnum, in dma_err_event()
1298 ret = fman->exception_cb(fman, FMAN_EX_DMA_SINGLE_PORT_ECC); in dma_err_event()
1300 ret = fman->exception_cb(fman, FMAN_EX_DMA_READ_ECC); in dma_err_event()
1302 ret = fman->exception_cb(fman, FMAN_EX_DMA_SYSTEM_WRITE_ECC); in dma_err_event()
1304 ret = fman->exception_cb(fman, FMAN_EX_DMA_FM_WRITE_ECC); in dma_err_event()
1309 static irqreturn_t fpm_err_event(struct fman *fman) in fpm_err_event() argument
1312 struct fman_fpm_regs __iomem *fpm_rg = fman->fpm_regs; in fpm_err_event()
1321 ret = fman->exception_cb(fman, FMAN_EX_FPM_DOUBLE_ECC); in fpm_err_event()
1323 ret = fman->exception_cb(fman, FMAN_EX_FPM_STALL_ON_TASKS); in fpm_err_event()
1326 ret = fman->exception_cb(fman, FMAN_EX_FPM_SINGLE_ECC); in fpm_err_event()
1331 static irqreturn_t muram_err_intr(struct fman *fman) in muram_err_intr() argument
1334 struct fman_fpm_regs __iomem *fpm_rg = fman->fpm_regs; in muram_err_intr()
1344 ret = fman->exception_cb(fman, FMAN_EX_MURAM_ECC); in muram_err_intr()
1349 static irqreturn_t qmi_event(struct fman *fman) in qmi_event() argument
1352 struct fman_qmi_regs __iomem *qmi_rg = fman->qmi_regs; in qmi_event()
1366 ret = fman->exception_cb(fman, FMAN_EX_QMI_SINGLE_ECC); in qmi_event()
1371 static void enable_time_stamp(struct fman *fman) in enable_time_stamp() argument
1373 struct fman_fpm_regs __iomem *fpm_rg = fman->fpm_regs; in enable_time_stamp()
1374 u16 fm_clk_freq = fman->state->fm_clk_freq; in enable_time_stamp()
1377 ts_freq = (u32)(1 << fman->state->count1_micro_bit); in enable_time_stamp()
1402 fman->state->enabled_time_stamp = true; in enable_time_stamp()
1405 static int clear_iram(struct fman *fman) in clear_iram() argument
1410 iram = fman->base_addr + IMEM_OFFSET; in clear_iram()
1421 for (i = 0; i < (fman->state->fm_iram_size / 4); i++) in clear_iram()
1424 iowrite32be(fman->state->fm_iram_size - 4, &iram->iadd); in clear_iram()
1525 static int set_size_of_fifo(struct fman *fman, u8 port_id, u32 *size_of_fifo, in set_size_of_fifo() argument
1528 struct fman_bmi_regs __iomem *bmi_rg = fman->bmi_regs; in set_size_of_fifo()
1537 if (extra_fifo && !fman->state->extra_fifo_pool_size) in set_size_of_fifo()
1538 fman->state->extra_fifo_pool_size = in set_size_of_fifo()
1539 fman->state->num_of_rx_ports * FMAN_BMI_FIFO_UNITS; in set_size_of_fifo()
1541 fman->state->extra_fifo_pool_size = in set_size_of_fifo()
1542 max(fman->state->extra_fifo_pool_size, extra_fifo); in set_size_of_fifo()
1545 if ((fman->state->accumulated_fifo_size + fifo) > in set_size_of_fifo()
1546 (fman->state->total_fifo_size - in set_size_of_fifo()
1547 fman->state->extra_fifo_pool_size)) { in set_size_of_fifo()
1548 dev_err(fman->dev, "%s: Requested fifo size and extra size exceed total FIFO size.\n", in set_size_of_fifo()
1560 fman->state->accumulated_fifo_size += fifo; in set_size_of_fifo()
1565 static int set_num_of_tasks(struct fman *fman, u8 port_id, u8 *num_of_tasks, in set_num_of_tasks() argument
1568 struct fman_bmi_regs __iomem *bmi_rg = fman->bmi_regs; in set_num_of_tasks()
1574 fman->state->extra_tasks_pool_size = in set_num_of_tasks()
1575 max(fman->state->extra_tasks_pool_size, extra_tasks); in set_num_of_tasks()
1578 if ((fman->state->accumulated_num_of_tasks + tasks) > in set_num_of_tasks()
1579 (fman->state->total_num_of_tasks - in set_num_of_tasks()
1580 fman->state->extra_tasks_pool_size)) { in set_num_of_tasks()
1581 …dev_err(fman->dev, "%s: Requested num_of_tasks and extra tasks pool for fm%d exceed total num_of_t… in set_num_of_tasks()
1582 __func__, fman->state->fm_id); in set_num_of_tasks()
1586 fman->state->accumulated_num_of_tasks += tasks; in set_num_of_tasks()
1598 static int set_num_of_open_dmas(struct fman *fman, u8 port_id, in set_num_of_open_dmas() argument
1602 struct fman_bmi_regs __iomem *bmi_rg = fman->bmi_regs; in set_num_of_open_dmas()
1624 fman->state->extra_open_dmas_pool_size = in set_num_of_open_dmas()
1625 (u8)max(fman->state->extra_open_dmas_pool_size, in set_num_of_open_dmas()
1627 fman->state->accumulated_num_of_open_dmas += current_val; in set_num_of_open_dmas()
1634 fman->state->extra_open_dmas_pool_size = in set_num_of_open_dmas()
1635 (u8)max(fman->state->extra_open_dmas_pool_size, in set_num_of_open_dmas()
1638 if ((fman->state->rev_info.major < 6) && in set_num_of_open_dmas()
1639 (fman->state->accumulated_num_of_open_dmas - current_val + in set_num_of_open_dmas()
1640 open_dmas > fman->state->max_num_of_open_dmas)) { in set_num_of_open_dmas()
1641 dev_err(fman->dev, "%s: Requested num_of_open_dmas for fm%d exceeds total num_of_open_dmas.\n", in set_num_of_open_dmas()
1642 __func__, fman->state->fm_id); in set_num_of_open_dmas()
1644 } else if ((fman->state->rev_info.major >= 6) && in set_num_of_open_dmas()
1645 !((fman->state->rev_info.major == 6) && in set_num_of_open_dmas()
1646 (fman->state->rev_info.minor == 0)) && in set_num_of_open_dmas()
1647 (fman->state->accumulated_num_of_open_dmas - in set_num_of_open_dmas()
1649 fman->state->dma_thresh_max_commq + 1)) { in set_num_of_open_dmas()
1650 dev_err(fman->dev, "%s: Requested num_of_open_dmas for fm%d exceeds DMA Command queue (%d)\n", in set_num_of_open_dmas()
1651 __func__, fman->state->fm_id, in set_num_of_open_dmas()
1652 fman->state->dma_thresh_max_commq + 1); in set_num_of_open_dmas()
1656 WARN_ON(fman->state->accumulated_num_of_open_dmas < current_val); in set_num_of_open_dmas()
1658 fman->state->accumulated_num_of_open_dmas -= current_val; in set_num_of_open_dmas()
1659 fman->state->accumulated_num_of_open_dmas += open_dmas; in set_num_of_open_dmas()
1661 if (fman->state->rev_info.major < 6) in set_num_of_open_dmas()
1663 (u8)(fman->state->accumulated_num_of_open_dmas + in set_num_of_open_dmas()
1664 fman->state->extra_open_dmas_pool_size); in set_num_of_open_dmas()
1685 static int fman_config(struct fman *fman) in fman_config() argument
1690 base_addr = fman->dts_params.base_addr; in fman_config()
1692 fman->state = kzalloc(sizeof(*fman->state), GFP_KERNEL); in fman_config()
1693 if (!fman->state) in fman_config()
1697 fman->cfg = kzalloc(sizeof(*fman->cfg), GFP_KERNEL); in fman_config()
1698 if (!fman->cfg) in fman_config()
1702 fman->muram = in fman_config()
1703 fman_muram_init(fman->dts_params.muram_res.start, in fman_config()
1704 resource_size(&fman->dts_params.muram_res)); in fman_config()
1705 if (!fman->muram) in fman_config()
1709 fman->state->fm_id = fman->dts_params.id; in fman_config()
1710 fman->state->fm_clk_freq = fman->dts_params.clk_freq; in fman_config()
1711 fman->state->qman_channel_base = fman->dts_params.qman_channel_base; in fman_config()
1712 fman->state->num_of_qman_channels = in fman_config()
1713 fman->dts_params.num_of_qman_channels; in fman_config()
1714 fman->state->res = fman->dts_params.res; in fman_config()
1715 fman->exception_cb = fman_exceptions; in fman_config()
1716 fman->bus_error_cb = fman_bus_error; in fman_config()
1717 fman->fpm_regs = base_addr + FPM_OFFSET; in fman_config()
1718 fman->bmi_regs = base_addr + BMI_OFFSET; in fman_config()
1719 fman->qmi_regs = base_addr + QMI_OFFSET; in fman_config()
1720 fman->dma_regs = base_addr + DMA_OFFSET; in fman_config()
1721 fman->hwp_regs = base_addr + HWP_OFFSET; in fman_config()
1722 fman->kg_regs = base_addr + KG_OFFSET; in fman_config()
1723 fman->base_addr = base_addr; in fman_config()
1725 spin_lock_init(&fman->spinlock); in fman_config()
1726 fman_defconfig(fman->cfg); in fman_config()
1728 fman->state->extra_fifo_pool_size = 0; in fman_config()
1729 fman->state->exceptions = (EX_DMA_BUS_ERROR | in fman_config()
1745 /* Read FMan revision for future use*/ in fman_config()
1746 fman_get_revision(fman, &fman->state->rev_info); in fman_config()
1748 err = fill_soc_specific_params(fman->state); in fman_config()
1753 if (fman->state->rev_info.major >= 6) in fman_config()
1754 fman->cfg->dma_aid_mode = FMAN_DMA_AID_OUT_PORT_ID; in fman_config()
1756 fman->cfg->qmi_def_tnums_thresh = fman->state->qmi_def_tnums_thresh; in fman_config()
1758 fman->state->total_num_of_tasks = in fman_config()
1759 (u8)DFLT_TOTAL_NUM_OF_TASKS(fman->state->rev_info.major, in fman_config()
1760 fman->state->rev_info.minor, in fman_config()
1761 fman->state->bmi_max_num_of_tasks); in fman_config()
1763 if (fman->state->rev_info.major < 6) { in fman_config()
1764 fman->cfg->dma_comm_qtsh_clr_emer = in fman_config()
1765 (u8)DFLT_DMA_COMM_Q_LOW(fman->state->rev_info.major, in fman_config()
1766 fman->state->dma_thresh_max_commq); in fman_config()
1768 fman->cfg->dma_comm_qtsh_asrt_emer = in fman_config()
1769 (u8)DFLT_DMA_COMM_Q_HIGH(fman->state->rev_info.major, in fman_config()
1770 fman->state->dma_thresh_max_commq); in fman_config()
1772 fman->cfg->dma_cam_num_of_entries = in fman_config()
1773 DFLT_DMA_CAM_NUM_OF_ENTRIES(fman->state->rev_info.major); in fman_config()
1775 fman->cfg->dma_read_buf_tsh_clr_emer = in fman_config()
1776 DFLT_DMA_READ_INT_BUF_LOW(fman->state->dma_thresh_max_buf); in fman_config()
1778 fman->cfg->dma_read_buf_tsh_asrt_emer = in fman_config()
1779 DFLT_DMA_READ_INT_BUF_HIGH(fman->state->dma_thresh_max_buf); in fman_config()
1781 fman->cfg->dma_write_buf_tsh_clr_emer = in fman_config()
1782 DFLT_DMA_WRITE_INT_BUF_LOW(fman->state->dma_thresh_max_buf); in fman_config()
1784 fman->cfg->dma_write_buf_tsh_asrt_emer = in fman_config()
1785 DFLT_DMA_WRITE_INT_BUF_HIGH(fman->state->dma_thresh_max_buf); in fman_config()
1787 fman->cfg->dma_axi_dbg_num_of_beats = in fman_config()
1794 kfree(fman->cfg); in fman_config()
1796 kfree(fman->state); in fman_config()
1798 kfree(fman); in fman_config()
1802 static int fman_reset(struct fman *fman) in fman_reset() argument
1807 if (fman->state->rev_info.major < 6) { in fman_reset()
1808 iowrite32be(FPM_RSTC_FM_RESET, &fman->fpm_regs->fm_rstc); in fman_reset()
1813 } while (((ioread32be(&fman->fpm_regs->fm_rstc)) & in fman_reset()
1830 dev_err(fman->dev, "%s: Couldn't find guts node\n", in fman_reset()
1837 dev_err(fman->dev, "%s: Couldn't map %pOF regs\n", in fman_reset()
1845 if (fman->dts_params.id == 0) in fman_reset()
1854 /* Perform FMan reset */ in fman_reset()
1855 iowrite32be(FPM_RSTC_FM_RESET, &fman->fpm_regs->fm_rstc); in fman_reset()
1861 } while (((ioread32be(&fman->fpm_regs->fm_rstc)) & in fman_reset()
1886 dev_dbg(fman->dev, "%s: Didn't perform FManV3 reset due to Errata A007273!\n", in fman_reset()
1894 static int fman_init(struct fman *fman) in fman_init() argument
1899 if (is_init_done(fman->cfg)) in fman_init()
1902 fman->state->count1_micro_bit = FM_TIMESTAMP_1_USEC_BIT; in fman_init()
1904 cfg = fman->cfg; in fman_init()
1907 if (fman->state->rev_info.major < 6) in fman_init()
1908 fman->state->exceptions &= ~FMAN_EX_BMI_DISPATCH_RAM_ECC; in fman_init()
1910 if (fman->state->rev_info.major >= 6) in fman_init()
1911 fman->state->exceptions &= ~FMAN_EX_QMI_SINGLE_ECC; in fman_init()
1914 memset_io((void __iomem *)(fman->base_addr + CGP_OFFSET), 0, in fman_init()
1915 fman->state->fm_port_num_of_cg); in fman_init()
1917 /* Save LIODN info before FMan reset in fman_init()
1923 fman->liodn_offset[i] = in fman_init()
1924 ioread32be(&fman->bmi_regs->fmbm_spliodn[i - 1]); in fman_init()
1927 liodn_base = ioread32be(&fman->dma_regs->fmdmplr[i / 2]); in fman_init()
1936 fman->liodn_base[i] = liodn_base; in fman_init()
1939 err = fman_reset(fman); in fman_init()
1943 if (ioread32be(&fman->qmi_regs->fmqm_gs) & QMI_GS_HALT_NOT_BUSY) { in fman_init()
1944 resume(fman->fpm_regs); in fman_init()
1949 } while (((ioread32be(&fman->qmi_regs->fmqm_gs)) & in fman_init()
1952 dev_warn(fman->dev, "%s: QMI is in halt not busy state\n", in fman_init()
1956 if (clear_iram(fman) != 0) in fman_init()
1959 cfg->exceptions = fman->state->exceptions; in fman_init()
1963 err = dma_init(fman); in fman_init()
1965 free_init_resources(fman); in fman_init()
1970 fpm_init(fman->fpm_regs, fman->cfg); in fman_init()
1974 fman->fifo_offset = fman_muram_alloc(fman->muram, in fman_init()
1975 fman->state->total_fifo_size); in fman_init()
1976 if (IS_ERR_VALUE(fman->fifo_offset)) { in fman_init()
1977 free_init_resources(fman); in fman_init()
1978 dev_err(fman->dev, "%s: MURAM alloc for BMI FIFO failed\n", in fman_init()
1983 cfg->fifo_base_addr = fman->fifo_offset; in fman_init()
1984 cfg->total_fifo_size = fman->state->total_fifo_size; in fman_init()
1985 cfg->total_num_of_tasks = fman->state->total_num_of_tasks; in fman_init()
1986 cfg->clk_freq = fman->state->fm_clk_freq; in fman_init()
1989 bmi_init(fman->bmi_regs, fman->cfg); in fman_init()
1992 qmi_init(fman->qmi_regs, fman->cfg); in fman_init()
1995 hwp_init(fman->hwp_regs); in fman_init()
1998 fman->keygen = keygen_init(fman->kg_regs); in fman_init()
1999 if (!fman->keygen) in fman_init()
2002 err = enable(fman, cfg); in fman_init()
2006 enable_time_stamp(fman); in fman_init()
2008 kfree(fman->cfg); in fman_init()
2009 fman->cfg = NULL; in fman_init()
2014 static int fman_set_exception(struct fman *fman, in fman_set_exception() argument
2019 if (!is_init_done(fman->cfg)) in fman_set_exception()
2025 fman->state->exceptions |= bit_mask; in fman_set_exception()
2027 fman->state->exceptions &= ~bit_mask; in fman_set_exception()
2029 dev_err(fman->dev, "%s: Undefined exception (%d)\n", in fman_set_exception()
2034 return set_exception(fman, exception, enable); in fman_set_exception()
2039 * @fman: A Pointer to FMan device
2046 * Used to register an event handler to be processed by FMan
2050 void fman_register_intr(struct fman *fman, enum fman_event_modules module, in fman_register_intr() argument
2060 fman->intr_mng[event].isr_cb = isr_cb; in fman_register_intr()
2061 fman->intr_mng[event].src_handle = src_arg; in fman_register_intr()
2067 * @fman: A Pointer to FMan device
2072 * Used to unregister an event handler to be processed by FMan
2076 void fman_unregister_intr(struct fman *fman, enum fman_event_modules module, in fman_unregister_intr() argument
2084 fman->intr_mng[event].isr_cb = NULL; in fman_unregister_intr()
2085 fman->intr_mng[event].src_handle = NULL; in fman_unregister_intr()
2091 * @fman: A Pointer to FMan device
2094 * Used by FMan Port to pass parameters to the FMan
2098 int fman_set_port_params(struct fman *fman, in fman_set_port_params() argument
2105 spin_lock_irqsave(&fman->spinlock, flags); in fman_set_port_params()
2107 err = set_num_of_tasks(fman, port_params->port_id, in fman_set_port_params()
2118 fman->state->accumulated_num_of_deq_tnums += in fman_set_port_params()
2120 enq_th = (ioread32be(&fman->qmi_regs->fmqm_gc) & in fman_set_port_params()
2125 if (enq_th >= (fman->state->qmi_max_num_of_tnums - in fman_set_port_params()
2126 fman->state->accumulated_num_of_deq_tnums)) { in fman_set_port_params()
2128 fman->state->qmi_max_num_of_tnums - in fman_set_port_params()
2129 fman->state->accumulated_num_of_deq_tnums - 1; in fman_set_port_params()
2131 reg = ioread32be(&fman->qmi_regs->fmqm_gc); in fman_set_port_params()
2134 iowrite32be(reg, &fman->qmi_regs->fmqm_gc); in fman_set_port_params()
2137 deq_th = ioread32be(&fman->qmi_regs->fmqm_gc) & in fman_set_port_params()
2142 * (fman->state->qmi_max_num_of_tnums-1). in fman_set_port_params()
2144 if ((deq_th <= fman->state->accumulated_num_of_deq_tnums) && in fman_set_port_params()
2145 (deq_th < fman->state->qmi_max_num_of_tnums - 1)) { in fman_set_port_params()
2146 deq_th = fman->state->accumulated_num_of_deq_tnums + 1; in fman_set_port_params()
2147 reg = ioread32be(&fman->qmi_regs->fmqm_gc); in fman_set_port_params()
2150 iowrite32be(reg, &fman->qmi_regs->fmqm_gc); in fman_set_port_params()
2154 err = set_size_of_fifo(fman, port_params->port_id, in fman_set_port_params()
2160 err = set_num_of_open_dmas(fman, port_params->port_id, in fman_set_port_params()
2166 set_port_liodn(fman, port_id, fman->liodn_base[port_id], in fman_set_port_params()
2167 fman->liodn_offset[port_id]); in fman_set_port_params()
2169 if (fman->state->rev_info.major < 6) in fman_set_port_params()
2170 set_port_order_restoration(fman->fpm_regs, port_id); in fman_set_port_params()
2172 mac_id = hw_port_id_to_sw_port_id(fman->state->rev_info.major, port_id); in fman_set_port_params()
2174 if (port_params->max_frame_length >= fman->state->mac_mfl[mac_id]) { in fman_set_port_params()
2175 fman->state->port_mfl[mac_id] = port_params->max_frame_length; in fman_set_port_params()
2177 dev_warn(fman->dev, "%s: Port (%d) max_frame_length is smaller than MAC (%d) current MTU\n", in fman_set_port_params()
2183 spin_unlock_irqrestore(&fman->spinlock, flags); in fman_set_port_params()
2188 spin_unlock_irqrestore(&fman->spinlock, flags); in fman_set_port_params()
2195 * @fman: A Pointer to FMan device
2202 int fman_reset_mac(struct fman *fman, u8 mac_id) in fman_reset_mac() argument
2204 struct fman_fpm_regs __iomem *fpm_rg = fman->fpm_regs; in fman_reset_mac()
2207 if (fman->state->rev_info.major >= 6) { in fman_reset_mac()
2208 dev_err(fman->dev, "%s: FMan MAC reset no available for FMan V3!\n", in fman_reset_mac()
2246 dev_warn(fman->dev, "%s: Illegal MAC Id [%d]\n", in fman_reset_mac()
2265 * @fman: A Pointer to FMan device
2269 * Set maximum frame length of specific MAC in FMan driver
2273 int fman_set_mac_max_frame(struct fman *fman, u8 mac_id, u16 mfl) in fman_set_mac_max_frame() argument
2278 if ((!fman->state->port_mfl[mac_id]) || in fman_set_mac_max_frame()
2279 (mfl <= fman->state->port_mfl[mac_id])) { in fman_set_mac_max_frame()
2280 fman->state->mac_mfl[mac_id] = mfl; in fman_set_mac_max_frame()
2282 dev_warn(fman->dev, "%s: MAC max_frame_length is larger than Port max_frame_length\n", in fman_set_mac_max_frame()
2292 * @fman: A Pointer to FMan device
2294 * Get FMan clock frequency
2296 * Return: FMan clock frequency
2298 u16 fman_get_clock_freq(struct fman *fman) in fman_get_clock_freq() argument
2300 return fman->state->fm_clk_freq; in fman_get_clock_freq()
2305 * @fman: A Pointer to FMan device
2307 * Get FMan maximum FIFO size
2309 * Return: FMan Maximum FIFO size
2311 u32 fman_get_bmi_max_fifo_size(struct fman *fman) in fman_get_bmi_max_fifo_size() argument
2313 return fman->state->bmi_max_fifo_size; in fman_get_bmi_max_fifo_size()
2319 * @fman: - Pointer to the FMan module
2328 void fman_get_revision(struct fman *fman, struct fman_rev_info *rev_info) in fman_get_revision() argument
2332 tmp = ioread32be(&fman->fpm_regs->fm_ip_rev_1); in fman_get_revision()
2341 * @fman: A Pointer to FMan device
2348 u32 fman_get_qman_channel_id(struct fman *fman, u32 port_id) in fman_get_qman_channel_id() argument
2352 if (fman->state->rev_info.major >= 6) { in fman_get_qman_channel_id()
2358 for (i = 0; i < fman->state->num_of_qman_channels; i++) { in fman_get_qman_channel_id()
2368 for (i = 0; i < fman->state->num_of_qman_channels; i++) { in fman_get_qman_channel_id()
2374 if (i == fman->state->num_of_qman_channels) in fman_get_qman_channel_id()
2377 return fman->state->qman_channel_base + i; in fman_get_qman_channel_id()
2383 * @fman: A Pointer to FMan device
2385 * Get FMan memory region
2387 * Return: A structure with FMan memory region information
2389 struct resource *fman_get_mem_region(struct fman *fman) in fman_get_mem_region() argument
2391 return fman->state->res; in fman_get_mem_region()
2407 * FMan is instructed to allocate, on the Rx path, this amount of
2485 * @fm_dev: FMan OF device pointer
2487 * Bind to a specific FMan device.
2491 * Return: A pointer to the FMan device
2493 struct fman *fman_bind(struct device *fm_dev) in fman_bind()
2495 return (struct fman *)(dev_get_drvdata(get_device(fm_dev))); in fman_bind()
2509 struct fman *fman = (struct fman *)handle; in fman_err_irq() local
2514 if (!is_init_done(fman->cfg)) in fman_err_irq()
2517 fpm_rg = fman->fpm_regs; in fman_err_irq()
2525 single_ret = bmi_err_event(fman); in fman_err_irq()
2530 single_ret = qmi_err_event(fman); in fman_err_irq()
2535 single_ret = fpm_err_event(fman); in fman_err_irq()
2540 single_ret = dma_err_event(fman); in fman_err_irq()
2545 single_ret = muram_err_intr(fman); in fman_err_irq()
2552 single_ret = call_mac_isr(fman, FMAN_EV_ERR_MAC0 + 0); in fman_err_irq()
2557 single_ret = call_mac_isr(fman, FMAN_EV_ERR_MAC0 + 1); in fman_err_irq()
2562 single_ret = call_mac_isr(fman, FMAN_EV_ERR_MAC0 + 2); in fman_err_irq()
2567 single_ret = call_mac_isr(fman, FMAN_EV_ERR_MAC0 + 3); in fman_err_irq()
2572 single_ret = call_mac_isr(fman, FMAN_EV_ERR_MAC0 + 4); in fman_err_irq()
2577 single_ret = call_mac_isr(fman, FMAN_EV_ERR_MAC0 + 5); in fman_err_irq()
2582 single_ret = call_mac_isr(fman, FMAN_EV_ERR_MAC0 + 6); in fman_err_irq()
2587 single_ret = call_mac_isr(fman, FMAN_EV_ERR_MAC0 + 7); in fman_err_irq()
2592 single_ret = call_mac_isr(fman, FMAN_EV_ERR_MAC0 + 8); in fman_err_irq()
2597 single_ret = call_mac_isr(fman, FMAN_EV_ERR_MAC0 + 9); in fman_err_irq()
2607 struct fman *fman = (struct fman *)handle; in fman_irq() local
2612 if (!is_init_done(fman->cfg)) in fman_irq()
2615 fpm_rg = fman->fpm_regs; in fman_irq()
2623 single_ret = qmi_event(fman); in fman_irq()
2630 single_ret = call_mac_isr(fman, FMAN_EV_MAC0 + 0); in fman_irq()
2635 single_ret = call_mac_isr(fman, FMAN_EV_MAC0 + 1); in fman_irq()
2640 single_ret = call_mac_isr(fman, FMAN_EV_MAC0 + 2); in fman_irq()
2645 single_ret = call_mac_isr(fman, FMAN_EV_MAC0 + 3); in fman_irq()
2650 single_ret = call_mac_isr(fman, FMAN_EV_MAC0 + 4); in fman_irq()
2655 single_ret = call_mac_isr(fman, FMAN_EV_MAC0 + 5); in fman_irq()
2660 single_ret = call_mac_isr(fman, FMAN_EV_MAC0 + 6); in fman_irq()
2665 single_ret = call_mac_isr(fman, FMAN_EV_MAC0 + 7); in fman_irq()
2670 single_ret = call_mac_isr(fman, FMAN_EV_MAC0 + 8); in fman_irq()
2675 single_ret = call_mac_isr(fman, FMAN_EV_MAC0 + 9); in fman_irq()
2685 .compatible = "fsl,fman-muram"},
2690 static struct fman *read_dts_node(struct platform_device *of_dev) in read_dts_node()
2692 struct fman *fman; in read_dts_node() local
2702 fman = kzalloc(sizeof(*fman), GFP_KERNEL); in read_dts_node()
2703 if (!fman) in read_dts_node()
2714 fman->dts_params.id = (u8)val; in read_dts_node()
2726 fman->dts_params.err_irq = err; in read_dts_node()
2732 dev_err(&of_dev->dev, "%s: Can't get FMan memory resource\n", in read_dts_node()
2744 __func__, fman->dts_params.id); in read_dts_node()
2752 __func__, fman->dts_params.id); in read_dts_node()
2756 fman->dts_params.clk_freq = DIV_ROUND_UP(clk_rate, 1000000); in read_dts_node()
2765 fman->dts_params.qman_channel_base = range[0]; in read_dts_node()
2766 fman->dts_params.num_of_qman_channels = range[1]; in read_dts_node()
2778 &fman->dts_params.muram_res); in read_dts_node()
2789 "fman", fman); in read_dts_node()
2796 if (fman->dts_params.err_irq != 0) { in read_dts_node()
2797 err = devm_request_irq(&of_dev->dev, fman->dts_params.err_irq, in read_dts_node()
2799 "fman-err", fman); in read_dts_node()
2802 __func__, fman->dts_params.err_irq, err); in read_dts_node()
2807 fman->dts_params.res = in read_dts_node()
2809 mem_size, "fman"); in read_dts_node()
2810 if (!fman->dts_params.res) { in read_dts_node()
2817 fman->dts_params.base_addr = in read_dts_node()
2819 if (!fman->dts_params.base_addr) { in read_dts_node()
2825 fman->dev = &of_dev->dev; in read_dts_node()
2839 return fman; in read_dts_node()
2844 kfree(fman); in read_dts_node()
2850 struct fman *fman; in fman_probe() local
2856 fman = read_dts_node(of_dev); in fman_probe()
2857 if (IS_ERR(fman)) in fman_probe()
2858 return PTR_ERR(fman); in fman_probe()
2860 err = fman_config(fman); in fman_probe()
2862 dev_err(dev, "%s: FMan config failed\n", __func__); in fman_probe()
2866 if (fman_init(fman) != 0) { in fman_probe()
2867 dev_err(dev, "%s: FMan init failed\n", __func__); in fman_probe()
2871 if (fman->dts_params.err_irq == 0) { in fman_probe()
2872 fman_set_exception(fman, FMAN_EX_DMA_BUS_ERROR, false); in fman_probe()
2873 fman_set_exception(fman, FMAN_EX_DMA_READ_ECC, false); in fman_probe()
2874 fman_set_exception(fman, FMAN_EX_DMA_SYSTEM_WRITE_ECC, false); in fman_probe()
2875 fman_set_exception(fman, FMAN_EX_DMA_FM_WRITE_ECC, false); in fman_probe()
2876 fman_set_exception(fman, FMAN_EX_DMA_SINGLE_PORT_ECC, false); in fman_probe()
2877 fman_set_exception(fman, FMAN_EX_FPM_STALL_ON_TASKS, false); in fman_probe()
2878 fman_set_exception(fman, FMAN_EX_FPM_SINGLE_ECC, false); in fman_probe()
2879 fman_set_exception(fman, FMAN_EX_FPM_DOUBLE_ECC, false); in fman_probe()
2880 fman_set_exception(fman, FMAN_EX_QMI_SINGLE_ECC, false); in fman_probe()
2881 fman_set_exception(fman, FMAN_EX_QMI_DOUBLE_ECC, false); in fman_probe()
2882 fman_set_exception(fman, in fman_probe()
2884 fman_set_exception(fman, FMAN_EX_BMI_LIST_RAM_ECC, false); in fman_probe()
2885 fman_set_exception(fman, FMAN_EX_BMI_STORAGE_PROFILE_ECC, in fman_probe()
2887 fman_set_exception(fman, FMAN_EX_BMI_STATISTICS_RAM_ECC, false); in fman_probe()
2888 fman_set_exception(fman, FMAN_EX_BMI_DISPATCH_RAM_ECC, false); in fman_probe()
2891 dev_set_drvdata(dev, fman); in fman_probe()
2893 dev_dbg(dev, "FMan%d probed\n", fman->dts_params.id); in fman_probe()
2900 .compatible = "fsl,fman"},
2908 .name = "fsl-fman",
2918 pr_debug("FSL DPAA FMan driver\n"); in fman_load()