Skip to content

Commit 44f0b63

Browse files
Jimmy Assarssonmarckleinebudde
authored andcommitted
can: kvaser_pciefd: Add support to control CAN LEDs on device
Add support to turn on/off CAN LEDs on device. Turn off all CAN LEDs in probe, since they are default on after a reset or power on. Reviewed-by: Axel Forsman <axfo@kvaser.com> Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> Signed-off-by: Jimmy Assarsson <extja@kvaser.com> Link: https://patch.msgid.link/20250725123230.8-2-extja@kvaser.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
1 parent 2db7a52 commit 44f0b63

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

drivers/net/can/kvaser_pciefd.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ MODULE_DESCRIPTION("CAN driver for Kvaser CAN/PCIe devices");
6666
#define KVASER_PCIEFD_KCAN_FIFO_LAST_REG 0x180
6767
#define KVASER_PCIEFD_KCAN_CTRL_REG 0x2c0
6868
#define KVASER_PCIEFD_KCAN_CMD_REG 0x400
69+
#define KVASER_PCIEFD_KCAN_IOC_REG 0x404
6970
#define KVASER_PCIEFD_KCAN_IEN_REG 0x408
7071
#define KVASER_PCIEFD_KCAN_IRQ_REG 0x410
7172
#define KVASER_PCIEFD_KCAN_TX_NR_PACKETS_REG 0x414
@@ -136,6 +137,9 @@ MODULE_DESCRIPTION("CAN driver for Kvaser CAN/PCIe devices");
136137
/* Request status packet */
137138
#define KVASER_PCIEFD_KCAN_CMD_SRQ BIT(0)
138139

140+
/* Control CAN LED, active low */
141+
#define KVASER_PCIEFD_KCAN_IOC_LED BIT(0)
142+
139143
/* Transmitter unaligned */
140144
#define KVASER_PCIEFD_KCAN_IRQ_TAL BIT(17)
141145
/* Tx FIFO empty */
@@ -410,6 +414,7 @@ struct kvaser_pciefd_can {
410414
struct kvaser_pciefd *kv_pcie;
411415
void __iomem *reg_base;
412416
struct can_berr_counter bec;
417+
u32 ioc;
413418
u8 cmd_seq;
414419
u8 tx_max_count;
415420
u8 tx_idx;
@@ -528,6 +533,16 @@ static inline void kvaser_pciefd_abort_flush_reset(struct kvaser_pciefd_can *can
528533
kvaser_pciefd_send_kcan_cmd(can, KVASER_PCIEFD_KCAN_CMD_AT);
529534
}
530535

536+
static inline void kvaser_pciefd_set_led(struct kvaser_pciefd_can *can, bool on)
537+
{
538+
if (on)
539+
can->ioc &= ~KVASER_PCIEFD_KCAN_IOC_LED;
540+
else
541+
can->ioc |= KVASER_PCIEFD_KCAN_IOC_LED;
542+
543+
iowrite32(can->ioc, can->reg_base + KVASER_PCIEFD_KCAN_IOC_REG);
544+
}
545+
531546
static void kvaser_pciefd_enable_err_gen(struct kvaser_pciefd_can *can)
532547
{
533548
u32 mode;
@@ -990,6 +1005,9 @@ static int kvaser_pciefd_setup_can_ctrls(struct kvaser_pciefd *pcie)
9901005
/* Disable Bus load reporting */
9911006
iowrite32(0, can->reg_base + KVASER_PCIEFD_KCAN_BUS_LOAD_REG);
9921007

1008+
can->ioc = ioread32(can->reg_base + KVASER_PCIEFD_KCAN_IOC_REG);
1009+
kvaser_pciefd_set_led(can, false);
1010+
9931011
tx_nr_packets_max =
9941012
FIELD_GET(KVASER_PCIEFD_KCAN_TX_NR_PACKETS_MAX_MASK,
9951013
ioread32(can->reg_base + KVASER_PCIEFD_KCAN_TX_NR_PACKETS_REG));

0 commit comments

Comments
 (0)