mirror of
https://github.com/torvalds/linux.git
synced 2026-05-27 08:33:17 +02:00
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>
This commit is contained in:
parent
2db7a52ca9
commit
44f0b630f6
|
|
@ -66,6 +66,7 @@ MODULE_DESCRIPTION("CAN driver for Kvaser CAN/PCIe devices");
|
|||
#define KVASER_PCIEFD_KCAN_FIFO_LAST_REG 0x180
|
||||
#define KVASER_PCIEFD_KCAN_CTRL_REG 0x2c0
|
||||
#define KVASER_PCIEFD_KCAN_CMD_REG 0x400
|
||||
#define KVASER_PCIEFD_KCAN_IOC_REG 0x404
|
||||
#define KVASER_PCIEFD_KCAN_IEN_REG 0x408
|
||||
#define KVASER_PCIEFD_KCAN_IRQ_REG 0x410
|
||||
#define KVASER_PCIEFD_KCAN_TX_NR_PACKETS_REG 0x414
|
||||
|
|
@ -136,6 +137,9 @@ MODULE_DESCRIPTION("CAN driver for Kvaser CAN/PCIe devices");
|
|||
/* Request status packet */
|
||||
#define KVASER_PCIEFD_KCAN_CMD_SRQ BIT(0)
|
||||
|
||||
/* Control CAN LED, active low */
|
||||
#define KVASER_PCIEFD_KCAN_IOC_LED BIT(0)
|
||||
|
||||
/* Transmitter unaligned */
|
||||
#define KVASER_PCIEFD_KCAN_IRQ_TAL BIT(17)
|
||||
/* Tx FIFO empty */
|
||||
|
|
@ -410,6 +414,7 @@ struct kvaser_pciefd_can {
|
|||
struct kvaser_pciefd *kv_pcie;
|
||||
void __iomem *reg_base;
|
||||
struct can_berr_counter bec;
|
||||
u32 ioc;
|
||||
u8 cmd_seq;
|
||||
u8 tx_max_count;
|
||||
u8 tx_idx;
|
||||
|
|
@ -528,6 +533,16 @@ static inline void kvaser_pciefd_abort_flush_reset(struct kvaser_pciefd_can *can
|
|||
kvaser_pciefd_send_kcan_cmd(can, KVASER_PCIEFD_KCAN_CMD_AT);
|
||||
}
|
||||
|
||||
static inline void kvaser_pciefd_set_led(struct kvaser_pciefd_can *can, bool on)
|
||||
{
|
||||
if (on)
|
||||
can->ioc &= ~KVASER_PCIEFD_KCAN_IOC_LED;
|
||||
else
|
||||
can->ioc |= KVASER_PCIEFD_KCAN_IOC_LED;
|
||||
|
||||
iowrite32(can->ioc, can->reg_base + KVASER_PCIEFD_KCAN_IOC_REG);
|
||||
}
|
||||
|
||||
static void kvaser_pciefd_enable_err_gen(struct kvaser_pciefd_can *can)
|
||||
{
|
||||
u32 mode;
|
||||
|
|
@ -990,6 +1005,9 @@ static int kvaser_pciefd_setup_can_ctrls(struct kvaser_pciefd *pcie)
|
|||
/* Disable Bus load reporting */
|
||||
iowrite32(0, can->reg_base + KVASER_PCIEFD_KCAN_BUS_LOAD_REG);
|
||||
|
||||
can->ioc = ioread32(can->reg_base + KVASER_PCIEFD_KCAN_IOC_REG);
|
||||
kvaser_pciefd_set_led(can, false);
|
||||
|
||||
tx_nr_packets_max =
|
||||
FIELD_GET(KVASER_PCIEFD_KCAN_TX_NR_PACKETS_MAX_MASK,
|
||||
ioread32(can->reg_base + KVASER_PCIEFD_KCAN_TX_NR_PACKETS_REG));
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user