aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/serial/imx.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-06 16:20:10 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-06 16:20:10 -0400
commitc6799ade4ae04b53a5f677e5289116155ff01574 (patch)
tree3601b5e2387e39d62c207e4268c6cc5c68f2a364 /drivers/serial/imx.c
parentb7405e16435f710edfae6ba32bef4ca20d3de145 (diff)
parent5cd47155155a32e5b944ac9fc3f3dc578e429aa0 (diff)
Merge branch 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm
* 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm: (82 commits) [ARM] Add comments marking in-use ptrace numbers [ARM] Move syscall saving out of the way of utrace [ARM] 4360/1: S3C24XX: regs-udc.h remove unused macro [ARM] 4358/1: S3C24XX: mach-qt2410.c: remove linux/mmc/protocol.h header [ARM] mm 10: allow memory type to be specified with ioremap [ARM] mm 9: add additional device memory types [ARM] mm 8: define mem_types table L1 bit 4 to be for ARMv6 [ARM] iop: add missing parens in macro [ARM] mm 7: remove duplicated __ioremap() prototypes ARM: OMAP: fix OMAP1 mpuio suspend/resume oops ARM: OMAP: MPUIO wake updates ARM: OMAP: speed up gpio irq handling ARM: OMAP: plat-omap changes for 2430 SDP ARM: OMAP: gpio object shrinkage, cleanup ARM: OMAP: /sys/kernel/debug/omap_gpio ARM: OMAP: Implement workaround for GPIO wakeup bug in OMAP2420 silicon ARM: OMAP: Enable 24xx GPIO autoidling [ARM] 4318/2: DSM-G600 Board Support [ARM] 4227/1: minor head.S fixups [ARM] 4328/1: Move i.MX UART regs to driver ...
Diffstat (limited to 'drivers/serial/imx.c')
-rw-r--r--drivers/serial/imx.c268
1 files changed, 205 insertions, 63 deletions
diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c
index 04cc88cc528c..e42faa4e4282 100644
--- a/drivers/serial/imx.c
+++ b/drivers/serial/imx.c
@@ -46,6 +46,122 @@
46#include <asm/hardware.h> 46#include <asm/hardware.h>
47#include <asm/arch/imx-uart.h> 47#include <asm/arch/imx-uart.h>
48 48
49/* Register definitions */
50#define URXD0 0x0 /* Receiver Register */
51#define URTX0 0x40 /* Transmitter Register */
52#define UCR1 0x80 /* Control Register 1 */
53#define UCR2 0x84 /* Control Register 2 */
54#define UCR3 0x88 /* Control Register 3 */
55#define UCR4 0x8c /* Control Register 4 */
56#define UFCR 0x90 /* FIFO Control Register */
57#define USR1 0x94 /* Status Register 1 */
58#define USR2 0x98 /* Status Register 2 */
59#define UESC 0x9c /* Escape Character Register */
60#define UTIM 0xa0 /* Escape Timer Register */
61#define UBIR 0xa4 /* BRM Incremental Register */
62#define UBMR 0xa8 /* BRM Modulator Register */
63#define UBRC 0xac /* Baud Rate Count Register */
64#define BIPR1 0xb0 /* Incremental Preset Register 1 */
65#define BIPR2 0xb4 /* Incremental Preset Register 2 */
66#define BIPR3 0xb8 /* Incremental Preset Register 3 */
67#define BIPR4 0xbc /* Incremental Preset Register 4 */
68#define BMPR1 0xc0 /* BRM Modulator Register 1 */
69#define BMPR2 0xc4 /* BRM Modulator Register 2 */
70#define BMPR3 0xc8 /* BRM Modulator Register 3 */
71#define BMPR4 0xcc /* BRM Modulator Register 4 */
72#define UTS 0xd0 /* UART Test Register */
73
74/* UART Control Register Bit Fields.*/
75#define URXD_CHARRDY (1<<15)
76#define URXD_ERR (1<<14)
77#define URXD_OVRRUN (1<<13)
78#define URXD_FRMERR (1<<12)
79#define URXD_BRK (1<<11)
80#define URXD_PRERR (1<<10)
81#define UCR1_ADEN (1<<15) /* Auto dectect interrupt */
82#define UCR1_ADBR (1<<14) /* Auto detect baud rate */
83#define UCR1_TRDYEN (1<<13) /* Transmitter ready interrupt enable */
84#define UCR1_IDEN (1<<12) /* Idle condition interrupt */
85#define UCR1_RRDYEN (1<<9) /* Recv ready interrupt enable */
86#define UCR1_RDMAEN (1<<8) /* Recv ready DMA enable */
87#define UCR1_IREN (1<<7) /* Infrared interface enable */
88#define UCR1_TXMPTYEN (1<<6) /* Transimitter empty interrupt enable */
89#define UCR1_RTSDEN (1<<5) /* RTS delta interrupt enable */
90#define UCR1_SNDBRK (1<<4) /* Send break */
91#define UCR1_TDMAEN (1<<3) /* Transmitter ready DMA enable */
92#define UCR1_UARTCLKEN (1<<2) /* UART clock enabled */
93#define UCR1_DOZE (1<<1) /* Doze */
94#define UCR1_UARTEN (1<<0) /* UART enabled */
95#define UCR2_ESCI (1<<15) /* Escape seq interrupt enable */
96#define UCR2_IRTS (1<<14) /* Ignore RTS pin */
97#define UCR2_CTSC (1<<13) /* CTS pin control */
98#define UCR2_CTS (1<<12) /* Clear to send */
99#define UCR2_ESCEN (1<<11) /* Escape enable */
100#define UCR2_PREN (1<<8) /* Parity enable */
101#define UCR2_PROE (1<<7) /* Parity odd/even */
102#define UCR2_STPB (1<<6) /* Stop */
103#define UCR2_WS (1<<5) /* Word size */
104#define UCR2_RTSEN (1<<4) /* Request to send interrupt enable */
105#define UCR2_TXEN (1<<2) /* Transmitter enabled */
106#define UCR2_RXEN (1<<1) /* Receiver enabled */
107#define UCR2_SRST (1<<0) /* SW reset */
108#define UCR3_DTREN (1<<13) /* DTR interrupt enable */
109#define UCR3_PARERREN (1<<12) /* Parity enable */
110#define UCR3_FRAERREN (1<<11) /* Frame error interrupt enable */
111#define UCR3_DSR (1<<10) /* Data set ready */
112#define UCR3_DCD (1<<9) /* Data carrier detect */
113#define UCR3_RI (1<<8) /* Ring indicator */
114#define UCR3_TIMEOUTEN (1<<7) /* Timeout interrupt enable */
115#define UCR3_RXDSEN (1<<6) /* Receive status interrupt enable */
116#define UCR3_AIRINTEN (1<<5) /* Async IR wake interrupt enable */
117#define UCR3_AWAKEN (1<<4) /* Async wake interrupt enable */
118#define UCR3_REF25 (1<<3) /* Ref freq 25 MHz */
119#define UCR3_REF30 (1<<2) /* Ref Freq 30 MHz */
120#define UCR3_INVT (1<<1) /* Inverted Infrared transmission */
121#define UCR3_BPEN (1<<0) /* Preset registers enable */
122#define UCR4_CTSTL_32 (32<<10) /* CTS trigger level (32 chars) */
123#define UCR4_INVR (1<<9) /* Inverted infrared reception */
124#define UCR4_ENIRI (1<<8) /* Serial infrared interrupt enable */
125#define UCR4_WKEN (1<<7) /* Wake interrupt enable */
126#define UCR4_REF16 (1<<6) /* Ref freq 16 MHz */
127#define UCR4_IRSC (1<<5) /* IR special case */
128#define UCR4_TCEN (1<<3) /* Transmit complete interrupt enable */
129#define UCR4_BKEN (1<<2) /* Break condition interrupt enable */
130#define UCR4_OREN (1<<1) /* Receiver overrun interrupt enable */
131#define UCR4_DREN (1<<0) /* Recv data ready interrupt enable */
132#define UFCR_RXTL_SHF 0 /* Receiver trigger level shift */
133#define UFCR_RFDIV (7<<7) /* Reference freq divider mask */
134#define UFCR_TXTL_SHF 10 /* Transmitter trigger level shift */
135#define USR1_PARITYERR (1<<15) /* Parity error interrupt flag */
136#define USR1_RTSS (1<<14) /* RTS pin status */
137#define USR1_TRDY (1<<13) /* Transmitter ready interrupt/dma flag */
138#define USR1_RTSD (1<<12) /* RTS delta */
139#define USR1_ESCF (1<<11) /* Escape seq interrupt flag */
140#define USR1_FRAMERR (1<<10) /* Frame error interrupt flag */
141#define USR1_RRDY (1<<9) /* Receiver ready interrupt/dma flag */
142#define USR1_TIMEOUT (1<<7) /* Receive timeout interrupt status */
143#define USR1_RXDS (1<<6) /* Receiver idle interrupt flag */
144#define USR1_AIRINT (1<<5) /* Async IR wake interrupt flag */
145#define USR1_AWAKE (1<<4) /* Aysnc wake interrupt flag */
146#define USR2_ADET (1<<15) /* Auto baud rate detect complete */
147#define USR2_TXFE (1<<14) /* Transmit buffer FIFO empty */
148#define USR2_DTRF (1<<13) /* DTR edge interrupt flag */
149#define USR2_IDLE (1<<12) /* Idle condition */
150#define USR2_IRINT (1<<8) /* Serial infrared interrupt flag */
151#define USR2_WAKE (1<<7) /* Wake */
152#define USR2_RTSF (1<<4) /* RTS edge interrupt flag */
153#define USR2_TXDC (1<<3) /* Transmitter complete */
154#define USR2_BRCD (1<<2) /* Break condition */
155#define USR2_ORE (1<<1) /* Overrun error */
156#define USR2_RDR (1<<0) /* Recv data ready */
157#define UTS_FRCPERR (1<<13) /* Force parity error */
158#define UTS_LOOP (1<<12) /* Loop tx and rx */
159#define UTS_TXEMPTY (1<<6) /* TxFIFO empty */
160#define UTS_RXEMPTY (1<<5) /* RxFIFO empty */
161#define UTS_TXFULL (1<<4) /* TxFIFO full */
162#define UTS_RXFULL (1<<3) /* RxFIFO full */
163#define UTS_SOFTRST (1<<0) /* Software reset */
164
49/* We've been assigned a range on the "Low-density serial ports" major */ 165/* We've been assigned a range on the "Low-density serial ports" major */
50#define SERIAL_IMX_MAJOR 204 166#define SERIAL_IMX_MAJOR 204
51#define MINOR_START 41 167#define MINOR_START 41
@@ -128,7 +244,10 @@ static void imx_timeout(unsigned long data)
128static void imx_stop_tx(struct uart_port *port) 244static void imx_stop_tx(struct uart_port *port)
129{ 245{
130 struct imx_port *sport = (struct imx_port *)port; 246 struct imx_port *sport = (struct imx_port *)port;
131 UCR1((u32)sport->port.membase) &= ~UCR1_TXMPTYEN; 247 unsigned long temp;
248
249 temp = readl(sport->port.membase + UCR1);
250 writel(temp & ~UCR1_TXMPTYEN, sport->port.membase + UCR1);
132} 251}
133 252
134/* 253/*
@@ -137,7 +256,10 @@ static void imx_stop_tx(struct uart_port *port)
137static void imx_stop_rx(struct uart_port *port) 256static void imx_stop_rx(struct uart_port *port)
138{ 257{
139 struct imx_port *sport = (struct imx_port *)port; 258 struct imx_port *sport = (struct imx_port *)port;
140 UCR2((u32)sport->port.membase) &= ~UCR2_RXEN; 259 unsigned long temp;
260
261 temp = readl(sport->port.membase + UCR2);
262 writel(temp &~ UCR2_RXEN, sport->port.membase + UCR2);
141} 263}
142 264
143/* 265/*
@@ -154,10 +276,10 @@ static inline void imx_transmit_buffer(struct imx_port *sport)
154{ 276{
155 struct circ_buf *xmit = &sport->port.info->xmit; 277 struct circ_buf *xmit = &sport->port.info->xmit;
156 278
157 while (!(UTS((u32)sport->port.membase) & UTS_TXFULL)) { 279 while (!(readl(sport->port.membase + UTS) & UTS_TXFULL)) {
158 /* send xmit->buf[xmit->tail] 280 /* send xmit->buf[xmit->tail]
159 * out the port here */ 281 * out the port here */
160 URTX0((u32)sport->port.membase) = xmit->buf[xmit->tail]; 282 writel(xmit->buf[xmit->tail], sport->port.membase + URTX0);
161 xmit->tail = (xmit->tail + 1) & 283 xmit->tail = (xmit->tail + 1) &
162 (UART_XMIT_SIZE - 1); 284 (UART_XMIT_SIZE - 1);
163 sport->port.icount.tx++; 285 sport->port.icount.tx++;
@@ -175,21 +297,24 @@ static inline void imx_transmit_buffer(struct imx_port *sport)
175static void imx_start_tx(struct uart_port *port) 297static void imx_start_tx(struct uart_port *port)
176{ 298{
177 struct imx_port *sport = (struct imx_port *)port; 299 struct imx_port *sport = (struct imx_port *)port;
300 unsigned long temp;
178 301
179 UCR1((u32)sport->port.membase) |= UCR1_TXMPTYEN; 302 temp = readl(sport->port.membase + UCR1);
303 writel(temp | UCR1_TXMPTYEN, sport->port.membase + UCR1);
180 304
181 imx_transmit_buffer(sport); 305 if (readl(sport->port.membase + UTS) & UTS_TXEMPTY)
306 imx_transmit_buffer(sport);
182} 307}
183 308
184static irqreturn_t imx_rtsint(int irq, void *dev_id) 309static irqreturn_t imx_rtsint(int irq, void *dev_id)
185{ 310{
186 struct imx_port *sport = (struct imx_port *)dev_id; 311 struct imx_port *sport = (struct imx_port *)dev_id;
187 unsigned int val = USR1((u32)sport->port.membase)&USR1_RTSS; 312 unsigned int val = readl(sport->port.membase + USR1) & USR1_RTSS;
188 unsigned long flags; 313 unsigned long flags;
189 314
190 spin_lock_irqsave(&sport->port.lock, flags); 315 spin_lock_irqsave(&sport->port.lock, flags);
191 316
192 USR1((u32)sport->port.membase) = USR1_RTSD; 317 writel(USR1_RTSD, sport->port.membase + USR1);
193 uart_handle_cts_change(&sport->port, !!val); 318 uart_handle_cts_change(&sport->port, !!val);
194 wake_up_interruptible(&sport->port.info->delta_msr_wait); 319 wake_up_interruptible(&sport->port.info->delta_msr_wait);
195 320
@@ -207,7 +332,7 @@ static irqreturn_t imx_txint(int irq, void *dev_id)
207 if (sport->port.x_char) 332 if (sport->port.x_char)
208 { 333 {
209 /* Send next char */ 334 /* Send next char */
210 URTX0((u32)sport->port.membase) = sport->port.x_char; 335 writel(sport->port.x_char, sport->port.membase + URTX0);
211 goto out; 336 goto out;
212 } 337 }
213 338
@@ -231,17 +356,18 @@ static irqreturn_t imx_rxint(int irq, void *dev_id)
231 struct imx_port *sport = dev_id; 356 struct imx_port *sport = dev_id;
232 unsigned int rx,flg,ignored = 0; 357 unsigned int rx,flg,ignored = 0;
233 struct tty_struct *tty = sport->port.info->tty; 358 struct tty_struct *tty = sport->port.info->tty;
234 unsigned long flags; 359 unsigned long flags, temp;
235 360
236 rx = URXD0((u32)sport->port.membase); 361 rx = readl(sport->port.membase + URXD0);
237 spin_lock_irqsave(&sport->port.lock,flags); 362 spin_lock_irqsave(&sport->port.lock,flags);
238 363
239 do { 364 do {
240 flg = TTY_NORMAL; 365 flg = TTY_NORMAL;
241 sport->port.icount.rx++; 366 sport->port.icount.rx++;
242 367
243 if( USR2((u32)sport->port.membase) & USR2_BRCD ) { 368 temp = readl(sport->port.membase + USR2);
244 USR2((u32)sport->port.membase) |= USR2_BRCD; 369 if( temp & USR2_BRCD ) {
370 writel(temp | USR2_BRCD, sport->port.membase + USR2);
245 if(uart_handle_break(&sport->port)) 371 if(uart_handle_break(&sport->port))
246 goto ignore_char; 372 goto ignore_char;
247 } 373 }
@@ -257,7 +383,7 @@ static irqreturn_t imx_rxint(int irq, void *dev_id)
257 tty_insert_flip_char(tty, rx, flg); 383 tty_insert_flip_char(tty, rx, flg);
258 384
259 ignore_char: 385 ignore_char:
260 rx = URXD0((u32)sport->port.membase); 386 rx = readl(sport->port.membase + URXD0);
261 } while(rx & URXD_CHARRDY); 387 } while(rx & URXD_CHARRDY);
262 388
263out: 389out:
@@ -301,7 +427,7 @@ static unsigned int imx_tx_empty(struct uart_port *port)
301{ 427{
302 struct imx_port *sport = (struct imx_port *)port; 428 struct imx_port *sport = (struct imx_port *)port;
303 429
304 return USR2((u32)sport->port.membase) & USR2_TXDC ? TIOCSER_TEMT : 0; 430 return (readl(sport->port.membase + USR2) & USR2_TXDC) ? TIOCSER_TEMT : 0;
305} 431}
306 432
307/* 433/*
@@ -312,10 +438,10 @@ static unsigned int imx_get_mctrl(struct uart_port *port)
312 struct imx_port *sport = (struct imx_port *)port; 438 struct imx_port *sport = (struct imx_port *)port;
313 unsigned int tmp = TIOCM_DSR | TIOCM_CAR; 439 unsigned int tmp = TIOCM_DSR | TIOCM_CAR;
314 440
315 if (USR1((u32)sport->port.membase) & USR1_RTSS) 441 if (readl(sport->port.membase + USR1) & USR1_RTSS)
316 tmp |= TIOCM_CTS; 442 tmp |= TIOCM_CTS;
317 443
318 if (UCR2((u32)sport->port.membase) & UCR2_CTS) 444 if (readl(sport->port.membase + UCR2) & UCR2_CTS)
319 tmp |= TIOCM_RTS; 445 tmp |= TIOCM_RTS;
320 446
321 return tmp; 447 return tmp;
@@ -324,11 +450,14 @@ static unsigned int imx_get_mctrl(struct uart_port *port)
324static void imx_set_mctrl(struct uart_port *port, unsigned int mctrl) 450static void imx_set_mctrl(struct uart_port *port, unsigned int mctrl)
325{ 451{
326 struct imx_port *sport = (struct imx_port *)port; 452 struct imx_port *sport = (struct imx_port *)port;
453 unsigned long temp;
454
455 temp = readl(sport->port.membase + UCR2) & ~UCR2_CTS;
327 456
328 if (mctrl & TIOCM_RTS) 457 if (mctrl & TIOCM_RTS)
329 UCR2((u32)sport->port.membase) |= UCR2_CTS; 458 temp |= UCR2_CTS;
330 else 459
331 UCR2((u32)sport->port.membase) &= ~UCR2_CTS; 460 writel(temp, sport->port.membase + UCR2);
332} 461}
333 462
334/* 463/*
@@ -337,14 +466,16 @@ static void imx_set_mctrl(struct uart_port *port, unsigned int mctrl)
337static void imx_break_ctl(struct uart_port *port, int break_state) 466static void imx_break_ctl(struct uart_port *port, int break_state)
338{ 467{
339 struct imx_port *sport = (struct imx_port *)port; 468 struct imx_port *sport = (struct imx_port *)port;
340 unsigned long flags; 469 unsigned long flags, temp;
341 470
342 spin_lock_irqsave(&sport->port.lock, flags); 471 spin_lock_irqsave(&sport->port.lock, flags);
343 472
473 temp = readl(sport->port.membase + UCR1) & ~UCR1_SNDBRK;
474
344 if ( break_state != 0 ) 475 if ( break_state != 0 )
345 UCR1((u32)sport->port.membase) |= UCR1_SNDBRK; 476 temp |= UCR1_SNDBRK;
346 else 477
347 UCR1((u32)sport->port.membase) &= ~UCR1_SNDBRK; 478 writel(temp, sport->port.membase + UCR1);
348 479
349 spin_unlock_irqrestore(&sport->port.lock, flags); 480 spin_unlock_irqrestore(&sport->port.lock, flags);
350} 481}
@@ -360,7 +491,7 @@ static int imx_setup_ufcr(struct imx_port *sport, unsigned int mode)
360 /* set receiver / transmitter trigger level. 491 /* set receiver / transmitter trigger level.
361 * RFDIV is set such way to satisfy requested uartclk value 492 * RFDIV is set such way to satisfy requested uartclk value
362 */ 493 */
363 val = TXTL<<10 | RXTL; 494 val = TXTL << 10 | RXTL;
364 ufcr_rfdiv = (imx_get_perclk1() + sport->port.uartclk / 2) / sport->port.uartclk; 495 ufcr_rfdiv = (imx_get_perclk1() + sport->port.uartclk / 2) / sport->port.uartclk;
365 496
366 if(!ufcr_rfdiv) 497 if(!ufcr_rfdiv)
@@ -373,7 +504,7 @@ static int imx_setup_ufcr(struct imx_port *sport, unsigned int mode)
373 504
374 val |= UFCR_RFDIV & (ufcr_rfdiv << 7); 505 val |= UFCR_RFDIV & (ufcr_rfdiv << 7);
375 506
376 UFCR((u32)sport->port.membase) = val; 507 writel(val, sport->port.membase + UFCR);
377 508
378 return 0; 509 return 0;
379} 510}
@@ -382,14 +513,15 @@ static int imx_startup(struct uart_port *port)
382{ 513{
383 struct imx_port *sport = (struct imx_port *)port; 514 struct imx_port *sport = (struct imx_port *)port;
384 int retval; 515 int retval;
385 unsigned long flags; 516 unsigned long flags, temp;
386 517
387 imx_setup_ufcr(sport, 0); 518 imx_setup_ufcr(sport, 0);
388 519
389 /* disable the DREN bit (Data Ready interrupt enable) before 520 /* disable the DREN bit (Data Ready interrupt enable) before
390 * requesting IRQs 521 * requesting IRQs
391 */ 522 */
392 UCR4((u32)sport->port.membase) &= ~UCR4_DREN; 523 temp = readl(sport->port.membase + UCR4);
524 writel(temp & ~UCR4_DREN, sport->port.membase + UCR4);
393 525
394 /* 526 /*
395 * Allocate the IRQ 527 * Allocate the IRQ
@@ -411,12 +543,16 @@ static int imx_startup(struct uart_port *port)
411 /* 543 /*
412 * Finally, clear and enable interrupts 544 * Finally, clear and enable interrupts
413 */ 545 */
546 writel(USR1_RTSD, sport->port.membase + USR1);
547
548 temp = readl(sport->port.membase + UCR1);
549 temp |= (UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN | UCR1_UARTEN);
550 writel(temp, sport->port.membase + UCR1);
414 551
415 USR1((u32)sport->port.membase) = USR1_RTSD; 552 temp = readl(sport->port.membase + UCR2);
416 UCR1((u32)sport->port.membase) |= 553 temp |= (UCR2_RXEN | UCR2_TXEN);
417 (UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN | UCR1_UARTEN); 554 writel(temp, sport->port.membase + UCR2);
418 555
419 UCR2((u32)sport->port.membase) |= (UCR2_RXEN | UCR2_TXEN);
420 /* 556 /*
421 * Enable modem status interrupts 557 * Enable modem status interrupts
422 */ 558 */
@@ -437,6 +573,7 @@ error_out1:
437static void imx_shutdown(struct uart_port *port) 573static void imx_shutdown(struct uart_port *port)
438{ 574{
439 struct imx_port *sport = (struct imx_port *)port; 575 struct imx_port *sport = (struct imx_port *)port;
576 unsigned long temp;
440 577
441 /* 578 /*
442 * Stop our timer. 579 * Stop our timer.
@@ -454,8 +591,9 @@ static void imx_shutdown(struct uart_port *port)
454 * Disable all interrupts, port and break condition. 591 * Disable all interrupts, port and break condition.
455 */ 592 */
456 593
457 UCR1((u32)sport->port.membase) &= 594 temp = readl(sport->port.membase + UCR1);
458 ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN | UCR1_UARTEN); 595 temp &= ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN | UCR1_UARTEN);
596 writel(temp, sport->port.membase + UCR1);
459} 597}
460 598
461static void 599static void
@@ -548,18 +686,18 @@ imx_set_termios(struct uart_port *port, struct ktermios *termios,
548 /* 686 /*
549 * disable interrupts and drain transmitter 687 * disable interrupts and drain transmitter
550 */ 688 */
551 old_ucr1 = UCR1((u32)sport->port.membase); 689 old_ucr1 = readl(sport->port.membase + UCR1);
552 UCR1((u32)sport->port.membase) &= ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN); 690 writel(old_ucr1 & ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN),
691 sport->port.membase + UCR1);
553 692
554 while ( !(USR2((u32)sport->port.membase) & USR2_TXDC)) 693 while ( !(readl(sport->port.membase + USR2) & USR2_TXDC))
555 barrier(); 694 barrier();
556 695
557 /* then, disable everything */ 696 /* then, disable everything */
558 old_txrxen = UCR2((u32)sport->port.membase) & ( UCR2_TXEN | UCR2_RXEN ); 697 old_txrxen = readl(sport->port.membase + UCR2);
559 UCR2((u32)sport->port.membase) &= ~( UCR2_TXEN | UCR2_RXEN); 698 writel(old_txrxen & ~( UCR2_TXEN | UCR2_RXEN),
560 699 sport->port.membase + UCR2);
561 /* set the parity, stop bits and data size */ 700 old_txrxen &= (UCR2_TXEN | UCR2_RXEN);
562 UCR2((u32)sport->port.membase) = ucr2;
563 701
564 /* set the baud rate. We assume uartclk = 16 MHz 702 /* set the baud rate. We assume uartclk = 16 MHz
565 * 703 *
@@ -567,11 +705,13 @@ imx_set_termios(struct uart_port *port, struct ktermios *termios,
567 * --------- = -------- 705 * --------- = --------
568 * uartclk UBMR - 1 706 * uartclk UBMR - 1
569 */ 707 */
570 UBIR((u32)sport->port.membase) = (baud / 100) - 1; 708 writel((baud / 100) - 1, sport->port.membase + UBIR);
571 UBMR((u32)sport->port.membase) = 10000 - 1; 709 writel(10000 - 1, sport->port.membase + UBMR);
710
711 writel(old_ucr1, sport->port.membase + UCR1);
572 712
573 UCR1((u32)sport->port.membase) = old_ucr1; 713 /* set the parity, stop bits and data size */
574 UCR2((u32)sport->port.membase) |= old_txrxen; 714 writel(ucr2 | old_txrxen, sport->port.membase + UCR2);
575 715
576 if (UART_ENABLE_MS(&sport->port, termios->c_cflag)) 716 if (UART_ENABLE_MS(&sport->port, termios->c_cflag))
577 imx_enable_ms(&sport->port); 717 imx_enable_ms(&sport->port);
@@ -730,9 +870,11 @@ static void __init imx_init_ports(void)
730static void imx_console_putchar(struct uart_port *port, int ch) 870static void imx_console_putchar(struct uart_port *port, int ch)
731{ 871{
732 struct imx_port *sport = (struct imx_port *)port; 872 struct imx_port *sport = (struct imx_port *)port;
733 while ((UTS((u32)sport->port.membase) & UTS_TXFULL)) 873
874 while (readl(sport->port.membase + UTS) & UTS_TXFULL)
734 barrier(); 875 barrier();
735 URTX0((u32)sport->port.membase) = ch; 876
877 writel(ch, sport->port.membase + URTX0);
736} 878}
737 879
738/* 880/*
@@ -747,13 +889,14 @@ imx_console_write(struct console *co, const char *s, unsigned int count)
747 /* 889 /*
748 * First, save UCR1/2 and then disable interrupts 890 * First, save UCR1/2 and then disable interrupts
749 */ 891 */
750 old_ucr1 = UCR1((u32)sport->port.membase); 892 old_ucr1 = readl(sport->port.membase + UCR1);
751 old_ucr2 = UCR2((u32)sport->port.membase); 893 old_ucr2 = readl(sport->port.membase + UCR2);
752 894
753 UCR1((u32)sport->port.membase) = 895 writel((old_ucr1 | UCR1_UARTCLKEN | UCR1_UARTEN) &
754 (old_ucr1 | UCR1_UARTCLKEN | UCR1_UARTEN) 896 ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN),
755 & ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN); 897 sport->port.membase + UCR1);
756 UCR2((u32)sport->port.membase) = old_ucr2 | UCR2_TXEN; 898
899 writel(old_ucr2 | UCR2_TXEN, sport->port.membase + UCR2);
757 900
758 uart_console_write(&sport->port, s, count, imx_console_putchar); 901 uart_console_write(&sport->port, s, count, imx_console_putchar);
759 902
@@ -761,10 +904,10 @@ imx_console_write(struct console *co, const char *s, unsigned int count)
761 * Finally, wait for transmitter to become empty 904 * Finally, wait for transmitter to become empty
762 * and restore UCR1/2 905 * and restore UCR1/2
763 */ 906 */
764 while (!(USR2((u32)sport->port.membase) & USR2_TXDC)); 907 while (!(readl(sport->port.membase + USR2) & USR2_TXDC));
765 908
766 UCR1((u32)sport->port.membase) = old_ucr1; 909 writel(old_ucr1, sport->port.membase + UCR1);
767 UCR2((u32)sport->port.membase) = old_ucr2; 910 writel(old_ucr2, sport->port.membase + UCR2);
768} 911}
769 912
770/* 913/*
@@ -776,13 +919,13 @@ imx_console_get_options(struct imx_port *sport, int *baud,
776 int *parity, int *bits) 919 int *parity, int *bits)
777{ 920{
778 921
779 if ( UCR1((u32)sport->port.membase) | UCR1_UARTEN ) { 922 if ( readl(sport->port.membase + UCR1) | UCR1_UARTEN ) {
780 /* ok, the port was enabled */ 923 /* ok, the port was enabled */
781 unsigned int ucr2, ubir,ubmr, uartclk; 924 unsigned int ucr2, ubir,ubmr, uartclk;
782 unsigned int baud_raw; 925 unsigned int baud_raw;
783 unsigned int ucfr_rfdiv; 926 unsigned int ucfr_rfdiv;
784 927
785 ucr2 = UCR2((u32)sport->port.membase); 928 ucr2 = readl(sport->port.membase + UCR2);
786 929
787 *parity = 'n'; 930 *parity = 'n';
788 if (ucr2 & UCR2_PREN) { 931 if (ucr2 & UCR2_PREN) {
@@ -797,11 +940,10 @@ imx_console_get_options(struct imx_port *sport, int *baud,
797 else 940 else
798 *bits = 7; 941 *bits = 7;
799 942
800 ubir = UBIR((u32)sport->port.membase) & 0xffff; 943 ubir = readl(sport->port.membase + UBIR) & 0xffff;
801 ubmr = UBMR((u32)sport->port.membase) & 0xffff; 944 ubmr = readl(sport->port.membase + UBMR) & 0xffff;
802
803 945
804 ucfr_rfdiv = (UFCR((u32)sport->port.membase) & UFCR_RFDIV) >> 7; 946 ucfr_rfdiv = (readl(sport->port.membase + UFCR) & UFCR_RFDIV) >> 7;
805 if (ucfr_rfdiv == 6) 947 if (ucfr_rfdiv == 6)
806 ucfr_rfdiv = 7; 948 ucfr_rfdiv = 7;
807 else 949 else