aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-09-09 14:27:01 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-09-09 14:27:01 -0400
commitb8889c4fc6ba03e289cec6a4d692f6f080a55e53 (patch)
tree45078625e0bfd865489b297d84eed17983d6d538
parentfac33bfdb0a54e149f8d1c2f002de5b57770b84c (diff)
parent0de6cfb9f314db230c47b2158e7725208b3b4728 (diff)
Merge tag 'tty-4.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
Pull tty driver reverts from Greg KH: "Here are some reverts for some tty patches (specifically the pl011 driver) that ended up breaking a bunch of machines (i.e. almost all of the ones with this chip). People are working on a fix for this, but in the meantime, it's best to just revert all 5 patches to restore people's serial consoles. These reverts have been in linux-next for many days now" * tag 'tty-4.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: Revert "uart: pl011: Rename regs with enumeration" Revert "uart: pl011: Introduce register accessor" Revert "uart: pl011: Introduce register look up table" Revert "uart: pl011: Improve LCRH register access decision" Revert "uart: pl011: Add support to ZTE ZX296702 uart"
-rw-r--r--drivers/tty/serial/Kconfig4
-rw-r--r--drivers/tty/serial/amba-pl011.c503
-rw-r--r--include/linux/amba/serial.h14
3 files changed, 125 insertions, 396 deletions
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index ed299b9e6375..687b1ea294b7 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -47,12 +47,12 @@ config SERIAL_AMBA_PL010_CONSOLE
47 47
48config SERIAL_AMBA_PL011 48config SERIAL_AMBA_PL011
49 tristate "ARM AMBA PL011 serial port support" 49 tristate "ARM AMBA PL011 serial port support"
50 depends on ARM_AMBA || SOC_ZX296702 50 depends on ARM_AMBA
51 select SERIAL_CORE 51 select SERIAL_CORE
52 help 52 help
53 This selects the ARM(R) AMBA(R) PrimeCell PL011 UART. If you have 53 This selects the ARM(R) AMBA(R) PrimeCell PL011 UART. If you have
54 an Integrator/PP2, Integrator/CP or Versatile platform, say Y or M 54 an Integrator/PP2, Integrator/CP or Versatile platform, say Y or M
55 here. Say Y or M if you have SOC_ZX296702. 55 here.
56 56
57 If unsure, say N. 57 If unsure, say N.
58 58
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 2af09ab153b6..fd27e986b1dd 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -74,13 +74,8 @@
74/* There is by now at least one vendor with differing details, so handle it */ 74/* There is by now at least one vendor with differing details, so handle it */
75struct vendor_data { 75struct vendor_data {
76 unsigned int ifls; 76 unsigned int ifls;
77 unsigned int fr_busy;
78 unsigned int fr_dsr;
79 unsigned int fr_cts;
80 unsigned int fr_ri;
81 unsigned int lcrh_tx; 77 unsigned int lcrh_tx;
82 unsigned int lcrh_rx; 78 unsigned int lcrh_rx;
83 u16 *reg_lut;
84 bool oversampling; 79 bool oversampling;
85 bool dma_threshold; 80 bool dma_threshold;
86 bool cts_event_workaround; 81 bool cts_event_workaround;
@@ -90,48 +85,6 @@ struct vendor_data {
90 unsigned int (*get_fifosize)(struct amba_device *dev); 85 unsigned int (*get_fifosize)(struct amba_device *dev);
91}; 86};
92 87
93/* Max address offset of register in use is 0x48 */
94#define REG_NR (0x48 >> 2)
95#define IDX(x) (x >> 2)
96enum reg_idx {
97 REG_DR = IDX(UART01x_DR),
98 REG_RSR = IDX(UART01x_RSR),
99 REG_ST_DMAWM = IDX(ST_UART011_DMAWM),
100 REG_FR = IDX(UART01x_FR),
101 REG_ST_LCRH_RX = IDX(ST_UART011_LCRH_RX),
102 REG_ILPR = IDX(UART01x_ILPR),
103 REG_IBRD = IDX(UART011_IBRD),
104 REG_FBRD = IDX(UART011_FBRD),
105 REG_LCRH = IDX(UART011_LCRH),
106 REG_CR = IDX(UART011_CR),
107 REG_IFLS = IDX(UART011_IFLS),
108 REG_IMSC = IDX(UART011_IMSC),
109 REG_RIS = IDX(UART011_RIS),
110 REG_MIS = IDX(UART011_MIS),
111 REG_ICR = IDX(UART011_ICR),
112 REG_DMACR = IDX(UART011_DMACR),
113};
114
115static u16 arm_reg[] = {
116 [REG_DR] = UART01x_DR,
117 [REG_RSR] = UART01x_RSR,
118 [REG_ST_DMAWM] = ~0,
119 [REG_FR] = UART01x_FR,
120 [REG_ST_LCRH_RX] = ~0,
121 [REG_ILPR] = UART01x_ILPR,
122 [REG_IBRD] = UART011_IBRD,
123 [REG_FBRD] = UART011_FBRD,
124 [REG_LCRH] = UART011_LCRH,
125 [REG_CR] = UART011_CR,
126 [REG_IFLS] = UART011_IFLS,
127 [REG_IMSC] = UART011_IMSC,
128 [REG_RIS] = UART011_RIS,
129 [REG_MIS] = UART011_MIS,
130 [REG_ICR] = UART011_ICR,
131 [REG_DMACR] = UART011_DMACR,
132};
133
134#ifdef CONFIG_ARM_AMBA
135static unsigned int get_fifosize_arm(struct amba_device *dev) 88static unsigned int get_fifosize_arm(struct amba_device *dev)
136{ 89{
137 return amba_rev(dev) < 3 ? 16 : 32; 90 return amba_rev(dev) < 3 ? 16 : 32;
@@ -139,13 +92,8 @@ static unsigned int get_fifosize_arm(struct amba_device *dev)
139 92
140static struct vendor_data vendor_arm = { 93static struct vendor_data vendor_arm = {
141 .ifls = UART011_IFLS_RX4_8|UART011_IFLS_TX4_8, 94 .ifls = UART011_IFLS_RX4_8|UART011_IFLS_TX4_8,
142 .fr_busy = UART01x_FR_BUSY, 95 .lcrh_tx = UART011_LCRH,
143 .fr_dsr = UART01x_FR_DSR, 96 .lcrh_rx = UART011_LCRH,
144 .fr_cts = UART01x_FR_CTS,
145 .fr_ri = UART011_FR_RI,
146 .lcrh_tx = REG_LCRH,
147 .lcrh_rx = REG_LCRH,
148 .reg_lut = arm_reg,
149 .oversampling = false, 97 .oversampling = false,
150 .dma_threshold = false, 98 .dma_threshold = false,
151 .cts_event_workaround = false, 99 .cts_event_workaround = false,
@@ -153,14 +101,8 @@ static struct vendor_data vendor_arm = {
153 .fixed_options = false, 101 .fixed_options = false,
154 .get_fifosize = get_fifosize_arm, 102 .get_fifosize = get_fifosize_arm,
155}; 103};
156#endif
157 104
158static struct vendor_data vendor_sbsa = { 105static struct vendor_data vendor_sbsa = {
159 .fr_busy = UART01x_FR_BUSY,
160 .fr_dsr = UART01x_FR_DSR,
161 .fr_cts = UART01x_FR_CTS,
162 .fr_ri = UART011_FR_RI,
163 .reg_lut = arm_reg,
164 .oversampling = false, 106 .oversampling = false,
165 .dma_threshold = false, 107 .dma_threshold = false,
166 .cts_event_workaround = false, 108 .cts_event_workaround = false,
@@ -168,26 +110,6 @@ static struct vendor_data vendor_sbsa = {
168 .fixed_options = true, 110 .fixed_options = true,
169}; 111};
170 112
171#ifdef CONFIG_ARM_AMBA
172static u16 st_reg[] = {
173 [REG_DR] = UART01x_DR,
174 [REG_RSR] = UART01x_RSR,
175 [REG_ST_DMAWM] = ST_UART011_DMAWM,
176 [REG_FR] = UART01x_FR,
177 [REG_ST_LCRH_RX] = ST_UART011_LCRH_RX,
178 [REG_ILPR] = UART01x_ILPR,
179 [REG_IBRD] = UART011_IBRD,
180 [REG_FBRD] = UART011_FBRD,
181 [REG_LCRH] = UART011_LCRH,
182 [REG_CR] = UART011_CR,
183 [REG_IFLS] = UART011_IFLS,
184 [REG_IMSC] = UART011_IMSC,
185 [REG_RIS] = UART011_RIS,
186 [REG_MIS] = UART011_MIS,
187 [REG_ICR] = UART011_ICR,
188 [REG_DMACR] = UART011_DMACR,
189};
190
191static unsigned int get_fifosize_st(struct amba_device *dev) 113static unsigned int get_fifosize_st(struct amba_device *dev)
192{ 114{
193 return 64; 115 return 64;
@@ -195,13 +117,8 @@ static unsigned int get_fifosize_st(struct amba_device *dev)
195 117
196static struct vendor_data vendor_st = { 118static struct vendor_data vendor_st = {
197 .ifls = UART011_IFLS_RX_HALF|UART011_IFLS_TX_HALF, 119 .ifls = UART011_IFLS_RX_HALF|UART011_IFLS_TX_HALF,
198 .fr_busy = UART01x_FR_BUSY, 120 .lcrh_tx = ST_UART011_LCRH_TX,
199 .fr_dsr = UART01x_FR_DSR, 121 .lcrh_rx = ST_UART011_LCRH_RX,
200 .fr_cts = UART01x_FR_CTS,
201 .fr_ri = UART011_FR_RI,
202 .lcrh_tx = REG_LCRH,
203 .lcrh_rx = REG_ST_LCRH_RX,
204 .reg_lut = st_reg,
205 .oversampling = true, 122 .oversampling = true,
206 .dma_threshold = true, 123 .dma_threshold = true,
207 .cts_event_workaround = true, 124 .cts_event_workaround = true,
@@ -209,43 +126,6 @@ static struct vendor_data vendor_st = {
209 .fixed_options = false, 126 .fixed_options = false,
210 .get_fifosize = get_fifosize_st, 127 .get_fifosize = get_fifosize_st,
211}; 128};
212#endif
213
214#ifdef CONFIG_SOC_ZX296702
215static u16 zte_reg[] = {
216 [REG_DR] = ZX_UART01x_DR,
217 [REG_RSR] = UART01x_RSR,
218 [REG_ST_DMAWM] = ST_UART011_DMAWM,
219 [REG_FR] = ZX_UART01x_FR,
220 [REG_ST_LCRH_RX] = ST_UART011_LCRH_RX,
221 [REG_ILPR] = UART01x_ILPR,
222 [REG_IBRD] = UART011_IBRD,
223 [REG_FBRD] = UART011_FBRD,
224 [REG_LCRH] = ZX_UART011_LCRH_TX,
225 [REG_CR] = ZX_UART011_CR,
226 [REG_IFLS] = ZX_UART011_IFLS,
227 [REG_IMSC] = ZX_UART011_IMSC,
228 [REG_RIS] = ZX_UART011_RIS,
229 [REG_MIS] = ZX_UART011_MIS,
230 [REG_ICR] = ZX_UART011_ICR,
231 [REG_DMACR] = ZX_UART011_DMACR,
232};
233
234static struct vendor_data vendor_zte = {
235 .ifls = UART011_IFLS_RX4_8|UART011_IFLS_TX4_8,
236 .fr_busy = ZX_UART01x_FR_BUSY,
237 .fr_dsr = ZX_UART01x_FR_DSR,
238 .fr_cts = ZX_UART01x_FR_CTS,
239 .fr_ri = ZX_UART011_FR_RI,
240 .lcrh_tx = REG_LCRH,
241 .lcrh_rx = REG_ST_LCRH_RX,
242 .reg_lut = zte_reg,
243 .oversampling = false,
244 .dma_threshold = false,
245 .cts_event_workaround = false,
246 .fixed_options = false,
247};
248#endif
249 129
250/* Deals with DMA transactions */ 130/* Deals with DMA transactions */
251 131
@@ -284,15 +164,10 @@ struct uart_amba_port {
284 struct uart_port port; 164 struct uart_port port;
285 struct clk *clk; 165 struct clk *clk;
286 const struct vendor_data *vendor; 166 const struct vendor_data *vendor;
287 u16 *reg_lut;
288 unsigned int dmacr; /* dma control reg */ 167 unsigned int dmacr; /* dma control reg */
289 unsigned int im; /* interrupt mask */ 168 unsigned int im; /* interrupt mask */
290 unsigned int old_status; 169 unsigned int old_status;
291 unsigned int fifosize; /* vendor-specific */ 170 unsigned int fifosize; /* vendor-specific */
292 unsigned int fr_busy; /* vendor-specific */
293 unsigned int fr_dsr; /* vendor-specific */
294 unsigned int fr_cts; /* vendor-specific */
295 unsigned int fr_ri; /* vendor-specific */
296 unsigned int lcrh_tx; /* vendor-specific */ 171 unsigned int lcrh_tx; /* vendor-specific */
297 unsigned int lcrh_rx; /* vendor-specific */ 172 unsigned int lcrh_rx; /* vendor-specific */
298 unsigned int old_cr; /* state during shutdown */ 173 unsigned int old_cr; /* state during shutdown */
@@ -309,29 +184,6 @@ struct uart_amba_port {
309#endif 184#endif
310}; 185};
311 186
312static bool is_implemented(struct uart_amba_port *uap, unsigned int reg)
313{
314 return uap->reg_lut[reg] != (u16)~0;
315}
316
317static unsigned int pl011_readw(struct uart_amba_port *uap, int index)
318{
319 WARN_ON(index > REG_NR);
320 return readw_relaxed(uap->port.membase + uap->reg_lut[index]);
321}
322
323static void pl011_writew(struct uart_amba_port *uap, int val, int index)
324{
325 WARN_ON(index > REG_NR);
326 writew_relaxed(val, uap->port.membase + uap->reg_lut[index]);
327}
328
329static void pl011_writeb(struct uart_amba_port *uap, u8 val, int index)
330{
331 WARN_ON(index > REG_NR);
332 writeb_relaxed(val, uap->port.membase + uap->reg_lut[index]);
333}
334
335/* 187/*
336 * Reads up to 256 characters from the FIFO or until it's empty and 188 * Reads up to 256 characters from the FIFO or until it's empty and
337 * inserts them into the TTY layer. Returns the number of characters 189 * inserts them into the TTY layer. Returns the number of characters
@@ -344,12 +196,12 @@ static int pl011_fifo_to_tty(struct uart_amba_port *uap)
344 int fifotaken = 0; 196 int fifotaken = 0;
345 197
346 while (max_count--) { 198 while (max_count--) {
347 status = pl011_readw(uap, REG_FR); 199 status = readw(uap->port.membase + UART01x_FR);
348 if (status & UART01x_FR_RXFE) 200 if (status & UART01x_FR_RXFE)
349 break; 201 break;
350 202
351 /* Take chars from the FIFO and update status */ 203 /* Take chars from the FIFO and update status */
352 ch = pl011_readw(uap, REG_DR) | 204 ch = readw(uap->port.membase + UART01x_DR) |
353 UART_DUMMY_DR_RX; 205 UART_DUMMY_DR_RX;
354 flag = TTY_NORMAL; 206 flag = TTY_NORMAL;
355 uap->port.icount.rx++; 207 uap->port.icount.rx++;
@@ -432,7 +284,7 @@ static void pl011_dma_probe(struct uart_amba_port *uap)
432 struct amba_pl011_data *plat = dev_get_platdata(uap->port.dev); 284 struct amba_pl011_data *plat = dev_get_platdata(uap->port.dev);
433 struct device *dev = uap->port.dev; 285 struct device *dev = uap->port.dev;
434 struct dma_slave_config tx_conf = { 286 struct dma_slave_config tx_conf = {
435 .dst_addr = uap->port.mapbase + uap->reg_lut[REG_DR], 287 .dst_addr = uap->port.mapbase + UART01x_DR,
436 .dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE, 288 .dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE,
437 .direction = DMA_MEM_TO_DEV, 289 .direction = DMA_MEM_TO_DEV,
438 .dst_maxburst = uap->fifosize >> 1, 290 .dst_maxburst = uap->fifosize >> 1,
@@ -487,7 +339,7 @@ static void pl011_dma_probe(struct uart_amba_port *uap)
487 339
488 if (chan) { 340 if (chan) {
489 struct dma_slave_config rx_conf = { 341 struct dma_slave_config rx_conf = {
490 .src_addr = uap->port.mapbase + uap->reg_lut[REG_DR], 342 .src_addr = uap->port.mapbase + UART01x_DR,
491 .src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE, 343 .src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE,
492 .direction = DMA_DEV_TO_MEM, 344 .direction = DMA_DEV_TO_MEM,
493 .src_maxburst = uap->fifosize >> 2, 345 .src_maxburst = uap->fifosize >> 2,
@@ -586,7 +438,7 @@ static void pl011_dma_tx_callback(void *data)
586 438
587 dmacr = uap->dmacr; 439 dmacr = uap->dmacr;
588 uap->dmacr = dmacr & ~UART011_TXDMAE; 440 uap->dmacr = dmacr & ~UART011_TXDMAE;
589 pl011_writew(uap, uap->dmacr, REG_DMACR); 441 writew(uap->dmacr, uap->port.membase + UART011_DMACR);
590 442
591 /* 443 /*
592 * If TX DMA was disabled, it means that we've stopped the DMA for 444 * If TX DMA was disabled, it means that we've stopped the DMA for
@@ -700,7 +552,7 @@ static int pl011_dma_tx_refill(struct uart_amba_port *uap)
700 dma_dev->device_issue_pending(chan); 552 dma_dev->device_issue_pending(chan);
701 553
702 uap->dmacr |= UART011_TXDMAE; 554 uap->dmacr |= UART011_TXDMAE;
703 pl011_writew(uap, uap->dmacr, REG_DMACR); 555 writew(uap->dmacr, uap->port.membase + UART011_DMACR);
704 uap->dmatx.queued = true; 556 uap->dmatx.queued = true;
705 557
706 /* 558 /*
@@ -736,9 +588,9 @@ static bool pl011_dma_tx_irq(struct uart_amba_port *uap)
736 */ 588 */
737 if (uap->dmatx.queued) { 589 if (uap->dmatx.queued) {
738 uap->dmacr |= UART011_TXDMAE; 590 uap->dmacr |= UART011_TXDMAE;
739 pl011_writew(uap, uap->dmacr, REG_DMACR); 591 writew(uap->dmacr, uap->port.membase + UART011_DMACR);
740 uap->im &= ~UART011_TXIM; 592 uap->im &= ~UART011_TXIM;
741 pl011_writew(uap, uap->im, REG_IMSC); 593 writew(uap->im, uap->port.membase + UART011_IMSC);
742 return true; 594 return true;
743 } 595 }
744 596
@@ -748,7 +600,7 @@ static bool pl011_dma_tx_irq(struct uart_amba_port *uap)
748 */ 600 */
749 if (pl011_dma_tx_refill(uap) > 0) { 601 if (pl011_dma_tx_refill(uap) > 0) {
750 uap->im &= ~UART011_TXIM; 602 uap->im &= ~UART011_TXIM;
751 pl011_writew(uap, uap->im, REG_IMSC); 603 writew(uap->im, uap->port.membase + UART011_IMSC);
752 return true; 604 return true;
753 } 605 }
754 return false; 606 return false;
@@ -762,7 +614,7 @@ static inline void pl011_dma_tx_stop(struct uart_amba_port *uap)
762{ 614{
763 if (uap->dmatx.queued) { 615 if (uap->dmatx.queued) {
764 uap->dmacr &= ~UART011_TXDMAE; 616 uap->dmacr &= ~UART011_TXDMAE;
765 pl011_writew(uap, uap->dmacr, REG_DMACR); 617 writew(uap->dmacr, uap->port.membase + UART011_DMACR);
766 } 618 }
767} 619}
768 620
@@ -788,12 +640,14 @@ static inline bool pl011_dma_tx_start(struct uart_amba_port *uap)
788 if (!uap->dmatx.queued) { 640 if (!uap->dmatx.queued) {
789 if (pl011_dma_tx_refill(uap) > 0) { 641 if (pl011_dma_tx_refill(uap) > 0) {
790 uap->im &= ~UART011_TXIM; 642 uap->im &= ~UART011_TXIM;
791 pl011_writew(uap, uap->im, REG_IMSC); 643 writew(uap->im, uap->port.membase +
644 UART011_IMSC);
792 } else 645 } else
793 ret = false; 646 ret = false;
794 } else if (!(uap->dmacr & UART011_TXDMAE)) { 647 } else if (!(uap->dmacr & UART011_TXDMAE)) {
795 uap->dmacr |= UART011_TXDMAE; 648 uap->dmacr |= UART011_TXDMAE;
796 pl011_writew(uap, uap->dmacr, REG_DMACR); 649 writew(uap->dmacr,
650 uap->port.membase + UART011_DMACR);
797 } 651 }
798 return ret; 652 return ret;
799 } 653 }
@@ -804,9 +658,9 @@ static inline bool pl011_dma_tx_start(struct uart_amba_port *uap)
804 */ 658 */
805 dmacr = uap->dmacr; 659 dmacr = uap->dmacr;
806 uap->dmacr &= ~UART011_TXDMAE; 660 uap->dmacr &= ~UART011_TXDMAE;
807 pl011_writew(uap, uap->dmacr, REG_DMACR); 661 writew(uap->dmacr, uap->port.membase + UART011_DMACR);
808 662
809 if (pl011_readw(uap, REG_FR) & UART01x_FR_TXFF) { 663 if (readw(uap->port.membase + UART01x_FR) & UART01x_FR_TXFF) {
810 /* 664 /*
811 * No space in the FIFO, so enable the transmit interrupt 665 * No space in the FIFO, so enable the transmit interrupt
812 * so we know when there is space. Note that once we've 666 * so we know when there is space. Note that once we've
@@ -815,13 +669,13 @@ static inline bool pl011_dma_tx_start(struct uart_amba_port *uap)
815 return false; 669 return false;
816 } 670 }
817 671
818 pl011_writew(uap, uap->port.x_char, REG_DR); 672 writew(uap->port.x_char, uap->port.membase + UART01x_DR);
819 uap->port.icount.tx++; 673 uap->port.icount.tx++;
820 uap->port.x_char = 0; 674 uap->port.x_char = 0;
821 675
822 /* Success - restore the DMA state */ 676 /* Success - restore the DMA state */
823 uap->dmacr = dmacr; 677 uap->dmacr = dmacr;
824 pl011_writew(uap, dmacr, REG_DMACR); 678 writew(dmacr, uap->port.membase + UART011_DMACR);
825 679
826 return true; 680 return true;
827} 681}
@@ -849,7 +703,7 @@ __acquires(&uap->port.lock)
849 DMA_TO_DEVICE); 703 DMA_TO_DEVICE);
850 uap->dmatx.queued = false; 704 uap->dmatx.queued = false;
851 uap->dmacr &= ~UART011_TXDMAE; 705 uap->dmacr &= ~UART011_TXDMAE;
852 pl011_writew(uap, uap->dmacr, REG_DMACR); 706 writew(uap->dmacr, uap->port.membase + UART011_DMACR);
853 } 707 }
854} 708}
855 709
@@ -889,11 +743,11 @@ static int pl011_dma_rx_trigger_dma(struct uart_amba_port *uap)
889 dma_async_issue_pending(rxchan); 743 dma_async_issue_pending(rxchan);
890 744
891 uap->dmacr |= UART011_RXDMAE; 745 uap->dmacr |= UART011_RXDMAE;
892 pl011_writew(uap, uap->dmacr, REG_DMACR); 746 writew(uap->dmacr, uap->port.membase + UART011_DMACR);
893 uap->dmarx.running = true; 747 uap->dmarx.running = true;
894 748
895 uap->im &= ~UART011_RXIM; 749 uap->im &= ~UART011_RXIM;
896 pl011_writew(uap, uap->im, REG_IMSC); 750 writew(uap->im, uap->port.membase + UART011_IMSC);
897 751
898 return 0; 752 return 0;
899} 753}
@@ -951,9 +805,8 @@ static void pl011_dma_rx_chars(struct uart_amba_port *uap,
951 */ 805 */
952 if (dma_count == pending && readfifo) { 806 if (dma_count == pending && readfifo) {
953 /* Clear any error flags */ 807 /* Clear any error flags */
954 pl011_writew(uap, 808 writew(UART011_OEIS | UART011_BEIS | UART011_PEIS | UART011_FEIS,
955 UART011_OEIS | UART011_BEIS | UART011_PEIS 809 uap->port.membase + UART011_ICR);
956 | UART011_FEIS, REG_ICR);
957 810
958 /* 811 /*
959 * If we read all the DMA'd characters, and we had an 812 * If we read all the DMA'd characters, and we had an
@@ -1001,7 +854,7 @@ static void pl011_dma_rx_irq(struct uart_amba_port *uap)
1001 854
1002 /* Disable RX DMA - incoming data will wait in the FIFO */ 855 /* Disable RX DMA - incoming data will wait in the FIFO */
1003 uap->dmacr &= ~UART011_RXDMAE; 856 uap->dmacr &= ~UART011_RXDMAE;
1004 pl011_writew(uap, uap->dmacr, REG_DMACR); 857 writew(uap->dmacr, uap->port.membase + UART011_DMACR);
1005 uap->dmarx.running = false; 858 uap->dmarx.running = false;
1006 859
1007 pending = sgbuf->sg.length - state.residue; 860 pending = sgbuf->sg.length - state.residue;
@@ -1021,7 +874,7 @@ static void pl011_dma_rx_irq(struct uart_amba_port *uap)
1021 dev_dbg(uap->port.dev, "could not retrigger RX DMA job " 874 dev_dbg(uap->port.dev, "could not retrigger RX DMA job "
1022 "fall back to interrupt mode\n"); 875 "fall back to interrupt mode\n");
1023 uap->im |= UART011_RXIM; 876 uap->im |= UART011_RXIM;
1024 pl011_writew(uap, uap->im, REG_IMSC); 877 writew(uap->im, uap->port.membase + UART011_IMSC);
1025 } 878 }
1026} 879}
1027 880
@@ -1069,7 +922,7 @@ static void pl011_dma_rx_callback(void *data)
1069 dev_dbg(uap->port.dev, "could not retrigger RX DMA job " 922 dev_dbg(uap->port.dev, "could not retrigger RX DMA job "
1070 "fall back to interrupt mode\n"); 923 "fall back to interrupt mode\n");
1071 uap->im |= UART011_RXIM; 924 uap->im |= UART011_RXIM;
1072 pl011_writew(uap, uap->im, REG_IMSC); 925 writew(uap->im, uap->port.membase + UART011_IMSC);
1073 } 926 }
1074} 927}
1075 928
@@ -1082,7 +935,7 @@ static inline void pl011_dma_rx_stop(struct uart_amba_port *uap)
1082{ 935{
1083 /* FIXME. Just disable the DMA enable */ 936 /* FIXME. Just disable the DMA enable */
1084 uap->dmacr &= ~UART011_RXDMAE; 937 uap->dmacr &= ~UART011_RXDMAE;
1085 pl011_writew(uap, uap->dmacr, REG_DMACR); 938 writew(uap->dmacr, uap->port.membase + UART011_DMACR);
1086} 939}
1087 940
1088/* 941/*
@@ -1126,7 +979,7 @@ static void pl011_dma_rx_poll(unsigned long args)
1126 spin_lock_irqsave(&uap->port.lock, flags); 979 spin_lock_irqsave(&uap->port.lock, flags);
1127 pl011_dma_rx_stop(uap); 980 pl011_dma_rx_stop(uap);
1128 uap->im |= UART011_RXIM; 981 uap->im |= UART011_RXIM;
1129 pl011_writew(uap, uap->im, REG_IMSC); 982 writew(uap->im, uap->port.membase + UART011_IMSC);
1130 spin_unlock_irqrestore(&uap->port.lock, flags); 983 spin_unlock_irqrestore(&uap->port.lock, flags);
1131 984
1132 uap->dmarx.running = false; 985 uap->dmarx.running = false;
@@ -1188,7 +1041,7 @@ static void pl011_dma_startup(struct uart_amba_port *uap)
1188skip_rx: 1041skip_rx:
1189 /* Turn on DMA error (RX/TX will be enabled on demand) */ 1042 /* Turn on DMA error (RX/TX will be enabled on demand) */
1190 uap->dmacr |= UART011_DMAONERR; 1043 uap->dmacr |= UART011_DMAONERR;
1191 pl011_writew(uap, uap->dmacr, REG_DMACR); 1044 writew(uap->dmacr, uap->port.membase + UART011_DMACR);
1192 1045
1193 /* 1046 /*
1194 * ST Micro variants has some specific dma burst threshold 1047 * ST Micro variants has some specific dma burst threshold
@@ -1196,9 +1049,8 @@ skip_rx:
1196 * be issued above/below 16 bytes. 1049 * be issued above/below 16 bytes.
1197 */ 1050 */
1198 if (uap->vendor->dma_threshold) 1051 if (uap->vendor->dma_threshold)
1199 pl011_writew(uap, 1052 writew(ST_UART011_DMAWM_RX_16 | ST_UART011_DMAWM_TX_16,
1200 ST_UART011_DMAWM_RX_16 | ST_UART011_DMAWM_TX_16, 1053 uap->port.membase + ST_UART011_DMAWM);
1201 REG_ST_DMAWM);
1202 1054
1203 if (uap->using_rx_dma) { 1055 if (uap->using_rx_dma) {
1204 if (pl011_dma_rx_trigger_dma(uap)) 1056 if (pl011_dma_rx_trigger_dma(uap))
@@ -1223,12 +1075,12 @@ static void pl011_dma_shutdown(struct uart_amba_port *uap)
1223 return; 1075 return;
1224 1076
1225 /* Disable RX and TX DMA */ 1077 /* Disable RX and TX DMA */
1226 while (pl011_readw(uap, REG_FR) & uap->fr_busy) 1078 while (readw(uap->port.membase + UART01x_FR) & UART01x_FR_BUSY)
1227 barrier(); 1079 barrier();
1228 1080
1229 spin_lock_irq(&uap->port.lock); 1081 spin_lock_irq(&uap->port.lock);
1230 uap->dmacr &= ~(UART011_DMAONERR | UART011_RXDMAE | UART011_TXDMAE); 1082 uap->dmacr &= ~(UART011_DMAONERR | UART011_RXDMAE | UART011_TXDMAE);
1231 pl011_writew(uap, uap->dmacr, REG_DMACR); 1083 writew(uap->dmacr, uap->port.membase + UART011_DMACR);
1232 spin_unlock_irq(&uap->port.lock); 1084 spin_unlock_irq(&uap->port.lock);
1233 1085
1234 if (uap->using_tx_dma) { 1086 if (uap->using_tx_dma) {
@@ -1329,7 +1181,7 @@ static void pl011_stop_tx(struct uart_port *port)
1329 container_of(port, struct uart_amba_port, port); 1181 container_of(port, struct uart_amba_port, port);
1330 1182
1331 uap->im &= ~UART011_TXIM; 1183 uap->im &= ~UART011_TXIM;
1332 pl011_writew(uap, uap->im, REG_IMSC); 1184 writew(uap->im, uap->port.membase + UART011_IMSC);
1333 pl011_dma_tx_stop(uap); 1185 pl011_dma_tx_stop(uap);
1334} 1186}
1335 1187
@@ -1339,7 +1191,7 @@ static void pl011_tx_chars(struct uart_amba_port *uap, bool from_irq);
1339static void pl011_start_tx_pio(struct uart_amba_port *uap) 1191static void pl011_start_tx_pio(struct uart_amba_port *uap)
1340{ 1192{
1341 uap->im |= UART011_TXIM; 1193 uap->im |= UART011_TXIM;
1342 pl011_writew(uap, uap->im, REG_IMSC); 1194 writew(uap->im, uap->port.membase + UART011_IMSC);
1343 pl011_tx_chars(uap, false); 1195 pl011_tx_chars(uap, false);
1344} 1196}
1345 1197
@@ -1359,7 +1211,7 @@ static void pl011_stop_rx(struct uart_port *port)
1359 1211
1360 uap->im &= ~(UART011_RXIM|UART011_RTIM|UART011_FEIM| 1212 uap->im &= ~(UART011_RXIM|UART011_RTIM|UART011_FEIM|
1361 UART011_PEIM|UART011_BEIM|UART011_OEIM); 1213 UART011_PEIM|UART011_BEIM|UART011_OEIM);
1362 pl011_writew(uap, uap->im, REG_IMSC); 1214 writew(uap->im, uap->port.membase + UART011_IMSC);
1363 1215
1364 pl011_dma_rx_stop(uap); 1216 pl011_dma_rx_stop(uap);
1365} 1217}
@@ -1370,7 +1222,7 @@ static void pl011_enable_ms(struct uart_port *port)
1370 container_of(port, struct uart_amba_port, port); 1222 container_of(port, struct uart_amba_port, port);
1371 1223
1372 uap->im |= UART011_RIMIM|UART011_CTSMIM|UART011_DCDMIM|UART011_DSRMIM; 1224 uap->im |= UART011_RIMIM|UART011_CTSMIM|UART011_DCDMIM|UART011_DSRMIM;
1373 pl011_writew(uap, uap->im, REG_IMSC); 1225 writew(uap->im, uap->port.membase + UART011_IMSC);
1374} 1226}
1375 1227
1376static void pl011_rx_chars(struct uart_amba_port *uap) 1228static void pl011_rx_chars(struct uart_amba_port *uap)
@@ -1390,7 +1242,7 @@ __acquires(&uap->port.lock)
1390 dev_dbg(uap->port.dev, "could not trigger RX DMA job " 1242 dev_dbg(uap->port.dev, "could not trigger RX DMA job "
1391 "fall back to interrupt mode again\n"); 1243 "fall back to interrupt mode again\n");
1392 uap->im |= UART011_RXIM; 1244 uap->im |= UART011_RXIM;
1393 pl011_writew(uap, uap->im, REG_IMSC); 1245 writew(uap->im, uap->port.membase + UART011_IMSC);
1394 } else { 1246 } else {
1395#ifdef CONFIG_DMA_ENGINE 1247#ifdef CONFIG_DMA_ENGINE
1396 /* Start Rx DMA poll */ 1248 /* Start Rx DMA poll */
@@ -1411,10 +1263,10 @@ static bool pl011_tx_char(struct uart_amba_port *uap, unsigned char c,
1411 bool from_irq) 1263 bool from_irq)
1412{ 1264{
1413 if (unlikely(!from_irq) && 1265 if (unlikely(!from_irq) &&
1414 pl011_readw(uap, REG_FR) & UART01x_FR_TXFF) 1266 readw(uap->port.membase + UART01x_FR) & UART01x_FR_TXFF)
1415 return false; /* unable to transmit character */ 1267 return false; /* unable to transmit character */
1416 1268
1417 pl011_writew(uap, c, REG_DR); 1269 writew(c, uap->port.membase + UART01x_DR);
1418 uap->port.icount.tx++; 1270 uap->port.icount.tx++;
1419 1271
1420 return true; 1272 return true;
@@ -1461,7 +1313,7 @@ static void pl011_modem_status(struct uart_amba_port *uap)
1461{ 1313{
1462 unsigned int status, delta; 1314 unsigned int status, delta;
1463 1315
1464 status = pl011_readw(uap, REG_FR) & UART01x_FR_MODEM_ANY; 1316 status = readw(uap->port.membase + UART01x_FR) & UART01x_FR_MODEM_ANY;
1465 1317
1466 delta = status ^ uap->old_status; 1318 delta = status ^ uap->old_status;
1467 uap->old_status = status; 1319 uap->old_status = status;
@@ -1472,11 +1324,11 @@ static void pl011_modem_status(struct uart_amba_port *uap)
1472 if (delta & UART01x_FR_DCD) 1324 if (delta & UART01x_FR_DCD)
1473 uart_handle_dcd_change(&uap->port, status & UART01x_FR_DCD); 1325 uart_handle_dcd_change(&uap->port, status & UART01x_FR_DCD);
1474 1326
1475 if (delta & uap->fr_dsr) 1327 if (delta & UART01x_FR_DSR)
1476 uap->port.icount.dsr++; 1328 uap->port.icount.dsr++;
1477 1329
1478 if (delta & uap->fr_cts) 1330 if (delta & UART01x_FR_CTS)
1479 uart_handle_cts_change(&uap->port, status & uap->fr_cts); 1331 uart_handle_cts_change(&uap->port, status & UART01x_FR_CTS);
1480 1332
1481 wake_up_interruptible(&uap->port.state->port.delta_msr_wait); 1333 wake_up_interruptible(&uap->port.state->port.delta_msr_wait);
1482} 1334}
@@ -1489,15 +1341,15 @@ static void check_apply_cts_event_workaround(struct uart_amba_port *uap)
1489 return; 1341 return;
1490 1342
1491 /* workaround to make sure that all bits are unlocked.. */ 1343 /* workaround to make sure that all bits are unlocked.. */
1492 pl011_writew(uap, 0x00, REG_ICR); 1344 writew(0x00, uap->port.membase + UART011_ICR);
1493 1345
1494 /* 1346 /*
1495 * WA: introduce 26ns(1 uart clk) delay before W1C; 1347 * WA: introduce 26ns(1 uart clk) delay before W1C;
1496 * single apb access will incur 2 pclk(133.12Mhz) delay, 1348 * single apb access will incur 2 pclk(133.12Mhz) delay,
1497 * so add 2 dummy reads 1349 * so add 2 dummy reads
1498 */ 1350 */
1499 dummy_read = pl011_readw(uap, REG_ICR); 1351 dummy_read = readw(uap->port.membase + UART011_ICR);
1500 dummy_read = pl011_readw(uap, REG_ICR); 1352 dummy_read = readw(uap->port.membase + UART011_ICR);
1501} 1353}
1502 1354
1503static irqreturn_t pl011_int(int irq, void *dev_id) 1355static irqreturn_t pl011_int(int irq, void *dev_id)
@@ -1509,13 +1361,15 @@ static irqreturn_t pl011_int(int irq, void *dev_id)
1509 int handled = 0; 1361 int handled = 0;
1510 1362
1511 spin_lock_irqsave(&uap->port.lock, flags); 1363 spin_lock_irqsave(&uap->port.lock, flags);
1512 imsc = pl011_readw(uap, REG_IMSC); 1364 imsc = readw(uap->port.membase + UART011_IMSC);
1513 status = pl011_readw(uap, REG_RIS) & imsc; 1365 status = readw(uap->port.membase + UART011_RIS) & imsc;
1514 if (status) { 1366 if (status) {
1515 do { 1367 do {
1516 check_apply_cts_event_workaround(uap); 1368 check_apply_cts_event_workaround(uap);
1517 pl011_writew(uap, status & ~(UART011_TXIS|UART011_RTIS| 1369
1518 UART011_RXIS), REG_ICR); 1370 writew(status & ~(UART011_TXIS|UART011_RTIS|
1371 UART011_RXIS),
1372 uap->port.membase + UART011_ICR);
1519 1373
1520 if (status & (UART011_RTIS|UART011_RXIS)) { 1374 if (status & (UART011_RTIS|UART011_RXIS)) {
1521 if (pl011_dma_rx_running(uap)) 1375 if (pl011_dma_rx_running(uap))
@@ -1532,7 +1386,7 @@ static irqreturn_t pl011_int(int irq, void *dev_id)
1532 if (pass_counter-- == 0) 1386 if (pass_counter-- == 0)
1533 break; 1387 break;
1534 1388
1535 status = pl011_readw(uap, REG_RIS) & imsc; 1389 status = readw(uap->port.membase + UART011_RIS) & imsc;
1536 } while (status != 0); 1390 } while (status != 0);
1537 handled = 1; 1391 handled = 1;
1538 } 1392 }
@@ -1546,8 +1400,8 @@ static unsigned int pl011_tx_empty(struct uart_port *port)
1546{ 1400{
1547 struct uart_amba_port *uap = 1401 struct uart_amba_port *uap =
1548 container_of(port, struct uart_amba_port, port); 1402 container_of(port, struct uart_amba_port, port);
1549 unsigned int status = pl011_readw(uap, REG_FR); 1403 unsigned int status = readw(uap->port.membase + UART01x_FR);
1550 return status & (uap->fr_busy|UART01x_FR_TXFF) ? 0 : TIOCSER_TEMT; 1404 return status & (UART01x_FR_BUSY|UART01x_FR_TXFF) ? 0 : TIOCSER_TEMT;
1551} 1405}
1552 1406
1553static unsigned int pl011_get_mctrl(struct uart_port *port) 1407static unsigned int pl011_get_mctrl(struct uart_port *port)
@@ -1555,16 +1409,16 @@ static unsigned int pl011_get_mctrl(struct uart_port *port)
1555 struct uart_amba_port *uap = 1409 struct uart_amba_port *uap =
1556 container_of(port, struct uart_amba_port, port); 1410 container_of(port, struct uart_amba_port, port);
1557 unsigned int result = 0; 1411 unsigned int result = 0;
1558 unsigned int status = pl011_readw(uap, REG_FR); 1412 unsigned int status = readw(uap->port.membase + UART01x_FR);
1559 1413
1560#define TIOCMBIT(uartbit, tiocmbit) \ 1414#define TIOCMBIT(uartbit, tiocmbit) \
1561 if (status & uartbit) \ 1415 if (status & uartbit) \
1562 result |= tiocmbit 1416 result |= tiocmbit
1563 1417
1564 TIOCMBIT(UART01x_FR_DCD, TIOCM_CAR); 1418 TIOCMBIT(UART01x_FR_DCD, TIOCM_CAR);
1565 TIOCMBIT(uap->fr_dsr, TIOCM_DSR); 1419 TIOCMBIT(UART01x_FR_DSR, TIOCM_DSR);
1566 TIOCMBIT(uap->fr_cts, TIOCM_CTS); 1420 TIOCMBIT(UART01x_FR_CTS, TIOCM_CTS);
1567 TIOCMBIT(uap->fr_ri, TIOCM_RNG); 1421 TIOCMBIT(UART011_FR_RI, TIOCM_RNG);
1568#undef TIOCMBIT 1422#undef TIOCMBIT
1569 return result; 1423 return result;
1570} 1424}
@@ -1575,7 +1429,7 @@ static void pl011_set_mctrl(struct uart_port *port, unsigned int mctrl)
1575 container_of(port, struct uart_amba_port, port); 1429 container_of(port, struct uart_amba_port, port);
1576 unsigned int cr; 1430 unsigned int cr;
1577 1431
1578 cr = pl011_readw(uap, REG_CR); 1432 cr = readw(uap->port.membase + UART011_CR);
1579 1433
1580#define TIOCMBIT(tiocmbit, uartbit) \ 1434#define TIOCMBIT(tiocmbit, uartbit) \
1581 if (mctrl & tiocmbit) \ 1435 if (mctrl & tiocmbit) \
@@ -1595,7 +1449,7 @@ static void pl011_set_mctrl(struct uart_port *port, unsigned int mctrl)
1595 } 1449 }
1596#undef TIOCMBIT 1450#undef TIOCMBIT
1597 1451
1598 pl011_writew(uap, cr, REG_CR); 1452 writew(cr, uap->port.membase + UART011_CR);
1599} 1453}
1600 1454
1601static void pl011_break_ctl(struct uart_port *port, int break_state) 1455static void pl011_break_ctl(struct uart_port *port, int break_state)
@@ -1606,12 +1460,12 @@ static void pl011_break_ctl(struct uart_port *port, int break_state)
1606 unsigned int lcr_h; 1460 unsigned int lcr_h;
1607 1461
1608 spin_lock_irqsave(&uap->port.lock, flags); 1462 spin_lock_irqsave(&uap->port.lock, flags);
1609 lcr_h = pl011_readw(uap, uap->lcrh_tx); 1463 lcr_h = readw(uap->port.membase + uap->lcrh_tx);
1610 if (break_state == -1) 1464 if (break_state == -1)
1611 lcr_h |= UART01x_LCRH_BRK; 1465 lcr_h |= UART01x_LCRH_BRK;
1612 else 1466 else
1613 lcr_h &= ~UART01x_LCRH_BRK; 1467 lcr_h &= ~UART01x_LCRH_BRK;
1614 pl011_writew(uap, lcr_h, uap->lcrh_tx); 1468 writew(lcr_h, uap->port.membase + uap->lcrh_tx);
1615 spin_unlock_irqrestore(&uap->port.lock, flags); 1469 spin_unlock_irqrestore(&uap->port.lock, flags);
1616} 1470}
1617 1471
@@ -1621,8 +1475,9 @@ static void pl011_quiesce_irqs(struct uart_port *port)
1621{ 1475{
1622 struct uart_amba_port *uap = 1476 struct uart_amba_port *uap =
1623 container_of(port, struct uart_amba_port, port); 1477 container_of(port, struct uart_amba_port, port);
1478 unsigned char __iomem *regs = uap->port.membase;
1624 1479
1625 pl011_writew(uap, pl011_readw(uap, REG_MIS), REG_ICR); 1480 writew(readw(regs + UART011_MIS), regs + UART011_ICR);
1626 /* 1481 /*
1627 * There is no way to clear TXIM as this is "ready to transmit IRQ", so 1482 * There is no way to clear TXIM as this is "ready to transmit IRQ", so
1628 * we simply mask it. start_tx() will unmask it. 1483 * we simply mask it. start_tx() will unmask it.
@@ -1636,7 +1491,7 @@ static void pl011_quiesce_irqs(struct uart_port *port)
1636 * (including tx queue), so we're also fine with start_tx()'s caller 1491 * (including tx queue), so we're also fine with start_tx()'s caller
1637 * side. 1492 * side.
1638 */ 1493 */
1639 pl011_writew(uap, pl011_readw(uap, REG_IMSC) & ~UART011_TXIM, REG_IMSC); 1494 writew(readw(regs + UART011_IMSC) & ~UART011_TXIM, regs + UART011_IMSC);
1640} 1495}
1641 1496
1642static int pl011_get_poll_char(struct uart_port *port) 1497static int pl011_get_poll_char(struct uart_port *port)
@@ -1651,11 +1506,11 @@ static int pl011_get_poll_char(struct uart_port *port)
1651 */ 1506 */
1652 pl011_quiesce_irqs(port); 1507 pl011_quiesce_irqs(port);
1653 1508
1654 status = pl011_readw(uap, REG_FR); 1509 status = readw(uap->port.membase + UART01x_FR);
1655 if (status & UART01x_FR_RXFE) 1510 if (status & UART01x_FR_RXFE)
1656 return NO_POLL_CHAR; 1511 return NO_POLL_CHAR;
1657 1512
1658 return pl011_readw(uap, REG_DR); 1513 return readw(uap->port.membase + UART01x_DR);
1659} 1514}
1660 1515
1661static void pl011_put_poll_char(struct uart_port *port, 1516static void pl011_put_poll_char(struct uart_port *port,
@@ -1664,10 +1519,10 @@ static void pl011_put_poll_char(struct uart_port *port,
1664 struct uart_amba_port *uap = 1519 struct uart_amba_port *uap =
1665 container_of(port, struct uart_amba_port, port); 1520 container_of(port, struct uart_amba_port, port);
1666 1521
1667 while (pl011_readw(uap, REG_FR) & UART01x_FR_TXFF) 1522 while (readw(uap->port.membase + UART01x_FR) & UART01x_FR_TXFF)
1668 barrier(); 1523 barrier();
1669 1524
1670 pl011_writew(uap, ch, REG_DR); 1525 writew(ch, uap->port.membase + UART01x_DR);
1671} 1526}
1672 1527
1673#endif /* CONFIG_CONSOLE_POLL */ 1528#endif /* CONFIG_CONSOLE_POLL */
@@ -1691,15 +1546,15 @@ static int pl011_hwinit(struct uart_port *port)
1691 uap->port.uartclk = clk_get_rate(uap->clk); 1546 uap->port.uartclk = clk_get_rate(uap->clk);
1692 1547
1693 /* Clear pending error and receive interrupts */ 1548 /* Clear pending error and receive interrupts */
1694 pl011_writew(uap, UART011_OEIS | UART011_BEIS | UART011_PEIS | 1549 writew(UART011_OEIS | UART011_BEIS | UART011_PEIS | UART011_FEIS |
1695 UART011_FEIS | UART011_RTIS | UART011_RXIS, REG_ICR); 1550 UART011_RTIS | UART011_RXIS, uap->port.membase + UART011_ICR);
1696 1551
1697 /* 1552 /*
1698 * Save interrupts enable mask, and enable RX interrupts in case if 1553 * Save interrupts enable mask, and enable RX interrupts in case if
1699 * the interrupt is used for NMI entry. 1554 * the interrupt is used for NMI entry.
1700 */ 1555 */
1701 uap->im = pl011_readw(uap, REG_IMSC); 1556 uap->im = readw(uap->port.membase + UART011_IMSC);
1702 pl011_writew(uap, UART011_RTIM | UART011_RXIM, REG_IMSC); 1557 writew(UART011_RTIM | UART011_RXIM, uap->port.membase + UART011_IMSC);
1703 1558
1704 if (dev_get_platdata(uap->port.dev)) { 1559 if (dev_get_platdata(uap->port.dev)) {
1705 struct amba_pl011_data *plat; 1560 struct amba_pl011_data *plat;
@@ -1713,22 +1568,22 @@ static int pl011_hwinit(struct uart_port *port)
1713 1568
1714static void pl011_write_lcr_h(struct uart_amba_port *uap, unsigned int lcr_h) 1569static void pl011_write_lcr_h(struct uart_amba_port *uap, unsigned int lcr_h)
1715{ 1570{
1716 pl011_writew(uap, lcr_h, uap->lcrh_rx); 1571 writew(lcr_h, uap->port.membase + uap->lcrh_rx);
1717 if (is_implemented(uap, REG_ST_LCRH_RX)) { 1572 if (uap->lcrh_rx != uap->lcrh_tx) {
1718 int i; 1573 int i;
1719 /* 1574 /*
1720 * Wait 10 PCLKs before writing LCRH_TX register, 1575 * Wait 10 PCLKs before writing LCRH_TX register,
1721 * to get this delay write read only register 10 times 1576 * to get this delay write read only register 10 times
1722 */ 1577 */
1723 for (i = 0; i < 10; ++i) 1578 for (i = 0; i < 10; ++i)
1724 pl011_writew(uap, 0xff, REG_MIS); 1579 writew(0xff, uap->port.membase + UART011_MIS);
1725 pl011_writew(uap, lcr_h, uap->lcrh_tx); 1580 writew(lcr_h, uap->port.membase + uap->lcrh_tx);
1726 } 1581 }
1727} 1582}
1728 1583
1729static int pl011_allocate_irq(struct uart_amba_port *uap) 1584static int pl011_allocate_irq(struct uart_amba_port *uap)
1730{ 1585{
1731 pl011_writew(uap, uap->im, REG_IMSC); 1586 writew(uap->im, uap->port.membase + UART011_IMSC);
1732 1587
1733 return request_irq(uap->port.irq, pl011_int, 0, "uart-pl011", uap); 1588 return request_irq(uap->port.irq, pl011_int, 0, "uart-pl011", uap);
1734} 1589}
@@ -1743,11 +1598,12 @@ static void pl011_enable_interrupts(struct uart_amba_port *uap)
1743 spin_lock_irq(&uap->port.lock); 1598 spin_lock_irq(&uap->port.lock);
1744 1599
1745 /* Clear out any spuriously appearing RX interrupts */ 1600 /* Clear out any spuriously appearing RX interrupts */
1746 pl011_writew(uap, UART011_RTIS | UART011_RXIS, REG_ICR); 1601 writew(UART011_RTIS | UART011_RXIS,
1602 uap->port.membase + UART011_ICR);
1747 uap->im = UART011_RTIM; 1603 uap->im = UART011_RTIM;
1748 if (!pl011_dma_rx_running(uap)) 1604 if (!pl011_dma_rx_running(uap))
1749 uap->im |= UART011_RXIM; 1605 uap->im |= UART011_RXIM;
1750 pl011_writew(uap, uap->im, REG_IMSC); 1606 writew(uap->im, uap->port.membase + UART011_IMSC);
1751 spin_unlock_irq(&uap->port.lock); 1607 spin_unlock_irq(&uap->port.lock);
1752} 1608}
1753 1609
@@ -1766,21 +1622,21 @@ static int pl011_startup(struct uart_port *port)
1766 if (retval) 1622 if (retval)
1767 goto clk_dis; 1623 goto clk_dis;
1768 1624
1769 pl011_writew(uap, uap->vendor->ifls, REG_IFLS); 1625 writew(uap->vendor->ifls, uap->port.membase + UART011_IFLS);
1770 1626
1771 spin_lock_irq(&uap->port.lock); 1627 spin_lock_irq(&uap->port.lock);
1772 1628
1773 /* restore RTS and DTR */ 1629 /* restore RTS and DTR */
1774 cr = uap->old_cr & (UART011_CR_RTS | UART011_CR_DTR); 1630 cr = uap->old_cr & (UART011_CR_RTS | UART011_CR_DTR);
1775 cr |= UART01x_CR_UARTEN | UART011_CR_RXE | UART011_CR_TXE; 1631 cr |= UART01x_CR_UARTEN | UART011_CR_RXE | UART011_CR_TXE;
1776 pl011_writew(uap, cr, REG_CR); 1632 writew(cr, uap->port.membase + UART011_CR);
1777 1633
1778 spin_unlock_irq(&uap->port.lock); 1634 spin_unlock_irq(&uap->port.lock);
1779 1635
1780 /* 1636 /*
1781 * initialise the old status of the modem signals 1637 * initialise the old status of the modem signals
1782 */ 1638 */
1783 uap->old_status = pl011_readw(uap, REG_FR) & UART01x_FR_MODEM_ANY; 1639 uap->old_status = readw(uap->port.membase + UART01x_FR) & UART01x_FR_MODEM_ANY;
1784 1640
1785 /* Startup DMA */ 1641 /* Startup DMA */
1786 pl011_dma_startup(uap); 1642 pl011_dma_startup(uap);
@@ -1819,11 +1675,11 @@ static int sbsa_uart_startup(struct uart_port *port)
1819static void pl011_shutdown_channel(struct uart_amba_port *uap, 1675static void pl011_shutdown_channel(struct uart_amba_port *uap,
1820 unsigned int lcrh) 1676 unsigned int lcrh)
1821{ 1677{
1822 unsigned long val; 1678 unsigned long val;
1823 1679
1824 val = pl011_readw(uap, lcrh); 1680 val = readw(uap->port.membase + lcrh);
1825 val &= ~(UART01x_LCRH_BRK | UART01x_LCRH_FEN); 1681 val &= ~(UART01x_LCRH_BRK | UART01x_LCRH_FEN);
1826 pl011_writew(uap, val, lcrh); 1682 writew(val, uap->port.membase + lcrh);
1827} 1683}
1828 1684
1829/* 1685/*
@@ -1837,18 +1693,18 @@ static void pl011_disable_uart(struct uart_amba_port *uap)
1837 1693
1838 uap->autorts = false; 1694 uap->autorts = false;
1839 spin_lock_irq(&uap->port.lock); 1695 spin_lock_irq(&uap->port.lock);
1840 cr = pl011_readw(uap, REG_CR); 1696 cr = readw(uap->port.membase + UART011_CR);
1841 uap->old_cr = cr; 1697 uap->old_cr = cr;
1842 cr &= UART011_CR_RTS | UART011_CR_DTR; 1698 cr &= UART011_CR_RTS | UART011_CR_DTR;
1843 cr |= UART01x_CR_UARTEN | UART011_CR_TXE; 1699 cr |= UART01x_CR_UARTEN | UART011_CR_TXE;
1844 pl011_writew(uap, cr, REG_CR); 1700 writew(cr, uap->port.membase + UART011_CR);
1845 spin_unlock_irq(&uap->port.lock); 1701 spin_unlock_irq(&uap->port.lock);
1846 1702
1847 /* 1703 /*
1848 * disable break condition and fifos 1704 * disable break condition and fifos
1849 */ 1705 */
1850 pl011_shutdown_channel(uap, uap->lcrh_rx); 1706 pl011_shutdown_channel(uap, uap->lcrh_rx);
1851 if (is_implemented(uap, REG_ST_LCRH_RX)) 1707 if (uap->lcrh_rx != uap->lcrh_tx)
1852 pl011_shutdown_channel(uap, uap->lcrh_tx); 1708 pl011_shutdown_channel(uap, uap->lcrh_tx);
1853} 1709}
1854 1710
@@ -1858,8 +1714,8 @@ static void pl011_disable_interrupts(struct uart_amba_port *uap)
1858 1714
1859 /* mask all interrupts and clear all pending ones */ 1715 /* mask all interrupts and clear all pending ones */
1860 uap->im = 0; 1716 uap->im = 0;
1861 pl011_writew(uap, uap->im, REG_IMSC); 1717 writew(uap->im, uap->port.membase + UART011_IMSC);
1862 pl011_writew(uap, 0xffff, REG_ICR); 1718 writew(0xffff, uap->port.membase + UART011_ICR);
1863 1719
1864 spin_unlock_irq(&uap->port.lock); 1720 spin_unlock_irq(&uap->port.lock);
1865} 1721}
@@ -2011,8 +1867,8 @@ pl011_set_termios(struct uart_port *port, struct ktermios *termios,
2011 pl011_enable_ms(port); 1867 pl011_enable_ms(port);
2012 1868
2013 /* first, disable everything */ 1869 /* first, disable everything */
2014 old_cr = pl011_readw(uap, REG_CR); 1870 old_cr = readw(port->membase + UART011_CR);
2015 pl011_writew(uap, 0, REG_CR); 1871 writew(0, port->membase + UART011_CR);
2016 1872
2017 if (termios->c_cflag & CRTSCTS) { 1873 if (termios->c_cflag & CRTSCTS) {
2018 if (old_cr & UART011_CR_RTS) 1874 if (old_cr & UART011_CR_RTS)
@@ -2045,17 +1901,17 @@ pl011_set_termios(struct uart_port *port, struct ktermios *termios,
2045 quot -= 2; 1901 quot -= 2;
2046 } 1902 }
2047 /* Set baud rate */ 1903 /* Set baud rate */
2048 pl011_writew(uap, quot & 0x3f, REG_FBRD); 1904 writew(quot & 0x3f, port->membase + UART011_FBRD);
2049 pl011_writew(uap, quot >> 6, REG_IBRD); 1905 writew(quot >> 6, port->membase + UART011_IBRD);
2050 1906
2051 /* 1907 /*
2052 * ----------v----------v----------v----------v----- 1908 * ----------v----------v----------v----------v-----
2053 * NOTE: lcrh_tx and lcrh_rx MUST BE WRITTEN AFTER 1909 * NOTE: lcrh_tx and lcrh_rx MUST BE WRITTEN AFTER
2054 * REG_FBRD & REG_IBRD. 1910 * UART011_FBRD & UART011_IBRD.
2055 * ----------^----------^----------^----------^----- 1911 * ----------^----------^----------^----------^-----
2056 */ 1912 */
2057 pl011_write_lcr_h(uap, lcr_h); 1913 pl011_write_lcr_h(uap, lcr_h);
2058 pl011_writew(uap, old_cr, REG_CR); 1914 writew(old_cr, port->membase + UART011_CR);
2059 1915
2060 spin_unlock_irqrestore(&port->lock, flags); 1916 spin_unlock_irqrestore(&port->lock, flags);
2061} 1917}
@@ -2196,9 +2052,9 @@ static void pl011_console_putchar(struct uart_port *port, int ch)
2196 struct uart_amba_port *uap = 2052 struct uart_amba_port *uap =
2197 container_of(port, struct uart_amba_port, port); 2053 container_of(port, struct uart_amba_port, port);
2198 2054
2199 while (pl011_readw(uap, REG_FR) & UART01x_FR_TXFF) 2055 while (readw(uap->port.membase + UART01x_FR) & UART01x_FR_TXFF)
2200 barrier(); 2056 barrier();
2201 pl011_writew(uap, ch, REG_DR); 2057 writew(ch, uap->port.membase + UART01x_DR);
2202} 2058}
2203 2059
2204static void 2060static void
@@ -2223,10 +2079,10 @@ pl011_console_write(struct console *co, const char *s, unsigned int count)
2223 * First save the CR then disable the interrupts 2079 * First save the CR then disable the interrupts
2224 */ 2080 */
2225 if (!uap->vendor->always_enabled) { 2081 if (!uap->vendor->always_enabled) {
2226 old_cr = pl011_readw(uap, REG_CR); 2082 old_cr = readw(uap->port.membase + UART011_CR);
2227 new_cr = old_cr & ~UART011_CR_CTSEN; 2083 new_cr = old_cr & ~UART011_CR_CTSEN;
2228 new_cr |= UART01x_CR_UARTEN | UART011_CR_TXE; 2084 new_cr |= UART01x_CR_UARTEN | UART011_CR_TXE;
2229 pl011_writew(uap, new_cr, REG_CR); 2085 writew(new_cr, uap->port.membase + UART011_CR);
2230 } 2086 }
2231 2087
2232 uart_console_write(&uap->port, s, count, pl011_console_putchar); 2088 uart_console_write(&uap->port, s, count, pl011_console_putchar);
@@ -2236,10 +2092,10 @@ pl011_console_write(struct console *co, const char *s, unsigned int count)
2236 * and restore the TCR 2092 * and restore the TCR
2237 */ 2093 */
2238 do { 2094 do {
2239 status = pl011_readw(uap, REG_FR); 2095 status = readw(uap->port.membase + UART01x_FR);
2240 } while (status & uap->fr_busy); 2096 } while (status & UART01x_FR_BUSY);
2241 if (!uap->vendor->always_enabled) 2097 if (!uap->vendor->always_enabled)
2242 pl011_writew(uap, old_cr, REG_CR); 2098 writew(old_cr, uap->port.membase + UART011_CR);
2243 2099
2244 if (locked) 2100 if (locked)
2245 spin_unlock(&uap->port.lock); 2101 spin_unlock(&uap->port.lock);
@@ -2252,10 +2108,10 @@ static void __init
2252pl011_console_get_options(struct uart_amba_port *uap, int *baud, 2108pl011_console_get_options(struct uart_amba_port *uap, int *baud,
2253 int *parity, int *bits) 2109 int *parity, int *bits)
2254{ 2110{
2255 if (pl011_readw(uap, REG_CR) & UART01x_CR_UARTEN) { 2111 if (readw(uap->port.membase + UART011_CR) & UART01x_CR_UARTEN) {
2256 unsigned int lcr_h, ibrd, fbrd; 2112 unsigned int lcr_h, ibrd, fbrd;
2257 2113
2258 lcr_h = pl011_readw(uap, uap->lcrh_tx); 2114 lcr_h = readw(uap->port.membase + uap->lcrh_tx);
2259 2115
2260 *parity = 'n'; 2116 *parity = 'n';
2261 if (lcr_h & UART01x_LCRH_PEN) { 2117 if (lcr_h & UART01x_LCRH_PEN) {
@@ -2270,13 +2126,13 @@ pl011_console_get_options(struct uart_amba_port *uap, int *baud,
2270 else 2126 else
2271 *bits = 8; 2127 *bits = 8;
2272 2128
2273 ibrd = pl011_readw(uap, REG_IBRD); 2129 ibrd = readw(uap->port.membase + UART011_IBRD);
2274 fbrd = pl011_readw(uap, REG_FBRD); 2130 fbrd = readw(uap->port.membase + UART011_FBRD);
2275 2131
2276 *baud = uap->port.uartclk * 4 / (64 * ibrd + fbrd); 2132 *baud = uap->port.uartclk * 4 / (64 * ibrd + fbrd);
2277 2133
2278 if (uap->vendor->oversampling) { 2134 if (uap->vendor->oversampling) {
2279 if (pl011_readw(uap, REG_CR) 2135 if (readw(uap->port.membase + UART011_CR)
2280 & ST_UART011_CR_OVSFACT) 2136 & ST_UART011_CR_OVSFACT)
2281 *baud *= 2; 2137 *baud *= 2;
2282 } 2138 }
@@ -2348,13 +2204,10 @@ static struct console amba_console = {
2348 2204
2349static void pl011_putc(struct uart_port *port, int c) 2205static void pl011_putc(struct uart_port *port, int c)
2350{ 2206{
2351 struct uart_amba_port *uap = 2207 while (readl(port->membase + UART01x_FR) & UART01x_FR_TXFF)
2352 container_of(port, struct uart_amba_port, port);
2353
2354 while (pl011_readw(uap, REG_FR) & UART01x_FR_TXFF)
2355 ; 2208 ;
2356 pl011_writeb(uap, c, REG_DR); 2209 writeb(c, port->membase + UART01x_DR);
2357 while (pl011_readw(uap, REG_FR) & uap->fr_busy) 2210 while (readl(port->membase + UART01x_FR) & UART01x_FR_BUSY)
2358 ; 2211 ;
2359} 2212}
2360 2213
@@ -2481,8 +2334,8 @@ static int pl011_register_port(struct uart_amba_port *uap)
2481 int ret; 2334 int ret;
2482 2335
2483 /* Ensure interrupts from this UART are masked and cleared */ 2336 /* Ensure interrupts from this UART are masked and cleared */
2484 pl011_writew(uap, 0, REG_IMSC); 2337 writew(0, uap->port.membase + UART011_IMSC);
2485 pl011_writew(uap, 0xffff, REG_ICR); 2338 writew(0xffff, uap->port.membase + UART011_ICR);
2486 2339
2487 if (!amba_reg.state) { 2340 if (!amba_reg.state) {
2488 ret = uart_register_driver(&amba_reg); 2341 ret = uart_register_driver(&amba_reg);
@@ -2500,7 +2353,6 @@ static int pl011_register_port(struct uart_amba_port *uap)
2500 return ret; 2353 return ret;
2501} 2354}
2502 2355
2503#ifdef CONFIG_ARM_AMBA
2504static int pl011_probe(struct amba_device *dev, const struct amba_id *id) 2356static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
2505{ 2357{
2506 struct uart_amba_port *uap; 2358 struct uart_amba_port *uap;
@@ -2521,13 +2373,8 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
2521 return PTR_ERR(uap->clk); 2373 return PTR_ERR(uap->clk);
2522 2374
2523 uap->vendor = vendor; 2375 uap->vendor = vendor;
2524 uap->reg_lut = vendor->reg_lut;
2525 uap->lcrh_rx = vendor->lcrh_rx; 2376 uap->lcrh_rx = vendor->lcrh_rx;
2526 uap->lcrh_tx = vendor->lcrh_tx; 2377 uap->lcrh_tx = vendor->lcrh_tx;
2527 uap->fr_busy = vendor->fr_busy;
2528 uap->fr_dsr = vendor->fr_dsr;
2529 uap->fr_cts = vendor->fr_cts;
2530 uap->fr_ri = vendor->fr_ri;
2531 uap->fifosize = vendor->get_fifosize(dev); 2378 uap->fifosize = vendor->get_fifosize(dev);
2532 uap->port.irq = dev->irq[0]; 2379 uap->port.irq = dev->irq[0];
2533 uap->port.ops = &amba_pl011_pops; 2380 uap->port.ops = &amba_pl011_pops;
@@ -2551,67 +2398,6 @@ static int pl011_remove(struct amba_device *dev)
2551 pl011_unregister_port(uap); 2398 pl011_unregister_port(uap);
2552 return 0; 2399 return 0;
2553} 2400}
2554#endif
2555
2556#ifdef CONFIG_SOC_ZX296702
2557static int zx_uart_probe(struct platform_device *pdev)
2558{
2559 struct uart_amba_port *uap;
2560 struct vendor_data *vendor = &vendor_zte;
2561 struct resource *res;
2562 int portnr, ret;
2563
2564 portnr = pl011_find_free_port();
2565 if (portnr < 0)
2566 return portnr;
2567
2568 uap = devm_kzalloc(&pdev->dev, sizeof(struct uart_amba_port),
2569 GFP_KERNEL);
2570 if (!uap) {
2571 ret = -ENOMEM;
2572 goto out;
2573 }
2574
2575 uap->clk = devm_clk_get(&pdev->dev, NULL);
2576 if (IS_ERR(uap->clk)) {
2577 ret = PTR_ERR(uap->clk);
2578 goto out;
2579 }
2580
2581 uap->vendor = vendor;
2582 uap->reg_lut = vendor->reg_lut;
2583 uap->lcrh_rx = vendor->lcrh_rx;
2584 uap->lcrh_tx = vendor->lcrh_tx;
2585 uap->fr_busy = vendor->fr_busy;
2586 uap->fr_dsr = vendor->fr_dsr;
2587 uap->fr_cts = vendor->fr_cts;
2588 uap->fr_ri = vendor->fr_ri;
2589 uap->fifosize = 16;
2590 uap->port.irq = platform_get_irq(pdev, 0);
2591 uap->port.ops = &amba_pl011_pops;
2592
2593 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2594
2595 ret = pl011_setup_port(&pdev->dev, uap, res, portnr);
2596 if (ret)
2597 return ret;
2598
2599 platform_set_drvdata(pdev, uap);
2600
2601 return pl011_register_port(uap);
2602out:
2603 return ret;
2604}
2605
2606static int zx_uart_remove(struct platform_device *pdev)
2607{
2608 struct uart_amba_port *uap = platform_get_drvdata(pdev);
2609
2610 uart_remove_one_port(&amba_reg, &uap->port);
2611 pl011_unregister_port(uap);
2612 return 0;
2613}
2614#endif
2615 2401
2616#ifdef CONFIG_PM_SLEEP 2402#ifdef CONFIG_PM_SLEEP
2617static int pl011_suspend(struct device *dev) 2403static int pl011_suspend(struct device *dev)
@@ -2668,11 +2454,6 @@ static int sbsa_uart_probe(struct platform_device *pdev)
2668 return -ENOMEM; 2454 return -ENOMEM;
2669 2455
2670 uap->vendor = &vendor_sbsa; 2456 uap->vendor = &vendor_sbsa;
2671 uap->reg_lut = vendor_sbsa.reg_lut;
2672 uap->fr_busy = vendor_sbsa.fr_busy;
2673 uap->fr_dsr = vendor_sbsa.fr_dsr;
2674 uap->fr_cts = vendor_sbsa.fr_cts;
2675 uap->fr_ri = vendor_sbsa.fr_ri;
2676 uap->fifosize = 32; 2457 uap->fifosize = 32;
2677 uap->port.irq = platform_get_irq(pdev, 0); 2458 uap->port.irq = platform_get_irq(pdev, 0);
2678 uap->port.ops = &sbsa_uart_pops; 2459 uap->port.ops = &sbsa_uart_pops;
@@ -2722,7 +2503,6 @@ static struct platform_driver arm_sbsa_uart_platform_driver = {
2722 }, 2503 },
2723}; 2504};
2724 2505
2725#ifdef CONFIG_ARM_AMBA
2726static struct amba_id pl011_ids[] = { 2506static struct amba_id pl011_ids[] = {
2727 { 2507 {
2728 .id = 0x00041011, 2508 .id = 0x00041011,
@@ -2748,57 +2528,20 @@ static struct amba_driver pl011_driver = {
2748 .probe = pl011_probe, 2528 .probe = pl011_probe,
2749 .remove = pl011_remove, 2529 .remove = pl011_remove,
2750}; 2530};
2751#endif
2752
2753#ifdef CONFIG_SOC_ZX296702
2754static const struct of_device_id zx_uart_dt_ids[] = {
2755 { .compatible = "zte,zx296702-uart", },
2756 { /* sentinel */ }
2757};
2758MODULE_DEVICE_TABLE(of, zx_uart_dt_ids);
2759
2760static struct platform_driver zx_uart_driver = {
2761 .driver = {
2762 .name = "zx-uart",
2763 .owner = THIS_MODULE,
2764 .pm = &pl011_dev_pm_ops,
2765 .of_match_table = zx_uart_dt_ids,
2766 },
2767 .probe = zx_uart_probe,
2768 .remove = zx_uart_remove,
2769};
2770#endif
2771
2772 2531
2773static int __init pl011_init(void) 2532static int __init pl011_init(void)
2774{ 2533{
2775 int ret;
2776 printk(KERN_INFO "Serial: AMBA PL011 UART driver\n"); 2534 printk(KERN_INFO "Serial: AMBA PL011 UART driver\n");
2777 2535
2778 if (platform_driver_register(&arm_sbsa_uart_platform_driver)) 2536 if (platform_driver_register(&arm_sbsa_uart_platform_driver))
2779 pr_warn("could not register SBSA UART platform driver\n"); 2537 pr_warn("could not register SBSA UART platform driver\n");
2780 2538 return amba_driver_register(&pl011_driver);
2781#ifdef CONFIG_SOC_ZX296702
2782 ret = platform_driver_register(&zx_uart_driver);
2783 if (ret)
2784 pr_warn("could not register ZX UART platform driver\n");
2785#endif
2786
2787#ifdef CONFIG_ARM_AMBA
2788 ret = amba_driver_register(&pl011_driver);
2789#endif
2790 return ret;
2791} 2539}
2792 2540
2793static void __exit pl011_exit(void) 2541static void __exit pl011_exit(void)
2794{ 2542{
2795 platform_driver_unregister(&arm_sbsa_uart_platform_driver); 2543 platform_driver_unregister(&arm_sbsa_uart_platform_driver);
2796#ifdef CONFIG_SOC_ZX296702
2797 platform_driver_unregister(&zx_uart_driver);
2798#endif
2799#ifdef CONFIG_ARM_AMBA
2800 amba_driver_unregister(&pl011_driver); 2544 amba_driver_unregister(&pl011_driver);
2801#endif
2802} 2545}
2803 2546
2804/* 2547/*
diff --git a/include/linux/amba/serial.h b/include/linux/amba/serial.h
index 6a0a89ed7f81..0ddb5c02ad8b 100644
--- a/include/linux/amba/serial.h
+++ b/include/linux/amba/serial.h
@@ -33,14 +33,12 @@
33#define UART01x_DR 0x00 /* Data read or written from the interface. */ 33#define UART01x_DR 0x00 /* Data read or written from the interface. */
34#define UART01x_RSR 0x04 /* Receive status register (Read). */ 34#define UART01x_RSR 0x04 /* Receive status register (Read). */
35#define UART01x_ECR 0x04 /* Error clear register (Write). */ 35#define UART01x_ECR 0x04 /* Error clear register (Write). */
36#define ZX_UART01x_DR 0x04 /* Data read or written from the interface. */
37#define UART010_LCRH 0x08 /* Line control register, high byte. */ 36#define UART010_LCRH 0x08 /* Line control register, high byte. */
38#define ST_UART011_DMAWM 0x08 /* DMA watermark configure register. */ 37#define ST_UART011_DMAWM 0x08 /* DMA watermark configure register. */
39#define UART010_LCRM 0x0C /* Line control register, middle byte. */ 38#define UART010_LCRM 0x0C /* Line control register, middle byte. */
40#define ST_UART011_TIMEOUT 0x0C /* Timeout period register. */ 39#define ST_UART011_TIMEOUT 0x0C /* Timeout period register. */
41#define UART010_LCRL 0x10 /* Line control register, low byte. */ 40#define UART010_LCRL 0x10 /* Line control register, low byte. */
42#define UART010_CR 0x14 /* Control register. */ 41#define UART010_CR 0x14 /* Control register. */
43#define ZX_UART01x_FR 0x14 /* Flag register (Read only). */
44#define UART01x_FR 0x18 /* Flag register (Read only). */ 42#define UART01x_FR 0x18 /* Flag register (Read only). */
45#define UART010_IIR 0x1C /* Interrupt identification register (Read). */ 43#define UART010_IIR 0x1C /* Interrupt identification register (Read). */
46#define UART010_ICR 0x1C /* Interrupt clear register (Write). */ 44#define UART010_ICR 0x1C /* Interrupt clear register (Write). */
@@ -51,21 +49,13 @@
51#define UART011_LCRH 0x2c /* Line control register. */ 49#define UART011_LCRH 0x2c /* Line control register. */
52#define ST_UART011_LCRH_TX 0x2c /* Tx Line control register. */ 50#define ST_UART011_LCRH_TX 0x2c /* Tx Line control register. */
53#define UART011_CR 0x30 /* Control register. */ 51#define UART011_CR 0x30 /* Control register. */
54#define ZX_UART011_LCRH_TX 0x30 /* Tx Line control register. */
55#define UART011_IFLS 0x34 /* Interrupt fifo level select. */ 52#define UART011_IFLS 0x34 /* Interrupt fifo level select. */
56#define ZX_UART011_CR 0x34 /* Control register. */
57#define ZX_UART011_IFLS 0x38 /* Interrupt fifo level select. */
58#define UART011_IMSC 0x38 /* Interrupt mask. */ 53#define UART011_IMSC 0x38 /* Interrupt mask. */
59#define UART011_RIS 0x3c /* Raw interrupt status. */ 54#define UART011_RIS 0x3c /* Raw interrupt status. */
60#define UART011_MIS 0x40 /* Masked interrupt status. */ 55#define UART011_MIS 0x40 /* Masked interrupt status. */
61#define ZX_UART011_IMSC 0x40 /* Interrupt mask. */
62#define UART011_ICR 0x44 /* Interrupt clear register. */ 56#define UART011_ICR 0x44 /* Interrupt clear register. */
63#define ZX_UART011_RIS 0x44 /* Raw interrupt status. */
64#define UART011_DMACR 0x48 /* DMA control register. */ 57#define UART011_DMACR 0x48 /* DMA control register. */
65#define ZX_UART011_MIS 0x48 /* Masked interrupt status. */
66#define ZX_UART011_ICR 0x4c /* Interrupt clear register. */
67#define ST_UART011_XFCR 0x50 /* XON/XOFF control register. */ 58#define ST_UART011_XFCR 0x50 /* XON/XOFF control register. */
68#define ZX_UART011_DMACR 0x50 /* DMA control register. */
69#define ST_UART011_XON1 0x54 /* XON1 register. */ 59#define ST_UART011_XON1 0x54 /* XON1 register. */
70#define ST_UART011_XON2 0x58 /* XON2 register. */ 60#define ST_UART011_XON2 0x58 /* XON2 register. */
71#define ST_UART011_XOFF1 0x5C /* XON1 register. */ 61#define ST_UART011_XOFF1 0x5C /* XON1 register. */
@@ -85,19 +75,15 @@
85#define UART01x_RSR_PE 0x02 75#define UART01x_RSR_PE 0x02
86#define UART01x_RSR_FE 0x01 76#define UART01x_RSR_FE 0x01
87 77
88#define ZX_UART01x_FR_BUSY 0x300
89#define UART011_FR_RI 0x100 78#define UART011_FR_RI 0x100
90#define UART011_FR_TXFE 0x080 79#define UART011_FR_TXFE 0x080
91#define UART011_FR_RXFF 0x040 80#define UART011_FR_RXFF 0x040
92#define UART01x_FR_TXFF 0x020 81#define UART01x_FR_TXFF 0x020
93#define UART01x_FR_RXFE 0x010 82#define UART01x_FR_RXFE 0x010
94#define UART01x_FR_BUSY 0x008 83#define UART01x_FR_BUSY 0x008
95#define ZX_UART01x_FR_DSR 0x008
96#define UART01x_FR_DCD 0x004 84#define UART01x_FR_DCD 0x004
97#define UART01x_FR_DSR 0x002 85#define UART01x_FR_DSR 0x002
98#define ZX_UART01x_FR_CTS 0x002
99#define UART01x_FR_CTS 0x001 86#define UART01x_FR_CTS 0x001
100#define ZX_UART011_FR_RI 0x001
101#define UART01x_FR_TMSK (UART01x_FR_TXFF + UART01x_FR_BUSY) 87#define UART01x_FR_TMSK (UART01x_FR_TXFF + UART01x_FR_BUSY)
102 88
103#define UART011_CR_CTSEN 0x8000 /* CTS hardware flow control */ 89#define UART011_CR_CTSEN 0x8000 /* CTS hardware flow control */