aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-09-04 12:13:39 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-09-04 12:14:43 -0400
commitf11c98417c65ddd730c483c1c9290ae0f7b121a7 (patch)
tree69bb89817677284fb5ef6cae4dad9ca8b7d85228
parentab66ca27c801605c6bb19baed2933544dd7d39e6 (diff)
Revert "uart: pl011: Introduce register accessor"
This reverts commit 7b753f318d1456c8e7740f3bd96d1dbb362d5449 as with this patch the serial console is broken on lots of platforms. Reported-by: Marc Zyngier <marc.zyngier@arm.com> Cc: Jun Nie <jun.nie@linaro.org> Acked-by: Will Deacon <will.deacon@arm.com> Tested-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/serial/amba-pl011.c263
1 files changed, 122 insertions, 141 deletions
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 29a291d3bf24..ee57e2bee9a1 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -85,26 +85,23 @@ struct vendor_data {
85 unsigned int (*get_fifosize)(struct amba_device *dev); 85 unsigned int (*get_fifosize)(struct amba_device *dev);
86}; 86};
87 87
88/* Max address offset of register in use is 0x48 */
89#define REG_NR (0x48 >> 2)
90#define IDX(x) (x >> 2)
91enum reg_idx { 88enum reg_idx {
92 REG_DR = IDX(UART01x_DR), 89 REG_DR = UART01x_DR,
93 REG_RSR = IDX(UART01x_RSR), 90 REG_RSR = UART01x_RSR,
94 REG_ST_DMAWM = IDX(ST_UART011_DMAWM), 91 REG_ST_DMAWM = ST_UART011_DMAWM,
95 REG_FR = IDX(UART01x_FR), 92 REG_FR = UART01x_FR,
96 REG_ST_LCRH_RX = IDX(ST_UART011_LCRH_RX), 93 REG_ST_LCRH_RX = ST_UART011_LCRH_RX,
97 REG_ILPR = IDX(UART01x_ILPR), 94 REG_ILPR = UART01x_ILPR,
98 REG_IBRD = IDX(UART011_IBRD), 95 REG_IBRD = UART011_IBRD,
99 REG_FBRD = IDX(UART011_FBRD), 96 REG_FBRD = UART011_FBRD,
100 REG_LCRH = IDX(UART011_LCRH), 97 REG_LCRH = UART011_LCRH,
101 REG_CR = IDX(UART011_CR), 98 REG_CR = UART011_CR,
102 REG_IFLS = IDX(UART011_IFLS), 99 REG_IFLS = UART011_IFLS,
103 REG_IMSC = IDX(UART011_IMSC), 100 REG_IMSC = UART011_IMSC,
104 REG_RIS = IDX(UART011_RIS), 101 REG_RIS = UART011_RIS,
105 REG_MIS = IDX(UART011_MIS), 102 REG_MIS = UART011_MIS,
106 REG_ICR = IDX(UART011_ICR), 103 REG_ICR = UART011_ICR,
107 REG_DMACR = IDX(UART011_DMACR), 104 REG_DMACR = UART011_DMACR,
108}; 105};
109 106
110static unsigned int get_fifosize_arm(struct amba_device *dev) 107static unsigned int get_fifosize_arm(struct amba_device *dev)
@@ -206,24 +203,6 @@ struct uart_amba_port {
206#endif 203#endif
207}; 204};
208 205
209static unsigned int pl011_readw(struct uart_amba_port *uap, int index)
210{
211 WARN_ON(index > REG_NR);
212 return readw_relaxed(uap->port.membase + (index << 2));
213}
214
215static void pl011_writew(struct uart_amba_port *uap, int val, int index)
216{
217 WARN_ON(index > REG_NR);
218 writew_relaxed(val, uap->port.membase + (index << 2));
219}
220
221static void pl011_writeb(struct uart_amba_port *uap, u8 val, int index)
222{
223 WARN_ON(index > REG_NR);
224 writeb_relaxed(val, uap->port.membase + (index << 2));
225}
226
227/* 206/*
228 * Reads up to 256 characters from the FIFO or until it's empty and 207 * Reads up to 256 characters from the FIFO or until it's empty and
229 * inserts them into the TTY layer. Returns the number of characters 208 * inserts them into the TTY layer. Returns the number of characters
@@ -236,12 +215,12 @@ static int pl011_fifo_to_tty(struct uart_amba_port *uap)
236 int fifotaken = 0; 215 int fifotaken = 0;
237 216
238 while (max_count--) { 217 while (max_count--) {
239 status = pl011_readw(uap, REG_FR); 218 status = readw(uap->port.membase + REG_FR);
240 if (status & UART01x_FR_RXFE) 219 if (status & UART01x_FR_RXFE)
241 break; 220 break;
242 221
243 /* Take chars from the FIFO and update status */ 222 /* Take chars from the FIFO and update status */
244 ch = pl011_readw(uap, REG_DR) | 223 ch = readw(uap->port.membase + REG_DR) |
245 UART_DUMMY_DR_RX; 224 UART_DUMMY_DR_RX;
246 flag = TTY_NORMAL; 225 flag = TTY_NORMAL;
247 uap->port.icount.rx++; 226 uap->port.icount.rx++;
@@ -478,7 +457,7 @@ static void pl011_dma_tx_callback(void *data)
478 457
479 dmacr = uap->dmacr; 458 dmacr = uap->dmacr;
480 uap->dmacr = dmacr & ~UART011_TXDMAE; 459 uap->dmacr = dmacr & ~UART011_TXDMAE;
481 pl011_writew(uap, uap->dmacr, REG_DMACR); 460 writew(uap->dmacr, uap->port.membase + REG_DMACR);
482 461
483 /* 462 /*
484 * If TX DMA was disabled, it means that we've stopped the DMA for 463 * If TX DMA was disabled, it means that we've stopped the DMA for
@@ -592,7 +571,7 @@ static int pl011_dma_tx_refill(struct uart_amba_port *uap)
592 dma_dev->device_issue_pending(chan); 571 dma_dev->device_issue_pending(chan);
593 572
594 uap->dmacr |= UART011_TXDMAE; 573 uap->dmacr |= UART011_TXDMAE;
595 pl011_writew(uap, uap->dmacr, REG_DMACR); 574 writew(uap->dmacr, uap->port.membase + REG_DMACR);
596 uap->dmatx.queued = true; 575 uap->dmatx.queued = true;
597 576
598 /* 577 /*
@@ -628,9 +607,9 @@ static bool pl011_dma_tx_irq(struct uart_amba_port *uap)
628 */ 607 */
629 if (uap->dmatx.queued) { 608 if (uap->dmatx.queued) {
630 uap->dmacr |= UART011_TXDMAE; 609 uap->dmacr |= UART011_TXDMAE;
631 pl011_writew(uap, uap->dmacr, REG_DMACR); 610 writew(uap->dmacr, uap->port.membase + REG_DMACR);
632 uap->im &= ~UART011_TXIM; 611 uap->im &= ~UART011_TXIM;
633 pl011_writew(uap, uap->im, REG_IMSC); 612 writew(uap->im, uap->port.membase + REG_IMSC);
634 return true; 613 return true;
635 } 614 }
636 615
@@ -640,7 +619,7 @@ static bool pl011_dma_tx_irq(struct uart_amba_port *uap)
640 */ 619 */
641 if (pl011_dma_tx_refill(uap) > 0) { 620 if (pl011_dma_tx_refill(uap) > 0) {
642 uap->im &= ~UART011_TXIM; 621 uap->im &= ~UART011_TXIM;
643 pl011_writew(uap, uap->im, REG_IMSC); 622 writew(uap->im, uap->port.membase + REG_IMSC);
644 return true; 623 return true;
645 } 624 }
646 return false; 625 return false;
@@ -654,7 +633,7 @@ static inline void pl011_dma_tx_stop(struct uart_amba_port *uap)
654{ 633{
655 if (uap->dmatx.queued) { 634 if (uap->dmatx.queued) {
656 uap->dmacr &= ~UART011_TXDMAE; 635 uap->dmacr &= ~UART011_TXDMAE;
657 pl011_writew(uap, uap->dmacr, REG_DMACR); 636 writew(uap->dmacr, uap->port.membase + REG_DMACR);
658 } 637 }
659} 638}
660 639
@@ -680,12 +659,14 @@ static inline bool pl011_dma_tx_start(struct uart_amba_port *uap)
680 if (!uap->dmatx.queued) { 659 if (!uap->dmatx.queued) {
681 if (pl011_dma_tx_refill(uap) > 0) { 660 if (pl011_dma_tx_refill(uap) > 0) {
682 uap->im &= ~UART011_TXIM; 661 uap->im &= ~UART011_TXIM;
683 pl011_writew(uap, uap->im, REG_IMSC); 662 writew(uap->im, uap->port.membase +
663 REG_IMSC);
684 } else 664 } else
685 ret = false; 665 ret = false;
686 } else if (!(uap->dmacr & UART011_TXDMAE)) { 666 } else if (!(uap->dmacr & UART011_TXDMAE)) {
687 uap->dmacr |= UART011_TXDMAE; 667 uap->dmacr |= UART011_TXDMAE;
688 pl011_writew(uap, uap->dmacr, REG_DMACR); 668 writew(uap->dmacr,
669 uap->port.membase + REG_DMACR);
689 } 670 }
690 return ret; 671 return ret;
691 } 672 }
@@ -696,9 +677,9 @@ static inline bool pl011_dma_tx_start(struct uart_amba_port *uap)
696 */ 677 */
697 dmacr = uap->dmacr; 678 dmacr = uap->dmacr;
698 uap->dmacr &= ~UART011_TXDMAE; 679 uap->dmacr &= ~UART011_TXDMAE;
699 pl011_writew(uap, uap->dmacr, REG_DMACR); 680 writew(uap->dmacr, uap->port.membase + REG_DMACR);
700 681
701 if (pl011_readw(uap, REG_FR) & UART01x_FR_TXFF) { 682 if (readw(uap->port.membase + REG_FR) & UART01x_FR_TXFF) {
702 /* 683 /*
703 * No space in the FIFO, so enable the transmit interrupt 684 * No space in the FIFO, so enable the transmit interrupt
704 * so we know when there is space. Note that once we've 685 * so we know when there is space. Note that once we've
@@ -707,13 +688,13 @@ static inline bool pl011_dma_tx_start(struct uart_amba_port *uap)
707 return false; 688 return false;
708 } 689 }
709 690
710 pl011_writew(uap, uap->port.x_char, REG_DR); 691 writew(uap->port.x_char, uap->port.membase + REG_DR);
711 uap->port.icount.tx++; 692 uap->port.icount.tx++;
712 uap->port.x_char = 0; 693 uap->port.x_char = 0;
713 694
714 /* Success - restore the DMA state */ 695 /* Success - restore the DMA state */
715 uap->dmacr = dmacr; 696 uap->dmacr = dmacr;
716 pl011_writew(uap, dmacr, REG_DMACR); 697 writew(dmacr, uap->port.membase + REG_DMACR);
717 698
718 return true; 699 return true;
719} 700}
@@ -741,7 +722,7 @@ __acquires(&uap->port.lock)
741 DMA_TO_DEVICE); 722 DMA_TO_DEVICE);
742 uap->dmatx.queued = false; 723 uap->dmatx.queued = false;
743 uap->dmacr &= ~UART011_TXDMAE; 724 uap->dmacr &= ~UART011_TXDMAE;
744 pl011_writew(uap, uap->dmacr, REG_DMACR); 725 writew(uap->dmacr, uap->port.membase + REG_DMACR);
745 } 726 }
746} 727}
747 728
@@ -781,11 +762,11 @@ static int pl011_dma_rx_trigger_dma(struct uart_amba_port *uap)
781 dma_async_issue_pending(rxchan); 762 dma_async_issue_pending(rxchan);
782 763
783 uap->dmacr |= UART011_RXDMAE; 764 uap->dmacr |= UART011_RXDMAE;
784 pl011_writew(uap, uap->dmacr, REG_DMACR); 765 writew(uap->dmacr, uap->port.membase + REG_DMACR);
785 uap->dmarx.running = true; 766 uap->dmarx.running = true;
786 767
787 uap->im &= ~UART011_RXIM; 768 uap->im &= ~UART011_RXIM;
788 pl011_writew(uap, uap->im, REG_IMSC); 769 writew(uap->im, uap->port.membase + REG_IMSC);
789 770
790 return 0; 771 return 0;
791} 772}
@@ -843,9 +824,8 @@ static void pl011_dma_rx_chars(struct uart_amba_port *uap,
843 */ 824 */
844 if (dma_count == pending && readfifo) { 825 if (dma_count == pending && readfifo) {
845 /* Clear any error flags */ 826 /* Clear any error flags */
846 pl011_writew(uap, 827 writew(UART011_OEIS | UART011_BEIS | UART011_PEIS | UART011_FEIS,
847 UART011_OEIS | UART011_BEIS | UART011_PEIS 828 uap->port.membase + REG_ICR);
848 | UART011_FEIS, REG_ICR);
849 829
850 /* 830 /*
851 * If we read all the DMA'd characters, and we had an 831 * If we read all the DMA'd characters, and we had an
@@ -893,7 +873,7 @@ static void pl011_dma_rx_irq(struct uart_amba_port *uap)
893 873
894 /* Disable RX DMA - incoming data will wait in the FIFO */ 874 /* Disable RX DMA - incoming data will wait in the FIFO */
895 uap->dmacr &= ~UART011_RXDMAE; 875 uap->dmacr &= ~UART011_RXDMAE;
896 pl011_writew(uap, uap->dmacr, REG_DMACR); 876 writew(uap->dmacr, uap->port.membase + REG_DMACR);
897 uap->dmarx.running = false; 877 uap->dmarx.running = false;
898 878
899 pending = sgbuf->sg.length - state.residue; 879 pending = sgbuf->sg.length - state.residue;
@@ -913,7 +893,7 @@ static void pl011_dma_rx_irq(struct uart_amba_port *uap)
913 dev_dbg(uap->port.dev, "could not retrigger RX DMA job " 893 dev_dbg(uap->port.dev, "could not retrigger RX DMA job "
914 "fall back to interrupt mode\n"); 894 "fall back to interrupt mode\n");
915 uap->im |= UART011_RXIM; 895 uap->im |= UART011_RXIM;
916 pl011_writew(uap, uap->im, REG_IMSC); 896 writew(uap->im, uap->port.membase + REG_IMSC);
917 } 897 }
918} 898}
919 899
@@ -961,7 +941,7 @@ static void pl011_dma_rx_callback(void *data)
961 dev_dbg(uap->port.dev, "could not retrigger RX DMA job " 941 dev_dbg(uap->port.dev, "could not retrigger RX DMA job "
962 "fall back to interrupt mode\n"); 942 "fall back to interrupt mode\n");
963 uap->im |= UART011_RXIM; 943 uap->im |= UART011_RXIM;
964 pl011_writew(uap, uap->im, REG_IMSC); 944 writew(uap->im, uap->port.membase + REG_IMSC);
965 } 945 }
966} 946}
967 947
@@ -974,7 +954,7 @@ static inline void pl011_dma_rx_stop(struct uart_amba_port *uap)
974{ 954{
975 /* FIXME. Just disable the DMA enable */ 955 /* FIXME. Just disable the DMA enable */
976 uap->dmacr &= ~UART011_RXDMAE; 956 uap->dmacr &= ~UART011_RXDMAE;
977 pl011_writew(uap, uap->dmacr, REG_DMACR); 957 writew(uap->dmacr, uap->port.membase + REG_DMACR);
978} 958}
979 959
980/* 960/*
@@ -1018,7 +998,7 @@ static void pl011_dma_rx_poll(unsigned long args)
1018 spin_lock_irqsave(&uap->port.lock, flags); 998 spin_lock_irqsave(&uap->port.lock, flags);
1019 pl011_dma_rx_stop(uap); 999 pl011_dma_rx_stop(uap);
1020 uap->im |= UART011_RXIM; 1000 uap->im |= UART011_RXIM;
1021 pl011_writew(uap, uap->im, REG_IMSC); 1001 writew(uap->im, uap->port.membase + REG_IMSC);
1022 spin_unlock_irqrestore(&uap->port.lock, flags); 1002 spin_unlock_irqrestore(&uap->port.lock, flags);
1023 1003
1024 uap->dmarx.running = false; 1004 uap->dmarx.running = false;
@@ -1080,7 +1060,7 @@ static void pl011_dma_startup(struct uart_amba_port *uap)
1080skip_rx: 1060skip_rx:
1081 /* Turn on DMA error (RX/TX will be enabled on demand) */ 1061 /* Turn on DMA error (RX/TX will be enabled on demand) */
1082 uap->dmacr |= UART011_DMAONERR; 1062 uap->dmacr |= UART011_DMAONERR;
1083 pl011_writew(uap, uap->dmacr, REG_DMACR); 1063 writew(uap->dmacr, uap->port.membase + REG_DMACR);
1084 1064
1085 /* 1065 /*
1086 * ST Micro variants has some specific dma burst threshold 1066 * ST Micro variants has some specific dma burst threshold
@@ -1088,9 +1068,9 @@ skip_rx:
1088 * be issued above/below 16 bytes. 1068 * be issued above/below 16 bytes.
1089 */ 1069 */
1090 if (uap->vendor->dma_threshold) 1070 if (uap->vendor->dma_threshold)
1091 pl011_writew(uap, 1071 writew(ST_UART011_DMAWM_RX_16 | ST_UART011_DMAWM_TX_16,
1092 ST_UART011_DMAWM_RX_16 | ST_UART011_DMAWM_TX_16, 1072 uap->port.membase + REG_ST_DMAWM);
1093 REG_ST_DMAWM); 1073
1094 1074
1095 if (uap->using_rx_dma) { 1075 if (uap->using_rx_dma) {
1096 if (pl011_dma_rx_trigger_dma(uap)) 1076 if (pl011_dma_rx_trigger_dma(uap))
@@ -1115,12 +1095,12 @@ static void pl011_dma_shutdown(struct uart_amba_port *uap)
1115 return; 1095 return;
1116 1096
1117 /* Disable RX and TX DMA */ 1097 /* Disable RX and TX DMA */
1118 while (pl011_readw(uap, REG_FR) & UART01x_FR_BUSY) 1098 while (readw(uap->port.membase + REG_FR) & UART01x_FR_BUSY)
1119 barrier(); 1099 barrier();
1120 1100
1121 spin_lock_irq(&uap->port.lock); 1101 spin_lock_irq(&uap->port.lock);
1122 uap->dmacr &= ~(UART011_DMAONERR | UART011_RXDMAE | UART011_TXDMAE); 1102 uap->dmacr &= ~(UART011_DMAONERR | UART011_RXDMAE | UART011_TXDMAE);
1123 pl011_writew(uap, uap->dmacr, REG_DMACR); 1103 writew(uap->dmacr, uap->port.membase + REG_DMACR);
1124 spin_unlock_irq(&uap->port.lock); 1104 spin_unlock_irq(&uap->port.lock);
1125 1105
1126 if (uap->using_tx_dma) { 1106 if (uap->using_tx_dma) {
@@ -1221,7 +1201,7 @@ static void pl011_stop_tx(struct uart_port *port)
1221 container_of(port, struct uart_amba_port, port); 1201 container_of(port, struct uart_amba_port, port);
1222 1202
1223 uap->im &= ~UART011_TXIM; 1203 uap->im &= ~UART011_TXIM;
1224 pl011_writew(uap, uap->im, REG_IMSC); 1204 writew(uap->im, uap->port.membase + REG_IMSC);
1225 pl011_dma_tx_stop(uap); 1205 pl011_dma_tx_stop(uap);
1226} 1206}
1227 1207
@@ -1231,7 +1211,7 @@ static void pl011_tx_chars(struct uart_amba_port *uap, bool from_irq);
1231static void pl011_start_tx_pio(struct uart_amba_port *uap) 1211static void pl011_start_tx_pio(struct uart_amba_port *uap)
1232{ 1212{
1233 uap->im |= UART011_TXIM; 1213 uap->im |= UART011_TXIM;
1234 pl011_writew(uap, uap->im, REG_IMSC); 1214 writew(uap->im, uap->port.membase + REG_IMSC);
1235 pl011_tx_chars(uap, false); 1215 pl011_tx_chars(uap, false);
1236} 1216}
1237 1217
@@ -1251,7 +1231,7 @@ static void pl011_stop_rx(struct uart_port *port)
1251 1231
1252 uap->im &= ~(UART011_RXIM|UART011_RTIM|UART011_FEIM| 1232 uap->im &= ~(UART011_RXIM|UART011_RTIM|UART011_FEIM|
1253 UART011_PEIM|UART011_BEIM|UART011_OEIM); 1233 UART011_PEIM|UART011_BEIM|UART011_OEIM);
1254 pl011_writew(uap, uap->im, REG_IMSC); 1234 writew(uap->im, uap->port.membase + REG_IMSC);
1255 1235
1256 pl011_dma_rx_stop(uap); 1236 pl011_dma_rx_stop(uap);
1257} 1237}
@@ -1262,7 +1242,7 @@ static void pl011_enable_ms(struct uart_port *port)
1262 container_of(port, struct uart_amba_port, port); 1242 container_of(port, struct uart_amba_port, port);
1263 1243
1264 uap->im |= UART011_RIMIM|UART011_CTSMIM|UART011_DCDMIM|UART011_DSRMIM; 1244 uap->im |= UART011_RIMIM|UART011_CTSMIM|UART011_DCDMIM|UART011_DSRMIM;
1265 pl011_writew(uap, uap->im, REG_IMSC); 1245 writew(uap->im, uap->port.membase + REG_IMSC);
1266} 1246}
1267 1247
1268static void pl011_rx_chars(struct uart_amba_port *uap) 1248static void pl011_rx_chars(struct uart_amba_port *uap)
@@ -1282,7 +1262,7 @@ __acquires(&uap->port.lock)
1282 dev_dbg(uap->port.dev, "could not trigger RX DMA job " 1262 dev_dbg(uap->port.dev, "could not trigger RX DMA job "
1283 "fall back to interrupt mode again\n"); 1263 "fall back to interrupt mode again\n");
1284 uap->im |= UART011_RXIM; 1264 uap->im |= UART011_RXIM;
1285 pl011_writew(uap, uap->im, REG_IMSC); 1265 writew(uap->im, uap->port.membase + REG_IMSC);
1286 } else { 1266 } else {
1287#ifdef CONFIG_DMA_ENGINE 1267#ifdef CONFIG_DMA_ENGINE
1288 /* Start Rx DMA poll */ 1268 /* Start Rx DMA poll */
@@ -1303,10 +1283,10 @@ static bool pl011_tx_char(struct uart_amba_port *uap, unsigned char c,
1303 bool from_irq) 1283 bool from_irq)
1304{ 1284{
1305 if (unlikely(!from_irq) && 1285 if (unlikely(!from_irq) &&
1306 pl011_readw(uap, REG_FR) & UART01x_FR_TXFF) 1286 readw(uap->port.membase + REG_FR) & UART01x_FR_TXFF)
1307 return false; /* unable to transmit character */ 1287 return false; /* unable to transmit character */
1308 1288
1309 pl011_writew(uap, c, REG_DR); 1289 writew(c, uap->port.membase + REG_DR);
1310 uap->port.icount.tx++; 1290 uap->port.icount.tx++;
1311 1291
1312 return true; 1292 return true;
@@ -1353,7 +1333,7 @@ static void pl011_modem_status(struct uart_amba_port *uap)
1353{ 1333{
1354 unsigned int status, delta; 1334 unsigned int status, delta;
1355 1335
1356 status = pl011_readw(uap, REG_FR) & UART01x_FR_MODEM_ANY; 1336 status = readw(uap->port.membase + REG_FR) & UART01x_FR_MODEM_ANY;
1357 1337
1358 delta = status ^ uap->old_status; 1338 delta = status ^ uap->old_status;
1359 uap->old_status = status; 1339 uap->old_status = status;
@@ -1381,15 +1361,15 @@ static void check_apply_cts_event_workaround(struct uart_amba_port *uap)
1381 return; 1361 return;
1382 1362
1383 /* workaround to make sure that all bits are unlocked.. */ 1363 /* workaround to make sure that all bits are unlocked.. */
1384 pl011_writew(uap, 0x00, REG_ICR); 1364 writew(0x00, uap->port.membase + REG_ICR);
1385 1365
1386 /* 1366 /*
1387 * WA: introduce 26ns(1 uart clk) delay before W1C; 1367 * WA: introduce 26ns(1 uart clk) delay before W1C;
1388 * single apb access will incur 2 pclk(133.12Mhz) delay, 1368 * single apb access will incur 2 pclk(133.12Mhz) delay,
1389 * so add 2 dummy reads 1369 * so add 2 dummy reads
1390 */ 1370 */
1391 dummy_read = pl011_readw(uap, REG_ICR); 1371 dummy_read = readw(uap->port.membase + REG_ICR);
1392 dummy_read = pl011_readw(uap, REG_ICR); 1372 dummy_read = readw(uap->port.membase + REG_ICR);
1393} 1373}
1394 1374
1395static irqreturn_t pl011_int(int irq, void *dev_id) 1375static irqreturn_t pl011_int(int irq, void *dev_id)
@@ -1401,13 +1381,15 @@ static irqreturn_t pl011_int(int irq, void *dev_id)
1401 int handled = 0; 1381 int handled = 0;
1402 1382
1403 spin_lock_irqsave(&uap->port.lock, flags); 1383 spin_lock_irqsave(&uap->port.lock, flags);
1404 imsc = pl011_readw(uap, REG_IMSC); 1384 imsc = readw(uap->port.membase + REG_IMSC);
1405 status = pl011_readw(uap, REG_RIS) & imsc; 1385 status = readw(uap->port.membase + REG_RIS) & imsc;
1406 if (status) { 1386 if (status) {
1407 do { 1387 do {
1408 check_apply_cts_event_workaround(uap); 1388 check_apply_cts_event_workaround(uap);
1409 pl011_writew(uap, status & ~(UART011_TXIS|UART011_RTIS| 1389
1410 UART011_RXIS), REG_ICR); 1390 writew(status & ~(UART011_TXIS|UART011_RTIS|
1391 UART011_RXIS),
1392 uap->port.membase + REG_ICR);
1411 1393
1412 if (status & (UART011_RTIS|UART011_RXIS)) { 1394 if (status & (UART011_RTIS|UART011_RXIS)) {
1413 if (pl011_dma_rx_running(uap)) 1395 if (pl011_dma_rx_running(uap))
@@ -1424,7 +1406,7 @@ static irqreturn_t pl011_int(int irq, void *dev_id)
1424 if (pass_counter-- == 0) 1406 if (pass_counter-- == 0)
1425 break; 1407 break;
1426 1408
1427 status = pl011_readw(uap, REG_RIS) & imsc; 1409 status = readw(uap->port.membase + REG_RIS) & imsc;
1428 } while (status != 0); 1410 } while (status != 0);
1429 handled = 1; 1411 handled = 1;
1430 } 1412 }
@@ -1438,7 +1420,7 @@ static unsigned int pl011_tx_empty(struct uart_port *port)
1438{ 1420{
1439 struct uart_amba_port *uap = 1421 struct uart_amba_port *uap =
1440 container_of(port, struct uart_amba_port, port); 1422 container_of(port, struct uart_amba_port, port);
1441 unsigned int status = pl011_readw(uap, REG_FR); 1423 unsigned int status = readw(uap->port.membase + REG_FR);
1442 return status & (UART01x_FR_BUSY|UART01x_FR_TXFF) ? 0 : TIOCSER_TEMT; 1424 return status & (UART01x_FR_BUSY|UART01x_FR_TXFF) ? 0 : TIOCSER_TEMT;
1443} 1425}
1444 1426
@@ -1447,7 +1429,7 @@ static unsigned int pl011_get_mctrl(struct uart_port *port)
1447 struct uart_amba_port *uap = 1429 struct uart_amba_port *uap =
1448 container_of(port, struct uart_amba_port, port); 1430 container_of(port, struct uart_amba_port, port);
1449 unsigned int result = 0; 1431 unsigned int result = 0;
1450 unsigned int status = pl011_readw(uap, REG_FR); 1432 unsigned int status = readw(uap->port.membase + REG_FR);
1451 1433
1452#define TIOCMBIT(uartbit, tiocmbit) \ 1434#define TIOCMBIT(uartbit, tiocmbit) \
1453 if (status & uartbit) \ 1435 if (status & uartbit) \
@@ -1467,7 +1449,7 @@ static void pl011_set_mctrl(struct uart_port *port, unsigned int mctrl)
1467 container_of(port, struct uart_amba_port, port); 1449 container_of(port, struct uart_amba_port, port);
1468 unsigned int cr; 1450 unsigned int cr;
1469 1451
1470 cr = pl011_readw(uap, REG_CR); 1452 cr = readw(uap->port.membase + REG_CR);
1471 1453
1472#define TIOCMBIT(tiocmbit, uartbit) \ 1454#define TIOCMBIT(tiocmbit, uartbit) \
1473 if (mctrl & tiocmbit) \ 1455 if (mctrl & tiocmbit) \
@@ -1487,7 +1469,7 @@ static void pl011_set_mctrl(struct uart_port *port, unsigned int mctrl)
1487 } 1469 }
1488#undef TIOCMBIT 1470#undef TIOCMBIT
1489 1471
1490 pl011_writew(uap, cr, REG_CR); 1472 writew(cr, uap->port.membase + REG_CR);
1491} 1473}
1492 1474
1493static void pl011_break_ctl(struct uart_port *port, int break_state) 1475static void pl011_break_ctl(struct uart_port *port, int break_state)
@@ -1498,12 +1480,12 @@ static void pl011_break_ctl(struct uart_port *port, int break_state)
1498 unsigned int lcr_h; 1480 unsigned int lcr_h;
1499 1481
1500 spin_lock_irqsave(&uap->port.lock, flags); 1482 spin_lock_irqsave(&uap->port.lock, flags);
1501 lcr_h = pl011_readw(uap, uap->lcrh_tx); 1483 lcr_h = readw(uap->port.membase + uap->lcrh_tx);
1502 if (break_state == -1) 1484 if (break_state == -1)
1503 lcr_h |= UART01x_LCRH_BRK; 1485 lcr_h |= UART01x_LCRH_BRK;
1504 else 1486 else
1505 lcr_h &= ~UART01x_LCRH_BRK; 1487 lcr_h &= ~UART01x_LCRH_BRK;
1506 pl011_writew(uap, lcr_h, uap->lcrh_tx); 1488 writew(lcr_h, uap->port.membase + uap->lcrh_tx);
1507 spin_unlock_irqrestore(&uap->port.lock, flags); 1489 spin_unlock_irqrestore(&uap->port.lock, flags);
1508} 1490}
1509 1491
@@ -1513,8 +1495,9 @@ static void pl011_quiesce_irqs(struct uart_port *port)
1513{ 1495{
1514 struct uart_amba_port *uap = 1496 struct uart_amba_port *uap =
1515 container_of(port, struct uart_amba_port, port); 1497 container_of(port, struct uart_amba_port, port);
1498 unsigned char __iomem *regs = uap->port.membase;
1516 1499
1517 pl011_writew(uap, pl011_readw(uap, REG_MIS), REG_ICR); 1500 writew(readw(regs + REG_MIS), regs + REG_ICR);
1518 /* 1501 /*
1519 * There is no way to clear TXIM as this is "ready to transmit IRQ", so 1502 * There is no way to clear TXIM as this is "ready to transmit IRQ", so
1520 * we simply mask it. start_tx() will unmask it. 1503 * we simply mask it. start_tx() will unmask it.
@@ -1528,7 +1511,7 @@ static void pl011_quiesce_irqs(struct uart_port *port)
1528 * (including tx queue), so we're also fine with start_tx()'s caller 1511 * (including tx queue), so we're also fine with start_tx()'s caller
1529 * side. 1512 * side.
1530 */ 1513 */
1531 pl011_writew(uap, pl011_readw(uap, REG_IMSC) & ~UART011_TXIM, REG_IMSC); 1514 writew(readw(regs + REG_IMSC) & ~UART011_TXIM, regs + REG_IMSC);
1532} 1515}
1533 1516
1534static int pl011_get_poll_char(struct uart_port *port) 1517static int pl011_get_poll_char(struct uart_port *port)
@@ -1543,11 +1526,11 @@ static int pl011_get_poll_char(struct uart_port *port)
1543 */ 1526 */
1544 pl011_quiesce_irqs(port); 1527 pl011_quiesce_irqs(port);
1545 1528
1546 status = pl011_readw(uap, REG_FR); 1529 status = readw(uap->port.membase + REG_FR);
1547 if (status & UART01x_FR_RXFE) 1530 if (status & UART01x_FR_RXFE)
1548 return NO_POLL_CHAR; 1531 return NO_POLL_CHAR;
1549 1532
1550 return pl011_readw(uap, REG_DR); 1533 return readw(uap->port.membase + REG_DR);
1551} 1534}
1552 1535
1553static void pl011_put_poll_char(struct uart_port *port, 1536static void pl011_put_poll_char(struct uart_port *port,
@@ -1556,10 +1539,10 @@ static void pl011_put_poll_char(struct uart_port *port,
1556 struct uart_amba_port *uap = 1539 struct uart_amba_port *uap =
1557 container_of(port, struct uart_amba_port, port); 1540 container_of(port, struct uart_amba_port, port);
1558 1541
1559 while (pl011_readw(uap, REG_FR) & UART01x_FR_TXFF) 1542 while (readw(uap->port.membase + REG_FR) & UART01x_FR_TXFF)
1560 barrier(); 1543 barrier();
1561 1544
1562 pl011_writew(uap, ch, REG_DR); 1545 writew(ch, uap->port.membase + REG_DR);
1563} 1546}
1564 1547
1565#endif /* CONFIG_CONSOLE_POLL */ 1548#endif /* CONFIG_CONSOLE_POLL */
@@ -1583,15 +1566,15 @@ static int pl011_hwinit(struct uart_port *port)
1583 uap->port.uartclk = clk_get_rate(uap->clk); 1566 uap->port.uartclk = clk_get_rate(uap->clk);
1584 1567
1585 /* Clear pending error and receive interrupts */ 1568 /* Clear pending error and receive interrupts */
1586 pl011_writew(uap, UART011_OEIS | UART011_BEIS | UART011_PEIS | 1569 writew(UART011_OEIS | UART011_BEIS | UART011_PEIS | UART011_FEIS |
1587 UART011_FEIS | UART011_RTIS | UART011_RXIS, REG_ICR); 1570 UART011_RTIS | UART011_RXIS, uap->port.membase + REG_ICR);
1588 1571
1589 /* 1572 /*
1590 * Save interrupts enable mask, and enable RX interrupts in case if 1573 * Save interrupts enable mask, and enable RX interrupts in case if
1591 * the interrupt is used for NMI entry. 1574 * the interrupt is used for NMI entry.
1592 */ 1575 */
1593 uap->im = pl011_readw(uap, REG_IMSC); 1576 uap->im = readw(uap->port.membase + REG_IMSC);
1594 pl011_writew(uap, UART011_RTIM | UART011_RXIM, REG_IMSC); 1577 writew(UART011_RTIM | UART011_RXIM, uap->port.membase + REG_IMSC);
1595 1578
1596 if (dev_get_platdata(uap->port.dev)) { 1579 if (dev_get_platdata(uap->port.dev)) {
1597 struct amba_pl011_data *plat; 1580 struct amba_pl011_data *plat;
@@ -1605,7 +1588,7 @@ static int pl011_hwinit(struct uart_port *port)
1605 1588
1606static void pl011_write_lcr_h(struct uart_amba_port *uap, unsigned int lcr_h) 1589static void pl011_write_lcr_h(struct uart_amba_port *uap, unsigned int lcr_h)
1607{ 1590{
1608 pl011_writew(uap, lcr_h, uap->lcrh_rx); 1591 writew(lcr_h, uap->port.membase + uap->lcrh_rx);
1609 if (uap->lcrh_rx != uap->lcrh_tx) { 1592 if (uap->lcrh_rx != uap->lcrh_tx) {
1610 int i; 1593 int i;
1611 /* 1594 /*
@@ -1613,14 +1596,14 @@ static void pl011_write_lcr_h(struct uart_amba_port *uap, unsigned int lcr_h)
1613 * to get this delay write read only register 10 times 1596 * to get this delay write read only register 10 times
1614 */ 1597 */
1615 for (i = 0; i < 10; ++i) 1598 for (i = 0; i < 10; ++i)
1616 pl011_writew(uap, 0xff, REG_MIS); 1599 writew(0xff, uap->port.membase + REG_MIS);
1617 pl011_writew(uap, lcr_h, uap->lcrh_tx); 1600 writew(lcr_h, uap->port.membase + uap->lcrh_tx);
1618 } 1601 }
1619} 1602}
1620 1603
1621static int pl011_allocate_irq(struct uart_amba_port *uap) 1604static int pl011_allocate_irq(struct uart_amba_port *uap)
1622{ 1605{
1623 pl011_writew(uap, uap->im, REG_IMSC); 1606 writew(uap->im, uap->port.membase + REG_IMSC);
1624 1607
1625 return request_irq(uap->port.irq, pl011_int, 0, "uart-pl011", uap); 1608 return request_irq(uap->port.irq, pl011_int, 0, "uart-pl011", uap);
1626} 1609}
@@ -1635,11 +1618,12 @@ static void pl011_enable_interrupts(struct uart_amba_port *uap)
1635 spin_lock_irq(&uap->port.lock); 1618 spin_lock_irq(&uap->port.lock);
1636 1619
1637 /* Clear out any spuriously appearing RX interrupts */ 1620 /* Clear out any spuriously appearing RX interrupts */
1638 pl011_writew(uap, UART011_RTIS | UART011_RXIS, REG_ICR); 1621 writew(UART011_RTIS | UART011_RXIS,
1622 uap->port.membase + REG_ICR);
1639 uap->im = UART011_RTIM; 1623 uap->im = UART011_RTIM;
1640 if (!pl011_dma_rx_running(uap)) 1624 if (!pl011_dma_rx_running(uap))
1641 uap->im |= UART011_RXIM; 1625 uap->im |= UART011_RXIM;
1642 pl011_writew(uap, uap->im, REG_IMSC); 1626 writew(uap->im, uap->port.membase + REG_IMSC);
1643 spin_unlock_irq(&uap->port.lock); 1627 spin_unlock_irq(&uap->port.lock);
1644} 1628}
1645 1629
@@ -1658,21 +1642,21 @@ static int pl011_startup(struct uart_port *port)
1658 if (retval) 1642 if (retval)
1659 goto clk_dis; 1643 goto clk_dis;
1660 1644
1661 pl011_writew(uap, uap->vendor->ifls, REG_IFLS); 1645 writew(uap->vendor->ifls, uap->port.membase + REG_IFLS);
1662 1646
1663 spin_lock_irq(&uap->port.lock); 1647 spin_lock_irq(&uap->port.lock);
1664 1648
1665 /* restore RTS and DTR */ 1649 /* restore RTS and DTR */
1666 cr = uap->old_cr & (UART011_CR_RTS | UART011_CR_DTR); 1650 cr = uap->old_cr & (UART011_CR_RTS | UART011_CR_DTR);
1667 cr |= UART01x_CR_UARTEN | UART011_CR_RXE | UART011_CR_TXE; 1651 cr |= UART01x_CR_UARTEN | UART011_CR_RXE | UART011_CR_TXE;
1668 pl011_writew(uap, cr, REG_CR); 1652 writew(cr, uap->port.membase + REG_CR);
1669 1653
1670 spin_unlock_irq(&uap->port.lock); 1654 spin_unlock_irq(&uap->port.lock);
1671 1655
1672 /* 1656 /*
1673 * initialise the old status of the modem signals 1657 * initialise the old status of the modem signals
1674 */ 1658 */
1675 uap->old_status = pl011_readw(uap, REG_FR) & 1659 uap->old_status = readw(uap->port.membase + REG_FR) &
1676 UART01x_FR_MODEM_ANY; 1660 UART01x_FR_MODEM_ANY;
1677 1661
1678 /* Startup DMA */ 1662 /* Startup DMA */
@@ -1712,11 +1696,11 @@ static int sbsa_uart_startup(struct uart_port *port)
1712static void pl011_shutdown_channel(struct uart_amba_port *uap, 1696static void pl011_shutdown_channel(struct uart_amba_port *uap,
1713 unsigned int lcrh) 1697 unsigned int lcrh)
1714{ 1698{
1715 unsigned long val; 1699 unsigned long val;
1716 1700
1717 val = pl011_readw(uap, lcrh); 1701 val = readw(uap->port.membase + lcrh);
1718 val &= ~(UART01x_LCRH_BRK | UART01x_LCRH_FEN); 1702 val &= ~(UART01x_LCRH_BRK | UART01x_LCRH_FEN);
1719 pl011_writew(uap, val, lcrh); 1703 writew(val, uap->port.membase + lcrh);
1720} 1704}
1721 1705
1722/* 1706/*
@@ -1730,11 +1714,11 @@ static void pl011_disable_uart(struct uart_amba_port *uap)
1730 1714
1731 uap->autorts = false; 1715 uap->autorts = false;
1732 spin_lock_irq(&uap->port.lock); 1716 spin_lock_irq(&uap->port.lock);
1733 cr = pl011_readw(uap, REG_CR); 1717 cr = readw(uap->port.membase + REG_CR);
1734 uap->old_cr = cr; 1718 uap->old_cr = cr;
1735 cr &= UART011_CR_RTS | UART011_CR_DTR; 1719 cr &= UART011_CR_RTS | UART011_CR_DTR;
1736 cr |= UART01x_CR_UARTEN | UART011_CR_TXE; 1720 cr |= UART01x_CR_UARTEN | UART011_CR_TXE;
1737 pl011_writew(uap, cr, REG_CR); 1721 writew(cr, uap->port.membase + REG_CR);
1738 spin_unlock_irq(&uap->port.lock); 1722 spin_unlock_irq(&uap->port.lock);
1739 1723
1740 /* 1724 /*
@@ -1751,8 +1735,8 @@ static void pl011_disable_interrupts(struct uart_amba_port *uap)
1751 1735
1752 /* mask all interrupts and clear all pending ones */ 1736 /* mask all interrupts and clear all pending ones */
1753 uap->im = 0; 1737 uap->im = 0;
1754 pl011_writew(uap, uap->im, REG_IMSC); 1738 writew(uap->im, uap->port.membase + REG_IMSC);
1755 pl011_writew(0xffff, REG_ICR); 1739 writew(0xffff, uap->port.membase + REG_ICR);
1756 1740
1757 spin_unlock_irq(&uap->port.lock); 1741 spin_unlock_irq(&uap->port.lock);
1758} 1742}
@@ -1904,8 +1888,8 @@ pl011_set_termios(struct uart_port *port, struct ktermios *termios,
1904 pl011_enable_ms(port); 1888 pl011_enable_ms(port);
1905 1889
1906 /* first, disable everything */ 1890 /* first, disable everything */
1907 old_cr = pl011_readw(uap, REG_CR); 1891 old_cr = readw(port->membase + REG_CR);
1908 pl011_writew(uap, 0, REG_CR); 1892 writew(0, port->membase + REG_CR);
1909 1893
1910 if (termios->c_cflag & CRTSCTS) { 1894 if (termios->c_cflag & CRTSCTS) {
1911 if (old_cr & UART011_CR_RTS) 1895 if (old_cr & UART011_CR_RTS)
@@ -1938,8 +1922,8 @@ pl011_set_termios(struct uart_port *port, struct ktermios *termios,
1938 quot -= 2; 1922 quot -= 2;
1939 } 1923 }
1940 /* Set baud rate */ 1924 /* Set baud rate */
1941 pl011_writew(uap, quot & 0x3f, REG_FBRD); 1925 writew(quot & 0x3f, port->membase + REG_FBRD);
1942 pl011_writew(uap, quot >> 6, REG_IBRD); 1926 writew(quot >> 6, port->membase + REG_IBRD);
1943 1927
1944 /* 1928 /*
1945 * ----------v----------v----------v----------v----- 1929 * ----------v----------v----------v----------v-----
@@ -1948,7 +1932,7 @@ pl011_set_termios(struct uart_port *port, struct ktermios *termios,
1948 * ----------^----------^----------^----------^----- 1932 * ----------^----------^----------^----------^-----
1949 */ 1933 */
1950 pl011_write_lcr_h(uap, lcr_h); 1934 pl011_write_lcr_h(uap, lcr_h);
1951 pl011_writew(uap, old_cr, REG_CR); 1935 writew(old_cr, port->membase + REG_CR);
1952 1936
1953 spin_unlock_irqrestore(&port->lock, flags); 1937 spin_unlock_irqrestore(&port->lock, flags);
1954} 1938}
@@ -2089,9 +2073,9 @@ static void pl011_console_putchar(struct uart_port *port, int ch)
2089 struct uart_amba_port *uap = 2073 struct uart_amba_port *uap =
2090 container_of(port, struct uart_amba_port, port); 2074 container_of(port, struct uart_amba_port, port);
2091 2075
2092 while (pl011_readw(uap, REG_FR) & UART01x_FR_TXFF) 2076 while (readw(uap->port.membase + REG_FR) & UART01x_FR_TXFF)
2093 barrier(); 2077 barrier();
2094 pl011_writew(uap, ch, REG_DR); 2078 writew(ch, uap->port.membase + REG_DR);
2095} 2079}
2096 2080
2097static void 2081static void
@@ -2116,10 +2100,10 @@ pl011_console_write(struct console *co, const char *s, unsigned int count)
2116 * First save the CR then disable the interrupts 2100 * First save the CR then disable the interrupts
2117 */ 2101 */
2118 if (!uap->vendor->always_enabled) { 2102 if (!uap->vendor->always_enabled) {
2119 old_cr = pl011_readw(uap, REG_CR); 2103 old_cr = readw(uap->port.membase + REG_CR);
2120 new_cr = old_cr & ~UART011_CR_CTSEN; 2104 new_cr = old_cr & ~UART011_CR_CTSEN;
2121 new_cr |= UART01x_CR_UARTEN | UART011_CR_TXE; 2105 new_cr |= UART01x_CR_UARTEN | UART011_CR_TXE;
2122 pl011_writew(uap, new_cr, REG_CR); 2106 writew(new_cr, uap->port.membase + REG_CR);
2123 } 2107 }
2124 2108
2125 uart_console_write(&uap->port, s, count, pl011_console_putchar); 2109 uart_console_write(&uap->port, s, count, pl011_console_putchar);
@@ -2129,10 +2113,10 @@ pl011_console_write(struct console *co, const char *s, unsigned int count)
2129 * and restore the TCR 2113 * and restore the TCR
2130 */ 2114 */
2131 do { 2115 do {
2132 status = pl011_readw(uap, REG_FR); 2116 status = readw(uap->port.membase + REG_FR);
2133 } while (status & UART01x_FR_BUSY); 2117 } while (status & UART01x_FR_BUSY);
2134 if (!uap->vendor->always_enabled) 2118 if (!uap->vendor->always_enabled)
2135 pl011_writew(uap, old_cr, REG_CR); 2119 writew(old_cr, uap->port.membase + REG_CR);
2136 2120
2137 if (locked) 2121 if (locked)
2138 spin_unlock(&uap->port.lock); 2122 spin_unlock(&uap->port.lock);
@@ -2145,10 +2129,10 @@ static void __init
2145pl011_console_get_options(struct uart_amba_port *uap, int *baud, 2129pl011_console_get_options(struct uart_amba_port *uap, int *baud,
2146 int *parity, int *bits) 2130 int *parity, int *bits)
2147{ 2131{
2148 if (pl011_readw(uap, REG_CR) & UART01x_CR_UARTEN) { 2132 if (readw(uap->port.membase + REG_CR) & UART01x_CR_UARTEN) {
2149 unsigned int lcr_h, ibrd, fbrd; 2133 unsigned int lcr_h, ibrd, fbrd;
2150 2134
2151 lcr_h = pl011_readw(uap, uap->lcrh_tx); 2135 lcr_h = readw(uap->port.membase + uap->lcrh_tx);
2152 2136
2153 *parity = 'n'; 2137 *parity = 'n';
2154 if (lcr_h & UART01x_LCRH_PEN) { 2138 if (lcr_h & UART01x_LCRH_PEN) {
@@ -2163,13 +2147,13 @@ pl011_console_get_options(struct uart_amba_port *uap, int *baud,
2163 else 2147 else
2164 *bits = 8; 2148 *bits = 8;
2165 2149
2166 ibrd = pl011_readw(uap, REG_IBRD); 2150 ibrd = readw(uap->port.membase + REG_IBRD);
2167 fbrd = pl011_readw(uap, REG_FBRD); 2151 fbrd = readw(uap->port.membase + REG_FBRD);
2168 2152
2169 *baud = uap->port.uartclk * 4 / (64 * ibrd + fbrd); 2153 *baud = uap->port.uartclk * 4 / (64 * ibrd + fbrd);
2170 2154
2171 if (uap->vendor->oversampling) { 2155 if (uap->vendor->oversampling) {
2172 if (pl011_readw(uap, REG_CR) 2156 if (readw(uap->port.membase + REG_CR)
2173 & ST_UART011_CR_OVSFACT) 2157 & ST_UART011_CR_OVSFACT)
2174 *baud *= 2; 2158 *baud *= 2;
2175 } 2159 }
@@ -2241,13 +2225,10 @@ static struct console amba_console = {
2241 2225
2242static void pl011_putc(struct uart_port *port, int c) 2226static void pl011_putc(struct uart_port *port, int c)
2243{ 2227{
2244 struct uart_amba_port *uap = 2228 while (readl(port->membase + REG_FR) & UART01x_FR_TXFF)
2245 container_of(port, struct uart_amba_port, port);
2246
2247 while (pl011_readw(uap, REG_FR) & UART01x_FR_TXFF)
2248 ; 2229 ;
2249 pl011_writeb(uap, c, REG_DR); 2230 writeb(c, port->membase + REG_DR);
2250 while (pl011_readw(uap, REG_FR) & UART01x_FR_BUSY) 2231 while (readl(port->membase + REG_FR) & UART01x_FR_BUSY)
2251 ; 2232 ;
2252} 2233}
2253 2234
@@ -2374,8 +2355,8 @@ static int pl011_register_port(struct uart_amba_port *uap)
2374 int ret; 2355 int ret;
2375 2356
2376 /* Ensure interrupts from this UART are masked and cleared */ 2357 /* Ensure interrupts from this UART are masked and cleared */
2377 pl011_writew(uap, 0, REG_IMSC); 2358 writew(0, uap->port.membase + REG_IMSC);
2378 pl011_writew(uap, 0xffff, REG_ICR); 2359 writew(0xffff, uap->port.membase + REG_ICR);
2379 2360
2380 if (!amba_reg.state) { 2361 if (!amba_reg.state) {
2381 ret = uart_register_driver(&amba_reg); 2362 ret = uart_register_driver(&amba_reg);