Jakub Kicinski
bb9a242ce5
Merge tag 'linux-can-next-for-6.18-20250924' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next
...
Marc Kleine-Budde says:
====================
pull-request: can-next 2025-09-25
this is a pull request of 48 patches for net-next/main, which
supersedes tags/linux-can-next-for-6.18-20250923.
The 1st patch is by Xichao Zhao and converts ns_to_ktime() to
us_to_ktime() in the m_can driver.
Vincent Mailhol contributes 2 patches: Updating the MAINTAINERS and
mailmap files to Vincent's new email address and sorting the includes
in the CAN helper library alphabeticaly.
Stéphane Grosjean's patch modifies all peak CAN drivers and the
mailmap to reflect Stéphane's new email address.
4 patches by Biju Das update the CAN-FD handling in the rcar_canfd
driver.
Followed by 11 patches by Geert Uytterhoeven updating and improving
the rcar_can driver.
Stefan Mätje contributes 2 patches for the esd_usb driver updating the
error messages.
The next 3 patch series are all by Vincent Mailhol: 3 patches to
optimize the size of struct raw_sock and struct uniqframe. 4 patches
which rework the CAN MTU logic as preparation for CAN-XL interfaces.
And finally 20 patches that prepare and refactor the CAN netlink code
for the upcoming CAN-XL support.
* tag 'linux-can-next-for-6.18-20250924' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next: (48 commits)
can: netlink: add userland error messages
can: dev: add can_get_ctrlmode_str()
can: calc_bittiming: make can_calc_tdco() FD agnostic
can: netlink: make can_tdc_fill_info() FD agnostic
can: netlink: add can_bitrate_const_fill_info()
can: netlink: add can_bittiming_const_fill_info()
can: netlink: add can_bittiming_fill_info()
can: netlink: add can_data_bittiming_get_size()
can: netlink: make can_tdc_get_size() FD agnostic
can: netlink: add can_ctrlmode_changelink()
can: netlink: add can_dtb_changelink()
can: netlink: make can_tdc_changelink() FD agnostic
can: netlink: remove useless check in can_tdc_changelink()
can: netlink: refactor CAN_CTRLMODE_TDC_{AUTO,MANUAL} flag reset logic
can: netlink: add can_validate_databittiming()
can: netlink: add can_validate_tdc()
can: netlink: refactor can_validate_bittiming()
can: netlink: document which symbols are FD specific
can: dev: make can_get_relative_tdco() FD agnostic and move it to bittiming.h
can: dev: move struct data_bittiming_params to linux/can/bittiming.h
...
====================
Link: https://patch.msgid.link/20250925121332.848157-1-mkl@pengutronix.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org >
2025-09-26 14:46:59 -07:00
Geert Uytterhoeven
7207788031
can: rcar_can: Convert to %pe
...
Replace numerical error codes by mnemotechnic error codes, to improve
the user experience in case of errors.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be >
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com >
Link: https://patch.msgid.link/adb2dc49c78b45191de410f645a5e423d341f94e.1755857536.git.geert+renesas@glider.be
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-09-19 19:25:17 +02:00
Geert Uytterhoeven
5317225e01
can: rcar_can: Do not print alloc_candev() failures
...
If alloc_candev() failed due to out-of-memory, the core memory
allocation code has already printed an error message.
If alloc_candev() failed for a different reason, alloc_netdev_mqs() has
already printed an error message.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be >
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com >
Link: https://patch.msgid.link/2d6ad4be211a35492570fd7219ca7a89b384bfad.1755857536.git.geert+renesas@glider.be
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-09-19 19:25:17 +02:00
Geert Uytterhoeven
729b1c69b8
can: rcar_can: Mailbox bitfield conversion
...
Convert CAN Mailbox Register field accesses to use the FIELD_PREP() and
FIELD_GET() bitfield access macro.
This gets rid of explicit shifts, and keeps a clear separation between
hardware register layouts and offical CAN definitions.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be >
Link: https://patch.msgid.link/c75c7d6ed5929c4becf7c9178cec04a0731e8ab1.1755857536.git.geert+renesas@glider.be
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-09-19 19:25:16 +02:00
Geert Uytterhoeven
8d930226d3
can: rcar_can: BCR bitfield conversion
...
Convert CAN Bit Configuration Register field accesses to use the
FIELD_PREP() bitfield access macro. While at it, fix the misspelling of
BRP.
This gets rid of custom function-like field preparation macros.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be >
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com >
Link: https://patch.msgid.link/01cfaedba2be22515ba8700893ea7f113df959c0.1755857536.git.geert+renesas@glider.be
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-09-19 19:25:16 +02:00
Geert Uytterhoeven
75f319455d
can: rcar_can: TFCR bitfield conversion
...
Convert CAN Transmit FIFO Control Register field accesses to use the
FIELD_GET() bitfield access macro.
This gets rid of an explicit shift.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be >
Link: https://patch.msgid.link/a8b1dc6f1249a01af9b691ca59e2e5cc2dba6d44.1755857536.git.geert+renesas@glider.be
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-09-19 19:25:16 +02:00
Geert Uytterhoeven
669abc4068
can: rcar_can: CTLR bitfield conversion
...
Convert CAN Control Register field accesses to use the FIELD_PREP()
bitfield access macro. Add a few more comments and definitions while at
it.
This gets rid of explicit (and sometimes confusing) shifts.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be >
Link: https://patch.msgid.link/077640e31949dc3c9d128a08ade94c9e9cd25672.1755857536.git.geert+renesas@glider.be
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-09-19 19:25:15 +02:00
Geert Uytterhoeven
28f3617c39
can: rcar_can: Convert to GENMASK()
...
Use the GENMASK() macro instead of open-coding the same operation.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be >
Link: https://patch.msgid.link/3f947f0f91a8857a2cbce74807e42258e9f209ca.1755857536.git.geert+renesas@glider.be
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-09-19 19:25:15 +02:00
Geert Uytterhoeven
bcf4dee47f
can: rcar_can: Convert to BIT()
...
Use the BIT() macro instead of open-coding the same operation.
Add a few more comments while at it.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be >
Link: https://patch.msgid.link/78fb16beb74975f6f6140ec9abb48beb94fb0afa.1755857536.git.geert+renesas@glider.be
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-09-19 19:25:15 +02:00
Geert Uytterhoeven
1bbff17626
can: rcar_can: Convert to Runtime PM
...
The R-Car CAN module is part of a Clock Domain on all supported SoCs.
Hence convert its driver from explicit clock management to Runtime PM.
While at it, use %pe to format error codes.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be >
Link: https://patch.msgid.link/68bfa5480a79c17c6ceec4fb073f33872e7ff5d0.1755857536.git.geert+renesas@glider.be
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-09-19 19:25:14 +02:00
Geert Uytterhoeven
f7844496cb
can: rcar_can: Add helper variable dev to rcar_can_probe()
...
rcar_can_probe() has many users of "pdev->dev". Introduce a shorthand
to simplify the code.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be >
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com >
Link: https://patch.msgid.link/baf34c8bef5625ae73c830dbb3c617eb8f7adddd.1755857536.git.geert+renesas@glider.be
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-09-19 19:25:14 +02:00
Geert Uytterhoeven
7abf704493
can: rcar_can: Consistently use ndev for net_device pointers
...
Most net_device pointers are named "ndev", but some are called "dev".
Increase uniformity by always using "ndev".
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be >
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com >
Link: https://patch.msgid.link/aac66fb5b5e1d6787121cf2ec36b551b41d4b32e.1755857536.git.geert+renesas@glider.be
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-09-19 19:25:14 +02:00
Duy Nguyen
5cff263606
can: rcar_canfd: Fix controller mode setting
...
Driver configures register to choose controller mode before
setting all channels to reset mode leading to failure.
The patch corrects operation of mode setting.
Signed-off-by: Duy Nguyen <duy.nguyen.rh@renesas.com >
Signed-off-by: Tranh Ha <tranh.ha.xb@renesas.com >
Link: https://patch.msgid.link/TYWPR01MB87434739F83E27EDCD23DF44B416A@TYWPR01MB8743.jpnprd01.prod.outlook.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-09-19 18:59:15 +02:00
Biju Das
33815032b0
can: rcar_canfd: Simplify data bit rate config
...
Introduce rcar_canfd_compute_data_bit_rate_cfg() for simplifying data bit
rate configuration by replacing function-like macros.
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be >
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com >
Link: https://patch.msgid.link/20250908120940.147196-5-biju.das.jz@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-09-13 19:06:57 +02:00
Biju Das
02d274adf4
can: rcar_canfd: Simplify nominal bit rate config
...
Introduce rcar_canfd_compute_nominal_bit_rate_cfg() for simplifying
nominal bit rate configuration by replacing function-like macros.
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be >
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com >
Link: https://patch.msgid.link/20250908120940.147196-4-biju.das.jz@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-09-13 19:06:55 +02:00
Biju Das
726213c8e7
can: rcar_canfd: Update RCANFD_CFG_* macros
...
Update RCANFD_CFG_* macros to give a meaning to the magic number using
GENMASK macro and extract the values using FIELD_PREP macro.
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be >
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com >
Link: https://patch.msgid.link/20250908120940.147196-3-biju.das.jz@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-09-13 19:06:54 +02:00
Biju Das
100fafc3e4
can: rcar_canfd: Update bit rate constants for RZ/G3E and R-Car Gen4
...
The calculation formula for nominal bit rate of classical CAN is the same as
that of nominal bit rate of CANFD on the RZ/G3E and R-Car Gen4 SoCs
compared to other SoCs. Update nominal bit rate constants.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com >
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be >
Link: https://patch.msgid.link/20250908120940.147196-2-biju.das.jz@bp.renesas.com
[mkl: slightly improve wording of commit message]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-09-13 19:06:52 +02:00
Geert Uytterhoeven
5c793afa07
can: rcar_can: rcar_can_resume(): fix s2ram with PSCI
...
On R-Car Gen3 using PSCI, s2ram powers down the SoC. After resume, the
CAN interface no longer works, until it is brought down and up again.
Fix this by calling rcar_can_start() from the PM resume callback, to
fully initialize the controller instead of just restarting it.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be >
Link: https://patch.msgid.link/699b2f7fcb60b31b6f976a37f08ce99c5ffccb31.1755165227.git.geert+renesas@glider.be
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-09-10 17:12:05 +02:00
Biju Das
0e6639c850
can: rcar_canfd: Drop unused macros
...
Drop unused macros from the rcar_canfd.c.
Reported-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Closes: https://lore.kernel.org/all/7ff93ff9-f578-4be2-bdc6-5b09eab64fe6@wanadoo.fr/
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com >
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://patch.msgid.link/20250702120539.98490-1-biju.das.jz@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-07-11 11:48:02 +02:00
Geert Uytterhoeven
25883e286e
can: rcar_can: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
...
Convert the Renesas R-Car CAN driver from SIMPLE_DEV_PM_OPS() to
DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr(). This lets us drop the
__maybe_unused annotations from its suspend and resume callbacks, and
reduces kernel size in case CONFIG_PM or CONFIG_PM_SLEEP is disabled.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be >
Link: https://patch.msgid.link/6ffe085f6e2548f53674dd11704b388cf4b303e9.1752086078.git.geert+renesas@glider.be
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-07-11 11:34:00 +02:00
Geert Uytterhoeven
ab2aa5453b
can: rcar_canfd: Describe channel-specific FD registers using C struct
...
The rcar_canfd_f_*() inline functions to obtain channel-specific CAN-FD
register offsets really describe a memory layout. Hence replace them by
a C structure, to simplify the code, and reduce kernel size.
This also gets rid of warnings about unused rcar_canfd_f_*() inline
functions, which are reported by recent versions of clang.
Suggested-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Reported-by: Jakub Kicinski <kuba@kernel.org >
Closes: https://lore.kernel.org/20250618183827.5bebca8f@kernel.org
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be >
Acked-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://patch.msgid.link/292b75b3bc8dd95f805f0223f606737071c8cf86.1750327217.git.geert+renesas@glider.be
Signed-off-by: Jakub Kicinski <kuba@kernel.org >
2025-06-21 07:36:21 -07:00
Geert Uytterhoeven
586d5eecdf
can: rcar_canfd: Add support for Transceiver Delay Compensation
...
The Renesas CAN-FD hardware block supports configuring Transceiver Delay
Compensation, and reading back the Transceiver Delay Compensation
Result, which is needed to support high transfer rates like 8 Mbps.
The Secondary Sample Point is either the measured delay plus the
configured offset, or just the configured offset.
Fix the existing RCANFD_FDCFG_TDCO() macro for the intended use case
(writing instead of reading the field). Add register definition bits
for the Channel n CAN-FD Status Register.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://patch.msgid.link/69db727d5f728d679ba691d20854e7d963d0f323.1749655315.git.geert+renesas@glider.be
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-06-13 09:34:09 +02:00
Geert Uytterhoeven
0acd46190e
can: rcar_canfd: Return early in rcar_canfd_set_bittiming() when not FD
...
Return early after completing all setup for non-FD mode in
rcar_canfd_set_bittiming(), to prepare for the advent of more FD-only
setup.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://patch.msgid.link/35fcdcad026cfdd0fd361637f065842d99a6c19d.1749655315.git.geert+renesas@glider.be
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-06-13 09:34:09 +02:00
Geert Uytterhoeven
0a0c94c682
can: rcar_canfd: Share config code in rcar_canfd_set_bittiming()
...
The configuration register format for nominal bit timings in CAN-FD mode
and the format for bit timings in CAN mode on CAN-FD controllers with
shared Classical CAN registers are the same.
Restructure the code to make this clear, also reducing kernel size by 80
bytes.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://patch.msgid.link/b7643a3c49777989d02145a85b85cf773ec2123f.1749655315.git.geert+renesas@glider.be
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-06-13 09:34:09 +02:00
Geert Uytterhoeven
1b76dca8fd
can: rcar_canfd: Rename rcar_canfd_setrnc() to rcar_canfd_set_rnc()
...
Insert an underscore in the function's name, for consistency with other
getter and setter helper functions.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://patch.msgid.link/9fdc2584ce27b2784ecea76390d2a81eab289d0d.1749655315.git.geert+renesas@glider.be
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-06-13 09:34:09 +02:00
Geert Uytterhoeven
e4d8eb97a4
can: rcar_canfd: Repurpose f_dcfg base for other registers
...
Reuse the existing Channel Data Bitrate Configuration Register offset
member in the register configuration as the base offset for all related
channel-specific registers.
Rename the member and update the (incorrect) comment to reflect this.
Replace the function-like channel-specific register offset macros by
inline functions.
This fixes the offsets of all other (currently unused) channel-specific
registers on R-Car Gen4 and RZ/G3E, and allows us to replace
RCANFD_GEN4_FDCFG() by the more generic rcar_canfd_f_cfdcfg().
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://patch.msgid.link/75c8197c849fc9e360a75d4fa55bc01c1d850433.1749655315.git.geert+renesas@glider.be
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-06-13 09:34:09 +02:00
Geert Uytterhoeven
f5e3150b1a
can: rcar_canfd: Simplify data access in rcar_canfd_{ge,pu}t_data()
...
Replace the repeated casts, pointer additions, and pointer dereferences
by array accesses to improve readability.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://patch.msgid.link/4f43f44dcfda13d48a2c502648833934a51d9d6c.1749655315.git.geert+renesas@glider.be
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-06-13 09:34:08 +02:00
Geert Uytterhoeven
1f9b5003d4
can: rcar_canfd: Add helper variable dev to rcar_canfd_reset_controller()
...
rcar_canfd_reset_controller() has many users of "pdev->dev". Introduce
a shorthand to simplify the code.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://patch.msgid.link/21e64816808eb3eba722f4c547f4f5112d5d62a6.1749655315.git.geert+renesas@glider.be
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-06-13 09:34:08 +02:00
Geert Uytterhoeven
4e5974f551
can: rcar_canfd: Add helper variable ndev to rcar_canfd_rx_pkt()
...
rcar_canfd_rx_pkt() has many users of "priv->ndev". Introduce a
shorthand to simplify the code.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://patch.msgid.link/22afe32a65f7c3e64ce3917aec943ac24d6e185a.1749655315.git.geert+renesas@glider.be
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-06-13 09:34:08 +02:00
Geert Uytterhoeven
a627813431
can: rcar_canfd: Remove bittiming debug prints
...
There is no need to have debug code to print the bittiming values, as
the user can get all values through the netlink interface.
Suggested-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://patch.msgid.link/a8b9f2c8938dc5e63b8faf1d0cdc91dadc12117e.1749655315.git.geert+renesas@glider.be
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-06-13 09:34:08 +02:00
Geert Uytterhoeven
df6b192e25
can: rcar_canfd: Consistently use ndev for net_device pointers
...
Most net_device pointers are named "ndev", but some are called "dev".
Increase uniformity by always using "ndev".
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://patch.msgid.link/7593bdd484a35999030865f90e4c9063b22d2a54.1749655315.git.geert+renesas@glider.be
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-06-13 09:34:08 +02:00
Vincent Mailhol
b803c4a4f7
can: dev: add struct data_bittiming_params to group FD parameters
...
This is a preparation patch for the introduction of CAN XL.
CAN FD and CAN XL uses similar bittiming parameters. Add one level of
nesting for all the CAN FD parameters. Typically:
priv->can.data_bittiming;
becomes:
priv->can.fd.data_bittiming;
This way, the CAN XL equivalent (to be introduced later) would be:
priv->can.xl.data_bittiming;
Add the new struct data_bittiming_params which contains all the data
bittiming parameters, including the TDC and the callback functions.
This done, update all the CAN FD drivers to make use of the new
layout.
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net >
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://patch.msgid.link/20250501171213.2161572-2-mailhol.vincent@wanadoo.fr
[mkl: fix rcar_canfd]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-05-21 14:33:28 +02:00
Biju Das
be53aa0520
can: rcar_canfd: Add RZ/G3E support
...
The CAN-FD IP found on the RZ/G3E SoC is similar to R-Car Gen4, but
it has no external clock instead it has clk_ram, it has 6 channels
and supports 20 interrupts. Add support for RZ/G3E CAN-FD driver.
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com >
Link: https://patch.msgid.link/20250417054320.14100-20-biju.das.jz@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-05-21 14:31:26 +02:00
Biju Das
0853b7e479
can: rcar_canfd: Enhance multi_channel_irqs handling
...
Currently multi_channel_irqs has only 2 channels. But RZ/G3E has six
channels. Enhance multi_channel_irqs handling to support more than two
channels.
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com >
Link: https://patch.msgid.link/20250417054320.14100-19-biju.das.jz@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-05-21 14:31:26 +02:00
Biju Das
e5258b337d
can: rcar_canfd: Add external_clk variable to struct rcar_canfd_hw_info
...
All existing SoCs support an external clock, but RZ/G3E has only internal
clocks. Add external_clk variable to struct rcar_canfd_hw_info to handle
this difference.
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com >
Link: https://patch.msgid.link/20250417054320.14100-18-biju.das.jz@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-05-21 14:31:25 +02:00
Biju Das
c5670c23d6
can: rcar_canfd: Add sh variable to struct rcar_canfd_hw_info
...
R-Car Gen3 and Gen4 have some differences in the shift bits. Introduce a
struct rcar_canfd_shift_data to hold these values and add the struct
rcar_canfd_shift_data variable sh to struct rcar_canfd_hw_info to handle
these differences. After this, drop the unused functions reg_gen4() and
is_gen4().
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be >
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com >
Link: https://patch.msgid.link/20250417054320.14100-17-biju.das.jz@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-05-21 14:31:25 +02:00
Biju Das
5026d2acae
can: rcar_canfd: Add struct rcanfd_regs variable to struct rcar_canfd_hw_info
...
R-Car Gen3 and Gen4 have some differences in the register offsets. Add
struct rcanfd_regs variable regs to the struct rcar_canfd_hw_info to
handle these differences.
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be >
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com >
Link: https://patch.msgid.link/20250417054320.14100-16-biju.das.jz@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-05-21 14:31:25 +02:00
Biju Das
836cc711fc
can: rcar_canfd: Add shared_can_regs variable to struct rcar_canfd_hw_info
...
R-Car Gen4 has shared regs for both CAN-FD and Classical CAN operations.
Add shared_can_regs variable to struct rcar_canfd_hw_info to handle this
difference.
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com >
Link: https://patch.msgid.link/20250417054320.14100-15-biju.das.jz@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-05-21 14:31:25 +02:00
Biju Das
c10e551010
can: rcar_canfd: Add ch_interface_mode variable to struct rcar_canfd_hw_info
...
R-Car Gen4 has channel specific interface mode bit for setting CAN-FD or
Classical CAN mode whereas on R-Car Gen3 it is global. Add a
ch_interface_mode variable to struct rcar_canfd_hw_info to handle this
difference.
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com >
Link: https://patch.msgid.link/20250417054320.14100-14-biju.das.jz@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-05-21 14:31:25 +02:00
Biju Das
b5a9f2ec42
can: rcar_canfd: Add {nom,data}_bittiming variables to struct rcar_canfd_hw_info
...
Both R-Car Gen4 and R-Car Gen3 have different bit timing parameters
Add {nom,data}_bittiming variables to struct rcar_canfd_hw_info to
handle this difference.
Since the mask used in the macros are max value - 1, replace that
as well.
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com >
Link: https://patch.msgid.link/20250417054320.14100-13-biju.das.jz@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-05-21 14:31:25 +02:00
Biju Das
04d7a3a466
can: rcar_canfd: Add max_cftml variable to struct rcar_canfd_hw_info
...
R-Car Gen3 has CFTML max positional value is 15 whereas on R-Car Gen4 it
is 31. Add a max_cftml variable to struct rcar_canfd_hw_info to handle
this difference.
While at it, rename the parameter x->cftml in RCANFD_CFCC_CFTML macro to
make it clear.
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com >
Link: https://patch.msgid.link/20250417054320.14100-12-biju.das.jz@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-05-21 14:31:25 +02:00
Biju Das
2d6cb8ff94
can: rcar_canfd: Add max_aflpn variable to struct rcar_canfd_hw_info
...
R-Car Gen3 has maximum acceptance filter list page number of 31 whereas on
R-Car Gen4 it is 127. Add max_aflpn variable to struct rcar_canfd_hw_info
in order to support RZ/G3E that has max AFLPN of 63.
While at it, rename the parameter x->page_num in RCANFD_GAFLECTR_AFLPN
macro to make it clear.
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com >
Link: https://patch.msgid.link/20250417054320.14100-11-biju.das.jz@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-05-21 14:31:24 +02:00
Biju Das
e9ffa12e02
can: rcar_canfd: Add rnc_field_width variable to struct rcar_canfd_hw_info
...
The shift and w value in rcar_canfd_setrnc() are dictated by the
field width:
- R-Car Gen4 packs 2 values in a 32-bit word, using a field width
of 16 bits,
- R-Car Gen3 packs up to 4 values in a 32-bit word, using a field
width of 8 bits.
Add rnc_field_width variable to struct rcar_canfd_hw_info to handle this
difference. The rnc_stride is 32 / rnc_field_width and the index parameter
w is calculated by ch / rnc_stride. The shift value in rcar_canfd_setrnc()
is computed by using (32 - (ch % rnc_stride + 1) * rnc_field_width).
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be >
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com >
Link: https://patch.msgid.link/20250417054320.14100-10-biju.das.jz@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-05-21 14:31:24 +02:00
Biju Das
a2427e4494
can: rcar_canfd: Update RCANFD_GAFLCFG macro
...
Update RCANFD_GAFLCFG macro by replacing the parameter ch->w, where w is
the GAFLCFG index used in the hardware manual.
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be >
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com >
Link: https://patch.msgid.link/20250417054320.14100-9-biju.das.jz@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-05-21 14:31:24 +02:00
Biju Das
6b9f8b53a1
can: rcar_canfd: Add rcar_canfd_setrnc()
...
Add rcar_canfd_setrnc() to replace the macro RCANFD_GAFLCFG_SETRNC.
While at it, replace int->unsigned int for local variables offset, page
and num_rules in rcar_canfd_configure_afl_rules().
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be >
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com >
Link: https://patch.msgid.link/20250417054320.14100-8-biju.das.jz@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-05-21 14:31:24 +02:00
Biju Das
c9e17c91f1
can: rcar_canfd: Drop the mask operation in RCANFD_GAFLCFG_SETRNC macro
...
Drop the mask operation in RCANFD_GAFLCFG_SETRNC macro as the num_rules
can never be larger than number of supported rules.
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be >
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com >
Link: https://patch.msgid.link/20250417054320.14100-7-biju.das.jz@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-05-21 14:31:24 +02:00
Biju Das
b75fcf2af2
can: rcar_canfd: Update RCANFD_GERFL_ERR macro
...
Replace the macro RCANFD_GERFL_EEF0_7->RCANFD_GERFL_EEF. The macros
RCANFD_GERFL_EEF* in RCANFD_GERFL_ERR can be replaced by FIELD_PREP() and
drop the redundant macro RCANFD_GERFL_EEF(ch).
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com >
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be >
Link: https://patch.msgid.link/20250417054320.14100-6-biju.das.jz@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-05-21 14:31:24 +02:00
Biju Das
05e7f5a90c
can: rcar_canfd: Drop RCANFD_GAFLCFG_GETRNC macro
...
Drop the unused macro RCANFD_GAFLCFG_GETRNC.
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com >
Link: https://patch.msgid.link/20250417054320.14100-5-biju.das.jz@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-05-21 14:31:24 +02:00
Biju Das
56f3dc3ea4
can: rcar_canfd: Use of_get_available_child_by_name()
...
Simplify rcar_canfd_probe() using of_get_available_child_by_name().
While at it, move of_node_put(child) inside the if block to avoid
additional check if of_child is NULL.
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be >
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com >
Link: https://patch.msgid.link/20250417054320.14100-4-biju.das.jz@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-05-21 14:31:23 +02:00
Biju Das
1dba0a3764
can: rcar_canfd: Fix page entries in the AFL list
...
There are a total of 96 AFL pages and each page has 16 entries with
registers CFDGAFLIDr, CFDGAFLMr, CFDGAFLP0r, CFDGAFLP1r holding
the rule entries (r = 0..15).
Currently, RCANFD_GAFL* macros use a start variable to find AFL entries,
which is incorrect as the testing on RZ/G3E shows ch1 and ch4
gets a start value of 0 and the register contents are overwritten.
Fix this issue by using rule_entry corresponding to the channel
to find the page entries in the AFL list.
Fixes: dd3bd23eb4 ("can: rcar_canfd: Add Renesas R-Car CAN FD driver")
Cc: stable@vger.kernel.org
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com >
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be >
Link: https://patch.msgid.link/20250307170330.173425-3-biju.das.jz@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2025-03-14 09:50:36 +01:00