Build own device driver usage Externel interrupt and SPI

I use BB-XM rev C.
I want to make device driver that combine External interrupt and SPI.
It seem i have to make new kernel for my own, right?
I test it from configuration memory mapping for Mux-mode from GPIO to SPI by C code.
I can control GPIO from C code.
Anyway, I get Segmentation fault when run C code that have memory mapping with SPI register.

Does anyone know where is some guidline for build own kernel for BB-XM?

Thank in advance.

Pakorn

The code for SPI device driver could/should be the same to any board.

http://www.jumpnowtek.com/?option=com_content&view=article&id=57&Itemid=62

However, SPI platform driver code is specific: https://github.com/torvalds/linux/blob/master/drivers/spi/spi-omap2-mcspi.c