diff options
author | Tomoya <tomoya-linux@dsn.okisemi.com> | 2010-12-12 15:24:12 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-12-13 15:24:21 -0500 |
commit | bd58cbc322e97550af5e12584324b7117180435d (patch) | |
tree | b39c36558b01f62372ea574b2384ac10800c8e92 /drivers/net | |
parent | 7f2bc50efeaeb1dff62ef7e128ae36499fbcf35d (diff) |
pch_can: Rename function/macro name
For easy to read/understand, Rename function/macro name.
Signed-off-by: Tomoya MORINAGA <tomoya-linux@dsn.okisemi.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/can/pch_can.c | 176 |
1 files changed, 77 insertions, 99 deletions
diff --git a/drivers/net/can/pch_can.c b/drivers/net/can/pch_can.c index 5fc99cb10df0..dd9ce16635b3 100644 --- a/drivers/net/can/pch_can.c +++ b/drivers/net/can/pch_can.c | |||
@@ -32,8 +32,6 @@ | |||
32 | #include <linux/can/dev.h> | 32 | #include <linux/can/dev.h> |
33 | #include <linux/can/error.h> | 33 | #include <linux/can/error.h> |
34 | 34 | ||
35 | #define PCH_ENABLE 1 /* The enable flag */ | ||
36 | #define PCH_DISABLE 0 /* The disable flag */ | ||
37 | #define PCH_CTRL_INIT BIT(0) /* The INIT bit of CANCONT register. */ | 35 | #define PCH_CTRL_INIT BIT(0) /* The INIT bit of CANCONT register. */ |
38 | #define PCH_CTRL_IE BIT(1) /* The IE bit of CAN control register */ | 36 | #define PCH_CTRL_IE BIT(1) /* The IE bit of CAN control register */ |
39 | #define PCH_CTRL_IE_SIE_EIE (BIT(3) | BIT(2) | BIT(1)) | 37 | #define PCH_CTRL_IE_SIE_EIE (BIT(3) | BIT(2) | BIT(1)) |
@@ -78,11 +76,12 @@ | |||
78 | #define PCH_BUS_OFF BIT(7) | 76 | #define PCH_BUS_OFF BIT(7) |
79 | 77 | ||
80 | /* bit position of certain controller bits. */ | 78 | /* bit position of certain controller bits. */ |
81 | #define PCH_BIT_BRP 0 | 79 | #define PCH_BIT_BRP_SHIFT 0 |
82 | #define PCH_BIT_SJW 6 | 80 | #define PCH_BIT_SJW_SHIFT 6 |
83 | #define PCH_BIT_TSEG1 8 | 81 | #define PCH_BIT_TSEG1_SHIFT 8 |
84 | #define PCH_BIT_TSEG2 12 | 82 | #define PCH_BIT_TSEG2_SHIFT 12 |
85 | #define PCH_BIT_BRPE_BRPE 6 | 83 | #define PCH_BIT_BRPE_BRPE_SHIFT 6 |
84 | |||
86 | #define PCH_MSK_BITT_BRP 0x3f | 85 | #define PCH_MSK_BITT_BRP 0x3f |
87 | #define PCH_MSK_BRPE_BRPE 0x3c0 | 86 | #define PCH_MSK_BRPE_BRPE 0x3c0 |
88 | #define PCH_MSK_CTRL_IE_SIE_EIE 0x07 | 87 | #define PCH_MSK_CTRL_IE_SIE_EIE 0x07 |
@@ -170,19 +169,16 @@ struct pch_can_regs { | |||
170 | 169 | ||
171 | struct pch_can_priv { | 170 | struct pch_can_priv { |
172 | struct can_priv can; | 171 | struct can_priv can; |
173 | unsigned int can_num; | ||
174 | struct pci_dev *dev; | 172 | struct pci_dev *dev; |
175 | int tx_enable[PCH_TX_OBJ_END]; | 173 | u32 tx_enable[PCH_TX_OBJ_END]; |
176 | int rx_enable[PCH_TX_OBJ_END]; | 174 | u32 rx_enable[PCH_TX_OBJ_END]; |
177 | int rx_link[PCH_TX_OBJ_END]; | 175 | u32 rx_link[PCH_TX_OBJ_END]; |
178 | unsigned int int_enables; | 176 | u32 int_enables; |
179 | unsigned int int_stat; | ||
180 | struct net_device *ndev; | 177 | struct net_device *ndev; |
181 | unsigned int msg_obj[PCH_TX_OBJ_END]; | ||
182 | struct pch_can_regs __iomem *regs; | 178 | struct pch_can_regs __iomem *regs; |
183 | struct napi_struct napi; | 179 | struct napi_struct napi; |
184 | unsigned int tx_obj; /* Point next Tx Obj index */ | 180 | int tx_obj; /* Point next Tx Obj index */ |
185 | unsigned int use_msi; | 181 | int use_msi; |
186 | }; | 182 | }; |
187 | 183 | ||
188 | static struct can_bittiming_const pch_can_bittiming_const = { | 184 | static struct can_bittiming_const pch_can_bittiming_const = { |
@@ -245,14 +241,27 @@ static void pch_can_set_optmode(struct pch_can_priv *priv) | |||
245 | iowrite32(reg_val, &priv->regs->opt); | 241 | iowrite32(reg_val, &priv->regs->opt); |
246 | } | 242 | } |
247 | 243 | ||
244 | static void pch_can_rw_msg_obj(void __iomem *creq_addr, u32 num) | ||
245 | { | ||
246 | int counter = PCH_COUNTER_LIMIT; | ||
247 | u32 ifx_creq; | ||
248 | |||
249 | iowrite32(num, creq_addr); | ||
250 | while (counter) { | ||
251 | ifx_creq = ioread32(creq_addr) & PCH_IF_CREQ_BUSY; | ||
252 | if (!ifx_creq) | ||
253 | break; | ||
254 | counter--; | ||
255 | udelay(1); | ||
256 | } | ||
257 | if (!counter) | ||
258 | pr_err("%s:IF1 BUSY Flag is set forever.\n", __func__); | ||
259 | } | ||
260 | |||
248 | static void pch_can_set_int_enables(struct pch_can_priv *priv, | 261 | static void pch_can_set_int_enables(struct pch_can_priv *priv, |
249 | enum pch_can_mode interrupt_no) | 262 | enum pch_can_mode interrupt_no) |
250 | { | 263 | { |
251 | switch (interrupt_no) { | 264 | switch (interrupt_no) { |
252 | case PCH_CAN_ENABLE: | ||
253 | pch_can_bit_set(&priv->regs->cont, PCH_CTRL_IE); | ||
254 | break; | ||
255 | |||
256 | case PCH_CAN_DISABLE: | 265 | case PCH_CAN_DISABLE: |
257 | pch_can_bit_clear(&priv->regs->cont, PCH_CTRL_IE); | 266 | pch_can_bit_clear(&priv->regs->cont, PCH_CTRL_IE); |
258 | break; | 267 | break; |
@@ -271,25 +280,8 @@ static void pch_can_set_int_enables(struct pch_can_priv *priv, | |||
271 | } | 280 | } |
272 | } | 281 | } |
273 | 282 | ||
274 | static void pch_can_check_if_busy(u32 __iomem *creq_addr, u32 num) | ||
275 | { | ||
276 | u32 counter = PCH_COUNTER_LIMIT; | ||
277 | u32 ifx_creq; | ||
278 | |||
279 | iowrite32(num, creq_addr); | ||
280 | while (counter) { | ||
281 | ifx_creq = ioread32(creq_addr) & PCH_IF_CREQ_BUSY; | ||
282 | if (!ifx_creq) | ||
283 | break; | ||
284 | counter--; | ||
285 | udelay(1); | ||
286 | } | ||
287 | if (!counter) | ||
288 | pr_err("%s:IF1 BUSY Flag is set forever.\n", __func__); | ||
289 | } | ||
290 | |||
291 | static void pch_can_set_rxtx(struct pch_can_priv *priv, u32 buff_num, | 283 | static void pch_can_set_rxtx(struct pch_can_priv *priv, u32 buff_num, |
292 | u32 set, enum pch_ifreg dir) | 284 | int set, enum pch_ifreg dir) |
293 | { | 285 | { |
294 | u32 ie; | 286 | u32 ie; |
295 | 287 | ||
@@ -300,27 +292,27 @@ static void pch_can_set_rxtx(struct pch_can_priv *priv, u32 buff_num, | |||
300 | 292 | ||
301 | /* Reading the receive buffer data from RAM to Interface1 registers */ | 293 | /* Reading the receive buffer data from RAM to Interface1 registers */ |
302 | iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->ifregs[dir].cmask); | 294 | iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->ifregs[dir].cmask); |
303 | pch_can_check_if_busy(&priv->regs->ifregs[dir].creq, buff_num); | 295 | pch_can_rw_msg_obj(&priv->regs->ifregs[dir].creq, buff_num); |
304 | 296 | ||
305 | /* Setting the IF1MASK1 register to access MsgVal and RxIE bits */ | 297 | /* Setting the IF1MASK1 register to access MsgVal and RxIE bits */ |
306 | iowrite32(PCH_CMASK_RDWR | PCH_CMASK_ARB | PCH_CMASK_CTRL, | 298 | iowrite32(PCH_CMASK_RDWR | PCH_CMASK_ARB | PCH_CMASK_CTRL, |
307 | &priv->regs->ifregs[dir].cmask); | 299 | &priv->regs->ifregs[dir].cmask); |
308 | 300 | ||
309 | if (set == PCH_ENABLE) { | 301 | if (set) { |
310 | /* Setting the MsgVal and RxIE bits */ | 302 | /* Setting the MsgVal and RxIE bits */ |
311 | pch_can_bit_set(&priv->regs->ifregs[dir].mcont, ie); | 303 | pch_can_bit_set(&priv->regs->ifregs[dir].mcont, ie); |
312 | pch_can_bit_set(&priv->regs->ifregs[dir].id2, PCH_ID_MSGVAL); | 304 | pch_can_bit_set(&priv->regs->ifregs[dir].id2, PCH_ID_MSGVAL); |
313 | 305 | ||
314 | } else if (set == PCH_DISABLE) { | 306 | } else { |
315 | /* Resetting the MsgVal and RxIE bits */ | 307 | /* Resetting the MsgVal and RxIE bits */ |
316 | pch_can_bit_clear(&priv->regs->ifregs[dir].mcont, ie); | 308 | pch_can_bit_clear(&priv->regs->ifregs[dir].mcont, ie); |
317 | pch_can_bit_clear(&priv->regs->ifregs[dir].id2, PCH_ID_MSGVAL); | 309 | pch_can_bit_clear(&priv->regs->ifregs[dir].id2, PCH_ID_MSGVAL); |
318 | } | 310 | } |
319 | 311 | ||
320 | pch_can_check_if_busy(&priv->regs->ifregs[dir].creq, buff_num); | 312 | pch_can_rw_msg_obj(&priv->regs->ifregs[dir].creq, buff_num); |
321 | } | 313 | } |
322 | 314 | ||
323 | static void pch_can_set_rx_all(struct pch_can_priv *priv, u32 set) | 315 | static void pch_can_set_rx_all(struct pch_can_priv *priv, int set) |
324 | { | 316 | { |
325 | int i; | 317 | int i; |
326 | 318 | ||
@@ -329,7 +321,7 @@ static void pch_can_set_rx_all(struct pch_can_priv *priv, u32 set) | |||
329 | pch_can_set_rxtx(priv, i, set, PCH_RX_IFREG); | 321 | pch_can_set_rxtx(priv, i, set, PCH_RX_IFREG); |
330 | } | 322 | } |
331 | 323 | ||
332 | static void pch_can_set_tx_all(struct pch_can_priv *priv, u32 set) | 324 | static void pch_can_set_tx_all(struct pch_can_priv *priv, int set) |
333 | { | 325 | { |
334 | int i; | 326 | int i; |
335 | 327 | ||
@@ -338,16 +330,16 @@ static void pch_can_set_tx_all(struct pch_can_priv *priv, u32 set) | |||
338 | pch_can_set_rxtx(priv, i, set, PCH_TX_IFREG); | 330 | pch_can_set_rxtx(priv, i, set, PCH_TX_IFREG); |
339 | } | 331 | } |
340 | 332 | ||
341 | static int pch_can_int_pending(struct pch_can_priv *priv) | 333 | static u32 pch_can_int_pending(struct pch_can_priv *priv) |
342 | { | 334 | { |
343 | return ioread32(&priv->regs->intr) & 0xffff; | 335 | return ioread32(&priv->regs->intr) & 0xffff; |
344 | } | 336 | } |
345 | 337 | ||
346 | static void pch_can_clear_buffers(struct pch_can_priv *priv) | 338 | static void pch_can_clear_if_buffers(struct pch_can_priv *priv) |
347 | { | 339 | { |
348 | int i; | 340 | int i; /* Msg Obj ID (1~32) */ |
349 | 341 | ||
350 | for (i = PCH_RX_OBJ_START; i <= PCH_RX_OBJ_END; i++) { | 342 | for (i = PCH_RX_OBJ_START; i <= PCH_TX_OBJ_END; i++) { |
351 | iowrite32(PCH_CMASK_RX_TX_SET, &priv->regs->ifregs[0].cmask); | 343 | iowrite32(PCH_CMASK_RX_TX_SET, &priv->regs->ifregs[0].cmask); |
352 | iowrite32(0xffff, &priv->regs->ifregs[0].mask1); | 344 | iowrite32(0xffff, &priv->regs->ifregs[0].mask1); |
353 | iowrite32(0xffff, &priv->regs->ifregs[0].mask2); | 345 | iowrite32(0xffff, &priv->regs->ifregs[0].mask2); |
@@ -361,24 +353,7 @@ static void pch_can_clear_buffers(struct pch_can_priv *priv) | |||
361 | iowrite32(PCH_CMASK_RDWR | PCH_CMASK_MASK | | 353 | iowrite32(PCH_CMASK_RDWR | PCH_CMASK_MASK | |
362 | PCH_CMASK_ARB | PCH_CMASK_CTRL, | 354 | PCH_CMASK_ARB | PCH_CMASK_CTRL, |
363 | &priv->regs->ifregs[0].cmask); | 355 | &priv->regs->ifregs[0].cmask); |
364 | pch_can_check_if_busy(&priv->regs->ifregs[0].creq, i); | 356 | pch_can_rw_msg_obj(&priv->regs->ifregs[0].creq, i); |
365 | } | ||
366 | |||
367 | for (i = PCH_TX_OBJ_START; i <= PCH_TX_OBJ_END; i++) { | ||
368 | iowrite32(PCH_CMASK_RX_TX_SET, &priv->regs->ifregs[1].cmask); | ||
369 | iowrite32(0xffff, &priv->regs->ifregs[1].mask1); | ||
370 | iowrite32(0xffff, &priv->regs->ifregs[1].mask2); | ||
371 | iowrite32(0x0, &priv->regs->ifregs[1].id1); | ||
372 | iowrite32(0x0, &priv->regs->ifregs[1].id2); | ||
373 | iowrite32(0x0, &priv->regs->ifregs[1].mcont); | ||
374 | iowrite32(0x0, &priv->regs->ifregs[1].data[0]); | ||
375 | iowrite32(0x0, &priv->regs->ifregs[1].data[1]); | ||
376 | iowrite32(0x0, &priv->regs->ifregs[1].data[2]); | ||
377 | iowrite32(0x0, &priv->regs->ifregs[1].data[3]); | ||
378 | iowrite32(PCH_CMASK_RDWR | PCH_CMASK_MASK | | ||
379 | PCH_CMASK_ARB | PCH_CMASK_CTRL, | ||
380 | &priv->regs->ifregs[1].cmask); | ||
381 | pch_can_check_if_busy(&priv->regs->ifregs[1].creq, i); | ||
382 | } | 357 | } |
383 | } | 358 | } |
384 | 359 | ||
@@ -389,7 +364,7 @@ static void pch_can_config_rx_tx_buffers(struct pch_can_priv *priv) | |||
389 | for (i = PCH_RX_OBJ_START; i <= PCH_RX_OBJ_END; i++) { | 364 | for (i = PCH_RX_OBJ_START; i <= PCH_RX_OBJ_END; i++) { |
390 | iowrite32(PCH_CMASK_RX_TX_GET, | 365 | iowrite32(PCH_CMASK_RX_TX_GET, |
391 | &priv->regs->ifregs[0].cmask); | 366 | &priv->regs->ifregs[0].cmask); |
392 | pch_can_check_if_busy(&priv->regs->ifregs[0].creq, i); | 367 | pch_can_rw_msg_obj(&priv->regs->ifregs[0].creq, i); |
393 | 368 | ||
394 | iowrite32(0x0, &priv->regs->ifregs[0].id1); | 369 | iowrite32(0x0, &priv->regs->ifregs[0].id1); |
395 | iowrite32(0x0, &priv->regs->ifregs[0].id2); | 370 | iowrite32(0x0, &priv->regs->ifregs[0].id2); |
@@ -403,6 +378,9 @@ static void pch_can_config_rx_tx_buffers(struct pch_can_priv *priv) | |||
403 | /* In case FIFO mode, Last EoB of Rx Obj must be 1 */ | 378 | /* In case FIFO mode, Last EoB of Rx Obj must be 1 */ |
404 | if (i == PCH_RX_OBJ_END) | 379 | if (i == PCH_RX_OBJ_END) |
405 | pch_can_bit_set(&priv->regs->ifregs[0].mcont, | 380 | pch_can_bit_set(&priv->regs->ifregs[0].mcont, |
381 | PCH_IF_MCONT_EOB); | ||
382 | else | ||
383 | pch_can_bit_clear(&priv->regs->ifregs[0].mcont, | ||
406 | PCH_IF_MCONT_EOB); | 384 | PCH_IF_MCONT_EOB); |
407 | 385 | ||
408 | iowrite32(0, &priv->regs->ifregs[0].mask1); | 386 | iowrite32(0, &priv->regs->ifregs[0].mask1); |
@@ -414,13 +392,13 @@ static void pch_can_config_rx_tx_buffers(struct pch_can_priv *priv) | |||
414 | PCH_CMASK_ARB | PCH_CMASK_CTRL, | 392 | PCH_CMASK_ARB | PCH_CMASK_CTRL, |
415 | &priv->regs->ifregs[0].cmask); | 393 | &priv->regs->ifregs[0].cmask); |
416 | 394 | ||
417 | pch_can_check_if_busy(&priv->regs->ifregs[0].creq, i); | 395 | pch_can_rw_msg_obj(&priv->regs->ifregs[0].creq, i); |
418 | } | 396 | } |
419 | 397 | ||
420 | for (i = PCH_TX_OBJ_START; i <= PCH_TX_OBJ_END; i++) { | 398 | for (i = PCH_TX_OBJ_START; i <= PCH_TX_OBJ_END; i++) { |
421 | iowrite32(PCH_CMASK_RX_TX_GET, | 399 | iowrite32(PCH_CMASK_RX_TX_GET, |
422 | &priv->regs->ifregs[1].cmask); | 400 | &priv->regs->ifregs[1].cmask); |
423 | pch_can_check_if_busy(&priv->regs->ifregs[1].creq, i); | 401 | pch_can_rw_msg_obj(&priv->regs->ifregs[1].creq, i); |
424 | 402 | ||
425 | /* Resetting DIR bit for reception */ | 403 | /* Resetting DIR bit for reception */ |
426 | iowrite32(0x0, &priv->regs->ifregs[1].id1); | 404 | iowrite32(0x0, &priv->regs->ifregs[1].id1); |
@@ -441,7 +419,7 @@ static void pch_can_config_rx_tx_buffers(struct pch_can_priv *priv) | |||
441 | PCH_CMASK_ARB | PCH_CMASK_CTRL, | 419 | PCH_CMASK_ARB | PCH_CMASK_CTRL, |
442 | &priv->regs->ifregs[1].cmask); | 420 | &priv->regs->ifregs[1].cmask); |
443 | 421 | ||
444 | pch_can_check_if_busy(&priv->regs->ifregs[1].creq, i); | 422 | pch_can_rw_msg_obj(&priv->regs->ifregs[1].creq, i); |
445 | } | 423 | } |
446 | } | 424 | } |
447 | 425 | ||
@@ -451,7 +429,7 @@ static void pch_can_init(struct pch_can_priv *priv) | |||
451 | pch_can_set_run_mode(priv, PCH_CAN_STOP); | 429 | pch_can_set_run_mode(priv, PCH_CAN_STOP); |
452 | 430 | ||
453 | /* Clearing all the message object buffers. */ | 431 | /* Clearing all the message object buffers. */ |
454 | pch_can_clear_buffers(priv); | 432 | pch_can_clear_if_buffers(priv); |
455 | 433 | ||
456 | /* Configuring the respective message object as either rx/tx object. */ | 434 | /* Configuring the respective message object as either rx/tx object. */ |
457 | pch_can_config_rx_tx_buffers(priv); | 435 | pch_can_config_rx_tx_buffers(priv); |
@@ -496,7 +474,7 @@ static void pch_can_int_clr(struct pch_can_priv *priv, u32 mask) | |||
496 | pch_can_bit_clear(&priv->regs->ifregs[0].mcont, | 474 | pch_can_bit_clear(&priv->regs->ifregs[0].mcont, |
497 | PCH_IF_MCONT_NEWDAT | PCH_IF_MCONT_INTPND); | 475 | PCH_IF_MCONT_NEWDAT | PCH_IF_MCONT_INTPND); |
498 | 476 | ||
499 | pch_can_check_if_busy(&priv->regs->ifregs[0].creq, mask); | 477 | pch_can_rw_msg_obj(&priv->regs->ifregs[0].creq, mask); |
500 | } else if ((mask >= PCH_TX_OBJ_START) && (mask <= PCH_TX_OBJ_END)) { | 478 | } else if ((mask >= PCH_TX_OBJ_START) && (mask <= PCH_TX_OBJ_END)) { |
501 | /* Setting CMASK for clearing interrupts for | 479 | /* Setting CMASK for clearing interrupts for |
502 | frame transmission. */ | 480 | frame transmission. */ |
@@ -512,7 +490,7 @@ static void pch_can_int_clr(struct pch_can_priv *priv, u32 mask) | |||
512 | pch_can_bit_clear(&priv->regs->ifregs[1].mcont, | 490 | pch_can_bit_clear(&priv->regs->ifregs[1].mcont, |
513 | PCH_IF_MCONT_NEWDAT | PCH_IF_MCONT_INTPND | | 491 | PCH_IF_MCONT_NEWDAT | PCH_IF_MCONT_INTPND | |
514 | PCH_IF_MCONT_TXRQXT); | 492 | PCH_IF_MCONT_TXRQXT); |
515 | pch_can_check_if_busy(&priv->regs->ifregs[1].creq, mask); | 493 | pch_can_rw_msg_obj(&priv->regs->ifregs[1].creq, mask); |
516 | } | 494 | } |
517 | } | 495 | } |
518 | 496 | ||
@@ -637,7 +615,7 @@ static void pch_fifo_thresh(struct pch_can_priv *priv, int obj_id) | |||
637 | /* Clearing NewDat & IntPnd */ | 615 | /* Clearing NewDat & IntPnd */ |
638 | pch_can_bit_clear(&priv->regs->ifregs[0].mcont, | 616 | pch_can_bit_clear(&priv->regs->ifregs[0].mcont, |
639 | PCH_IF_MCONT_INTPND); | 617 | PCH_IF_MCONT_INTPND); |
640 | pch_can_check_if_busy(&priv->regs->ifregs[0].creq, obj_id); | 618 | pch_can_rw_msg_obj(&priv->regs->ifregs[0].creq, obj_id); |
641 | } else if (obj_id > PCH_FIFO_THRESH) { | 619 | } else if (obj_id > PCH_FIFO_THRESH) { |
642 | pch_can_int_clr(priv, obj_id); | 620 | pch_can_int_clr(priv, obj_id); |
643 | } else if (obj_id == PCH_FIFO_THRESH) { | 621 | } else if (obj_id == PCH_FIFO_THRESH) { |
@@ -659,7 +637,7 @@ static void pch_can_rx_msg_lost(struct net_device *ndev, int obj_id) | |||
659 | PCH_IF_MCONT_MSGLOST); | 637 | PCH_IF_MCONT_MSGLOST); |
660 | iowrite32(PCH_CMASK_RDWR | PCH_CMASK_CTRL, | 638 | iowrite32(PCH_CMASK_RDWR | PCH_CMASK_CTRL, |
661 | &priv->regs->ifregs[0].cmask); | 639 | &priv->regs->ifregs[0].cmask); |
662 | pch_can_check_if_busy(&priv->regs->ifregs[0].creq, obj_id); | 640 | pch_can_rw_msg_obj(&priv->regs->ifregs[0].creq, obj_id); |
663 | 641 | ||
664 | skb = alloc_can_err_skb(ndev, &cf); | 642 | skb = alloc_can_err_skb(ndev, &cf); |
665 | if (!skb) | 643 | if (!skb) |
@@ -689,7 +667,7 @@ static int pch_can_rx_normal(struct net_device *ndev, u32 obj_num, int quota) | |||
689 | do { | 667 | do { |
690 | /* Reading the messsage object from the Message RAM */ | 668 | /* Reading the messsage object from the Message RAM */ |
691 | iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->ifregs[0].cmask); | 669 | iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->ifregs[0].cmask); |
692 | pch_can_check_if_busy(&priv->regs->ifregs[0].creq, obj_num); | 670 | pch_can_rw_msg_obj(&priv->regs->ifregs[0].creq, obj_num); |
693 | 671 | ||
694 | /* Reading the MCONT register. */ | 672 | /* Reading the MCONT register. */ |
695 | reg = ioread32(&priv->regs->ifregs[0].mcont); | 673 | reg = ioread32(&priv->regs->ifregs[0].mcont); |
@@ -758,7 +736,7 @@ static void pch_can_tx_complete(struct net_device *ndev, u32 int_stat) | |||
758 | can_get_echo_skb(ndev, int_stat - PCH_RX_OBJ_END - 1); | 736 | can_get_echo_skb(ndev, int_stat - PCH_RX_OBJ_END - 1); |
759 | iowrite32(PCH_CMASK_RX_TX_GET | PCH_CMASK_CLRINTPND, | 737 | iowrite32(PCH_CMASK_RX_TX_GET | PCH_CMASK_CLRINTPND, |
760 | &priv->regs->ifregs[1].cmask); | 738 | &priv->regs->ifregs[1].cmask); |
761 | pch_can_check_if_busy(&priv->regs->ifregs[1].creq, int_stat); | 739 | pch_can_rw_msg_obj(&priv->regs->ifregs[1].creq, int_stat); |
762 | dlc = get_can_dlc(ioread32(&priv->regs->ifregs[1].mcont) & | 740 | dlc = get_can_dlc(ioread32(&priv->regs->ifregs[1].mcont) & |
763 | PCH_IF_MCONT_DLC); | 741 | PCH_IF_MCONT_DLC); |
764 | stats->tx_bytes += dlc; | 742 | stats->tx_bytes += dlc; |
@@ -767,7 +745,7 @@ static void pch_can_tx_complete(struct net_device *ndev, u32 int_stat) | |||
767 | netif_wake_queue(ndev); | 745 | netif_wake_queue(ndev); |
768 | } | 746 | } |
769 | 747 | ||
770 | static int pch_can_rx_poll(struct napi_struct *napi, int quota) | 748 | static int pch_can_poll(struct napi_struct *napi, int quota) |
771 | { | 749 | { |
772 | struct net_device *ndev = napi->dev; | 750 | struct net_device *ndev = napi->dev; |
773 | struct pch_can_priv *priv = netdev_priv(ndev); | 751 | struct pch_can_priv *priv = netdev_priv(ndev); |
@@ -832,10 +810,10 @@ static int pch_set_bittiming(struct net_device *ndev) | |||
832 | 810 | ||
833 | brp = (bt->tq) / (1000000000/PCH_CAN_CLK) - 1; | 811 | brp = (bt->tq) / (1000000000/PCH_CAN_CLK) - 1; |
834 | canbit = brp & PCH_MSK_BITT_BRP; | 812 | canbit = brp & PCH_MSK_BITT_BRP; |
835 | canbit |= (bt->sjw - 1) << PCH_BIT_SJW; | 813 | canbit |= (bt->sjw - 1) << PCH_BIT_SJW_SHIFT; |
836 | canbit |= (bt->phase_seg1 + bt->prop_seg - 1) << PCH_BIT_TSEG1; | 814 | canbit |= (bt->phase_seg1 + bt->prop_seg - 1) << PCH_BIT_TSEG1_SHIFT; |
837 | canbit |= (bt->phase_seg2 - 1) << PCH_BIT_TSEG2; | 815 | canbit |= (bt->phase_seg2 - 1) << PCH_BIT_TSEG2_SHIFT; |
838 | bepe = (brp & PCH_MSK_BRPE_BRPE) >> PCH_BIT_BRPE_BRPE; | 816 | bepe = (brp & PCH_MSK_BRPE_BRPE) >> PCH_BIT_BRPE_BRPE_SHIFT; |
839 | iowrite32(canbit, &priv->regs->bitt); | 817 | iowrite32(canbit, &priv->regs->bitt); |
840 | iowrite32(bepe, &priv->regs->brpe); | 818 | iowrite32(bepe, &priv->regs->brpe); |
841 | pch_can_bit_clear(&priv->regs->cont, PCH_CTRL_CCE); | 819 | pch_can_bit_clear(&priv->regs->cont, PCH_CTRL_CCE); |
@@ -947,7 +925,7 @@ static netdev_tx_t pch_xmit(struct sk_buff *skb, struct net_device *ndev) | |||
947 | { | 925 | { |
948 | struct pch_can_priv *priv = netdev_priv(ndev); | 926 | struct pch_can_priv *priv = netdev_priv(ndev); |
949 | struct can_frame *cf = (struct can_frame *)skb->data; | 927 | struct can_frame *cf = (struct can_frame *)skb->data; |
950 | int tx_buffer_avail = 0; | 928 | int tx_obj_no; |
951 | int i; | 929 | int i; |
952 | 930 | ||
953 | if (can_dropped_invalid_skb(ndev, skb)) | 931 | if (can_dropped_invalid_skb(ndev, skb)) |
@@ -957,16 +935,16 @@ static netdev_tx_t pch_xmit(struct sk_buff *skb, struct net_device *ndev) | |||
957 | if (ioread32(&priv->regs->treq2) & PCH_TREQ2_TX_MASK) | 935 | if (ioread32(&priv->regs->treq2) & PCH_TREQ2_TX_MASK) |
958 | netif_stop_queue(ndev); | 936 | netif_stop_queue(ndev); |
959 | 937 | ||
960 | tx_buffer_avail = priv->tx_obj; | 938 | tx_obj_no = priv->tx_obj; |
961 | priv->tx_obj = PCH_TX_OBJ_START; | 939 | priv->tx_obj = PCH_TX_OBJ_START; |
962 | } else { | 940 | } else { |
963 | tx_buffer_avail = priv->tx_obj; | 941 | tx_obj_no = priv->tx_obj; |
964 | priv->tx_obj++; | 942 | priv->tx_obj++; |
965 | } | 943 | } |
966 | 944 | ||
967 | /* Reading the Msg Obj from the Msg RAM to the Interface register. */ | 945 | /* Reading the Msg Obj from the Msg RAM to the Interface register. */ |
968 | iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->ifregs[1].cmask); | 946 | iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->ifregs[1].cmask); |
969 | pch_can_check_if_busy(&priv->regs->ifregs[1].creq, tx_buffer_avail); | 947 | pch_can_rw_msg_obj(&priv->regs->ifregs[1].creq, tx_obj_no); |
970 | 948 | ||
971 | /* Setting the CMASK register. */ | 949 | /* Setting the CMASK register. */ |
972 | pch_can_bit_set(&priv->regs->ifregs[1].cmask, PCH_CMASK_ALL); | 950 | pch_can_bit_set(&priv->regs->ifregs[1].cmask, PCH_CMASK_ALL); |
@@ -995,7 +973,7 @@ static netdev_tx_t pch_xmit(struct sk_buff *skb, struct net_device *ndev) | |||
995 | &priv->regs->ifregs[1].data[i / 2]); | 973 | &priv->regs->ifregs[1].data[i / 2]); |
996 | } | 974 | } |
997 | 975 | ||
998 | can_put_echo_skb(skb, ndev, tx_buffer_avail - PCH_RX_OBJ_END - 1); | 976 | can_put_echo_skb(skb, ndev, tx_obj_no - PCH_RX_OBJ_END - 1); |
999 | 977 | ||
1000 | /* Updating the size of the data. */ | 978 | /* Updating the size of the data. */ |
1001 | pch_can_bit_clear(&priv->regs->ifregs[1].mcont, 0x0f); | 979 | pch_can_bit_clear(&priv->regs->ifregs[1].mcont, 0x0f); |
@@ -1010,7 +988,7 @@ static netdev_tx_t pch_xmit(struct sk_buff *skb, struct net_device *ndev) | |||
1010 | pch_can_bit_set(&priv->regs->ifregs[1].mcont, | 988 | pch_can_bit_set(&priv->regs->ifregs[1].mcont, |
1011 | PCH_IF_MCONT_NEWDAT | PCH_IF_MCONT_TXRQXT); | 989 | PCH_IF_MCONT_NEWDAT | PCH_IF_MCONT_TXRQXT); |
1012 | 990 | ||
1013 | pch_can_check_if_busy(&priv->regs->ifregs[1].creq, tx_buffer_avail); | 991 | pch_can_rw_msg_obj(&priv->regs->ifregs[1].creq, tx_obj_no); |
1014 | 992 | ||
1015 | return NETDEV_TX_OK; | 993 | return NETDEV_TX_OK; |
1016 | } | 994 | } |
@@ -1064,7 +1042,7 @@ static u32 pch_can_get_rxtx_ir(struct pch_can_priv *priv, u32 buff_num, | |||
1064 | ie = PCH_IF_MCONT_TXIE; | 1042 | ie = PCH_IF_MCONT_TXIE; |
1065 | 1043 | ||
1066 | iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->ifregs[dir].cmask); | 1044 | iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->ifregs[dir].cmask); |
1067 | pch_can_check_if_busy(&priv->regs->ifregs[dir].creq, buff_num); | 1045 | pch_can_rw_msg_obj(&priv->regs->ifregs[dir].creq, buff_num); |
1068 | 1046 | ||
1069 | if (((ioread32(&priv->regs->ifregs[dir].id2)) & PCH_ID_MSGVAL) && | 1047 | if (((ioread32(&priv->regs->ifregs[dir].id2)) & PCH_ID_MSGVAL) && |
1070 | ((ioread32(&priv->regs->ifregs[dir].mcont)) & ie)) { | 1048 | ((ioread32(&priv->regs->ifregs[dir].mcont)) & ie)) { |
@@ -1076,37 +1054,37 @@ static u32 pch_can_get_rxtx_ir(struct pch_can_priv *priv, u32 buff_num, | |||
1076 | } | 1054 | } |
1077 | 1055 | ||
1078 | static void pch_can_set_rx_buffer_link(struct pch_can_priv *priv, | 1056 | static void pch_can_set_rx_buffer_link(struct pch_can_priv *priv, |
1079 | u32 buffer_num, u32 set) | 1057 | u32 buffer_num, int set) |
1080 | { | 1058 | { |
1081 | iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->ifregs[0].cmask); | 1059 | iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->ifregs[0].cmask); |
1082 | pch_can_check_if_busy(&priv->regs->ifregs[0].creq, buffer_num); | 1060 | pch_can_rw_msg_obj(&priv->regs->ifregs[0].creq, buffer_num); |
1083 | iowrite32(PCH_CMASK_RDWR | PCH_CMASK_CTRL, | 1061 | iowrite32(PCH_CMASK_RDWR | PCH_CMASK_CTRL, |
1084 | &priv->regs->ifregs[0].cmask); | 1062 | &priv->regs->ifregs[0].cmask); |
1085 | if (set == PCH_ENABLE) | 1063 | if (set) |
1086 | pch_can_bit_clear(&priv->regs->ifregs[0].mcont, | 1064 | pch_can_bit_clear(&priv->regs->ifregs[0].mcont, |
1087 | PCH_IF_MCONT_EOB); | 1065 | PCH_IF_MCONT_EOB); |
1088 | else | 1066 | else |
1089 | pch_can_bit_set(&priv->regs->ifregs[0].mcont, PCH_IF_MCONT_EOB); | 1067 | pch_can_bit_set(&priv->regs->ifregs[0].mcont, PCH_IF_MCONT_EOB); |
1090 | 1068 | ||
1091 | pch_can_check_if_busy(&priv->regs->ifregs[0].creq, buffer_num); | 1069 | pch_can_rw_msg_obj(&priv->regs->ifregs[0].creq, buffer_num); |
1092 | } | 1070 | } |
1093 | 1071 | ||
1094 | static void pch_can_get_rx_buffer_link(struct pch_can_priv *priv, | 1072 | static void pch_can_get_rx_buffer_link(struct pch_can_priv *priv, |
1095 | u32 buffer_num, u32 *link) | 1073 | u32 buffer_num, u32 *link) |
1096 | { | 1074 | { |
1097 | iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->ifregs[0].cmask); | 1075 | iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->ifregs[0].cmask); |
1098 | pch_can_check_if_busy(&priv->regs->ifregs[0].creq, buffer_num); | 1076 | pch_can_rw_msg_obj(&priv->regs->ifregs[0].creq, buffer_num); |
1099 | 1077 | ||
1100 | if (ioread32(&priv->regs->ifregs[0].mcont) & PCH_IF_MCONT_EOB) | 1078 | if (ioread32(&priv->regs->ifregs[0].mcont) & PCH_IF_MCONT_EOB) |
1101 | *link = PCH_DISABLE; | 1079 | *link = 0; |
1102 | else | 1080 | else |
1103 | *link = PCH_ENABLE; | 1081 | *link = 1; |
1104 | } | 1082 | } |
1105 | 1083 | ||
1106 | static int pch_can_get_buffer_status(struct pch_can_priv *priv) | 1084 | static int pch_can_get_buffer_status(struct pch_can_priv *priv) |
1107 | { | 1085 | { |
1108 | return (ioread32(&priv->regs->treq1) & 0xffff) | | 1086 | return (ioread32(&priv->regs->treq1) & 0xffff) | |
1109 | ((ioread32(&priv->regs->treq2) & 0xffff) << 16); | 1087 | (ioread32(&priv->regs->treq2) << 16); |
1110 | } | 1088 | } |
1111 | 1089 | ||
1112 | static int pch_can_suspend(struct pci_dev *pdev, pm_message_t state) | 1090 | static int pch_can_suspend(struct pci_dev *pdev, pm_message_t state) |
@@ -1114,7 +1092,7 @@ static int pch_can_suspend(struct pci_dev *pdev, pm_message_t state) | |||
1114 | int i; /* Counter variable. */ | 1092 | int i; /* Counter variable. */ |
1115 | int retval; /* Return value. */ | 1093 | int retval; /* Return value. */ |
1116 | u32 buf_stat; /* Variable for reading the transmit buffer status. */ | 1094 | u32 buf_stat; /* Variable for reading the transmit buffer status. */ |
1117 | u32 counter = 0xFFFFFF; | 1095 | int counter = PCH_COUNTER_LIMIT; |
1118 | 1096 | ||
1119 | struct net_device *dev = pci_get_drvdata(pdev); | 1097 | struct net_device *dev = pci_get_drvdata(pdev); |
1120 | struct pch_can_priv *priv = netdev_priv(dev); | 1098 | struct pch_can_priv *priv = netdev_priv(dev); |
@@ -1291,7 +1269,7 @@ static int __devinit pch_can_probe(struct pci_dev *pdev, | |||
1291 | ndev->netdev_ops = &pch_can_netdev_ops; | 1269 | ndev->netdev_ops = &pch_can_netdev_ops; |
1292 | priv->can.clock.freq = PCH_CAN_CLK; /* Hz */ | 1270 | priv->can.clock.freq = PCH_CAN_CLK; /* Hz */ |
1293 | 1271 | ||
1294 | netif_napi_add(ndev, &priv->napi, pch_can_rx_poll, PCH_RX_OBJ_END); | 1272 | netif_napi_add(ndev, &priv->napi, pch_can_poll, PCH_RX_OBJ_END); |
1295 | 1273 | ||
1296 | rc = register_candev(ndev); | 1274 | rc = register_candev(ndev); |
1297 | if (rc) { | 1275 | if (rc) { |