Skip to content

Commit 88da174

Browse files
Ji-Ze Hongmarckleinebudde
authored andcommitted
can: usb: f81604: add Fintek F81604 support
This patch adds support for Fintek USB to 2CAN controller. Changelog: v7: https://lore.kernel.org/all/20230509073821.25289-1-peter_hong@fintek.com.tw 1. Fix consistency of coding style for "break" in f81604_register_urbs(). 2. Remove goto statement in f81604_open(). v6: https://lore.kernel.org/all/20230505022317.22417-1-peter_hong@fintek.com.tw 1. Remove non-used define and change constant mask to GENMASK(). 2. Move some variables declaration from function start to block start. 3. Move some variables initization into declaration. 4. Change variable "id" in f81604_start_xmit() only for CAN ID usage. v5: https://lore.kernel.org/all/20230420024403.13830-1-peter_hong@fintek.com.tw 1. Change all u8 *buff to struct f81604_int_data/f81604_can_frame. 2. Change all netdev->dev_id to netdev->dev_port. 3. Remove over design for f81604_process_rx_packet(). This device only report a frame at once, so the f81604_process_rx_packet() are reduced to process 1 frame. v4: https://lore.kernel.org/all/20230413084253.1524-1-peter_hong@fintek.com.tw 1. Remove f81604_prepare_urbs/f81604_remove_urbs() and alloc URB/buffer dynamically in f81604_register_urbs(), using "urbs_anchor" for manage all rx/int URBs. 2. Add F81604 to MAINTAINERS list. 3. Change handle_clear_reg_work/handle_clear_overrun_work to single clear_reg_work and using bitwise "clear_flags" to record it. 4. Move __f81604_set_termination in front of f81604_probe() to avoid rarely racing condition. 5. Add __aligned to struct f81604_int_data / f81604_sff / f81604_eff. 6. Add aligned operations in f81604_start_xmit/f81604_process_rx_packet(). 7. Change lots of CANBUS functions first parameter from struct usb_device* to struct f81604_port_priv *priv. But remain f81604_write / f81604_read / f81604_update_bits() as struct usb_device* for __f81604_set_termination() in probe() stage. 8. Simplify f81604_read_int_callback() and separate into f81604_handle_tx / f81604_handle_can_bus_errors() functions. v3: https://lore.kernel.org/all/20230327051048.11589-1-peter_hong@fintek.com.tw 1. Change CAN clock to using MEGA units. 2. Remove USB set/get retry, only remain SJA1000 reset/operation retry. 3. Fix all numberic constant to define. 4. Add terminator control. (only 0 & 120 ohm) 5. Using struct data to represent INT/TX/RX endpoints data instead byte arrays. 6. Error message reports changed from %d to %pe for mnemotechnic values. 7. Some bit operations are changed to FIELD_PREP(). 8. Separate TX functions from f81604_read_int_callback(). 9. cf->can_id |= CAN_ERR_CNT in f81604_read_int_callback to report valid TX/RX error counts. 10. Move f81604_prepare_urbs/f81604_remove_urbs() from CAN open/close() to USB probe/disconnect(). 11. coding style refactoring. v2: https://lore.kernel.org/all/20230321081152.26510-1-peter_hong@fintek.com.tw 1. coding style refactoring. 2. some const number are defined to describe itself. 3. fix wrong usage for can_get_echo_skb() in f81604_write_bulk_callback(). v1: https://lore.kernel.org/all/20230317093352.3979-1-peter_hong@fintek.com.tw Signed-off-by: Ji-Ze Hong (Peter Hong) <peter_hong@fintek.com.tw> Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> Link: https://lore.kernel.org/all/20230509073821.25289-1-peter_hong@fintek.com.tw [mkl: add changelog, fix printf format] Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
1 parent 0d9b41d commit 88da174

File tree

4 files changed

+1220
-0
lines changed

4 files changed

+1220
-0
lines changed

MAINTAINERS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7966,6 +7966,12 @@ S: Maintained
79667966
F: drivers/hwmon/f75375s.c
79677967
F: include/linux/f75375s.h
79687968

7969+
FINTEK F81604 USB to 2xCANBUS DEVICE DRIVER
7970+
M: Ji-Ze Hong (Peter Hong) <peter_hong@fintek.com.tw>
7971+
L: linux-can@vger.kernel.org
7972+
S: Maintained
7973+
F: drivers/net/can/usb/f81604.c
7974+
79697975
FIREWIRE AUDIO DRIVERS and IEC 61883-1/6 PACKET STREAMING ENGINE
79707976
M: Clemens Ladisch <clemens@ladisch.de>
79717977
M: Takashi Sakamoto <o-takashi@sakamocchi.jp>

drivers/net/can/usb/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ config CAN_ETAS_ES58X
3838
To compile this driver as a module, choose M here: the module
3939
will be called etas_es58x.
4040

41+
config CAN_F81604
42+
tristate "Fintek F81604 USB to 2CAN interface"
43+
help
44+
This driver supports the Fintek F81604 USB to 2CAN interface.
45+
The device can support CAN2.0A/B protocol and also support
46+
2 output pins to control external terminator (optional).
47+
48+
To compile this driver as a module, choose M here: the module will
49+
be called f81604.
50+
51+
(see also https://www.fintek.com.tw).
52+
4153
config CAN_GS_USB
4254
tristate "Geschwister Schneider UG and candleLight compatible interfaces"
4355
help

drivers/net/can/usb/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ obj-$(CONFIG_CAN_8DEV_USB) += usb_8dev.o
77
obj-$(CONFIG_CAN_EMS_USB) += ems_usb.o
88
obj-$(CONFIG_CAN_ESD_USB) += esd_usb.o
99
obj-$(CONFIG_CAN_ETAS_ES58X) += etas_es58x/
10+
obj-$(CONFIG_CAN_F81604) += f81604.o
1011
obj-$(CONFIG_CAN_GS_USB) += gs_usb.o
1112
obj-$(CONFIG_CAN_KVASER_USB) += kvaser_usb/
1213
obj-$(CONFIG_CAN_MCBA_USB) += mcba_usb.o

0 commit comments

Comments
 (0)