Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
urefriendforever
PostPosted: May 21, 2008 - 09:37 AM
Wannabe


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
 
 View user's profile Send private message  
Reply with quote Back to top
hardy_hard
PostPosted: May 21, 2008 - 11:51 AM
Hangaround


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
 
 View user's profile Send private message  
Reply with quote Back to top
urefriendforever
PostPosted: May 22, 2008 - 09:29 AM
Wannabe


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..
 
 View user's profile Send private message  
Reply with quote Back to top
squidgit
PostPosted: May 22, 2008 - 10:38 AM
Raving lunatic


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
 
 View user's profile Send private message  
Reply with quote Back to top
urefriendforever
PostPosted: May 22, 2008 - 12:08 PM
Wannabe


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?
 
 View user's profile Send private message  
Reply with quote Back to top
urefriendforever
PostPosted: May 22, 2008 - 03:31 PM
Wannabe


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.
 
 View user's profile Send private message  
Reply with quote Back to top
eaanon01
PostPosted: May 22, 2008 - 03:59 PM
Posting Freak


Joined: Aug 22, 2002
Posts: 1482
Location: Arendal Norway

Have you compiled spidev in the kernel or as a module?
 
 View user's profile Send private message  
Reply with quote Back to top
urefriendforever
PostPosted: May 22, 2008 - 06:45 PM
Wannabe


Joined: Mar 21, 2008
Posts: 57


as a kernel..i have the spidev.o
 
 View user's profile Send private message  
Reply with quote Back to top
eaanon01
PostPosted: May 23, 2008 - 07:39 AM
Posting Freak


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?
 
 View user's profile Send private message  
Reply with quote Back to top
urefriendforever
PostPosted: May 23, 2008 - 08:15 AM
Wannabe


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
 
 View user's profile Send private message  
Reply with quote Back to top
eaanon01
PostPosted: May 23, 2008 - 08:20 AM
Posting Freak


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));
 
 View user's profile Send private message  
Reply with quote Back to top
urefriendforever
PostPosted: May 24, 2008 - 08:03 AM
Wannabe


Joined: Mar 21, 2008
Posts: 57


yes very much
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits