分类: LINUX
2010-07-14 21:25:22
1、参照网页《我在Linux-2.6.32.2下为ST16C554移植驱动的经历》编写
sc
原文:http://blog.chinaunix.net/u3/116495/showart.php?id=2272834
2、出现问题:
(1)首次没有移植成功;是因为sc
(2)遂自己编写驱动查找原因,编写了字符型设备来驱动
(3)芯片正常后,仿照8250.c编写tty驱动,编写成功,linux
(4)二次移植时,居然正常了,欣喜中。但很快发现数据发送不对,每次只能发送16个字节。问题出在
#define PORT(_base,_irq) \
{
.mapbase = (unsigned long)_base, \
.irq = _irq, \
.uartclk = 16000000, \
.iotype = UPIO_MEM32, \
.flags = (UPF_BOOT_AUTOCONF | UPF_IOREMAP), \
.regshift = 0, \
}
iotype应为UPIO_MEM,即8位读写。
更改后即可。
(3)ttS3收发不对,使用cat /proc/tty/driver/serial命令查看时总是被识别为XScale设备和UNKOWN设备。后来发现是
*((volatile unsigned int *)S
((*((volatile unsigned int *)S
| S
| S
| S
| S
设置不对,应该为
*((volatile unsigned int *)S
((*((volatile unsigned int *)S
| S
| S
| S
| S
因为原作者用的CS1,CS2,CS3,CS5,我这里CS5变成了CS4,所以0x30333<<要变成0x03333。
(5)驱动正常后,参照linux-
3、关于8250_exar_sc16c554.
硬件平台:s3c2440 自制印制板
操作系统:linux-
编 译 器:gcc-linux-arm 4.3.2
/*
* linux/drivers/serial/8250_exar_sc16c554.c
*
* Written by Kou Jinqiao
* Based on 8250_exar_st16c554.c.
*
* Copyright (C) 2010.07.07.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include
#include
#include
#include
#include
#define PORT(_base,_irq) \
{ .iobase = (unsigned long)_base, \
.mapbase = (resource_size_t)_base, \
.irq = (unsigned int)_irq, \
.irqflags = IRQF_TRIGGER_RISING, \
.uartclk = 16000000, \
.iotype = UPIO_MEM, \
.flags = (UPF_BOOT_AUTOCONF | UPF_IOREMAP), \
.regshift = 0, \
}
static struct plat_serial8250_port exar_data[] = {
PORT(S3C2410_CS1 + 0x0, IRQ_EINT0),
PORT(S3C2410_CS2 + 0x0, IRQ_EINT1),
PORT(S3C2410_CS3 + 0x0, IRQ_EINT2),
PORT(S3C2410_CS4 + 0x0, IRQ_EINT3),
{ },
};
static struct platform_device exar_device = {
.name = "serial8250",
.id = PLAT8250_DEV_EXAR_ST16C554,
.dev = {
.platform_data = exar_data,
},
};
static int __init exar_init(void)
{
/* Set the 8bit bus width of bank1,bank2,bank3,bank4*/
*((volatile unsigned int *)S3C2410_BWSCON) =
((*((volatile unsigned int *)S3C2410_BWSCON)) & ~(0x03333<<4))
| S3C2410_BWSCON_DW1_8
| S3C2410_BWSCON_DW2_8
| S3C2410_BWSCON_DW3_8
| S3C2410_BWSCON_DW4_8;
return platform_device_register(&exar_device);
}
module_init(exar_init);
MODULE_AUTHOR("Kou Jinqiao");
MODULE_DESCRIPTION("8250 serial probe module for Exar cards-sc16c554");
MODULE_LICENSE("GPL");
把8250_exar_sc16c554.c放入linux/drivers/serial/下,修改Makefile文件,重新make menuconfig 选中8250_exar_sc16c554,然后make zImage即可。
chinaunix网友2010-09-07 15:46:53
Kou Jinqiao,你好!想问一下,如果4个通道都用CS5片选,寄存器地址分别为: 2800_0000~2800_0007, .... 2800_0018~2800_001F PORT(S3C2410_CS1 + 0x0, IRQ_EINT0), PORT(S3C2410_CS2 + 0x0, IRQ_EINT1), PORT(S3C2410_CS3 + 0x0, IRQ_EINT2), PORT(S3C2410_CS4 + 0x0, IRQ_EINT3), 此处的偏移地址如何确定?还请多指教