I want to use UART 2. The kernel version is 2.6.10_mvl401-davinci_evm-PSP_01_30_00_082
the kernel info is about UART 2 is:
(0x01c40004) = 0x00000085 -> 0x00000085
Serial: 8250/16550 driver $Revision: 1.90 $ 2 ports, IRQ sharing disabled
Registering platform device 'serial8250'. Parent at platform
ttyS0 at MMIO 0x1c20000 (irq = 40) is a 16550A
ttyS1 at MMIO 0x1c20800 (irq = 42) is a 16550A
The kernel source I changed is as follow:
-static struct plat_serial8250_port serial_platform_data[] = {
+static struct plat_serial8250_port serial_platform_data[2] = {
{
.membase = (char *)IO_ADDRESS(DAVINCI_UART0_BASE),
.mapbase = (unsigned long)DAVINCI_UART0_BASE,
@@ -76,6 +76,15 @@ static struct plat_serial8250_port serial_platform_data[] = {
.uartclk = DAVINCI_UART_CLK,
},
{
+ .membase = (char *)IO_ADDRESS(DAVINCI_UART2_BASE),
+ .mapbase = (unsigned long)DAVINCI_UART2_BASE,
+ .irq = IRQ_UARTINT2,
+ .flags = UPF_SKIP_TEST,
+ .iotype = UPIO_MEM32,
+ .regshift = 2,
+ .uartclk = DAVINCI_UART_CLK,
+ },
+ {
.flags = 0,
},
};
@@ -427,6 +436,7 @@ static void board_init(void)
board_setup_psc(DAVINCI_GPSC_ARMDOMAIN, DAVINCI_LPSC_TPTC1, 1);
board_setup_psc(DAVINCI_GPSC_ARMDOMAIN, DAVINCI_LPSC_GPIO, 1);
+ board_setup_psc(DAVINCI_GPSC_ARMDOMAIN, DAVINCI_LPSC_UART2, 1);
/* Turn on WatchDog timer LPSC. Needed for RESET to work */
board_setup_psc(DAVINCI_GPSC_ARMDOMAIN, DAVINCI_LPSC_TIMER2, 1);
@@ -436,8 +446,10 @@ static void board_init(void)
static void dm644x_setup_pinmux(unsigned int id)
{
@@ -468,6 +480,9 @@ static void dm644x_setup_pinmux(unsigned int id)
davinci_cfg_reg(DM644X_VLINQEN);
davinci_cfg_reg(DM644X_VLINQWD);
break;
+ case DAVINCI_LPSC_UART2:
+ davinci_cfg_reg(DM644X_UART2);
+ break;
default:
break;
diff --git a/arch/arm/mach-davinci/clock.c b/arch/arm/mach-davinci/clock.c
index d7a6398..e4b0266 100755
--- a/arch/arm/mach-davinci/clock.c
+++ b/arch/arm/mach-davinci/clock.c
@@ -259,6 +259,12 @@ static struct clk davinci_dm644x_clks[] = {
.lpsc = DAVINCI_LPSC_UART0,
.usecount = 1,
},
"+ {
+ .name = "UART2",
+ .rate = &fixedrate,
+ .lpsc = DAVINCI_LPSC_UART2,
+ .usecount = 1,
+ },
{
.name = "EMACCLK",
.rate = &commonrate,
diff --git a/arch/arm/mach-davinci/mux.c b/arch/arm/mach-davinci/mux.c
index 96ef251..0c7d2ad 100644
--- a/arch/arm/mach-davinci/mux.c
+++ b/arch/arm/mach-davinci/mux.c
@@ -79,6 +79,9 @@ int __init_or_module davinci_cfg_reg(const unsigned long index)
if (tmp1 != tmp2)
warn = 1;
+//lemon add
+ printk(" %s (0x%08x) = 0x%08x -> 0x%08x\n",
+ cfg->mux_reg_name, cfg->mux_reg, reg_orig, reg);
davinci_writel(reg, cfg->mux_reg);
spin_unlock_irqrestore(&mux_spin_lock, flags);
diff --git a/arch/arm/mach-davinci/mux_cfg.c b/arch/arm/mach-davinci/mux_cfg.c
index dac2d27..20fb494 100644
--- a/arch/arm/mach-davinci/mux_cfg.c
+++ b/arch/arm/mach-davinci/mux_cfg.c
@@ -59,6 +59,7 @@ MUX_CFG("RGB666", 0, 22, 1, 1, 1)
MUX_CFG("LOEEN", 0, 24, 1, 1, 1)
MUX_CFG("LFLDEN", 0, 25, 1, 1, 0)
+MUX_CFG("UART2", 1, 2, 1, 1, 1)
};
struct pin_config __initdata_or_module davinci_dm646x_pins[] = {
diff --git a/arch/arm/mach-davinci/serial.c b/arch/arm/mach-davinci/serial.c
index c3090e9..6d60de3 100755
--- a/arch/arm/mach-davinci/serial.c
+++ b/arch/arm/mach-davinci/serial.c
@@ -47,14 +47,17 @@ static inline unsigned int davinci_serial_in(struct plat_serial8250_port *up,
int offset)
{
offset <<= up->regshift;
- return (unsigned int)__raw_readb(up->membase + offset);
+ return (unsigned int)__raw_readw(up->membase + offset);
+// return (unsigned int)__raw_readb(up->membase + offset);
}
static inline void davinci_serial_outp(struct plat_serial8250_port *p,
int offset, int value)
{
offset <<= p->regshift;
- __raw_writeb(value, p->membase + offset);
+// __raw_writeb(value, p->membase + offset);
+ __raw_writew(value, p->membase + offset);
+
}
static void __init davinci_serial_reset(struct plat_serial8250_port *p)
@@ -95,14 +98,17 @@ void __init davinci_serial_init(struct platform_device *pdev)
memset(uart_name, 0, sizeof(uart_name));
for (p = dev->platform_data; p && p->flags; p++) {
- switch (p->mapbase) {
+ printk("p:%x;%d\n",p,p->flags);
+ printk("********************base address:%x\n",p->mapbase);
+switch (p->mapbase) {
case DAVINCI_UART0_BASE:
uart = 0;
break;
case DAVINCI_UART1_BASE:
uart = 1;
break;
- case DM644X_UART2_BASE:
+ case DAVINCI_UART2_BASE:
+ //case DM644X_UART2_BASE:
case DM355_UART2_BASE:
uart = 2;
break;
diff --git a/include/asm-arm/arch-davinci/hardware.h b/include/asm-arm/arch-davinci/hardware.h
index 4bb782c..6883191 100755
--- a/include/asm-arm/arch-davinci/hardware.h
+++ b/include/asm-arm/arch-davinci/hardware.h
@@ -44,6 +44,7 @@
#define DAVINCI_DMA_3PTC1_BASE (0x01C10400)
#define DAVINCI_UART0_BASE (0x01C20000)
#define DAVINCI_UART1_BASE (0x01C20400)
+#define DAVINCI_UART2_BASE (0x01C20800)
#define DAVINCI_I2C_BASE (0x01C21000)
#define DAVINCI_TIMER0_BASE (0x01C21400)
#define DAVINCI_TIMER1_BASE (0x01C21800)
@@ -84,7 +85,7 @@
#define DAVINCI_VLYNQ_REMOTE_BASE (0x0C000000)
#define DM644X_ASYNC_EMIF_CNTRL_BASE (0x01E00000)
-#define DM644X_UART2_BASE (0x01C20800)
+//#define DM644X_UART2_BASE (0x01C20800)
#define DM644X_DDR2_CNTL_BASE (0x20000000)
#define DM355_MMC1_BASE (0x01E00000)
diff --git a/include/asm-arm/arch-davinci/mux.h b/include/asm-arm/arch-davinci/mux.h
index 24ecebf..d1fd175 100644
--- a/include/asm-arm/arch-davinci/mux.h
+++ b/include/asm-arm/arch-davinci/mux.h
@@ -96,6 +96,7 @@ enum davinci_dm644x_index {
/* LCD */
DM644X_LOEEN,
DM644X_LFLDEN,
+ DM644X_UART2,
};
Now after
root@192.168.1.162:~# mknod /dev/ttyS1 c 4 65
root@192.168.1.162:~# stty sane 115200 raw -echo crtscts < /dev/ttyS1
root@192.168.1.162:~# stty -a < /dev/ttyS1
speed 115200 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread clocal crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon
-ixoff -iuclc -ixany -imaxbel
-opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0
ff0
-isig -icanon iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke
root@192.168.1.162:~# cat /proc/tty/driver/serial
serinfo:1.0 driver revision:
0: uart:16550A port:00000000 irq:40 tx:2667 rx:175 RTS|CTS|DTR|DSR
1: uart:16550A port:00000000 irq:42 tx:0 rx:0 CTS|DSR
root@192.168.1.162:~# echo "this is test" > /dev/ttyS1
root@192.168.1.162:~#
root@192.168.1.162:~# cat /proc/tty/driver/serial
serinfo:1.0 driver revision:
0: uart:16550A port:00000000 irq:40 tx:3012 rx:216 RTS|CTS|DTR|DSR
1: uart:16550A port:00000000 irq:42 tx:0 rx:0 CTS|DSR
I write data on the remote terminal which connect to uart 2
But there is no ack.
and we can find there is no change on "tx"
So I think there is still some problem about my driver.