Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

arch/nios2/.../gpio.h versus PIO peripheral

I am looking at the file in linux-2.6/include/nios2/include/asm/gpio.h in the source code I downloaded from the NiosWiki.

See https://www.alteraforum.com/forum/attachment.php?attachmentid=1945

It doesn't seem to match up at all with the register map shown in the PIO data sheet found here:

http://www.altera.com/literature/hb/nios2/n2cpu_nii51007.pdf

Unfortunately, the functions in gpio.h are used by the bit-banged GPIO/I2C driver and thus do not work.

Has anyone else noticed this? Is there another version of the gpio.h file?

Thanks,

Dave ...

P.S. Oddly enough, there is some other code in that same Linux release that exercises the PIO peripheral to toggle LEDs. That code matches the datasheet exactly and can be found in .../linux-2.6/include/nios2/include/asm/pio.h and pio_struct.h. It uses the following structure:


// PIO Registers
typedef volatile struct
	{
	int np_piodata;          // read/write, up to 32 bits
	int np_piodirection;     // write/readable, up to 32 bits, 1->output bit
	int np_piointerruptmask; // write/readable, up to 32 bits, 1->enable interrupt
	int np_pioedgecapture;   // read, up to 32 bits, cleared by any write
	} np_pio;

1 Reply

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I think I figured out my own problem. I had been using the PIO peripheral provided by Altera with SOPC Builder. I needed to download the Linux-specific gpio block from the ip library that is on the nioswiki. It has a completely different register map that is more amenable to bit-banging. (It uses one register to handle all the functions for each GPIO pin, not one register that handles a single function for up to 32 pins.)