Lines Matching refs:gpriv
84 #define RCANFD_GERFL_ERR(gpriv, x) \ argument
85 ((x) & (reg_gen4(gpriv, RCANFD_GERFL_EEF0_7, \
88 ((gpriv)->fdmode ? RCANFD_GERFL_CMPOF : 0)))
93 #define RCANFD_GAFLCFG_SETRNC(gpriv, n, x) \ argument
94 (((x) & reg_gen4(gpriv, 0x1ff, 0xff)) << \
95 (reg_gen4(gpriv, 16, 24) - ((n) & 1) * reg_gen4(gpriv, 16, 8)))
97 #define RCANFD_GAFLCFG_GETRNC(gpriv, n, x) \ argument
98 (((x) >> (reg_gen4(gpriv, 16, 24) - ((n) & 1) * reg_gen4(gpriv, 16, 8))) & \
99 reg_gen4(gpriv, 0x1ff, 0xff))
103 #define RCANFD_GAFLECTR_AFLPN(gpriv, x) ((x) & reg_gen4(gpriv, 0x7f, 0x1f)) argument
120 #define RCANFD_NCFG_NTSEG2(gpriv, x) \ argument
121 (((x) & reg_gen4(gpriv, 0x7f, 0x1f)) << reg_gen4(gpriv, 25, 24))
123 #define RCANFD_NCFG_NTSEG1(gpriv, x) \ argument
124 (((x) & reg_gen4(gpriv, 0xff, 0x7f)) << reg_gen4(gpriv, 17, 16))
126 #define RCANFD_NCFG_NSJW(gpriv, x) \ argument
127 (((x) & reg_gen4(gpriv, 0x7f, 0x1f)) << reg_gen4(gpriv, 10, 11))
189 #define RCANFD_DCFG_DSJW(gpriv, x) (((x) & reg_gen4(gpriv, 0xf, 0x7)) << 24) argument
191 #define RCANFD_DCFG_DTSEG2(gpriv, x) \ argument
192 (((x) & reg_gen4(gpriv, 0x0f, 0x7)) << reg_gen4(gpriv, 16, 20))
194 #define RCANFD_DCFG_DTSEG1(gpriv, x) \ argument
195 (((x) & reg_gen4(gpriv, 0x1f, 0xf)) << reg_gen4(gpriv, 8, 16))
236 #define RCANFD_CFCC_CFTML(gpriv, x) \ argument
237 (((x) & reg_gen4(gpriv, 0x1f, 0xf)) << reg_gen4(gpriv, 16, 20))
238 #define RCANFD_CFCC_CFM(gpriv, x) (((x) & 0x3) << reg_gen4(gpriv, 8, 16)) argument
240 #define RCANFD_CFCC_CFDC(gpriv, x) (((x) & 0x7) << reg_gen4(gpriv, 21, 8)) argument
308 #define RCANFD_RFCC(gpriv, x) (reg_gen4(gpriv, 0x00c0, 0x00b8) + (0x04 * (x))) argument
310 #define RCANFD_RFSTS(gpriv, x) (RCANFD_RFCC(gpriv, x) + 0x20) argument
312 #define RCANFD_RFPCTR(gpriv, x) (RCANFD_RFCC(gpriv, x) + 0x40) argument
317 #define RCANFD_CFCC(gpriv, ch, idx) \ argument
318 (reg_gen4(gpriv, 0x0120, 0x0118) + (0x0c * (ch)) + (0x04 * (idx)))
320 #define RCANFD_CFSTS(gpriv, ch, idx) \ argument
321 (reg_gen4(gpriv, 0x01e0, 0x0178) + (0x0c * (ch)) + (0x04 * (idx)))
323 #define RCANFD_CFPCTR(gpriv, ch, idx) \ argument
324 (reg_gen4(gpriv, 0x0240, 0x01d8) + (0x0c * (ch)) + (0x04 * (idx)))
440 #define RCANFD_F_DCFG(gpriv, m) (reg_gen4(gpriv, 0x1400, 0x0500) + (0x20 * (m))) argument
456 #define RCANFD_F_RFOFFSET(gpriv) reg_gen4(gpriv, 0x6000, 0x3000) argument
457 #define RCANFD_F_RFID(gpriv, x) (RCANFD_F_RFOFFSET(gpriv) + (0x80 * (x))) argument
458 #define RCANFD_F_RFPTR(gpriv, x) (RCANFD_F_RFOFFSET(gpriv) + 0x04 + (0x80 * (x))) argument
459 #define RCANFD_F_RFFDSTS(gpriv, x) (RCANFD_F_RFOFFSET(gpriv) + 0x08 + (0x80 * (x))) argument
460 #define RCANFD_F_RFDF(gpriv, x, df) \ argument
461 (RCANFD_F_RFOFFSET(gpriv) + 0x0c + (0x80 * (x)) + (0x04 * (df)))
464 #define RCANFD_F_CFOFFSET(gpriv) reg_gen4(gpriv, 0x6400, 0x3400) argument
466 #define RCANFD_F_CFID(gpriv, ch, idx) \ argument
467 (RCANFD_F_CFOFFSET(gpriv) + (0x180 * (ch)) + (0x80 * (idx)))
469 #define RCANFD_F_CFPTR(gpriv, ch, idx) \ argument
470 (RCANFD_F_CFOFFSET(gpriv) + 0x04 + (0x180 * (ch)) + (0x80 * (idx)))
472 #define RCANFD_F_CFFDCSTS(gpriv, ch, idx) \ argument
473 (RCANFD_F_CFOFFSET(gpriv) + 0x08 + (0x180 * (ch)) + (0x80 * (idx)))
475 #define RCANFD_F_CFDF(gpriv, ch, idx, df) \ argument
476 (RCANFD_F_CFOFFSET(gpriv) + 0x0c + (0x180 * (ch)) + (0x80 * (idx)) + \
531 struct rcar_canfd_global *gpriv; /* Controller reference */ member
614 static inline bool is_gen4(struct rcar_canfd_global *gpriv) in is_gen4() argument
616 return gpriv->info == &rcar_gen4_hw_info; in is_gen4()
619 static inline u32 reg_gen4(struct rcar_canfd_global *gpriv, in reg_gen4() argument
622 return is_gen4(gpriv) ? gen4 : not_gen4; in reg_gen4()
690 static void rcar_canfd_set_mode(struct rcar_canfd_global *gpriv) in rcar_canfd_set_mode() argument
692 if (is_gen4(gpriv)) { in rcar_canfd_set_mode()
693 u32 ch, val = gpriv->fdmode ? RCANFD_GEN4_FDCFG_FDOE in rcar_canfd_set_mode()
696 for_each_set_bit(ch, &gpriv->channels_mask, in rcar_canfd_set_mode()
697 gpriv->info->max_channels) in rcar_canfd_set_mode()
698 rcar_canfd_set_bit(gpriv->base, RCANFD_GEN4_FDCFG(ch), in rcar_canfd_set_mode()
701 if (gpriv->fdmode) in rcar_canfd_set_mode()
702 rcar_canfd_set_bit(gpriv->base, RCANFD_GRMCFG, in rcar_canfd_set_mode()
705 rcar_canfd_clear_bit(gpriv->base, RCANFD_GRMCFG, in rcar_canfd_set_mode()
710 static int rcar_canfd_reset_controller(struct rcar_canfd_global *gpriv) in rcar_canfd_reset_controller() argument
718 err = readl_poll_timeout((gpriv->base + RCANFD_GSTS), sts, in rcar_canfd_reset_controller()
721 dev_dbg(&gpriv->pdev->dev, "global raminit failed\n"); in rcar_canfd_reset_controller()
726 rcar_canfd_clear_bit(gpriv->base, RCANFD_GCTR, RCANFD_GCTR_GSLPR); in rcar_canfd_reset_controller()
727 rcar_canfd_update_bit(gpriv->base, RCANFD_GCTR, in rcar_canfd_reset_controller()
731 err = readl_poll_timeout((gpriv->base + RCANFD_GSTS), sts, in rcar_canfd_reset_controller()
734 dev_dbg(&gpriv->pdev->dev, "global reset failed\n"); in rcar_canfd_reset_controller()
739 rcar_canfd_write(gpriv->base, RCANFD_GERFL, 0x0); in rcar_canfd_reset_controller()
742 rcar_canfd_set_mode(gpriv); in rcar_canfd_reset_controller()
745 for_each_set_bit(ch, &gpriv->channels_mask, gpriv->info->max_channels) { in rcar_canfd_reset_controller()
746 rcar_canfd_clear_bit(gpriv->base, in rcar_canfd_reset_controller()
749 rcar_canfd_update_bit(gpriv->base, RCANFD_CCTR(ch), in rcar_canfd_reset_controller()
754 err = readl_poll_timeout((gpriv->base + RCANFD_CSTS(ch)), sts, in rcar_canfd_reset_controller()
758 dev_dbg(&gpriv->pdev->dev, in rcar_canfd_reset_controller()
766 static void rcar_canfd_configure_controller(struct rcar_canfd_global *gpriv) in rcar_canfd_configure_controller() argument
775 if (gpriv->fdmode) in rcar_canfd_configure_controller()
780 if (gpriv->fcan != RCANFD_CANFDCLK) in rcar_canfd_configure_controller()
783 rcar_canfd_set_bit(gpriv->base, RCANFD_GCFG, cfg); in rcar_canfd_configure_controller()
786 for_each_set_bit(ch, &gpriv->channels_mask, gpriv->info->max_channels) { in rcar_canfd_configure_controller()
787 rcar_canfd_set_bit(gpriv->base, RCANFD_CCTR(ch), in rcar_canfd_configure_controller()
789 rcar_canfd_update_bit(gpriv->base, RCANFD_CCTR(ch), in rcar_canfd_configure_controller()
795 static void rcar_canfd_configure_afl_rules(struct rcar_canfd_global *gpriv, in rcar_canfd_configure_afl_rules() argument
806 cfg = rcar_canfd_read(gpriv->base, RCANFD_GAFLCFG(ch)); in rcar_canfd_configure_afl_rules()
807 start = RCANFD_GAFLCFG_GETRNC(gpriv, 0, cfg); in rcar_canfd_configure_afl_rules()
812 rcar_canfd_set_bit(gpriv->base, RCANFD_GAFLECTR, in rcar_canfd_configure_afl_rules()
813 (RCANFD_GAFLECTR_AFLPN(gpriv, page) | in rcar_canfd_configure_afl_rules()
817 rcar_canfd_set_bit(gpriv->base, RCANFD_GAFLCFG(ch), in rcar_canfd_configure_afl_rules()
818 RCANFD_GAFLCFG_SETRNC(gpriv, ch, num_rules)); in rcar_canfd_configure_afl_rules()
819 if (is_gen4(gpriv)) in rcar_canfd_configure_afl_rules()
821 else if (gpriv->fdmode) in rcar_canfd_configure_afl_rules()
827 rcar_canfd_write(gpriv->base, RCANFD_GAFLID(offset, start), 0); in rcar_canfd_configure_afl_rules()
829 rcar_canfd_write(gpriv->base, RCANFD_GAFLM(offset, start), 0); in rcar_canfd_configure_afl_rules()
831 rcar_canfd_write(gpriv->base, RCANFD_GAFLP0(offset, start), 0); in rcar_canfd_configure_afl_rules()
833 rcar_canfd_set_bit(gpriv->base, RCANFD_GAFLP1(offset, start), in rcar_canfd_configure_afl_rules()
837 rcar_canfd_clear_bit(gpriv->base, in rcar_canfd_configure_afl_rules()
841 static void rcar_canfd_configure_rx(struct rcar_canfd_global *gpriv, u32 ch) in rcar_canfd_configure_rx() argument
851 if (gpriv->fdmode) in rcar_canfd_configure_rx()
858 rcar_canfd_write(gpriv->base, RCANFD_RFCC(gpriv, ridx), cfg); in rcar_canfd_configure_rx()
861 static void rcar_canfd_configure_tx(struct rcar_canfd_global *gpriv, u32 ch) in rcar_canfd_configure_tx() argument
875 if (gpriv->fdmode) in rcar_canfd_configure_tx()
880 cfg = (RCANFD_CFCC_CFTML(gpriv, cftml) | RCANFD_CFCC_CFM(gpriv, cfm) | in rcar_canfd_configure_tx()
881 RCANFD_CFCC_CFIM | RCANFD_CFCC_CFDC(gpriv, cfdc) | in rcar_canfd_configure_tx()
883 rcar_canfd_write(gpriv->base, RCANFD_CFCC(gpriv, ch, RCANFD_CFFIFO_IDX), cfg); in rcar_canfd_configure_tx()
885 if (gpriv->fdmode) in rcar_canfd_configure_tx()
887 rcar_canfd_write(gpriv->base, in rcar_canfd_configure_tx()
888 RCANFD_F_CFFDCSTS(gpriv, ch, RCANFD_CFFIFO_IDX), 0); in rcar_canfd_configure_tx()
891 static void rcar_canfd_enable_global_interrupts(struct rcar_canfd_global *gpriv) in rcar_canfd_enable_global_interrupts() argument
896 rcar_canfd_write(gpriv->base, RCANFD_GERFL, 0); in rcar_canfd_enable_global_interrupts()
900 if (gpriv->fdmode) in rcar_canfd_enable_global_interrupts()
903 rcar_canfd_set_bit(gpriv->base, RCANFD_GCTR, ctr); in rcar_canfd_enable_global_interrupts()
907 *gpriv) in rcar_canfd_disable_global_interrupts()
910 rcar_canfd_write(gpriv->base, RCANFD_GCTR, 0); in rcar_canfd_disable_global_interrupts()
913 rcar_canfd_write(gpriv->base, RCANFD_GERFL, 0); in rcar_canfd_disable_global_interrupts()
952 struct rcar_canfd_global *gpriv = priv->gpriv; in rcar_canfd_global_error() local
965 RCANFD_CFSTS(gpriv, ch, RCANFD_CFFIFO_IDX)); in rcar_canfd_global_error()
970 RCANFD_CFSTS(gpriv, ch, RCANFD_CFFIFO_IDX), in rcar_canfd_global_error()
974 sts = rcar_canfd_read(priv->base, RCANFD_RFSTS(gpriv, ridx)); in rcar_canfd_global_error()
978 rcar_canfd_write(priv->base, RCANFD_RFSTS(gpriv, ridx), in rcar_canfd_global_error()
982 if (gpriv->fdmode && gerfl & RCANFD_GERFL_CMPOF) { in rcar_canfd_global_error()
1113 struct rcar_canfd_global *gpriv = priv->gpriv; in rcar_canfd_tx_done() local
1129 RCANFD_CFSTS(gpriv, ch, RCANFD_CFFIFO_IDX)); in rcar_canfd_tx_done()
1145 rcar_canfd_write(priv->base, RCANFD_CFSTS(gpriv, ch, RCANFD_CFFIFO_IDX), in rcar_canfd_tx_done()
1149 static void rcar_canfd_handle_global_err(struct rcar_canfd_global *gpriv, u32 ch) in rcar_canfd_handle_global_err() argument
1151 struct rcar_canfd_channel *priv = gpriv->ch[ch]; in rcar_canfd_handle_global_err()
1157 if (unlikely(RCANFD_GERFL_ERR(gpriv, gerfl))) in rcar_canfd_handle_global_err()
1163 struct rcar_canfd_global *gpriv = dev_id; in rcar_canfd_global_err_interrupt() local
1166 for_each_set_bit(ch, &gpriv->channels_mask, gpriv->info->max_channels) in rcar_canfd_global_err_interrupt()
1167 rcar_canfd_handle_global_err(gpriv, ch); in rcar_canfd_global_err_interrupt()
1172 static void rcar_canfd_handle_global_receive(struct rcar_canfd_global *gpriv, u32 ch) in rcar_canfd_handle_global_receive() argument
1174 struct rcar_canfd_channel *priv = gpriv->ch[ch]; in rcar_canfd_handle_global_receive()
1179 sts = rcar_canfd_read(priv->base, RCANFD_RFSTS(gpriv, ridx)); in rcar_canfd_handle_global_receive()
1180 cc = rcar_canfd_read(priv->base, RCANFD_RFCC(gpriv, ridx)); in rcar_canfd_handle_global_receive()
1186 RCANFD_RFCC(gpriv, ridx), in rcar_canfd_handle_global_receive()
1195 struct rcar_canfd_global *gpriv = dev_id; in rcar_canfd_global_receive_fifo_interrupt() local
1198 for_each_set_bit(ch, &gpriv->channels_mask, gpriv->info->max_channels) in rcar_canfd_global_receive_fifo_interrupt()
1199 rcar_canfd_handle_global_receive(gpriv, ch); in rcar_canfd_global_receive_fifo_interrupt()
1206 struct rcar_canfd_global *gpriv = dev_id; in rcar_canfd_global_interrupt() local
1212 for_each_set_bit(ch, &gpriv->channels_mask, gpriv->info->max_channels) { in rcar_canfd_global_interrupt()
1213 rcar_canfd_handle_global_err(gpriv, ch); in rcar_canfd_global_interrupt()
1214 rcar_canfd_handle_global_receive(gpriv, ch); in rcar_canfd_global_interrupt()
1250 static void rcar_canfd_handle_channel_tx(struct rcar_canfd_global *gpriv, u32 ch) in rcar_canfd_handle_channel_tx() argument
1252 struct rcar_canfd_channel *priv = gpriv->ch[ch]; in rcar_canfd_handle_channel_tx()
1258 RCANFD_CFSTS(gpriv, ch, RCANFD_CFFIFO_IDX)); in rcar_canfd_handle_channel_tx()
1267 rcar_canfd_handle_channel_tx(priv->gpriv, priv->channel); in rcar_canfd_channel_tx_interrupt()
1272 static void rcar_canfd_handle_channel_err(struct rcar_canfd_global *gpriv, u32 ch) in rcar_canfd_handle_channel_err() argument
1274 struct rcar_canfd_channel *priv = gpriv->ch[ch]; in rcar_canfd_handle_channel_err()
1297 rcar_canfd_handle_channel_err(priv->gpriv, priv->channel); in rcar_canfd_channel_err_interrupt()
1304 struct rcar_canfd_global *gpriv = dev_id; in rcar_canfd_channel_interrupt() local
1308 for_each_set_bit(ch, &gpriv->channels_mask, gpriv->info->max_channels) { in rcar_canfd_channel_interrupt()
1309 rcar_canfd_handle_channel_err(gpriv, ch); in rcar_canfd_channel_interrupt()
1310 rcar_canfd_handle_channel_tx(gpriv, ch); in rcar_canfd_channel_interrupt()
1319 struct rcar_canfd_global *gpriv = priv->gpriv; in rcar_canfd_set_bittiming() local
1334 cfg = (RCANFD_NCFG_NTSEG1(gpriv, tseg1) | RCANFD_NCFG_NBRP(brp) | in rcar_canfd_set_bittiming()
1335 RCANFD_NCFG_NSJW(gpriv, sjw) | RCANFD_NCFG_NTSEG2(gpriv, tseg2)); in rcar_canfd_set_bittiming()
1347 cfg = (RCANFD_DCFG_DTSEG1(gpriv, tseg1) | RCANFD_DCFG_DBRP(brp) | in rcar_canfd_set_bittiming()
1348 RCANFD_DCFG_DSJW(gpriv, sjw) | RCANFD_DCFG_DTSEG2(gpriv, tseg2)); in rcar_canfd_set_bittiming()
1350 rcar_canfd_write(priv->base, RCANFD_F_DCFG(gpriv, ch), cfg); in rcar_canfd_set_bittiming()
1355 if (is_gen4(gpriv)) { in rcar_canfd_set_bittiming()
1356 cfg = (RCANFD_NCFG_NTSEG1(gpriv, tseg1) | in rcar_canfd_set_bittiming()
1358 RCANFD_NCFG_NSJW(gpriv, sjw) | in rcar_canfd_set_bittiming()
1359 RCANFD_NCFG_NTSEG2(gpriv, tseg2)); in rcar_canfd_set_bittiming()
1377 struct rcar_canfd_global *gpriv = priv->gpriv; in rcar_canfd_start() local
1399 rcar_canfd_set_bit(priv->base, RCANFD_CFCC(gpriv, ch, RCANFD_CFFIFO_IDX), in rcar_canfd_start()
1401 rcar_canfd_set_bit(priv->base, RCANFD_RFCC(gpriv, ridx), RCANFD_RFCC_RFE); in rcar_canfd_start()
1414 struct rcar_canfd_global *gpriv = priv->gpriv; in rcar_canfd_open() local
1424 err = clk_prepare_enable(gpriv->can_clk); in rcar_canfd_open()
1446 clk_disable_unprepare(gpriv->can_clk); in rcar_canfd_open()
1455 struct rcar_canfd_global *gpriv = priv->gpriv; in rcar_canfd_stop() local
1473 rcar_canfd_clear_bit(priv->base, RCANFD_CFCC(gpriv, ch, RCANFD_CFFIFO_IDX), in rcar_canfd_stop()
1475 rcar_canfd_clear_bit(priv->base, RCANFD_RFCC(gpriv, ridx), RCANFD_RFCC_RFE); in rcar_canfd_stop()
1484 struct rcar_canfd_global *gpriv = priv->gpriv; in rcar_canfd_close() local
1489 clk_disable_unprepare(gpriv->can_clk); in rcar_canfd_close()
1499 struct rcar_canfd_global *gpriv = priv->gpriv; in rcar_canfd_start_xmit() local
1520 if ((priv->can.ctrlmode & CAN_CTRLMODE_FD) || is_gen4(gpriv)) { in rcar_canfd_start_xmit()
1522 RCANFD_F_CFID(gpriv, ch, RCANFD_CFFIFO_IDX), id); in rcar_canfd_start_xmit()
1524 RCANFD_F_CFPTR(gpriv, ch, RCANFD_CFFIFO_IDX), dlc); in rcar_canfd_start_xmit()
1537 RCANFD_F_CFFDCSTS(gpriv, ch, RCANFD_CFFIFO_IDX), sts); in rcar_canfd_start_xmit()
1540 RCANFD_F_CFDF(gpriv, ch, RCANFD_CFFIFO_IDX, 0)); in rcar_canfd_start_xmit()
1563 RCANFD_CFPCTR(gpriv, ch, RCANFD_CFFIFO_IDX), 0xff); in rcar_canfd_start_xmit()
1572 struct rcar_canfd_global *gpriv = priv->gpriv; in rcar_canfd_rx_pkt() local
1579 if ((priv->can.ctrlmode & CAN_CTRLMODE_FD) || is_gen4(gpriv)) { in rcar_canfd_rx_pkt()
1580 id = rcar_canfd_read(priv->base, RCANFD_F_RFID(gpriv, ridx)); in rcar_canfd_rx_pkt()
1581 dlc = rcar_canfd_read(priv->base, RCANFD_F_RFPTR(gpriv, ridx)); in rcar_canfd_rx_pkt()
1583 sts = rcar_canfd_read(priv->base, RCANFD_F_RFFDSTS(gpriv, ridx)); in rcar_canfd_rx_pkt()
1624 rcar_canfd_get_data(priv, cf, RCANFD_F_RFDF(gpriv, ridx, 0)); in rcar_canfd_rx_pkt()
1630 else if (is_gen4(gpriv)) in rcar_canfd_rx_pkt()
1631 rcar_canfd_get_data(priv, cf, RCANFD_F_RFDF(gpriv, ridx, 0)); in rcar_canfd_rx_pkt()
1639 rcar_canfd_write(priv->base, RCANFD_RFPCTR(gpriv, ridx), 0xff); in rcar_canfd_rx_pkt()
1651 struct rcar_canfd_global *gpriv = priv->gpriv; in rcar_canfd_rx_poll() local
1658 sts = rcar_canfd_read(priv->base, RCANFD_RFSTS(gpriv, ridx)); in rcar_canfd_rx_poll()
1667 rcar_canfd_write(priv->base, RCANFD_RFSTS(gpriv, ridx), in rcar_canfd_rx_poll()
1675 rcar_canfd_set_bit(priv->base, RCANFD_RFCC(gpriv, ridx), in rcar_canfd_rx_poll()
1722 static int rcar_canfd_channel_probe(struct rcar_canfd_global *gpriv, u32 ch, in rcar_canfd_channel_probe() argument
1725 const struct rcar_canfd_hw_info *info = gpriv->info; in rcar_canfd_channel_probe()
1726 struct platform_device *pdev = gpriv->pdev; in rcar_canfd_channel_probe()
1742 priv->base = gpriv->base; in rcar_canfd_channel_probe()
1745 priv->gpriv = gpriv; in rcar_canfd_channel_probe()
1798 if (gpriv->fdmode) { in rcar_canfd_channel_probe()
1821 gpriv->ch[priv->channel] = priv; in rcar_canfd_channel_probe()
1837 static void rcar_canfd_channel_remove(struct rcar_canfd_global *gpriv, u32 ch) in rcar_canfd_channel_remove() argument
1839 struct rcar_canfd_channel *priv = gpriv->ch[ch]; in rcar_canfd_channel_remove()
1855 struct rcar_canfd_global *gpriv; in rcar_canfd_probe() local
1909 gpriv = devm_kzalloc(dev, sizeof(*gpriv), GFP_KERNEL); in rcar_canfd_probe()
1910 if (!gpriv) in rcar_canfd_probe()
1913 gpriv->pdev = pdev; in rcar_canfd_probe()
1914 gpriv->channels_mask = channels_mask; in rcar_canfd_probe()
1915 gpriv->fdmode = fdmode; in rcar_canfd_probe()
1916 gpriv->info = info; in rcar_canfd_probe()
1918 gpriv->rstc1 = devm_reset_control_get_optional_exclusive(dev, "rstp_n"); in rcar_canfd_probe()
1919 if (IS_ERR(gpriv->rstc1)) in rcar_canfd_probe()
1920 return dev_err_probe(dev, PTR_ERR(gpriv->rstc1), in rcar_canfd_probe()
1923 gpriv->rstc2 = devm_reset_control_get_optional_exclusive(dev, "rstc_n"); in rcar_canfd_probe()
1924 if (IS_ERR(gpriv->rstc2)) in rcar_canfd_probe()
1925 return dev_err_probe(dev, PTR_ERR(gpriv->rstc2), in rcar_canfd_probe()
1929 gpriv->clkp = devm_clk_get(dev, "fck"); in rcar_canfd_probe()
1930 if (IS_ERR(gpriv->clkp)) in rcar_canfd_probe()
1931 return dev_err_probe(dev, PTR_ERR(gpriv->clkp), in rcar_canfd_probe()
1937 gpriv->can_clk = devm_clk_get(dev, "can_clk"); in rcar_canfd_probe()
1938 if (IS_ERR(gpriv->can_clk) || (clk_get_rate(gpriv->can_clk) == 0)) { in rcar_canfd_probe()
1939 gpriv->can_clk = devm_clk_get(dev, "canfd"); in rcar_canfd_probe()
1940 if (IS_ERR(gpriv->can_clk)) in rcar_canfd_probe()
1941 return dev_err_probe(dev, PTR_ERR(gpriv->can_clk), in rcar_canfd_probe()
1944 gpriv->fcan = RCANFD_CANFDCLK; in rcar_canfd_probe()
1947 gpriv->fcan = RCANFD_EXTCLK; in rcar_canfd_probe()
1949 fcan_freq = clk_get_rate(gpriv->can_clk); in rcar_canfd_probe()
1951 if (gpriv->fcan == RCANFD_CANFDCLK) in rcar_canfd_probe()
1960 gpriv->base = addr; in rcar_canfd_probe()
1966 "canfd.ch_int", gpriv); in rcar_canfd_probe()
1974 0, "canfd.g_int", gpriv); in rcar_canfd_probe()
1983 "canfd.g_recc", gpriv); in rcar_canfd_probe()
1993 "canfd.g_err", gpriv); in rcar_canfd_probe()
2001 err = reset_control_reset(gpriv->rstc1); in rcar_canfd_probe()
2004 err = reset_control_reset(gpriv->rstc2); in rcar_canfd_probe()
2006 reset_control_assert(gpriv->rstc1); in rcar_canfd_probe()
2011 err = clk_prepare_enable(gpriv->clkp); in rcar_canfd_probe()
2018 err = rcar_canfd_reset_controller(gpriv); in rcar_canfd_probe()
2025 rcar_canfd_configure_controller(gpriv); in rcar_canfd_probe()
2028 for_each_set_bit(ch, &gpriv->channels_mask, info->max_channels) { in rcar_canfd_probe()
2030 rcar_canfd_configure_rx(gpriv, ch); in rcar_canfd_probe()
2033 rcar_canfd_configure_tx(gpriv, ch); in rcar_canfd_probe()
2036 rcar_canfd_configure_afl_rules(gpriv, ch); in rcar_canfd_probe()
2040 rcar_canfd_enable_global_interrupts(gpriv); in rcar_canfd_probe()
2043 rcar_canfd_update_bit(gpriv->base, RCANFD_GCTR, RCANFD_GCTR_GMDC_MASK, in rcar_canfd_probe()
2047 err = readl_poll_timeout((gpriv->base + RCANFD_GSTS), sts, in rcar_canfd_probe()
2054 for_each_set_bit(ch, &gpriv->channels_mask, info->max_channels) { in rcar_canfd_probe()
2055 err = rcar_canfd_channel_probe(gpriv, ch, fcan_freq, in rcar_canfd_probe()
2061 platform_set_drvdata(pdev, gpriv); in rcar_canfd_probe()
2063 gpriv->fcan, gpriv->fdmode); in rcar_canfd_probe()
2067 for_each_set_bit(ch, &gpriv->channels_mask, info->max_channels) in rcar_canfd_probe()
2068 rcar_canfd_channel_remove(gpriv, ch); in rcar_canfd_probe()
2070 rcar_canfd_disable_global_interrupts(gpriv); in rcar_canfd_probe()
2072 clk_disable_unprepare(gpriv->clkp); in rcar_canfd_probe()
2074 reset_control_assert(gpriv->rstc1); in rcar_canfd_probe()
2075 reset_control_assert(gpriv->rstc2); in rcar_canfd_probe()
2082 struct rcar_canfd_global *gpriv = platform_get_drvdata(pdev); in rcar_canfd_remove() local
2085 rcar_canfd_reset_controller(gpriv); in rcar_canfd_remove()
2086 rcar_canfd_disable_global_interrupts(gpriv); in rcar_canfd_remove()
2088 for_each_set_bit(ch, &gpriv->channels_mask, gpriv->info->max_channels) { in rcar_canfd_remove()
2089 rcar_canfd_disable_channel_interrupts(gpriv->ch[ch]); in rcar_canfd_remove()
2090 rcar_canfd_channel_remove(gpriv, ch); in rcar_canfd_remove()
2094 rcar_canfd_set_bit(gpriv->base, RCANFD_GCTR, RCANFD_GCTR_GSLPR); in rcar_canfd_remove()
2095 clk_disable_unprepare(gpriv->clkp); in rcar_canfd_remove()
2096 reset_control_assert(gpriv->rstc1); in rcar_canfd_remove()
2097 reset_control_assert(gpriv->rstc2); in rcar_canfd_remove()