SAMV7 MCAN: Finishes most of the initalization logic

This commit is contained in:
Gregory Nutt 2015-08-03 09:10:38 -06:00
parent cabe75a51d
commit d53f6b9353
2 changed files with 282 additions and 18 deletions

View File

@ -67,7 +67,7 @@
#define SAM_MCAN_ECR_OFFSET 0x0040 /* Error Counter Register */
#define SAM_MCAN_PSR_OFFSET 0x0044 /* Protocol Status Register */
/* 0x0048-0x004c Reserved */
#define SAM_MCAN_IR_OFFSET 0x0050 /* Interrupt Register*/
#define SAM_MCAN_IR_OFFSET 0x0050 /* Interrupt Register*/
#define SAM_MCAN_IE_OFFSET 0x0054 /* Interrupt Enable Register */
#define SAM_MCAN_ILS_OFFSET 0x0058 /* Interrupt Line Select Register */
#define SAM_MCAN_ILE_OFFSET 0x005c /* Interrupt Line Enable Register */
@ -360,7 +360,7 @@
/* Common bit definitions for Interrupt Register, Interrupt Enable Register, Interrupt
* Line Select Register
*/
*/
#define MCAN_INT_RF0N (1 << 0) /* Bit 0: Receive FIFO 0 New Message */
#define MCAN_INT_RF0W (1 << 1) /* Bit 1: Receive FIFO 0 Watermark Reached */
@ -393,6 +393,8 @@
#define MCAN_INT_FOE (1 << 30) /* Bit 30: Format Error */
#define MCAN_INT_STE (1 << 31) /* Bit 31: Stuff Error */
#define MCAN_INT_ALL (0xffcfffff)
/* Interrupt Line Enable Register */
#define MCAN_ILE_EINT0 (1 << 0) /* Bit 0: Enable Interrupt Line 0 */
@ -535,6 +537,7 @@
#define MCAN_RXESC_F0DS_SHIFT (0) /* Bits 0-2: Receive FIFO 0 Data Field Size */
#define MCAN_RXESC_F0DS_MASK (7 << MCAN_RXESC_F0DS_SHIFT)
# define MCAN_RXESC_F0DS(n) ((uint32_t)(n) << MCAN_RXESC_F0DS_SHIFT)
# define MCAN_RXESC_F0DS_8B (0 << MCAN_RXESC_F0DS_SHIFT) /* 8-byte data field */
# define MCAN_RXESC_F0DS_12B (1 << MCAN_RXESC_F0DS_SHIFT) /* 12-byte data field */
# define MCAN_RXESC_F0DS_16B (2 << MCAN_RXESC_F0DS_SHIFT) /* 16-byte data field */
@ -545,6 +548,7 @@
# define MCAN_RXESC_F0DS_64B (7 << MCAN_RXESC_F0DS_SHIFT) /* 64-byte data field */
#define MCAN_RXESC_F1DS_SHIFT (4) /* Bits 4-6: Receive FIFO 1 Data Field Size */
#define MCAN_RXESC_F1DS_MASK (7 << MCAN_RXESC_F1DS_SHIFT)
# define MCAN_RXESC_F1DS(n) ((uint32_t)(n) << MCAN_RXESC_F1DS_SHIFT)
# define MCAN_RXESC_F1DS_8B (0 << MCAN_RXESC_F1DS_SHIFT) /* 8-byte data field */
# define MCAN_RXESC_F1DS_12B (1 << MCAN_RXESC_F1DS_SHIFT) /* 12-byte data field */
# define MCAN_RXESC_F1DS_16B (2 << MCAN_RXESC_F1DS_SHIFT) /* 16-byte data field */
@ -555,6 +559,7 @@
# define MCAN_RXESC_F1DS_64B (7 << MCAN_RXESC_F1DS_SHIFT) /* 64-byte data field */
#define MCAN_RXESC_RBDS_SHIFT (8) /* Bits 8-10: Receive Buffer Data Field Size */
#define MCAN_RXESC_RBDS_MASK (7 << MCAN_RXESC_RBDS_SHIFT)
# define MCAN_RXESC_RBDS(n) ((uint32_t)(n) << MCAN_RXESC_RBDS_SHIFT)
# define MCAN_RXESC_RBDS_8B (0 << MCAN_RXESC_RBDS_SHIFT) /* 8-byte data field */
# define MCAN_RXESC_RBDS_12B (1 << MCAN_RXESC_RBDS_SHIFT) /* 12-byte data field */
# define MCAN_RXESC_RBDS_16B (2 << MCAN_RXESC_RBDS_SHIFT) /* 16-byte data field */
@ -594,6 +599,7 @@
#define MCAN_TXESC_TBDS_SHIFT (0) /* Bits 0-2: Tx Buffer Data Field Size */
#define MCAN_TXESC_TBDS_MASK (7 << MCAN_TXESC_TBDS_SHIFT)
# define MCAN_TXESC_TBDS(n) ((uint32_t)(n) << MCAN_TXESC_TBDS_SHIFT)
# define MCAN_TXESC_TBDS_8B (0 << MCAN_TXESC_TBDS_SHIFT) /* 8-byte data field */
# define MCAN_TXESC_TBDS_12B (1 << MCAN_TXESC_TBDS_SHIFT) /* 12-byte data field */
# define MCAN_TXESC_TBDS_16B (2 << MCAN_TXESC_TBDS_SHIFT) /* 16-byte data field */
@ -661,6 +667,137 @@
#define MCAN_TXEFA_MASK 0x0000001f /* Event fifo acknowledge index mask */
/* Message RAM Definitions **************************************************************/
/* Common Buffer and FIFO element bit definitions:
*
* --------------- ------------------- --------------------------------
* RESOURCE R0 R1
* --------------- ------------------- --------------------------------
* RX Buffer: ESI, XTD, RTR, ID, ANMF, FIDX, EDL, BRS, DLC, RXTS
* RX FIFO: ESI, XTD, RTR, ID, ANMF, FIDX, EDL, BRS, DLC, RXTS
* TX buffer: XTD, RTR, ID, MM, EFC, DLC
* TX Event FIFO: ESI, XTD, RTR, ID, MM, ET, EDL, BRS, DLC, TXTS
* --------------- ------------------- --------------------------------
*/
/* Common */
#define BUFFER_R0_EXTID_SHIFT (0) /* Bits 0-28: Extended identifer */
#define BUFFER_R0_EXTID_MASK (0x1fffffff << BUFFER_R0_EXTID_SHIFT)
# define BUFFER_R0_EXTID(n) ((uint32_t)(n) << BUFFER_R0_EXTID_SHIFT)
#define BUFFER_R0_STDID_SHIFT (18) /* Bits 18-28: Standard idendifier */
#define BUFFER_R0_STDID_MASK (0x1ffc << BUFFER_R0_STDID_SHIFT)
# define BUFFER_R0_STDID_(n) ((uint32_t)(n) << BUFFER_R0_STDID_SHIFT)
#define BUFFER_R0_RTR (1 << 29) /* Bit 29: Remote Transmission Request */
#define BUFFER_R0_XTD (1 << 30) /* Bit 30: Extended Identifier */
#define BUFFER_R0_ESI (1 << 31) /* Bit 31: Error State Indicator */
/* Common */
#define BUFFER_R1_DLC_SHIFT (16) /* Bits 16-19: Date length code */
#define BUFFER_R1_DLC_MASK (15 << BUFFER_R1_DLC_SHIFT)
# define BUFFER_R1_DLC(n) ((uint32_t)(n) << BUFFER_R1_DLC_SHIFT)
#define BUFFER_R1_BRS (1 << 20) /* Bit 20: Bit Rate Switch */
#define BUFFER_R1_EDL (1 << 21) /* Bit 21: Extended Data Length */
/* RX buffer/RX FIFOs */
#define BUFFER_R1_RXTS_SHIFT (0) /* Bits 0-15: RX Timestamp */
#define BUFFER_R1_RXTS_MASK (0xffff << BUFFER_R1_RXTS_SHIFT)
# define BUFFER_R1_RXTS(n) ((uint32_t)(n) << BUFFER_R1_RXTS_SHIFT)
#define BUFFER_R1_FIDX_SHIFT (24) /* Bits 24-30: Filter index */
#define BUFFER_R1_FIDX_MASK (0x7f << BUFFER_R1_FIDX_SHIFT)
# define BUFFER_R1_FIDX(n) ((uint32_t)(n) << BUFFER_R1_FIDX_SHIFT)
#define BUFFER_R1_ANMF (1 << 31) /* Bit 31: Accepted Non-matching Frame */
/* TX buffer/TX Event FIFO */
#define BUFFER_R1_MM_SHIFT (24) /* Bits 24-31: Message Marker */
#define BUFFER_R1_MM_MASK (0xffff << BUFFER_R1_MM_SHIFT)
# define BUFFER_R1_MM(n) ((uint32_t)(n) << BUFFER_R1_MM_SHIFT)
/* TX buffer */
#define BUFFER_R1_EFC (1 << 23) /* Bit 23: Event FIFO Control */
/* TX Event FIFO */
#define BUFFER_R1_TXTS_SHIFT (0) /* Bits 0-15: TX Timestamp */
#define BUFFER_R1_TXTS_MASK (0xffff << BUFFER_R1_TXTS_SHIFT)
# define BUFFER_R1_TXTS(n) ((uint32_t)(n) << BUFFER_R1_TXTS_SHIFT)
#define BUFFER_R1_ET_SHIFT (22) /* Bits 22-23: Event Type */
#define BUFFER_R1_ET_MASK (15 << BUFFER_R1_ET_SHIFT)
# define BUFFER_R1_ET_TXEVENT (1 << BUFFER_R1_ET_SHIFT) /* Tx event */
# define BUFFER_R1_ET_TXCANCEL (2 << BUFFER_R1_ET_SHIFT) /* Transmission despite cancellation */
/* Standard Message ID Filter Element */
#define STDFILTER_S0_SFID2_SHIFT (0) /* Bits 0-10: Standard Filter ID 2 */
#define STDFILTER_S0_SFID2_MASK (0x3ff << STDFILTER_S0_SFID2_SHIFT)
# define STDFILTER_S0_SFID2(n) ((uint32_t)(n) << STDFILTER_S0_SFID2_SHIFT)
#define STDFILTER_S0_BUFFER_SHIFT (0) /* Bits 0-5: RX buffer start address */
#define STDFILTER_S0_BUFFER_MASK (0x3f << STDFILTER_S0_BUFFER_SHIFT)
# define STDFILTER_S0_BUFFER(n) ((uint32_t)(n) << STDFILTER_S0_BUFFER_SHIFT)
#define STDFILTER_S0_ACTION_SHIFT (9) /* Bits 9-10: Action taken */
#define STDFILTER_S0_ACTION_MASK (3 << STDFILTER_S0_ACTION_SHIFT)
# define STDFILTER_S0_RXBUFFER (0 << STDFILTER_S0_ACTION_SHIFT) /* Store message in a Rx buffer */
# define STDFILTER_S0_DEBUGA (1 << STDFILTER_S0_ACTION_SHIFT) /* Debug Message A */
# define STDFILTER_S0_DEBUGB (2 << STDFILTER_S0_ACTION_SHIFT) /* Debug Message B */
# define STDFILTER_S0_DEBUGC (3 << STDFILTER_S0_ACTION_SHIFT) /* Debug Message C */
#define STDFILTER_S0_SFID1_SHIFT (16) /* Bits 16-26: Standard Filter ID 2 */
#define STDFILTER_S0_SFID1_MASK (0x3ff << STDFILTER_S0_SFID1_SHIFT)
# define STDFILTER_S0_SFID1(n) ((uint32_t)(n) << STDFILTER_S0_SFID1_SHIFT)
#define STDFILTER_S0_SFEC_SHIFT (17) /* Bits 27-29: Standard Filter Element Configuration */
#define STDFILTER_S0_SFEC_MASK (7 << STDFILTER_S0_SFEC_SHIFT)
# define STDFILTER_S0_SFEC_DISABLE (0 << STDFILTER_S0_SFEC_SHIFT) /* Disable filter element */
# define STDFILTER_S0_SFEC_FIFO0 (1 << STDFILTER_S0_SFEC_SHIFT) /* Store in Rx FIFO 0 on match */
# define STDFILTER_S0_SFEC_FIFO1 (2 << STDFILTER_S0_SFEC_SHIFT) /* Store in Rx FIFO 1 on match */
# define STDFILTER_S0_SFEC_REJECT (3 << STDFILTER_S0_SFEC_SHIFT) /* Reject ID on match */
# define STDFILTER_S0_SFEC_PRIORITY (4 << STDFILTER_S0_SFEC_SHIFT) /* Set priority ion match */
# define STDFILTER_S0_SFEC_PRIOFIFO0 (5 << STDFILTER_S0_SFEC_SHIFT) /* Set priority and store in FIFO 0 on match */
# define STDFILTER_S0_SFEC_PRIOFIFO1 (6 << STDFILTER_S0_SFEC_SHIFT) /* Set priority and store in FIFO 1 on match */
# define STDFILTER_S0_SFEC_BUFFER (7 << STDFILTER_S0_SFEC_SHIFT) /* Store into Rx Buffer or as debug message */
#define STDFILTER_S0_SFT_SHIFT (30) /* Bits 30-31: Standard Filter Type */
#define STDFILTER_S0_SFT_MASK (3 << STDFILTER_S0_SFT_SHIFT)
# define STDFILTER_S0_SFT_RANGE (0 << STDFILTER_S0_SFT_SHIFT) /* Range filter from SF1ID to SF2ID */
# define STDFILTER_S0_SFT_DUAL (1 << STDFILTER_S0_SFT_SHIFT) /* Dual ID filter for SF1ID or SF2ID */
# define STDFILTER_S0_SFT_CLASSIC (2 << STDFILTER_S0_SFT_SHIFT) /* Classic filter: SF1ID=filter SF2ID=mask */
/* Extended Message ID Filter Element */
#define EXTFILTER_F0_EFID1_SHIFT (0) /* Bits 0-28: Extended Filter ID 1 */
#define EXTFILTER_F0_EFID1_MASK (0x1fffffff << EXTFILTER_F0_EFID1_SHIFT)
# define EXTFILTER_F0_EFID1(n) ((uint32_t)(n) << EXTFILTER_F0_EFID1_SHIFT)
#define EXTFILTER_F0_EFEC_SHIFT (29) /* Bits 29-31: Extended Filter Element Configuration */
#define EXTFILTER_F0_EFEC_MASK (7 << EXTFILTER_F0_EFEC_SHIFT)
# define EXTFILTER_F0_EFEC_DISABLE (0 << EXTFILTER_F0_EFEC_SHIFT) /* Disable filter element */
# define EXTFILTER_F0_EFEC_FIFO0 (1 << EXTFILTER_F0_EFEC_SHIFT) /* Store in Rx FIFO 0 on match */
# define EXTFILTER_F0_EFEC_FIFO1 (2 << EXTFILTER_F0_EFEC_SHIFT) /* Store in Rx FIFO 1 on match */
# define EXTFILTER_F0_EFEC_REJECT (3 << EXTFILTER_F0_EFEC_SHIFT) /* Reject ID on match */
# define EXTFILTER_F0_EFEC_PRIORITY (4 << EXTFILTER_F0_EFEC_SHIFT) /* Set priority on match */
# define EXTFILTER_F0_EFEC_PRIOFIFO0 (5 << EXTFILTER_F0_EFEC_SHIFT) /* Set priority and store in FIFO 0 on match */
# define EXTFILTER_F0_EFEC_PRIOFIFO1 (6 << EXTFILTER_F0_EFEC_SHIFT) /* Set priority and store in FIFO 1 on match */
# define EXTFILTER_F0_EFEC_BUFFER (7 << EXTFILTER_F0_EFEC_SHIFT) /* Store into Rx Buffer or as debug message */
#define EXTFILTER_F1_EFID2_SHIFT (0) /* Bits 0-28: Extended Filter ID 2 */
#define EXTFILTER_F1_EFID2_MASK (0x1fffffff << EXTFILTER_F1_EFID2_SHIFT)
# define EXTFILTER_F1_EFID2(n) ((uint32_t)(n) << EXTFILTER_F1_EFID2_SHIFT)
#define EXTFILTER_F1_BUFFER_SHIFT (0) /* Bits 0-5: RX buffer start address */
#define EXTFILTER_F1_BUFFER_MASK (0x3f << EXTFILTER_F1_BUFFER_SHIFT)
# define EXTFILTER_F1_BUFFER(n) ((uint32_t)(n) << EXTFILTER_F1_BUFFER_SHIFT)
#define EXTFILTER_F1_ACTION_SHIFT (9) /* Bits 9-10: Action taken */
#define EXTFILTER_F1_ACTION_MASK (3 << EXTFILTER_F1_ACTION_SHIFT)
# define EXTFILTER_F1_RXBUFFER (0 << EXTFILTER_F1_ACTION_SHIFT) /* Store message in a Rx buffer */
# define EXTFILTER_F1_DEBUGA (1 << EXTFILTER_F1_ACTION_SHIFT) /* Debug Message A */
# define EXTFILTER_F1_DEBUGB (2 << EXTFILTER_F1_ACTION_SHIFT) /* Debug Message B */
# define EXTFILTER_F1_DEBUGC (3 << EXTFILTER_F1_ACTION_SHIFT) /* Debug Message C */
#define EXTFILTER_F1_EFT_SHIFT (30) /* Bits 30-31: Extended Filter Type */
#define EXTFILTER_F1_EFT_MASK (3 << EXTFILTER_F1_EFT_SHIFT)
# define EXTFILTER_F1_EFT_RANGE (0 << EXTFILTER_F1_EFT_SHIFT) /* Range filter from SF1ID to SF2ID */
# define EXTFILTER_F1_EFT_DUAL (1 << EXTFILTER_F1_EFT_SHIFT) /* Dual ID filter for SF1ID or SF2ID */
# define EXTFILTER_F1_EFT_CLASSIC (2 << EXTFILTER_F1_EFT_SHIFT) /* Classic filter: SF1ID=filter SF2ID=mask */
# define EXTFILTER_F1_EFT_NOXIDAM (2 << EXTFILTER_F1_EFT_SHIFT) /* Range filter from EF1ID to EF2ID, no XIDAM */
/****************************************************************************************
* Public Types
****************************************************************************************/

