* [U-Boot-Users] Please explain this code in drivers/pci.c
@ 2003-05-18 23:39 Donald White
0 siblings, 0 replies; 4+ messages in thread
From: Donald White @ 2003-05-18 23:39 UTC (permalink / raw)
To: u-boot
Group,
Please help me to understand the following code. It occurs in drivers/pci.c in the
function pci_hose_config_device(). I have ported U-Boot 0.3.0 and HHL 2.0 to our
custom MPC8265A board. It has one device on the PCI bus. The driver develop was
wanting a specific memory space allocation for the device. So I created a PCI
configuration table with the memory base of 0x90000000. The card wants 4 regions 0f
0x8000 bytes in size. The driver writer thinks this should be 0x90000000,
0x90008000, 0x90010000 and 0x90018000. This brings us to the code snippet:
bar_size = ~(bar_response & PCI_BASE_ADDRESS_MEM_MASK) + 1;
bar_value = mem;
mem = ((mem - 1) | (bar_size - 1)) + 1;
The value of bar_response is 0xffff8008 which looks good. This gives bar size of
0x8000 which also looks good. The value of mem is initially 0x90000000. So,
(mem - 1) = 0x8fffffff and (bar_size - 1) = 0x7fff). When these are or'd one gets
0x8fffffff and adding 1 gives 0x90000000. This result is that the card is given 4
address bases all at 0x90000000.
Thanks for any help,
Don
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot-Users] Please explain this code in drivers/pci.c
@ 2003-05-19 15:19 Rune Torgersen
2003-05-20 0:47 ` Donald White
0 siblings, 1 reply; 4+ messages in thread
From: Rune Torgersen @ 2003-05-19 15:19 UTC (permalink / raw)
To: u-boot
>Subject: [U-Boot-Users] Please explain this code in drivers/pci.c
>The value of bar_response is 0xffff8008 which looks good. This gives bar
size of
>0x8000 which also looks good. The value of mem is initially 0x90000000.
So,
>(mem - 1) = 0x8fffffff and (bar_size - 1) = 0x7fff). When these are or'd
one gets
>0x8fffffff and adding 1 gives 0x90000000. This result is that the card is
given 4
>address bases all at 0x90000000.
If the card wants 4 different memory regiuons, I assume it has 4 BAR
registers? Each BAR must have the correct base address, so you have to add
the size of the last region to the memory pointer before writing the
address to the next BAR
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot-Users] Please explain this code in drivers/pci.c
2003-05-19 15:19 Rune Torgersen
@ 2003-05-20 0:47 ` Donald White
[not found] ` <3EC9CCC5.4060006@bigfoot.com>
0 siblings, 1 reply; 4+ messages in thread
From: Donald White @ 2003-05-20 0:47 UTC (permalink / raw)
To: u-boot
Rune Torgersen wrote:
>
>>Subject: [U-Boot-Users] Please explain this code in drivers/pci.c
>
>
>>The value of bar_response is 0xffff8008 which looks good. This gives bar
>
> size of
>
>>0x8000 which also looks good. The value of mem is initially 0x90000000.
>
> So,
>
>>(mem - 1) = 0x8fffffff and (bar_size - 1) = 0x7fff). When these are or'd
>
> one gets
>
>>0x8fffffff and adding 1 gives 0x90000000. This result is that the card is
>
> given 4
>
>>address bases all at 0x90000000.
>
>
>
> If the card wants 4 different memory regiuons, I assume it has 4 BAR
> registers? Each BAR must have the correct base address, so you have to add
> the size of the last region to the memory pointer before writing the
> address to the next BAR
>
>
I am not sure if you are trying to clarify the question or provide an answer. My
complaint is that the code does not do what you say. I believe the code should
provide four unique values for the four BARs, but it does not. Each gets the same
value because the ORing logic does not succeed in doing a new base = old base + size.
The logic envoked by CONFIG_PCI_PNP gets the calculation right. If someone is
familiar with the code and can confirm that it is not behaving as intended, then I
will do a patch. The ORing logic looks to me to be copied from the Linux kernel
where the allocation starts at the top of the address range and proceeds downward,
but maybe it is an attempt to force alignment. I don't know.
Don
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-05-21 3:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-18 23:39 [U-Boot-Users] Please explain this code in drivers/pci.c Donald White
-- strict thread matches above, loose matches on Subject: below --
2003-05-19 15:19 Rune Torgersen
2003-05-20 0:47 ` Donald White
[not found] ` <3EC9CCC5.4060006@bigfoot.com>
2003-05-21 3:14 ` Donald White
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox