Lines Matching refs:gpriv

87 #define RCANFD_GERFL_ERR(gpriv, x)	((x) & (RCANFD_GERFL_EEF1 |\  argument
89 (gpriv->fdmode ?\
500 struct rcar_canfd_global *gpriv; /* Controller reference */ member
627 static int rcar_canfd_reset_controller(struct rcar_canfd_global *gpriv) in rcar_canfd_reset_controller() argument
635 err = readl_poll_timeout((gpriv->base + RCANFD_GSTS), sts, in rcar_canfd_reset_controller()
638 dev_dbg(&gpriv->pdev->dev, "global raminit failed\n"); in rcar_canfd_reset_controller()
643 rcar_canfd_clear_bit(gpriv->base, RCANFD_GCTR, RCANFD_GCTR_GSLPR); in rcar_canfd_reset_controller()
644 rcar_canfd_update_bit(gpriv->base, RCANFD_GCTR, in rcar_canfd_reset_controller()
648 err = readl_poll_timeout((gpriv->base + RCANFD_GSTS), sts, in rcar_canfd_reset_controller()
651 dev_dbg(&gpriv->pdev->dev, "global reset failed\n"); in rcar_canfd_reset_controller()
656 rcar_canfd_write(gpriv->base, RCANFD_GERFL, 0x0); in rcar_canfd_reset_controller()
659 if (gpriv->fdmode) in rcar_canfd_reset_controller()
660 rcar_canfd_set_bit(gpriv->base, RCANFD_GRMCFG, in rcar_canfd_reset_controller()
663 rcar_canfd_clear_bit(gpriv->base, RCANFD_GRMCFG, in rcar_canfd_reset_controller()
667 for_each_set_bit(ch, &gpriv->channels_mask, RCANFD_NUM_CHANNELS) { in rcar_canfd_reset_controller()
668 rcar_canfd_clear_bit(gpriv->base, in rcar_canfd_reset_controller()
671 rcar_canfd_update_bit(gpriv->base, RCANFD_CCTR(ch), in rcar_canfd_reset_controller()
676 err = readl_poll_timeout((gpriv->base + RCANFD_CSTS(ch)), sts, in rcar_canfd_reset_controller()
680 dev_dbg(&gpriv->pdev->dev, in rcar_canfd_reset_controller()
688 static void rcar_canfd_configure_controller(struct rcar_canfd_global *gpriv) in rcar_canfd_configure_controller() argument
697 if (gpriv->fdmode) in rcar_canfd_configure_controller()
702 if (gpriv->fcan != RCANFD_CANFDCLK) in rcar_canfd_configure_controller()
705 rcar_canfd_set_bit(gpriv->base, RCANFD_GCFG, cfg); in rcar_canfd_configure_controller()
708 for_each_set_bit(ch, &gpriv->channels_mask, RCANFD_NUM_CHANNELS) { in rcar_canfd_configure_controller()
709 rcar_canfd_set_bit(gpriv->base, RCANFD_CCTR(ch), in rcar_canfd_configure_controller()
711 rcar_canfd_update_bit(gpriv->base, RCANFD_CCTR(ch), in rcar_canfd_configure_controller()
717 static void rcar_canfd_configure_afl_rules(struct rcar_canfd_global *gpriv, in rcar_canfd_configure_afl_rules() argument
728 cfg = rcar_canfd_read(gpriv->base, RCANFD_GAFLCFG0); in rcar_canfd_configure_afl_rules()
734 rcar_canfd_set_bit(gpriv->base, RCANFD_GAFLECTR, in rcar_canfd_configure_afl_rules()
739 rcar_canfd_set_bit(gpriv->base, RCANFD_GAFLCFG0, in rcar_canfd_configure_afl_rules()
741 if (gpriv->fdmode) in rcar_canfd_configure_afl_rules()
747 rcar_canfd_write(gpriv->base, RCANFD_GAFLID(offset, start), 0); in rcar_canfd_configure_afl_rules()
749 rcar_canfd_write(gpriv->base, RCANFD_GAFLM(offset, start), 0); in rcar_canfd_configure_afl_rules()
751 rcar_canfd_write(gpriv->base, RCANFD_GAFLP0(offset, start), 0); in rcar_canfd_configure_afl_rules()
753 rcar_canfd_write(gpriv->base, RCANFD_GAFLP1(offset, start), in rcar_canfd_configure_afl_rules()
757 rcar_canfd_clear_bit(gpriv->base, in rcar_canfd_configure_afl_rules()
761 static void rcar_canfd_configure_rx(struct rcar_canfd_global *gpriv, u32 ch) in rcar_canfd_configure_rx() argument
771 if (gpriv->fdmode) in rcar_canfd_configure_rx()
778 rcar_canfd_write(gpriv->base, RCANFD_RFCC(ridx), cfg); in rcar_canfd_configure_rx()
781 static void rcar_canfd_configure_tx(struct rcar_canfd_global *gpriv, u32 ch) in rcar_canfd_configure_tx() argument
795 if (gpriv->fdmode) in rcar_canfd_configure_tx()
803 rcar_canfd_write(gpriv->base, RCANFD_CFCC(ch, RCANFD_CFFIFO_IDX), cfg); in rcar_canfd_configure_tx()
805 if (gpriv->fdmode) in rcar_canfd_configure_tx()
807 rcar_canfd_write(gpriv->base, in rcar_canfd_configure_tx()
811 static void rcar_canfd_enable_global_interrupts(struct rcar_canfd_global *gpriv) in rcar_canfd_enable_global_interrupts() argument
816 rcar_canfd_write(gpriv->base, RCANFD_GERFL, 0); in rcar_canfd_enable_global_interrupts()
820 if (gpriv->fdmode) in rcar_canfd_enable_global_interrupts()
823 rcar_canfd_set_bit(gpriv->base, RCANFD_GCTR, ctr); in rcar_canfd_enable_global_interrupts()
827 *gpriv) in rcar_canfd_disable_global_interrupts()
830 rcar_canfd_write(gpriv->base, RCANFD_GCTR, 0); in rcar_canfd_disable_global_interrupts()
833 rcar_canfd_write(gpriv->base, RCANFD_GERFL, 0); in rcar_canfd_disable_global_interrupts()
872 struct rcar_canfd_global *gpriv = priv->gpriv; in rcar_canfd_global_error() local
906 if (gpriv->fdmode && gerfl & RCANFD_GERFL_CMPOF) { in rcar_canfd_global_error()
1079 struct rcar_canfd_global *gpriv = dev_id; in rcar_canfd_global_interrupt() local
1088 for_each_set_bit(ch, &gpriv->channels_mask, RCANFD_NUM_CHANNELS) { in rcar_canfd_global_interrupt()
1089 priv = gpriv->ch[ch]; in rcar_canfd_global_interrupt()
1095 if (unlikely(RCANFD_GERFL_ERR(gpriv, gerfl))) in rcar_canfd_global_interrupt()
1148 struct rcar_canfd_global *gpriv = dev_id; in rcar_canfd_channel_interrupt() local
1155 for_each_set_bit(ch, &gpriv->channels_mask, RCANFD_NUM_CHANNELS) { in rcar_canfd_channel_interrupt()
1156 priv = gpriv->ch[ch]; in rcar_canfd_channel_interrupt()
1268 struct rcar_canfd_global *gpriv = priv->gpriv; in rcar_canfd_open() local
1272 err = clk_prepare_enable(gpriv->can_clk); in rcar_canfd_open()
1295 clk_disable_unprepare(gpriv->can_clk); in rcar_canfd_open()
1331 struct rcar_canfd_global *gpriv = priv->gpriv; in rcar_canfd_close() local
1336 clk_disable_unprepare(gpriv->can_clk); in rcar_canfd_close()
1559 static int rcar_canfd_channel_probe(struct rcar_canfd_global *gpriv, u32 ch, in rcar_canfd_channel_probe() argument
1562 struct platform_device *pdev = gpriv->pdev; in rcar_canfd_channel_probe()
1578 priv->base = gpriv->base; in rcar_canfd_channel_probe()
1583 if (gpriv->fdmode) { in rcar_canfd_channel_probe()
1599 priv->gpriv = gpriv; in rcar_canfd_channel_probe()
1612 gpriv->ch[priv->channel] = priv; in rcar_canfd_channel_probe()
1623 static void rcar_canfd_channel_remove(struct rcar_canfd_global *gpriv, u32 ch) in rcar_canfd_channel_remove() argument
1625 struct rcar_canfd_channel *priv = gpriv->ch[ch]; in rcar_canfd_channel_remove()
1639 struct rcar_canfd_global *gpriv; in rcar_canfd_probe() local
1671 gpriv = devm_kzalloc(&pdev->dev, sizeof(*gpriv), GFP_KERNEL); in rcar_canfd_probe()
1672 if (!gpriv) { in rcar_canfd_probe()
1676 gpriv->pdev = pdev; in rcar_canfd_probe()
1677 gpriv->channels_mask = channels_mask; in rcar_canfd_probe()
1678 gpriv->fdmode = fdmode; in rcar_canfd_probe()
1681 gpriv->clkp = devm_clk_get(&pdev->dev, "fck"); in rcar_canfd_probe()
1682 if (IS_ERR(gpriv->clkp)) { in rcar_canfd_probe()
1683 err = PTR_ERR(gpriv->clkp); in rcar_canfd_probe()
1692 gpriv->can_clk = devm_clk_get(&pdev->dev, "can_clk"); in rcar_canfd_probe()
1693 if (IS_ERR(gpriv->can_clk) || (clk_get_rate(gpriv->can_clk) == 0)) { in rcar_canfd_probe()
1694 gpriv->can_clk = devm_clk_get(&pdev->dev, "canfd"); in rcar_canfd_probe()
1695 if (IS_ERR(gpriv->can_clk)) { in rcar_canfd_probe()
1696 err = PTR_ERR(gpriv->can_clk); in rcar_canfd_probe()
1701 gpriv->fcan = RCANFD_CANFDCLK; in rcar_canfd_probe()
1704 gpriv->fcan = RCANFD_EXTCLK; in rcar_canfd_probe()
1706 fcan_freq = clk_get_rate(gpriv->can_clk); in rcar_canfd_probe()
1708 if (gpriv->fcan == RCANFD_CANFDCLK) in rcar_canfd_probe()
1718 gpriv->base = addr; in rcar_canfd_probe()
1723 "canfd.chn", gpriv); in rcar_canfd_probe()
1731 "canfd.gbl", gpriv); in rcar_canfd_probe()
1739 err = clk_prepare_enable(gpriv->clkp); in rcar_canfd_probe()
1746 err = rcar_canfd_reset_controller(gpriv); in rcar_canfd_probe()
1753 rcar_canfd_configure_controller(gpriv); in rcar_canfd_probe()
1756 for_each_set_bit(ch, &gpriv->channels_mask, RCANFD_NUM_CHANNELS) { in rcar_canfd_probe()
1758 rcar_canfd_configure_rx(gpriv, ch); in rcar_canfd_probe()
1761 rcar_canfd_configure_tx(gpriv, ch); in rcar_canfd_probe()
1764 rcar_canfd_configure_afl_rules(gpriv, ch); in rcar_canfd_probe()
1768 rcar_canfd_enable_global_interrupts(gpriv); in rcar_canfd_probe()
1771 rcar_canfd_update_bit(gpriv->base, RCANFD_GCTR, RCANFD_GCTR_GMDC_MASK, in rcar_canfd_probe()
1775 err = readl_poll_timeout((gpriv->base + RCANFD_GSTS), sts, in rcar_canfd_probe()
1782 for_each_set_bit(ch, &gpriv->channels_mask, RCANFD_NUM_CHANNELS) { in rcar_canfd_probe()
1783 err = rcar_canfd_channel_probe(gpriv, ch, fcan_freq); in rcar_canfd_probe()
1788 platform_set_drvdata(pdev, gpriv); in rcar_canfd_probe()
1790 gpriv->fcan, gpriv->fdmode); in rcar_canfd_probe()
1794 for_each_set_bit(ch, &gpriv->channels_mask, RCANFD_NUM_CHANNELS) in rcar_canfd_probe()
1795 rcar_canfd_channel_remove(gpriv, ch); in rcar_canfd_probe()
1797 rcar_canfd_disable_global_interrupts(gpriv); in rcar_canfd_probe()
1799 clk_disable_unprepare(gpriv->clkp); in rcar_canfd_probe()
1806 struct rcar_canfd_global *gpriv = platform_get_drvdata(pdev); in rcar_canfd_remove() local
1809 rcar_canfd_reset_controller(gpriv); in rcar_canfd_remove()
1810 rcar_canfd_disable_global_interrupts(gpriv); in rcar_canfd_remove()
1812 for_each_set_bit(ch, &gpriv->channels_mask, RCANFD_NUM_CHANNELS) { in rcar_canfd_remove()
1813 rcar_canfd_disable_channel_interrupts(gpriv->ch[ch]); in rcar_canfd_remove()
1814 rcar_canfd_channel_remove(gpriv, ch); in rcar_canfd_remove()
1818 rcar_canfd_set_bit(gpriv->base, RCANFD_GCTR, RCANFD_GCTR_GSLPR); in rcar_canfd_remove()
1819 clk_disable_unprepare(gpriv->clkp); in rcar_canfd_remove()