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  [ 2 posts ] 
Author Message
 Post subject: how to use "GPIO-based bitbanging spi master"?
PostPosted: Fri Feb 17, 2012 10:37 am 
Offline

Joined: Fri Feb 17, 2012 9:14 am
Posts: 1
I configure kernel 2.6.30 as below: make menuconfig [Device Drivers -> SPI support]
Code:
          --- SPI support                           
                *** SPI Master Controller Drivers ***
          < >   Atmel SPI Controller                 
          -*-   Utilities for Bitbanging SPI masters
          <*>   GPIO-based bitbanging SPI Master     
                *** SPI Protocol Masters ***         
          < >   User mode SPI device driver support 
          < >   Infineon TLE62X0 (for power switching)


then add something to /arch/arm/mach-at91/board-sam9260ek.c
Code:
.....
static struct spi_board_info ek_spi_gpio_devices[] = {
   {   /* ATT7022 */
      .modalias   = "acsample",
      .chip_select   = 0,
      .max_speed_hz   = 15 * 1000 * 1000,
      .mode      = SPI_MODE_0,
      .controller_data = (void*) AT91_PIN_PB27,
   },

};

......

extern void __init at91_add_device_spi_gpio(struct spi_board_info *devices, int nr_devices);

static void __init ek_board_init(void)
{

    .....
    //at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
    at91_add_device_spi_gpio( ek_spi_gpio_devices, ARRAY_SIZE(ek_spi_gpio_devices) );
    .....
}


add code to /arch/arm/mach-at91/at91sam9260_devices.c
Code:
.....
static struct spi_gpio_platform_data pacsdata = {
   .sck      = AT91_PIN_PB23,
   .mosi      = AT91_PIN_PB26,
   .miso      = AT91_PIN_PB22,
   .num_chipselect = 1,
};

static struct platform_device at91sam9260_acsample_device = {
   .name         = "spi_gpio",
   .id         = 0,
   .dev.platform_data   = &pacsdata,
};

void __init at91_add_device_spi_gpio(struct spi_board_info *devices, int nr_devices)
{
   unsigned long cs_pin;
   int ret;
   
   at91_sys_write( AT91_PMC_PCER, (1<<AT91SAM9260_ID_PIOB) );
   
   at91_set_GPIO_periph(AT91_PIN_PB23, 1);      /* SCK */
   at91_set_multi_drive(AT91_PIN_PB23, 1);

   at91_set_GPIO_periph(AT91_PIN_PB26, 1);      /* MOSI */
   at91_set_multi_drive(AT91_PIN_PB26, 1);

   at91_set_GPIO_periph(AT91_PIN_PB22, 1);      /* MISO */
   at91_set_multi_drive(AT91_PIN_PB22, 1);
   
   at91_set_GPIO_periph(AT91_PIN_PB27, 1);      /* CS */
   at91_set_multi_drive(AT91_PIN_PB27, 1);

   ret = spi_register_board_info(devices, nr_devices);
   ret = platform_device_register(&at91sam9260_acsample_device);
}
.........


then "make uImage", and boot it.

I can found file "spi_gpio.0" in "/sys/devices/platform/", but found nothing about spi device in "/dev".

I want to use the bitbanging spi master device to read/write ATT7022, Can anyone give me some advices or examples? I am a linux newer.
Code:
/ # cat /sys/devices/platform/spi_gpio.0/spi0.0/modalias
acsample


Top
 Profile  
 
 Post subject: Re: how to use "GPIO-based bitbanging spi master"?
PostPosted: Mon Mar 05, 2012 12:29 am 
Offline

Joined: Thu Apr 19, 2007 10:15 pm
Posts: 330
Location: USA
lightrain wrote:
I can found file "spi_gpio.0" in "/sys/devices/platform/", but found nothing about spi device in "/dev".

I want to use the bitbanging spi master device to read/write ATT7022, Can anyone give me some advices or examples?


You won't find a "spi" device in /dev, because the SPI is not a device node; SPI is an interface path to a target device. Your target device apparently is an ATT7022 (whatever that is).

You need to write a SPI target device driver for your ATT7022. That driver will utilize the (bit-banging) SPI master driver to access and control the ATT7022. There are several SPI target devices in the Linux source tree to use as examples.

Regards


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

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 2 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: