linux-mips
[Top] [All Lists]

Re: Can't read from mmaped PCI memory space

To: Wolfgang Grandegger <wg@grandegger.com>
Subject: Re: Can't read from mmaped PCI memory space
From: "tiejun.chen" <tiejun.chen@windriver.com>
Date: Mon, 29 Nov 2010 18:24:29 +0800
Cc: Linux-MIPS <linux-mips@linux-mips.org>
In-reply-to: <4CF2C7B1.5030007@grandegger.com>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <4CF2C7B1.5030007@grandegger.com>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Thunderbird 2.0.0.24 (X11/20101027)
Wolfgang Grandegger wrote:
> Hello,
> 
> I'm trying to read from mmapped PCI memory space on an alchemy board,
> but I can't get it to work. Here's the lspci output of the PCI card:
> 
>   bash-3.00# lspci -v
>   00:00.0 Class 0200: 168c:001b (rev 01)
>       Subsystem: 168c:2063
>       Flags: bus master, medium devsel, latency 168, IRQ 9
>       Memory at 0000000040000000 (32-bit, non-prefetchable) [size=64K]
>       Capabilities: [44] Power Management version 2
> 
> I used mmap on "/dev/mem" and "/sys/bus/pci/.../resource0", but I do not
> read the expected values using "*(volatile u32 *)mmap_addr" from that
> region. The value also changes from read to read. Reading from kernel
> space just work fine. Am I doing something illegal? Any idea why it does
> not work?

Form here I'm not sure how you did exactly.

Theoretically, you can mmap() directly that at least from the sys resource. But
I think you have to notice the aligning requirement for a page. I means you
should firstly map one given base_address & ~(PAGE_SIZE - 1). Then access the
last destination address with adding the corresponding offset as you want.

Hope its useful.

Tiejun

> 
> TIA,
> 
> Wolfgang.
> 
> 


<Prev in Thread] Current Thread [Next in Thread>