Hi,
I am using the GPMC driver using chip select 0, It is working fine but when I am removing the module and then inserting the module once again it is failing at requesting GPMC memory for CS0.
I think there is some issue with de-initialization code.
Code for initialization and de initialization is given at bottom.
Error log:
root@(none):~# insmod uu_gpmc_drv_read_interrupt_mode9.ko
UURMI gpmc drver with IQ samples
board_fpga_init ........................
FPGA initialization
GPMC_CS_CONFIG1: 28001010
GPMC_CS_CONFIG2: 30380
GPMC_CS_CONFIG3: 20201
GPMC_CS_CONFIG4: f031003
GPMC_CS_CONFIG5: 50607
GPMC_CS_CONFIG6: 2000080
GPMC_CS_CONFIG7: c48
uu_cs0_mem_base:8000000
uu_gpmc_cs0_base:
root@(none):~# rmmod uu_gpmc_drv_read_interrupt_mode.ko
FPGA De-initialization
Module removed Successfully
root@(none):~# insmod uu_gpmc_drv_read_interrupt_mode9.ko
UURMI gpmc drver with IQ samples
board_fpga_init ........................
FPGA initialization
GPMC_CS_CONFIG1: 28001010
GPMC_CS_CONFIG2: 30380
GPMC_CS_CONFIG3: 20201
GPMC_CS_CONFIG4: f031003
GPMC_CS_CONFIG5: 50607
GPMC_CS_CONFIG6: 2000080
GPMC_CS_CONFIG7: c48
Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = cf074000
[00000000] *pgd=8f04b031, *pte=00000000, *ppte=00000000
Internal error: Oops: 17 [#1]
last sysfs file:
Modules linked in: uu_gpmc_drv_read_interrupt_mode(+) [last unloaded: uu_gpmc_drv_read_interrupt_mode]
CPU: 0 Not tainted (2.6.37+ #5)
PC is at adjust_resource+0x14/0xc4
LR is at gpmc_cs_request+0x140/0x154
pc : [<c007cbe8>] lr : [<c0059c3c>] psr: 00000013
sp : cf025e94 ip : cf025ea8 fp : cf025ea4
r10: 00000078 r9 : 00000001 r8 : c05e762c
r7 : 00000000 r6 : 01000000 r5 : c05e7604 r4 : bf019938
r3 : c05e762c r2 : 01000000 r1 : 08000000 r0 : 00000000
Flags: nzcv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
Control: 10c5387d Table: 8f074019 DAC: 00000015
Process insmod (pid: 132, stack limit = 0xcf0242e8)
Stack: (0xcf025e94 to 0xcf026000)
5e80: bf019938 cf025eec cf025ea8
5ea0: c0059c3c c007cbe0 00000000 c004a288 cf024000 00000000 cf025edc c05e762c
5ec0: c046e834 bf011430 bf019410 00000000 00000000 c004a288 cf024000 00000000
5ee0: cf025f14 cf025ef0 bf0109f4 c0059b08 c0068048 c00533fc c05e7340 c05e7340
5f00: bf011430 bf010c34 cf025f3c cf025f18 bf010c90 bf0108e4 00000000 0000001d
5f20: 0000001e c05e7340 bf01130c bf010c34 cf025f7c cf025f40 c003d52c bf010c40
5f40: 00000000 00012018 bf01130c 00000000 0001a433 00012018 bf01130c 00000000
5f60: 0001a433 c004a288 cf024000 00000000 cf025fa4 cf025f80 c00a8800 c003d3e0
5f80: cf025fa4 cf025f90 00000000 00020000 00000003 00000080 00000000 cf025fa8
5fa0: c004a0c0 c00a8754 00000000 00020000 00012018 0001a433 00012008 00000001
5fc0: 00000000 00020000 00000003 00000080 00012008 00000000 00012018 00000000
5fe0: beb46ee3 beb46c7c 00008da0 401a97d4 60000010 00012018 aaaaaaaa aaaaaaaa
Backtrace:
[<c007cbd4>] (adjust_resource+0x0/0xc4) from [<c0059c3c>] (gpmc_cs_request+0x140/0x154)
r4:bf019938
[<c0059afc>] (gpmc_cs_request+0x0/0x154) from [<bf0109f4>] (uu_init_gpmc_fpga_hw_init+0x11c/0x35c [uu_gpmc_drv_read_interrupt_mode])
[<bf0108d8>] (uu_init_gpmc_fpga_hw_init+0x0/0x35c [uu_gpmc_drv_read_interrupt_mode]) from [<bf010c90>] (init_module+0x5c/0x154 [uu_gpmc_drv_read_interrupt_mode])
r6:bf010c34 r5:bf011430 r4:c05e7340
[<bf010c34>] (init_module+0x0/0x154 [uu_gpmc_drv_read_interrupt_mode]) from [<c003d52c>] (do_one_initcall+0x158/0x1b0)
r6:bf010c34 r5:bf01130c r4:c05e7340
[<c003d3d4>] (do_one_initcall+0x0/0x1b0) from [<c00a8800>] (sys_init_module+0xb8/0x1c8)
[<c00a8748>] (sys_init_module+0x0/0x1c8) from [<c004a0c0>] (ret_fast_syscall+0x0/0x30)
r7:00000080 r6:00000003 r5:00020000 r4:00000000
Code: e92dd810 e24cb004 e1a03000 e5900010 (e590c000)
---[ end trace 10b924f980820d34 ]---
Segmentation fault
root@(none):~#
Initialization and UN-initialization of the GPMC driver.
int uu_init_gpmc_fpga_hw_init(void )
{
unsigned int ret=-1,read_val=-1;//tx_irq=0,rx_irq=0;
gpmc_write_reg(GPMC_SYSCONFIG, 0x0);
gpmc_write_reg(GPMC_CONFIG, 0x0);
//sychronous,16bit,NOR,no multiplexed,GPMC_CLK==GPMC_FCLK
gpmc_cs_write_reg(0, GPMC_CS_CONFIG1,0x28001010); // 0x28001010
read_val= gpmc_cs_read_reg(0, GPMC_CS_CONFIG1);
printk("GPMC_CS_CONFIG1: %x\n\r",read_val);
read_val=0;
gpmc_cs_write_reg(0, GPMC_CS_CONFIG2,0x00030380); // 0x00101080 *
read_val= gpmc_cs_read_reg(0, GPMC_CS_CONFIG2);
printk("GPMC_CS_CONFIG2: %x\n\r",read_val);
read_val=0;
gpmc_cs_write_reg(0, GPMC_CS_CONFIG3,0x00020201); // 0x00020201
read_val= gpmc_cs_read_reg(0, GPMC_CS_CONFIG3);
printk("GPMC_CS_CONFIG3: %x\n\r",read_val);
read_val=0;
gpmc_cs_write_reg(0, GPMC_CS_CONFIG4,0x0f031003); // 0x0f031003
read_val= gpmc_cs_read_reg(0, GPMC_CS_CONFIG4);
printk("GPMC_CS_CONFIG4: %x\n\r",read_val);
read_val=0;
gpmc_cs_write_reg(0, GPMC_CS_CONFIG5,0x00050607); // 0x000F1011
read_val= gpmc_cs_read_reg(0, GPMC_CS_CONFIG5);
printk("GPMC_CS_CONFIG5: %x\n\r",read_val);
read_val=0;
gpmc_cs_write_reg(0, GPMC_CS_CONFIG6,0x02000080); // 0x0F000080
read_val= gpmc_cs_read_reg(0, GPMC_CS_CONFIG6);
printk("GPMC_CS_CONFIG6: %x\n\r",read_val);
read_val=0;
gpmc_cs_write_reg(0, GPMC_CS_CONFIG7,0x00000C48); // 0x00000C48
read_val= gpmc_cs_read_reg(0, GPMC_CS_CONFIG7);
printk("GPMC_CS_CONFIG7: %x\n\r",read_val);
read_val=0;
if (gpmc_cs_request(0, SZ_16M, &uu_cs0_mem_base) < 0)
{
printk("<1>Failed to request GPMC mem for cs0\n");
return -1;
}
printk("<1>uu_cs0_mem_base:%x\n",uu_cs0_mem_base);
uu_gpmc_cs0_base=ioremap(uu_cs0_mem_base,SZ_16M);
if(uu_gpmc_cs0_base!=0)
{
printk("<1>uu_gpmc_cs0_base:");
}
out:
return ret;
}
int init_gpmc_fpga_device(void)
{
unsigned int l=0;
printk(KERN_INFO"board_fpga_init ........................\n\r");
printk("FPGA initialization\n");
l = TI8148_GPMC_BASE;
uu_gpmc_base = ioremap(l, SZ_4K);
if (uu_gpmc_base == NULL)
{
printk("gpmc-fpga: Memory allocation failed\n");
goto out;
}
uu_init_gpmc_fpga_hw_init();
uu_init_device_node();
out:
return 0;
}
void exit_gpmc_fpga_device(void)
{
printk("FPGA De-initialization\n");
gpmc_cs_free(0);
iounmap(uu_gpmc_base);
device_destroy(uu_fpga_class, MKDEV(UU_FPGA_MAJOR, 0));
class_destroy(uu_fpga_class);
unregister_chrdev(UU_FPGA_MAJOR, UU_FPGADEVNAME);
if(tx_irq > 0)
free_irq(tx_irq, NULL);
if(rx_irq > 0)
free_irq(rx_irq, NULL);
printk("\n Module removed Successfully\n");
}
module_init(init_gpmc_fpga_device);
module_exit(exit_gpmc_fpga_device);
Please help to resolve
Thanks,
Sudheer.