Skip to content

Commit d2beb85

Browse files
DonBrusdor-dbrusamento
authored andcommitted
drivers: can: mchp_mss: add control via KConfig of CAN_CONFIG.SWAP_ENDIAN bit
1 parent a12ace0 commit d2beb85

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

drivers/can/Kconfig.mchp_mss

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,19 @@ config CAN_MCHP_MSS
77
help
88
This option enables the CAN driver for Microchip's PolarFire SoC
99
platform.
10+
11+
if CAN_MCHP_MSS
12+
13+
config CAN_MCHP_MSS_SWAP_ENDIANNESS
14+
bool "Force little endian on transmit and receive buffers."
15+
default n
16+
help
17+
This option sets the SWAP_ENDIAN bit of CAN_CONFIG register.
18+
By setting this bit, the values of [TX|RX]_MSGx_DATA_[LOW|HIGH]
19+
will operate in little endian mode. For example, either field set
20+
to 0x01020304 will result in 0x01 -> 0x02 -> 0x03 -> 0x04 being written on the bus.
21+
22+
Conversely, when operating in the (default) big endian mode, the inverse
23+
sequence will be transmitted on the bus, i.e. in network order.
24+
25+
endif # CAN_MCHP_MSS

drivers/can/can_mchp_mss.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,14 @@ static int mss_can_reset(const struct device *dev)
269269
mss_can_stop_and_disable_interrupts(reg_base);
270270
BUILD_ASSERT(MSS_CAN_TX_MSG_COUNT == MSS_CAN_RX_MSG_COUNT);
271271

272+
uint32_t can_config = sys_read32(reg_base + MSS_CAN_CONFIG);
273+
#if CONFIG_CAN_MCHP_MSS_SWAP_ENDIANNESS
274+
can_config |= MSS_CAN_CFG_SWAP_ENDIAN;
275+
#else
276+
can_config &= ~MSS_CAN_CFG_SWAP_ENDIAN;
277+
#endif
278+
sys_write32(can_config, reg_base + MSS_CAN_CONFIG);
279+
272280
for (uintptr_t i = 0; i < MSS_CAN_TX_MSG_COUNT; ++i) {
273281
/* Clear transmit buffer */
274282
uintptr_t tx_msg_base = reg_base + MSS_CAN_TX_MSG(i);

0 commit comments

Comments
 (0)