rt-socket-can "no device" problem with advantech PCM-26D2CA CAN board
Quoted 257 lines
Hello,
Am 02.09.2016 um 10:19 schrieb Jack Lee:
Quoted 87 lines
Quoted 53 lines
Hello,
Am 02.09.2016 um 09:23 schrieb Jack Lee:
Quoted 26 lines
Quoted 26 lines
Hello,
Am 02.09.2016 um 08:23 schrieb Jack Lee:
Quoted 10 lines
Hi, everyone!
I am using the advantech PCM-26D2CA CAN board, its details can be found here at
http://www.advantech.com/products/14263729-aaa3-4552-b990-99d16cdfee24/pcm-26d2ca/mod_9a1e9dbf-e22d-4770-a896-cecf40607084.
The original driver works fine, but I need it to be realtime.
rt-can driver was compiled as modules previously. When booted and "#modprobexeno_can_adv_pci" was executed,
"#dmesg | grep -i can" output was
...
RT-Socket-CAN 0.90-2 - (c) 2006 RT-Socket-CAN Development Team
RTCAN SJA1000 driver initializedQuoted 7 lines
"#lsmod | grep -i can" output was
xeno_can_adv_pcixeno_can_sja1000used byxeno_can_adv_pcixeno_canused byxeno_can_sja1000,xeno_can_adv_pciWhat strange is that
/proc/rtcan/deviceshas no devices like rtcan0. The/proc/rtcandirectory just has three files: devices, sockets and versioWhat is the PCI device id of the CAN device? You can use "lspci -vv" to list the ids.
Quoted 1 line
Does this CAN board supported by rt-socket-can? How can I implement real-timer driver for it?
Quoted 8 lines
Quoted 6 lines
Most likely the device id is missing in the driver PCI device list:
http://git.xenomai.org/xenomai-2.6.git/tree/ksrc/drivers/can/sja1000/rtcan_adv_pci.c#n87
Wolfgang.
Thank you, Wolfgang! My mailbox delays that I cannot add you in the contact, so I send to the xenomai list. Sorry for that.
No problem.
Quoted 4 lines
CAN board information is below.
#lspci -vv
03:00.0 CANBUS: Advantech Co. Ltd MIOe-3680 2-Port CAN-Bus MIOe Module with Isolation Protection
Subsystem: Advantech Co. Ltd MIOe-3680 2-Port CAN-Bus MIOe Module with Isolation ProtectionQuoted 8 lines
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Interrupt: pin A routed to IRQ 10
Region 0: Memory atd0c02000(32-bit, non-prefetchable) [size=2K]
Region 1: Memory atd0c01000(32-bit, non-prefetchable) [size=128]
Region 2: Memory atd0c00000(32-bit, non-prefetchable) [size=128]
Capabilities: <access denied>Quoted 3 lines
Could you please use "lspci -vvn" to get numbers (instead of strings).
Wolfgang.
Thanks! The information is below.
#lspci -vvn
03:00.0 0c09: 13fe:c302
Subsystem: 13fe:c302
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Interrupt: pin A routed to IRQ 10
Region 0: Memory atd0c02000(32-bit, non-prefetchable) [size=2K]
Region 1: Memory atd0c01000(32-bit, non-prefetchable) [size=128]
Region 2: Memory atd0c00000(32-bit, non-prefetchable) [size=128]
Capabilities: [40] Power Management version 3
Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mAPME(D0+,D1+,D2+,D3hot+,D3cold-)
Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [48] MSI: Enable- Count=1/2 Maskable- 64bit+
Address: 0000000000000000 Data: 0000
Capabilities: [58] Express (v1) Legacy Endpoint, MSI 00
DevCap: MaxPayload 512 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us
ExtTag- AttnBtn- AttnInd- PwrInd- RBE+ FLReset-
DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop+
MaxPayload 128 bytes, MaxReadReq 512 bytes
DevSta: CorrErr+ UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend-
LnkCap: Port #0, Speed 2.5GT/s, Width x1, ASPM L0s, Exit Latency L0s unlimited, L1 unlimited
ClockPM- Surprise- LLActRep- BwNot- ASPMOptComp-
LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- CommClk-
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x1, TrErr- Train- SlotClk- DLActive- BWMgmt- ABWMgmt-Quoted 1 line
Is “0c09: 13fe:c302” the device ID? Can you show me some instructions to make this device work? I am really new to this.
The PCI vendor id is
0x13feand the device id is0xc302.Quoted 38 lines
I opened the link you paste above, perhaps the following two places should be modified.
A new line "
ADV_PCI_DEVICE(0xc302), " should be added?
---------------------------------------------------------------static DEFINE_PCI_DEVICE_TABLE(adv_pci_tbl) = { ADV_PCI_DEVICE(0x1680), ADV_PCI_DEVICE(0x3680), ADV_PCI_DEVICE(0x2052), ADV_PCI_DEVICE(0x1681), ADV_PCI_DEVICE(0xc001), ADV_PCI_DEVICE(0xc002), ADV_PCI_DEVICE(0xc004), ADV_PCI_DEVICE(0xc101), ADV_PCI_DEVICE(0xc102), ADV_PCI_DEVICE(0xc104), /* required last entry */ { } };How to deal with this one?
---------------------------------------------------------------switch (pdev->device) { case 0xc001: case 0xc002: case 0xc004: case 0xc101: case 0xc102: case 0xc104: nb_ports = pdev->device & 0x7; offset = 0x100; bar = 0; break; case 0x1680: case 0x2052: nb_ports = 2; bar = 2; bar_flag = 1; break;Quoted 8 lines
case 0x1681: nb_ports = 1; bar = 2; bar_flag = 1; break; default: goto failure_regions; }Could you please give the untested patch below a try.
Good luck,
Wolfgang.
Quoted 1 line
From
00c9631f26675b90ea1ff2b4bb9f72fd81fcb91cMon Sep 17 00:00:00 2001From: Wolfgang Grandegger <Wolfgang Grandegger>
Date: Fri, 2 Sep 2016 10:46:26 +0200
Subject: [PATCH] rtcan: add support for new Advantec CAN PCI devices--- ksrc/drivers/can/sja1000/rtcan_adv_pci.c | 46 +++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 4 deletions(-)ksrc/drivers/can/sja1000/rtcan_adv_pci.c +42
-4@@ -95,6 +95,12 @@ static DEFINE_PCI_DEVICE_TABLE(adv_pci_tbl) = {ADV_PCI_DEVICE (0xc101 ),ADV_PCI_DEVICE (0xc102 ),ADV_PCI_DEVICE (0xc104 ), +ADV_PCI_DEVICE (0xc201 ), +ADV_PCI_DEVICE (0xc202 ), +ADV_PCI_DEVICE (0xc204 ), +ADV_PCI_DEVICE (0xc301 ), +ADV_PCI_DEVICE (0xc302 ), + ADV_PCI_DEVICE(0xc304), /* required last entry */ { } };@@ -115,6 +121,21 @@ static void rtcan_adv_pci_write_reg(struct rtcan_device *dev, int port, u8 data)iowrite8 (data, board->base_addr + port); } +static u8 rtcan_adv_pci_read_reg_shift2 (struct rtcan_device *dev,int port) +{ +struct rtcan_adv_pci *board = (struct rtcan_adv_pci *)dev->board_priv; + +return ioread8 (board->base_addr + (port <<2 )); +} + +static void rtcan_adv_pci_write_reg_shift2 (struct rtcan_device *dev,int port, +u8 data) +{ +struct rtcan_adv_pci *board = (struct rtcan_adv_pci *)dev->board_priv; + +iowrite8 (data, board->base_addr + (port <<2 )); +} +static void rtcan_adv_pci_del_chan (struct pci_dev *pdev,struct rtcan_device *dev) {@@ -137,6 +158,7 @@ static int rtcan_adv_pci_add_chan(struct pci_dev *pdev,int channel, unsigned int bar, unsigned int offset, + unsigned int shift, struct rtcan_device **master_dev) { struct rtcan_device *dev;@@ -180,8 +202,13 @@ static int rtcan_adv_pci_add_chan(struct pci_dev *pdev, dev->board_name = adv_pci_board_name; - chip->read_reg = rtcan_adv_pci_read_reg; - chip->write_reg = rtcan_adv_pci_write_reg; +if (shift ==2 ) { + chip->read_reg = rtcan_adv_pci_read_reg_shift2; + chip->write_reg = rtcan_adv_pci_write_reg_shift2; + }else { + chip->read_reg = rtcan_adv_pci_read_reg; + chip->write_reg = rtcan_adv_pci_write_reg; + }/* Clock frequency in Hz */ dev->can_sys_clock =ADV_PCI_CAN_CLOCK ;@@ -244,6 +271,7 @@ static int adv_pci_init_one(struct pci_dev *pdev,unsigned int bar =0 ;unsigned int bar_flag =0 ;unsigned int offset =0 ; +unsigned int shift =0 ;unsigned int ix;struct rtcan_device *master_dev =NULL ;@@ -270,7 +298,16 @@ static int adv_pci_init_one(struct pci_dev *pdev,case 0xc104 : nb_ports = pdev->device &0x7 ; offset =0x100 ; - bar =0 ; +break ; +case 0xc201 : +case 0xc202 : +case 0xc204 : +case 0xc301 : +case 0xc302 : +case 0xc304 : + nb_ports = pdev->device &0x7 ; + offset =0x400 ; + shift =2 ;break ;case 0x1680 :case 0x2052 :@@ -298,7 +335,8 @@ static int adv_pci_init_one(struct pci_dev *pdev, pdev->device, pdev->subsystem_device); - ret =rtcan_adv_pci_add_chan (pdev, channel, bar, offset, &master_dev); + ret =rtcan_adv_pci_add_chan (pdev, channel, bar, offset, shift, + &master_dev);if (ret) goto failure_iounmap;Signature · 1 line
1.9.1
Thank you very much. Are you the Wolfgang of the driver author? That's really amazing and you are really a nice person. Wish you a good weekend! As I have mentioned, I am new to this, it will take me a while coming back. Thank you!
------------I am back.--------------
I modified the source code and compiled the xeno_can_adv_pci.ko with "make CONFIG_XENO_...=m -C $(krnsrc) M=$(krnsrc)/drivers/xenomai/can/sja1000 modules". After copied the module to the /lib/... directory and "modprobe xeno_can_adv_pci", /proc/rtcan/devices remain the same. But "dmesg | grep -i can" outputs these:
...
[ 239.374873] RT-Socket-CAN 0.90.2 - (C) 2006 RT-Socket-CAN Development Team [ 239.396977] RTCAN SJA1000 driver initialized [ 239.405819] xeno_can_adv_pci: module verification failed: signature and/or required key missing - tainting kernel [ 239.408014] ADV-PCI-CAN 0000:03:00.0: RTCAN Registering card [ 239.408121] ADV-PCI-CAN 0000:03:00.0: PCI->APIC IRQ transform: INT A -> IRQ 18 [ 239.408189] ADV-PCI-CAN 0000:03:00.0: RTCAN detected Advantech PCI card at slot #0 [ 239.408254] ADV-PCI-CAN: Initializing device 13fe:c302:c302 [ 239.408386] ADV-PCI-CAN: base_addr=ffffc900008fe400 conf_addr= (null) irq=18 ocr=0xfa cdr=0xc0 [ 239.408575] rtcan: registered rtcan0 [ 239.408631] Unregistering SJA1000 device rtcan0 [ 239.408736] RTCAN: unregistered rtcan0 [ 239.408890] ADV-PCI-CAN: probe of 0000:03:00.0 failed with error -5
Hello,
Am 03.09.2016 um 02:54 schrieb Jack Lee:
...snip...
Quoted 17 lines
------------I am back.--------------
I modified the source code and compiled the xeno_can_adv_pci.ko with "make CONFIG_XENO_...=m -C $(krnsrc) M=$(krnsrc)/drivers/xenomai/can/sja1000 modules".
After copied the module to the/lib/... directory and "modprobexeno_can_adv_pci",/proc/rtcan/devicesremain the same. But "dmesg | grep -i can" outputs these:
...[ 239.374873] RT-Socket-CAN 0.90.2 - (C) 2006 RT-Socket-CAN Development Team [ 239.396977] RTCAN SJA1000 driver initialized [ 239.405819] xeno_can_adv_pci: module verification failed: signature and/or required key missing - tainting kernel [ 239.408014] ADV-PCI-CAN 0000:03:00.0: RTCAN Registering card [ 239.408121] ADV-PCI-CAN 0000:03:00.0: PCI->APIC IRQ transform: INT A -> IRQ 18 [ 239.408189] ADV-PCI-CAN 0000:03:00.0: RTCAN detected Advantech PCI
Quoted 8 lines
card at slot #0
[ 239.408254] ADV-PCI-CAN: Initializing device 13fe:c302:c302 [ 239.408386] ADV-PCI-CAN: base_addr=ffffc900008fe400 conf_addr= (null) irq=18 ocr=0xfa cdr=0xc0 [ 239.408575] rtcan: registered rtcan0 [ 239.408631] Unregistering SJA1000 device rtcan0 [ 239.408736] RTCAN: unregistered rtcan0 [ 239.408890] ADV-PCI-CAN: probe of 0000:03:00.0 failed with error -5
Oops, I forgot to adjust the mapped PCI space. In "pci_map()" "ADV_PCI_BASE_SIZE << shift" should be used. Below is v2 of the patch. Hope it works now.
Wolfgang.
Quoted 1 line
From
f346a0e7b08a02cc4ef3b06eef88992a6140b957Mon Sep 17 00:00:00 2001
From: Wolfgang Grandegger <Wolfgang Grandegger>
Date: Fri, 2 Sep 2016 10:46:26 +0200
Subject: [PATCH v2] rtcan: add support for new Advantec CAN PCI devices
--- ksrc/drivers/can/sja1000/rtcan_adv_pci.c | 52 ++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 6 deletions(-)
ksrc/drivers/can/sja1000/rtcan_adv_pci.c +46 -6
@@ -95,6 +95,12 @@ static DEFINE_PCI_DEVICE_TABLE(adv_pci_tbl) = {ADV_PCI_DEVICE (0xc101 ),ADV_PCI_DEVICE (0xc102 ),ADV_PCI_DEVICE (0xc104 ), +ADV_PCI_DEVICE (0xc201 ), +ADV_PCI_DEVICE (0xc202 ), +ADV_PCI_DEVICE (0xc204 ), +ADV_PCI_DEVICE (0xc301 ), +ADV_PCI_DEVICE (0xc302 ), + ADV_PCI_DEVICE(0xc304), /* required last entry */ { } };
@@ -115,6 +121,21 @@ static void rtcan_adv_pci_write_reg(struct rtcan_device *dev, int port, u8 data)iowrite8 (data, board->base_addr + port); } +static u8 rtcan_adv_pci_read_reg_shift2 (struct rtcan_device *dev,int port) +{ +struct rtcan_adv_pci *board = (struct rtcan_adv_pci *)dev->board_priv; + +return ioread8 (board->base_addr + (port <<2 )); +} + +static void rtcan_adv_pci_write_reg_shift2 (struct rtcan_device *dev,int port, +u8 data) +{ +struct rtcan_adv_pci *board = (struct rtcan_adv_pci *)dev->board_priv; + +iowrite8 (data, board->base_addr + (port <<2 )); +} +static void rtcan_adv_pci_del_chan (struct pci_dev *pdev,struct rtcan_device *dev) {
@@ -137,6 +158,7 @@ static int rtcan_adv_pci_add_chan(struct pci_dev *pdev,int channel, unsigned int bar, unsigned int offset, + unsigned int shift, struct rtcan_device **master_dev) { struct rtcan_device *dev;
@@ -161,13 +183,15 @@ static int rtcan_adv_pci_add_chan(struct pci_dev *pdev,if (offset) base_addr = master_board->base_addr+offset;else - base_addr =pci_iomap (pdev, bar,ADV_PCI_BASE_SIZE ); + base_addr =pci_iomap (pdev, bar, +ADV_PCI_BASE_SIZE << shift);if (!base_addr) { ret = -EIO ; goto failure; } }else { - base_addr =pci_iomap (pdev, bar,ADV_PCI_BASE_SIZE ) + offset; + base_addr =pci_iomap (pdev, bar, +ADV_PCI_BASE_SIZE << shift) + offset;if (!base_addr) { ret = -EIO ; goto failure;
@@ -180,8 +204,13 @@ static int rtcan_adv_pci_add_chan(struct pci_dev *pdev, dev->board_name = adv_pci_board_name; - chip->read_reg = rtcan_adv_pci_read_reg; - chip->write_reg = rtcan_adv_pci_write_reg; +if (shift ==2 ) { + chip->read_reg = rtcan_adv_pci_read_reg_shift2; + chip->write_reg = rtcan_adv_pci_write_reg_shift2; + }else { + chip->read_reg = rtcan_adv_pci_read_reg; + chip->write_reg = rtcan_adv_pci_write_reg; + }/* Clock frequency in Hz */ dev->can_sys_clock =ADV_PCI_CAN_CLOCK ;
@@ -244,6 +273,7 @@ static int adv_pci_init_one(struct pci_dev *pdev,unsigned int bar =0 ;unsigned int bar_flag =0 ;unsigned int offset =0 ; +unsigned int shift =0 ;unsigned int ix;struct rtcan_device *master_dev =NULL ;
@@ -270,7 +300,16 @@ static int adv_pci_init_one(struct pci_dev *pdev,case 0xc104 : nb_ports = pdev->device &0x7 ; offset =0x100 ; - bar =0 ; +break ; +case 0xc201 : +case 0xc202 : +case 0xc204 : +case 0xc301 : +case 0xc302 : +case 0xc304 : + nb_ports = pdev->device &0x7 ; + offset =0x400 ; + shift =2 ;break ;case 0x1680 :case 0x2052 :
@@ -298,7 +337,8 @@ static int adv_pci_init_one(struct pci_dev *pdev, pdev->device, pdev->subsystem_device); - ret =rtcan_adv_pci_add_chan (pdev, channel, bar, offset, &master_dev); + ret =rtcan_adv_pci_add_chan (pdev, channel, bar, offset, shift, + &master_dev);if (ret) goto failure_iounmap;
Signature · 1 line
1.9.1
[Xenomai] rt-socket-can "no device" problem with advantech PCM-26D2CA CANboard
Quoted 165 lines
Hello,
Am 03.09.2016 um 02:54 schrieb Jack Lee:
...snip...Quoted 17 lines
------------I am back.--------------
I modified the source code and compiled the xeno_can_adv_pci.ko with "make CONFIG_XENO_...=m -C $(krnsrc) M=$(krnsrc)/drivers/xenomai/can/sja1000 modules".
After copied the module to the/lib/... directory and "modprobexeno_can_adv_pci",/proc/rtcan/devicesremain the same. But "dmesg | grep -i can" outputs these:
...[ 239.374873] RT-Socket-CAN 0.90.2 - (C) 2006 RT-Socket-CAN Development Team [ 239.396977] RTCAN SJA1000 driver initialized [ 239.405819] xeno_can_adv_pci: module verification failed: signature and/or required key missing - tainting kernel [ 239.408014] ADV-PCI-CAN 0000:03:00.0: RTCAN Registering card [ 239.408121] ADV-PCI-CAN 0000:03:00.0: PCI->APIC IRQ transform: INT A -> IRQ 18 [ 239.408189] ADV-PCI-CAN 0000:03:00.0: RTCAN detected Advantech PCIQuoted 8 lines
card at slot #0
[ 239.408254] ADV-PCI-CAN: Initializing device 13fe:c302:c302 [ 239.408386] ADV-PCI-CAN: base_addr=ffffc900008fe400 conf_addr= (null) irq=18 ocr=0xfa cdr=0xc0 [ 239.408575] rtcan: registered rtcan0 [ 239.408631] Unregistering SJA1000 device rtcan0 [ 239.408736] RTCAN: unregistered rtcan0 [ 239.408890] ADV-PCI-CAN: probe of 0000:03:00.0 failed with error -5Oops, I forgot to adjust the mapped PCI space. In "
pci_map()" "ADV_PCI_BASE_SIZE<< shift" should be used. Below is v2 of the patch. Hope it works now.Wolfgang.
From
f346a0e7b08a02cc4ef3b06eef88992a6140b957Mon Sep 17 00:00:00 2001
From: Wolfgang Grandegger <Wolfgang Grandegger>
Date: Fri, 2 Sep 2016 10:46:26 +0200
Subject: [PATCH v2] rtcan: add support for new Advantec CAN PCI devices--- ksrc/drivers/can/sja1000/rtcan_adv_pci.c | 52 ++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 6 deletions(-)ksrc/drivers/can/sja1000/rtcan_adv_pci.c +46
-6@@ -95,6 +95,12 @@ static DEFINE_PCI_DEVICE_TABLE(adv_pci_tbl) = {ADV_PCI_DEVICE (0xc101 ),ADV_PCI_DEVICE (0xc102 ),ADV_PCI_DEVICE (0xc104 ), +ADV_PCI_DEVICE (0xc201 ), +ADV_PCI_DEVICE (0xc202 ), +ADV_PCI_DEVICE (0xc204 ), +ADV_PCI_DEVICE (0xc301 ), +ADV_PCI_DEVICE (0xc302 ), + ADV_PCI_DEVICE(0xc304), /* required last entry */ { } };@@ -115,6 +121,21 @@ static void rtcan_adv_pci_write_reg(struct rtcan_device *dev, int port, u8 data)iowrite8 (data, board->base_addr + port); } +static u8 rtcan_adv_pci_read_reg_shift2 (struct rtcan_device *dev,int port) +{ +struct rtcan_adv_pci *board = (struct rtcan_adv_pci *)dev->board_priv; + +return ioread8 (board->base_addr + (port <<2 )); +} + +static void rtcan_adv_pci_write_reg_shift2 (struct rtcan_device *dev,int port, +u8 data) +{ +struct rtcan_adv_pci *board = (struct rtcan_adv_pci *)dev->board_priv; + +iowrite8 (data, board->base_addr + (port <<2 )); +} +static void rtcan_adv_pci_del_chan (struct pci_dev *pdev,struct rtcan_device *dev) {@@ -137,6 +158,7 @@ static int rtcan_adv_pci_add_chan(struct pci_dev *pdev,int channel, unsigned int bar, unsigned int offset, + unsigned int shift, struct rtcan_device **master_dev) { struct rtcan_device *dev;@@ -161,13 +183,15 @@ static int rtcan_adv_pci_add_chan(struct pci_dev *pdev,if (offset) base_addr = master_board->base_addr+offset;else - base_addr =pci_iomap (pdev, bar,ADV_PCI_BASE_SIZE ); + base_addr =pci_iomap (pdev, bar, +ADV_PCI_BASE_SIZE << shift);if (!base_addr) { ret = -EIO ; goto failure; } }else { - base_addr =pci_iomap (pdev, bar,ADV_PCI_BASE_SIZE ) + offset; + base_addr =pci_iomap (pdev, bar, +ADV_PCI_BASE_SIZE << shift) + offset;if (!base_addr) { ret = -EIO ; goto failure;@@ -180,8 +204,13 @@ static int rtcan_adv_pci_add_chan(struct pci_dev *pdev, dev->board_name = adv_pci_board_name; - chip->read_reg = rtcan_adv_pci_read_reg; - chip->write_reg = rtcan_adv_pci_write_reg; +if (shift ==2 ) { + chip->read_reg = rtcan_adv_pci_read_reg_shift2; + chip->write_reg = rtcan_adv_pci_write_reg_shift2; + }else { + chip->read_reg = rtcan_adv_pci_read_reg; + chip->write_reg = rtcan_adv_pci_write_reg; + }/* Clock frequency in Hz */ dev->can_sys_clock =ADV_PCI_CAN_CLOCK ;@@ -244,6 +273,7 @@ static int adv_pci_init_one(struct pci_dev *pdev,unsigned int bar =0 ;unsigned int bar_flag =0 ;unsigned int offset =0 ; +unsigned int shift =0 ;unsigned int ix;struct rtcan_device *master_dev =NULL ;@@ -270,7 +300,16 @@ static int adv_pci_init_one(struct pci_dev *pdev,case 0xc104 : nb_ports = pdev->device &0x7 ; offset =0x100 ; - bar =0 ; +break ; +case 0xc201 : +case 0xc202 : +case 0xc204 : +case 0xc301 : +case 0xc302 : +case 0xc304 : + nb_ports = pdev->device &0x7 ; + offset =0x400 ; + shift =2 ;break ;case 0x1680 :case 0x2052 :@@ -298,7 +337,8 @@ static int adv_pci_init_one(struct pci_dev *pdev, pdev->device, pdev->subsystem_device); - ret =rtcan_adv_pci_add_chan (pdev, channel, bar, offset, &master_dev); + ret =rtcan_adv_pci_add_chan (pdev, channel, bar, offset, shift, + &master_dev);if (ret) goto failure_iounmap;Signature · 1 line
1.9.1
Thanks a lot! The device is not on my hand at the moment. I will test it tomorrow and bring back the result. By the way, I am in the East +8.00 timezone. Have a good day!
[Xenomai] rt-socket-can "no device" problem with advantech PCM-26D2CA CANboard
Quoted 165 lines
Hello,
Am 03.09.2016 um 02:54 schrieb Jack Lee:
...snip...Quoted 17 lines
------------I am back.--------------
I modified the source code and compiled the xeno_can_adv_pci.ko with "make CONFIG_XENO_...=m -C $(krnsrc) M=$(krnsrc)/drivers/xenomai/can/sja1000 modules".
After copied the module to the/lib/... directory and "modprobexeno_can_adv_pci",/proc/rtcan/devicesremain the same. But "dmesg | grep -i can" outputs these:
...[ 239.374873] RT-Socket-CAN 0.90.2 - (C) 2006 RT-Socket-CAN Development Team [ 239.396977] RTCAN SJA1000 driver initialized [ 239.405819] xeno_can_adv_pci: module verification failed: signature and/or required key missing - tainting kernel [ 239.408014] ADV-PCI-CAN 0000:03:00.0: RTCAN Registering card [ 239.408121] ADV-PCI-CAN 0000:03:00.0: PCI->APIC IRQ transform: INT A -> IRQ 18 [ 239.408189] ADV-PCI-CAN 0000:03:00.0: RTCAN detected Advantech PCIQuoted 8 lines
card at slot #0
[ 239.408254] ADV-PCI-CAN: Initializing device 13fe:c302:c302 [ 239.408386] ADV-PCI-CAN: base_addr=ffffc900008fe400 conf_addr= (null) irq=18 ocr=0xfa cdr=0xc0 [ 239.408575] rtcan: registered rtcan0 [ 239.408631] Unregistering SJA1000 device rtcan0 [ 239.408736] RTCAN: unregistered rtcan0 [ 239.408890] ADV-PCI-CAN: probe of 0000:03:00.0 failed with error -5Oops, I forgot to adjust the mapped PCI space. In "
pci_map()" "ADV_PCI_BASE_SIZE<< shift" should be used. Below is v2 of the patch. Hope it works now.Wolfgang.
From
f346a0e7b08a02cc4ef3b06eef88992a6140b957Mon Sep 17 00:00:00 2001
From: Wolfgang Grandegger <Wolfgang Grandegger>
Date: Fri, 2 Sep 2016 10:46:26 +0200
Subject: [PATCH v2] rtcan: add support for new Advantec CAN PCI devices--- ksrc/drivers/can/sja1000/rtcan_adv_pci.c | 52 ++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 6 deletions(-)ksrc/drivers/can/sja1000/rtcan_adv_pci.c +46
-6@@ -95,6 +95,12 @@ static DEFINE_PCI_DEVICE_TABLE(adv_pci_tbl) = {ADV_PCI_DEVICE (0xc101 ),ADV_PCI_DEVICE (0xc102 ),ADV_PCI_DEVICE (0xc104 ), +ADV_PCI_DEVICE (0xc201 ), +ADV_PCI_DEVICE (0xc202 ), +ADV_PCI_DEVICE (0xc204 ), +ADV_PCI_DEVICE (0xc301 ), +ADV_PCI_DEVICE (0xc302 ), + ADV_PCI_DEVICE(0xc304), /* required last entry */ { } };@@ -115,6 +121,21 @@ static void rtcan_adv_pci_write_reg(struct rtcan_device *dev, int port, u8 data)iowrite8 (data, board->base_addr + port); } +static u8 rtcan_adv_pci_read_reg_shift2 (struct rtcan_device *dev,int port) +{ +struct rtcan_adv_pci *board = (struct rtcan_adv_pci *)dev->board_priv; + +return ioread8 (board->base_addr + (port <<2 )); +} + +static void rtcan_adv_pci_write_reg_shift2 (struct rtcan_device *dev,int port, +u8 data) +{ +struct rtcan_adv_pci *board = (struct rtcan_adv_pci *)dev->board_priv; + +iowrite8 (data, board->base_addr + (port <<2 )); +} +static void rtcan_adv_pci_del_chan (struct pci_dev *pdev,struct rtcan_device *dev) {@@ -137,6 +158,7 @@ static int rtcan_adv_pci_add_chan(struct pci_dev *pdev,int channel, unsigned int bar, unsigned int offset, + unsigned int shift, struct rtcan_device **master_dev) { struct rtcan_device *dev;@@ -161,13 +183,15 @@ static int rtcan_adv_pci_add_chan(struct pci_dev *pdev,if (offset) base_addr = master_board->base_addr+offset;else - base_addr =pci_iomap (pdev, bar,ADV_PCI_BASE_SIZE ); + base_addr =pci_iomap (pdev, bar, +ADV_PCI_BASE_SIZE << shift);if (!base_addr) { ret = -EIO ; goto failure; } }else { - base_addr =pci_iomap (pdev, bar,ADV_PCI_BASE_SIZE ) + offset; + base_addr =pci_iomap (pdev, bar, +ADV_PCI_BASE_SIZE << shift) + offset;if (!base_addr) { ret = -EIO ; goto failure;@@ -180,8 +204,13 @@ static int rtcan_adv_pci_add_chan(struct pci_dev *pdev, dev->board_name = adv_pci_board_name; - chip->read_reg = rtcan_adv_pci_read_reg; - chip->write_reg = rtcan_adv_pci_write_reg; +if (shift ==2 ) { + chip->read_reg = rtcan_adv_pci_read_reg_shift2; + chip->write_reg = rtcan_adv_pci_write_reg_shift2; + }else { + chip->read_reg = rtcan_adv_pci_read_reg; + chip->write_reg = rtcan_adv_pci_write_reg; + }/* Clock frequency in Hz */ dev->can_sys_clock =ADV_PCI_CAN_CLOCK ;@@ -244,6 +273,7 @@ static int adv_pci_init_one(struct pci_dev *pdev,unsigned int bar =0 ;unsigned int bar_flag =0 ;unsigned int offset =0 ; +unsigned int shift =0 ;unsigned int ix;struct rtcan_device *master_dev =NULL ;@@ -270,7 +300,16 @@ static int adv_pci_init_one(struct pci_dev *pdev,case 0xc104 : nb_ports = pdev->device &0x7 ; offset =0x100 ; - bar =0 ; +break ; +case 0xc201 : +case 0xc202 : +case 0xc204 : +case 0xc301 : +case 0xc302 : +case 0xc304 : + nb_ports = pdev->device &0x7 ; + offset =0x400 ; + shift =2 ;break ;case 0x1680 :case 0x2052 :@@ -298,7 +337,8 @@ static int adv_pci_init_one(struct pci_dev *pdev, pdev->device, pdev->subsystem_device); - ret =rtcan_adv_pci_add_chan (pdev, channel, bar, offset, &master_dev); + ret =rtcan_adv_pci_add_chan (pdev, channel, bar, offset, shift, + &master_dev);if (ret) goto failure_iounmap;Signature · 1 line
1.9.1
Thanks a lot! The device is not on my hand at the moment. I will test it tomorrow and bring back the result. By the way, I am in the East +8.00 timezone. Have a good day! ---------back.------------
Sorry to say that error exactly the same with before.