aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/can/pch_can.c
diff options
context:
space:
mode:
authorTomoya <tomoya-linux@dsn.okisemi.com>2010-11-29 13:11:52 -0500
committerDavid S. Miller <davem@davemloft.net>2010-12-02 16:04:50 -0500
commit8339a7ed562719e040ca783bf59fa2d614d10ac9 (patch)
treec2bdfa54014191d78a9ece9c561443ae691e8df5 /drivers/net/can/pch_can.c
parentdb3949c4506a21633469d71f2915cf660eea0a35 (diff)
can: EG20T PCH: Separate Interface Register(IF1/IF2)
CAN register of Intel PCH EG20T has 2 sets of interface register. To reduce whole of code size, separate interface register. As a result, the number of function also can be reduced. Signed-off-by: Tomoya MORINAGA <tomoya-linux@dsn.okisemi.com> Acked-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/can/pch_can.c')
-rw-r--r--drivers/net/can/pch_can.c445
1 files changed, 201 insertions, 244 deletions
diff --git a/drivers/net/can/pch_can.c b/drivers/net/can/pch_can.c
index 238622a04bc1..dae8ed19630e 100644
--- a/drivers/net/can/pch_can.c
+++ b/drivers/net/can/pch_can.c
@@ -113,6 +113,11 @@
113 113
114#define PCH_FIFO_THRESH 16 114#define PCH_FIFO_THRESH 16
115 115
116enum pch_ifreg {
117 PCH_RX_IFREG,
118 PCH_TX_IFREG,
119};
120
116enum pch_can_mode { 121enum pch_can_mode {
117 PCH_CAN_ENABLE, 122 PCH_CAN_ENABLE,
118 PCH_CAN_DISABLE, 123 PCH_CAN_DISABLE,
@@ -122,6 +127,21 @@ enum pch_can_mode {
122 PCH_CAN_RUN 127 PCH_CAN_RUN
123}; 128};
124 129
130struct pch_can_if_regs {
131 u32 creq;
132 u32 cmask;
133 u32 mask1;
134 u32 mask2;
135 u32 id1;
136 u32 id2;
137 u32 mcont;
138 u32 dataa1;
139 u32 dataa2;
140 u32 datab1;
141 u32 datab2;
142 u32 rsv[13];
143};
144
125struct pch_can_regs { 145struct pch_can_regs {
126 u32 cont; 146 u32 cont;
127 u32 stat; 147 u32 stat;
@@ -130,38 +150,21 @@ struct pch_can_regs {
130 u32 intr; 150 u32 intr;
131 u32 opt; 151 u32 opt;
132 u32 brpe; 152 u32 brpe;
133 u32 reserve1; 153 u32 reserve;
134 u32 if1_creq; 154 struct pch_can_if_regs ifregs[2]; /* [0]=if1 [1]=if2 */
135 u32 if1_cmask; 155 u32 reserve1[8];
136 u32 if1_mask1;
137 u32 if1_mask2;
138 u32 if1_id1;
139 u32 if1_id2;
140 u32 if1_mcont;
141 u32 if1_dataa1;
142 u32 if1_dataa2;
143 u32 if1_datab1;
144 u32 if1_datab2;
145 u32 reserve2;
146 u32 reserve3[12];
147 u32 if2_creq;
148 u32 if2_cmask;
149 u32 if2_mask1;
150 u32 if2_mask2;
151 u32 if2_id1;
152 u32 if2_id2;
153 u32 if2_mcont;
154 u32 if2_dataa1;
155 u32 if2_dataa2;
156 u32 if2_datab1;
157 u32 if2_datab2;
158 u32 reserve4;
159 u32 reserve5[20];
160 u32 treq1; 156 u32 treq1;
161 u32 treq2; 157 u32 treq2;
162 u32 reserve6[2]; 158 u32 reserve2[6];
163 u32 reserve7[56]; 159 u32 data1;
164 u32 reserve8[3]; 160 u32 data2;
161 u32 reserve3[6];
162 u32 canipend1;
163 u32 canipend2;
164 u32 reserve4[6];
165 u32 canmval1;
166 u32 canmval2;
167 u32 reserve5[37];
165 u32 srst; 168 u32 srst;
166}; 169};
167 170
@@ -303,143 +306,87 @@ static void pch_can_check_if_busy(u32 __iomem *creq_addr, u32 num)
303 pr_err("%s:IF1 BUSY Flag is set forever.\n", __func__); 306 pr_err("%s:IF1 BUSY Flag is set forever.\n", __func__);
304} 307}
305 308
306static void pch_can_set_rx_enable(struct pch_can_priv *priv, u32 buff_num, 309static void pch_can_set_rxtx(struct pch_can_priv *priv, u32 buff_num,
307 u32 set) 310 u32 set, enum pch_ifreg dir)
308{ 311{
309 unsigned long flags; 312 unsigned long flags;
313 u32 ie;
314
315 if (dir)
316 ie = PCH_IF_MCONT_TXIE;
317 else
318 ie = PCH_IF_MCONT_RXIE;
310 319
311 spin_lock_irqsave(&priv->msgif_reg_lock, flags); 320 spin_lock_irqsave(&priv->msgif_reg_lock, flags);
312 /* Reading the receive buffer data from RAM to Interface1 registers */ 321 /* Reading the receive buffer data from RAM to Interface1 registers */
313 iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->if1_cmask); 322 iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->ifregs[dir].cmask);
314 pch_can_check_if_busy(&priv->regs->if1_creq, buff_num); 323 pch_can_check_if_busy(&priv->regs->ifregs[dir].creq, buff_num);
315 324
316 /* Setting the IF1MASK1 register to access MsgVal and RxIE bits */ 325 /* Setting the IF1MASK1 register to access MsgVal and RxIE bits */
317 iowrite32(PCH_CMASK_RDWR | PCH_CMASK_ARB | PCH_CMASK_CTRL, 326 iowrite32(PCH_CMASK_RDWR | PCH_CMASK_ARB | PCH_CMASK_CTRL,
318 &priv->regs->if1_cmask); 327 &priv->regs->ifregs[dir].cmask);
319 328
320 if (set == PCH_ENABLE) { 329 if (set == PCH_ENABLE) {
321 /* Setting the MsgVal and RxIE bits */ 330 /* Setting the MsgVal and RxIE bits */
322 pch_can_bit_set(&priv->regs->if1_mcont, PCH_IF_MCONT_RXIE); 331 pch_can_bit_set(&priv->regs->ifregs[dir].mcont, ie);
323 pch_can_bit_set(&priv->regs->if1_id2, PCH_ID_MSGVAL); 332 pch_can_bit_set(&priv->regs->ifregs[dir].id2, PCH_ID_MSGVAL);
324 333
325 } else if (set == PCH_DISABLE) { 334 } else if (set == PCH_DISABLE) {
326 /* Resetting the MsgVal and RxIE bits */ 335 /* Resetting the MsgVal and RxIE bits */
327 pch_can_bit_clear(&priv->regs->if1_mcont, PCH_IF_MCONT_RXIE); 336 pch_can_bit_clear(&priv->regs->ifregs[dir].mcont, ie);
328 pch_can_bit_clear(&priv->regs->if1_id2, PCH_ID_MSGVAL); 337 pch_can_bit_clear(&priv->regs->ifregs[dir].id2, PCH_ID_MSGVAL);
329 } 338 }
330 339
331 pch_can_check_if_busy(&priv->regs->if1_creq, buff_num); 340 pch_can_check_if_busy(&priv->regs->ifregs[dir].creq, buff_num);
332 spin_unlock_irqrestore(&priv->msgif_reg_lock, flags); 341 spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
333} 342}
334 343
335static void pch_can_rx_enable_all(struct pch_can_priv *priv)
336{
337 int i;
338
339 /* Traversing to obtain the object configured as receivers. */
340 for (i = 0; i < PCH_OBJ_NUM; i++) {
341 if (priv->msg_obj[i] == PCH_MSG_OBJ_RX)
342 pch_can_set_rx_enable(priv, i + 1, PCH_ENABLE);
343 }
344}
345 344
346static void pch_can_rx_disable_all(struct pch_can_priv *priv) 345static void pch_can_set_rx_all(struct pch_can_priv *priv, u32 set)
347{ 346{
348 int i; 347 int i;
349 348
350 /* Traversing to obtain the object configured as receivers. */ 349 /* Traversing to obtain the object configured as receivers. */
351 for (i = 0; i < PCH_OBJ_NUM; i++) { 350 for (i = 0; i < PCH_OBJ_NUM; i++) {
352 if (priv->msg_obj[i] == PCH_MSG_OBJ_RX) 351 if (priv->msg_obj[i] == PCH_MSG_OBJ_RX)
353 pch_can_set_rx_enable(priv, i + 1, PCH_DISABLE); 352 pch_can_set_rxtx(priv, i + 1, set, PCH_RX_IFREG);
354 }
355}
356
357static void pch_can_set_tx_enable(struct pch_can_priv *priv, u32 buff_num,
358 u32 set)
359{
360 unsigned long flags;
361
362 spin_lock_irqsave(&priv->msgif_reg_lock, flags);
363 /* Reading the Msg buffer from Message RAM to Interface2 registers. */
364 iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->if2_cmask);
365 pch_can_check_if_busy(&priv->regs->if2_creq, buff_num);
366
367 /* Setting the IF2CMASK register for accessing the
368 MsgVal and TxIE bits */
369 iowrite32(PCH_CMASK_RDWR | PCH_CMASK_ARB | PCH_CMASK_CTRL,
370 &priv->regs->if2_cmask);
371
372 if (set == PCH_ENABLE) {
373 /* Setting the MsgVal and TxIE bits */
374 pch_can_bit_set(&priv->regs->if2_mcont, PCH_IF_MCONT_TXIE);
375 pch_can_bit_set(&priv->regs->if2_id2, PCH_ID_MSGVAL);
376 } else if (set == PCH_DISABLE) {
377 /* Resetting the MsgVal and TxIE bits. */
378 pch_can_bit_clear(&priv->regs->if2_mcont, PCH_IF_MCONT_TXIE);
379 pch_can_bit_clear(&priv->regs->if2_id2, PCH_ID_MSGVAL);
380 }
381
382 pch_can_check_if_busy(&priv->regs->if2_creq, buff_num);
383 spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
384}
385
386static void pch_can_tx_enable_all(struct pch_can_priv *priv)
387{
388 int i;
389
390 /* Traversing to obtain the object configured as transmit object. */
391 for (i = 0; i < PCH_OBJ_NUM; i++) {
392 if (priv->msg_obj[i] == PCH_MSG_OBJ_TX)
393 pch_can_set_tx_enable(priv, i + 1, PCH_ENABLE);
394 } 353 }
395} 354}
396 355
397static void pch_can_tx_disable_all(struct pch_can_priv *priv) 356static void pch_can_set_tx_all(struct pch_can_priv *priv, u32 set)
398{ 357{
399 int i; 358 int i;
400 359
401 /* Traversing to obtain the object configured as transmit object. */ 360 /* Traversing to obtain the object configured as transmit object. */
402 for (i = 0; i < PCH_OBJ_NUM; i++) { 361 for (i = 0; i < PCH_OBJ_NUM; i++) {
403 if (priv->msg_obj[i] == PCH_MSG_OBJ_TX) 362 if (priv->msg_obj[i] == PCH_MSG_OBJ_TX)
404 pch_can_set_tx_enable(priv, i + 1, PCH_DISABLE); 363 pch_can_set_rxtx(priv, i + 1, set, PCH_TX_IFREG);
405 } 364 }
406} 365}
407 366
408static void pch_can_get_rx_enable(struct pch_can_priv *priv, u32 buff_num, 367static u32 pch_can_get_rxtx_ir(struct pch_can_priv *priv, u32 buff_num,
409 u32 *enable) 368 enum pch_ifreg dir)
410{ 369{
411 unsigned long flags; 370 unsigned long flags;
371 u32 ie, enable;
412 372
413 spin_lock_irqsave(&priv->msgif_reg_lock, flags); 373 if (dir)
414 iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->if1_cmask); 374 ie = PCH_IF_MCONT_RXIE;
415 pch_can_check_if_busy(&priv->regs->if1_creq, buff_num);
416
417 if (((ioread32(&priv->regs->if1_id2)) & PCH_ID_MSGVAL) &&
418 ((ioread32(&priv->regs->if1_mcont)) &
419 PCH_IF_MCONT_RXIE))
420 *enable = PCH_ENABLE;
421 else 375 else
422 *enable = PCH_DISABLE; 376 ie = PCH_IF_MCONT_TXIE;
423 spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
424}
425
426static void pch_can_get_tx_enable(struct pch_can_priv *priv, u32 buff_num,
427 u32 *enable)
428{
429 unsigned long flags;
430 377
431 spin_lock_irqsave(&priv->msgif_reg_lock, flags); 378 spin_lock_irqsave(&priv->msgif_reg_lock, flags);
432 iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->if2_cmask); 379 iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->ifregs[dir].cmask);
433 pch_can_check_if_busy(&priv->regs->if2_creq, buff_num); 380 pch_can_check_if_busy(&priv->regs->ifregs[dir].creq, buff_num);
434 381
435 if (((ioread32(&priv->regs->if2_id2)) & PCH_ID_MSGVAL) && 382 if (((ioread32(&priv->regs->ifregs[dir].id2)) & PCH_ID_MSGVAL) &&
436 ((ioread32(&priv->regs->if2_mcont)) & 383 ((ioread32(&priv->regs->ifregs[dir].mcont)) & ie)) {
437 PCH_IF_MCONT_TXIE)) { 384 enable = PCH_ENABLE;
438 *enable = PCH_ENABLE;
439 } else { 385 } else {
440 *enable = PCH_DISABLE; 386 enable = PCH_DISABLE;
441 } 387 }
442 spin_unlock_irqrestore(&priv->msgif_reg_lock, flags); 388 spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
389 return enable;
443} 390}
444 391
445static int pch_can_int_pending(struct pch_can_priv *priv) 392static int pch_can_int_pending(struct pch_can_priv *priv)
@@ -453,15 +400,17 @@ static void pch_can_set_rx_buffer_link(struct pch_can_priv *priv,
453 unsigned long flags; 400 unsigned long flags;
454 401
455 spin_lock_irqsave(&priv->msgif_reg_lock, flags); 402 spin_lock_irqsave(&priv->msgif_reg_lock, flags);
456 iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->if1_cmask); 403 iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->ifregs[0].cmask);
457 pch_can_check_if_busy(&priv->regs->if1_creq, buffer_num); 404 pch_can_check_if_busy(&priv->regs->ifregs[0].creq, buffer_num);
458 iowrite32(PCH_CMASK_RDWR | PCH_CMASK_CTRL, &priv->regs->if1_cmask); 405 iowrite32(PCH_CMASK_RDWR | PCH_CMASK_CTRL,
406 &priv->regs->ifregs[0].cmask);
459 if (set == PCH_ENABLE) 407 if (set == PCH_ENABLE)
460 pch_can_bit_clear(&priv->regs->if1_mcont, PCH_IF_MCONT_EOB); 408 pch_can_bit_clear(&priv->regs->ifregs[0].mcont,
409 PCH_IF_MCONT_EOB);
461 else 410 else
462 pch_can_bit_set(&priv->regs->if1_mcont, PCH_IF_MCONT_EOB); 411 pch_can_bit_set(&priv->regs->ifregs[0].mcont, PCH_IF_MCONT_EOB);
463 412
464 pch_can_check_if_busy(&priv->regs->if1_creq, buffer_num); 413 pch_can_check_if_busy(&priv->regs->ifregs[0].creq, buffer_num);
465 spin_unlock_irqrestore(&priv->msgif_reg_lock, flags); 414 spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
466} 415}
467 416
@@ -471,10 +420,10 @@ static void pch_can_get_rx_buffer_link(struct pch_can_priv *priv,
471 unsigned long flags; 420 unsigned long flags;
472 421
473 spin_lock_irqsave(&priv->msgif_reg_lock, flags); 422 spin_lock_irqsave(&priv->msgif_reg_lock, flags);
474 iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->if1_cmask); 423 iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->ifregs[0].cmask);
475 pch_can_check_if_busy(&priv->regs->if1_creq, buffer_num); 424 pch_can_check_if_busy(&priv->regs->ifregs[0].creq, buffer_num);
476 425
477 if (ioread32(&priv->regs->if1_mcont) & PCH_IF_MCONT_EOB) 426 if (ioread32(&priv->regs->ifregs[0].mcont) & PCH_IF_MCONT_EOB)
478 *link = PCH_DISABLE; 427 *link = PCH_DISABLE;
479 else 428 else
480 *link = PCH_ENABLE; 429 *link = PCH_ENABLE;
@@ -486,37 +435,37 @@ static void pch_can_clear_buffers(struct pch_can_priv *priv)
486 int i; 435 int i;
487 436
488 for (i = 0; i < PCH_RX_OBJ_NUM; i++) { 437 for (i = 0; i < PCH_RX_OBJ_NUM; i++) {
489 iowrite32(PCH_CMASK_RX_TX_SET, &priv->regs->if1_cmask); 438 iowrite32(PCH_CMASK_RX_TX_SET, &priv->regs->ifregs[0].cmask);
490 iowrite32(0xffff, &priv->regs->if1_mask1); 439 iowrite32(0xffff, &priv->regs->ifregs[0].mask1);
491 iowrite32(0xffff, &priv->regs->if1_mask2); 440 iowrite32(0xffff, &priv->regs->ifregs[0].mask2);
492 iowrite32(0x0, &priv->regs->if1_id1); 441 iowrite32(0x0, &priv->regs->ifregs[0].id1);
493 iowrite32(0x0, &priv->regs->if1_id2); 442 iowrite32(0x0, &priv->regs->ifregs[0].id2);
494 iowrite32(0x0, &priv->regs->if1_mcont); 443 iowrite32(0x0, &priv->regs->ifregs[0].mcont);
495 iowrite32(0x0, &priv->regs->if1_dataa1); 444 iowrite32(0x0, &priv->regs->ifregs[0].dataa1);
496 iowrite32(0x0, &priv->regs->if1_dataa2); 445 iowrite32(0x0, &priv->regs->ifregs[0].dataa2);
497 iowrite32(0x0, &priv->regs->if1_datab1); 446 iowrite32(0x0, &priv->regs->ifregs[0].datab1);
498 iowrite32(0x0, &priv->regs->if1_datab2); 447 iowrite32(0x0, &priv->regs->ifregs[0].datab2);
499 iowrite32(PCH_CMASK_RDWR | PCH_CMASK_MASK | 448 iowrite32(PCH_CMASK_RDWR | PCH_CMASK_MASK |
500 PCH_CMASK_ARB | PCH_CMASK_CTRL, 449 PCH_CMASK_ARB | PCH_CMASK_CTRL,
501 &priv->regs->if1_cmask); 450 &priv->regs->ifregs[0].cmask);
502 pch_can_check_if_busy(&priv->regs->if1_creq, i+1); 451 pch_can_check_if_busy(&priv->regs->ifregs[0].creq, i+1);
503 } 452 }
504 453
505 for (i = i; i < PCH_OBJ_NUM; i++) { 454 for (i = i; i < PCH_OBJ_NUM; i++) {
506 iowrite32(PCH_CMASK_RX_TX_SET, &priv->regs->if2_cmask); 455 iowrite32(PCH_CMASK_RX_TX_SET, &priv->regs->ifregs[1].cmask);
507 iowrite32(0xffff, &priv->regs->if2_mask1); 456 iowrite32(0xffff, &priv->regs->ifregs[1].mask1);
508 iowrite32(0xffff, &priv->regs->if2_mask2); 457 iowrite32(0xffff, &priv->regs->ifregs[1].mask2);
509 iowrite32(0x0, &priv->regs->if2_id1); 458 iowrite32(0x0, &priv->regs->ifregs[1].id1);
510 iowrite32(0x0, &priv->regs->if2_id2); 459 iowrite32(0x0, &priv->regs->ifregs[1].id2);
511 iowrite32(0x0, &priv->regs->if2_mcont); 460 iowrite32(0x0, &priv->regs->ifregs[1].mcont);
512 iowrite32(0x0, &priv->regs->if2_dataa1); 461 iowrite32(0x0, &priv->regs->ifregs[1].dataa1);
513 iowrite32(0x0, &priv->regs->if2_dataa2); 462 iowrite32(0x0, &priv->regs->ifregs[1].dataa2);
514 iowrite32(0x0, &priv->regs->if2_datab1); 463 iowrite32(0x0, &priv->regs->ifregs[1].datab1);
515 iowrite32(0x0, &priv->regs->if2_datab2); 464 iowrite32(0x0, &priv->regs->ifregs[1].datab2);
516 iowrite32(PCH_CMASK_RDWR | PCH_CMASK_MASK | 465 iowrite32(PCH_CMASK_RDWR | PCH_CMASK_MASK |
517 PCH_CMASK_ARB | PCH_CMASK_CTRL, 466 PCH_CMASK_ARB | PCH_CMASK_CTRL,
518 &priv->regs->if2_cmask); 467 &priv->regs->ifregs[1].cmask);
519 pch_can_check_if_busy(&priv->regs->if2_creq, i+1); 468 pch_can_check_if_busy(&priv->regs->ifregs[1].creq, i+1);
520 } 469 }
521} 470}
522 471
@@ -530,58 +479,60 @@ static void pch_can_config_rx_tx_buffers(struct pch_can_priv *priv)
530 for (i = 0; i < PCH_OBJ_NUM; i++) { 479 for (i = 0; i < PCH_OBJ_NUM; i++) {
531 if (priv->msg_obj[i] == PCH_MSG_OBJ_RX) { 480 if (priv->msg_obj[i] == PCH_MSG_OBJ_RX) {
532 iowrite32(PCH_CMASK_RX_TX_GET, 481 iowrite32(PCH_CMASK_RX_TX_GET,
533 &priv->regs->if1_cmask); 482 &priv->regs->ifregs[0].cmask);
534 pch_can_check_if_busy(&priv->regs->if1_creq, i+1); 483 pch_can_check_if_busy(&priv->regs->ifregs[0].creq, i+1);
535 484
536 iowrite32(0x0, &priv->regs->if1_id1); 485 iowrite32(0x0, &priv->regs->ifregs[0].id1);
537 iowrite32(0x0, &priv->regs->if1_id2); 486 iowrite32(0x0, &priv->regs->ifregs[0].id2);
538 487
539 pch_can_bit_set(&priv->regs->if1_mcont, 488 pch_can_bit_set(&priv->regs->ifregs[0].mcont,
540 PCH_IF_MCONT_UMASK); 489 PCH_IF_MCONT_UMASK);
541 490
542 /* Set FIFO mode set to 0 except last Rx Obj*/ 491 /* Set FIFO mode set to 0 except last Rx Obj*/
543 pch_can_bit_clear(&priv->regs->if1_mcont, 492 pch_can_bit_clear(&priv->regs->ifregs[0].mcont,
544 PCH_IF_MCONT_EOB); 493 PCH_IF_MCONT_EOB);
545 /* In case FIFO mode, Last EoB of Rx Obj must be 1 */ 494 /* In case FIFO mode, Last EoB of Rx Obj must be 1 */
546 if (i == (PCH_RX_OBJ_NUM - 1)) 495 if (i == (PCH_RX_OBJ_NUM - 1))
547 pch_can_bit_set(&priv->regs->if1_mcont, 496 pch_can_bit_set(&priv->regs->ifregs[0].mcont,
548 PCH_IF_MCONT_EOB); 497 PCH_IF_MCONT_EOB);
549 498
550 iowrite32(0, &priv->regs->if1_mask1); 499 iowrite32(0, &priv->regs->ifregs[0].mask1);
551 pch_can_bit_clear(&priv->regs->if1_mask2, 500 pch_can_bit_clear(&priv->regs->ifregs[0].mask2,
552 0x1fff | PCH_MASK2_MDIR_MXTD); 501 0x1fff | PCH_MASK2_MDIR_MXTD);
553 502
554 /* Setting CMASK for writing */ 503 /* Setting CMASK for writing */
555 iowrite32(PCH_CMASK_RDWR | PCH_CMASK_MASK | 504 iowrite32(PCH_CMASK_RDWR | PCH_CMASK_MASK |
556 PCH_CMASK_ARB | PCH_CMASK_CTRL, 505 PCH_CMASK_ARB | PCH_CMASK_CTRL,
557 &priv->regs->if1_cmask); 506 &priv->regs->ifregs[0].cmask);
558 507
559 pch_can_check_if_busy(&priv->regs->if1_creq, i+1); 508 pch_can_check_if_busy(&priv->regs->ifregs[0].creq, i+1);
560 } else if (priv->msg_obj[i] == PCH_MSG_OBJ_TX) { 509 } else if (priv->msg_obj[i] == PCH_MSG_OBJ_TX) {
561 iowrite32(PCH_CMASK_RX_TX_GET, 510 iowrite32(PCH_CMASK_RX_TX_GET,
562 &priv->regs->if2_cmask); 511 &priv->regs->ifregs[1].cmask);
563 pch_can_check_if_busy(&priv->regs->if2_creq, i+1); 512 pch_can_check_if_busy(&priv->regs->ifregs[1].creq, i+1);
564 513
565 /* Resetting DIR bit for reception */ 514 /* Resetting DIR bit for reception */
566 iowrite32(0x0, &priv->regs->if2_id1); 515 iowrite32(0x0, &priv->regs->ifregs[1].id1);
567 iowrite32(0x0, &priv->regs->if2_id2); 516 iowrite32(0x0, &priv->regs->ifregs[1].id2);
568 pch_can_bit_set(&priv->regs->if2_id2, PCH_ID2_DIR); 517 pch_can_bit_set(&priv->regs->ifregs[1].id2,
518 PCH_ID2_DIR);
569 519
570 /* Setting EOB bit for transmitter */ 520 /* Setting EOB bit for transmitter */
571 iowrite32(PCH_IF_MCONT_EOB, &priv->regs->if2_mcont); 521 iowrite32(PCH_IF_MCONT_EOB,
522 &priv->regs->ifregs[1].mcont);
572 523
573 pch_can_bit_set(&priv->regs->if2_mcont, 524 pch_can_bit_set(&priv->regs->ifregs[1].mcont,
574 PCH_IF_MCONT_UMASK); 525 PCH_IF_MCONT_UMASK);
575 526
576 iowrite32(0, &priv->regs->if2_mask1); 527 iowrite32(0, &priv->regs->ifregs[1].mask1);
577 pch_can_bit_clear(&priv->regs->if2_mask2, 0x1fff); 528 pch_can_bit_clear(&priv->regs->ifregs[1].mask2, 0x1fff);
578 529
579 /* Setting CMASK for writing */ 530 /* Setting CMASK for writing */
580 iowrite32(PCH_CMASK_RDWR | PCH_CMASK_MASK | 531 iowrite32(PCH_CMASK_RDWR | PCH_CMASK_MASK |
581 PCH_CMASK_ARB | PCH_CMASK_CTRL, 532 PCH_CMASK_ARB | PCH_CMASK_CTRL,
582 &priv->regs->if2_cmask); 533 &priv->regs->ifregs[1].cmask);
583 534
584 pch_can_check_if_busy(&priv->regs->if2_creq, i+1); 535 pch_can_check_if_busy(&priv->regs->ifregs[1].creq, i+1);
585 } 536 }
586 } 537 }
587 spin_unlock_irqrestore(&priv->msgif_reg_lock, flags); 538 spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
@@ -611,10 +562,10 @@ static void pch_can_release(struct pch_can_priv *priv)
611 pch_can_set_int_enables(priv, PCH_CAN_NONE); 562 pch_can_set_int_enables(priv, PCH_CAN_NONE);
612 563
613 /* Disabling all the receive object. */ 564 /* Disabling all the receive object. */
614 pch_can_rx_disable_all(priv); 565 pch_can_set_rx_all(priv, 0);
615 566
616 /* Disabling all the transmit object. */ 567 /* Disabling all the transmit object. */
617 pch_can_tx_disable_all(priv); 568 pch_can_set_tx_all(priv, 0);
618} 569}
619 570
620/* This function clears interrupt(s) from the CAN device. */ 571/* This function clears interrupt(s) from the CAN device. */
@@ -630,31 +581,31 @@ static void pch_can_int_clr(struct pch_can_priv *priv, u32 mask)
630 /* Setting CMASK for clearing interrupts for 581 /* Setting CMASK for clearing interrupts for
631 frame transmission. */ 582 frame transmission. */
632 iowrite32(PCH_CMASK_RDWR | PCH_CMASK_CTRL | PCH_CMASK_ARB, 583 iowrite32(PCH_CMASK_RDWR | PCH_CMASK_CTRL | PCH_CMASK_ARB,
633 &priv->regs->if2_cmask); 584 &priv->regs->ifregs[1].cmask);
634 585
635 /* Resetting the ID registers. */ 586 /* Resetting the ID registers. */
636 pch_can_bit_set(&priv->regs->if2_id2, 587 pch_can_bit_set(&priv->regs->ifregs[1].id2,
637 PCH_ID2_DIR | (0x7ff << 2)); 588 PCH_ID2_DIR | (0x7ff << 2));
638 iowrite32(0x0, &priv->regs->if2_id1); 589 iowrite32(0x0, &priv->regs->ifregs[1].id1);
639 590
640 /* Claring NewDat, TxRqst & IntPnd */ 591 /* Claring NewDat, TxRqst & IntPnd */
641 pch_can_bit_clear(&priv->regs->if2_mcont, 592 pch_can_bit_clear(&priv->regs->ifregs[1].mcont,
642 PCH_IF_MCONT_NEWDAT | PCH_IF_MCONT_INTPND | 593 PCH_IF_MCONT_NEWDAT | PCH_IF_MCONT_INTPND |
643 PCH_IF_MCONT_TXRQXT); 594 PCH_IF_MCONT_TXRQXT);
644 pch_can_check_if_busy(&priv->regs->if2_creq, mask); 595 pch_can_check_if_busy(&priv->regs->ifregs[1].creq, mask);
645 } else if (priv->msg_obj[mask - 1] == PCH_MSG_OBJ_RX) { 596 } else if (priv->msg_obj[mask - 1] == PCH_MSG_OBJ_RX) {
646 /* Setting CMASK for clearing the reception interrupts. */ 597 /* Setting CMASK for clearing the reception interrupts. */
647 iowrite32(PCH_CMASK_RDWR | PCH_CMASK_CTRL | PCH_CMASK_ARB, 598 iowrite32(PCH_CMASK_RDWR | PCH_CMASK_CTRL | PCH_CMASK_ARB,
648 &priv->regs->if1_cmask); 599 &priv->regs->ifregs[0].cmask);
649 600
650 /* Clearing the Dir bit. */ 601 /* Clearing the Dir bit. */
651 pch_can_bit_clear(&priv->regs->if1_id2, PCH_ID2_DIR); 602 pch_can_bit_clear(&priv->regs->ifregs[0].id2, PCH_ID2_DIR);
652 603
653 /* Clearing NewDat & IntPnd */ 604 /* Clearing NewDat & IntPnd */
654 pch_can_bit_clear(&priv->regs->if1_mcont, 605 pch_can_bit_clear(&priv->regs->ifregs[0].mcont,
655 PCH_IF_MCONT_NEWDAT | PCH_IF_MCONT_INTPND); 606 PCH_IF_MCONT_NEWDAT | PCH_IF_MCONT_INTPND);
656 607
657 pch_can_check_if_busy(&priv->regs->if1_creq, mask); 608 pch_can_check_if_busy(&priv->regs->ifregs[0].creq, mask);
658 } 609 }
659} 610}
660 611
@@ -685,8 +636,8 @@ static void pch_can_error(struct net_device *ndev, u32 status)
685 return; 636 return;
686 637
687 if (status & PCH_BUS_OFF) { 638 if (status & PCH_BUS_OFF) {
688 pch_can_tx_disable_all(priv); 639 pch_can_set_tx_all(priv, 0);
689 pch_can_rx_disable_all(priv); 640 pch_can_set_rx_all(priv, 0);
690 state = CAN_STATE_BUS_OFF; 641 state = CAN_STATE_BUS_OFF;
691 cf->can_id |= CAN_ERR_BUSOFF; 642 cf->can_id |= CAN_ERR_BUSOFF;
692 can_bus_off(ndev); 643 can_bus_off(ndev);
@@ -783,22 +734,22 @@ static int pch_can_rx_normal(struct net_device *ndev, u32 int_stat)
783 struct net_device_stats *stats = &(priv->ndev->stats); 734 struct net_device_stats *stats = &(priv->ndev->stats);
784 735
785 /* Reading the messsage object from the Message RAM */ 736 /* Reading the messsage object from the Message RAM */
786 iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->if1_cmask); 737 iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->ifregs[0].cmask);
787 pch_can_check_if_busy(&priv->regs->if1_creq, int_stat); 738 pch_can_check_if_busy(&priv->regs->ifregs[0].creq, int_stat);
788 739
789 /* Reading the MCONT register. */ 740 /* Reading the MCONT register. */
790 reg = ioread32(&priv->regs->if1_mcont); 741 reg = ioread32(&priv->regs->ifregs[0].mcont);
791 reg &= 0xffff; 742 reg &= 0xffff;
792 743
793 for (k = int_stat; !(reg & PCH_IF_MCONT_EOB); k++) { 744 for (k = int_stat; !(reg & PCH_IF_MCONT_EOB); k++) {
794 /* If MsgLost bit set. */ 745 /* If MsgLost bit set. */
795 if (reg & PCH_IF_MCONT_MSGLOST) { 746 if (reg & PCH_IF_MCONT_MSGLOST) {
796 dev_err(&priv->ndev->dev, "Msg Obj is overwritten.\n"); 747 dev_err(&priv->ndev->dev, "Msg Obj is overwritten.\n");
797 pch_can_bit_clear(&priv->regs->if1_mcont, 748 pch_can_bit_clear(&priv->regs->ifregs[0].mcont,
798 PCH_IF_MCONT_MSGLOST); 749 PCH_IF_MCONT_MSGLOST);
799 iowrite32(PCH_CMASK_RDWR | PCH_CMASK_CTRL, 750 iowrite32(PCH_CMASK_RDWR | PCH_CMASK_CTRL,
800 &priv->regs->if1_cmask); 751 &priv->regs->ifregs[0].cmask);
801 pch_can_check_if_busy(&priv->regs->if1_creq, k); 752 pch_can_check_if_busy(&priv->regs->ifregs[0].creq, k);
802 753
803 skb = alloc_can_err_skb(ndev, &cf); 754 skb = alloc_can_err_skb(ndev, &cf);
804 if (!skb) 755 if (!skb)
@@ -824,29 +775,30 @@ static int pch_can_rx_normal(struct net_device *ndev, u32 int_stat)
824 return -ENOMEM; 775 return -ENOMEM;
825 776
826 /* Get Received data */ 777 /* Get Received data */
827 ide = ((ioread32(&priv->regs->if1_id2)) & PCH_ID2_XTD) >> 14; 778 ide = ((ioread32(&priv->regs->ifregs[0].id2)) & PCH_ID2_XTD) >>
779 14;
828 if (ide) { 780 if (ide) {
829 id = (ioread32(&priv->regs->if1_id1) & 0xffff); 781 id = (ioread32(&priv->regs->ifregs[0].id1) & 0xffff);
830 id |= (((ioread32(&priv->regs->if1_id2)) & 782 id |= (((ioread32(&priv->regs->ifregs[0].id2)) &
831 0x1fff) << 16); 783 0x1fff) << 16);
832 cf->can_id = (id & CAN_EFF_MASK) | CAN_EFF_FLAG; 784 cf->can_id = (id & CAN_EFF_MASK) | CAN_EFF_FLAG;
833 } else { 785 } else {
834 id = (((ioread32(&priv->regs->if1_id2)) & 786 id = (((ioread32(&priv->regs->ifregs[0].id2)) &
835 (CAN_SFF_MASK << 2)) >> 2); 787 (CAN_SFF_MASK << 2)) >> 2);
836 cf->can_id = (id & CAN_SFF_MASK); 788 cf->can_id = (id & CAN_SFF_MASK);
837 } 789 }
838 790
839 rtr = (ioread32(&priv->regs->if1_id2) & PCH_ID2_DIR); 791 rtr = (ioread32(&priv->regs->ifregs[0].id2) & PCH_ID2_DIR);
840 if (rtr) { 792 if (rtr) {
841 cf->can_dlc = 0; 793 cf->can_dlc = 0;
842 cf->can_id |= CAN_RTR_FLAG; 794 cf->can_id |= CAN_RTR_FLAG;
843 } else { 795 } else {
844 cf->can_dlc = ((ioread32(&priv->regs->if1_mcont)) & 796 cf->can_dlc = ((ioread32(&priv->regs->ifregs[0].mcont))
845 0x0f); 797 & 0x0f);
846 } 798 }
847 799
848 for (i = 0, j = 0; i < cf->can_dlc; j++) { 800 for (i = 0, j = 0; i < cf->can_dlc; j++) {
849 reg = ioread32(&priv->regs->if1_dataa1 + j*4); 801 reg = ioread32(&priv->regs->ifregs[0].dataa1 + j*4);
850 cf->data[i++] = cpu_to_le32(reg & 0xff); 802 cf->data[i++] = cpu_to_le32(reg & 0xff);
851 if (i == cf->can_dlc) 803 if (i == cf->can_dlc)
852 break; 804 break;
@@ -860,15 +812,16 @@ static int pch_can_rx_normal(struct net_device *ndev, u32 int_stat)
860 812
861 if (k < PCH_FIFO_THRESH) { 813 if (k < PCH_FIFO_THRESH) {
862 iowrite32(PCH_CMASK_RDWR | PCH_CMASK_CTRL | 814 iowrite32(PCH_CMASK_RDWR | PCH_CMASK_CTRL |
863 PCH_CMASK_ARB, &priv->regs->if1_cmask); 815 PCH_CMASK_ARB, &priv->regs->ifregs[0].cmask);
864 816
865 /* Clearing the Dir bit. */ 817 /* Clearing the Dir bit. */
866 pch_can_bit_clear(&priv->regs->if1_id2, PCH_ID2_DIR); 818 pch_can_bit_clear(&priv->regs->ifregs[0].id2,
819 PCH_ID2_DIR);
867 820
868 /* Clearing NewDat & IntPnd */ 821 /* Clearing NewDat & IntPnd */
869 pch_can_bit_clear(&priv->regs->if1_mcont, 822 pch_can_bit_clear(&priv->regs->ifregs[0].mcont,
870 PCH_IF_MCONT_INTPND); 823 PCH_IF_MCONT_INTPND);
871 pch_can_check_if_busy(&priv->regs->if1_creq, k); 824 pch_can_check_if_busy(&priv->regs->ifregs[0].creq, k);
872 } else if (k > PCH_FIFO_THRESH) { 825 } else if (k > PCH_FIFO_THRESH) {
873 pch_can_int_clr(priv, k); 826 pch_can_int_clr(priv, k);
874 } else if (k == PCH_FIFO_THRESH) { 827 } else if (k == PCH_FIFO_THRESH) {
@@ -878,9 +831,9 @@ static int pch_can_rx_normal(struct net_device *ndev, u32 int_stat)
878 } 831 }
879RX_NEXT: 832RX_NEXT:
880 /* Reading the messsage object from the Message RAM */ 833 /* Reading the messsage object from the Message RAM */
881 iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->if1_cmask); 834 iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->ifregs[0].cmask);
882 pch_can_check_if_busy(&priv->regs->if1_creq, k + 1); 835 pch_can_check_if_busy(&priv->regs->ifregs[0].creq, k + 1);
883 reg = ioread32(&priv->regs->if1_mcont); 836 reg = ioread32(&priv->regs->ifregs[0].mcont);
884 } 837 }
885 838
886 return rcv_pkts; 839 return rcv_pkts;
@@ -910,8 +863,9 @@ INT_STAT:
910 863
911 if (reg_stat & PCH_TX_OK) { 864 if (reg_stat & PCH_TX_OK) {
912 spin_lock_irqsave(&priv->msgif_reg_lock, flags); 865 spin_lock_irqsave(&priv->msgif_reg_lock, flags);
913 iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->if2_cmask); 866 iowrite32(PCH_CMASK_RX_TX_GET,
914 pch_can_check_if_busy(&priv->regs->if2_creq, 867 &priv->regs->ifregs[1].cmask);
868 pch_can_check_if_busy(&priv->regs->ifregs[1].creq,
915 ioread32(&priv->regs->intr)); 869 ioread32(&priv->regs->intr));
916 spin_unlock_irqrestore(&priv->msgif_reg_lock, flags); 870 spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
917 pch_can_bit_clear(&priv->regs->stat, PCH_TX_OK); 871 pch_can_bit_clear(&priv->regs->stat, PCH_TX_OK);
@@ -938,10 +892,11 @@ MSG_OBJ:
938 can_get_echo_skb(ndev, int_stat - PCH_RX_OBJ_NUM - 1); 892 can_get_echo_skb(ndev, int_stat - PCH_RX_OBJ_NUM - 1);
939 spin_lock_irqsave(&priv->msgif_reg_lock, flags); 893 spin_lock_irqsave(&priv->msgif_reg_lock, flags);
940 iowrite32(PCH_CMASK_RX_TX_GET | PCH_CMASK_CLRINTPND, 894 iowrite32(PCH_CMASK_RX_TX_GET | PCH_CMASK_CLRINTPND,
941 &priv->regs->if2_cmask); 895 &priv->regs->ifregs[1].cmask);
942 dlc = ioread32(&priv->regs->if2_mcont) & 896 dlc = ioread32(&priv->regs->ifregs[1].mcont) &
943 PCH_IF_MCONT_DLC; 897 PCH_IF_MCONT_DLC;
944 pch_can_check_if_busy(&priv->regs->if2_creq, int_stat); 898 pch_can_check_if_busy(&priv->regs->ifregs[1].creq,
899 int_stat);
945 spin_unlock_irqrestore(&priv->msgif_reg_lock, flags); 900 spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
946 if (dlc > 8) 901 if (dlc > 8)
947 dlc = 8; 902 dlc = 8;
@@ -996,8 +951,8 @@ static void pch_can_start(struct net_device *ndev)
996 pch_set_bittiming(ndev); 951 pch_set_bittiming(ndev);
997 pch_can_set_optmode(priv); 952 pch_can_set_optmode(priv);
998 953
999 pch_can_tx_enable_all(priv); 954 pch_can_set_tx_all(priv, 1);
1000 pch_can_rx_enable_all(priv); 955 pch_can_set_rx_all(priv, 1);
1001 956
1002 /* Setting the CAN to run mode. */ 957 /* Setting the CAN to run mode. */
1003 pch_can_set_run_mode(priv, PCH_CAN_RUN); 958 pch_can_set_run_mode(priv, PCH_CAN_RUN);
@@ -1125,54 +1080,55 @@ static netdev_tx_t pch_xmit(struct sk_buff *skb, struct net_device *ndev)
1125 spin_lock_irqsave(&priv->msgif_reg_lock, flags); 1080 spin_lock_irqsave(&priv->msgif_reg_lock, flags);
1126 1081
1127 /* Reading the Msg Obj from the Msg RAM to the Interface register. */ 1082 /* Reading the Msg Obj from the Msg RAM to the Interface register. */
1128 iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->if2_cmask); 1083 iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->ifregs[1].cmask);
1129 pch_can_check_if_busy(&priv->regs->if2_creq, tx_buffer_avail); 1084 pch_can_check_if_busy(&priv->regs->ifregs[1].creq, tx_buffer_avail);
1130 1085
1131 /* Setting the CMASK register. */ 1086 /* Setting the CMASK register. */
1132 pch_can_bit_set(&priv->regs->if2_cmask, PCH_CMASK_ALL); 1087 pch_can_bit_set(&priv->regs->ifregs[1].cmask, PCH_CMASK_ALL);
1133 1088
1134 /* If ID extended is set. */ 1089 /* If ID extended is set. */
1135 pch_can_bit_clear(&priv->regs->if2_id1, 0xffff); 1090 pch_can_bit_clear(&priv->regs->ifregs[1].id1, 0xffff);
1136 pch_can_bit_clear(&priv->regs->if2_id2, 0x1fff | PCH_ID2_XTD); 1091 pch_can_bit_clear(&priv->regs->ifregs[1].id2, 0x1fff | PCH_ID2_XTD);
1137 if (cf->can_id & CAN_EFF_FLAG) { 1092 if (cf->can_id & CAN_EFF_FLAG) {
1138 pch_can_bit_set(&priv->regs->if2_id1, cf->can_id & 0xffff); 1093 pch_can_bit_set(&priv->regs->ifregs[1].id1,
1139 pch_can_bit_set(&priv->regs->if2_id2, 1094 cf->can_id & 0xffff);
1095 pch_can_bit_set(&priv->regs->ifregs[1].id2,
1140 ((cf->can_id >> 16) & 0x1fff) | PCH_ID2_XTD); 1096 ((cf->can_id >> 16) & 0x1fff) | PCH_ID2_XTD);
1141 } else { 1097 } else {
1142 pch_can_bit_set(&priv->regs->if2_id1, 0); 1098 pch_can_bit_set(&priv->regs->ifregs[1].id1, 0);
1143 pch_can_bit_set(&priv->regs->if2_id2, 1099 pch_can_bit_set(&priv->regs->ifregs[1].id2,
1144 (cf->can_id & CAN_SFF_MASK) << 2); 1100 (cf->can_id & CAN_SFF_MASK) << 2);
1145 } 1101 }
1146 1102
1147 /* If remote frame has to be transmitted.. */ 1103 /* If remote frame has to be transmitted.. */
1148 if (cf->can_id & CAN_RTR_FLAG) 1104 if (cf->can_id & CAN_RTR_FLAG)
1149 pch_can_bit_clear(&priv->regs->if2_id2, PCH_ID2_DIR); 1105 pch_can_bit_clear(&priv->regs->ifregs[1].id2, PCH_ID2_DIR);
1150 1106
1151 for (i = 0, j = 0; i < cf->can_dlc; j++) { 1107 for (i = 0, j = 0; i < cf->can_dlc; j++) {
1152 iowrite32(le32_to_cpu(cf->data[i++]), 1108 iowrite32(le32_to_cpu(cf->data[i++]),
1153 (&priv->regs->if2_dataa1) + j*4); 1109 (&priv->regs->ifregs[1].dataa1) + j*4);
1154 if (i == cf->can_dlc) 1110 if (i == cf->can_dlc)
1155 break; 1111 break;
1156 iowrite32(le32_to_cpu(cf->data[i++] << 8), 1112 iowrite32(le32_to_cpu(cf->data[i++] << 8),
1157 (&priv->regs->if2_dataa1) + j*4); 1113 (&priv->regs->ifregs[1].dataa1) + j*4);
1158 } 1114 }
1159 1115
1160 can_put_echo_skb(skb, ndev, tx_buffer_avail - PCH_RX_OBJ_NUM - 1); 1116 can_put_echo_skb(skb, ndev, tx_buffer_avail - PCH_RX_OBJ_NUM - 1);
1161 1117
1162 /* Updating the size of the data. */ 1118 /* Updating the size of the data. */
1163 pch_can_bit_clear(&priv->regs->if2_mcont, 0x0f); 1119 pch_can_bit_clear(&priv->regs->ifregs[1].mcont, 0x0f);
1164 pch_can_bit_set(&priv->regs->if2_mcont, cf->can_dlc); 1120 pch_can_bit_set(&priv->regs->ifregs[1].mcont, cf->can_dlc);
1165 1121
1166 /* Clearing IntPend, NewDat & TxRqst */ 1122 /* Clearing IntPend, NewDat & TxRqst */
1167 pch_can_bit_clear(&priv->regs->if2_mcont, 1123 pch_can_bit_clear(&priv->regs->ifregs[1].mcont,
1168 PCH_IF_MCONT_NEWDAT | PCH_IF_MCONT_INTPND | 1124 PCH_IF_MCONT_NEWDAT | PCH_IF_MCONT_INTPND |
1169 PCH_IF_MCONT_TXRQXT); 1125 PCH_IF_MCONT_TXRQXT);
1170 1126
1171 /* Setting NewDat, TxRqst bits */ 1127 /* Setting NewDat, TxRqst bits */
1172 pch_can_bit_set(&priv->regs->if2_mcont, 1128 pch_can_bit_set(&priv->regs->ifregs[1].mcont,
1173 PCH_IF_MCONT_NEWDAT | PCH_IF_MCONT_TXRQXT); 1129 PCH_IF_MCONT_NEWDAT | PCH_IF_MCONT_TXRQXT);
1174 1130
1175 pch_can_check_if_busy(&priv->regs->if2_creq, tx_buffer_avail); 1131 pch_can_check_if_busy(&priv->regs->ifregs[1].creq, tx_buffer_avail);
1176 1132
1177 spin_unlock_irqrestore(&priv->msgif_reg_lock, flags); 1133 spin_unlock_irqrestore(&priv->msgif_reg_lock, flags);
1178 1134
@@ -1234,25 +1190,25 @@ static int pch_can_suspend(struct pci_dev *pdev, pm_message_t state)
1234 /* Save Tx buffer enable state */ 1190 /* Save Tx buffer enable state */
1235 for (i = 0; i < PCH_OBJ_NUM; i++) { 1191 for (i = 0; i < PCH_OBJ_NUM; i++) {
1236 if (priv->msg_obj[i] == PCH_MSG_OBJ_TX) 1192 if (priv->msg_obj[i] == PCH_MSG_OBJ_TX)
1237 pch_can_get_tx_enable(priv, i + 1, 1193 priv->tx_enable[i] = pch_can_get_rxtx_ir(priv, i + 1,
1238 &(priv->tx_enable[i])); 1194 PCH_TX_IFREG);
1239 } 1195 }
1240 1196
1241 /* Disable all Transmit buffers */ 1197 /* Disable all Transmit buffers */
1242 pch_can_tx_disable_all(priv); 1198 pch_can_set_tx_all(priv, 0);
1243 1199
1244 /* Save Rx buffer enable state */ 1200 /* Save Rx buffer enable state */
1245 for (i = 0; i < PCH_OBJ_NUM; i++) { 1201 for (i = 0; i < PCH_OBJ_NUM; i++) {
1246 if (priv->msg_obj[i] == PCH_MSG_OBJ_RX) { 1202 if (priv->msg_obj[i] == PCH_MSG_OBJ_RX) {
1247 pch_can_get_rx_enable(priv, i + 1, 1203 priv->rx_enable[i] = pch_can_get_rxtx_ir(priv, i + 1,
1248 &(priv->rx_enable[i])); 1204 PCH_RX_IFREG);
1249 pch_can_get_rx_buffer_link(priv, i + 1, 1205 pch_can_get_rx_buffer_link(priv, i + 1,
1250 &(priv->rx_link[i])); 1206 &(priv->rx_link[i]));
1251 } 1207 }
1252 } 1208 }
1253 1209
1254 /* Disable all Receive buffers */ 1210 /* Disable all Receive buffers */
1255 pch_can_rx_disable_all(priv); 1211 pch_can_set_rx_all(priv, 0);
1256 retval = pci_save_state(pdev); 1212 retval = pci_save_state(pdev);
1257 if (retval) { 1213 if (retval) {
1258 dev_err(&pdev->dev, "pci_save_state failed.\n"); 1214 dev_err(&pdev->dev, "pci_save_state failed.\n");
@@ -1301,10 +1257,9 @@ static int pch_can_resume(struct pci_dev *pdev)
1301 1257
1302 /* Enabling the transmit buffer. */ 1258 /* Enabling the transmit buffer. */
1303 for (i = 0; i < PCH_OBJ_NUM; i++) { 1259 for (i = 0; i < PCH_OBJ_NUM; i++) {
1304 if (priv->msg_obj[i] == PCH_MSG_OBJ_TX) { 1260 if (priv->msg_obj[i] == PCH_MSG_OBJ_TX)
1305 pch_can_set_tx_enable(priv, i + 1, 1261 pch_can_set_rxtx(priv, i, priv->tx_enable[i],
1306 priv->tx_enable[i]); 1262 PCH_TX_IFREG);
1307 }
1308 } 1263 }
1309 1264
1310 /* Configuring the receive buffer and enabling them. */ 1265 /* Configuring the receive buffer and enabling them. */
@@ -1315,7 +1270,9 @@ static int pch_can_resume(struct pci_dev *pdev)
1315 priv->rx_link[i]); 1270 priv->rx_link[i]);
1316 1271
1317 /* Restore buffer enables */ 1272 /* Restore buffer enables */
1318 pch_can_set_rx_enable(priv, i + 1, priv->rx_enable[i]); 1273 pch_can_set_rxtx(priv, i, priv->rx_enable[i],
1274 PCH_RX_IFREG);
1275
1319 } 1276 }
1320 } 1277 }
1321 1278