Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: AT91SAM9260-EK Question Application
PostPosted: Mon Jul 09, 2007 10:57 am 
Offline

Joined: Thu Apr 05, 2007 11:49 am
Posts: 11
Location: Korea
working kernel version - 2.6.20 patched at91
board - at91sam9260-ek

I'm going to develop the linux application which use the master mode SPI in at91sam9260. The kernel supply the SPI driver.(atmel_spi.c) :oops: But I don't know to use this driver in linux. Can I receive the sample application to use the SPI device driver?


Top
 Profile  
 
 Post subject: SPI Application
PostPosted: Wed Jul 11, 2007 5:46 am 
Offline

Joined: Thu Apr 05, 2007 11:49 am
Posts: 11
Location: Korea
I'm novice for Linux. former times, I develped the WinCE product.
And Linux program isn't a familiar job to me.

I found the 'spi-summary document in linux/Documentation/spi folder. Atfer I read this, I guess taht the atmel_spi.c is related the controller driver. And spi.c is Protocol drivers. Is it right?

I guess that the code modify the ek_spi_device structure in board-9260ek.c to customize SPI driver for my project.

But, as before, I don't know how to using the SPI driver in application.

I find the below code in drivers/char/at91_spidev.c

static struct file_operations spidev_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.read = spidev_rd_wr,
.write = (int (*) (struct file *file, const char *buf, size_t count, loff_t *offset))spidev_rd_wr,
.ioctl = spidev_ioctl,
.open = spidev_open,
.release = spidev_close,
};


So, If I write a below code in application, is it right?

file = open("/dev/module name", attribute);
open(file, ~);

I'm sorry for poor english.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 11, 2007 11:39 pm 
Offline

Joined: Thu Apr 19, 2007 10:15 pm
Posts: 204
Location: USA
Hi there

The SPI is a bridge device that connects other devices to the processor/system bus. There should be no need to access the SPI from an application. Device drivers would use the SPI, since I/O should be done in kernel space.

Dataflash is the only device on the at91sam920ek connected to SPI. Try taking a look at drivers/mtd/devices/at91_dataflash.c.

What device are you going to connect to SPI?

Regards


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 12, 2007 3:44 am 
Offline

Joined: Thu Apr 05, 2007 11:49 am
Posts: 11
Location: Korea
Thanks for your reply.

In my project, The system comprises two block. One is the main which use the AT91SAM9260, other is the sub block which use the atmel2560. And sub block is four board. Each board has the one atmel 2560.

i.e One AT91SAM9260 has to communicate four atmel2560 by SPI.

And I think to modify below code. (modalias, chip_select, bus_num)
I am planning to use the SPI1 to connect the slaves.

static struct spi_board_info ek_spi_devices[] = {
//#if !defined(CONFIG_MMC_AT91)
{ /* DataFlash chip */
.modalias = "mtd_dataflash",
.chip_select = 1,
.max_speed_hz = 15 * 1000 * 1000,
.bus_num = 0,
},
//#if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)
{ /* DataFlash card */
.modalias = "mtd_dataflash",
.chip_select = 0,
.max_speed_hz = 15 * 1000 * 1000,
.bus_num = 0,
},
//#endif
//#endif
//#if defined(CONFIG_SND_AT73C213) || defined
//(CONFIG_SND_AT73C213_MODULE)
{ /* AT73C213 DAC */
.modalias = "at73c213",
.chip_select = 0,
.max_speed_hz = 10 * 1000 * 1000,
.bus_num = 1,
},
//#endif

As like above mentioned, I don't know how to program the application in user mode. (and now reading "Beginning Linux Programming 2nd" printed by WROX - chapter 3. ). ask advice of a application.

I'm very happy for appending reply.


Last edited by Kang sang woo on Thu Jul 12, 2007 4:50 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 12, 2007 6:06 am 
Offline

Joined: Thu Apr 19, 2007 10:15 pm
Posts: 204
Location: USA
Hi there

Okay, so you're going to use SPI as an interprocessor communications link.

Unless I'm missing something, fooling around with the existing atmel_spi.c driver is not reasonable. And as currently written, it's not a user accessible device; it has no major/minor numbers and it's not in /dev. So you cannot open, read or write it from an application program.

From the application point-of-view, you want to be able to access the slave processors. So create "devices" for each connected slave. The pseudo-device driver for each slave processor would resemble a combination of the dataflash and a com port. This driver would perform the actual SPI requests using atmel_spi.c just like the at91_dataflash.c driver does. But this driver would have major/minor numbers and open/read/write/ioctl/close operations.

Your application would open each slave device, and perform reads and writes to the slave device. The application should deal with the logical end of the SPI link. Let the device drivers handle all the intermediate SPI handshaking.

Just my $.02.

Regards


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 12, 2007 8:10 am 
Offline

Joined: Thu Apr 05, 2007 11:49 am
Posts: 11
Location: Korea
hum...I understand what you means. Suddenly, I felt this job very difficult.

Again, Thanks for your replying


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 16, 2007 11:46 am 
Offline

Joined: Thu Apr 05, 2007 11:49 am
Posts: 11
Location: Korea
I know that kernel 2.6.22 support spi character device driver. That is spidev.c file. (this file omitted the kernel 2.6.20)

The sample code and description is supplied in spidev kernel documentation.

I'm received the above information from Atmel.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 28 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: