diff options
Diffstat (limited to 'drivers/net/can/mcp251x.c')
-rw-r--r-- | drivers/net/can/mcp251x.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c index a580db29e503..26e7129332ab 100644 --- a/drivers/net/can/mcp251x.c +++ b/drivers/net/can/mcp251x.c | |||
@@ -83,6 +83,11 @@ | |||
83 | #define INSTRUCTION_LOAD_TXB(n) (0x40 + 2 * (n)) | 83 | #define INSTRUCTION_LOAD_TXB(n) (0x40 + 2 * (n)) |
84 | #define INSTRUCTION_READ_RXB(n) (((n) == 0) ? 0x90 : 0x94) | 84 | #define INSTRUCTION_READ_RXB(n) (((n) == 0) ? 0x90 : 0x94) |
85 | #define INSTRUCTION_RESET 0xC0 | 85 | #define INSTRUCTION_RESET 0xC0 |
86 | #define RTS_TXB0 0x01 | ||
87 | #define RTS_TXB1 0x02 | ||
88 | #define RTS_TXB2 0x04 | ||
89 | #define INSTRUCTION_RTS(n) (0x80 | ((n) & 0x07)) | ||
90 | |||
86 | 91 | ||
87 | /* MPC251x registers */ | 92 | /* MPC251x registers */ |
88 | #define CANSTAT 0x0e | 93 | #define CANSTAT 0x0e |
@@ -397,6 +402,7 @@ static void mcp251x_hw_tx_frame(struct spi_device *spi, u8 *buf, | |||
397 | static void mcp251x_hw_tx(struct spi_device *spi, struct can_frame *frame, | 402 | static void mcp251x_hw_tx(struct spi_device *spi, struct can_frame *frame, |
398 | int tx_buf_idx) | 403 | int tx_buf_idx) |
399 | { | 404 | { |
405 | struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); | ||
400 | u32 sid, eid, exide, rtr; | 406 | u32 sid, eid, exide, rtr; |
401 | u8 buf[SPI_TRANSFER_BUF_LEN]; | 407 | u8 buf[SPI_TRANSFER_BUF_LEN]; |
402 | 408 | ||
@@ -418,7 +424,10 @@ static void mcp251x_hw_tx(struct spi_device *spi, struct can_frame *frame, | |||
418 | buf[TXBDLC_OFF] = (rtr << DLC_RTR_SHIFT) | frame->can_dlc; | 424 | buf[TXBDLC_OFF] = (rtr << DLC_RTR_SHIFT) | frame->can_dlc; |
419 | memcpy(buf + TXBDAT_OFF, frame->data, frame->can_dlc); | 425 | memcpy(buf + TXBDAT_OFF, frame->data, frame->can_dlc); |
420 | mcp251x_hw_tx_frame(spi, buf, frame->can_dlc, tx_buf_idx); | 426 | mcp251x_hw_tx_frame(spi, buf, frame->can_dlc, tx_buf_idx); |
421 | mcp251x_write_reg(spi, TXBCTRL(tx_buf_idx), TXBCTRL_TXREQ); | 427 | |
428 | /* use INSTRUCTION_RTS, to avoid "repeated frame problem" */ | ||
429 | priv->spi_tx_buf[0] = INSTRUCTION_RTS(1 << tx_buf_idx); | ||
430 | mcp251x_spi_trans(priv->spi, 1); | ||
422 | } | 431 | } |
423 | 432 | ||
424 | static void mcp251x_hw_rx_frame(struct spi_device *spi, u8 *buf, | 433 | static void mcp251x_hw_rx_frame(struct spi_device *spi, u8 *buf, |