Unable to write to SIMASK

2002-02-21 Thread [EMAIL PROTECTED]
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 = 3eed, read1 = 1eed, read2 = 1eed
(above was the output of printk from the driver)

> insmod myMpc.o ; rmmod myMpc
read0 = 3eed, read1 = 1eed, read2 = 1eed
(read0 is again 3eed implying the original value is restored)

> insmod myMpc.o ; rmmod myMpc
read0 = 3eed, read1 = 1eed, read2 = 1eed

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);
> >   }
> >
> >
> 
>
>
> HTH,
>
> R. Scop
>

-- next part --
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#define IMAP_ADDR  ((uint)0xff00)

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 = 0x1eed;
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;
}


Unable to write to SIMASK

2002-02-21 Thread [EMAIL PROTECTED]

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();
(volatile unsigned int *)(IMMR + simask_offset) = mask;
written_value = *(volatile unsigned int *)(IMMR + simask_offset);
sti();
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);
  }


  When we make the ioctl calls from user space the value of the mask
seems to be getting changed during the driver time, but is reverted
back to its original value when we try to read it again.

Following is the sequence of events:

  ioctl(fd, READ_MASK_IOCTL) = 0x3edd
  ioctl(fd, WRITE_MASK_IOCTL, 0x1edd)
here printk of the driver prints 0x1edd, so it looks like
the value is written
  ioctl(fd, READ_MASK_IOCTL) = 0x3edd
=> somebody is reverting it back.

Any clue as to why this is happening?

thanx in advance
gopi

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/





Unable to write to SIMASK

2002-02-20 Thread Ricardo Scop

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...)

> 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);
>   }
>
>



HTH,

R. Scop


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/