12.1 Modify the source code
The kernel only support 2 serial ports, i.e., UART0 and UART1 of the S3C2440. The driver of UART2 is for infra-red, not the serial port. Here we modify it to be for serial port.
Modify line 99 of source files of kernel “arch/arm/mach-s3c2440/mach-smdk2440.c” (line 100 of Linux-2.6.30.4):
Change it to:
.ulcon = 0x03,
Modify Linux-2.6.25.8 kernel source file”drivers/serial/s3c2410.c”. Insert the red part between line 518 and line 958:
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_GPH6, S3C2410_GPH6_TXD2);
s3c2410_gpio_pullup(S3C2410_GPH6, 1);
s3c2410_gpio_cfgpin(S3C2410_GPH7, S3C2410_GPH7_RXD2);
s3c2410_gpio_pullup(S3C2410_GPH7, 1);
}
rx_enabled(port) = 1;
ret = request_irq(RX_IRQ(port),
s3c24xx_serial_rx_chars, 0,
s3c24xx_serial_portname(port), ourport);
if (ret != 0) {
printk(KERN_ERR “cannot get irq %dn”, RX_IRQ(port));
return ret;
}
Next step is to modify serial port device name in line 958, the content is as follows:
static struct uart_driver s3c24xx_uart_drv = {
.owner = THIS_MODULE,
.dev_name = “tq2440_serial“,
.nr = 3,
.cons = S3C24XX_SERIAL_CONSOLE,
.driver_name = S3C24XX_SERIAL_NAME,
.major = S3C24XX_SERIAL_MAJOR,
.minor = S3C24XX_SERIAL_MINOR,
};
Modify Linux-2.6.30.4 “drivers/serial/samsung.c”, line 53 insert the following:
#include
Add the following content in line 433:
if (port->line == 2) {
s3c2410_gpio_cfgpin(S3C2410_GPH6, S3C2410_GPH6_TXD2);
s3c2410_gpio_pullup(S3C2410_GPH6, 1);
s3c2410_gpio_cfgpin(S3C2410_GPH7, S3C2410_GPH7_RXD2);
s3c2410_gpio_pullup(S3C2410_GPH7, 1);
}
Next is to modify line 888, content is as follows:
.dev_name = “tq2440_serial“,
Now we can rebuild the image and burn to the development board. We can use all there serial ports!
Note: in the preceding tutorials, we already used s3c2410_defconfig to config the serial ports.
We list the serial port config:( the following is 2.6.30.4, and 2.6.25.8 is similar)
Device Drivers —>
Character devices —>
Serial drivers —>
< > 8250/16550 and compatible serial support
*** Non-8250 serial port support ***
<*> Samsung SoC serial support
[*] Support for console on Samsung SoC serial port
<*> Samsung S3C2440/S3C2442 Serial port support
12.2 Test of Serial Ports
We use the simplest method to test the serial ports. There is a getty command in busybox, its function is to switch the control console.
In embedded system, normally serial port is control console. So we can use getty command to test serial port.
Test of Serial port 1:
Default serial port 1, ie, UART0 is the control console.
Test of Serial port 2:
In secureCRT, we type: $getty /dev/tq2440_serial1 115200(which will transfer control to UART1), then type root and enter.
Test of Serial port 3:
In secureCRT, we type: $getty /dev/tq2440_serial2 115200(which will transfer control to UART2), then type root and enter.
The following is the screen capture:
Leave a Reply
You must be logged in to post a comment.