分类: LINUX
2009-12-03 16:35:16
RST:GP81
INTA:GP82
INTB:GP83(16C550要求高电平触发,所以使用上升沿)
ADDRESS——A:0x10000000(经过CPLD译码)
ADDRESS——B:0x12000000
修改:include/asm-arm/serial.h
增加:include/asm-arm/arch-pxa/serial.h
修改:drivers/serial/8250.c
修改:drivers/serial/pxa.c
修改:include/asm-arm/arch-pxa/mainstone.h
在mainstone.中增加地址映射:
static struct map_desc
mainstone_io_desc[] __initdata = {
{ MST_FPGA_VIRT, MST_FPGA_PHYS,
0x00100000, MT_DEVICE }, /* CPLD */
{
EPC_EXT_SER_A_VIRT, EPC_EXT_SER_A_PHYS, 0x00100000, MT_DEVICE }, /* 16C550 */
{ EPC_EXT_SER_B_VIRT,
EPC_EXT_SER_B_PHYS, 0x00100000, MT_DEVICE }, /* 16C550 */
};
在mainstone.h中增加:
#define
EPC_EXT_SER_A_PHYS
0x10000000 //A
#define EPC_EXT_SER_A_VIRT
(MST_FPGA_VIRT+0x100000)
#define EPC_EXT_SER_B_PHYS 0x12000000 //B
#define EPC_EXT_SER_B_VIRT
(MST_FPGA_VIRT+0x200000)
在include/asm-arm/serial.h文件增加:
#include
#define SERIAL_PORT_DFNS \
STD_SERIAL_PORT_DEFNS \
EXTRA_SERIAL_PORT_DEFNS
在include/asm-arm/arch-pxa/serial.h文件中增加:
#define BASE_BAUD (1843200 / 16) //16C550的时钟是18M
#define BAUD_BASE (1843200 / 16)
/* Standard COM flags */
//#define STD_COM_FLAGS (ASYNC_SKIP_TEST)
#define STD_COM_FLAGS (ASYNC_SKIP_TEST|ASYNC_BOOT_AUTOCONF)
#define RS_TABLE_SIZE 8
#define EXTRA_SERIAL_PORT_DEFNS
//#define STD_SERIAL_PORT_DEFNS
//#define EXTRA_SERIAL_PORT_DEFNS
#define STD_SERIAL_PORT_DEFNS \
{
\
.baud_base = BASE_BAUD, \
.iomem_base = EPC_EXT_SER_A_VIRT, \
.io_type = UPIO_MEM, \
.irq = EPC_EXT_SER_A_IRQ, \
.flags = STD_COM_FLAGS, \
.iomem_reg_shift=1,\
}, { \
.baud_base = BASE_BAUD, \
.iomem_base = EPC_EXT_SER_B_VIRT, \
.io_type = UPIO_MEM, \
.irq = EPC_EXT_SER_B_IRQ, \
.flags = STD_COM_FLAGS, \
.iomem_reg_shift=1,\
}
其中,iomem_reg_shift表示寄存器对齐宽度,两字节对齐设置为1,如果是4字节对齐,设置为2。
在mainstone.c中设置中断。
pxa_gpio_mode(GPIO80_nCS_4_MD); /*
16C550, BANK4 */
pxa_gpio_mode(81|GPIO_OUT|GPIO_DFLT_HIGH);
/* 16C550 RESET */
pxa_gpio_mode(81|GPIO_OUT|GPIO_DFLT_LOW);
/* 16C550 RESET */
pxa_gpio_mode(82|GPIO_IN); /* 16C550 INTA */
set_irq_handler(IRQ_GPIO(82),
do_edge_IRQ);
set_irq_type(IRQ_GPIO(82),
IRQT_RISING);
pxa_gpio_mode(83|GPIO_IN); /* 16C550 INTB */
set_irq_handler(IRQ_GPIO(83),
do_edge_IRQ);
set_irq_type(IRQ_GPIO(83),
IRQT_RISING);
在mainstone.c中设置总线。
MSC2 = 0x7FF87FF8; //BANK5--PC104 BANK4--16C550
由于pxa.c和8250.c中串口设备使用了相同的次设备号,造成冲突,导致以前的内核崩溃。修改8250.c中的设备号,以及将设备名称由原来的ttyS修改为ttySE。
#
# Serial drivers
#
CONFIG_SERIAL_8250=y
CONFIG_SERIAL_8250_CONSOLE=y
# CONFIG_SERIAL_8250_CS is not set
CONFIG_SERIAL_8250_NR_UARTS=4
CONFIG_SERIAL_8250_EXTENDED=y
CONFIG_SERIAL_8250_MANY_PORTS=y
CONFIG_SERIAL_8250_SHARE_IRQ=y
CONFIG_SERIAL_8250_DETECT_IRQ=y
# CONFIG_SERIAL_8250_MULTIPORT is not set
CONFIG_SERIAL_8250_RSA=y
#
# Non-8250 serial port support
#
CONFIG_SERIAL_PXA=y
CONFIG_SERIAL_PXA_CONSOLE=y
CONFIG_SERIAL_CORE=y
CONFIG_SERIAL_CORE_CONSOLE=y
CONFIG_UNIX98_PTYS=y
CONFIG_LEGACY_PTYS=y
CONFIG_LEGACY_PTY_COUNT=256
SA1100 Real Time Clock
driver v1.02
Serial: 8250/16550 driver $Revision: 1.90 $ 6 ports, IRQ sharing enabled
ttySE0 at MMIO 0x0 (irq = 114) is a 16550A
ttySE1 at MMIO 0x0 (irq = 115) is a 16550A
ttyS0 at MMIO 0x40100000 (irq = 22) is a FFUART
ttyS1 at MMIO 0x40200000 (irq = 21) is a BTUART
ttyS2 at MMIO 0x40700000 (irq = 20) is a STUART
io scheduler noop registered
io scheduler anticipatory registered
io scheduler deadline registered
io scheduler cfq registered
将EPC外扩串口和笔记本相连,使用9600波特率。
在Shell终端使用echo hello>/dev/ttySE0即可。
或者cat
file>/dev/ttySE0