在Linux-2.6.32.2下为ST16C554移植驱动的经历
来源:互联网 发布:力士乐plc编程软件 编辑:程序博客网 时间:2024/06/05 15:32
一、Linux驱动的基本理论
我们来看一下两个结构体的定义:
struct platform_device {
};
在arch/arm/mach-s 3c2440/mach-mini2440.c中初始化
struct device {
#ifdef CONFIG_NUMA
#endif
};
};
在drivers/serial/8250.c中初始化
struct device_driver {
};
二、ST16C554
三、移植过程
1.
添加头文件
#ifdef CONFIG_SERIAL_8250_MINI2440_ST16C554
#include <linux/serial_8250.h>
#endif
初始化st16c554的platform_device数据结构
#define PORT(_base,_irq)
static struct plat_serial8250_port mini2440_st16c554_8250_data[] = {
};
static struct platform_device mini2440_device_st16c554 = {
};
将st16c554对应的platform_device数据结构体添加到mini2440对应的platform_device数据结构体中。
static struct platform_device *mini2440_devices[] __initdata = {
//#ifdef CONFIG_SERIAL_8250_MINI2440_ST16C554
//#endif
};
2.修改 drivers/serial/8250.c
#ifdef CONFIG_SERIAL_8250_MINI2440_ST16C554
#include <mach/regs-mem.h>
#endif
修改S3C2440 四个Bank使用的的bus width为8位,以及设定这四个Bank的总线timing。
static int __init serial8250_init(void)
{
#ifdef CONFIG_SERIAL_8250_MINI2440_ST16C554
((*((volatile unsigned int *)S3C2410_BWSCON)) & ~(0x30333<<4))
#endif
#ifdef CONFIG_SPARC
#else
#endif
#ifdef CONFIG_8250_MINI2440_ST16C554
serial8250_isa_devs =
platform_device_alloc("serial8250", PLAT8250_DEV_EXAR_ST16C554);
#else
#endif
修改中断信号的类型为下降沿触发
#ifdef CONFIG_SERIAL_8250_MINI2440_ST16C554
#else
#endif
3.修改 drivers/serial/Kconfig
添加一个编译配置选项
config SERIAL_8250_MINI2440_ST16C554
To compile this driver as a module, choose M here: the module will be called 8250_mini2440_st16c554.
4.重新编译内核
> make menucofig
Device Drivers
保存.config文件
> make zImage
这样驱动就添加好了,如果你的根文件系统使用了mdev,那么不用做任何修改,mdev会自动地将四个新串口添加在/dev/serial/tty目录下面,分别为 ttyS0, ttyS1, ttyS2, ttyS3。
查看更详细的信息
> cat /proc/tty/driver/serial 将显示四个串口的物理地址和虚拟地址
四.碰到的问题
内核启动过程中,报错
Unable to handle kernel NULL pointer dereference at virtual address 000000c0
产生这个错误有两种可能:
(1)
static struct platform_device mini2440_device_st16c554 = {
};
(2)
#define PORT(_base,_irq)
在 driver/serial/8250_exar_st16c554.c中使用的是IO地址
#define PORT(_base,_irq)
- Linux-2.6.32.2下为ST16C554移植驱动的经历
- 在Linux-2.6.32.2下为ST16C554移植驱动的经历
- mini2440触摸屏驱动在linux-2.6.32.2的移植
- Linux-2.6.32.2内核在mini2440上的移植(十六)---基于中断的按键驱动移植
- Linux-2.6.32.2内核在mini2440上的移植(十六)---基于中断的按键驱动移植
- Linux-2.6.32.2内核在mini2440上的移植(十六)---基于中断的按键驱动移植
- Linux-2.6.32.2内核在mini2440上的移植(九)---触摸屏驱动移植
- Linux-2.6.32.2内核在mini2440上的移植(三)---DM9000网卡驱动移植
- Linux-2.6.32.2内核在mini2440上的移植(六)---LCD驱动移植
- Linux-2.6.32.2内核在mini2440上的移植(八)---触摸屏驱动移植
- Linux-2.6.32.2内核在mini2440上的移植(九)---触摸屏驱动移植
- .Linux-2.6.32.2内核在mini2440上的移植(十一)---移植SD卡驱动
- Linux-2.6.32.2内核在mini2440上的移植(十二)---移植I2C EEPROM驱动
- Linux-2.6.32.2内核在mini2440上的移植(十三)---移植UDA1341音频驱动
- Linux-2.6.32.2内核在mini2440上的移植(十四)---移植看门狗驱动
- Linux-2.6.32.2内核在mini2440上的移植(十五)---移植LED驱动
- .Linux-2.6.32.2内核在mini2440上的移植(十七)---移植PWM控制蜂鸣器驱动
- Linux-2.6.32.2内核在mini2440上的移植(七)---LCD驱动移植
- js时间戳格式化成日期格式
- KGTP内核调试使用
- Java 垃圾回收机制原理
- Leetcode: Binary Tree Postorder Traversal
- 一个引号引起的血案,ORACLE SQL 分页语句的错误
- 在Linux-2.6.32.2下为ST16C554移植驱动的经历
- QQ群推广最大化营销效果分析
- HMM 自学教程(一)引言
- WP8开发学习(4):Style样式的四种使用
- Linux中Apache+Tomcat+JK实现负载均衡和群集的完整过程
- 【Android】数据存储之SDcard
- Leetcode: LRU Cache
- MySql源码安装
- Android2.3.5 vold个人总结