[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[microblaze-uclinux] Timer (PWM) kernel module problem



Hello,
I wrote the list a while ago about writing kernel modules and I finally built one for the obp_timer. However, I am having troubles writing to the registers on this device. I am trying to use two timers to generate PWM.

Loading my module maps the device correctly:
xtmrctr #0 at 0x41C20000 mapped to 0x41C20000
xtmrctr #1 at 0x41C00000 mapped to 0x41C00000
Xilinx TIMER registered

I have written a C++ IOCTL test app to test the kernel module and it seems to be passing the values correctly.
I can verify this by following this procedure:
My Timer handler class opens the device in the constructor.
I then call a write command on this device by calling: ioctl(fd, XTIMER_WRITEREG, &ioctl_data)
XTIMER_WRITEREG is simply a define:
#define XTIMER_WRITEREG        _IOWR(XTIMER_IOCTL_BASE, 0, struct xilinx_tmrctr_ioctl_data)

The following code gets called:

XTIMER_WRITEREG:
XTmrCtr_mWriteReg(inst->save_BaseAddress, ioctl_data.intdevnum, ioctl_data.mask, ioctl_data.data);
printk("Writing Register %08X on Timer instance %d @ BaseAddress: %08X | Value = %08X\n", ioctl_data.mask, inst->index, inst->save_BaseAddress, ioctl_data.data);

XTIMER_READREG:
 ioctl_data.data = "" ioctl_data.intdevnum, ioctl_data.mask);
        printk("Reading Register %08X on Timer instance %d @ BaseAddress: %08X | Value = %08X\n", ioctl_data.mask, inst->index, inst->save_BaseAddress, ioctl_data.data);

However the output I get when I read is not the same:
Writing Register 00000000 on Timer instance 0 @ BaseAddress: 41C20000 | Value = 00000656
Reading Register 00000000 on Timer instance 0 @ BaseAddress: 41C20000 | Value = 000007D6
Writing Register 00000010 on Timer instance 0 @ BaseAddress: 41C20000 | Value = 00000656
Reading Register 00000010 on Timer instance 0 @ BaseAddress: 41C20000 | Value = 00000000

I have used the xilinx_gpio code as a guideline while writing my own code and I have made sure to modify the code provided by xilinx to use u32 instead of Xuint32.

Can anyone provide assistance as to why it is not writing 0x00000656 as it should? I have been battling this problem for weeks now and have run out of solutions.

Thanks,
Jose Torres