Re: Cannot access PCI device

Jeff Garzik (jgarzik@mandrakesoft.com)
Thu, 12 Jul 2001 10:07:59 -0400


Zehetbauer Thomas wrote:
>
> Hi! I am trying to access a custom PCI device on a Walnut Rev. D system
> running Hard Hat Linux Rev. 1.2 with Montavista kernel snapshot
> 01.04.12. The following code is beeing executed in the probe function of
> a kernel module and works well on Linux 2.4.2/Intel but returns useless
> values on PowerPC.
>
> ### begin code ###
> unsigned long linux_addr_start, linux_addr_end, val;
> u32 config_addr;
>
> pdev = pci_find_device(0x10ee, 0x4030, pdev);
> if (NULL == pdev)
> return(-1);

use pci_register_driver or pci_module_init not pci_find_device

> if (pci_enable_device(pdev))
> return(-1);
> linux_addr_start = pci_resource_start(pdev, 0);
> linux_addr_end = pci_resource_end(pdev, 0);
> pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &config_addr);
> printk("Found %s\n", pdev->name);
> printk("pci_resource_start=%lx\n", linux_addr_start);
> printk("pci_resource_end=%lx\n", linux_addr_end);
> printk("PCI_BASE_ADDRESS_0=%lx\n", config_addr);
> IOAddress = ioremap(config_addr, 0xffff);

bug: calling ioremap with config_addr value directly from PCI BAR
register. You should mask the value. However, it is irrelevant:
linux_addr_start make config_addr unnecessary.

-- 
Jeff Garzik      | A recent study has shown that too much soup
Building 1024    | can cause malaise in laboratory mice.
MandrakeSoft     |
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/