View File

@ -570,7 +570,9 @@
#endif /* CONFIG_SAMV7_MCAN1 */
/* Interrupts ***************************************************************/
/* MCAN helpers *************************************************************/
#define MAILBOX_ADDRESS(a) ((uint32_t)(a) & 0x0000fffc)
/* Debug ********************************************************************/
/* Non-standard debug that may be enabled just for testing CAN */
@ -1247,7 +1249,7 @@ static void mcan_mbfree(FAR struct sam_mcan_s *priv, int mbndx)
*
* Assumptions:
* Caller has exclusive access to the CAN data structures
* CAN interrupts are disabled at the AIC
* CAN interrupts are disabled at the NVIC
*
****************************************************************************/
@ -1442,7 +1444,8 @@ static int mcan_setup(FAR struct can_dev_s *dev)
mcan_dumpctrlregs(priv, "After receive setup");
mcan_dumpmbregs(priv, NULL);
/* Enable the interrupts at the AIC. */
/* Enable the interrupts at the NVIC (they are still disabled at the MCAN
* peripheral). */
up_enable_irq(config->irq);
mcan_semgive(priv);
@ -2319,8 +2322,10 @@ static int mcan_bittiming(struct sam_mcan_s *priv)
static int mcan_hwinitialize(struct sam_mcan_s *priv)
{
FAR const struct sam_config_s *config = priv->config;
FAR uint32_t *msgram;
uint32_t regval;
uint32_t mck;
uint32_t cntr;
uint32_t cmr;
int ret;
canllvdbg("CAN%d\n", config->port);
@ -2370,45 +2375,167 @@ static int mcan_hwinitialize(struct sam_mcan_s *priv)
sam_enableperiph1(config->pid);
#if 0 // REVISIT -- may apply only to SAMA5
/* Disable all CAN interrupts */
/* Enable the Initialization state */
mcan_putreg(priv, SAM_CAN_IDR_OFFSET, CAN_INT_ALL);
regval = sam_getreg(priv, SAM_MCAN_CCCR_OFFSET)
regval |= MCAN_CCCR_INIT;
sam_putreg(priv, SAM_MCAN_CCCR_OFFSET, regval);
/* Configure bit timing. */
/* Wait for initialization mode to take effect */
ret = mcan_bittiming(priv);
if (ret < 0)
while ((sam_getreg(priv, SAM_MCAN_CCCR_OFFSET) & MCAN_CCCR_INIT) == 0);
/* Enable writing to configuration registers */
regval = sam_getreg(priv, SAM_MCAN_CCCR_OFFSET)
regval |= MCAN_CCCR_INIT | MCAN_CCCR_CCE;
sam_putreg(priv, SAM_MCAN_CCCR_OFFSET, regval);
/* Global Filter Configuration: Reject remote frames, reject non-matching
* frames.
*/
regval = MCAN_GFC_RRFE | MCAN_GFC_RRFS | MCAN_GFC_ANFE_REJECTED |
MCAN_GFC_ANFS_REJECTED;
sam_putreg(priv, SAM_MCAN_GFC_OFFSET, regval);
/* Extended ID Filter AND mask */
sam_putreg(priv, SAM_MCAN_XIDAM_OFFSET, 0x1fffffff);
/* Disable all interrupts */
sam_putreg(priv, SAM_MCAN_IE_OFFSET, 0);
sam_putreg(priv, SAM_MCAN_TXBTIE_OFFSET, 0);
/* All interrupts directed to Line 0. But disable bot interrupt line 0
* and 1 for now.
*/
sam_putreg(priv, SAM_MCAN_ILS_OFFSET, 0);
sam_putreg(priv, SAM_MCAN_ILE_OFFSET, 0);
/* Clear all pending interrupts. */
sam_putreg(priv, SAM_MCAN_IR_OFFSET, MCAN_INT_ALL);
/* Configure MCAN bit timing */
sam_putreg(priv, SAM_MCAN_BTP_OFFSET, config->btp);
sam_putreg(priv, SAM_MCAN_FBTP_OFFSET, config->fbtp);
/* Configure message RAM starting addresses and sizes. */
regval = MAILBOX_ADDRESS(config->msgram.stdfilters) |
MCAN_SIDFC_LSS(config->nstdfilters);
sam_putreg(priv, SAM_MCAN_SIDFC_OFFSET, regval);
regval = MAILBOX_ADDRESS(config->msgram.extfilters) |
MCAN_XIDFC_LSE(config->nextfilters);
sam_putreg(priv, SAM_MCAN_XIDFC_OFFSET, regval);
/* Configure RX FIFOs */
regval = MAILBOX_ADDRESS(config->msgram.rxfifo0) |
MCAN_RXF0C_F0S(config->nfifo0);
sam_putreg(priv, SAM_MCAN_RXF0C_OFFSET, regval);
regval = MAILBOX_ADDRESS(config->msgram.rxfifo1) |
MCAN_RXF1C_F1S(config->nfifo1);
sam_putreg(priv, SAM_MCAN_RXF1C_OFFSET, regval);
/* Watermark interrupt off, blocking mode */
regval = MAILBOX_ADDRESS(config->msgram.rxdedicated);
sam_putreg(priv, SAM_MCAN_RXBC_OFFSET, regval);
regval = MAILBOX_ADDRESS(config->msgram.txeventfifo) |
MCAN_TXEFC_EFS(config->ntxeventfifo);
sam_putreg(priv, SAM_MCAN_TXEFC_OFFSET, regval);
/* Watermark interrupt off */
regval = MAILBOX_ADDRESS(config->msgram.txdedicated) |
MCAN_TXBC_NDTB(config->ntxdedicated) |
MCAN_TXBC_TFQS(config->ntxfifoq);
sam_putreg(priv, SAM_MCAN_TXBC_OFFSET, regval);
regval = MCAN_RXESC_RBDS(config->rxbufferecode) |
MCAN_RXESC_F1DS(config->rxfifo1ecode) |
MCAN_RXESC_F0DS(config->rxfifo0ecode)
sam_putreg(priv, SAM_MCAN_RXESC_OFFSET, regval);
regval = MCAN_TXESC_TBDS(config->txbufferesize);
sam_putreg(priv, SAM_MCAN_TXESC_OFFSET, regval);
/* Configure Message Filters */
/* Disable all standard filters */
msgram = config->msgram.stdfilters;
cntr = config->nstdfilters;
while (cntr > 0)
{
candbg("ERROR: Failed to set bit timing: %d\n", ret);
return ret;
*msgram++ = STDFILTER_S0_SFEC_DISABLE;
cntr--;
}
#endif
# error Missing SAMV71 MCAN initialization logic
/* Select FD mode with or without fast bit rate switching */
/* Disable all extended filters */
msgram = config->msgram.extfilters;
cntr = config->nextfilters;
while (cntr > 0)
{
*msgram = EXTFILTER_F0_EFEC_DISABLE;
msgram = msgram + 2;
cntr--;
}
/* Clear new RX data flags */
sam_putreg(priv, SAM_MCAN_NDAT1_OFFSET, 0xffffffff);
sam_putreg(priv, SAM_MCAN_NDAT2_OFFSET, 0xffffffff);
/* Select ISO11898-1 mode or FD mode with or without fast bit rate
* switching
*/
regval = sam_getreg(priv, SAM_MCAN_CCCR_OFFSET);
regval &= ~MCAN_CCCR_CME_MASK;
regval &= ~(MCAN_CCCR_CME_MASK | MCAN_CCCR_CMR_MASK);
switch (priv->mode)
{
default:
case CONFIG_MCAN_ISO11898_1_MODE:
regval |= MCAN_CCCR_CME_ISO11898_1;
cmr = MCAN_CCCR_CMR_ISO11898_1;
break;
case CONFIG_MCAN_FD_MODE:
regval |= MCAN_CCCR_CME_FD;
cmr = MCAN_CCCR_CMR_FD;
break;
case CONFIG_MCAN_FD_BSW_MODE:
regval |= MCAN_CCCR_CME_FD_BSW;
cmr = MCAN_CCCR_CMR_FD_BSW;
break;
}
/* Set the initial CAN mode */
sam_putreg(priv, SAM_MCAN_CCCR_OFFSET, regval);
/* Request the mode change */
regval |= cmr;
sam_putreg(priv, SAM_MCAN_CCCR_OFFSET, regval);
#if 0 /* Not necessary in initialization mode */
/* Wait for the mode to take effect */
while ((sam_getreg(priv, SAM_MCAN_CCCR_OFFSET) & (MCAN_CCCR_FDBS | MCAN_CCCR_FDO)) != 0);
#endif
/* Enable FIFO/Queue mode */
regval = sam_getreg(priv, SAM_MCAN_TXBC_OFFSET);