lkml.org 
[lkml]   [1998]   [Mar]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: PCI Driver for NIC, base address problem!!
Date
From
Here is an example that maps a BAR. Note that the handling of offsets
is necessary because some smarter BIOSes may map memory to places
within a page.

pcibios_read_config_dword(bus, dfn, PCI_BASE_ADDRESS_0, &dw);

{ unsigned long base = dw & PAGE_MASK;
unsigned long off = dw & (~0xf & (PAGE_SIZE-1));
xsp->amcc0 = off + (unsigned long)ioremap(base, AMCC_SIZE+off);
}
if (debug_flag&DBG_VERBIAGE)
printk("sinj%u: BAR[0] = 0x%08x [%p]\n", xsp->dev_num,
dw, xsp->amcc0);


Note that there is a #define ioremap vremap up higher. Also note that
I use readl and writel to access memory mapped registers. This is the
most portable way to do it, and looks neater then a bunch of casts.

I can provide the source to the entire driver if anyone is interested
(it is for a scanner simulator board we built) and I have other drivers
buried in uCR packages in:

ftp://ftp.picturel.com/pub/source/ucr/ucr-1.0.tar.gz

--
Steve Williams "The woods are lovely, dark and deep.
steve@icarus.com But I have promises to keep,
steve@picturel.com and lines to code before I sleep,
http://www.picturel.com And lines to code before I sleep."



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu

\
 
 \ /
  Last update: 2005-03-22 13:41    [W:0.069 / U:0.096 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site