| Author |
Message |
|
|
Posted: May 21, 2008 - 09:37 AM |
|

Joined: Mar 21, 2008
Posts: 57
|
|
Hi,
I would like to interface a transceiver chip to the ATNGW board, it uses a SPI interface.
I would like to know how to start off building application to use the SPI (via linux).
Pls guide as to where i can find information about the pre configured SPI driver in the linux ported on the ATNGW and anything else that is needed to start with this exercise.
--NK |
|
|
| |
|
|
|
|
|
Posted: May 21, 2008 - 11:51 AM |
|

Joined: Jul 20, 2007
Posts: 130
Location: Germany
|
|
If you want to do things in userspace, I suggest using the spi-dev driver.
At first, you need to modify the Kernel adding "Device drivers" -> "SPI support" -> "User mode SPI device driver support" in menuconfig. You also need to add an SPI device in the arch/avr32/boards/atngw100/setup.c.
Example:
Code:
static struct spi_board_info spi0_board_info[] __initdata = {
{
.modalias = "mtd_dataflash",
.max_speed_hz = 8000000,
.chip_select = 0,
},{
.modalias = "spidev", /* custom dev */
.max_speed_hz = 8000000,
.chip_select = 1,
},{
.modalias = "spidev", /* another dev */
.max_speed_hz = 8000000,
.chip_select = 2,
},
};
Recompile the Kernel. When this is done, you should see the filedescriptor /dev/spi0.1 or similar.
Read Documentation/spi/spidev for more information and an example.
Regards
hardy |
|
|
| |
|
|
|
|
|
Posted: May 22, 2008 - 09:29 AM |
|

Joined: Mar 21, 2008
Posts: 57
|
|
Well i added a part of what you have mentioned to the setup.c
what i added was
{
.modalias = "spidev", /* custom dev */
.max_speed_hz = 10000000,
.chip_select = 1,
},
then i recompiled the kernel, copied the uImage file from avr32/boot/images to my TFTP folder that i have shared for booting the kernel via network...
Everything goes well, the system takes the uImage and the file system over tftp and nfs...
When i check /dev i do not see any spi0.1 or anything remotely close to it..
i have used the atngw100_defconfig as my configuration file?
Can someone pls throw light to why this is happenning.. |
|
|
| |
|
|
|
|
|
Posted: May 22, 2008 - 10:38 AM |
|


Joined: Sep 14, 2003
Posts: 4209
Location: Queanbeyan, Australia
|
|
Where're you getting your original root filesystem from? You must use a quite new (i.e. buildroot generated) filesystem which includes scripts to initialize mdev. Without mdev nothing will care about the "new device created" message and use it to create the actual device node.
If that isn't the problem, "cat /proc/devices" and check that there's a spidev major assigned. Check the output of dmesg; you should see a device registered on the chip select.
-S. |
_________________ Blag: http://www.niasdigital.com/blag
|
| |
|
|
|
|
|
Posted: May 22, 2008 - 12:08 PM |
|

Joined: Mar 21, 2008
Posts: 57
|
|
I have the file system downloaded from the atmel.no website (downloaded very recently), i dont see anything in /proc/devices there is no spidev..
can you tell me the name of the script where the mdev is initialized? |
|
|
| |
|
|
|
|
|
Posted: May 22, 2008 - 03:31 PM |
|

Joined: Mar 21, 2008
Posts: 57
|
|
i can see spi0.1 in /sys/class/spi_master/spi0/device
but i dont see any spi devices in /dev
but i see a whole list of others like ttyS0, console, null and some mtdXXXX
does it mean that mdev is running? which script is supposed to have mdev command. |
|
|
| |
|
|
|
|
|
Posted: May 22, 2008 - 03:59 PM |
|


Joined: Aug 22, 2002
Posts: 1482
Location: Arendal Norway
|
|
| Have you compiled spidev in the kernel or as a module? |
|
|
| |
|
|
|
|
|
Posted: May 22, 2008 - 06:45 PM |
|

Joined: Mar 21, 2008
Posts: 57
|
|
| as a kernel..i have the spidev.o |
|
|
| |
|
|
|
|
|
Posted: May 23, 2008 - 07:39 AM |
|


Joined: Aug 22, 2002
Posts: 1482
Location: Arendal Norway
|
|
|
urefriendforever wrote:
as a kernel..i have the spidev.o
Do you have spidev0.1 under /dev/ or do you mean something else? |
|
|
| |
|
|
|
|
|
Posted: May 23, 2008 - 08:15 AM |
|

Joined: Mar 21, 2008
Posts: 57
|
|
| i dont have any spidev0.1 under /dev what i meant was after the compiling the kernel in the source directory i have the spidev.o |
|
|
| |
|
|
|
|
|
Posted: May 23, 2008 - 08:20 AM |
|


Joined: Aug 22, 2002
Posts: 1482
Location: Arendal Norway
|
|
And you still have this code lini in your board init code?
Code:
at32_add_device_spi(0, spi0_board_info, ARRAY_SIZE(spi0_board_info));
|
|
|
| |
|
|
|
|
|
Posted: May 24, 2008 - 08:03 AM |
|

Joined: Mar 21, 2008
Posts: 57
|
|
|
|
|
|
|