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

can: kvaser_pciefd: Split driver into C-file and header-file.

Split driver into C-file and header-file, to simplify future patches.
Move common definitions and declarations to a header file.

Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
Link: https://patch.msgid.link/20250725123230.8-7-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

authored by

Jimmy Assarsson and committed by
Marc Kleine-Budde
20bc87ae d54b16b4

+96 -71
+1 -1
drivers/net/can/Makefile
··· 25 25 obj-$(CONFIG_CAN_GRCAN) += grcan.o 26 26 obj-$(CONFIG_CAN_IFI_CANFD) += ifi_canfd/ 27 27 obj-$(CONFIG_CAN_JANZ_ICAN3) += janz-ican3.o 28 - obj-$(CONFIG_CAN_KVASER_PCIEFD) += kvaser_pciefd.o 28 + obj-$(CONFIG_CAN_KVASER_PCIEFD) += kvaser_pciefd/ 29 29 obj-$(CONFIG_CAN_MSCAN) += mscan/ 30 30 obj-$(CONFIG_CAN_M_CAN) += m_can/ 31 31 obj-$(CONFIG_CAN_PEAK_PCIEFD) += peak_canfd/
+2 -70
drivers/net/can/kvaser_pciefd.c drivers/net/can/kvaser_pciefd/kvaser_pciefd_core.c
··· 5 5 * - PEAK linux canfd driver 6 6 */ 7 7 8 + #include "kvaser_pciefd.h" 9 + 8 10 #include <linux/bitfield.h> 9 11 #include <linux/can/dev.h> 10 12 #include <linux/device.h> ··· 29 27 #define KVASER_PCIEFD_WAIT_TIMEOUT msecs_to_jiffies(1000) 30 28 #define KVASER_PCIEFD_BEC_POLL_FREQ (jiffies + msecs_to_jiffies(200)) 31 29 #define KVASER_PCIEFD_MAX_ERR_REP 256U 32 - #define KVASER_PCIEFD_CAN_TX_MAX_COUNT 17U 33 - #define KVASER_PCIEFD_MAX_CAN_CHANNELS 8UL 34 - #define KVASER_PCIEFD_DMA_COUNT 2U 35 - #define KVASER_PCIEFD_DMA_SIZE (4U * 1024U) 36 30 37 31 #define KVASER_PCIEFD_VENDOR 0x1a07 38 32 ··· 294 296 static void kvaser_pciefd_write_dma_map_xilinx(struct kvaser_pciefd *pcie, 295 297 dma_addr_t addr, int index); 296 298 297 - struct kvaser_pciefd_address_offset { 298 - u32 serdes; 299 - u32 pci_ien; 300 - u32 pci_irq; 301 - u32 sysid; 302 - u32 loopback; 303 - u32 kcan_srb_fifo; 304 - u32 kcan_srb; 305 - u32 kcan_ch0; 306 - u32 kcan_ch1; 307 - }; 308 - 309 - struct kvaser_pciefd_dev_ops { 310 - void (*kvaser_pciefd_write_dma_map)(struct kvaser_pciefd *pcie, 311 - dma_addr_t addr, int index); 312 - }; 313 - 314 - struct kvaser_pciefd_irq_mask { 315 - u32 kcan_rx0; 316 - u32 kcan_tx[KVASER_PCIEFD_MAX_CAN_CHANNELS]; 317 - u32 all; 318 - }; 319 - 320 - struct kvaser_pciefd_driver_data { 321 - const struct kvaser_pciefd_address_offset *address_offset; 322 - const struct kvaser_pciefd_irq_mask *irq_mask; 323 - const struct kvaser_pciefd_dev_ops *ops; 324 - }; 325 - 326 - struct kvaser_pciefd_fw_version { 327 - u8 major; 328 - u8 minor; 329 - u16 build; 330 - }; 331 - 332 299 static const struct kvaser_pciefd_address_offset kvaser_pciefd_altera_address_offset = { 333 300 .serdes = 0x1000, 334 301 .pci_ien = 0x50, ··· 376 413 .address_offset = &kvaser_pciefd_xilinx_address_offset, 377 414 .irq_mask = &kvaser_pciefd_xilinx_irq_mask, 378 415 .ops = &kvaser_pciefd_xilinx_dev_ops, 379 - }; 380 - 381 - struct kvaser_pciefd_can { 382 - struct can_priv can; 383 - struct kvaser_pciefd *kv_pcie; 384 - void __iomem *reg_base; 385 - struct can_berr_counter bec; 386 - u32 ioc; 387 - u8 cmd_seq; 388 - u8 tx_max_count; 389 - u8 tx_idx; 390 - u8 ack_idx; 391 - int err_rep_cnt; 392 - unsigned int completed_tx_pkts; 393 - unsigned int completed_tx_bytes; 394 - spinlock_t lock; /* Locks sensitive registers (e.g. MODE) */ 395 - struct timer_list bec_poll_timer; 396 - struct completion start_comp, flush_comp; 397 - }; 398 - 399 - struct kvaser_pciefd { 400 - struct pci_dev *pci; 401 - void __iomem *reg_base; 402 - struct kvaser_pciefd_can *can[KVASER_PCIEFD_MAX_CAN_CHANNELS]; 403 - const struct kvaser_pciefd_driver_data *driver_data; 404 - void *dma_data[KVASER_PCIEFD_DMA_COUNT]; 405 - u8 nr_channels; 406 - u32 bus_freq; 407 - u32 freq; 408 - u32 freq_to_ticks_div; 409 - struct kvaser_pciefd_fw_version fw_version; 410 416 }; 411 417 412 418 struct kvaser_pciefd_rx_packet {
+3
drivers/net/can/kvaser_pciefd/Makefile
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + obj-$(CONFIG_CAN_KVASER_PCIEFD) += kvaser_pciefd.o 3 + kvaser_pciefd-y = kvaser_pciefd_core.o
+90
drivers/net/can/kvaser_pciefd/kvaser_pciefd.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */ 2 + /* kvaser_pciefd common definitions and declarations 3 + * 4 + * Copyright (C) 2025 KVASER AB, Sweden. All rights reserved. 5 + */ 6 + 7 + #ifndef _KVASER_PCIEFD_H 8 + #define _KVASER_PCIEFD_H 9 + 10 + #include <linux/can/dev.h> 11 + #include <linux/completion.h> 12 + #include <linux/pci.h> 13 + #include <linux/spinlock.h> 14 + #include <linux/timer.h> 15 + #include <linux/types.h> 16 + 17 + #define KVASER_PCIEFD_MAX_CAN_CHANNELS 8UL 18 + #define KVASER_PCIEFD_DMA_COUNT 2U 19 + #define KVASER_PCIEFD_DMA_SIZE (4U * 1024U) 20 + #define KVASER_PCIEFD_CAN_TX_MAX_COUNT 17U 21 + 22 + struct kvaser_pciefd; 23 + 24 + struct kvaser_pciefd_address_offset { 25 + u32 serdes; 26 + u32 pci_ien; 27 + u32 pci_irq; 28 + u32 sysid; 29 + u32 loopback; 30 + u32 kcan_srb_fifo; 31 + u32 kcan_srb; 32 + u32 kcan_ch0; 33 + u32 kcan_ch1; 34 + }; 35 + 36 + struct kvaser_pciefd_irq_mask { 37 + u32 kcan_rx0; 38 + u32 kcan_tx[KVASER_PCIEFD_MAX_CAN_CHANNELS]; 39 + u32 all; 40 + }; 41 + 42 + struct kvaser_pciefd_dev_ops { 43 + void (*kvaser_pciefd_write_dma_map)(struct kvaser_pciefd *pcie, 44 + dma_addr_t addr, int index); 45 + }; 46 + 47 + struct kvaser_pciefd_driver_data { 48 + const struct kvaser_pciefd_address_offset *address_offset; 49 + const struct kvaser_pciefd_irq_mask *irq_mask; 50 + const struct kvaser_pciefd_dev_ops *ops; 51 + }; 52 + 53 + struct kvaser_pciefd_fw_version { 54 + u8 major; 55 + u8 minor; 56 + u16 build; 57 + }; 58 + 59 + struct kvaser_pciefd_can { 60 + struct can_priv can; 61 + struct kvaser_pciefd *kv_pcie; 62 + void __iomem *reg_base; 63 + struct can_berr_counter bec; 64 + u32 ioc; 65 + u8 cmd_seq; 66 + u8 tx_max_count; 67 + u8 tx_idx; 68 + u8 ack_idx; 69 + int err_rep_cnt; 70 + unsigned int completed_tx_pkts; 71 + unsigned int completed_tx_bytes; 72 + spinlock_t lock; /* Locks sensitive registers (e.g. MODE) */ 73 + struct timer_list bec_poll_timer; 74 + struct completion start_comp, flush_comp; 75 + }; 76 + 77 + struct kvaser_pciefd { 78 + struct pci_dev *pci; 79 + void __iomem *reg_base; 80 + struct kvaser_pciefd_can *can[KVASER_PCIEFD_MAX_CAN_CHANNELS]; 81 + const struct kvaser_pciefd_driver_data *driver_data; 82 + void *dma_data[KVASER_PCIEFD_DMA_COUNT]; 83 + u8 nr_channels; 84 + u32 bus_freq; 85 + u32 freq; 86 + u32 freq_to_ticks_div; 87 + struct kvaser_pciefd_fw_version fw_version; 88 + }; 89 + 90 + #endif /* _KVASER_PCIEFD_H */