aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2014-04-11 04:13:18 -0400
committerMarc Kleine-Budde <mkl@pengutronix.de>2014-04-24 16:09:00 -0400
commit8ff2de0fb41560cfdf072eb41b5a5b4799d126ea (patch)
treeef8a8ef774d861882e182ea8aaa9502aa9bda222 /drivers/net
parent4fb6dccd13b27651998f773755e2a1db461c62f1 (diff)
can: c_can: Cleanup setup of receive buffers
Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Alexander Stein <alexander.stein@systec-electronic.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/can/c_can/c_can.c38
1 files changed, 17 insertions, 21 deletions
diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
index d0daef8d67e1..e4eaa841a826 100644
--- a/drivers/net/can/c_can/c_can.c
+++ b/drivers/net/can/c_can/c_can.c
@@ -125,6 +125,10 @@
125/* For the high buffers we clear the interrupt bit and newdat */ 125/* For the high buffers we clear the interrupt bit and newdat */
126#define IF_COMM_RCV_HIGH (IF_COMM_RCV_LOW | IF_COMM_CLR_NEWDAT) 126#define IF_COMM_RCV_HIGH (IF_COMM_RCV_LOW | IF_COMM_CLR_NEWDAT)
127 127
128
129/* Receive setup of message objects */
130#define IF_COMM_RCV_SETUP (IF_COMM_MASK | IF_COMM_ARB | IF_COMM_CONTROL)
131
128/* IFx arbitration */ 132/* IFx arbitration */
129#define IF_ARB_MSGVAL BIT(15) 133#define IF_ARB_MSGVAL BIT(15)
130#define IF_ARB_MSGXTD BIT(14) 134#define IF_ARB_MSGXTD BIT(14)
@@ -142,6 +146,9 @@
142#define IF_MCONT_EOB BIT(7) 146#define IF_MCONT_EOB BIT(7)
143#define IF_MCONT_DLC_MASK 0xf 147#define IF_MCONT_DLC_MASK 0xf
144 148
149#define IF_MCONT_RCV (IF_MCONT_RXIE | IF_MCONT_UMASK)
150#define IF_MCONT_RCV_EOB (IF_MCONT_RCV | IF_MCONT_EOB)
151
145/* 152/*
146 * Use IF1 for RX and IF2 for TX 153 * Use IF1 for RX and IF2 for TX
147 */ 154 */
@@ -424,30 +431,20 @@ static int c_can_read_msg_object(struct net_device *dev, int iface, u32 ctrl)
424} 431}
425 432
426static void c_can_setup_receive_object(struct net_device *dev, int iface, 433static void c_can_setup_receive_object(struct net_device *dev, int iface,
427 int objno, unsigned int mask, 434 u32 obj, u32 mask, u32 id, u32 mcont)
428 unsigned int id, unsigned int mcont)
429{ 435{
430 struct c_can_priv *priv = netdev_priv(dev); 436 struct c_can_priv *priv = netdev_priv(dev);
431 437
432 priv->write_reg(priv, C_CAN_IFACE(MASK1_REG, iface), 438 mask |= BIT(29);
433 IFX_WRITE_LOW_16BIT(mask)); 439 priv->write_reg(priv, C_CAN_IFACE(MASK1_REG, iface), mask);
434 440 priv->write_reg(priv, C_CAN_IFACE(MASK2_REG, iface), mask >> 16);
435 /* According to C_CAN documentation, the reserved bit
436 * in IFx_MASK2 register is fixed 1
437 */
438 priv->write_reg(priv, C_CAN_IFACE(MASK2_REG, iface),
439 IFX_WRITE_HIGH_16BIT(mask) | BIT(13));
440 441
441 priv->write_reg(priv, C_CAN_IFACE(ARB1_REG, iface), 442 id |= IF_ARB_MSGVAL << 16;
442 IFX_WRITE_LOW_16BIT(id)); 443 priv->write_reg(priv, C_CAN_IFACE(ARB1_REG, iface), id);
443 priv->write_reg(priv, C_CAN_IFACE(ARB2_REG, iface), 444 priv->write_reg(priv, C_CAN_IFACE(ARB2_REG, iface), id >> 16);
444 (IF_ARB_MSGVAL | IFX_WRITE_HIGH_16BIT(id)));
445 445
446 priv->write_reg(priv, C_CAN_IFACE(MSGCTRL_REG, iface), mcont); 446 priv->write_reg(priv, C_CAN_IFACE(MSGCTRL_REG, iface), mcont);
447 c_can_object_put(dev, iface, objno, IF_COMM_ALL & ~IF_COMM_TXRQST); 447 c_can_object_put(dev, iface, obj, IF_COMM_RCV_SETUP);
448
449 netdev_dbg(dev, "obj no:%d, msgval:0x%08x\n", objno,
450 c_can_read_reg32(priv, C_CAN_MSGVAL1_REG));
451} 448}
452 449
453static void c_can_inval_msg_object(struct net_device *dev, int iface, int objno) 450static void c_can_inval_msg_object(struct net_device *dev, int iface, int objno)
@@ -581,11 +578,10 @@ static void c_can_configure_msg_objects(struct net_device *dev)
581 578
582 /* setup receive message objects */ 579 /* setup receive message objects */
583 for (i = C_CAN_MSG_OBJ_RX_FIRST; i < C_CAN_MSG_OBJ_RX_LAST; i++) 580 for (i = C_CAN_MSG_OBJ_RX_FIRST; i < C_CAN_MSG_OBJ_RX_LAST; i++)
584 c_can_setup_receive_object(dev, IF_RX, i, 0, 0, 581 c_can_setup_receive_object(dev, IF_RX, i, 0, 0, IF_MCONT_RCV);
585 IF_MCONT_RXIE | IF_MCONT_UMASK);
586 582
587 c_can_setup_receive_object(dev, IF_RX, C_CAN_MSG_OBJ_RX_LAST, 0, 0, 583 c_can_setup_receive_object(dev, IF_RX, C_CAN_MSG_OBJ_RX_LAST, 0, 0,
588 IF_MCONT_EOB | IF_MCONT_RXIE | IF_MCONT_UMASK); 584 IF_MCONT_RCV_EOB);
589} 585}
590 586
591/* 587/*