arch/arm/mach-s3c2440/mach-tq2440.c
所有的改动都是在arch/arm/mach-s3c2440/mach-tq2440.c中
1. 添加include
2.添加board_info
并在tq2440_machine_init中将board_info赋值
3.最后添加spi的设备
因为在./arch/arm/plat-s3c24xx/devs.c中己经有了spi0的platform_device,
这儿只需要添加到设备列表中即可
4. 内核配置: make menuconfig
1-3是添加spi的设备,4步是添加spi的driver
- --- a/arch/arm/mach-s3c2440/mach-tq2440.c
- +++ b/arch/arm/mach-s3c2440/mach-tq2440.c
- @@ -46,6 +46,9 @@
-
- #include <sound/s3c24xx_uda134x.h>
-
- +#include <../mach-s3c2410/include/mach/spi.h>
- +#include <linux/spi/spi.h>
- +
- static struct map_desc tq2440_iodesc[] __initdata = {
- };
-
- @@ -318,6 +321,22 @@ static struct platform_device s3c_device_uda134x = {
- }
- };
-
- +static struct spi_board_info s3c2410_spi0_board[] = {
- + [0] = {
- + .modalias = "spidev",
- + .bus_num = 0,
- + .chip_select = 0,
- + .irq = IRQ_EINT10,
- + .max_speed_hz = 500*1000,
- + },
- +};
- +
- +static struct s3c2410_spi_info s3c2410_spi0_platdata = {
- + .pin_cs = S3C2410_GPG2,
- + .num_cs = 1,
- + .bus_num = 0,
- +};
- +
- static struct platform_device *tq2440_devices[] __initdata = {
- &s3c_device_usb,
- &s3c_device_lcd,
- @@ -330,6 +349,7 @@ static struct platform_device *tq2440_devices[] __initdata = {
- #endif
- &s3c_device_usbgadget,
- &s3c_device_uda134x,
- + &s3c_device_spi0,
- };
-
- static void __init tq2440_map_io(void)
- @@ -346,6 +366,8 @@ static void __init tq2440_machine_init(void)
-
- platform_add_devices(tq2440_devices, ARRAY_SIZE(tq2440_devices));
- EmbedSky_machine_init();
- + s3c_device_spi0.dev.platform_data= &s3c2410_spi0_platdata;
- + spi_register_board_info(s3c2410_spi0_board, ARRAY_SIZE(s3c2410_spi0_board));
- s3c2410_gpio_setpin(S3C2410_GPG12, 0);
- s3c2410_gpio_cfgpin(S3C2410_GPG12, S3C2410_GPIO_OUTPUT);
- s3c24xx_udc_set_platdata(&EmbedSky_udc_cfg);
1. 添加include
- #include <../mach-s3c2410/include/mach/spi.h>
- #include <linux/spi/spi.h>
- static struct spi_board_info s3c2410_spi0_board[] = {
- [0] = {
- .modalias = "spidev",
- .bus_num = 0,
- .chip_select = 0,
- .irq = IRQ_EINT10,
- .max_speed_hz = 500*1000,
- },
- };
-
- static struct s3c2410_spi_info s3c2410_spi0_platdata = {
- .pin_cs = S3C2410_GPG2,
- .num_cs = 1,
- .bus_num = 0,
- };
- static void __init tq2440_machine_init(void)
- {
- ....
- s3c_device_spi0.dev.platform_data= &s3c2410_spi0_platdata;
- spi_register_board_info(s3c2410_spi0_board, ARRAY_SIZE(s3c2410_spi0_board));
- .....
- }
因为在./arch/arm/plat-s3c24xx/devs.c中己经有了spi0的platform_device,
这儿只需要添加到设备列表中即可
- static struct platform_device *tq2440_devices[] __initdata = {
- &s3c_device_spi0,
- };
- Device Drivers --->
- [*] SPI support --->
- *** SPI Master Controller Drivers ***
- -*- Utilities for Bitbanging SPI masters --> SPI_BITBANG
- < > GPIO-based bitbanging SPI Master --> SPI_GPIO not set
- <*> Samsung S3C24XX series SPI --> SPI_S3C24XX
- <*> Samsung S3C24XX series SPI by GPIO --> SPI_S3C24XX_GPIO
- *** SPI Protocol Masters ***
- <*> User mode SPI device driver support --> SPI_SPIDEV
- < > Infineon TLE62X0 (for power switching)