在arch/arm/mach-s3c64XX/mach-smdk6410.c中中增加如下代码:
static void cs_set_level(unsigned line_id, int lvl) {
gpio_direction_output(line_id, lvl);
};
static struct s3c64xx_spi_csinfo s3c64xx_spi0_csinfo = {
.fb_delay=100,
.line=S3C64XX_GPC(3),
.set_level=cs_set_level,
};
static struct spi_board_info s3c6410_spi0_board[] = {
[0] = {
.modalias = "spidev",
.bus_num= 0,
.chip_select= 0, //必须小于s3c6410_spi0_platdata.num_cs
.irq =IRQ_SPI0,
.max_speed_hz= 500*1000,
.mode=SPI_MODE_0,
.controller_data=&s3c64xx_spi0_csinfo,
},
};
static struct s3c64xx_spi_csinfo s3c64xx_spi1_csinfo = {
.fb_delay=100,
.line=S3C64XX_GPC(7),
.set_level=cs_set_level,
};
static struct spi_board_info s3c6410_spi1_board[] = {
[0] = {
.modalias = "spidev",
.bus_num= 1,//代表使用芯片的第二个spi模块
.chip_select= 0, //必须小于s3c6410_spi1_platdata.num_cs
.irq = IRQ_SPI1,
.max_speed_hz = 500*1000,
.mode=SPI_MODE_0,
.controller_data=&s3c64xx_spi1_csinfo,
},
};
在mach-smdk6410.c最后在函数 mini6410_machine_init中添加:
s3c64xx_spi_set_info(0,0,2);
s3c64xx_spi_set_info(1,0,2);
spi_register_board_info(s3c6410_spi0_board, ARRAY_SIZE(s3c6410_spi0_board));
spi_register_board_info(s3c6410_spi1_board, ARRAY_SIZE(s3c6410_spi1_board));
mach-smdk6410.c头文件里面添加了:
#include <linux/spi/spidev.h>
#include <linux/spi/spi.h>
#include <plat/s3c64xx-spi.h>
重点的来了:
在此目录中找到:Makefile,打开
修改成
# device support
obj-y += dev-uart.o
obj-y += dev-audio.o
obj-y += dev-spi.o
现在编译make zImage,成功
放到板子上安装,就可以在dev下看到spidev0.0,spidev1.0了:
留个qq:493763664