* Re: [Xenomai-help] IXXAT SJA_MOD register refuses to set up dual channel cards
2010-07-09 10:44 ` Wolfgang Grandegger
@ 2010-07-09 13:29 ` Peter Soetens
0 siblings, 0 replies; 3+ messages in thread
From: Peter Soetens @ 2010-07-09 13:29 UTC (permalink / raw)
To: Wolfgang Grandegger; +Cc: xenomai-help
[-- Attachment #1: Type: text/plain, Size: 859 bytes --]
On Fri, Jul 9, 2010 at 12:44 PM, Wolfgang Grandegger <wg@domain.hid> wrote:
> Hi Peter,
>
> On 07/09/2010 12:26 PM, Peter Soetens wrote:
>> Hi,
>>
>> (Xenomai 2.5.2&2.5.3)
>>
>> I'm testing the rtcan ixxat driver for a dual channel card (PLX
>> Technology, Inc. Device 2540)
>>
>> It recognizes the first channel, but refuses to setup the second one
>> because the SJA_MOD flag is 0x7f instead of 0x21
>> The SJA_IR and SJA_SR flags read as are what the driver expects.
>
> In the Socket-CAN "plx_pci" driver we mask the value with 0xa1:
>
> 0x7f & 0xa1 = 0x21 ==> OK.
>
> See
> http://lxr.linux.no/#linux+v2.6.34.1/drivers/net/can/sja1000/plx_pci.c#L223
>
>> Any suggestions on what it means and how to fix this ?
>
> See above. A patch would be nice.
Your analysis is correct. It works flawlessly now. See attachment.
Peter
[-- Attachment #2: 0001-rtcan-Mask-the-SJA_MOD-register-when-probing-for-cha.patch --]
[-- Type: text/x-patch, Size: 1620 bytes --]
From 5c7bec10b099fd1973394b2a6ca388a5e3742b64 Mon Sep 17 00:00:00 2001
From: Peter Soetens <peter@thesourceworks.com>
Date: Fri, 9 Jul 2010 15:21:53 +0200
Subject: [PATCH] rtcan: Mask the SJA_MOD register when probing for channels
Inspired by the plx_pci.c driver which does the same.
Tested on IXXAT PC-I 04
Signed-off-by: Peter Soetens <peter@thesourceworks.com>
---
ksrc/drivers/can/sja1000/rtcan_ixxat_pci.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/ksrc/drivers/can/sja1000/rtcan_ixxat_pci.c b/ksrc/drivers/can/sja1000/rtcan_ixxat_pci.c
index 5faa763..8c91efd 100644
--- a/ksrc/drivers/can/sja1000/rtcan_ixxat_pci.c
+++ b/ksrc/drivers/can/sja1000/rtcan_ixxat_pci.c
@@ -63,6 +63,7 @@ struct rtcan_ixxat_pci
#define IXXAT_INTCSR_OFFSET 0x4c /* Offset in PLX9050 conf registers */
#define IXXAT_INTCSR_SLAVE 0x41 /* LINT1 and PCI interrupt enabled */
#define IXXAT_INTCSR_MASTER 0x08 /* LINT2 enabled */
+#define IXXAT_SJA_MOD_MASK 0xa1 /* Mask for reading dual/single channel */
/* PCI vender, device and sub-device ID */
#define IXXAT_PCI_VENDOR_ID 0x10b5
@@ -238,7 +239,7 @@ static int __devinit ixxat_pci_init_one (struct pci_dev *pdev,
writeb(0x1, base_addr + CHANNEL_MASTER_RESET);
writeb(0x1, base_addr + CHANNEL_SLAVE_RESET);
udelay(100);
- if (readb(base_addr + CHANNEL_OFFSET + SJA_MOD) != 0x21 ||
+ if ( (readb(base_addr + CHANNEL_OFFSET + SJA_MOD) & IXXAT_SJA_MOD_MASK ) != 0x21 ||
readb(base_addr + CHANNEL_OFFSET + SJA_SR ) != 0x0c ||
readb(base_addr + CHANNEL_OFFSET + SJA_IR ) != 0xe0)
channel = CHANNEL_SINGLE;
--
1.6.3.3
^ permalink raw reply related [flat|nested] 3+ messages in thread