Hi, Can anybody help me out in writing spi driver for 4 slaves and also please help me out with a sample program how to use it in user application to make that particular device to get selected. I have written the driver as such : static struct spi_board_info __initdata mini2440_spi_board_info[] = { // SPI Port 0 { .modalias = "spidev", .max_speed_hz = 48000000, //48 Mbps .bus_num = 0, .chip_select = 0, .mode = SPI_MODE_1, }, } static void mini2440_spi0_cs(struct s3c2410_spi_info *spi, int cs, int pol) { s3c2410_gpio_setpin(S3C2410_GPG(2),pol); s3c2410_gpio_setpin(S3C2410_GPE(14),pol); s3c2410_gpio_setpin(S3C2410_GPE(15),pol); s3c2410_gpio_setpin(S3C2410_GPB(1),pol); s3c2410_gpio_setpin(S3C2410_GPH(9),pol); } static struct s3c2410_spi_info mini2440_spi0_platdata = { .num_cs = 1,//1 .bus_num = 0, .set_cs = mini2440_spi0_cs, }; static void __init mini2440_machine_init(void) { #if defined (LCD_WIDTH) s3c24xx_fb_set_platdata(&mini2440_fb_info); #endif s3c_i2c0_set_platdata(NULL); /* setup SPI0 pins */ s3c2410_gpio_cfgpin(S3C2410_GPE(11), S3C2410_GPE11_SPIMISO0); s3c2410_gpio_cfgpin(S3C2410_GPE(12), S3C2410_GPE12_SPIMOSI0); s3c2410_gpio_cfgpin(S3C2410_GPE(13), S3C2410_GPE13_SPICLK0); s3c2410_gpio_cfgpin(S3C2410_GPG(2), S3C2410_GPIO_OUTPUT); s3c2410_gpio_cfgpin(S3C2410_GPE(14), S3C2410_GPIO_OUTPUT); s3c2410_gpio_cfgpin(S3C2410_GPE(15), S3C2410_GPIO_OUTPUT); s3c2410_gpio_cfgpin(S3C2410_GPB(1), S3C2410_GPIO_OUTPUT); s3c2410_gpio_cfgpin(S3C2410_GPH(9), S3C2410_GPIO_OUTPUT); s3c_device_spi0.dev.platform_data = &mini2440_spi0_platdata; spi_register_board_info(mini2440_spi_board_info, ARRAY_SIZE(mini2440_spi_board_info)); printk(KERN_ERR "Setup SPI0\n"); .................................................................. ......................... } But my driver is reading only one slave device !!:-(
how to write the spi driver in mini2440 for 4 devices
The purpose of the mini2440_spi0_cs() is different then you implement it. It should look like: static void mini2440_spi0_cs(struct s3c2410_spi_info *spi, int cs, int pol) { int gpio; switch (cs) { case 0: gpio = S3C2410_GPG(2; break; case 1: gpio = S3C2410_GPE(14); break; <and so on for the other GPIOs acting as CS lines> } /* now change one CS line */ gpio_set_value(gpio, pol); } And the platform data must setup the correct count of CS lines: [...] static struct s3c2410_spi_info mini2440_spi0_platdata = { .num_cs = 6, [...] This is valid at least for a 2.6.38 kernel.
To test the SPI function? Search the internet for: spidev_test.c then cross-compile it for this platform.
hi vidya, i'm also interested to write spi driver modules on mini2440. if possible please send me the spi driver module and user application to my mail id 25kisna@gmail.com Thanks in Advance.
Here is an example of how I got a single SPI device to work in 3.1 Only good as a guide to the things that need changing. User application? I think you need to write that.
Not that I recall. I don't think I even actually tested it on a real SPI device ... just did the loop-back test, as above. I moved all my peripheral requirements to Teensy equivalent add-on USB dev boards. Good luck!