Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2150670
  • 博文数量: 438
  • 博客积分: 3871
  • 博客等级: 中校
  • 技术积分: 6075
  • 用 户 组: 普通用户
  • 注册时间: 2011-09-10 00:11
个人简介

邮箱: wangcong02345@163.com

文章分类

全部博文(438)

文章存档

2017年(15)

2016年(119)

2015年(91)

2014年(62)

2013年(56)

2012年(79)

2011年(16)

分类: LINUX

2015-05-14 11:51:15

arch/arm/mach-s3c2440/mach-tq2440.c
  1. --- a/arch/arm/mach-s3c2440/mach-tq2440.c
  2. +++ b/arch/arm/mach-s3c2440/mach-tq2440.c
  3. @@ -46,6 +46,9 @@
  4.  
  5.  #include <sound/s3c24xx_uda134x.h>
  6.  
  7. +#include <../mach-s3c2410/include/mach/spi.h>
  8. +#include <linux/spi/spi.h>
  9. +
  10.  static struct map_desc tq2440_iodesc[] __initdata = {
  11.  };
  12.  
  13. @@ -318,6 +321,22 @@ static struct platform_device s3c_device_uda134x = {
  14.         }
  15.  };
  16.  
  17. +static struct spi_board_info s3c2410_spi0_board[] = {
  18. + [0] = {
  19. + .modalias = "spidev",
  20. + .bus_num = 0,
  21. + .chip_select = 0,
  22. + .irq = IRQ_EINT10,
  23. + .max_speed_hz = 500*1000,
  24. + },
  25. +};
  26. +
  27. +static struct s3c2410_spi_info s3c2410_spi0_platdata = {
  28. + .pin_cs = S3C2410_GPG2,
  29. + .num_cs = 1,
  30. + .bus_num = 0,
  31. +};
  32. +
  33.  static struct platform_device *tq2440_devices[] __initdata = {
  34.         &s3c_device_usb,
  35.         &s3c_device_lcd,
  36. @@ -330,6 +349,7 @@ static struct platform_device *tq2440_devices[] __initdata = {
  37.  #endif
  38.         &s3c_device_usbgadget,
  39.         &s3c_device_uda134x,
  40.         + &s3c_device_spi0,
  41.  };
  42.  
  43.  static void __init tq2440_map_io(void)
  44. @@ -346,6 +366,8 @@ static void __init tq2440_machine_init(void)
  45.  
  46.         platform_add_devices(tq2440_devices, ARRAY_SIZE(tq2440_devices));
  47.         EmbedSky_machine_init();
  48. + s3c_device_spi0.dev.platform_data= &s3c2410_spi0_platdata;
  49. + spi_register_board_info(s3c2410_spi0_board, ARRAY_SIZE(s3c2410_spi0_board));
  50.         s3c2410_gpio_setpin(S3C2410_GPG12, 0);
  51.         s3c2410_gpio_cfgpin(S3C2410_GPG12, S3C2410_GPIO_OUTPUT);
  52.         s3c24xx_udc_set_platdata(&EmbedSky_udc_cfg);
所有的改动都是在arch/arm/mach-s3c2440/mach-tq2440.c中
1. 添加include
  1. #include <../mach-s3c2410/include/mach/spi.h>
  2. #include <linux/spi/spi.h>
2.添加board_info
  1. static struct spi_board_info s3c2410_spi0_board[] = {
  2.         [0] = {
  3.                  .modalias = "spidev",
  4.                 .bus_num = 0,
  5.                 .chip_select = 0,
  6.                 .irq = IRQ_EINT10,
  7.                 .max_speed_hz = 500*1000,
  8.         },
  9. };

  10. static struct s3c2410_spi_info s3c2410_spi0_platdata = {
  11.         .pin_cs = S3C2410_GPG2,
  12.         .num_cs = 1,
  13.         .bus_num = 0,
  14. };
并在tq2440_machine_init中将board_info赋值
  1. static void __init tq2440_machine_init(void)
  2. {
  3.     ....
  4.     s3c_device_spi0.dev.platform_data= &s3c2410_spi0_platdata;
  5.     spi_register_board_info(s3c2410_spi0_board, ARRAY_SIZE(s3c2410_spi0_board));
  6.     .....
  7. }
3.最后添加spi的设备
因为在./arch/arm/plat-s3c24xx/devs.c中己经有了spi0的platform_device,
这儿只需要添加到设备列表中即可
  1. static struct platform_device *tq2440_devices[] __initdata = {
  2.     &s3c_device_spi0,
  3. };
4. 内核配置: make menuconfig
  1. Device Drivers --->
  2.       [*] SPI support --->
  3.          *** SPI Master Controller Drivers ***
  4.          -*- Utilities for Bitbanging SPI masters --> SPI_BITBANG
  5.          < > GPIO-based bitbanging SPI Master --> SPI_GPIO not set
  6.          <*> Samsung S3C24XX series SPI --> SPI_S3C24XX
  7.          <*> Samsung S3C24XX series SPI by GPIO --> SPI_S3C24XX_GPIO
  8.          *** SPI Protocol Masters ***
  9.          <*> User mode SPI device driver support --> SPI_SPIDEV
  10.          < > Infineon TLE62X0 (for power switching)
1-3是添加spi的设备,4步是添加spi的driver

阅读(1519) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~