Unable to write to SIMASK
gopi at india.tejasnetworks.com
gopi at india.tejasnetworks.com
Fri Feb 22 04:34:49 EST 2002
hi..
I tried the simple code attatched with this mail:
complied using:
ppc_8xx-gcc -c -D__KERNEL__ -DMODULE -O2 -Wall myMpc.c
Then, on the target board:
> insmod myMpc.o ; rmmod myMpc
read0 = 3eed0000, read1 = 1eed0000, read2 = 1eed0000
(above was the output of printk from the driver)
> insmod myMpc.o ; rmmod myMpc
read0 = 3eed0000, read1 = 1eed0000, read2 = 1eed0000
(read0 is again 3eed0000 implying the original value is restored)
> insmod myMpc.o ; rmmod myMpc
read0 = 3eed0000, read1 = 1eed0000, read2 = 1eed0000
So, it looks like when we go out of the driver(exit from system call),
the value of simask is being restored by some code in the kernel.
I understand that this is not a good way of enabling/disabling
irqs(better use request_8xxirq etc..), but I thought this should work.
gopi
On Wed, 20 Feb 2002, Ricardo Scop wrote:
> On Wednesday 20 February 2002 21:53, gopi at india.tejasnetworks.com wrote:
> > hi..
> >
> > We have an MPC860T based custom board.
> >
> > We wanted to control interrupt on one of the irqs by writing to SIMASK
> > register using a small driver with two ioctls which will will do
> > the following:
> >
> > // WRITE_MASK_IOCTL
> > simask_write_ioctl(mask) {
> > cli();
> better use save_flags(flags); cli();
>
> > (volatile unsigned int *)(IMMR + simask_offset) = mask;
> You're missing a * operator here (don't know about your actual source code,
> though...)
That was a typing error, it was ok in code.
>
> > written_value = *(volatile unsigned int *)(IMMR + simask_offset);
> > sti();
> better use restore_flags(flags)... and flags must be defined as an unsigned
> long.
>
> > printk (written_value);
> > }
> >
> > // READ_MASK_IOCTL
> > simask_read_ioctl() {
> > cli(); // Not really needed..
> > read_value = *(volatile unsigned int *)(IMMR + simask_offset);
> > sti();
> > printk (read_value);
> > }
> >
> >
> <snip>
>
>
> HTH,
>
> R. Scop
>
-------------- next part --------------
#include <linux/config.h>
#include <linux/module.h>
#include <linux/version.h>
#include <linux/types.h>
#include <linux/sched.h>
#include <linux/kernel.h>
#include <linux/interrupt.h>
#include <asm/8xx_immap.h>
#define IMAP_ADDR ((uint)0xff000000)
int init_module(void) {
volatile immap_t *imp = (immap_t *)IMAP_ADDR;
volatile sysconf8xx_t *sysp = (sysconf8xx_t *) &(imp->im_siu_conf);
unsigned int read0, read1, read2;
unsigned long flags;
save_flags(flags); cli();
read0 = sysp->sc_simask;
sysp->sc_simask = 0x1eed0000;
read1 = sysp->sc_simask;
restore_flags(flags);
read2 = sysp->sc_simask;
printk("read0 = %x, read1 = %x, read2 = %x\n",read0, read1, read2);
return 0;
}
int cleanup_module(void) {
return 0;
}
More information about the Linuxppc-embedded
mailing list