Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'linux-can-next-for-6.20-20260131' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next

Marc Kleine-Budde says:

====================
pull-request: can-next 2026-01-31

This first 2 patches are by Biju Das, target the rcar_canfd driver and
add support for FD-only mode.

Lad Prabhakar's patches, also for the rcar_canfd driver add support
for the RZ/T2H SoC.

The last 2 patches are by Michael Tretter and me, target the sja1000
driver and clean up the CAN state handling.

* tag 'linux-can-next-for-6.20-20260131' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next:
can: sja1000: sja1000_err(): use error counter for error state
can: sja1000: sja1000_err(): make use of sja1000_get_berr_counter() to read error counters
can: rcar_canfd: Add RZ/T2H support
dt-bindings: can: renesas,rcar-canfd: Document RZ/T2H and RZ/N2H SoCs
dt-bindings: can: renesas,rcar-canfd: Document RZ/V2H(P) and RZ/V2N SoCs
dt-bindings: can: renesas,rcar-canfd: Specify reset-names
can: rcar_canfd: Add support for FD-Only mode
dt-bindings: can: renesas,rcar-canfd: Document renesas,fd-only property
====================

Link: https://patch.msgid.link/20260131101512.1958907-1-mkl@pengutronix.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+142 -49
+100 -17
Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml
··· 12 12 properties: 13 13 compatible: 14 14 oneOf: 15 + - enum: 16 + - renesas,r9a09g047-canfd # RZ/G3E 17 + - renesas,r9a09g077-canfd # RZ/T2H 18 + 15 19 - items: 16 20 - enum: 17 21 - renesas,r8a774a1-canfd # RZ/G2M ··· 46 42 - renesas,r9a07g054-canfd # RZ/V2L 47 43 - const: renesas,rzg2l-canfd # RZ/G2L family 48 44 49 - - const: renesas,r9a09g047-canfd # RZ/G3E 45 + - items: 46 + - enum: 47 + - renesas,r9a09g056-canfd # RZ/V2N 48 + - renesas,r9a09g057-canfd # RZ/V2H(P) 49 + - const: renesas,r9a09g047-canfd 50 + 51 + - items: 52 + - const: renesas,r9a09g087-canfd # RZ/N2H 53 + - const: renesas,r9a09g077-canfd 50 54 51 55 reg: 52 56 maxItems: 1 ··· 134 122 135 123 resets: true 136 124 125 + reset-names: 126 + items: 127 + - const: rstp_n 128 + - const: rstc_n 129 + 137 130 renesas,no-can-fd: 138 131 $ref: /schemas/types.yaml#/definitions/flag 139 132 description: 140 - The controller can operate in either CAN FD only mode (default) or 141 - Classical CAN only mode. The mode is global to all channels. 142 - Specify this property to put the controller in Classical CAN only mode. 133 + The controller can operate in either CAN-FD mode (default) or FD-Only 134 + mode (RZ/{G2L,G3E} and R-Car Gen4) or Classical CAN mode. Specify this 135 + property to put the controller in Classical CAN mode. 136 + 137 + renesas,fd-only: 138 + $ref: /schemas/types.yaml#/definitions/flag 139 + description: 140 + The CANFD on RZ/{G2L,G3E} and R-Car Gen4 SoCs support 3 modes FD-Only 141 + mode, Classical CAN mode and CAN-FD mode (default). In FD-Only mode, 142 + communication in Classical CAN frame format is disabled. Specify this 143 + property to put the controller in FD-Only mode. 143 144 144 145 assigned-clocks: 145 146 description: ··· 185 160 - clocks 186 161 - clock-names 187 162 - power-domains 188 - - resets 189 163 - assigned-clocks 190 164 - assigned-clock-rates 191 165 - channel0 ··· 210 186 resets: 211 187 minItems: 2 212 188 maxItems: 2 213 - 214 - reset-names: 215 - minItems: 2 216 - maxItems: 2 217 - 218 - required: 219 - - reset-names 220 189 221 190 - if: 222 191 properties: ··· 248 231 minItems: 2 249 232 maxItems: 2 250 233 251 - reset-names: 252 - minItems: 2 253 - maxItems: 2 234 + - if: 235 + properties: 236 + compatible: 237 + contains: 238 + const: renesas,r9a09g077-canfd 239 + then: 240 + properties: 241 + interrupts: 242 + maxItems: 8 254 243 255 - required: 256 - - reset-names 244 + interrupt-names: 245 + maxItems: 8 257 246 258 247 - if: 259 248 properties: 260 249 compatible: 261 250 contains: 262 251 enum: 252 + - renesas,r9a09g077-canfd 263 253 - renesas,rcar-gen3-canfd 264 254 - renesas,rzg2l-canfd 265 255 then: ··· 290 266 then: 291 267 patternProperties: 292 268 "^channel[6-7]$": false 269 + 270 + - if: 271 + properties: 272 + compatible: 273 + contains: 274 + enum: 275 + - renesas,rcar-gen3-canfd 276 + then: 277 + properties: 278 + renesas,fd-only: false 279 + 280 + - if: 281 + required: 282 + - renesas,no-can-fd 283 + then: 284 + properties: 285 + renesas,fd-only: false 286 + 287 + - if: 288 + required: 289 + - renesas,fd-only 290 + then: 291 + properties: 292 + renesas,no-can-fd: false 293 + 294 + - if: 295 + properties: 296 + compatible: 297 + contains: 298 + const: renesas,r9a09g077-canfd 299 + then: 300 + properties: 301 + resets: false 302 + reset-names: false 303 + 304 + - if: 305 + properties: 306 + compatible: 307 + contains: 308 + enum: 309 + - renesas,r9a09g047-canfd 310 + - renesas,rzg2l-canfd 311 + then: 312 + required: 313 + - resets 314 + - reset-names 315 + 316 + - if: 317 + properties: 318 + compatible: 319 + contains: 320 + enum: 321 + - renesas,rcar-gen3-canfd 322 + - renesas,rcar-gen4-canfd 323 + then: 324 + required: 325 + - resets 326 + properties: 327 + reset-names: false 293 328 294 329 unevaluatedProperties: false 295 330
+31 -1
drivers/net/can/rcar/rcar_canfd.c
··· 472 472 unsigned long channels_mask; /* Enabled channels mask */ 473 473 bool extclk; /* CANFD or Ext clock */ 474 474 bool fdmode; /* CAN FD or Classical CAN only mode */ 475 + bool fd_only_mode; /* FD-Only mode for CAN-FD */ 475 476 struct reset_control *rstc1; 476 477 struct reset_control *rstc2; 477 478 const struct rcar_canfd_hw_info *info; ··· 670 669 .external_clk = 0, 671 670 }; 672 671 672 + static const struct rcar_canfd_hw_info r9a09g077_hw_info = { 673 + .nom_bittiming = &rcar_canfd_gen4_nom_bittiming_const, 674 + .data_bittiming = &rcar_canfd_gen4_data_bittiming_const, 675 + .tdc_const = &rcar_canfd_gen4_tdc_const, 676 + .regs = &rcar_gen4_regs, 677 + .sh = &rcar_gen4_shift_data, 678 + .rnc_field_width = 16, 679 + .max_aflpn = 15, 680 + .max_cftml = 31, 681 + .max_channels = 2, 682 + .postdiv = 1, 683 + .multi_channel_irqs = 1, 684 + .ch_interface_mode = 1, 685 + .shared_can_regs = 1, 686 + .external_clk = 1, 687 + }; 688 + 673 689 /* Helper functions */ 674 690 static inline void rcar_canfd_update(u32 mask, u32 val, u32 __iomem *reg) 675 691 { ··· 847 829 RCANFD_GEN4_FDCFG_FDOE); 848 830 rcar_canfd_set_bit_reg(&gpriv->fcbase[ch].cfdcfg, 849 831 RCANFD_GEN4_FDCFG_CLOE); 832 + } else if (gpriv->fd_only_mode) { 833 + rcar_canfd_clear_bit_reg(&gpriv->fcbase[ch].cfdcfg, 834 + RCANFD_GEN4_FDCFG_CLOE); 835 + rcar_canfd_set_bit_reg(&gpriv->fcbase[ch].cfdcfg, 836 + RCANFD_GEN4_FDCFG_FDOE); 850 837 } else { 851 838 rcar_canfd_clear_bit_reg(&gpriv->fcbase[ch].cfdcfg, 852 839 RCANFD_GEN4_FDCFG_FDOE); 853 840 rcar_canfd_clear_bit_reg(&gpriv->fcbase[ch].cfdcfg, 854 841 RCANFD_GEN4_FDCFG_CLOE); 855 842 } 843 + } else if (gpriv->fd_only_mode) { 844 + rcar_canfd_set_bit_reg(&gpriv->fcbase[ch].cfdcfg, 845 + RCANFD_GEN4_FDCFG_FDOE); 856 846 } 857 847 } 858 848 ··· 2166 2140 gpriv->fdmode = fdmode; 2167 2141 gpriv->info = info; 2168 2142 2143 + if (of_property_read_bool(dev->of_node, "renesas,fd-only")) 2144 + gpriv->fd_only_mode = true; /* FD-Only mode for CAN-FD */ 2145 + 2169 2146 gpriv->rstc1 = devm_reset_control_get_optional_exclusive(dev, "rstp_n"); 2170 2147 if (IS_ERR(gpriv->rstc1)) 2171 2148 return dev_err_probe(dev, PTR_ERR(gpriv->rstc1), ··· 2268 2239 platform_set_drvdata(pdev, gpriv); 2269 2240 dev_info(dev, "global operational state (%s clk, %s mode)\n", 2270 2241 gpriv->extclk ? "ext" : "canfd", 2271 - gpriv->fdmode ? "fd" : "classical"); 2242 + gpriv->fdmode ? (gpriv->fd_only_mode ? "fd-only" : "fd") : "classical"); 2272 2243 return 0; 2273 2244 2274 2245 fail_channel: ··· 2362 2333 static const __maybe_unused struct of_device_id rcar_canfd_of_table[] = { 2363 2334 { .compatible = "renesas,r8a779a0-canfd", .data = &rcar_gen4_hw_info }, 2364 2335 { .compatible = "renesas,r9a09g047-canfd", .data = &r9a09g047_hw_info }, 2336 + { .compatible = "renesas,r9a09g077-canfd", .data = &r9a09g077_hw_info }, 2365 2337 { .compatible = "renesas,rcar-gen3-canfd", .data = &rcar_gen3_hw_info }, 2366 2338 { .compatible = "renesas,rcar-gen4-canfd", .data = &rcar_gen4_hw_info }, 2367 2339 { .compatible = "renesas,rzg2l-canfd", .data = &rzg2l_hw_info },
+11 -31
drivers/net/can/sja1000/sja1000.c
··· 407 407 { 408 408 struct sja1000_priv *priv = netdev_priv(dev); 409 409 struct net_device_stats *stats = &dev->stats; 410 + enum can_state state, rx_state, tx_state; 410 411 struct can_frame *cf; 411 412 struct sk_buff *skb; 412 - enum can_state state = priv->can.state; 413 - enum can_state rx_state, tx_state; 414 - unsigned int rxerr, txerr; 413 + struct can_berr_counter bec; 415 414 uint8_t ecc, alc; 416 415 int ret = 0; 417 416 418 417 skb = alloc_can_err_skb(dev, &cf); 419 418 420 - txerr = priv->read_reg(priv, SJA1000_TXERR); 421 - rxerr = priv->read_reg(priv, SJA1000_RXERR); 419 + sja1000_get_berr_counter(dev, &bec); 420 + can_state_get_by_berr_counter(dev, &bec, &tx_state, &rx_state); 421 + 422 + if (status & SR_BS) 423 + rx_state = CAN_STATE_BUS_OFF; 424 + 425 + state = max(tx_state, rx_state); 422 426 423 427 if (isrc & IRQ_DOI) { 424 428 /* data overrun interrupt */ ··· 445 441 if (priv->flags & SJA1000_QUIRK_RESET_ON_OVERRUN) 446 442 ret = IRQ_WAKE_THREAD; 447 443 } 448 - 449 - if (isrc & IRQ_EI) { 450 - /* error warning interrupt */ 451 - netdev_dbg(dev, "error warning interrupt\n"); 452 - 453 - if (status & SR_BS) 454 - state = CAN_STATE_BUS_OFF; 455 - else if (status & SR_ES) 456 - state = CAN_STATE_ERROR_WARNING; 457 - else 458 - state = CAN_STATE_ERROR_ACTIVE; 459 - } 460 444 if (state != CAN_STATE_BUS_OFF && skb) { 461 445 cf->can_id |= CAN_ERR_CNT; 462 - cf->data[6] = txerr; 463 - cf->data[7] = rxerr; 446 + cf->data[6] = bec.txerr; 447 + cf->data[7] = bec.rxerr; 464 448 } 465 449 if (isrc & IRQ_BEI) { 466 450 /* bus error interrupt */ ··· 486 494 stats->rx_errors++; 487 495 } 488 496 } 489 - if (isrc & IRQ_EPI) { 490 - /* error passive interrupt */ 491 - netdev_dbg(dev, "error passive interrupt\n"); 492 - 493 - if (state == CAN_STATE_ERROR_PASSIVE) 494 - state = CAN_STATE_ERROR_WARNING; 495 - else 496 - state = CAN_STATE_ERROR_PASSIVE; 497 - } 498 497 if (isrc & IRQ_ALI) { 499 498 /* arbitration lost interrupt */ 500 499 netdev_dbg(dev, "arbitration lost interrupt\n"); ··· 498 515 } 499 516 500 517 if (state != priv->can.state) { 501 - tx_state = txerr >= rxerr ? state : 0; 502 - rx_state = txerr <= rxerr ? state : 0; 503 - 504 518 can_change_state(dev, cf, tx_state, rx_state); 505 519 506 520 if(state == CAN_STATE_BUS_OFF)