linux3.18内核移植到GT2440成功---完善串口

来源:互联网 发布:佳能ip2780清零软件 编辑:程序博客网 时间:2024/05/16 09:35

linux3.18内核移植到GT2440成功---完善串口

在linux3.1.8内核里面只支持 2 个串口,也就是芯片的 UART0 和 UART1,而 UART2 的驱动是针对红外接口的,而不是串口驱动,这里将其修改为串口驱动。

一.修改

1.修改内核源码“arch/arm/mach-s3c2440/mach-smdk2440.c”文件的smdk2440_uartcfgs结构体数组,

将其改为:

static struct s3c2410_uartcfg  smdk2440_uartcfgs[] __initdata = {

[0] = {

.hwport     = 0,

.flags     = 0,

.ucon     = 0x3c5,

.ulcon     = 0x03,

.ufcon     = 0x51,

},

[1] = {

.hwport     = 1,

.flags     = 0,

.ucon     = 0x3c5,

.ulcon     = 0x03,

.ufcon     = 0x51,

},

[2] = {

.hwport     = 2,

.flags     = 0,

.ucon     = 0x3c5,

.ulcon     = 0x3,  /*修改为3*/

.ufcon     = 0x51,

}

};

2.在drivers/tty/serial/samsung.c中

添加头文件:

#include <mach/gpio-fns.h>

#include <mach/regs-gpio.h>

3.在static int s3c24xx_serial_startup(struct uart_port *port)函数中添加:

if(port->line == 2)

{

s3c2410_gpio_cfgpin(S3C2410_GPH(6), S3C2410_GPH6_TXD2);

s3c2410_gpio_pullup(S3C2410_GPH(6), 1);

s3c2410_gpio_cfgpin(S3C2410_GPH(7), S3C2410_GPH7_RXD2);

s3c2410_gpio_pullup(S3C2410_GPH(7), 1);

}

添加后为:

static int s3c24xx_serial_startup(struct uart_port *port)

{

struct s3c24xx_uart_port *ourport = to_ourport(port);

int ret;

dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",

   port->mapbase, port->membase);

if(port->line == 2)

{

s3c2410_gpio_cfgpin(S3C2410_GPH(6), S3C2410_GPH6_TXD2);

s3c2410_gpio_pullup(S3C2410_GPH(6), 1);

s3c2410_gpio_cfgpin(S3C2410_GPH(7), S3C2410_GPH7_RXD2);

s3c2410_gpio_pullup(S3C2410_GPH(7), 1);

}

rx_enabled(port) = 1;

ret = request_irq(ourport->rx_irq, s3c24xx_serial_rx_chars, 0,

s3c24xx_serial_portname(port), ourport);

if (ret != 0) {

printk(KERN_ERR "cannot get irq %d\n", ourport->rx_irq);

return ret;

}

ourport->rx_claimed = 1;

dbg("requesting tx irq...\n");

tx_enabled(port) = 1;

ret = request_irq(ourport->tx_irq, s3c24xx_serial_tx_chars, 0,

s3c24xx_serial_portname(port), ourport);

if (ret) {

printk(KERN_ERR "cannot get irq %d\n", ourport->tx_irq);

goto err;

}

ourport->tx_claimed = 1;

dbg("s3c24xx_serial_startup ok\n");

/* the port reset code should have done the correct

* register setup for the port controls */

return ret;

err:

s3c24xx_serial_shutdown(port);

return ret;

}

二.配置

Device Drivers --->

                    Character devices --->

                              Serial drivers --->

< > 8250/16550 and compatible serial support                   

  │ │   *** Non-8250 serial port support ***                 

  │ │    <*> Samsung SoC serial support                       

  │ │    [ ] Samsung SoC serial debug                              

  │ │    [*] Support for console on Samsung SoC serial port        

  │ │    < > Samsung S3C2410 Serial port support                  

  │ │    <*> Samsung S3C2440/S3C2442/S3C2416 Serial port support       

  │ │    < > MAX3100 support                                     

  │ │    < > MAX3107 support                                   

  │ │    < > Support for timberdale UART                               

原创粉丝点击