Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tty: xuartps: Rebrand driver as Cadence UART

Zynq's UART is Cadence IP. Make this visible in the prompt in kconfig
and additional comments in the driver.
This also renames functions and symbols, as far as possible without
breaking user space API, to reflect the Cadence origin. This is achieved
through simple search and replace:
- s/XUARTPS/CDNS_UART/g
- s/xuartps/cdns_uart/g
The only exceptions are PORT_XUARTPS and the driver name, which stay as is,
due to their exposure to user space. As well as the - no legacy -
compatibility string 'xlnx,xuartps'

Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
Tested-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Soren Brinkmann and committed by
Greg Kroah-Hartman
d9bb3fb1 b494a5fa

+471 -448
+5 -4
drivers/tty/serial/Kconfig
··· 1369 1369 Enable a MXS AUART port to be the system console. 1370 1370 1371 1371 config SERIAL_XILINX_PS_UART 1372 - tristate "Xilinx PS UART support" 1372 + tristate "Cadence (Xilinx Zynq) UART support" 1373 1373 depends on OF 1374 1374 select SERIAL_CORE 1375 1375 help 1376 - This driver supports the Xilinx PS UART port. 1376 + This driver supports the Cadence UART. It is found e.g. in Xilinx 1377 + Zynq. 1377 1378 1378 1379 config SERIAL_XILINX_PS_UART_CONSOLE 1379 - bool "Xilinx PS UART console support" 1380 + bool "Cadence UART console support" 1380 1381 depends on SERIAL_XILINX_PS_UART=y 1381 1382 select SERIAL_CORE_CONSOLE 1382 1383 help 1383 - Enable a Xilinx PS UART port to be the system console. 1384 + Enable a Cadence UART port to be the system console. 1384 1385 1385 1386 config SERIAL_AR933X 1386 1387 tristate "AR933X serial port support"
+465 -443
drivers/tty/serial/xilinx_uartps.c
··· 1 1 /* 2 - * Xilinx PS UART driver 2 + * Cadence UART driver (found in Xilinx Zynq) 3 3 * 4 4 * 2011 - 2014 (C) Xilinx Inc. 5 5 * ··· 8 8 * License as published by the Free Software Foundation; 9 9 * either version 2 of the License, or (at your option) any 10 10 * later version. 11 + * 12 + * This driver has originally been pushed by Xilinx using a Zynq-branding. This 13 + * still shows in the naming of this file, the kconfig symbols and some symbols 14 + * in the code. 11 15 */ 12 16 13 17 #if defined(CONFIG_SERIAL_XILINX_PS_UART_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) ··· 31 27 #include <linux/of.h> 32 28 #include <linux/module.h> 33 29 34 - #define XUARTPS_TTY_NAME "ttyPS" 35 - #define XUARTPS_NAME "xuartps" 36 - #define XUARTPS_MAJOR 0 /* use dynamic node allocation */ 37 - #define XUARTPS_MINOR 0 /* works best with devtmpfs */ 38 - #define XUARTPS_NR_PORTS 2 39 - #define XUARTPS_FIFO_SIZE 64 /* FIFO size */ 40 - #define XUARTPS_REGISTER_SPACE 0xFFF 30 + #define CDNS_UART_TTY_NAME "ttyPS" 31 + #define CDNS_UART_NAME "xuartps" 32 + #define CDNS_UART_MAJOR 0 /* use dynamic node allocation */ 33 + #define CDNS_UART_MINOR 0 /* works best with devtmpfs */ 34 + #define CDNS_UART_NR_PORTS 2 35 + #define CDNS_UART_FIFO_SIZE 64 /* FIFO size */ 36 + #define CDNS_UART_REGISTER_SPACE 0xFFF 41 37 42 - #define xuartps_readl(offset) ioread32(port->membase + offset) 43 - #define xuartps_writel(val, offset) iowrite32(val, port->membase + offset) 38 + #define cdns_uart_readl(offset) ioread32(port->membase + offset) 39 + #define cdns_uart_writel(val, offset) iowrite32(val, port->membase + offset) 44 40 45 41 /* Rx Trigger level */ 46 42 static int rx_trigger_level = 56; ··· 53 49 MODULE_PARM_DESC(rx_timeout, "Rx timeout, 1-255"); 54 50 55 51 /* Register offsets for the UART. */ 56 - #define XUARTPS_CR_OFFSET 0x00 /* Control Register */ 57 - #define XUARTPS_MR_OFFSET 0x04 /* Mode Register */ 58 - #define XUARTPS_IER_OFFSET 0x08 /* Interrupt Enable */ 59 - #define XUARTPS_IDR_OFFSET 0x0C /* Interrupt Disable */ 60 - #define XUARTPS_IMR_OFFSET 0x10 /* Interrupt Mask */ 61 - #define XUARTPS_ISR_OFFSET 0x14 /* Interrupt Status */ 62 - #define XUARTPS_BAUDGEN_OFFSET 0x18 /* Baud Rate Generator */ 63 - #define XUARTPS_RXTOUT_OFFSET 0x1C /* RX Timeout */ 64 - #define XUARTPS_RXWM_OFFSET 0x20 /* RX FIFO Trigger Level */ 65 - #define XUARTPS_MODEMCR_OFFSET 0x24 /* Modem Control */ 66 - #define XUARTPS_MODEMSR_OFFSET 0x28 /* Modem Status */ 67 - #define XUARTPS_SR_OFFSET 0x2C /* Channel Status */ 68 - #define XUARTPS_FIFO_OFFSET 0x30 /* FIFO */ 69 - #define XUARTPS_BAUDDIV_OFFSET 0x34 /* Baud Rate Divider */ 70 - #define XUARTPS_FLOWDEL_OFFSET 0x38 /* Flow Delay */ 71 - #define XUARTPS_IRRX_PWIDTH_OFFSET 0x3C /* IR Minimum Received Pulse Width */ 72 - #define XUARTPS_IRTX_PWIDTH_OFFSET 0x40 /* IR Transmitted pulse Width */ 73 - #define XUARTPS_TXWM_OFFSET 0x44 /* TX FIFO Trigger Level */ 52 + #define CDNS_UART_CR_OFFSET 0x00 /* Control Register */ 53 + #define CDNS_UART_MR_OFFSET 0x04 /* Mode Register */ 54 + #define CDNS_UART_IER_OFFSET 0x08 /* Interrupt Enable */ 55 + #define CDNS_UART_IDR_OFFSET 0x0C /* Interrupt Disable */ 56 + #define CDNS_UART_IMR_OFFSET 0x10 /* Interrupt Mask */ 57 + #define CDNS_UART_ISR_OFFSET 0x14 /* Interrupt Status */ 58 + #define CDNS_UART_BAUDGEN_OFFSET 0x18 /* Baud Rate Generator */ 59 + #define CDNS_UART_RXTOUT_OFFSET 0x1C /* RX Timeout */ 60 + #define CDNS_UART_RXWM_OFFSET 0x20 /* RX FIFO Trigger Level */ 61 + #define CDNS_UART_MODEMCR_OFFSET 0x24 /* Modem Control */ 62 + #define CDNS_UART_MODEMSR_OFFSET 0x28 /* Modem Status */ 63 + #define CDNS_UART_SR_OFFSET 0x2C /* Channel Status */ 64 + #define CDNS_UART_FIFO_OFFSET 0x30 /* FIFO */ 65 + #define CDNS_UART_BAUDDIV_OFFSET 0x34 /* Baud Rate Divider */ 66 + #define CDNS_UART_FLOWDEL_OFFSET 0x38 /* Flow Delay */ 67 + #define CDNS_UART_IRRX_PWIDTH_OFFSET 0x3C /* IR Min Received Pulse Width */ 68 + #define CDNS_UART_IRTX_PWIDTH_OFFSET 0x40 /* IR Transmitted pulse Width */ 69 + #define CDNS_UART_TXWM_OFFSET 0x44 /* TX FIFO Trigger Level */ 74 70 75 71 /* Control Register Bit Definitions */ 76 - #define XUARTPS_CR_STOPBRK 0x00000100 /* Stop TX break */ 77 - #define XUARTPS_CR_STARTBRK 0x00000080 /* Set TX break */ 78 - #define XUARTPS_CR_TX_DIS 0x00000020 /* TX disabled. */ 79 - #define XUARTPS_CR_TX_EN 0x00000010 /* TX enabled */ 80 - #define XUARTPS_CR_RX_DIS 0x00000008 /* RX disabled. */ 81 - #define XUARTPS_CR_RX_EN 0x00000004 /* RX enabled */ 82 - #define XUARTPS_CR_TXRST 0x00000002 /* TX logic reset */ 83 - #define XUARTPS_CR_RXRST 0x00000001 /* RX logic reset */ 84 - #define XUARTPS_CR_RST_TO 0x00000040 /* Restart Timeout Counter */ 72 + #define CDNS_UART_CR_STOPBRK 0x00000100 /* Stop TX break */ 73 + #define CDNS_UART_CR_STARTBRK 0x00000080 /* Set TX break */ 74 + #define CDNS_UART_CR_TX_DIS 0x00000020 /* TX disabled. */ 75 + #define CDNS_UART_CR_TX_EN 0x00000010 /* TX enabled */ 76 + #define CDNS_UART_CR_RX_DIS 0x00000008 /* RX disabled. */ 77 + #define CDNS_UART_CR_RX_EN 0x00000004 /* RX enabled */ 78 + #define CDNS_UART_CR_TXRST 0x00000002 /* TX logic reset */ 79 + #define CDNS_UART_CR_RXRST 0x00000001 /* RX logic reset */ 80 + #define CDNS_UART_CR_RST_TO 0x00000040 /* Restart Timeout Counter */ 85 81 86 82 /* 87 83 * Mode Register: ··· 89 85 * format. If this register is modified during transmission or reception, 90 86 * data validity cannot be guaranteed. 91 87 */ 92 - #define XUARTPS_MR_CLKSEL 0x00000001 /* Pre-scalar selection */ 93 - #define XUARTPS_MR_CHMODE_L_LOOP 0x00000200 /* Local loop back mode */ 94 - #define XUARTPS_MR_CHMODE_NORM 0x00000000 /* Normal mode */ 88 + #define CDNS_UART_MR_CLKSEL 0x00000001 /* Pre-scalar selection */ 89 + #define CDNS_UART_MR_CHMODE_L_LOOP 0x00000200 /* Local loop back mode */ 90 + #define CDNS_UART_MR_CHMODE_NORM 0x00000000 /* Normal mode */ 95 91 96 - #define XUARTPS_MR_STOPMODE_2_BIT 0x00000080 /* 2 stop bits */ 97 - #define XUARTPS_MR_STOPMODE_1_BIT 0x00000000 /* 1 stop bit */ 92 + #define CDNS_UART_MR_STOPMODE_2_BIT 0x00000080 /* 2 stop bits */ 93 + #define CDNS_UART_MR_STOPMODE_1_BIT 0x00000000 /* 1 stop bit */ 98 94 99 - #define XUARTPS_MR_PARITY_NONE 0x00000020 /* No parity mode */ 100 - #define XUARTPS_MR_PARITY_MARK 0x00000018 /* Mark parity mode */ 101 - #define XUARTPS_MR_PARITY_SPACE 0x00000010 /* Space parity mode */ 102 - #define XUARTPS_MR_PARITY_ODD 0x00000008 /* Odd parity mode */ 103 - #define XUARTPS_MR_PARITY_EVEN 0x00000000 /* Even parity mode */ 95 + #define CDNS_UART_MR_PARITY_NONE 0x00000020 /* No parity mode */ 96 + #define CDNS_UART_MR_PARITY_MARK 0x00000018 /* Mark parity mode */ 97 + #define CDNS_UART_MR_PARITY_SPACE 0x00000010 /* Space parity mode */ 98 + #define CDNS_UART_MR_PARITY_ODD 0x00000008 /* Odd parity mode */ 99 + #define CDNS_UART_MR_PARITY_EVEN 0x00000000 /* Even parity mode */ 104 100 105 - #define XUARTPS_MR_CHARLEN_6_BIT 0x00000006 /* 6 bits data */ 106 - #define XUARTPS_MR_CHARLEN_7_BIT 0x00000004 /* 7 bits data */ 107 - #define XUARTPS_MR_CHARLEN_8_BIT 0x00000000 /* 8 bits data */ 101 + #define CDNS_UART_MR_CHARLEN_6_BIT 0x00000006 /* 6 bits data */ 102 + #define CDNS_UART_MR_CHARLEN_7_BIT 0x00000004 /* 7 bits data */ 103 + #define CDNS_UART_MR_CHARLEN_8_BIT 0x00000000 /* 8 bits data */ 108 104 109 105 /* 110 106 * Interrupt Registers: ··· 117 113 * Reading either IER or IDR returns 0x00. 118 114 * All four registers have the same bit definitions. 119 115 */ 120 - #define XUARTPS_IXR_TOUT 0x00000100 /* RX Timeout error interrupt */ 121 - #define XUARTPS_IXR_PARITY 0x00000080 /* Parity error interrupt */ 122 - #define XUARTPS_IXR_FRAMING 0x00000040 /* Framing error interrupt */ 123 - #define XUARTPS_IXR_OVERRUN 0x00000020 /* Overrun error interrupt */ 124 - #define XUARTPS_IXR_TXFULL 0x00000010 /* TX FIFO Full interrupt */ 125 - #define XUARTPS_IXR_TXEMPTY 0x00000008 /* TX FIFO empty interrupt */ 126 - #define XUARTPS_ISR_RXEMPTY 0x00000002 /* RX FIFO empty interrupt */ 127 - #define XUARTPS_IXR_RXTRIG 0x00000001 /* RX FIFO trigger interrupt */ 128 - #define XUARTPS_IXR_RXFULL 0x00000004 /* RX FIFO full interrupt. */ 129 - #define XUARTPS_IXR_RXEMPTY 0x00000002 /* RX FIFO empty interrupt. */ 130 - #define XUARTPS_IXR_MASK 0x00001FFF /* Valid bit mask */ 116 + #define CDNS_UART_IXR_TOUT 0x00000100 /* RX Timeout error interrupt */ 117 + #define CDNS_UART_IXR_PARITY 0x00000080 /* Parity error interrupt */ 118 + #define CDNS_UART_IXR_FRAMING 0x00000040 /* Framing error interrupt */ 119 + #define CDNS_UART_IXR_OVERRUN 0x00000020 /* Overrun error interrupt */ 120 + #define CDNS_UART_IXR_TXFULL 0x00000010 /* TX FIFO Full interrupt */ 121 + #define CDNS_UART_IXR_TXEMPTY 0x00000008 /* TX FIFO empty interrupt */ 122 + #define CDNS_UART_ISR_RXEMPTY 0x00000002 /* RX FIFO empty interrupt */ 123 + #define CDNS_UART_IXR_RXTRIG 0x00000001 /* RX FIFO trigger interrupt */ 124 + #define CDNS_UART_IXR_RXFULL 0x00000004 /* RX FIFO full interrupt. */ 125 + #define CDNS_UART_IXR_RXEMPTY 0x00000002 /* RX FIFO empty interrupt. */ 126 + #define CDNS_UART_IXR_MASK 0x00001FFF /* Valid bit mask */ 131 127 132 128 /* Goes in read_status_mask for break detection as the HW doesn't do it*/ 133 - #define XUARTPS_IXR_BRK 0x80000000 129 + #define CDNS_UART_IXR_BRK 0x80000000 134 130 135 131 /* 136 132 * Channel Status Register: ··· 138 134 * to monitor the status of bits in the channel interrupt status register, 139 135 * even if these are masked out by the interrupt mask register. 140 136 */ 141 - #define XUARTPS_SR_RXEMPTY 0x00000002 /* RX FIFO empty */ 142 - #define XUARTPS_SR_TXEMPTY 0x00000008 /* TX FIFO empty */ 143 - #define XUARTPS_SR_TXFULL 0x00000010 /* TX FIFO full */ 144 - #define XUARTPS_SR_RXTRIG 0x00000001 /* Rx Trigger */ 137 + #define CDNS_UART_SR_RXEMPTY 0x00000002 /* RX FIFO empty */ 138 + #define CDNS_UART_SR_TXEMPTY 0x00000008 /* TX FIFO empty */ 139 + #define CDNS_UART_SR_TXFULL 0x00000010 /* TX FIFO full */ 140 + #define CDNS_UART_SR_RXTRIG 0x00000001 /* Rx Trigger */ 145 141 146 142 /* baud dividers min/max values */ 147 - #define XUARTPS_BDIV_MIN 4 148 - #define XUARTPS_BDIV_MAX 255 149 - #define XUARTPS_CD_MAX 65535 143 + #define CDNS_UART_BDIV_MIN 4 144 + #define CDNS_UART_BDIV_MAX 255 145 + #define CDNS_UART_CD_MAX 65535 150 146 151 147 /** 152 - * struct xuartps - device data 148 + * struct cdns_uart - device data 153 149 * @port: Pointer to the UART port 154 - * @refclk: Reference clock 155 - * @aperclk: APB clock 150 + * @uartclk: Reference clock 151 + * @pclk: APB clock 156 152 * @baud: Current baud rate 157 153 * @clk_rate_change_nb: Notifier block for clock changes 158 154 */ 159 - struct xuartps { 155 + struct cdns_uart { 160 156 struct uart_port *port; 161 - struct clk *refclk; 162 - struct clk *aperclk; 157 + struct clk *uartclk; 158 + struct clk *pclk; 163 159 unsigned int baud; 164 160 struct notifier_block clk_rate_change_nb; 165 161 }; 166 - #define to_xuartps(_nb) container_of(_nb, struct xuartps, clk_rate_change_nb); 162 + #define to_cdns_uart(_nb) container_of(_nb, struct cdns_uart, \ 163 + clk_rate_change_nb); 167 164 168 165 /** 169 - * xuartps_isr - Interrupt handler 166 + * cdns_uart_isr - Interrupt handler 170 167 * @irq: Irq number 171 168 * @dev_id: Id of the port 172 169 * 173 170 * Return: IRQHANDLED 174 171 */ 175 - static irqreturn_t xuartps_isr(int irq, void *dev_id) 172 + static irqreturn_t cdns_uart_isr(int irq, void *dev_id) 176 173 { 177 174 struct uart_port *port = (struct uart_port *)dev_id; 178 175 unsigned long flags; ··· 186 181 /* Read the interrupt status register to determine which 187 182 * interrupt(s) is/are active. 188 183 */ 189 - isrstatus = xuartps_readl(XUARTPS_ISR_OFFSET); 184 + isrstatus = cdns_uart_readl(CDNS_UART_ISR_OFFSET); 190 185 191 186 /* 192 187 * There is no hardware break detection, so we interpret framing 193 188 * error with all-zeros data as a break sequence. Most of the time, 194 189 * there's another non-zero byte at the end of the sequence. 195 190 */ 196 - if (isrstatus & XUARTPS_IXR_FRAMING) { 197 - while (!(xuartps_readl(XUARTPS_SR_OFFSET) & 198 - XUARTPS_SR_RXEMPTY)) { 199 - if (!xuartps_readl(XUARTPS_FIFO_OFFSET)) { 200 - port->read_status_mask |= XUARTPS_IXR_BRK; 201 - isrstatus &= ~XUARTPS_IXR_FRAMING; 191 + if (isrstatus & CDNS_UART_IXR_FRAMING) { 192 + while (!(cdns_uart_readl(CDNS_UART_SR_OFFSET) & 193 + CDNS_UART_SR_RXEMPTY)) { 194 + if (!cdns_uart_readl(CDNS_UART_FIFO_OFFSET)) { 195 + port->read_status_mask |= CDNS_UART_IXR_BRK; 196 + isrstatus &= ~CDNS_UART_IXR_FRAMING; 202 197 } 203 198 } 204 - xuartps_writel(XUARTPS_IXR_FRAMING, XUARTPS_ISR_OFFSET); 199 + cdns_uart_writel(CDNS_UART_IXR_FRAMING, CDNS_UART_ISR_OFFSET); 205 200 } 206 201 207 202 /* drop byte with parity error if IGNPAR specified */ 208 - if (isrstatus & port->ignore_status_mask & XUARTPS_IXR_PARITY) 209 - isrstatus &= ~(XUARTPS_IXR_RXTRIG | XUARTPS_IXR_TOUT); 203 + if (isrstatus & port->ignore_status_mask & CDNS_UART_IXR_PARITY) 204 + isrstatus &= ~(CDNS_UART_IXR_RXTRIG | CDNS_UART_IXR_TOUT); 210 205 211 206 isrstatus &= port->read_status_mask; 212 207 isrstatus &= ~port->ignore_status_mask; 213 208 214 - if ((isrstatus & XUARTPS_IXR_TOUT) || 215 - (isrstatus & XUARTPS_IXR_RXTRIG)) { 209 + if ((isrstatus & CDNS_UART_IXR_TOUT) || 210 + (isrstatus & CDNS_UART_IXR_RXTRIG)) { 216 211 /* Receive Timeout Interrupt */ 217 - while ((xuartps_readl(XUARTPS_SR_OFFSET) & 218 - XUARTPS_SR_RXEMPTY) != XUARTPS_SR_RXEMPTY) { 219 - data = xuartps_readl(XUARTPS_FIFO_OFFSET); 212 + while ((cdns_uart_readl(CDNS_UART_SR_OFFSET) & 213 + CDNS_UART_SR_RXEMPTY) != CDNS_UART_SR_RXEMPTY) { 214 + data = cdns_uart_readl(CDNS_UART_FIFO_OFFSET); 220 215 221 216 /* Non-NULL byte after BREAK is garbage (99%) */ 222 217 if (data && (port->read_status_mask & 223 - XUARTPS_IXR_BRK)) { 224 - port->read_status_mask &= ~XUARTPS_IXR_BRK; 218 + CDNS_UART_IXR_BRK)) { 219 + port->read_status_mask &= ~CDNS_UART_IXR_BRK; 225 220 port->icount.brk++; 226 221 if (uart_handle_break(port)) 227 222 continue; ··· 245 240 246 241 port->icount.rx++; 247 242 248 - if (isrstatus & XUARTPS_IXR_PARITY) { 243 + if (isrstatus & CDNS_UART_IXR_PARITY) { 249 244 port->icount.parity++; 250 245 status = TTY_PARITY; 251 - } else if (isrstatus & XUARTPS_IXR_FRAMING) { 246 + } else if (isrstatus & CDNS_UART_IXR_FRAMING) { 252 247 port->icount.frame++; 253 248 status = TTY_FRAME; 254 - } else if (isrstatus & XUARTPS_IXR_OVERRUN) { 249 + } else if (isrstatus & CDNS_UART_IXR_OVERRUN) { 255 250 port->icount.overrun++; 256 251 } 257 252 258 - uart_insert_char(port, isrstatus, XUARTPS_IXR_OVERRUN, 253 + uart_insert_char(port, isrstatus, CDNS_UART_IXR_OVERRUN, 259 254 data, status); 260 255 } 261 256 spin_unlock(&port->lock); ··· 264 259 } 265 260 266 261 /* Dispatch an appropriate handler */ 267 - if ((isrstatus & XUARTPS_IXR_TXEMPTY) == XUARTPS_IXR_TXEMPTY) { 262 + if ((isrstatus & CDNS_UART_IXR_TXEMPTY) == CDNS_UART_IXR_TXEMPTY) { 268 263 if (uart_circ_empty(&port->state->xmit)) { 269 - xuartps_writel(XUARTPS_IXR_TXEMPTY, 270 - XUARTPS_IDR_OFFSET); 264 + cdns_uart_writel(CDNS_UART_IXR_TXEMPTY, 265 + CDNS_UART_IDR_OFFSET); 271 266 } else { 272 267 numbytes = port->fifosize; 273 268 /* Break if no more data available in the UART buffer */ ··· 275 270 if (uart_circ_empty(&port->state->xmit)) 276 271 break; 277 272 /* Get the data from the UART circular buffer 278 - * and write it to the xuartps's TX_FIFO 273 + * and write it to the cdns_uart's TX_FIFO 279 274 * register. 280 275 */ 281 - xuartps_writel( 276 + cdns_uart_writel( 282 277 port->state->xmit.buf[port->state->xmit. 283 - tail], XUARTPS_FIFO_OFFSET); 278 + tail], CDNS_UART_FIFO_OFFSET); 284 279 285 280 port->icount.tx++; 286 281 ··· 298 293 } 299 294 } 300 295 301 - xuartps_writel(isrstatus, XUARTPS_ISR_OFFSET); 296 + cdns_uart_writel(isrstatus, CDNS_UART_ISR_OFFSET); 302 297 303 298 /* be sure to release the lock and tty before leaving */ 304 299 spin_unlock_irqrestore(&port->lock, flags); ··· 307 302 } 308 303 309 304 /** 310 - * xuartps_calc_baud_divs - Calculate baud rate divisors 305 + * cdns_uart_calc_baud_divs - Calculate baud rate divisors 311 306 * @clk: UART module input clock 312 307 * @baud: Desired baud rate 313 308 * @rbdiv: BDIV value (return value) ··· 326 321 * baud rate generate register 327 322 * baud rate clock divisor register 328 323 */ 329 - static unsigned int xuartps_calc_baud_divs(unsigned int clk, unsigned int baud, 330 - u32 *rbdiv, u32 *rcd, int *div8) 324 + static unsigned int cdns_uart_calc_baud_divs(unsigned int clk, 325 + unsigned int baud, u32 *rbdiv, u32 *rcd, int *div8) 331 326 { 332 327 u32 cd, bdiv; 333 328 unsigned int calc_baud; ··· 335 330 unsigned int bauderror; 336 331 unsigned int besterror = ~0; 337 332 338 - if (baud < clk / ((XUARTPS_BDIV_MAX + 1) * XUARTPS_CD_MAX)) { 333 + if (baud < clk / ((CDNS_UART_BDIV_MAX + 1) * CDNS_UART_CD_MAX)) { 339 334 *div8 = 1; 340 335 clk /= 8; 341 336 } else { 342 337 *div8 = 0; 343 338 } 344 339 345 - for (bdiv = XUARTPS_BDIV_MIN; bdiv <= XUARTPS_BDIV_MAX; bdiv++) { 340 + for (bdiv = CDNS_UART_BDIV_MIN; bdiv <= CDNS_UART_BDIV_MAX; bdiv++) { 346 341 cd = DIV_ROUND_CLOSEST(clk, baud * (bdiv + 1)); 347 - if (cd < 1 || cd > XUARTPS_CD_MAX) 342 + if (cd < 1 || cd > CDNS_UART_CD_MAX) 348 343 continue; 349 344 350 345 calc_baud = clk / (cd * (bdiv + 1)); ··· 369 364 } 370 365 371 366 /** 372 - * xuartps_set_baud_rate - Calculate and set the baud rate 367 + * cdns_uart_set_baud_rate - Calculate and set the baud rate 373 368 * @port: Handle to the uart port structure 374 369 * @baud: Baud rate to set 375 370 * Return: baud rate, requested baud when possible, or actual baud when there 376 371 * was too much error, zero if no valid divisors are found. 377 372 */ 378 - static unsigned int xuartps_set_baud_rate(struct uart_port *port, 373 + static unsigned int cdns_uart_set_baud_rate(struct uart_port *port, 379 374 unsigned int baud) 380 375 { 381 376 unsigned int calc_baud; 382 377 u32 cd = 0, bdiv = 0; 383 378 u32 mreg; 384 379 int div8; 385 - struct xuartps *xuartps = port->private_data; 380 + struct cdns_uart *cdns_uart = port->private_data; 386 381 387 - calc_baud = xuartps_calc_baud_divs(port->uartclk, baud, &bdiv, &cd, 382 + calc_baud = cdns_uart_calc_baud_divs(port->uartclk, baud, &bdiv, &cd, 388 383 &div8); 389 384 390 385 /* Write new divisors to hardware */ 391 - mreg = xuartps_readl(XUARTPS_MR_OFFSET); 386 + mreg = cdns_uart_readl(CDNS_UART_MR_OFFSET); 392 387 if (div8) 393 - mreg |= XUARTPS_MR_CLKSEL; 388 + mreg |= CDNS_UART_MR_CLKSEL; 394 389 else 395 - mreg &= ~XUARTPS_MR_CLKSEL; 396 - xuartps_writel(mreg, XUARTPS_MR_OFFSET); 397 - xuartps_writel(cd, XUARTPS_BAUDGEN_OFFSET); 398 - xuartps_writel(bdiv, XUARTPS_BAUDDIV_OFFSET); 399 - xuartps->baud = baud; 390 + mreg &= ~CDNS_UART_MR_CLKSEL; 391 + cdns_uart_writel(mreg, CDNS_UART_MR_OFFSET); 392 + cdns_uart_writel(cd, CDNS_UART_BAUDGEN_OFFSET); 393 + cdns_uart_writel(bdiv, CDNS_UART_BAUDDIV_OFFSET); 394 + cdns_uart->baud = baud; 400 395 401 396 return calc_baud; 402 397 } 403 398 404 399 #ifdef CONFIG_COMMON_CLK 405 400 /** 406 - * xuartps_clk_notitifer_cb - Clock notifier callback 401 + * cdns_uart_clk_notitifer_cb - Clock notifier callback 407 402 * @nb: Notifier block 408 403 * @event: Notify event 409 404 * @data: Notifier data 410 405 * Return: NOTIFY_OK or NOTIFY_DONE on success, NOTIFY_BAD on error. 411 406 */ 412 - static int xuartps_clk_notifier_cb(struct notifier_block *nb, 407 + static int cdns_uart_clk_notifier_cb(struct notifier_block *nb, 413 408 unsigned long event, void *data) 414 409 { 415 410 u32 ctrl_reg; ··· 417 412 int locked = 0; 418 413 struct clk_notifier_data *ndata = data; 419 414 unsigned long flags = 0; 420 - struct xuartps *xuartps = to_xuartps(nb); 415 + struct cdns_uart *cdns_uart = to_cdns_uart(nb); 421 416 422 - port = xuartps->port; 417 + port = cdns_uart->port; 423 418 if (port->suspended) 424 419 return NOTIFY_OK; 425 420 ··· 433 428 * Find out if current baud-rate can be achieved with new clock 434 429 * frequency. 435 430 */ 436 - if (!xuartps_calc_baud_divs(ndata->new_rate, xuartps->baud, 431 + if (!cdns_uart_calc_baud_divs(ndata->new_rate, cdns_uart->baud, 437 432 &bdiv, &cd, &div8)) { 438 433 dev_warn(port->dev, "clock rate change rejected\n"); 439 434 return NOTIFY_BAD; 440 435 } 441 436 442 - spin_lock_irqsave(&xuartps->port->lock, flags); 437 + spin_lock_irqsave(&cdns_uart->port->lock, flags); 443 438 444 439 /* Disable the TX and RX to set baud rate */ 445 - ctrl_reg = xuartps_readl(XUARTPS_CR_OFFSET); 446 - ctrl_reg |= XUARTPS_CR_TX_DIS | XUARTPS_CR_RX_DIS; 447 - xuartps_writel(ctrl_reg, XUARTPS_CR_OFFSET); 440 + ctrl_reg = cdns_uart_readl(CDNS_UART_CR_OFFSET); 441 + ctrl_reg |= CDNS_UART_CR_TX_DIS | CDNS_UART_CR_RX_DIS; 442 + cdns_uart_writel(ctrl_reg, CDNS_UART_CR_OFFSET); 448 443 449 - spin_unlock_irqrestore(&xuartps->port->lock, flags); 444 + spin_unlock_irqrestore(&cdns_uart->port->lock, flags); 450 445 451 446 return NOTIFY_OK; 452 447 } ··· 456 451 * frequency. 457 452 */ 458 453 459 - spin_lock_irqsave(&xuartps->port->lock, flags); 454 + spin_lock_irqsave(&cdns_uart->port->lock, flags); 460 455 461 456 locked = 1; 462 457 port->uartclk = ndata->new_rate; 463 458 464 - xuartps->baud = xuartps_set_baud_rate(xuartps->port, 465 - xuartps->baud); 459 + cdns_uart->baud = cdns_uart_set_baud_rate(cdns_uart->port, 460 + cdns_uart->baud); 466 461 /* fall through */ 467 462 case ABORT_RATE_CHANGE: 468 463 if (!locked) 469 - spin_lock_irqsave(&xuartps->port->lock, flags); 464 + spin_lock_irqsave(&cdns_uart->port->lock, flags); 470 465 471 466 /* Set TX/RX Reset */ 472 - ctrl_reg = xuartps_readl(XUARTPS_CR_OFFSET); 473 - ctrl_reg |= XUARTPS_CR_TXRST | XUARTPS_CR_RXRST; 474 - xuartps_writel(ctrl_reg, XUARTPS_CR_OFFSET); 467 + ctrl_reg = cdns_uart_readl(CDNS_UART_CR_OFFSET); 468 + ctrl_reg |= CDNS_UART_CR_TXRST | CDNS_UART_CR_RXRST; 469 + cdns_uart_writel(ctrl_reg, CDNS_UART_CR_OFFSET); 475 470 476 - while (xuartps_readl(XUARTPS_CR_OFFSET) & 477 - (XUARTPS_CR_TXRST | XUARTPS_CR_RXRST)) 471 + while (cdns_uart_readl(CDNS_UART_CR_OFFSET) & 472 + (CDNS_UART_CR_TXRST | CDNS_UART_CR_RXRST)) 478 473 cpu_relax(); 479 474 480 475 /* ··· 482 477 * enable bit and RX enable bit to enable the transmitter and 483 478 * receiver. 484 479 */ 485 - xuartps_writel(rx_timeout, XUARTPS_RXTOUT_OFFSET); 486 - ctrl_reg = xuartps_readl(XUARTPS_CR_OFFSET); 487 - ctrl_reg &= ~(XUARTPS_CR_TX_DIS | XUARTPS_CR_RX_DIS); 488 - ctrl_reg |= XUARTPS_CR_TX_EN | XUARTPS_CR_RX_EN; 489 - xuartps_writel(ctrl_reg, XUARTPS_CR_OFFSET); 480 + cdns_uart_writel(rx_timeout, CDNS_UART_RXTOUT_OFFSET); 481 + ctrl_reg = cdns_uart_readl(CDNS_UART_CR_OFFSET); 482 + ctrl_reg &= ~(CDNS_UART_CR_TX_DIS | CDNS_UART_CR_RX_DIS); 483 + ctrl_reg |= CDNS_UART_CR_TX_EN | CDNS_UART_CR_RX_EN; 484 + cdns_uart_writel(ctrl_reg, CDNS_UART_CR_OFFSET); 490 485 491 - spin_unlock_irqrestore(&xuartps->port->lock, flags); 486 + spin_unlock_irqrestore(&cdns_uart->port->lock, flags); 492 487 493 488 return NOTIFY_OK; 494 489 default: ··· 498 493 #endif 499 494 500 495 /** 501 - * xuartps_start_tx - Start transmitting bytes 496 + * cdns_uart_start_tx - Start transmitting bytes 502 497 * @port: Handle to the uart port structure 503 498 */ 504 - static void xuartps_start_tx(struct uart_port *port) 499 + static void cdns_uart_start_tx(struct uart_port *port) 505 500 { 506 501 unsigned int status, numbytes = port->fifosize; 507 502 508 503 if (uart_circ_empty(&port->state->xmit) || uart_tx_stopped(port)) 509 504 return; 510 505 511 - status = xuartps_readl(XUARTPS_CR_OFFSET); 506 + status = cdns_uart_readl(CDNS_UART_CR_OFFSET); 512 507 /* Set the TX enable bit and clear the TX disable bit to enable the 513 508 * transmitter. 514 509 */ 515 - xuartps_writel((status & ~XUARTPS_CR_TX_DIS) | XUARTPS_CR_TX_EN, 516 - XUARTPS_CR_OFFSET); 510 + cdns_uart_writel((status & ~CDNS_UART_CR_TX_DIS) | CDNS_UART_CR_TX_EN, 511 + CDNS_UART_CR_OFFSET); 517 512 518 - while (numbytes-- && ((xuartps_readl(XUARTPS_SR_OFFSET) & 519 - XUARTPS_SR_TXFULL)) != XUARTPS_SR_TXFULL) { 513 + while (numbytes-- && ((cdns_uart_readl(CDNS_UART_SR_OFFSET) & 514 + CDNS_UART_SR_TXFULL)) != CDNS_UART_SR_TXFULL) { 520 515 /* Break if no more data available in the UART buffer */ 521 516 if (uart_circ_empty(&port->state->xmit)) 522 517 break; 523 518 524 519 /* Get the data from the UART circular buffer and 525 - * write it to the xuartps's TX_FIFO register. 520 + * write it to the cdns_uart's TX_FIFO register. 526 521 */ 527 - xuartps_writel( 522 + cdns_uart_writel( 528 523 port->state->xmit.buf[port->state->xmit.tail], 529 - XUARTPS_FIFO_OFFSET); 524 + CDNS_UART_FIFO_OFFSET); 530 525 port->icount.tx++; 531 526 532 527 /* Adjust the tail of the UART buffer and wrap ··· 535 530 port->state->xmit.tail = (port->state->xmit.tail + 1) & 536 531 (UART_XMIT_SIZE - 1); 537 532 } 538 - xuartps_writel(XUARTPS_IXR_TXEMPTY, XUARTPS_ISR_OFFSET); 533 + cdns_uart_writel(CDNS_UART_IXR_TXEMPTY, CDNS_UART_ISR_OFFSET); 539 534 /* Enable the TX Empty interrupt */ 540 - xuartps_writel(XUARTPS_IXR_TXEMPTY, XUARTPS_IER_OFFSET); 535 + cdns_uart_writel(CDNS_UART_IXR_TXEMPTY, CDNS_UART_IER_OFFSET); 541 536 542 537 if (uart_circ_chars_pending(&port->state->xmit) < WAKEUP_CHARS) 543 538 uart_write_wakeup(port); 544 539 } 545 540 546 541 /** 547 - * xuartps_stop_tx - Stop TX 542 + * cdns_uart_stop_tx - Stop TX 548 543 * @port: Handle to the uart port structure 549 544 */ 550 - static void xuartps_stop_tx(struct uart_port *port) 545 + static void cdns_uart_stop_tx(struct uart_port *port) 551 546 { 552 547 unsigned int regval; 553 548 554 - regval = xuartps_readl(XUARTPS_CR_OFFSET); 555 - regval |= XUARTPS_CR_TX_DIS; 549 + regval = cdns_uart_readl(CDNS_UART_CR_OFFSET); 550 + regval |= CDNS_UART_CR_TX_DIS; 556 551 /* Disable the transmitter */ 557 - xuartps_writel(regval, XUARTPS_CR_OFFSET); 552 + cdns_uart_writel(regval, CDNS_UART_CR_OFFSET); 558 553 } 559 554 560 555 /** 561 - * xuartps_stop_rx - Stop RX 556 + * cdns_uart_stop_rx - Stop RX 562 557 * @port: Handle to the uart port structure 563 558 */ 564 - static void xuartps_stop_rx(struct uart_port *port) 559 + static void cdns_uart_stop_rx(struct uart_port *port) 565 560 { 566 561 unsigned int regval; 567 562 568 - regval = xuartps_readl(XUARTPS_CR_OFFSET); 569 - regval |= XUARTPS_CR_RX_DIS; 563 + regval = cdns_uart_readl(CDNS_UART_CR_OFFSET); 564 + regval |= CDNS_UART_CR_RX_DIS; 570 565 /* Disable the receiver */ 571 - xuartps_writel(regval, XUARTPS_CR_OFFSET); 566 + cdns_uart_writel(regval, CDNS_UART_CR_OFFSET); 572 567 } 573 568 574 569 /** 575 - * xuartps_tx_empty - Check whether TX is empty 570 + * cdns_uart_tx_empty - Check whether TX is empty 576 571 * @port: Handle to the uart port structure 577 572 * 578 573 * Return: TIOCSER_TEMT on success, 0 otherwise 579 574 */ 580 - static unsigned int xuartps_tx_empty(struct uart_port *port) 575 + static unsigned int cdns_uart_tx_empty(struct uart_port *port) 581 576 { 582 577 unsigned int status; 583 578 584 - status = xuartps_readl(XUARTPS_ISR_OFFSET) & XUARTPS_IXR_TXEMPTY; 579 + status = cdns_uart_readl(CDNS_UART_ISR_OFFSET) & CDNS_UART_IXR_TXEMPTY; 585 580 return status ? TIOCSER_TEMT : 0; 586 581 } 587 582 588 583 /** 589 - * xuartps_break_ctl - Based on the input ctl we have to start or stop 584 + * cdns_uart_break_ctl - Based on the input ctl we have to start or stop 590 585 * transmitting char breaks 591 586 * @port: Handle to the uart port structure 592 587 * @ctl: Value based on which start or stop decision is taken 593 588 */ 594 - static void xuartps_break_ctl(struct uart_port *port, int ctl) 589 + static void cdns_uart_break_ctl(struct uart_port *port, int ctl) 595 590 { 596 591 unsigned int status; 597 592 unsigned long flags; 598 593 599 594 spin_lock_irqsave(&port->lock, flags); 600 595 601 - status = xuartps_readl(XUARTPS_CR_OFFSET); 596 + status = cdns_uart_readl(CDNS_UART_CR_OFFSET); 602 597 603 598 if (ctl == -1) 604 - xuartps_writel(XUARTPS_CR_STARTBRK | status, 605 - XUARTPS_CR_OFFSET); 599 + cdns_uart_writel(CDNS_UART_CR_STARTBRK | status, 600 + CDNS_UART_CR_OFFSET); 606 601 else { 607 - if ((status & XUARTPS_CR_STOPBRK) == 0) 608 - xuartps_writel(XUARTPS_CR_STOPBRK | status, 609 - XUARTPS_CR_OFFSET); 602 + if ((status & CDNS_UART_CR_STOPBRK) == 0) 603 + cdns_uart_writel(CDNS_UART_CR_STOPBRK | status, 604 + CDNS_UART_CR_OFFSET); 610 605 } 611 606 spin_unlock_irqrestore(&port->lock, flags); 612 607 } 613 608 614 609 /** 615 - * xuartps_set_termios - termios operations, handling data length, parity, 610 + * cdns_uart_set_termios - termios operations, handling data length, parity, 616 611 * stop bits, flow control, baud rate 617 612 * @port: Handle to the uart port structure 618 613 * @termios: Handle to the input termios structure 619 614 * @old: Values of the previously saved termios structure 620 615 */ 621 - static void xuartps_set_termios(struct uart_port *port, 616 + static void cdns_uart_set_termios(struct uart_port *port, 622 617 struct ktermios *termios, struct ktermios *old) 623 618 { 624 619 unsigned int cval = 0; ··· 629 624 spin_lock_irqsave(&port->lock, flags); 630 625 631 626 /* Empty the receive FIFO 1st before making changes */ 632 - while ((xuartps_readl(XUARTPS_SR_OFFSET) & 633 - XUARTPS_SR_RXEMPTY) != XUARTPS_SR_RXEMPTY) { 634 - xuartps_readl(XUARTPS_FIFO_OFFSET); 627 + while ((cdns_uart_readl(CDNS_UART_SR_OFFSET) & 628 + CDNS_UART_SR_RXEMPTY) != CDNS_UART_SR_RXEMPTY) { 629 + cdns_uart_readl(CDNS_UART_FIFO_OFFSET); 635 630 } 636 631 637 632 /* Disable the TX and RX to set baud rate */ 638 - ctrl_reg = xuartps_readl(XUARTPS_CR_OFFSET); 639 - ctrl_reg |= XUARTPS_CR_TX_DIS | XUARTPS_CR_RX_DIS; 640 - xuartps_writel(ctrl_reg, XUARTPS_CR_OFFSET); 633 + ctrl_reg = cdns_uart_readl(CDNS_UART_CR_OFFSET); 634 + ctrl_reg |= CDNS_UART_CR_TX_DIS | CDNS_UART_CR_RX_DIS; 635 + cdns_uart_writel(ctrl_reg, CDNS_UART_CR_OFFSET); 641 636 642 637 /* 643 638 * Min baud rate = 6bps and Max Baud Rate is 10Mbps for 100Mhz clk 644 639 * min and max baud should be calculated here based on port->uartclk. 645 640 * this way we get a valid baud and can safely call set_baud() 646 641 */ 647 - minbaud = port->uartclk / ((XUARTPS_BDIV_MAX + 1) * XUARTPS_CD_MAX * 8); 648 - maxbaud = port->uartclk / (XUARTPS_BDIV_MIN + 1); 642 + minbaud = port->uartclk / 643 + ((CDNS_UART_BDIV_MAX + 1) * CDNS_UART_CD_MAX * 8); 644 + maxbaud = port->uartclk / (CDNS_UART_BDIV_MIN + 1); 649 645 baud = uart_get_baud_rate(port, termios, old, minbaud, maxbaud); 650 - baud = xuartps_set_baud_rate(port, baud); 646 + baud = cdns_uart_set_baud_rate(port, baud); 651 647 if (tty_termios_baud_rate(termios)) 652 648 tty_termios_encode_baud_rate(termios, baud, baud); 653 649 ··· 656 650 uart_update_timeout(port, termios->c_cflag, baud); 657 651 658 652 /* Set TX/RX Reset */ 659 - ctrl_reg = xuartps_readl(XUARTPS_CR_OFFSET); 660 - ctrl_reg |= XUARTPS_CR_TXRST | XUARTPS_CR_RXRST; 661 - xuartps_writel(ctrl_reg, XUARTPS_CR_OFFSET); 653 + ctrl_reg = cdns_uart_readl(CDNS_UART_CR_OFFSET); 654 + ctrl_reg |= CDNS_UART_CR_TXRST | CDNS_UART_CR_RXRST; 655 + cdns_uart_writel(ctrl_reg, CDNS_UART_CR_OFFSET); 662 656 663 657 /* 664 658 * Clear the RX disable and TX disable bits and then set the TX enable 665 659 * bit and RX enable bit to enable the transmitter and receiver. 666 660 */ 667 - ctrl_reg = xuartps_readl(XUARTPS_CR_OFFSET); 668 - ctrl_reg &= ~(XUARTPS_CR_TX_DIS | XUARTPS_CR_RX_DIS); 669 - ctrl_reg |= XUARTPS_CR_TX_EN | XUARTPS_CR_RX_EN; 670 - xuartps_writel(ctrl_reg, XUARTPS_CR_OFFSET); 661 + ctrl_reg = cdns_uart_readl(CDNS_UART_CR_OFFSET); 662 + ctrl_reg &= ~(CDNS_UART_CR_TX_DIS | CDNS_UART_CR_RX_DIS); 663 + ctrl_reg |= CDNS_UART_CR_TX_EN | CDNS_UART_CR_RX_EN; 664 + cdns_uart_writel(ctrl_reg, CDNS_UART_CR_OFFSET); 671 665 672 - xuartps_writel(rx_timeout, XUARTPS_RXTOUT_OFFSET); 666 + cdns_uart_writel(rx_timeout, CDNS_UART_RXTOUT_OFFSET); 673 667 674 - port->read_status_mask = XUARTPS_IXR_TXEMPTY | XUARTPS_IXR_RXTRIG | 675 - XUARTPS_IXR_OVERRUN | XUARTPS_IXR_TOUT; 668 + port->read_status_mask = CDNS_UART_IXR_TXEMPTY | CDNS_UART_IXR_RXTRIG | 669 + CDNS_UART_IXR_OVERRUN | CDNS_UART_IXR_TOUT; 676 670 port->ignore_status_mask = 0; 677 671 678 672 if (termios->c_iflag & INPCK) 679 - port->read_status_mask |= XUARTPS_IXR_PARITY | 680 - XUARTPS_IXR_FRAMING; 673 + port->read_status_mask |= CDNS_UART_IXR_PARITY | 674 + CDNS_UART_IXR_FRAMING; 681 675 682 676 if (termios->c_iflag & IGNPAR) 683 - port->ignore_status_mask |= XUARTPS_IXR_PARITY | 684 - XUARTPS_IXR_FRAMING | XUARTPS_IXR_OVERRUN; 677 + port->ignore_status_mask |= CDNS_UART_IXR_PARITY | 678 + CDNS_UART_IXR_FRAMING | CDNS_UART_IXR_OVERRUN; 685 679 686 680 /* ignore all characters if CREAD is not set */ 687 681 if ((termios->c_cflag & CREAD) == 0) 688 - port->ignore_status_mask |= XUARTPS_IXR_RXTRIG | 689 - XUARTPS_IXR_TOUT | XUARTPS_IXR_PARITY | 690 - XUARTPS_IXR_FRAMING | XUARTPS_IXR_OVERRUN; 682 + port->ignore_status_mask |= CDNS_UART_IXR_RXTRIG | 683 + CDNS_UART_IXR_TOUT | CDNS_UART_IXR_PARITY | 684 + CDNS_UART_IXR_FRAMING | CDNS_UART_IXR_OVERRUN; 691 685 692 - mode_reg = xuartps_readl(XUARTPS_MR_OFFSET); 686 + mode_reg = cdns_uart_readl(CDNS_UART_MR_OFFSET); 693 687 694 688 /* Handling Data Size */ 695 689 switch (termios->c_cflag & CSIZE) { 696 690 case CS6: 697 - cval |= XUARTPS_MR_CHARLEN_6_BIT; 691 + cval |= CDNS_UART_MR_CHARLEN_6_BIT; 698 692 break; 699 693 case CS7: 700 - cval |= XUARTPS_MR_CHARLEN_7_BIT; 694 + cval |= CDNS_UART_MR_CHARLEN_7_BIT; 701 695 break; 702 696 default: 703 697 case CS8: 704 - cval |= XUARTPS_MR_CHARLEN_8_BIT; 698 + cval |= CDNS_UART_MR_CHARLEN_8_BIT; 705 699 termios->c_cflag &= ~CSIZE; 706 700 termios->c_cflag |= CS8; 707 701 break; ··· 709 703 710 704 /* Handling Parity and Stop Bits length */ 711 705 if (termios->c_cflag & CSTOPB) 712 - cval |= XUARTPS_MR_STOPMODE_2_BIT; /* 2 STOP bits */ 706 + cval |= CDNS_UART_MR_STOPMODE_2_BIT; /* 2 STOP bits */ 713 707 else 714 - cval |= XUARTPS_MR_STOPMODE_1_BIT; /* 1 STOP bit */ 708 + cval |= CDNS_UART_MR_STOPMODE_1_BIT; /* 1 STOP bit */ 715 709 716 710 if (termios->c_cflag & PARENB) { 717 711 /* Mark or Space parity */ 718 712 if (termios->c_cflag & CMSPAR) { 719 713 if (termios->c_cflag & PARODD) 720 - cval |= XUARTPS_MR_PARITY_MARK; 714 + cval |= CDNS_UART_MR_PARITY_MARK; 721 715 else 722 - cval |= XUARTPS_MR_PARITY_SPACE; 716 + cval |= CDNS_UART_MR_PARITY_SPACE; 723 717 } else { 724 718 if (termios->c_cflag & PARODD) 725 - cval |= XUARTPS_MR_PARITY_ODD; 719 + cval |= CDNS_UART_MR_PARITY_ODD; 726 720 else 727 - cval |= XUARTPS_MR_PARITY_EVEN; 721 + cval |= CDNS_UART_MR_PARITY_EVEN; 728 722 } 729 723 } else { 730 - cval |= XUARTPS_MR_PARITY_NONE; 724 + cval |= CDNS_UART_MR_PARITY_NONE; 731 725 } 732 726 cval |= mode_reg & 1; 733 - xuartps_writel(cval, XUARTPS_MR_OFFSET); 727 + cdns_uart_writel(cval, CDNS_UART_MR_OFFSET); 734 728 735 729 spin_unlock_irqrestore(&port->lock, flags); 736 730 } 737 731 738 732 /** 739 - * xuartps_startup - Called when an application opens a xuartps port 733 + * cdns_uart_startup - Called when an application opens a cdns_uart port 740 734 * @port: Handle to the uart port structure 741 735 * 742 736 * Return: 0 on success, negative errno otherwise 743 737 */ 744 - static int xuartps_startup(struct uart_port *port) 738 + static int cdns_uart_startup(struct uart_port *port) 745 739 { 746 740 unsigned int retval = 0, status = 0; 747 741 748 - retval = request_irq(port->irq, xuartps_isr, 0, XUARTPS_NAME, 742 + retval = request_irq(port->irq, cdns_uart_isr, 0, CDNS_UART_NAME, 749 743 (void *)port); 750 744 if (retval) 751 745 return retval; 752 746 753 747 /* Disable the TX and RX */ 754 - xuartps_writel(XUARTPS_CR_TX_DIS | XUARTPS_CR_RX_DIS, 755 - XUARTPS_CR_OFFSET); 748 + cdns_uart_writel(CDNS_UART_CR_TX_DIS | CDNS_UART_CR_RX_DIS, 749 + CDNS_UART_CR_OFFSET); 756 750 757 751 /* Set the Control Register with TX/RX Enable, TX/RX Reset, 758 752 * no break chars. 759 753 */ 760 - xuartps_writel(XUARTPS_CR_TXRST | XUARTPS_CR_RXRST, 761 - XUARTPS_CR_OFFSET); 754 + cdns_uart_writel(CDNS_UART_CR_TXRST | CDNS_UART_CR_RXRST, 755 + CDNS_UART_CR_OFFSET); 762 756 763 - status = xuartps_readl(XUARTPS_CR_OFFSET); 757 + status = cdns_uart_readl(CDNS_UART_CR_OFFSET); 764 758 765 759 /* Clear the RX disable and TX disable bits and then set the TX enable 766 760 * bit and RX enable bit to enable the transmitter and receiver. 767 761 */ 768 - xuartps_writel((status & ~(XUARTPS_CR_TX_DIS | XUARTPS_CR_RX_DIS)) 769 - | (XUARTPS_CR_TX_EN | XUARTPS_CR_RX_EN | 770 - XUARTPS_CR_STOPBRK), XUARTPS_CR_OFFSET); 762 + cdns_uart_writel((status & ~(CDNS_UART_CR_TX_DIS | CDNS_UART_CR_RX_DIS)) 763 + | (CDNS_UART_CR_TX_EN | CDNS_UART_CR_RX_EN | 764 + CDNS_UART_CR_STOPBRK), CDNS_UART_CR_OFFSET); 771 765 772 766 /* Set the Mode Register with normal mode,8 data bits,1 stop bit, 773 767 * no parity. 774 768 */ 775 - xuartps_writel(XUARTPS_MR_CHMODE_NORM | XUARTPS_MR_STOPMODE_1_BIT 776 - | XUARTPS_MR_PARITY_NONE | XUARTPS_MR_CHARLEN_8_BIT, 777 - XUARTPS_MR_OFFSET); 769 + cdns_uart_writel(CDNS_UART_MR_CHMODE_NORM | CDNS_UART_MR_STOPMODE_1_BIT 770 + | CDNS_UART_MR_PARITY_NONE | CDNS_UART_MR_CHARLEN_8_BIT, 771 + CDNS_UART_MR_OFFSET); 778 772 779 773 /* 780 774 * Set the RX FIFO Trigger level to use most of the FIFO, but it 781 775 * can be tuned with a module parameter 782 776 */ 783 - xuartps_writel(rx_trigger_level, XUARTPS_RXWM_OFFSET); 777 + cdns_uart_writel(rx_trigger_level, CDNS_UART_RXWM_OFFSET); 784 778 785 779 /* 786 780 * Receive Timeout register is enabled but it 787 781 * can be tuned with a module parameter 788 782 */ 789 - xuartps_writel(rx_timeout, XUARTPS_RXTOUT_OFFSET); 783 + cdns_uart_writel(rx_timeout, CDNS_UART_RXTOUT_OFFSET); 790 784 791 785 /* Clear out any pending interrupts before enabling them */ 792 - xuartps_writel(xuartps_readl(XUARTPS_ISR_OFFSET), XUARTPS_ISR_OFFSET); 786 + cdns_uart_writel(cdns_uart_readl(CDNS_UART_ISR_OFFSET), 787 + CDNS_UART_ISR_OFFSET); 793 788 794 789 /* Set the Interrupt Registers with desired interrupts */ 795 - xuartps_writel(XUARTPS_IXR_TXEMPTY | XUARTPS_IXR_PARITY | 796 - XUARTPS_IXR_FRAMING | XUARTPS_IXR_OVERRUN | 797 - XUARTPS_IXR_RXTRIG | XUARTPS_IXR_TOUT, XUARTPS_IER_OFFSET); 790 + cdns_uart_writel(CDNS_UART_IXR_TXEMPTY | CDNS_UART_IXR_PARITY | 791 + CDNS_UART_IXR_FRAMING | CDNS_UART_IXR_OVERRUN | 792 + CDNS_UART_IXR_RXTRIG | CDNS_UART_IXR_TOUT, 793 + CDNS_UART_IER_OFFSET); 798 794 799 795 return retval; 800 796 } 801 797 802 798 /** 803 - * xuartps_shutdown - Called when an application closes a xuartps port 799 + * cdns_uart_shutdown - Called when an application closes a cdns_uart port 804 800 * @port: Handle to the uart port structure 805 801 */ 806 - static void xuartps_shutdown(struct uart_port *port) 802 + static void cdns_uart_shutdown(struct uart_port *port) 807 803 { 808 804 int status; 809 805 810 806 /* Disable interrupts */ 811 - status = xuartps_readl(XUARTPS_IMR_OFFSET); 812 - xuartps_writel(status, XUARTPS_IDR_OFFSET); 807 + status = cdns_uart_readl(CDNS_UART_IMR_OFFSET); 808 + cdns_uart_writel(status, CDNS_UART_IDR_OFFSET); 813 809 814 810 /* Disable the TX and RX */ 815 - xuartps_writel(XUARTPS_CR_TX_DIS | XUARTPS_CR_RX_DIS, 816 - XUARTPS_CR_OFFSET); 811 + cdns_uart_writel(CDNS_UART_CR_TX_DIS | CDNS_UART_CR_RX_DIS, 812 + CDNS_UART_CR_OFFSET); 817 813 free_irq(port->irq, port); 818 814 } 819 815 820 816 /** 821 - * xuartps_type - Set UART type to xuartps port 817 + * cdns_uart_type - Set UART type to cdns_uart port 822 818 * @port: Handle to the uart port structure 823 819 * 824 820 * Return: string on success, NULL otherwise 825 821 */ 826 - static const char *xuartps_type(struct uart_port *port) 822 + static const char *cdns_uart_type(struct uart_port *port) 827 823 { 828 - return port->type == PORT_XUARTPS ? XUARTPS_NAME : NULL; 824 + return port->type == PORT_XUARTPS ? CDNS_UART_NAME : NULL; 829 825 } 830 826 831 827 /** 832 - * xuartps_verify_port - Verify the port params 828 + * cdns_uart_verify_port - Verify the port params 833 829 * @port: Handle to the uart port structure 834 830 * @ser: Handle to the structure whose members are compared 835 831 * 836 832 * Return: 0 on success, negative errno otherwise. 837 833 */ 838 - static int xuartps_verify_port(struct uart_port *port, 834 + static int cdns_uart_verify_port(struct uart_port *port, 839 835 struct serial_struct *ser) 840 836 { 841 837 if (ser->type != PORT_UNKNOWN && ser->type != PORT_XUARTPS) ··· 854 846 } 855 847 856 848 /** 857 - * xuartps_request_port - Claim the memory region attached to xuartps port, 858 - * called when the driver adds a xuartps port via 849 + * cdns_uart_request_port - Claim the memory region attached to cdns_uart port, 850 + * called when the driver adds a cdns_uart port via 859 851 * uart_add_one_port() 860 852 * @port: Handle to the uart port structure 861 853 * 862 854 * Return: 0 on success, negative errno otherwise. 863 855 */ 864 - static int xuartps_request_port(struct uart_port *port) 856 + static int cdns_uart_request_port(struct uart_port *port) 865 857 { 866 - if (!request_mem_region(port->mapbase, XUARTPS_REGISTER_SPACE, 867 - XUARTPS_NAME)) { 858 + if (!request_mem_region(port->mapbase, CDNS_UART_REGISTER_SPACE, 859 + CDNS_UART_NAME)) { 868 860 return -ENOMEM; 869 861 } 870 862 871 - port->membase = ioremap(port->mapbase, XUARTPS_REGISTER_SPACE); 863 + port->membase = ioremap(port->mapbase, CDNS_UART_REGISTER_SPACE); 872 864 if (!port->membase) { 873 865 dev_err(port->dev, "Unable to map registers\n"); 874 - release_mem_region(port->mapbase, XUARTPS_REGISTER_SPACE); 866 + release_mem_region(port->mapbase, CDNS_UART_REGISTER_SPACE); 875 867 return -ENOMEM; 876 868 } 877 869 return 0; 878 870 } 879 871 880 872 /** 881 - * xuartps_release_port - Release UART port 873 + * cdns_uart_release_port - Release UART port 882 874 * @port: Handle to the uart port structure 883 875 * 884 - * Release the memory region attached to a xuartps port. Called when the 885 - * driver removes a xuartps port via uart_remove_one_port(). 876 + * Release the memory region attached to a cdns_uart port. Called when the 877 + * driver removes a cdns_uart port via uart_remove_one_port(). 886 878 */ 887 - static void xuartps_release_port(struct uart_port *port) 879 + static void cdns_uart_release_port(struct uart_port *port) 888 880 { 889 - release_mem_region(port->mapbase, XUARTPS_REGISTER_SPACE); 881 + release_mem_region(port->mapbase, CDNS_UART_REGISTER_SPACE); 890 882 iounmap(port->membase); 891 883 port->membase = NULL; 892 884 } 893 885 894 886 /** 895 - * xuartps_config_port - Configure UART port 887 + * cdns_uart_config_port - Configure UART port 896 888 * @port: Handle to the uart port structure 897 889 * @flags: If any 898 890 */ 899 - static void xuartps_config_port(struct uart_port *port, int flags) 891 + static void cdns_uart_config_port(struct uart_port *port, int flags) 900 892 { 901 - if (flags & UART_CONFIG_TYPE && xuartps_request_port(port) == 0) 893 + if (flags & UART_CONFIG_TYPE && cdns_uart_request_port(port) == 0) 902 894 port->type = PORT_XUARTPS; 903 895 } 904 896 905 897 /** 906 - * xuartps_get_mctrl - Get the modem control state 898 + * cdns_uart_get_mctrl - Get the modem control state 907 899 * @port: Handle to the uart port structure 908 900 * 909 901 * Return: the modem control state 910 902 */ 911 - static unsigned int xuartps_get_mctrl(struct uart_port *port) 903 + static unsigned int cdns_uart_get_mctrl(struct uart_port *port) 912 904 { 913 905 return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR; 914 906 } 915 907 916 - static void xuartps_set_mctrl(struct uart_port *port, unsigned int mctrl) 908 + static void cdns_uart_set_mctrl(struct uart_port *port, unsigned int mctrl) 917 909 { 918 910 /* N/A */ 919 911 } 920 912 921 - static void xuartps_enable_ms(struct uart_port *port) 913 + static void cdns_uart_enable_ms(struct uart_port *port) 922 914 { 923 915 /* N/A */ 924 916 } 925 917 926 918 #ifdef CONFIG_CONSOLE_POLL 927 - static int xuartps_poll_get_char(struct uart_port *port) 919 + static int cdns_uart_poll_get_char(struct uart_port *port) 928 920 { 929 921 u32 imr; 930 922 int c; 931 923 932 924 /* Disable all interrupts */ 933 - imr = xuartps_readl(XUARTPS_IMR_OFFSET); 934 - xuartps_writel(imr, XUARTPS_IDR_OFFSET); 925 + imr = cdns_uart_readl(CDNS_UART_IMR_OFFSET); 926 + cdns_uart_writel(imr, CDNS_UART_IDR_OFFSET); 935 927 936 928 /* Check if FIFO is empty */ 937 - if (xuartps_readl(XUARTPS_SR_OFFSET) & XUARTPS_SR_RXEMPTY) 929 + if (cdns_uart_readl(CDNS_UART_SR_OFFSET) & CDNS_UART_SR_RXEMPTY) 938 930 c = NO_POLL_CHAR; 939 931 else /* Read a character */ 940 - c = (unsigned char) xuartps_readl(XUARTPS_FIFO_OFFSET); 932 + c = (unsigned char) cdns_uart_readl(CDNS_UART_FIFO_OFFSET); 941 933 942 934 /* Enable interrupts */ 943 - xuartps_writel(imr, XUARTPS_IER_OFFSET); 935 + cdns_uart_writel(imr, CDNS_UART_IER_OFFSET); 944 936 945 937 return c; 946 938 } 947 939 948 - static void xuartps_poll_put_char(struct uart_port *port, unsigned char c) 940 + static void cdns_uart_poll_put_char(struct uart_port *port, unsigned char c) 949 941 { 950 942 u32 imr; 951 943 952 944 /* Disable all interrupts */ 953 - imr = xuartps_readl(XUARTPS_IMR_OFFSET); 954 - xuartps_writel(imr, XUARTPS_IDR_OFFSET); 945 + imr = cdns_uart_readl(CDNS_UART_IMR_OFFSET); 946 + cdns_uart_writel(imr, CDNS_UART_IDR_OFFSET); 955 947 956 948 /* Wait until FIFO is empty */ 957 - while (!(xuartps_readl(XUARTPS_SR_OFFSET) & XUARTPS_SR_TXEMPTY)) 949 + while (!(cdns_uart_readl(CDNS_UART_SR_OFFSET) & CDNS_UART_SR_TXEMPTY)) 958 950 cpu_relax(); 959 951 960 952 /* Write a character */ 961 - xuartps_writel(c, XUARTPS_FIFO_OFFSET); 953 + cdns_uart_writel(c, CDNS_UART_FIFO_OFFSET); 962 954 963 955 /* Wait until FIFO is empty */ 964 - while (!(xuartps_readl(XUARTPS_SR_OFFSET) & XUARTPS_SR_TXEMPTY)) 956 + while (!(cdns_uart_readl(CDNS_UART_SR_OFFSET) & CDNS_UART_SR_TXEMPTY)) 965 957 cpu_relax(); 966 958 967 959 /* Enable interrupts */ 968 - xuartps_writel(imr, XUARTPS_IER_OFFSET); 960 + cdns_uart_writel(imr, CDNS_UART_IER_OFFSET); 969 961 970 962 return; 971 963 } 972 964 #endif 973 965 974 - static struct uart_ops xuartps_ops = { 975 - .set_mctrl = xuartps_set_mctrl, 976 - .get_mctrl = xuartps_get_mctrl, 977 - .enable_ms = xuartps_enable_ms, 978 - .start_tx = xuartps_start_tx, 979 - .stop_tx = xuartps_stop_tx, 980 - .stop_rx = xuartps_stop_rx, 981 - .tx_empty = xuartps_tx_empty, 982 - .break_ctl = xuartps_break_ctl, 983 - .set_termios = xuartps_set_termios, 984 - .startup = xuartps_startup, 985 - .shutdown = xuartps_shutdown, 986 - .type = xuartps_type, 987 - .verify_port = xuartps_verify_port, 988 - .request_port = xuartps_request_port, 989 - .release_port = xuartps_release_port, 990 - .config_port = xuartps_config_port, 966 + static struct uart_ops cdns_uart_ops = { 967 + .set_mctrl = cdns_uart_set_mctrl, 968 + .get_mctrl = cdns_uart_get_mctrl, 969 + .enable_ms = cdns_uart_enable_ms, 970 + .start_tx = cdns_uart_start_tx, 971 + .stop_tx = cdns_uart_stop_tx, 972 + .stop_rx = cdns_uart_stop_rx, 973 + .tx_empty = cdns_uart_tx_empty, 974 + .break_ctl = cdns_uart_break_ctl, 975 + .set_termios = cdns_uart_set_termios, 976 + .startup = cdns_uart_startup, 977 + .shutdown = cdns_uart_shutdown, 978 + .type = cdns_uart_type, 979 + .verify_port = cdns_uart_verify_port, 980 + .request_port = cdns_uart_request_port, 981 + .release_port = cdns_uart_release_port, 982 + .config_port = cdns_uart_config_port, 991 983 #ifdef CONFIG_CONSOLE_POLL 992 - .poll_get_char = xuartps_poll_get_char, 993 - .poll_put_char = xuartps_poll_put_char, 984 + .poll_get_char = cdns_uart_poll_get_char, 985 + .poll_put_char = cdns_uart_poll_put_char, 994 986 #endif 995 987 }; 996 988 997 - static struct uart_port xuartps_port[2]; 989 + static struct uart_port cdns_uart_port[2]; 998 990 999 991 /** 1000 - * xuartps_get_port - Configure the port from the platform device resource info 992 + * cdns_uart_get_port - Configure the port from platform device resource info 1001 993 * @id: Port id 1002 994 * 1003 995 * Return: a pointer to a uart_port or NULL for failure 1004 996 */ 1005 - static struct uart_port *xuartps_get_port(int id) 997 + static struct uart_port *cdns_uart_get_port(int id) 1006 998 { 1007 999 struct uart_port *port; 1008 1000 1009 1001 /* Try the given port id if failed use default method */ 1010 - if (xuartps_port[id].mapbase != 0) { 1002 + if (cdns_uart_port[id].mapbase != 0) { 1011 1003 /* Find the next unused port */ 1012 - for (id = 0; id < XUARTPS_NR_PORTS; id++) 1013 - if (xuartps_port[id].mapbase == 0) 1004 + for (id = 0; id < CDNS_UART_NR_PORTS; id++) 1005 + if (cdns_uart_port[id].mapbase == 0) 1014 1006 break; 1015 1007 } 1016 1008 1017 - if (id >= XUARTPS_NR_PORTS) 1009 + if (id >= CDNS_UART_NR_PORTS) 1018 1010 return NULL; 1019 1011 1020 - port = &xuartps_port[id]; 1012 + port = &cdns_uart_port[id]; 1021 1013 1022 1014 /* At this point, we've got an empty uart_port struct, initialize it */ 1023 1015 spin_lock_init(&port->lock); ··· 1027 1019 port->type = PORT_UNKNOWN; 1028 1020 port->iotype = UPIO_MEM32; 1029 1021 port->flags = UPF_BOOT_AUTOCONF; 1030 - port->ops = &xuartps_ops; 1031 - port->fifosize = XUARTPS_FIFO_SIZE; 1022 + port->ops = &cdns_uart_ops; 1023 + port->fifosize = CDNS_UART_FIFO_SIZE; 1032 1024 port->line = id; 1033 1025 port->dev = NULL; 1034 1026 return port; ··· 1036 1028 1037 1029 #ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE 1038 1030 /** 1039 - * xuartps_console_wait_tx - Wait for the TX to be full 1031 + * cdns_uart_console_wait_tx - Wait for the TX to be full 1040 1032 * @port: Handle to the uart port structure 1041 1033 */ 1042 - static void xuartps_console_wait_tx(struct uart_port *port) 1034 + static void cdns_uart_console_wait_tx(struct uart_port *port) 1043 1035 { 1044 - while ((xuartps_readl(XUARTPS_SR_OFFSET) & XUARTPS_SR_TXEMPTY) 1045 - != XUARTPS_SR_TXEMPTY) 1036 + while ((cdns_uart_readl(CDNS_UART_SR_OFFSET) & CDNS_UART_SR_TXEMPTY) 1037 + != CDNS_UART_SR_TXEMPTY) 1046 1038 barrier(); 1047 1039 } 1048 1040 1049 1041 /** 1050 - * xuartps_console_putchar - write the character to the FIFO buffer 1042 + * cdns_uart_console_putchar - write the character to the FIFO buffer 1051 1043 * @port: Handle to the uart port structure 1052 1044 * @ch: Character to be written 1053 1045 */ 1054 - static void xuartps_console_putchar(struct uart_port *port, int ch) 1046 + static void cdns_uart_console_putchar(struct uart_port *port, int ch) 1055 1047 { 1056 - xuartps_console_wait_tx(port); 1057 - xuartps_writel(ch, XUARTPS_FIFO_OFFSET); 1048 + cdns_uart_console_wait_tx(port); 1049 + cdns_uart_writel(ch, CDNS_UART_FIFO_OFFSET); 1058 1050 } 1059 1051 1060 1052 /** 1061 - * xuartps_console_write - perform write operation 1053 + * cdns_uart_console_write - perform write operation 1062 1054 * @co: Console handle 1063 1055 * @s: Pointer to character array 1064 1056 * @count: No of characters 1065 1057 */ 1066 - static void xuartps_console_write(struct console *co, const char *s, 1058 + static void cdns_uart_console_write(struct console *co, const char *s, 1067 1059 unsigned int count) 1068 1060 { 1069 - struct uart_port *port = &xuartps_port[co->index]; 1061 + struct uart_port *port = &cdns_uart_port[co->index]; 1070 1062 unsigned long flags; 1071 1063 unsigned int imr, ctrl; 1072 1064 int locked = 1; ··· 1077 1069 spin_lock_irqsave(&port->lock, flags); 1078 1070 1079 1071 /* save and disable interrupt */ 1080 - imr = xuartps_readl(XUARTPS_IMR_OFFSET); 1081 - xuartps_writel(imr, XUARTPS_IDR_OFFSET); 1072 + imr = cdns_uart_readl(CDNS_UART_IMR_OFFSET); 1073 + cdns_uart_writel(imr, CDNS_UART_IDR_OFFSET); 1082 1074 1083 1075 /* 1084 1076 * Make sure that the tx part is enabled. Set the TX enable bit and 1085 1077 * clear the TX disable bit to enable the transmitter. 1086 1078 */ 1087 - ctrl = xuartps_readl(XUARTPS_CR_OFFSET); 1088 - xuartps_writel((ctrl & ~XUARTPS_CR_TX_DIS) | XUARTPS_CR_TX_EN, 1089 - XUARTPS_CR_OFFSET); 1079 + ctrl = cdns_uart_readl(CDNS_UART_CR_OFFSET); 1080 + cdns_uart_writel((ctrl & ~CDNS_UART_CR_TX_DIS) | CDNS_UART_CR_TX_EN, 1081 + CDNS_UART_CR_OFFSET); 1090 1082 1091 - uart_console_write(port, s, count, xuartps_console_putchar); 1092 - xuartps_console_wait_tx(port); 1083 + uart_console_write(port, s, count, cdns_uart_console_putchar); 1084 + cdns_uart_console_wait_tx(port); 1093 1085 1094 - xuartps_writel(ctrl, XUARTPS_CR_OFFSET); 1086 + cdns_uart_writel(ctrl, CDNS_UART_CR_OFFSET); 1095 1087 1096 1088 /* restore interrupt state */ 1097 - xuartps_writel(imr, XUARTPS_IER_OFFSET); 1089 + cdns_uart_writel(imr, CDNS_UART_IER_OFFSET); 1098 1090 1099 1091 if (locked) 1100 1092 spin_unlock_irqrestore(&port->lock, flags); 1101 1093 } 1102 1094 1103 1095 /** 1104 - * xuartps_console_setup - Initialize the uart to default config 1096 + * cdns_uart_console_setup - Initialize the uart to default config 1105 1097 * @co: Console handle 1106 1098 * @options: Initial settings of uart 1107 1099 * 1108 1100 * Return: 0 on success, negative errno otherwise. 1109 1101 */ 1110 - static int __init xuartps_console_setup(struct console *co, char *options) 1102 + static int __init cdns_uart_console_setup(struct console *co, char *options) 1111 1103 { 1112 - struct uart_port *port = &xuartps_port[co->index]; 1104 + struct uart_port *port = &cdns_uart_port[co->index]; 1113 1105 int baud = 9600; 1114 1106 int bits = 8; 1115 1107 int parity = 'n'; 1116 1108 int flow = 'n'; 1117 1109 1118 - if (co->index < 0 || co->index >= XUARTPS_NR_PORTS) 1110 + if (co->index < 0 || co->index >= CDNS_UART_NR_PORTS) 1119 1111 return -EINVAL; 1120 1112 1121 1113 if (!port->mapbase) { ··· 1129 1121 return uart_set_options(port, co, baud, parity, bits, flow); 1130 1122 } 1131 1123 1132 - static struct uart_driver xuartps_uart_driver; 1124 + static struct uart_driver cdns_uart_uart_driver; 1133 1125 1134 - static struct console xuartps_console = { 1135 - .name = XUARTPS_TTY_NAME, 1136 - .write = xuartps_console_write, 1126 + static struct console cdns_uart_console = { 1127 + .name = CDNS_UART_TTY_NAME, 1128 + .write = cdns_uart_console_write, 1137 1129 .device = uart_console_device, 1138 - .setup = xuartps_console_setup, 1130 + .setup = cdns_uart_console_setup, 1139 1131 .flags = CON_PRINTBUFFER, 1140 1132 .index = -1, /* Specified on the cmdline (e.g. console=ttyPS ) */ 1141 - .data = &xuartps_uart_driver, 1133 + .data = &cdns_uart_uart_driver, 1142 1134 }; 1143 1135 1144 1136 /** 1145 - * xuartps_console_init - Initialization call 1137 + * cdns_uart_console_init - Initialization call 1146 1138 * 1147 1139 * Return: 0 on success, negative errno otherwise 1148 1140 */ 1149 - static int __init xuartps_console_init(void) 1141 + static int __init cdns_uart_console_init(void) 1150 1142 { 1151 - register_console(&xuartps_console); 1143 + register_console(&cdns_uart_console); 1152 1144 return 0; 1153 1145 } 1154 1146 1155 - console_initcall(xuartps_console_init); 1147 + console_initcall(cdns_uart_console_init); 1156 1148 1157 1149 #endif /* CONFIG_SERIAL_XILINX_PS_UART_CONSOLE */ 1158 1150 1159 - static struct uart_driver xuartps_uart_driver = { 1151 + static struct uart_driver cdns_uart_uart_driver = { 1160 1152 .owner = THIS_MODULE, 1161 - .driver_name = XUARTPS_NAME, 1162 - .dev_name = XUARTPS_TTY_NAME, 1163 - .major = XUARTPS_MAJOR, 1164 - .minor = XUARTPS_MINOR, 1165 - .nr = XUARTPS_NR_PORTS, 1153 + .driver_name = CDNS_UART_NAME, 1154 + .dev_name = CDNS_UART_TTY_NAME, 1155 + .major = CDNS_UART_MAJOR, 1156 + .minor = CDNS_UART_MINOR, 1157 + .nr = CDNS_UART_NR_PORTS, 1166 1158 #ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE 1167 - .cons = &xuartps_console, 1159 + .cons = &cdns_uart_console, 1168 1160 #endif 1169 1161 }; 1170 1162 1171 1163 #ifdef CONFIG_PM_SLEEP 1172 1164 /** 1173 - * xuartps_suspend - suspend event 1165 + * cdns_uart_suspend - suspend event 1174 1166 * @device: Pointer to the device structure 1175 1167 * 1176 1168 * Return: 0 1177 1169 */ 1178 - static int xuartps_suspend(struct device *device) 1170 + static int cdns_uart_suspend(struct device *device) 1179 1171 { 1180 1172 struct uart_port *port = dev_get_drvdata(device); 1181 1173 struct tty_struct *tty; ··· 1194 1186 * Call the API provided in serial_core.c file which handles 1195 1187 * the suspend. 1196 1188 */ 1197 - uart_suspend_port(&xuartps_uart_driver, port); 1189 + uart_suspend_port(&cdns_uart_uart_driver, port); 1198 1190 if (console_suspend_enabled && !may_wake) { 1199 - struct xuartps *xuartps = port->private_data; 1191 + struct cdns_uart *cdns_uart = port->private_data; 1200 1192 1201 - clk_disable(xuartps->refclk); 1202 - clk_disable(xuartps->aperclk); 1193 + clk_disable(cdns_uart->uartclk); 1194 + clk_disable(cdns_uart->pclk); 1203 1195 } else { 1204 1196 unsigned long flags = 0; 1205 1197 1206 1198 spin_lock_irqsave(&port->lock, flags); 1207 1199 /* Empty the receive FIFO 1st before making changes */ 1208 - while (!(xuartps_readl(XUARTPS_SR_OFFSET) & XUARTPS_SR_RXEMPTY)) 1209 - xuartps_readl(XUARTPS_FIFO_OFFSET); 1200 + while (!(cdns_uart_readl(CDNS_UART_SR_OFFSET) & 1201 + CDNS_UART_SR_RXEMPTY)) 1202 + cdns_uart_readl(CDNS_UART_FIFO_OFFSET); 1210 1203 /* set RX trigger level to 1 */ 1211 - xuartps_writel(1, XUARTPS_RXWM_OFFSET); 1204 + cdns_uart_writel(1, CDNS_UART_RXWM_OFFSET); 1212 1205 /* disable RX timeout interrups */ 1213 - xuartps_writel(XUARTPS_IXR_TOUT, XUARTPS_IDR_OFFSET); 1206 + cdns_uart_writel(CDNS_UART_IXR_TOUT, CDNS_UART_IDR_OFFSET); 1214 1207 spin_unlock_irqrestore(&port->lock, flags); 1215 1208 } 1216 1209 ··· 1219 1210 } 1220 1211 1221 1212 /** 1222 - * xuartps_resume - Resume after a previous suspend 1213 + * cdns_uart_resume - Resume after a previous suspend 1223 1214 * @device: Pointer to the device structure 1224 1215 * 1225 1216 * Return: 0 1226 1217 */ 1227 - static int xuartps_resume(struct device *device) 1218 + static int cdns_uart_resume(struct device *device) 1228 1219 { 1229 1220 struct uart_port *port = dev_get_drvdata(device); 1230 1221 unsigned long flags = 0; ··· 1242 1233 } 1243 1234 1244 1235 if (console_suspend_enabled && !may_wake) { 1245 - struct xuartps *xuartps = port->private_data; 1236 + struct cdns_uart *cdns_uart = port->private_data; 1246 1237 1247 - clk_enable(xuartps->aperclk); 1248 - clk_enable(xuartps->refclk); 1238 + clk_enable(cdns_uart->pclk); 1239 + clk_enable(cdns_uart->uartclk); 1249 1240 1250 1241 spin_lock_irqsave(&port->lock, flags); 1251 1242 1252 1243 /* Set TX/RX Reset */ 1253 - ctrl_reg = xuartps_readl(XUARTPS_CR_OFFSET); 1254 - ctrl_reg |= XUARTPS_CR_TXRST | XUARTPS_CR_RXRST; 1255 - xuartps_writel(ctrl_reg, XUARTPS_CR_OFFSET); 1256 - while (xuartps_readl(XUARTPS_CR_OFFSET) & 1257 - (XUARTPS_CR_TXRST | XUARTPS_CR_RXRST)) 1244 + ctrl_reg = cdns_uart_readl(CDNS_UART_CR_OFFSET); 1245 + ctrl_reg |= CDNS_UART_CR_TXRST | CDNS_UART_CR_RXRST; 1246 + cdns_uart_writel(ctrl_reg, CDNS_UART_CR_OFFSET); 1247 + while (cdns_uart_readl(CDNS_UART_CR_OFFSET) & 1248 + (CDNS_UART_CR_TXRST | CDNS_UART_CR_RXRST)) 1258 1249 cpu_relax(); 1259 1250 1260 1251 /* restore rx timeout value */ 1261 - xuartps_writel(rx_timeout, XUARTPS_RXTOUT_OFFSET); 1252 + cdns_uart_writel(rx_timeout, CDNS_UART_RXTOUT_OFFSET); 1262 1253 /* Enable Tx/Rx */ 1263 - ctrl_reg = xuartps_readl(XUARTPS_CR_OFFSET); 1264 - ctrl_reg &= ~(XUARTPS_CR_TX_DIS | XUARTPS_CR_RX_DIS); 1265 - ctrl_reg |= XUARTPS_CR_TX_EN | XUARTPS_CR_RX_EN; 1266 - xuartps_writel(ctrl_reg, XUARTPS_CR_OFFSET); 1254 + ctrl_reg = cdns_uart_readl(CDNS_UART_CR_OFFSET); 1255 + ctrl_reg &= ~(CDNS_UART_CR_TX_DIS | CDNS_UART_CR_RX_DIS); 1256 + ctrl_reg |= CDNS_UART_CR_TX_EN | CDNS_UART_CR_RX_EN; 1257 + cdns_uart_writel(ctrl_reg, CDNS_UART_CR_OFFSET); 1267 1258 1268 1259 spin_unlock_irqrestore(&port->lock, flags); 1269 1260 } else { 1270 1261 spin_lock_irqsave(&port->lock, flags); 1271 1262 /* restore original rx trigger level */ 1272 - xuartps_writel(rx_trigger_level, XUARTPS_RXWM_OFFSET); 1263 + cdns_uart_writel(rx_trigger_level, CDNS_UART_RXWM_OFFSET); 1273 1264 /* enable RX timeout interrupt */ 1274 - xuartps_writel(XUARTPS_IXR_TOUT, XUARTPS_IER_OFFSET); 1265 + cdns_uart_writel(CDNS_UART_IXR_TOUT, CDNS_UART_IER_OFFSET); 1275 1266 spin_unlock_irqrestore(&port->lock, flags); 1276 1267 } 1277 1268 1278 - return uart_resume_port(&xuartps_uart_driver, port); 1269 + return uart_resume_port(&cdns_uart_uart_driver, port); 1279 1270 } 1280 1271 #endif /* ! CONFIG_PM_SLEEP */ 1281 1272 1282 - static SIMPLE_DEV_PM_OPS(xuartps_dev_pm_ops, xuartps_suspend, xuartps_resume); 1273 + static SIMPLE_DEV_PM_OPS(cdns_uart_dev_pm_ops, cdns_uart_suspend, 1274 + cdns_uart_resume); 1283 1275 1284 1276 /** 1285 - * xuartps_probe - Platform driver probe 1277 + * cdns_uart_probe - Platform driver probe 1286 1278 * @pdev: Pointer to the platform device structure 1287 1279 * 1288 1280 * Return: 0 on success, negative errno otherwise 1289 1281 */ 1290 - static int xuartps_probe(struct platform_device *pdev) 1282 + static int cdns_uart_probe(struct platform_device *pdev) 1291 1283 { 1292 1284 int rc, id; 1293 1285 struct uart_port *port; 1294 1286 struct resource *res, *res2; 1295 - struct xuartps *xuartps_data; 1287 + struct cdns_uart *cdns_uart_data; 1296 1288 1297 - xuartps_data = devm_kzalloc(&pdev->dev, sizeof(*xuartps_data), 1289 + cdns_uart_data = devm_kzalloc(&pdev->dev, sizeof(*cdns_uart_data), 1298 1290 GFP_KERNEL); 1299 - if (!xuartps_data) 1291 + if (!cdns_uart_data) 1300 1292 return -ENOMEM; 1301 1293 1302 - xuartps_data->aperclk = devm_clk_get(&pdev->dev, "aper_clk"); 1303 - if (IS_ERR(xuartps_data->aperclk)) { 1304 - dev_err(&pdev->dev, "aper_clk clock not found.\n"); 1305 - return PTR_ERR(xuartps_data->aperclk); 1294 + cdns_uart_data->pclk = devm_clk_get(&pdev->dev, "pclk"); 1295 + if (IS_ERR(cdns_uart_data->pclk)) { 1296 + cdns_uart_data->pclk = devm_clk_get(&pdev->dev, "aper_clk"); 1297 + if (!IS_ERR(cdns_uart_data->pclk)) 1298 + dev_err(&pdev->dev, "clock name 'aper_clk' is deprecated.\n"); 1306 1299 } 1307 - xuartps_data->refclk = devm_clk_get(&pdev->dev, "ref_clk"); 1308 - if (IS_ERR(xuartps_data->refclk)) { 1309 - dev_err(&pdev->dev, "ref_clk clock not found.\n"); 1310 - return PTR_ERR(xuartps_data->refclk); 1300 + if (IS_ERR(cdns_uart_data->pclk)) { 1301 + dev_err(&pdev->dev, "pclk clock not found.\n"); 1302 + return PTR_ERR(cdns_uart_data->pclk); 1311 1303 } 1312 1304 1313 - rc = clk_prepare_enable(xuartps_data->aperclk); 1305 + cdns_uart_data->uartclk = devm_clk_get(&pdev->dev, "uart_clk"); 1306 + if (IS_ERR(cdns_uart_data->uartclk)) { 1307 + cdns_uart_data->uartclk = devm_clk_get(&pdev->dev, "ref_clk"); 1308 + if (!IS_ERR(cdns_uart_data->uartclk)) 1309 + dev_err(&pdev->dev, "clock name 'ref_clk' is deprecated.\n"); 1310 + } 1311 + if (IS_ERR(cdns_uart_data->uartclk)) { 1312 + dev_err(&pdev->dev, "uart_clk clock not found.\n"); 1313 + return PTR_ERR(cdns_uart_data->uartclk); 1314 + } 1315 + 1316 + rc = clk_prepare_enable(cdns_uart_data->pclk); 1314 1317 if (rc) { 1315 - dev_err(&pdev->dev, "Unable to enable APER clock.\n"); 1318 + dev_err(&pdev->dev, "Unable to enable pclk clock.\n"); 1316 1319 return rc; 1317 1320 } 1318 - rc = clk_prepare_enable(xuartps_data->refclk); 1321 + rc = clk_prepare_enable(cdns_uart_data->uartclk); 1319 1322 if (rc) { 1320 1323 dev_err(&pdev->dev, "Unable to enable device clock.\n"); 1321 - goto err_out_clk_dis_aper; 1324 + goto err_out_clk_dis_pclk; 1322 1325 } 1323 1326 1324 1327 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); ··· 1346 1325 } 1347 1326 1348 1327 #ifdef CONFIG_COMMON_CLK 1349 - xuartps_data->clk_rate_change_nb.notifier_call = 1350 - xuartps_clk_notifier_cb; 1351 - if (clk_notifier_register(xuartps_data->refclk, 1352 - &xuartps_data->clk_rate_change_nb)) 1328 + cdns_uart_data->clk_rate_change_nb.notifier_call = 1329 + cdns_uart_clk_notifier_cb; 1330 + if (clk_notifier_register(cdns_uart_data->uartclk, 1331 + &cdns_uart_data->clk_rate_change_nb)) 1353 1332 dev_warn(&pdev->dev, "Unable to register clock notifier.\n"); 1354 1333 #endif 1355 1334 /* Look for a serialN alias */ ··· 1358 1337 id = 0; 1359 1338 1360 1339 /* Initialize the port structure */ 1361 - port = xuartps_get_port(id); 1340 + port = cdns_uart_get_port(id); 1362 1341 1363 1342 if (!port) { 1364 1343 dev_err(&pdev->dev, "Cannot get uart_port structure\n"); ··· 1372 1351 port->mapbase = res->start; 1373 1352 port->irq = res2->start; 1374 1353 port->dev = &pdev->dev; 1375 - port->uartclk = clk_get_rate(xuartps_data->refclk); 1376 - port->private_data = xuartps_data; 1377 - xuartps_data->port = port; 1354 + port->uartclk = clk_get_rate(cdns_uart_data->uartclk); 1355 + port->private_data = cdns_uart_data; 1356 + cdns_uart_data->port = port; 1378 1357 platform_set_drvdata(pdev, port); 1379 - rc = uart_add_one_port(&xuartps_uart_driver, port); 1358 + rc = uart_add_one_port(&cdns_uart_uart_driver, port); 1380 1359 if (rc) { 1381 1360 dev_err(&pdev->dev, 1382 1361 "uart_add_one_port() failed; err=%i\n", rc); ··· 1387 1366 1388 1367 err_out_notif_unreg: 1389 1368 #ifdef CONFIG_COMMON_CLK 1390 - clk_notifier_unregister(xuartps_data->refclk, 1391 - &xuartps_data->clk_rate_change_nb); 1369 + clk_notifier_unregister(cdns_uart_data->uartclk, 1370 + &cdns_uart_data->clk_rate_change_nb); 1392 1371 #endif 1393 1372 err_out_clk_disable: 1394 - clk_disable_unprepare(xuartps_data->refclk); 1395 - err_out_clk_dis_aper: 1396 - clk_disable_unprepare(xuartps_data->aperclk); 1373 + clk_disable_unprepare(cdns_uart_data->uartclk); 1374 + err_out_clk_dis_pclk: 1375 + clk_disable_unprepare(cdns_uart_data->pclk); 1397 1376 1398 1377 return rc; 1399 1378 } 1400 1379 1401 1380 /** 1402 - * xuartps_remove - called when the platform driver is unregistered 1381 + * cdns_uart_remove - called when the platform driver is unregistered 1403 1382 * @pdev: Pointer to the platform device structure 1404 1383 * 1405 1384 * Return: 0 on success, negative errno otherwise 1406 1385 */ 1407 - static int xuartps_remove(struct platform_device *pdev) 1386 + static int cdns_uart_remove(struct platform_device *pdev) 1408 1387 { 1409 1388 struct uart_port *port = platform_get_drvdata(pdev); 1410 - struct xuartps *xuartps_data = port->private_data; 1389 + struct cdns_uart *cdns_uart_data = port->private_data; 1411 1390 int rc; 1412 1391 1413 - /* Remove the xuartps port from the serial core */ 1392 + /* Remove the cdns_uart port from the serial core */ 1414 1393 #ifdef CONFIG_COMMON_CLK 1415 - clk_notifier_unregister(xuartps_data->refclk, 1416 - &xuartps_data->clk_rate_change_nb); 1394 + clk_notifier_unregister(cdns_uart_data->uartclk, 1395 + &cdns_uart_data->clk_rate_change_nb); 1417 1396 #endif 1418 - rc = uart_remove_one_port(&xuartps_uart_driver, port); 1397 + rc = uart_remove_one_port(&cdns_uart_uart_driver, port); 1419 1398 port->mapbase = 0; 1420 - clk_disable_unprepare(xuartps_data->refclk); 1421 - clk_disable_unprepare(xuartps_data->aperclk); 1399 + clk_disable_unprepare(cdns_uart_data->uartclk); 1400 + clk_disable_unprepare(cdns_uart_data->pclk); 1422 1401 return rc; 1423 1402 } 1424 1403 1425 1404 /* Match table for of_platform binding */ 1426 - static struct of_device_id xuartps_of_match[] = { 1405 + static struct of_device_id cdns_uart_of_match[] = { 1427 1406 { .compatible = "xlnx,xuartps", }, 1407 + { .compatible = "cdns,uart-r1p8", }, 1428 1408 {} 1429 1409 }; 1430 - MODULE_DEVICE_TABLE(of, xuartps_of_match); 1410 + MODULE_DEVICE_TABLE(of, cdns_uart_of_match); 1431 1411 1432 - static struct platform_driver xuartps_platform_driver = { 1433 - .probe = xuartps_probe, 1434 - .remove = xuartps_remove, 1412 + static struct platform_driver cdns_uart_platform_driver = { 1413 + .probe = cdns_uart_probe, 1414 + .remove = cdns_uart_remove, 1435 1415 .driver = { 1436 1416 .owner = THIS_MODULE, 1437 - .name = XUARTPS_NAME, 1438 - .of_match_table = xuartps_of_match, 1439 - .pm = &xuartps_dev_pm_ops, 1417 + .name = CDNS_UART_NAME, 1418 + .of_match_table = cdns_uart_of_match, 1419 + .pm = &cdns_uart_dev_pm_ops, 1440 1420 }, 1441 1421 }; 1442 1422 1443 - static int __init xuartps_init(void) 1423 + static int __init cdns_uart_init(void) 1444 1424 { 1445 1425 int retval = 0; 1446 1426 1447 - /* Register the xuartps driver with the serial core */ 1448 - retval = uart_register_driver(&xuartps_uart_driver); 1427 + /* Register the cdns_uart driver with the serial core */ 1428 + retval = uart_register_driver(&cdns_uart_uart_driver); 1449 1429 if (retval) 1450 1430 return retval; 1451 1431 1452 1432 /* Register the platform driver */ 1453 - retval = platform_driver_register(&xuartps_platform_driver); 1433 + retval = platform_driver_register(&cdns_uart_platform_driver); 1454 1434 if (retval) 1455 - uart_unregister_driver(&xuartps_uart_driver); 1435 + uart_unregister_driver(&cdns_uart_uart_driver); 1456 1436 1457 1437 return retval; 1458 1438 } 1459 1439 1460 - static void __exit xuartps_exit(void) 1440 + static void __exit cdns_uart_exit(void) 1461 1441 { 1462 1442 /* Unregister the platform driver */ 1463 - platform_driver_unregister(&xuartps_platform_driver); 1443 + platform_driver_unregister(&cdns_uart_platform_driver); 1464 1444 1465 - /* Unregister the xuartps driver */ 1466 - uart_unregister_driver(&xuartps_uart_driver); 1445 + /* Unregister the cdns_uart driver */ 1446 + uart_unregister_driver(&cdns_uart_uart_driver); 1467 1447 } 1468 1448 1469 - module_init(xuartps_init); 1470 - module_exit(xuartps_exit); 1449 + module_init(cdns_uart_init); 1450 + module_exit(cdns_uart_exit); 1471 1451 1472 - MODULE_DESCRIPTION("Driver for PS UART"); 1452 + MODULE_DESCRIPTION("Driver for Cadence UART"); 1473 1453 MODULE_AUTHOR("Xilinx Inc."); 1474 1454 MODULE_LICENSE("GPL");
+1 -1
include/uapi/linux/serial_core.h
··· 211 211 /* VIA VT8500 SoC */ 212 212 #define PORT_VT8500 97 213 213 214 - /* Xilinx PSS UART */ 214 + /* Cadence (Xilinx Zynq) UART */ 215 215 #define PORT_XUARTPS 98 216 216 217 217 /* Atheros AR933X SoC */