* [PATCH] can: peak_usb: Add support of loopback mode to the PCAN-USB FD family
@ 2026-09-30 13:34 Stéphane Grosjean
2026-09-30 13:51 ` Marc Kleine-Budde
0 siblings, 1 reply; 4+ messages in thread
From: Stéphane Grosjean @ 2026-09-30 13:34 UTC (permalink / raw)
To: Marc Kleine-Budde, Vincent Mailhol
Cc: linux-can, linux-kernel, Stéphane Grosjean
From: Stéphane Grosjean <s.grosjean@peak-system.fr>
This commit adds loopback mode support for all PEAK-System USB-to-CAN FD
interfaces.
The implementation follows the same approach as the peak_pciefd driver.
The only difference is local echo handling: on USB devices, transmit
confirmations are provided through USB write acknowledgments rather than
through the reception of a controller-generated loopback frame.
Signed-off-by: Stéphane Grosjean <s.grosjean@peak-system.fr>
---
drivers/net/can/usb/peak_usb/pcan_usb_fd.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
index 5840623662af..a00ce1f52341 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
@@ -934,6 +934,12 @@ static int pcan_usb_fd_encode_msg(struct peak_usb_device *dev,
if (dev->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT)
tx_msg_flags |= PUCAN_MSG_SINGLE_SHOT;
+ /* Request controller loopback and mark the frame as self-received,
+ * matching the behavior of the peak_pciefd driver.
+ */
+ if (dev->can.ctrlmode & CAN_CTRLMODE_LOOPBACK)
+ tx_msg_flags |= PUCAN_MSG_LOOPED_BACK | PUCAN_MSG_SELF_RECEIVE;
+
tx_msg->flags = cpu_to_le16(tx_msg_flags);
tx_msg->channel_dlc = PUCAN_MSG_CHANNEL_DLC(dev->ctrl_idx, dlc);
memcpy(tx_msg->d, cfd->data, cfd->len);
@@ -1266,7 +1272,7 @@ const struct peak_usb_adapter pcan_usb_fd = {
.ctrlmode_supported = CAN_CTRLMODE_FD |
CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_LISTENONLY |
CAN_CTRLMODE_ONE_SHOT | CAN_CTRLMODE_CC_LEN8_DLC |
- CAN_CTRLMODE_BERR_REPORTING,
+ CAN_CTRLMODE_BERR_REPORTING | CAN_CTRLMODE_LOOPBACK,
.clock = {
.freq = PCAN_UFD_CRYSTAL_HZ,
},
@@ -1343,7 +1349,7 @@ const struct peak_usb_adapter pcan_usb_chip = {
.ctrlmode_supported = CAN_CTRLMODE_FD |
CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_LISTENONLY |
CAN_CTRLMODE_ONE_SHOT | CAN_CTRLMODE_CC_LEN8_DLC |
- CAN_CTRLMODE_BERR_REPORTING,
+ CAN_CTRLMODE_BERR_REPORTING | CAN_CTRLMODE_LOOPBACK,
.clock = {
.freq = PCAN_UFD_CRYSTAL_HZ,
},
@@ -1420,7 +1426,7 @@ const struct peak_usb_adapter pcan_usb_pro_fd = {
.ctrlmode_supported = CAN_CTRLMODE_FD |
CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_LISTENONLY |
CAN_CTRLMODE_ONE_SHOT | CAN_CTRLMODE_CC_LEN8_DLC |
- CAN_CTRLMODE_BERR_REPORTING,
+ CAN_CTRLMODE_BERR_REPORTING | CAN_CTRLMODE_LOOPBACK,
.clock = {
.freq = PCAN_UFD_CRYSTAL_HZ,
},
@@ -1497,7 +1503,7 @@ const struct peak_usb_adapter pcan_usb_x6 = {
.ctrlmode_supported = CAN_CTRLMODE_FD |
CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_LISTENONLY |
CAN_CTRLMODE_ONE_SHOT | CAN_CTRLMODE_CC_LEN8_DLC |
- CAN_CTRLMODE_BERR_REPORTING,
+ CAN_CTRLMODE_BERR_REPORTING | CAN_CTRLMODE_LOOPBACK,
.clock = {
.freq = PCAN_UFD_CRYSTAL_HZ,
},
---
base-commit: baf950233c8efcd3807f771ae5dc3cd6f5326278
change-id: 20260930-peak_usb-canfd-loopback-ffffe0ff9015
Best regards,
--
Stéphane Grosjean <s.grosjean@peak-system.fr>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] can: peak_usb: Add support of loopback mode to the PCAN-USB FD family
2026-09-30 13:34 [PATCH] can: peak_usb: Add support of loopback mode to the PCAN-USB FD family Stéphane Grosjean
@ 2026-09-30 13:51 ` Marc Kleine-Budde
2026-09-30 14:24 ` Stéphane Grosjean
0 siblings, 1 reply; 4+ messages in thread
From: Marc Kleine-Budde @ 2026-09-30 13:51 UTC (permalink / raw)
To: Stéphane Grosjean
Cc: Vincent Mailhol, linux-can, linux-kernel, Stéphane Grosjean
[-- Attachment #1: Type: text/plain, Size: 2369 bytes --]
On 30.09.2026 15:34:48, Stéphane Grosjean wrote:
> From: Stéphane Grosjean <s.grosjean@peak-system.fr>
>
> This commit adds loopback mode support for all PEAK-System USB-to-CAN FD
> interfaces.
>
> The implementation follows the same approach as the peak_pciefd driver.
> The only difference is local echo handling: on USB devices, transmit
> confirmations are provided through USB write acknowledgments rather than
> through the reception of a controller-generated loopback frame.
>
> Signed-off-by: Stéphane Grosjean <s.grosjean@peak-system.fr>
> ---
> drivers/net/can/usb/peak_usb/pcan_usb_fd.c | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
> index 5840623662af..a00ce1f52341 100644
> --- a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
> +++ b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
> @@ -934,6 +934,12 @@ static int pcan_usb_fd_encode_msg(struct peak_usb_device *dev,
> if (dev->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT)
> tx_msg_flags |= PUCAN_MSG_SINGLE_SHOT;
>
> + /* Request controller loopback and mark the frame as self-received,
> + * matching the behavior of the peak_pciefd driver.
> + */
> + if (dev->can.ctrlmode & CAN_CTRLMODE_LOOPBACK)
> + tx_msg_flags |= PUCAN_MSG_LOOPED_BACK | PUCAN_MSG_SELF_RECEIVE;
> +
> tx_msg->flags = cpu_to_le16(tx_msg_flags);
> tx_msg->channel_dlc = PUCAN_MSG_CHANNEL_DLC(dev->ctrl_idx, dlc);
> memcpy(tx_msg->d, cfd->data, cfd->len);
> @@ -1266,7 +1272,7 @@ const struct peak_usb_adapter pcan_usb_fd = {
> .ctrlmode_supported = CAN_CTRLMODE_FD |
> CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_LISTENONLY |
> CAN_CTRLMODE_ONE_SHOT | CAN_CTRLMODE_CC_LEN8_DLC |
> - CAN_CTRLMODE_BERR_REPORTING,
> + CAN_CTRLMODE_BERR_REPORTING | CAN_CTRLMODE_LOOPBACK,
Can you keep the CAN_CTRLMODE sorted by their value?
Please make an incremental patch for the CAN_CTRLMODE_BERR_REPORTING,
I'll squash that...and add CAN_CTRLMODE_LOOPBACK in the appropriate
place.
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] can: peak_usb: Add support of loopback mode to the PCAN-USB FD family
2026-09-30 13:51 ` Marc Kleine-Budde
@ 2026-09-30 14:24 ` Stéphane Grosjean
2026-09-30 14:43 ` Marc Kleine-Budde
0 siblings, 1 reply; 4+ messages in thread
From: Stéphane Grosjean @ 2026-09-30 14:24 UTC (permalink / raw)
To: Marc Kleine-Budde
Cc: Vincent Mailhol, linux-can, linux-kernel, Stéphane Grosjean
> > @@ -1266,7 +1272,7 @@ const struct peak_usb_adapter pcan_usb_fd = {
> > .ctrlmode_supported = CAN_CTRLMODE_FD |
> > CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_LISTENONLY |
> > CAN_CTRLMODE_ONE_SHOT | CAN_CTRLMODE_CC_LEN8_DLC |
> > - CAN_CTRLMODE_BERR_REPORTING,
> > + CAN_CTRLMODE_BERR_REPORTING | CAN_CTRLMODE_LOOPBACK,
>
> Can you keep the CAN_CTRLMODE sorted by their value?
>
> Please make an incremental patch for the CAN_CTRLMODE_BERR_REPORTING,
> I'll squash that...and add CAN_CTRLMODE_LOOPBACK in the appropriate
> place.
>
Hello Marc,
Do you want me to post a v2 of this patch with the CAN_CTRLMODE flags sorted by value, or do you prefer a separate incremental patch on top of the bus error reporting series?
> Marc
>
> --
> Pengutronix e.K. | Marc Kleine-Budde |
> Embedded Linux | https://www.pengutronix.de |
> Vertretung Nürnberg | Phone: +49-5121-206917-129 |
> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] can: peak_usb: Add support of loopback mode to the PCAN-USB FD family
2026-09-30 14:24 ` Stéphane Grosjean
@ 2026-09-30 14:43 ` Marc Kleine-Budde
0 siblings, 0 replies; 4+ messages in thread
From: Marc Kleine-Budde @ 2026-09-30 14:43 UTC (permalink / raw)
To: Stéphane Grosjean
Cc: Vincent Mailhol, linux-can, linux-kernel, Stéphane Grosjean
[-- Attachment #1: Type: text/plain, Size: 1290 bytes --]
On 30.09.2026 16:24:44, Stéphane Grosjean wrote:
> > > @@ -1266,7 +1272,7 @@ const struct peak_usb_adapter pcan_usb_fd = {
> > > .ctrlmode_supported = CAN_CTRLMODE_FD |
> > > CAN_CTRLMODE_3_SAMPLES | CAN_CTRLMODE_LISTENONLY |
> > > CAN_CTRLMODE_ONE_SHOT | CAN_CTRLMODE_CC_LEN8_DLC |
> > > - CAN_CTRLMODE_BERR_REPORTING,
> > > + CAN_CTRLMODE_BERR_REPORTING | CAN_CTRLMODE_LOOPBACK,
> >
> > Can you keep the CAN_CTRLMODE sorted by their value?
> >
> > Please make an incremental patch for the CAN_CTRLMODE_BERR_REPORTING,
> > I'll squash that...and add CAN_CTRLMODE_LOOPBACK in the appropriate
> > place.
>
> Do you want me to post a v2 of this patch with the CAN_CTRLMODE flags
> sorted by value, or do you prefer a separate incremental patch on top
> of the bus error reporting series?
Sorry for being unclear. :)
Please a separate incremental patch on top of the bus error reporting
series.
Then post a v2 of the loopback patch on top of the incremental patch.
regards,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-30 14:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-30 13:34 [PATCH] can: peak_usb: Add support of loopback mode to the PCAN-USB FD family Stéphane Grosjean
2026-09-30 13:51 ` Marc Kleine-Budde
2026-09-30 14:24 ` Stéphane Grosjean
2026-09-30 14:43 ` Marc Kleine-Budde
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®