* Q: PCI Driver ioremap
@ 2002-02-20 21:57 David Stroupe
2002-02-20 22:03 ` Jeff Garzik
2002-02-20 23:15 ` Alan Cox
0 siblings, 2 replies; 3+ messages in thread
From: David Stroupe @ 2002-02-20 21:57 UTC (permalink / raw)
To: linux-kernel
I am creating a PCI driver for a custom card and want to write 0xffff to
a location offset from the base by 0x48 and
have the following code:
<snip>
unsigned int io_addr;
unsigned int io_size;
void* base;
pci_enable_device (pdev)
io_addr = pci_resource_start(pdev, 0);
io_size = pci_resource_len(pdev, 0);
if ((pci_resource_flags(pdev, 0) & IORESOURCE_MEM)){
if(check_mem_region(io_addr, io_size))
DBG("Already In Use");//this is never reached
request_mem_region(io_addr, io_size , "Card Driver");
base=ioremap(io_addr, io_size);
if(base==0)
DBG("memory mapped wrong\n");//this is never reached
writew(0xffff, base + 0x48);
<snip>
The card is found, io_addr = 0xe9011000 and io_size = 0x200.
The write is unsuccessful or at least the data never reaches the card.
What am I doing incorrectly?
Thanks and best regards,
David
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Q: PCI Driver ioremap
2002-02-20 21:57 Q: PCI Driver ioremap David Stroupe
@ 2002-02-20 22:03 ` Jeff Garzik
2002-02-20 23:15 ` Alan Cox
1 sibling, 0 replies; 3+ messages in thread
From: Jeff Garzik @ 2002-02-20 22:03 UTC (permalink / raw)
To: David Stroupe; +Cc: linux-kernel
David Stroupe wrote:
>
> I am creating a PCI driver for a custom card and want to write 0xffff to
> a location offset from the base by 0x48 and
> have the following code:
>
> <snip>
> unsigned int io_addr;
> unsigned int io_size;
> void* base;
> pci_enable_device (pdev)
> io_addr = pci_resource_start(pdev, 0);
> io_size = pci_resource_len(pdev, 0);
> if ((pci_resource_flags(pdev, 0) & IORESOURCE_MEM)){
> if(check_mem_region(io_addr, io_size))
> DBG("Already In Use");//this is never reached
> request_mem_region(io_addr, io_size , "Card Driver");
In 2.4 and later, check request_mem_region return value, and never call
check_mem_region.
> base=ioremap(io_addr, io_size);
> if(base==0)
> DBG("memory mapped wrong\n");//this is never reached
> writew(0xffff, base + 0x48);
> <snip>
>
> The card is found, io_addr = 0xe9011000 and io_size = 0x200.
>
> The write is unsuccessful or at least the data never reaches the card.
> What am I doing incorrectly?
Looks correct to me... maybe you need to do
readw(base + 0x48)
to flush the transaction?
--
Jeff Garzik | "Why is it that attractive girls like you
Building 1024 | always seem to have a boyfriend?"
MandrakeSoft | "Because I'm a nympho that owns a brewery?"
| - BBC TV show "Coupling"
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Q: PCI Driver ioremap
2002-02-20 21:57 Q: PCI Driver ioremap David Stroupe
2002-02-20 22:03 ` Jeff Garzik
@ 2002-02-20 23:15 ` Alan Cox
1 sibling, 0 replies; 3+ messages in thread
From: Alan Cox @ 2002-02-20 23:15 UTC (permalink / raw)
To: David Stroupe; +Cc: linux-kernel
> pci_enable_device (pdev)
Should check the return but that is fine I guess
> if(base==0)
> DBG("memory mapped wrong\n");//this is never reached
> writew(0xffff, base + 0x48);
> <snip>
> The write is unsuccessful or at least the data never reaches the card.
> What am I doing incorrectly?
Looks fine to me. Obviously you should a read to make sure the write
reaches the card from PCI posting but I'd expect that to timeout and
hit the card
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-02-20 23:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-20 21:57 Q: PCI Driver ioremap David Stroupe
2002-02-20 22:03 ` Jeff Garzik
2002-02-20 23:15 ` Alan Cox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®