Driver Development Kit (DDK)

cancel
Showing results for 
Search instead for 
Did you mean: 

Sorry, I sent previous messages by mistake, I need help on PCI 6251 register level program

HI, Guys,
 
Sorry, I sent previous messages by mistakenly pressing the keyboard. 
 
I ahve a PCI 6251 board.  I need to use register level program since I am working on the RT Linux.  My program looks like this: 
 
1) get PCI device
 
dev = pci_find_device(vender_ID, device_ID, dev);
 
BAR0=pci_resource_start(dev,0);
BAR_LEN0=pci_resource_len(dev,0);
 
BAR1=pci_resource_start(dev,1);
BAR_LEN0=pci_resource_len(dev,1);
 
2) remap the address
mem0=ioremap(BAR0, BAR_LEN0);
mem1=ioremap(BAR1, BAR_LEN1);
 
3) initialize the MITE Controller
 
writew( 0xaeae, mem0+0x0340); ( I tried both with and without this line) 
 
writew( (mem1&0xffffff00)|0x80, mem0+0xc0);
 
4) test DIO Port1
 
writew(0xffff, mem1+0x028); // set port1 to output
 
writew(0xff, mem1+0x024); // output high
 
 
PROBLEM:  nothing happened when I run this program.
~~~~~~~~
Is there any body can advise me on this problem?  I thank you very much in advance.
 
BTW, Where can I find the PIN map of the IDC connector on the corner of the board?  Iahve the PIN map of the 68 pins SCSI connector.
 
 
 
Happy NEW YEAR!
 
0 Kudos
Message 1 of 7
(8,788 Views)
Hi,

In:

     writew( (mem1&0xffffff00)|0x80, mem0+0xc0);

'mem1' should be the physical address of bar1 (
BAR1) not the virtual kernel address:

     writew( (BAR1&0xffffff00)|0x80, mem0+0xc0);

Hope that helps,
Diego
0 Kudos
Message 2 of 7
(8,777 Views)
HI, DiegoF,
 
Thank you for your help.  I tried, but it seems still not work.  Do you think there is anything else wrong?
 
I got the
 
      Vendor_ID= 0x1093; Device_ID=0x70b8;             by using cat  /proc/bus/pci/devices
 
I got the
 
      BAR0 = 0x50002000; BAR1=0x50001000;
 
after remapping: 
 
      mem0=0xf8922000; mem1=0xf8924000; 
 
 
BTW,
1)  do I need this line: 
      writew(0xaeae, mem0+0x340)?   what's this line for?
 
2)  Am I right by using:
      writew(0xffff, mem1+0x28); // define DIO port direction
      writew(0xff, mem1+0x24);  //output "0xff" to DIO port
 
Thank you very much!
 
 
 
 
 
0 Kudos
Message 3 of 7
(8,771 Views)
>> do I need this line: writew(0xaeae, mem0+0x340)?   what's this line for?

I don't think you need it.

>> Am I right by using:
>>     writew(0xffff, mem1+0x28); // define DIO port direction
>>      writew(0xff, mem1+0x24);  //output "0xff" to DIO port

That looks correct.

-------------------------------

Try using writel (long) instead of writew (word).  Both the mite and dio mseries registers are 32-bit registers.  The names of the io macros can be misleading, but you can check the linux source include/asm-i386/io.h:

writeb - 8-bits (unsigned char)
writew -16-bits (unsigned short)
writel - 32-bits (unsinged int)

Let me know if it works,
Diego

P.S. some mseries registers are 16-bit, but the DIO registers you are using are 32-bits

0 Kudos
Message 4 of 7
(8,748 Views)

Hi, DieoF,

Thank you so much!  the DIO function is working! 

My working programe is:

===initial MITE===

writew( 0xaeae, mem0+0x0340); (this is not needed, I deleted it) 
 
writel( (mem1&0xffffff00)|0x80, mem0+0xc0);  (here writel() is needed, writew() doesn't work)
 
===test DIO===
 
writew(0xffff, mem1+0x028); // set port1 to output  ( Here both writel() and writew() work for PORT0, writew() may not work with port2, I guess)
 
writew(0xff, mem1+0x024); // output high ( Here both writel() and writew() work for PORT0, writew() may not work with port2, I guess)

Thank you again.

BTW,  would you mind if tell me how to sample AD channels?  Using Counters?  I am sorry bothering so much.  I am working on my PhD project, I have spent a lot of time to make the card working.  Thank you very much!

 

Best,

Haihong 

0 Kudos
Message 5 of 7
(8,744 Views)

Sorry,

writel( (mem1&0xffffff00)|0x80, mem0+0xc0); 

should be:

writel( (BAR1 & 0xffffff00 ) | 0x80, mem0+0xc0);

 

0 Kudos
Message 6 of 7
(8,747 Views)