xeno_can_mem driver
Thank you for your reply !
Quoted 8 lines
Quoted 8 lines
I'm currently trying to get the can-interfaces of an Samsung S3C2440
based board working (NetDCU10). The used Linux kernel version is
2.6.19,
because this was deliverd in the BSP. I patched this kernel with
Xenomai
2.4.0., as this was the newest Version I managed the Kernel to compile with.
Quoted 7 lines
Quoted 4 lines
The standard driver delivered with the board (lincan 0.3.3) mappes the
can devices to 10000000-10000007 : onboard-can
10000008-1000000f :
onboard-canHmm, the SJA1000 has 32 registers, not just 8.
This is strange, cause the original driver just maps these 8 registers.
Quoted 7 lines
Quoted 4 lines
So I tried to use the driver
xeno_can_mem.I use
modprobexen_can_memmem=0x10000000 irq=17 clock=48000000Are you sure you give the right clock frequency? Seems to be too high.
I used this clock frequency because I noticed, that the frequency is divided by 2. So I just tried it. The frequency I found in the original driver is 24MHz.
But even with clock=24000000 it appears "No such device".
Quoted 23 lines
Quoted 17 lines
to install the module but it complains that there is no such device...
As far as I know, this board uses the an sja1000p chip for can. Do you
know if there are any differences to the sja1000 chip? Are there any changes necessary in the driver sources?I figured out, that the installation of the driver stops in the function
intrtcan_sja1000_register(struct rtcan_device *dev)And there in that part:printk("chip->read_reg(dev, SJA_SR) = %d \n",chip->read_reg(dev, SJA_SR)); if ((chip->read_reg(dev, SJA_SR)& (SJA_SR_RBS | SJA_SR_DOS | SJA_SR_TBS)) != SJA_SR_TBS) { printk("ERROR! No SJA1000 device found!\n"); return -ENODEV; }Quoted 5 lines
When I comment this out the installation works and in
/proc/iomem
sja1000-mem is visible. But I'm not able to send Can-messages with rtcansen.
The program seems to work, but no messages are send as I checked it with
a scope.
Quoted 4 lines
There is no point in commenting out the driver's check for the existence of the SJA1000 and complain that it does not work. This check is there for a good reason.
It was just a try to find out where the problem comes from.
Quoted 6 lines
Quoted 2 lines
Does anybody have an hint for me, how to get the can driver working?
First find out where the 32 registers of the SJA1000 are mapped and also check the clock frequency.
Sorry for my stupid question, but how can I find out where the registers are mapped? In the original driver the base address is defined as 0x10000000.
Port size ist defined as 4 and when the memory region is requested twice of the port size is requested:request_mem_region(mem_addr, nx_can->if_portsize * 2, "onboard-can")
Do you have any suggestions how I should proceed?
Thank you!
Best regards,
Nils
Signature · 2 lines
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT! Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
Quoted 15 lines · Nils Armbruster
Thank you for your reply !
Quoted 13 lines
Quoted 12 lines
I'm currently trying to get the can-interfaces of an Samsung S3C2440
based board working (NetDCU10). The used Linux kernel version is
2.6.19,
because this was deliverd in the BSP. I patched this kernel with
Xenomai
2.4.0., as this was the newest Version I managed the Kernel to compile with.The standard driver delivered with the board (lincan 0.3.3) mappes the
can devices to 10000000-10000007 : onboard-can
10000008-1000000f :
onboard-can
Quoted 4 lines
Quoted 2 lines
Hmm, the SJA1000 has 32 registers, not just 8.
This is strange, cause the original driver just maps these 8 registers.
How does the read/write register access function look like in your lincan driver?
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
So I tried to use the driver
xeno_can_mem.I use
modprobexen_can_memmem=0x10000000 irq=17 clock=48000000
Where did you get irq=17 from? From /proc/interrups?
Quoted 6 lines
Sorry for my stupid question, but how can I find out where the registers are mapped? In the original driver the base address is defined as
0x10000000.
Port size ist defined as 4 and when the memory region is requested twice of the port size is requested:request_mem_region(mem_addr, nx_can->if_portsize * 2, "onboard-can")Do you have any suggestions how I should proceed?
I assume that the lincan driver source code is under the GPL. Feel free to post it here so we can have a closer look.
Wolfgang.
-------- Original-Nachricht --------
Quoted 24 lines
Datum: Wed, 09 Jun 2010 11:03:03 +0200
Von: Wolfgang Grandegger <[email protected]>
An: Nils Armbruster <[email protected]>
CC: [email protected], [email protected]
Betreff: Re: [Xenomai-help]xeno_can_memdriverQuoted 8 lines · Nils Armbruster
Thank you for your reply !
Quoted 6 lines
Quoted 6 lines
I'm currently trying to get the can-interfaces of an Samsung S3C2440
based board working (NetDCU10). The used Linux kernel version is
2.6.19,
because this was deliverd in the BSP. I patched this kernel with
Xenomai
2.4.0., as this was the newest Version I managed the Kernel tocompile
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
with.
The standard driver delivered with the board (lincan 0.3.3) mappes
the
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
can devices to 10000000-10000007 : onboard-can
10000008-1000000f :
onboard-can
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Hmm, the SJA1000 has 32 registers, not just 8.
This is strange, cause the original driver just maps these 8 registers.
How does the read/write register access function look like in your lincan driver?
The registers in lincan driver are written as follows:
extern inline void can_write_reg(const struct canchip_t *chip, unsigned char data, unsigned address)
{
unsigned long address_to_write;
address_to_write = chip->chip_base_addr+address;
chip->write_register(chip, data, address_to_write);
}where through chip->write_register the following function is called:
void netdcux_can_write_register(const struct canchip_t *chip, unsigned data, unsigned long address)
{
struct candevice_t *candev = chip->hostdevice;
struct netdcux_can *nx_can = (struct netdcux_can*)candev->private_data;
int chipnr;
chipnr = (address & (0xF << 28)) >> 28;
nx_can->send_byte_can(chipnr, (0xFF & address), data, (void *)nx_can);
}adress should be 0x10000000 + Reg so chipnr should be just 0x10000000 after the bit operations. I think nx_can->send_byte_can calls this function:
void FS_OnBoard_can_data_out(int if_nr, unsigned char addr, unsigned char data, void *dev)
{
struct netdcux_can *nx_can = (struct netdcux_can *)dev;
unsigned long can_flags;#ifdef FS_CAN_DEBUG
printk("OnBoard_can_out[%d] addr: %x value: %x\n", if_nr, addr, data);
#endif
spin_lock_irqsave(&fscan_atomic_lock, can_flags);
iowrite8(addr, nx_can->if_virtaddr_addr[if_nr]);
iowrite8(data, nx_can->if_virtaddr_data[if_nr]);
spin_unlock_irqrestore(&fscan_atomic_lock, can_flags);
}So I think the address of the can controller should still be 0x10000000. Or am I thinking wrong?
Quoted 22 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
So I tried to use the driver
xeno_can_mem.I use
modprobexen_can_memmem=0x10000000 irq=17 clock=48000000Where did you get irq=17 from? From
/proc/interrups?Quoted 1 line
Sorry for my stupid question, but how can I find out where the registers
are mapped?
Quoted 2 lines
In the original driver the base address is defined as
0x10000000. Port size ist defined as 4 and when the memory region is requested twiceof the port size is requested:
Quoted 3 lines
request_mem_region(mem_addr, nx_can->if_portsize * 2, "onboard-can")Do you have any suggestions how I should proceed?
I assume that the lincan driver source code is under the GPL. Feel free to post it here so we can have a closer look.
Wolfgang.
Signature · 2 lines
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT! Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
Quoted 5 lines · Nils Armbruster
void FS_OnBoard_can_data_out(int
if_nr, unsigned char addr, unsigned chardata, void *dev) { struct netdcux_can *nx_can = (struct netdcux_can *)dev; unsigned long can_flags;
Quoted 9 lines
#ifdef FS_CAN_DEBUG
printk("OnBoard_can_out[%d] addr: %x value: %x\n", if_nr, addr, data);
#endif
spin_lock_irqsave(&fscan_atomic_lock, can_flags);
iowrite8(addr, nx_can->if_virtaddr_addr[if_nr]);
iowrite8(data, nx_can->if_virtaddr_data[if_nr]);
spin_unlock_irqrestore(&fscan_atomic_lock, can_flags);
}Here we have the reason. the SJA1000 registers aren't linearly mapped into the memory space of the processor; it seems that every write to such a registers needs two iowrite8s: First the address, then the data. So I would say the xeno_can_mem driver isn't useful for you. Your CAN hardware needs a special RTCAN driver which does not exist yet.
Signature · 1 line
Sebastian
Quoted 10 lines · Nils Armbruster
Quoted 6 lines
Quoted 4 lines
So I tried to use the driver
xeno_can_mem.I use
modprobexen_can_memmem=0x10000000 irq=17 clock=48000000Are you sure you give the right clock frequency? Seems to be too high.
I used this clock frequency because I noticed, that the frequency is
divided by 2. So I just tried it. The frequency I found in the original driver is 24MHz.
You definitely have to define 24MHz here, not 48MHz.
Quoted 1 line
But even with clock=24000000 it appears "No such device".
Sure, this is another problem: The SJA1000 registers are not accessible (see below).
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
Does anybody have an hint for me, how to get the can driver working?
First find out where the 32 registers of the SJA1000 are mapped and also check the clock frequency.
Quoted 7 lines
Sorry for my stupid question, but how can I find out where the registers
are mapped? In the original driver the base address is defined as0x10000000. Port size ist defined as 4 and when the memory region is requested twice of the port size is requested:
request_mem_region(mem_addr, nx_can->if_portsize * 2, "onboard-can")Do you have any suggestions how I should proceed?
Either you study the appropriate datasheet to learn how the SJA1000 registers are accessible from your board, or you go through the code of your original driver and search for the way the SJA registers are read and write. For example, the SJA_CDR register is the last of the 32 registers.
Signature · 1 line
Sebastian