Configuration of PCI Video card on a BIOS-less board
Dear All,
I was wondering if anyone has any experience in configuring the PCI registers in a PCI Video Card on a MIPS board that has no BIOS like in a PC.
At the moment when I have some "home grown" PCI probing routines based on my best interpretation of the PCI spec. But it's not working.
I can probe the Base Address Register successfully, determine the cards memory requirement and that it is memory rather than mapped IO. But when I try to write the address I have allocated to the PCI card ( eg 0xC000 0000 ) the address will not latch in the base address register.
The card is designed for x86 PCs and when the PC bios configures the card, the base address register has the value 0xF200 0000.
Any comments from anybody with any insight into what is happening here / or how I might fix my probelm, would be greatly appreciated.
Does anyone know of any code that carries out PCI probing similar to that found on x86 PC's ?
TIA
Wayne
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/
Quoted 6 lines · Wayne Gowcher
I can probe the Base Address Register successfully, determine the cards memory requirement and that it is memory rather than mapped IO. But when I try to write the address I have allocated to the PCI card ( eg
0xC0000000 ) the address will not latch in the base address register.
Is that a valid bus address on your system?
Quoted 2 lines
Does anyone know of any code that carries out PCI probing similar to that found on x86 PC's ?
Look in drivers/pci - that can scan the bus and such - it's generic code used on many architectures. Many systems lack "bios" and work fine in linux.
Signature · 4 lines
Keith M Wesolowski <[email protected]> http://foobazco.org/~wesolows ------(( Project Foobazco Coordinator and Network Administrator ))------ "Nothing motivates a man more than to see his boss put in an honest day's work." -- The fortune file
Quoted 19 lines · Wayne Gowcher
I was wondering if anyone has any experience in configuring the PCI registers in a PCI Video Card on a MIPS board that has no BIOS like in a PC.
At the moment when I have some "home grown" PCI probing routines based on my best interpretation of the PCI spec. But it's not working.
I can probe the Base Address Register successfully, determine the cards memory requirement and that it is memory rather than mapped IO. But when I try to write the address I have allocated to the PCI card ( eg
0xC0000000 ) the address will not latch in the base address register.The card is designed for x86 PCs and when the PC bios configures the card, the base address register has the value
0xF2000000.
Quoted 6 lines
Any comments from anybody with any insight into what is happening here / or how I might fix my probelm, would be greatly appreciated.
Does anyone know of any code that carries out PCI probing similar to that found on x86 PC's ?
Initialising video cards is a real PITA. The simplest method is to use a x86 BIOS emulator to execute the code in the video BIOS on the card.
Note that some cards (mostly older cards) power up in VGA legacy mode. They will not respond to PCI memory space as specified by the BAR before you tell them to do so (in a card-specific way :-(
Most modern cards power up in PCI mode. However, to use them, you still have to know the card-specific initialization sequence.
BTW, what video card do you have? If you're lucky and have a Matrox Millennium, you can use matroxfb, which knows how to initialize uninitialized cards.
Good luck!
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven ------------- Sony Software Development Center Europe (SDCE) [email protected] ------------------- Sint-Stevens-Woluwestraat 55 Voice +32-2-7248626 Fax +32-2-7262686 ---------------- B-1130 Brussels, Belgium
Quoted 22 lines · Wayne Gowcher
Dear All,
I was wondering if anyone has any experience in configuring the PCI registers in a PCI Video Card on a MIPS board that has no BIOS like in a PC.
At the moment when I have some "home grown" PCI probing routines based on my best interpretation of the PCI spec. But it's not working.
I can probe the Base Address Register successfully, determine the cards memory requirement and that it is memory rather than mapped IO. But when I try to write the address I have allocated to the PCI card ( eg
0xC0000000 ) the address will not latch in the base address register.The card is designed for x86 PCs and when the PC bios configures the card, the base address register has the value
0xF2000000.
Quoted 6 lines
Any comments from anybody with any insight into what is happening here / or how I might fix my probelm, would be greatly appreciated.
Does anyone know of any code that carries out PCI probing similar to that found on x86 PC's ?
The boot code on our mips boards, whether some version of pmon or yamon does that initialization. The powerpc guys have implemented pci scanning scheme that allows the kernel to complete initialize pretty much arbitrarily complex pci bus systems with pci-to-pci bridges etc. I hope I'll have time to someday port that to mips. I don't think you can wait till then :-)
Are you really trying to assign 0xC000 0000 to the card or was that just an example address? Unless your pci to memory window is such that there's a translation that occurs, that address is incorrect. If the window is 1:1, the physical address 0xC000 0000 does not exist. You need to assign the card a real physical address; if your system has 32MB of memory, than that address would have to be between 0 and 0x2000000. (well, you can't give it address "0" because of interrupt vectors, but you get the point). I can point you to some examples if you have problems.
Pete
Quoted 9 lines · Pete Popov
Are you really trying to assign
0xC0000000 to the card or was that just an example address? Unless your pci to memory window is such that there's a translation that occurs, that address is incorrect. If the window is 1:1, the physical address0xC0000000 does not exist. You need to assign the card a real physical address; if your system has 32MB of memory, than that address would have to be between 0 and0x2000000. (well, you can't give it address "0" because of interrupt vectors, but you get the point). I can point you to some examples if you have problems.
If you have 32 MB of RAM and you put a PCI card at an address between 0 and 0x2000000 you'll have a problem! PCI cards must not overlap with real memory.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven ------------- Sony Software Development Center Europe (SDCE) [email protected] ------------------- Sint-Stevens-Woluwestraat 55 Voice +32-2-7248626 Fax +32-2-7262686 ---------------- B-1130 Brussels, Belgium
Quoted 12 lines · Geert Uytterhoeven
Quoted 9 lines · Pete Popov
Are you really trying to assign
0xC0000000 to the card or was that just an example address? Unless your pci to memory window is such that there's a translation that occurs, that address is incorrect. If the window is 1:1, the physical address0xC0000000 does not exist. You need to assign the card a real physical address; if your system has 32MB of memory, than that address would have to be between 0 and0x2000000. (well, you can't give it address "0" because of interrupt vectors, but you get the point). I can point you to some examples if you have problems.
Quoted 2 lines
If you have 32 MB of RAM and you put a PCI card at an address between 0 and
0x2000000you'll have a problem! PCI cards must not overlap with real memory.
Sorry Wayne, I'm working on an ethernet driver and was thinking of descriptors and data buffers for PCI ethernet cards, which have to be in real physical memory. Geert is right, but 0xC000 0000 still seems suspicious. That's a very high physical address and pci devices are usually mapped at lower addresses. Something like 0x2000 0000 is more reasonable and makes accessing the card through kseg1 possible.
Pete
Geert, Pete,
Thanks for your input, it makes me question things I should have questioned before.
0xC000 0000 is the actual address I am trying to use. I used it because another PCI card that I have a driver for was using it and so I just carried on its use. I didnt really question the value or its use. But obviously it works for that card.
After your emails I revisited that code and now I partially understand why it works. The chip has an internal bus that translates address requests internally. So when i write to 0xC000 0000 it would never make to the actual address lines of the chip and instead be routed to the PCI controller ( I think :) )
The original card i had a problem had an ATI Rage chip. I am now experimenting with a VGA card with a Cirrus Logic chip. I've got this card to accept the programmed base address and am in teh process of studying clgenfb.c to see if I can modify it to my needs.
On first inspection clgenfb.c is written for the Amiga??? and so I am trying to weed out the dependencies. If anyone knows of a more generic driver it would be much appreciated.
Wayne
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/
Quoted 11 lines · Wayne Gowcher
Geert, Pete,
Thanks for your input, it makes me question things I should have questioned before.
0xC0000000 is the actual address I am trying to use. I used it because another PCI card that I have a driver for was using it and so I just carried on its use. I didnt really question the value or its use. But obviously it works for that card.
And this driver works on mips? When you read the base mem register from this card that works, it says "0xC0000000"?
Quoted 6 lines
After your emails I revisited that code and now I partially understand why it works. The chip has an internal bus that translates address requests internally. So when i write to
0xC0000000 it would never make to the actual address lines of the chip and instead be routed to the PCI controller ( I think :) )
I'm not clear on how this works with the good driver. If you write to 0xC000 0000, that's a mips virtual address in the kseg2 region, which is a mapped region. So what physical address you put on the bus when you write to 0xC000 0000 depends on the tlb entry you've setup. If 0xC000 0000 is truly a PCI memory physical address, then you need to setup a tlb entry that maps some virtual address to the physical address 0xC000 0000. I doubt you want to muck with that and would suggest you redo your PCI bus memory map so that the PCI bus is at a lower address, like 0x1000 0000. You can then access physical 0x1000 0000 through virtual address 0xB000 0000 (kseg1). I think you already told me, but what board/CPU are you working with?
Pete
Pete,
I think I am in "dopey" mode this morning.
The 0xC000 0000 I was talking about comes from another board I was working on recently that mapped a comapnion chip into kseg2 space. It seems it's been burnt into my brain :(
The working PCI card is actually mapped to 0xA200 0000, and I am using that for the VGA card. My comments about the address translation were totally wrong. Sorry for any confusion.
Time for a coffee and a long rethink :)
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/
Quoted 5 lines · Pete Popov
I'm not clear on how this works with the good driver. If you write to
0xC0000000, that's a mips virtual address in the kseg2 region, which is a mapped region. So what physical address you put on the bus when you write to0xC0000000 depends on the tlb entry you've setup. If0xC0000000 is truly a PCI memory physical address, then you need to setup a
Repeat after me until done: BAR values have nothing to do with CPU addresses. If your PCI bus happens to map PCI memory location 0 onto physical address 0, then they are the same. That's almost certainly not the case. Otherwise, an address in a BAR is the *PCI bus address*, NOT a CPU physical address.
A simple example: a PCI bridge exists in a system. It is wired into the CPU address bus such that it responds to 0x18000000-0x19ffffff physical. On the other side of the bridge, it maps 0x00000000-0x7fffffff bus addresses onto physical memory (for DMA), and 0x80000000-0xffffffff onto PCI memory space (for PIO). The bridge translates addresses such that:
bus_address_for_BARs == 0x80000000 + (cpu_physical_address - 0x18000000) bus_address_for_DMA == cpu_physical_address
and, of course,
cpu_virtual_address_for_pointers == KSEG[01]ADDR (cpu_physical_address)
In the example above, the PCI bus is mapped into CPU memory such that it can be accessed via ksegX, which is normal. If it were mapped at, for example, 0x40000000, that would not be the case and you would need a TLB entry. Note that for mips64, you can use KPHYS to access any physical address; ie it need not be below 0x20000000.
Signature · 4 lines
Keith M Wesolowski <[email protected]> http://foobazco.org/~wesolows ------(( Project Foobazco Coordinator and Network Administrator ))------ "Nothing motivates a man more than to see his boss put in an honest day's work." -- The fortune file
Quoted 9 lines · Keith M Wesolowski
Quoted 5 lines · Pete Popov
I'm not clear on how this works with the good driver. If you write to
0xC0000000, that's a mips virtual address in the kseg2 region, which is a mapped region. So what physical address you put on the bus when you write to0xC0000000 depends on the tlb entry you've setup. If0xC0000000 is truly a PCI memory physical address, then you need to setup a
Quoted 5 lines
Repeat after me until done: BAR values have nothing to do with CPU addresses. If your PCI bus happens to map PCI memory location 0 onto physical address 0, then they are the same. That's almost certainly not the case. Otherwise, an address in a BAR is the *PCI bus address*, NOT a CPU physical address.
Wayne's email indicated, if I understood it correctly, that he is trying to access the card's registers by writing to 0xC000 0000, after he has written 0xC000 0000 to the BAR. That address cannot be an address that the host to pci controller understands as PCI memory address because it overlaps with kseg2. So if 0xC000 0000 is the correct address to write in the BAR, then he needs to access the card's registers through the PCI mem region that looks something like your example below. But if his memory map is 1:1, then 0xC000 0000 is the wrong value to write to that register.
Quoted 19 lines
A simple example: a PCI bridge exists in a system. It is wired into the CPU address bus such that it responds to 0x18000000-0x19ffffff physical. On the other side of the bridge, it maps 0x00000000-0x7fffffff bus addresses onto physical memory (for DMA), and 0x80000000-0xffffffff onto PCI memory space (for PIO). The bridge translates addresses such that:
bus_address_for_BARs==0x80000000+ (cpu_physical_address-0x18000000)bus_address_for_DMA==cpu_physical_addressand, of course,
cpu_virtual_address_for_pointers== KSEG[01]ADDR (cpu_physical_address)In the example above, the PCI bus is mapped into CPU memory such that it can be accessed via ksegX, which is normal. If it were mapped at, for example,
0x40000000, that would not be the case and you would need a TLB entry. Note that for mips64, you can use KPHYS to access any physical address; ie it need not be below0x20000000.
Netscape on linux-mipsel ??
Dear All,
Does anyone know if Netscape or any other browser has been compiled to run on linux mipsel ? All I can find so far are "x86" source for netscape.
If it has, care to tell me the links where I may get it ?
Alternatively, if no one knows of anyone having a working linux mipsel Netscape binary / rpm. Anyone care to guess the scope of attempting to modify the x86 or mips-sgi-irix sources to run on mips ?
TIA
Wayne
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/
Re: Netscape on linux-mipsel ??
Quoted 6 lines · Wayne Gowcher
Dear All,
Does anyone know if Netscape or any other browser has been compiled to run on linux mipsel ? All I can find so far are "x86" source for netscape.
Quoted 8 lines
If it has, care to tell me the links where I may get it ?
Alternatively, if no one knows of anyone having a working linux mipsel Netscape binary / rpm. Anyone care to guess the scope of attempting to modify the x86 or mips-sgi-irix sources to run on mips ?
We're pretty close on having both, be and le mips binaries. You'll need a graphics card which has frame buffer driver support so that X can run on top of the FBdev driver. Check with me again "later".
Pete
Re: Netscape on linux-mipsel ??
In reply to Wayne GowcherQuoted 11 lines · Wayne Gowcher
Does anyone know if Netscape or any other browser has been compiled to run on linux mipsel ? All I can find so far are "x86" source for netscape.
If it has, care to tell me the links where I may get it ?
Alternatively, if no one knows of anyone having a working linux mipsel Netscape binary / rpm. Anyone care to guess the scope of attempting to modify the x86 or mips-sgi-irix sources to run on mips ?
If you check more exactly you'll find that all the sources are actually binaries ...
I had Mozilla running on Linux/MIPS three years ago but didn't continue to debug it. Getting it to work shouldn't be rocket science. The text mode browsers lynx, w3m or link just work.
Ralf
Quoted 9 lines · Keith M Wesolowski
Quoted 5 lines · Pete Popov
I'm not clear on how this works with the good driver. If you write to
0xC0000000, that's a mips virtual address in the kseg2 region, which is a mapped region. So what physical address you put on the bus when you write to0xC0000000 depends on the tlb entry you've setup. If0xC0000000 is truly a PCI memory physical address, then you need to setup a
Quoted 6 lines
Repeat after me until done: BAR values have nothing to do with CPU addresses. If your PCI bus happens to map PCI memory location 0 onto physical address 0, then they are the same. That's almost certainly not the case. Otherwise, an address in a BAR is the *PCI bus address*, NOT a CPU physical address.
Keith,
What you said is right in theory. However not correct in practice.
Most drivers read BAR address (in PCI memory space) and do ioremap() to get (usually uncached) virtual address to access the PCI memory region. On mips, the default ioremap() essentially does 1 to 1 mapping from PCI meory space to physical address space and then further maps it into KSEG1.
That pretty much mandates each MIPS port must maintain 1:1 mapping between the PCI memory space and CPU physical space - unless you enjoy the fun of hacking with PCI fixups.
Quoted 25 lines
A simple example: a PCI bridge exists in a system. It is wired into the CPU address bus such that it responds to 0x18000000-0x19ffffff physical. On the other side of the bridge, it maps 0x00000000-0x7fffffff bus addresses onto physical memory (for DMA), and 0x80000000-0xffffffff onto PCI memory space (for PIO). The bridge translates addresses such that:
bus_address_for_BARs==0x80000000+ (cpu_physical_address-0x18000000)bus_address_for_DMA==cpu_physical_addressand, of course,
cpu_virtual_address_for_pointers== KSEG[01]ADDR (cpu_physical_address)In the example above, the PCI bus is mapped into CPU memory such that it can be accessed via ksegX, which is normal. If it were mapped at, for example,
0x40000000, that would not be the case and you would need a TLB entry. Note that for mips64, you can use KPHYS to access any physical address; ie it need not be below0x20000000.--
Keith M Wesolowski <[email protected]> http://foobazco.org/~wesolows
------(( Project Foobazco Coordinator and Network Administrator ))------
"Nothing motivates a man more than to see his boss put
in an honest day's work." -- The fortune file
Guys,
Sorry for all the confusion, and subsequent traffic as a result of my mistakes.
I'm still feeling my way with regards to programming the PCI and have mixed up terms and addresses.
Just for the record :
In actual fact the PCI code is writing physical addresses to the Base Address Register, eg 0x02000000. Then later on when the driver is initialising itself it reads the BAR and adds on KSEG1 :
dev->base_addr = KSEG1ADDR(base_addr);
It is this "dev->base_addr" that gets reported to me on boot up ( 0xA2000000 ) as being the base address of the device. The 0xC000 0000 I wrote in my first mail was from another problem I had been working and was somehow burned into my brain.
There is nothing like someone questioning one's assumptions to make one re-evaluate those assumptions. For this I am grateful to those people, for spotting the gaping whole of my mistake and bringing it to my attention. For me at least it has been very useful in that respect.
I still would like to understand PCI issues more particularly with respect to so called "legacy PCi devices" VGA, sound card etc. So if anyone would like to mail me off the list with tips / reading they have found useful, it would be most appreciated.
Wayne
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/
Quoted 10 lines · Wayne Gowcher
The original card i had a problem had an ATI Rage chip. I am now experimenting with a VGA card with a Cirrus Logic chip. I've got this card to accept the programmed base address and am in teh process of studying
clgenfb.cto see if I can modify it to my needs.
On first inspectionclgenfb.cis written for the Amiga??? and so I am trying to weed out the dependencies. If anyone knows of a more generic driver it would be much appreciated.
Clgenfb supports both Amiga Zorro cards with a Cirrus Logic chip and PCI cards. Note that it may depend on some chip initialisation already been done.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven ------------- Sony Software Development Center Europe (SDCE) [email protected] ------------------- Sint-Stevens-Woluwestraat 55 Voice +32-2-7248626 Fax +32-2-7262686 ---------------- B-1130 Brussels, Belgium