本帖最后由 suseng777 于 2010-11-10 23:58 编辑
看了海天雄开发板下tvscaler的驱动源码,ioremap后,base为映射后的虚拟地址,寄存器的物理地址0x76300000,base为0xC9400000,紧接着对tvscaler的寄存器无法读写
static int s3c_tvscaler_probe(struct platform_device *pdev)
{
struct resource *res;
int ret;
/* find the IRQs */
s3c_tvscaler_irq = platform_get_irq(pdev, 0);
if(s3c_tvscaler_irq <= 0) {
printk(KERN_ERR PFX "failed to get irq resouce\n");
return -ENOENT;
}
/* get the memory region for the tv scaler driver */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if(res == NULL) {
printk(KERN_ERR PFX "failed to get memory region resouce\n");
return -ENOENT;
}
s3c_tvscaler_mem = request_mem_region(res->start, res->end-res->start+1, pdev->name);
if(s3c_tvscaler_mem == NULL) {
printk(KERN_ERR PFX "failed to reserve memory region\n");
return -ENOENT;
}
base = ioremap(s3c_tvscaler_mem->start, s3c_tvscaler_mem->end - res->start + 1);
printk("tvscaler : base, res->start, res->end:=%08x %08x %08x\n", base, res->start, res->end);
printk("base-reg : 0x%08x\n", __raw_readl(base)); //先读出来映射的寄存器值全为0
__raw_writel(0x00070B12, base); //写入0x00070B12到base映射的寄存器中
printk("base-reg : 0x%08x\n", __raw_readl(base)); //再次读出,还是全为0
printk("tvscaler : base, res->start, res->end:=%08x %08x %08x\n", base, res->start, res->end);
if(s3c_tvscaler_mem == NULL) {
printk(KERN_ERR PFX "failed ioremap\n");
return -ENOENT;
}
tvscaler_clock = clk_get(&pdev->dev, "tv_encoder");
if(tvscaler_clock == NULL) {
printk(KERN_ERR PFX "failed to find tvscaler clock source\n");
return -ENOENT;
}
clk_enable(tvscaler_clock);
h_clk = clk_get(&pdev->dev, "hclk");
if(h_clk == NULL) {
printk(KERN_ERR PFX "failed to find h_clk clock source\n");
return -ENOENT;
}
init_waitqueue_head(&waitq);
ret = request_irq(s3c_tvscaler_irq, s3c_tvscaler_isr, IRQF_DISABLED,
"TV_SCALER", NULL);
if (ret) {
printk("request_irq(TV_SCALER) failed.\n");
return ret;
}
return 0;
}
以下是板子开机启动的部分信息,寄存器的物理地址0x76300000,可以看到映射的虚拟地址是0xC9400000,不明白为何无法对映射后的tvscaler寄存器读写,
哪位高手能指点一下吗?
另外,tvencoder驱动部分是可以读写的,读出来的是默认值。
eth%d: con201 Invalid ethernet MAC address. using default config, Please set using ifconfig
eth0: dm9000 at f7200300,f7200304 IRQ 111 MAC: 00:e0:4a:bc:15:e8
Linux video capture interface: v2.00
s3c-fimc: controller 0 registered successfully
s3c-fimc: controller 1 registered successfully
S3C6400 MFC Driver, (c) 2007 Samsung Electronics
S3C6400 MFC Driver, (c) 2007 Samsung Electronics
S3C PostProcessor Driver v3.12, (c) 2009 Samsung Electronics
S3C6410 TV encoder Driver, (c) 2008 Samsung Electronics
tvencoder:base,res->start,res->end:=c9200000 76200000 762fffff
base-reg : 0x00010000
base-reg : 0x00010100
S3C6410 TV encoder Driver init OK.
S3C6410 TV scaler Driver, (c) 2008 Samsung Electronics
tvscaler : base, res->start, res->end:=c9400000 76300000 763fffff
base-reg : 0x00000000 //读出来全是0,base对应的寄存器MOD的初始值0x00070B12的
base-reg : 0x00000000 //尝试写入0x00070B12到base映射的寄存器再次读出还是为0
tvscaler : base, res->start, res->end:=c9400000 76300000 763fffff
S3C6410 TV scaler Driver init OK.
S3C JPEG Driver, (c) 2007 Samsung Electronics
s3c_g2d_probe called
s3c_g2d_probe Success
S3C G2D Init : Done
S3C G3D Driver, (c) 2007-2009 Samsung Electronics
s3c_g3d version : 0x1050000
G3D_RESERVED_MEM_SIZE : 16 MB
G3D_CHUNK_SIZE : 2 MB
G3D_CHUNK_NUM : 8
0 th virt_addr = 0xc7800000, phy_addr = 0x57800000
1 th virt_addr = 0xc7a00000, phy_addr = 0x57a00000
2 th virt_addr = 0xc7c00000, phy_addr = 0x57c00000
3 th virt_addr = 0xc7e00000, phy_addr = 0x57e00000
4 th virt_addr = 0xc6000000, phy_addr = 0x56000000
5 th virt_addr = 0xc6200000, phy_addr = 0x56200000
6 th virt_addr = 0xc6400000, phy_addr = 0x56400000
7 th virt_addr = 0xc6600000, phy_addr = 0x56600000
Driver 'sd' needs updating - please use bus_type methods
S3C NAND Driver, (c) 2008 Samsung Electronics
S3C NAND Driver is using hardware ECC.
NAND device: Manufacturer ID: 0xec, Chip ID: 0xd3 (Samsung NAND 1GiB 3,3V 8-bit)
Creating 4 MTD partitions on "NAND 1GiB 3,3V 8-bit":
0x00000000-0x00080000 : "Bootloader"
0x00080000-0x00400000 : "Kernel"
0x00400000-0x03400000 : "Rootfs"
0x03400000-0x40000000 : "File System"
|