添加AL9V576的CHAR驱动到基于linux-2.6.27的9G9260开发板
1,修改drivers/char/Makefile文件
root@yuanxh-desktop:/home/yuanxh/sam9260/linux-2.6.27-9g9260# vi drivers/char/Makefile
在第102行添加:
obj-$(CONFIG_FY_AL9V576) += al9v576.o
2, 修改drivers/char/Kconfig文件
root@yuanxh-desktop:/home/yuanxh/sam9260/linux-2.6.27-9g9260# vi drivers/char/Kconfig
在第1123行添加:
config FY_AL9V576
tristate "AverLogic AL9V576 MPEG-4/2/1 A/V Encoder"
depends on MACH_9G9260EK
help
If you say yes here you get support for the
AverLogic AL9V576 MPEG-4/2/1 A/V Encoder.
This driver can also be built as a module. If so, the module
will be called al9v576.
config FY_AL9V576_DEBUG
boolean "AL9V576 Encoder debug messages"
depends on MACH_9G9260EK && FY_AL9V576
help
Select this if you want AL9V576 debug messages
3,编译配置内核
root@yuanxh-desktop:/home/yuanxh/sam9260/linux-2.6.27-9g9260# make menuconfig
进入配置菜单添加驱动到内核:
System Type --->
Atmel AT91 System-on-Chip --->
[*] Atmel AT91SAM9260-EK / AT91SAM9XE Evaluation Kit
[*] 9G9260-EK Evaluation Kit
Device Drivers --->
Character devices --->
<M> AverLogic AL9V576 MPEG-4/2/1 A/V Encoder
[*] AL9V576 Encoder debug messages
4,修改arch/arm/mach-at91/board-sam9260ek.c文件
root@yuanxh-desktop:/home/yuanxh/sam9260/linux-2.6.27-9g9260# vi arch/arm/mach-at91/board-sam9260ek.c
在头文件列表后添加:
#include <mach/at91sam9260.h>
#include <mach/at91sam9260_matrix.h>
#include <mach/at91sam9_smc.h>
在static void __init ek_board_init(void)内部添加:
#if defined(CONFIG_MACH_9G9260EK)
/* al9v576 */
at91_add_device_al9v576();
#endif
在static void __init ek_board_init(void)前面添加:
#if defined(CONFIG_MACH_9G9260EK)
#define AL9V576_BASE AT91_CHIPSELECT_0
#define AL9V576_SIZE SZ_1K
static struct resource al9v576_resources[] =
{
{
.start = AL9V576_BASE,
.end = AL9V576_BASE + AL9V576_SIZE - 1,
.flags = IORESOURCE_MEM,
}
};
static struct platform_device al9v576_driver =
{
.name = "al9v576",
.id = 0,
.dev =
{
.platform_data = NULL,
},
.resource = al9v576_resources,
.num_resources = ARRAY_SIZE(al9v576_resources),
};
static struct sam9_smc_config __initdata al9v576_smc_config =
{
.ncs_read_setup = 0x01,
.nrd_setup = 0x02,
.ncs_write_setup = 0x01,
.nwe_setup = 0x02,
.ncs_read_pulse = 0x08,
.nrd_pulse = 0x06,
.ncs_write_pulse = 0x08,
.nwe_pulse = 0x06,
.read_cycle = 0x12,
.write_cycle = 0x12,
.mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,
.tdf_cycles = 0x08,
};
static __init void at91_add_device_al9v576(void)
{
unsigned long csa;
csa = at91_sys_read(AT91_MATRIX_EBICSA);
at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_VDDIOMSEL_3_3V);
/* setup bus-width (8 or 16) */
#if defined(CONFIG_AL9V576_BUSWIDTH_16)
al9v576_smc_config.mode |= AT91_SMC_DBW_16;
#else
al9v576_smc_config.mode |= AT91_SMC_DBW_8;
#endif
/* configure chip-select 0 (AL9V576) */
sam9_smc_configure(0, &al9v576_smc_config);
platform_device_register(&al9v576_driver);
}
#endif
5,添加drivers/char/al9v576.h文件
root@yuanxh-desktop:/home/yuanxh/sam9260/linux-2.6.27-9g9260# vi drivers/char/al9v576.h
添加的源码见附件。
6,添加drivers/char/al9v576.c文件
root@yuanxh-desktop:/home/yuanxh/sam9260/linux-2.6.27-9g9260# vi drivers/char/al9v576.c
添加的源码见附件。
7, 编译内核生成驱动
root@yuanxh-desktop:/home/yuanxh/sam9260/linux-2.6.27-9g9260# make
附件:
(保密)
离线