SPI NAND flash

I am trying to integrate sam3x8e with winbond nand flash(w25n01) using spi protocol. I got the chip id from nand flash but not able to store the values sent from controller in nand flash properly. I have attached the program below. can someone tell me where I am going wrong.

spi-nand.txt (11.6 KB)

You want to power the Nand Flash Controller (SMC_SDRAMC) before using it.