新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 基于S3C2440處理器SPI移植全過程

基于S3C2440處理器SPI移植全過程

作者: 時間:2016-11-10 來源:網(wǎng)絡(luò) 收藏
環(huán)境

硬件:S3C2440(ARM920T)

本文引用地址:http://butianyuan.cn/article/201611/317171.htm

嵌入式操作系統(tǒng):Linux2.6.24內(nèi)核

文件系統(tǒng):Yaffs2文件系統(tǒng)

服務(wù)器:SuSe10.0 Linux服務(wù)器

第一步:內(nèi)核配置

需要在內(nèi)核中選擇以上幾個選項:

很多網(wǎng)友發(fā)郵件說Linux2.6.24內(nèi)核在SPI選項上未發(fā)現(xiàn)有Samsung S3C2440 series SPI 或 Samsung S3C24XX series SPI 和User mode SPI device driver support這兩個選項。

其實在Linux2.6.24內(nèi)核里已經(jīng)兼容了對SPI的操作。只是在Linux2.6.24/drivers/spi/Kconfig中未能選中此選項。至于什么原因看下面的說明:打開Linux2.6.24/drivers/spi/Kconfig

找到以下幾個選項:

config SPI_BITBANG
tristate "Bitbanging SPI master"
depends on SPI_MASTER#&& EXPERIMENTAL
help
With a few GPIO pins, your system can bitbang the SPI protocol.
Select this to get SPI support through I/O pins (GPIO, parallel
port, etc). Or, some systems SPI master controller drivers use
this code to manage the per-word or per-transfer accesses to the
hardware shift registers.

This is library code, and is automatically selected by drivers that
need it. You only need to select this explicitly to support driver
modules that arent part of this kernel tree.

使用SPI的時候需要把Bitbanging SPI master打開,但是依賴的條件EXPERIMENTAL,這里我們把這個條件去掉,然后再找到:

config SPI_S3C24XX
tristate "Samsung S3C24XX series SPI"
depends on SPI_MASTER && ARCH_S3C2410 && EXPERIMENTAL
select SPI_BITBANG
help
SPI driver for Samsung S3C24XX series ARM SoCs

config SPI_S3C2440
tristate "Samsung S3C2440 series SPI"
depends on SPI_MASTER && ARCH_S3C2410
select SPI_BITBANG
help
Add by SmallBox at 2011.02.18 SPI driver for Samsung S3C24XX series ARM SoCs
以上藍(lán)色的字是我添加的。為了區(qū)別Linux內(nèi)核默認(rèn)的配置!修改到這里保存,退出。然后打開該目錄下面的Makefile文件,需要做以下修改:

添加:

obj-$(CONFIG_SPI_S3C2440) += spi_s3c24xx.o

這里說明一下:如果不想在Kconfig中添加我添加的選項,這里就不需要修改Makefile文件了。因為本身已經(jīng)有對S3C24XX的支持!

修改后保存退出!

下面需要修改的是Linux2.6.24里面的文件:

1)打開smallbox@linux-server:/home/Linux2.6.24/arch/arm/plat-s3c24xx/devs.c添加一下語句

這里還需要說明一下,添加后編譯會出現(xiàn)錯誤。還需要增加相應(yīng)的頭文件:

#include
#include
#include

如果還有錯誤,可能就是你的頭文件添加的不夠。繼續(xù)查找添加,知道Make成功;

2)打開smallbox@linux-server:/home/Linux2.6.24/arch/arm/mach-s3c2440/mach-hyh2440.c 文件添加

static struct platform_device *utu2440_devices[] __initdata = {
&s3c_device_usb,
&s3c_device_lcd,
&s3c_device_wdt,
&s3c_device_i2c,
&s3c_device_iis,
&s3c_device_usbgadget,
&s3c_device_ts,
&s3c_device_dm9000,
&s3c_device_nand,
&s3c_device_sound,
&s3c_device_buttons,
&s3c_device_rtc,
&s3c_device_sdi,
&s3c_device_spi0,

};
保存退出!

最后就可以Make了。下載你的內(nèi)核,啟動你的硬件,你會在dev下發(fā)現(xiàn)spidev0.1這個設(shè)備了!



關(guān)鍵詞: S3C2440SPI移植全過

評論


技術(shù)專區(qū)

關(guān)閉