look you should use the IDE "Embest" has much AT91xxx example code
and it is very easy to use
and according to me. "Embest" has the best registry editor for embededd systems based on linux
this is the link
**broken link removed**
within the package ARM_exp_Atmel_LibTgt,
in the directory "periph" there is a GPIO driver called "PIO" and there you have everything you need.