diff options
Diffstat (limited to 'drivers/serial')
-rw-r--r-- | drivers/serial/mpc52xx_uart.c | 210 | ||||
-rw-r--r-- | drivers/serial/suncore.c | 2 |
2 files changed, 114 insertions, 98 deletions
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c index 7e3ba8b455a8..1e3721a0eef7 100644 --- a/drivers/serial/mpc52xx_uart.c +++ b/drivers/serial/mpc52xx_uart.c | |||
@@ -36,7 +36,7 @@ | |||
36 | * DCD. However, the pin multiplexing aren't changed and should be set either | 36 | * DCD. However, the pin multiplexing aren't changed and should be set either |
37 | * by the bootloader or in the platform init code. | 37 | * by the bootloader or in the platform init code. |
38 | * | 38 | * |
39 | * The idx field must be equal to the PSC index ( e.g. 0 for PSC1, 1 for PSC2, | 39 | * The idx field must be equal to the PSC index (e.g. 0 for PSC1, 1 for PSC2, |
40 | * and so on). So the PSC1 is mapped to /dev/ttyPSC0, PSC2 to /dev/ttyPSC1 and | 40 | * and so on). So the PSC1 is mapped to /dev/ttyPSC0, PSC2 to /dev/ttyPSC1 and |
41 | * so on. But be warned, it's an ABSOLUTE REQUIREMENT ! This is needed mainly | 41 | * so on. But be warned, it's an ABSOLUTE REQUIREMENT ! This is needed mainly |
42 | * fpr the console code : without this 1:1 mapping, at early boot time, when we | 42 | * fpr the console code : without this 1:1 mapping, at early boot time, when we |
@@ -68,8 +68,8 @@ | |||
68 | #include <linux/sysrq.h> | 68 | #include <linux/sysrq.h> |
69 | #include <linux/console.h> | 69 | #include <linux/console.h> |
70 | 70 | ||
71 | #include <asm/delay.h> | 71 | #include <linux/delay.h> |
72 | #include <asm/io.h> | 72 | #include <linux/io.h> |
73 | 73 | ||
74 | #if defined(CONFIG_PPC_MERGE) | 74 | #if defined(CONFIG_PPC_MERGE) |
75 | #include <linux/of.h> | 75 | #include <linux/of.h> |
@@ -112,16 +112,18 @@ static void mpc52xx_uart_of_enumerate(void); | |||
112 | #endif | 112 | #endif |
113 | 113 | ||
114 | #define PSC(port) ((struct mpc52xx_psc __iomem *)((port)->membase)) | 114 | #define PSC(port) ((struct mpc52xx_psc __iomem *)((port)->membase)) |
115 | #define FIFO(port) ((struct mpc52xx_psc_fifo __iomem *)(PSC(port)+1)) | ||
115 | 116 | ||
116 | 117 | ||
117 | /* Forward declaration of the interruption handling routine */ | 118 | /* Forward declaration of the interruption handling routine */ |
118 | static irqreturn_t mpc52xx_uart_int(int irq,void *dev_id); | 119 | static irqreturn_t mpc52xx_uart_int(int irq, void *dev_id); |
119 | 120 | ||
120 | 121 | ||
121 | /* Simple macro to test if a port is console or not. This one is taken | 122 | /* Simple macro to test if a port is console or not. This one is taken |
122 | * for serial_core.c and maybe should be moved to serial_core.h ? */ | 123 | * for serial_core.c and maybe should be moved to serial_core.h ? */ |
123 | #ifdef CONFIG_SERIAL_CORE_CONSOLE | 124 | #ifdef CONFIG_SERIAL_CORE_CONSOLE |
124 | #define uart_console(port) ((port)->cons && (port)->cons->index == (port)->line) | 125 | #define uart_console(port) \ |
126 | ((port)->cons && (port)->cons->index == (port)->line) | ||
125 | #else | 127 | #else |
126 | #define uart_console(port) (0) | 128 | #define uart_console(port) (0) |
127 | #endif | 129 | #endif |
@@ -163,7 +165,7 @@ mpc52xx_uart_stop_tx(struct uart_port *port) | |||
163 | { | 165 | { |
164 | /* port->lock taken by caller */ | 166 | /* port->lock taken by caller */ |
165 | port->read_status_mask &= ~MPC52xx_PSC_IMR_TXRDY; | 167 | port->read_status_mask &= ~MPC52xx_PSC_IMR_TXRDY; |
166 | out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask); | 168 | out_be16(&PSC(port)->mpc52xx_psc_imr, port->read_status_mask); |
167 | } | 169 | } |
168 | 170 | ||
169 | static void | 171 | static void |
@@ -171,7 +173,7 @@ mpc52xx_uart_start_tx(struct uart_port *port) | |||
171 | { | 173 | { |
172 | /* port->lock taken by caller */ | 174 | /* port->lock taken by caller */ |
173 | port->read_status_mask |= MPC52xx_PSC_IMR_TXRDY; | 175 | port->read_status_mask |= MPC52xx_PSC_IMR_TXRDY; |
174 | out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask); | 176 | out_be16(&PSC(port)->mpc52xx_psc_imr, port->read_status_mask); |
175 | } | 177 | } |
176 | 178 | ||
177 | static void | 179 | static void |
@@ -185,7 +187,7 @@ mpc52xx_uart_send_xchar(struct uart_port *port, char ch) | |||
185 | /* Make sure tx interrupts are on */ | 187 | /* Make sure tx interrupts are on */ |
186 | /* Truly necessary ??? They should be anyway */ | 188 | /* Truly necessary ??? They should be anyway */ |
187 | port->read_status_mask |= MPC52xx_PSC_IMR_TXRDY; | 189 | port->read_status_mask |= MPC52xx_PSC_IMR_TXRDY; |
188 | out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask); | 190 | out_be16(&PSC(port)->mpc52xx_psc_imr, port->read_status_mask); |
189 | } | 191 | } |
190 | 192 | ||
191 | spin_unlock_irqrestore(&port->lock, flags); | 193 | spin_unlock_irqrestore(&port->lock, flags); |
@@ -196,7 +198,7 @@ mpc52xx_uart_stop_rx(struct uart_port *port) | |||
196 | { | 198 | { |
197 | /* port->lock taken by caller */ | 199 | /* port->lock taken by caller */ |
198 | port->read_status_mask &= ~MPC52xx_PSC_IMR_RXRDY; | 200 | port->read_status_mask &= ~MPC52xx_PSC_IMR_RXRDY; |
199 | out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask); | 201 | out_be16(&PSC(port)->mpc52xx_psc_imr, port->read_status_mask); |
200 | } | 202 | } |
201 | 203 | ||
202 | static void | 204 | static void |
@@ -211,10 +213,10 @@ mpc52xx_uart_break_ctl(struct uart_port *port, int ctl) | |||
211 | unsigned long flags; | 213 | unsigned long flags; |
212 | spin_lock_irqsave(&port->lock, flags); | 214 | spin_lock_irqsave(&port->lock, flags); |
213 | 215 | ||
214 | if ( ctl == -1 ) | 216 | if (ctl == -1) |
215 | out_8(&PSC(port)->command,MPC52xx_PSC_START_BRK); | 217 | out_8(&PSC(port)->command, MPC52xx_PSC_START_BRK); |
216 | else | 218 | else |
217 | out_8(&PSC(port)->command,MPC52xx_PSC_STOP_BRK); | 219 | out_8(&PSC(port)->command, MPC52xx_PSC_STOP_BRK); |
218 | 220 | ||
219 | spin_unlock_irqrestore(&port->lock, flags); | 221 | spin_unlock_irqrestore(&port->lock, flags); |
220 | } | 222 | } |
@@ -223,6 +225,7 @@ static int | |||
223 | mpc52xx_uart_startup(struct uart_port *port) | 225 | mpc52xx_uart_startup(struct uart_port *port) |
224 | { | 226 | { |
225 | struct mpc52xx_psc __iomem *psc = PSC(port); | 227 | struct mpc52xx_psc __iomem *psc = PSC(port); |
228 | struct mpc52xx_psc_fifo __iomem *fifo = FIFO(port); | ||
226 | int ret; | 229 | int ret; |
227 | 230 | ||
228 | /* Request IRQ */ | 231 | /* Request IRQ */ |
@@ -232,23 +235,23 @@ mpc52xx_uart_startup(struct uart_port *port) | |||
232 | return ret; | 235 | return ret; |
233 | 236 | ||
234 | /* Reset/activate the port, clear and enable interrupts */ | 237 | /* Reset/activate the port, clear and enable interrupts */ |
235 | out_8(&psc->command,MPC52xx_PSC_RST_RX); | 238 | out_8(&psc->command, MPC52xx_PSC_RST_RX); |
236 | out_8(&psc->command,MPC52xx_PSC_RST_TX); | 239 | out_8(&psc->command, MPC52xx_PSC_RST_TX); |
237 | 240 | ||
238 | out_be32(&psc->sicr,0); /* UART mode DCD ignored */ | 241 | out_be32(&psc->sicr, 0); /* UART mode DCD ignored */ |
239 | 242 | ||
240 | out_be16(&psc->mpc52xx_psc_clock_select, 0xdd00); /* /16 prescaler on */ | 243 | out_be16(&psc->mpc52xx_psc_clock_select, 0xdd00); /* /16 prescaler on */ |
241 | 244 | ||
242 | out_8(&psc->rfcntl, 0x00); | 245 | out_8(&fifo->rfcntl, 0x00); |
243 | out_be16(&psc->rfalarm, 0x1ff); | 246 | out_be16(&fifo->rfalarm, 0x1ff); |
244 | out_8(&psc->tfcntl, 0x07); | 247 | out_8(&fifo->tfcntl, 0x07); |
245 | out_be16(&psc->tfalarm, 0x80); | 248 | out_be16(&fifo->tfalarm, 0x80); |
246 | 249 | ||
247 | port->read_status_mask |= MPC52xx_PSC_IMR_RXRDY | MPC52xx_PSC_IMR_TXRDY; | 250 | port->read_status_mask |= MPC52xx_PSC_IMR_RXRDY | MPC52xx_PSC_IMR_TXRDY; |
248 | out_be16(&psc->mpc52xx_psc_imr,port->read_status_mask); | 251 | out_be16(&psc->mpc52xx_psc_imr, port->read_status_mask); |
249 | 252 | ||
250 | out_8(&psc->command,MPC52xx_PSC_TX_ENABLE); | 253 | out_8(&psc->command, MPC52xx_PSC_TX_ENABLE); |
251 | out_8(&psc->command,MPC52xx_PSC_RX_ENABLE); | 254 | out_8(&psc->command, MPC52xx_PSC_RX_ENABLE); |
252 | 255 | ||
253 | return 0; | 256 | return 0; |
254 | } | 257 | } |
@@ -259,12 +262,12 @@ mpc52xx_uart_shutdown(struct uart_port *port) | |||
259 | struct mpc52xx_psc __iomem *psc = PSC(port); | 262 | struct mpc52xx_psc __iomem *psc = PSC(port); |
260 | 263 | ||
261 | /* Shut down the port. Leave TX active if on a console port */ | 264 | /* Shut down the port. Leave TX active if on a console port */ |
262 | out_8(&psc->command,MPC52xx_PSC_RST_RX); | 265 | out_8(&psc->command, MPC52xx_PSC_RST_RX); |
263 | if (!uart_console(port)) | 266 | if (!uart_console(port)) |
264 | out_8(&psc->command,MPC52xx_PSC_RST_TX); | 267 | out_8(&psc->command, MPC52xx_PSC_RST_TX); |
265 | 268 | ||
266 | port->read_status_mask = 0; | 269 | port->read_status_mask = 0; |
267 | out_be16(&psc->mpc52xx_psc_imr,port->read_status_mask); | 270 | out_be16(&psc->mpc52xx_psc_imr, port->read_status_mask); |
268 | 271 | ||
269 | /* Release interrupt */ | 272 | /* Release interrupt */ |
270 | free_irq(port->irq, port); | 273 | free_irq(port->irq, port); |
@@ -272,7 +275,7 @@ mpc52xx_uart_shutdown(struct uart_port *port) | |||
272 | 275 | ||
273 | static void | 276 | static void |
274 | mpc52xx_uart_set_termios(struct uart_port *port, struct ktermios *new, | 277 | mpc52xx_uart_set_termios(struct uart_port *port, struct ktermios *new, |
275 | struct ktermios *old) | 278 | struct ktermios *old) |
276 | { | 279 | { |
277 | struct mpc52xx_psc __iomem *psc = PSC(port); | 280 | struct mpc52xx_psc __iomem *psc = PSC(port); |
278 | unsigned long flags; | 281 | unsigned long flags; |
@@ -284,14 +287,14 @@ mpc52xx_uart_set_termios(struct uart_port *port, struct ktermios *new, | |||
284 | mr1 = 0; | 287 | mr1 = 0; |
285 | 288 | ||
286 | switch (new->c_cflag & CSIZE) { | 289 | switch (new->c_cflag & CSIZE) { |
287 | case CS5: mr1 |= MPC52xx_PSC_MODE_5_BITS; | 290 | case CS5: mr1 |= MPC52xx_PSC_MODE_5_BITS; |
288 | break; | 291 | break; |
289 | case CS6: mr1 |= MPC52xx_PSC_MODE_6_BITS; | 292 | case CS6: mr1 |= MPC52xx_PSC_MODE_6_BITS; |
290 | break; | 293 | break; |
291 | case CS7: mr1 |= MPC52xx_PSC_MODE_7_BITS; | 294 | case CS7: mr1 |= MPC52xx_PSC_MODE_7_BITS; |
292 | break; | 295 | break; |
293 | case CS8: | 296 | case CS8: |
294 | default: mr1 |= MPC52xx_PSC_MODE_8_BITS; | 297 | default: mr1 |= MPC52xx_PSC_MODE_8_BITS; |
295 | } | 298 | } |
296 | 299 | ||
297 | if (new->c_cflag & PARENB) { | 300 | if (new->c_cflag & PARENB) { |
@@ -333,24 +336,24 @@ mpc52xx_uart_set_termios(struct uart_port *port, struct ktermios *new, | |||
333 | udelay(1); | 336 | udelay(1); |
334 | 337 | ||
335 | if (!j) | 338 | if (!j) |
336 | printk( KERN_ERR "mpc52xx_uart.c: " | 339 | printk(KERN_ERR "mpc52xx_uart.c: " |
337 | "Unable to flush RX & TX fifos in-time in set_termios." | 340 | "Unable to flush RX & TX fifos in-time in set_termios." |
338 | "Some chars may have been lost.\n" ); | 341 | "Some chars may have been lost.\n"); |
339 | 342 | ||
340 | /* Reset the TX & RX */ | 343 | /* Reset the TX & RX */ |
341 | out_8(&psc->command,MPC52xx_PSC_RST_RX); | 344 | out_8(&psc->command, MPC52xx_PSC_RST_RX); |
342 | out_8(&psc->command,MPC52xx_PSC_RST_TX); | 345 | out_8(&psc->command, MPC52xx_PSC_RST_TX); |
343 | 346 | ||
344 | /* Send new mode settings */ | 347 | /* Send new mode settings */ |
345 | out_8(&psc->command,MPC52xx_PSC_SEL_MODE_REG_1); | 348 | out_8(&psc->command, MPC52xx_PSC_SEL_MODE_REG_1); |
346 | out_8(&psc->mode,mr1); | 349 | out_8(&psc->mode, mr1); |
347 | out_8(&psc->mode,mr2); | 350 | out_8(&psc->mode, mr2); |
348 | out_8(&psc->ctur,ctr >> 8); | 351 | out_8(&psc->ctur, ctr >> 8); |
349 | out_8(&psc->ctlr,ctr & 0xff); | 352 | out_8(&psc->ctlr, ctr & 0xff); |
350 | 353 | ||
351 | /* Reenable TX & RX */ | 354 | /* Reenable TX & RX */ |
352 | out_8(&psc->command,MPC52xx_PSC_TX_ENABLE); | 355 | out_8(&psc->command, MPC52xx_PSC_TX_ENABLE); |
353 | out_8(&psc->command,MPC52xx_PSC_RX_ENABLE); | 356 | out_8(&psc->command, MPC52xx_PSC_RX_ENABLE); |
354 | 357 | ||
355 | /* We're all set, release the lock */ | 358 | /* We're all set, release the lock */ |
356 | spin_unlock_irqrestore(&port->lock, flags); | 359 | spin_unlock_irqrestore(&port->lock, flags); |
@@ -365,7 +368,8 @@ mpc52xx_uart_type(struct uart_port *port) | |||
365 | static void | 368 | static void |
366 | mpc52xx_uart_release_port(struct uart_port *port) | 369 | mpc52xx_uart_release_port(struct uart_port *port) |
367 | { | 370 | { |
368 | if (port->flags & UPF_IOREMAP) { /* remapped by us ? */ | 371 | /* remapped by us ? */ |
372 | if (port->flags & UPF_IOREMAP) { | ||
369 | iounmap(port->membase); | 373 | iounmap(port->membase); |
370 | port->membase = NULL; | 374 | port->membase = NULL; |
371 | } | 375 | } |
@@ -380,7 +384,7 @@ mpc52xx_uart_request_port(struct uart_port *port) | |||
380 | 384 | ||
381 | if (port->flags & UPF_IOREMAP) /* Need to remap ? */ | 385 | if (port->flags & UPF_IOREMAP) /* Need to remap ? */ |
382 | port->membase = ioremap(port->mapbase, | 386 | port->membase = ioremap(port->mapbase, |
383 | sizeof(struct mpc52xx_psc)); | 387 | sizeof(struct mpc52xx_psc)); |
384 | 388 | ||
385 | if (!port->membase) | 389 | if (!port->membase) |
386 | return -EINVAL; | 390 | return -EINVAL; |
@@ -399,22 +403,22 @@ mpc52xx_uart_request_port(struct uart_port *port) | |||
399 | static void | 403 | static void |
400 | mpc52xx_uart_config_port(struct uart_port *port, int flags) | 404 | mpc52xx_uart_config_port(struct uart_port *port, int flags) |
401 | { | 405 | { |
402 | if ( (flags & UART_CONFIG_TYPE) && | 406 | if ((flags & UART_CONFIG_TYPE) |
403 | (mpc52xx_uart_request_port(port) == 0) ) | 407 | && (mpc52xx_uart_request_port(port) == 0)) |
404 | port->type = PORT_MPC52xx; | 408 | port->type = PORT_MPC52xx; |
405 | } | 409 | } |
406 | 410 | ||
407 | static int | 411 | static int |
408 | mpc52xx_uart_verify_port(struct uart_port *port, struct serial_struct *ser) | 412 | mpc52xx_uart_verify_port(struct uart_port *port, struct serial_struct *ser) |
409 | { | 413 | { |
410 | if ( ser->type != PORT_UNKNOWN && ser->type != PORT_MPC52xx ) | 414 | if (ser->type != PORT_UNKNOWN && ser->type != PORT_MPC52xx) |
411 | return -EINVAL; | 415 | return -EINVAL; |
412 | 416 | ||
413 | if ( (ser->irq != port->irq) || | 417 | if ((ser->irq != port->irq) || |
414 | (ser->io_type != SERIAL_IO_MEM) || | 418 | (ser->io_type != SERIAL_IO_MEM) || |
415 | (ser->baud_base != port->uartclk) || | 419 | (ser->baud_base != port->uartclk) || |
416 | (ser->iomem_base != (void*)port->mapbase) || | 420 | (ser->iomem_base != (void *)port->mapbase) || |
417 | (ser->hub6 != 0 ) ) | 421 | (ser->hub6 != 0)) |
418 | return -EINVAL; | 422 | return -EINVAL; |
419 | 423 | ||
420 | return 0; | 424 | return 0; |
@@ -456,8 +460,8 @@ mpc52xx_uart_int_rx_chars(struct uart_port *port) | |||
456 | unsigned short status; | 460 | unsigned short status; |
457 | 461 | ||
458 | /* While we can read, do so ! */ | 462 | /* While we can read, do so ! */ |
459 | while ( (status = in_be16(&PSC(port)->mpc52xx_psc_status)) & | 463 | while ((status = in_be16(&PSC(port)->mpc52xx_psc_status)) & |
460 | MPC52xx_PSC_SR_RXRDY) { | 464 | MPC52xx_PSC_SR_RXRDY) { |
461 | 465 | ||
462 | /* Get the char */ | 466 | /* Get the char */ |
463 | ch = in_8(&PSC(port)->mpc52xx_psc_buffer_8); | 467 | ch = in_8(&PSC(port)->mpc52xx_psc_buffer_8); |
@@ -475,9 +479,9 @@ mpc52xx_uart_int_rx_chars(struct uart_port *port) | |||
475 | flag = TTY_NORMAL; | 479 | flag = TTY_NORMAL; |
476 | port->icount.rx++; | 480 | port->icount.rx++; |
477 | 481 | ||
478 | if ( status & (MPC52xx_PSC_SR_PE | | 482 | if (status & (MPC52xx_PSC_SR_PE | |
479 | MPC52xx_PSC_SR_FE | | 483 | MPC52xx_PSC_SR_FE | |
480 | MPC52xx_PSC_SR_RB) ) { | 484 | MPC52xx_PSC_SR_RB)) { |
481 | 485 | ||
482 | if (status & MPC52xx_PSC_SR_RB) { | 486 | if (status & MPC52xx_PSC_SR_RB) { |
483 | flag = TTY_BREAK; | 487 | flag = TTY_BREAK; |
@@ -488,7 +492,7 @@ mpc52xx_uart_int_rx_chars(struct uart_port *port) | |||
488 | flag = TTY_FRAME; | 492 | flag = TTY_FRAME; |
489 | 493 | ||
490 | /* Clear error condition */ | 494 | /* Clear error condition */ |
491 | out_8(&PSC(port)->command,MPC52xx_PSC_RST_ERR_STAT); | 495 | out_8(&PSC(port)->command, MPC52xx_PSC_RST_ERR_STAT); |
492 | 496 | ||
493 | } | 497 | } |
494 | tty_insert_flip_char(tty, ch, flag); | 498 | tty_insert_flip_char(tty, ch, flag); |
@@ -569,16 +573,16 @@ mpc52xx_uart_int(int irq, void *dev_id) | |||
569 | 573 | ||
570 | /* Do we need to receive chars ? */ | 574 | /* Do we need to receive chars ? */ |
571 | /* For this RX interrupts must be on and some chars waiting */ | 575 | /* For this RX interrupts must be on and some chars waiting */ |
572 | if ( status & MPC52xx_PSC_IMR_RXRDY ) | 576 | if (status & MPC52xx_PSC_IMR_RXRDY) |
573 | keepgoing |= mpc52xx_uart_int_rx_chars(port); | 577 | keepgoing |= mpc52xx_uart_int_rx_chars(port); |
574 | 578 | ||
575 | /* Do we need to send chars ? */ | 579 | /* Do we need to send chars ? */ |
576 | /* For this, TX must be ready and TX interrupt enabled */ | 580 | /* For this, TX must be ready and TX interrupt enabled */ |
577 | if ( status & MPC52xx_PSC_IMR_TXRDY ) | 581 | if (status & MPC52xx_PSC_IMR_TXRDY) |
578 | keepgoing |= mpc52xx_uart_int_tx_chars(port); | 582 | keepgoing |= mpc52xx_uart_int_tx_chars(port); |
579 | 583 | ||
580 | /* Limit number of iteration */ | 584 | /* Limit number of iteration */ |
581 | if ( !(--pass) ) | 585 | if (!(--pass)) |
582 | keepgoing = 0; | 586 | keepgoing = 0; |
583 | 587 | ||
584 | } while (keepgoing); | 588 | } while (keepgoing); |
@@ -597,7 +601,7 @@ mpc52xx_uart_int(int irq, void *dev_id) | |||
597 | 601 | ||
598 | static void __init | 602 | static void __init |
599 | mpc52xx_console_get_options(struct uart_port *port, | 603 | mpc52xx_console_get_options(struct uart_port *port, |
600 | int *baud, int *parity, int *bits, int *flow) | 604 | int *baud, int *parity, int *bits, int *flow) |
601 | { | 605 | { |
602 | struct mpc52xx_psc __iomem *psc = PSC(port); | 606 | struct mpc52xx_psc __iomem *psc = PSC(port); |
603 | unsigned char mr1; | 607 | unsigned char mr1; |
@@ -605,7 +609,7 @@ mpc52xx_console_get_options(struct uart_port *port, | |||
605 | pr_debug("mpc52xx_console_get_options(port=%p)\n", port); | 609 | pr_debug("mpc52xx_console_get_options(port=%p)\n", port); |
606 | 610 | ||
607 | /* Read the mode registers */ | 611 | /* Read the mode registers */ |
608 | out_8(&psc->command,MPC52xx_PSC_SEL_MODE_REG_1); | 612 | out_8(&psc->command, MPC52xx_PSC_SEL_MODE_REG_1); |
609 | mr1 = in_8(&psc->mode); | 613 | mr1 = in_8(&psc->mode); |
610 | 614 | ||
611 | /* CT{U,L}R are write-only ! */ | 615 | /* CT{U,L}R are write-only ! */ |
@@ -617,11 +621,18 @@ mpc52xx_console_get_options(struct uart_port *port, | |||
617 | 621 | ||
618 | /* Parse them */ | 622 | /* Parse them */ |
619 | switch (mr1 & MPC52xx_PSC_MODE_BITS_MASK) { | 623 | switch (mr1 & MPC52xx_PSC_MODE_BITS_MASK) { |
620 | case MPC52xx_PSC_MODE_5_BITS: *bits = 5; break; | 624 | case MPC52xx_PSC_MODE_5_BITS: |
621 | case MPC52xx_PSC_MODE_6_BITS: *bits = 6; break; | 625 | *bits = 5; |
622 | case MPC52xx_PSC_MODE_7_BITS: *bits = 7; break; | 626 | break; |
623 | case MPC52xx_PSC_MODE_8_BITS: | 627 | case MPC52xx_PSC_MODE_6_BITS: |
624 | default: *bits = 8; | 628 | *bits = 6; |
629 | break; | ||
630 | case MPC52xx_PSC_MODE_7_BITS: | ||
631 | *bits = 7; | ||
632 | break; | ||
633 | case MPC52xx_PSC_MODE_8_BITS: | ||
634 | default: | ||
635 | *bits = 8; | ||
625 | } | 636 | } |
626 | 637 | ||
627 | if (mr1 & MPC52xx_PSC_MODE_PARNONE) | 638 | if (mr1 & MPC52xx_PSC_MODE_PARNONE) |
@@ -658,7 +669,7 @@ mpc52xx_console_write(struct console *co, const char *s, unsigned int count) | |||
658 | /* Wait the TX buffer to be empty */ | 669 | /* Wait the TX buffer to be empty */ |
659 | j = 20000; /* Maximum wait */ | 670 | j = 20000; /* Maximum wait */ |
660 | while (!(in_be16(&psc->mpc52xx_psc_status) & | 671 | while (!(in_be16(&psc->mpc52xx_psc_status) & |
661 | MPC52xx_PSC_SR_TXEMP) && --j) | 672 | MPC52xx_PSC_SR_TXEMP) && --j) |
662 | udelay(1); | 673 | udelay(1); |
663 | } | 674 | } |
664 | 675 | ||
@@ -731,16 +742,18 @@ mpc52xx_console_setup(struct console *co, char *options) | |||
731 | } | 742 | } |
732 | 743 | ||
733 | pr_debug("Console on ttyPSC%x is %s\n", | 744 | pr_debug("Console on ttyPSC%x is %s\n", |
734 | co->index, mpc52xx_uart_nodes[co->index]->full_name); | 745 | co->index, mpc52xx_uart_nodes[co->index]->full_name); |
735 | 746 | ||
736 | /* Fetch register locations */ | 747 | /* Fetch register locations */ |
737 | if ((ret = of_address_to_resource(np, 0, &res)) != 0) { | 748 | ret = of_address_to_resource(np, 0, &res); |
749 | if (ret) { | ||
738 | pr_debug("Could not get resources for PSC%x\n", co->index); | 750 | pr_debug("Could not get resources for PSC%x\n", co->index); |
739 | return ret; | 751 | return ret; |
740 | } | 752 | } |
741 | 753 | ||
742 | /* Search for bus-frequency property in this node or a parent */ | 754 | /* Search for bus-frequency property in this node or a parent */ |
743 | if ((ipb_freq = mpc52xx_find_ipb_freq(np)) == 0) { | 755 | ipb_freq = mpc52xx_find_ipb_freq(np); |
756 | if (ipb_freq == 0) { | ||
744 | pr_debug("Could not find IPB bus frequency!\n"); | 757 | pr_debug("Could not find IPB bus frequency!\n"); |
745 | return -EINVAL; | 758 | return -EINVAL; |
746 | } | 759 | } |
@@ -758,7 +771,8 @@ mpc52xx_console_setup(struct console *co, char *options) | |||
758 | return -EINVAL; | 771 | return -EINVAL; |
759 | 772 | ||
760 | pr_debug("mpc52xx-psc uart at %p, mapped to %p, irq=%x, freq=%i\n", | 773 | pr_debug("mpc52xx-psc uart at %p, mapped to %p, irq=%x, freq=%i\n", |
761 | (void*)port->mapbase, port->membase, port->irq, port->uartclk); | 774 | (void *)port->mapbase, port->membase, |
775 | port->irq, port->uartclk); | ||
762 | 776 | ||
763 | /* Setup the port parameters accoding to options */ | 777 | /* Setup the port parameters accoding to options */ |
764 | if (options) | 778 | if (options) |
@@ -767,7 +781,7 @@ mpc52xx_console_setup(struct console *co, char *options) | |||
767 | mpc52xx_console_get_options(port, &baud, &parity, &bits, &flow); | 781 | mpc52xx_console_get_options(port, &baud, &parity, &bits, &flow); |
768 | 782 | ||
769 | pr_debug("Setting console parameters: %i %i%c1 flow=%c\n", | 783 | pr_debug("Setting console parameters: %i %i%c1 flow=%c\n", |
770 | baud, bits, parity, flow); | 784 | baud, bits, parity, flow); |
771 | 785 | ||
772 | return uart_set_options(port, co, baud, parity, bits, flow); | 786 | return uart_set_options(port, co, baud, parity, bits, flow); |
773 | } | 787 | } |
@@ -782,7 +796,7 @@ static struct console mpc52xx_console = { | |||
782 | .device = uart_console_device, | 796 | .device = uart_console_device, |
783 | .setup = mpc52xx_console_setup, | 797 | .setup = mpc52xx_console_setup, |
784 | .flags = CON_PRINTBUFFER, | 798 | .flags = CON_PRINTBUFFER, |
785 | .index = -1, /* Specified on the cmdline (e.g. console=ttyPSC0 ) */ | 799 | .index = -1, /* Specified on the cmdline (e.g. console=ttyPSC0) */ |
786 | .data = &mpc52xx_uart_driver, | 800 | .data = &mpc52xx_uart_driver, |
787 | }; | 801 | }; |
788 | 802 | ||
@@ -810,7 +824,6 @@ console_initcall(mpc52xx_console_init); | |||
810 | /* ======================================================================== */ | 824 | /* ======================================================================== */ |
811 | 825 | ||
812 | static struct uart_driver mpc52xx_uart_driver = { | 826 | static struct uart_driver mpc52xx_uart_driver = { |
813 | .owner = THIS_MODULE, | ||
814 | .driver_name = "mpc52xx_psc_uart", | 827 | .driver_name = "mpc52xx_psc_uart", |
815 | .dev_name = "ttyPSC", | 828 | .dev_name = "ttyPSC", |
816 | .major = SERIAL_PSC_MAJOR, | 829 | .major = SERIAL_PSC_MAJOR, |
@@ -838,7 +851,7 @@ mpc52xx_uart_probe(struct platform_device *dev) | |||
838 | if (idx < 0 || idx >= MPC52xx_PSC_MAXNUM) | 851 | if (idx < 0 || idx >= MPC52xx_PSC_MAXNUM) |
839 | return -EINVAL; | 852 | return -EINVAL; |
840 | 853 | ||
841 | if (!mpc52xx_match_psc_function(idx,"uart")) | 854 | if (!mpc52xx_match_psc_function(idx, "uart")) |
842 | return -ENODEV; | 855 | return -ENODEV; |
843 | 856 | ||
844 | /* Init the port structure */ | 857 | /* Init the port structure */ |
@@ -849,13 +862,13 @@ mpc52xx_uart_probe(struct platform_device *dev) | |||
849 | port->fifosize = 512; | 862 | port->fifosize = 512; |
850 | port->iotype = UPIO_MEM; | 863 | port->iotype = UPIO_MEM; |
851 | port->flags = UPF_BOOT_AUTOCONF | | 864 | port->flags = UPF_BOOT_AUTOCONF | |
852 | ( uart_console(port) ? 0 : UPF_IOREMAP ); | 865 | (uart_console(port) ? 0 : UPF_IOREMAP); |
853 | port->line = idx; | 866 | port->line = idx; |
854 | port->ops = &mpc52xx_uart_ops; | 867 | port->ops = &mpc52xx_uart_ops; |
855 | port->dev = &dev->dev; | 868 | port->dev = &dev->dev; |
856 | 869 | ||
857 | /* Search for IRQ and mapbase */ | 870 | /* Search for IRQ and mapbase */ |
858 | for (i=0 ; i<dev->num_resources ; i++, res++) { | 871 | for (i = 0 ; i < dev->num_resources ; i++, res++) { |
859 | if (res->flags & IORESOURCE_MEM) | 872 | if (res->flags & IORESOURCE_MEM) |
860 | port->mapbase = res->start; | 873 | port->mapbase = res->start; |
861 | else if (res->flags & IORESOURCE_IRQ) | 874 | else if (res->flags & IORESOURCE_IRQ) |
@@ -867,7 +880,7 @@ mpc52xx_uart_probe(struct platform_device *dev) | |||
867 | /* Add the port to the uart sub-system */ | 880 | /* Add the port to the uart sub-system */ |
868 | ret = uart_add_one_port(&mpc52xx_uart_driver, port); | 881 | ret = uart_add_one_port(&mpc52xx_uart_driver, port); |
869 | if (!ret) | 882 | if (!ret) |
870 | platform_set_drvdata(dev, (void*)port); | 883 | platform_set_drvdata(dev, (void *)port); |
871 | 884 | ||
872 | return ret; | 885 | return ret; |
873 | } | 886 | } |
@@ -918,6 +931,7 @@ static struct platform_driver mpc52xx_uart_platform_driver = { | |||
918 | .resume = mpc52xx_uart_resume, | 931 | .resume = mpc52xx_uart_resume, |
919 | #endif | 932 | #endif |
920 | .driver = { | 933 | .driver = { |
934 | .owner = THIS_MODULE, | ||
921 | .name = "mpc52xx-psc", | 935 | .name = "mpc52xx-psc", |
922 | }, | 936 | }, |
923 | }; | 937 | }; |
@@ -947,10 +961,11 @@ mpc52xx_uart_of_probe(struct of_device *op, const struct of_device_id *match) | |||
947 | if (idx >= MPC52xx_PSC_MAXNUM) | 961 | if (idx >= MPC52xx_PSC_MAXNUM) |
948 | return -EINVAL; | 962 | return -EINVAL; |
949 | pr_debug("Found %s assigned to ttyPSC%x\n", | 963 | pr_debug("Found %s assigned to ttyPSC%x\n", |
950 | mpc52xx_uart_nodes[idx]->full_name, idx); | 964 | mpc52xx_uart_nodes[idx]->full_name, idx); |
951 | 965 | ||
952 | /* Search for bus-frequency property in this node or a parent */ | 966 | /* Search for bus-frequency property in this node or a parent */ |
953 | if ((ipb_freq = mpc52xx_find_ipb_freq(op->node)) == 0) { | 967 | ipb_freq = mpc52xx_find_ipb_freq(op->node); |
968 | if (ipb_freq == 0) { | ||
954 | dev_dbg(&op->dev, "Could not find IPB bus frequency!\n"); | 969 | dev_dbg(&op->dev, "Could not find IPB bus frequency!\n"); |
955 | return -EINVAL; | 970 | return -EINVAL; |
956 | } | 971 | } |
@@ -963,22 +978,23 @@ mpc52xx_uart_of_probe(struct of_device *op, const struct of_device_id *match) | |||
963 | port->fifosize = 512; | 978 | port->fifosize = 512; |
964 | port->iotype = UPIO_MEM; | 979 | port->iotype = UPIO_MEM; |
965 | port->flags = UPF_BOOT_AUTOCONF | | 980 | port->flags = UPF_BOOT_AUTOCONF | |
966 | ( uart_console(port) ? 0 : UPF_IOREMAP ); | 981 | (uart_console(port) ? 0 : UPF_IOREMAP); |
967 | port->line = idx; | 982 | port->line = idx; |
968 | port->ops = &mpc52xx_uart_ops; | 983 | port->ops = &mpc52xx_uart_ops; |
969 | port->dev = &op->dev; | 984 | port->dev = &op->dev; |
970 | 985 | ||
971 | /* Search for IRQ and mapbase */ | 986 | /* Search for IRQ and mapbase */ |
972 | if ((ret = of_address_to_resource(op->node, 0, &res)) != 0) | 987 | ret = of_address_to_resource(op->node, 0, &res); |
988 | if (ret) | ||
973 | return ret; | 989 | return ret; |
974 | 990 | ||
975 | port->mapbase = res.start; | 991 | port->mapbase = res.start; |
976 | port->irq = irq_of_parse_and_map(op->node, 0); | 992 | port->irq = irq_of_parse_and_map(op->node, 0); |
977 | 993 | ||
978 | dev_dbg(&op->dev, "mpc52xx-psc uart at %p, irq=%x, freq=%i\n", | 994 | dev_dbg(&op->dev, "mpc52xx-psc uart at %p, irq=%x, freq=%i\n", |
979 | (void*)port->mapbase, port->irq, port->uartclk); | 995 | (void *)port->mapbase, port->irq, port->uartclk); |
980 | 996 | ||
981 | if ((port->irq==NO_IRQ) || !port->mapbase) { | 997 | if ((port->irq == NO_IRQ) || !port->mapbase) { |
982 | printk(KERN_ERR "Could not allocate resources for PSC\n"); | 998 | printk(KERN_ERR "Could not allocate resources for PSC\n"); |
983 | return -EINVAL; | 999 | return -EINVAL; |
984 | } | 1000 | } |
@@ -986,7 +1002,7 @@ mpc52xx_uart_of_probe(struct of_device *op, const struct of_device_id *match) | |||
986 | /* Add the port to the uart sub-system */ | 1002 | /* Add the port to the uart sub-system */ |
987 | ret = uart_add_one_port(&mpc52xx_uart_driver, port); | 1003 | ret = uart_add_one_port(&mpc52xx_uart_driver, port); |
988 | if (!ret) | 1004 | if (!ret) |
989 | dev_set_drvdata(&op->dev, (void*)port); | 1005 | dev_set_drvdata(&op->dev, (void *)port); |
990 | 1006 | ||
991 | return ret; | 1007 | return ret; |
992 | } | 1008 | } |
@@ -1049,6 +1065,7 @@ mpc52xx_uart_of_assign(struct device_node *np, int idx) | |||
1049 | if (idx < 0) | 1065 | if (idx < 0) |
1050 | return; /* No free slot; abort */ | 1066 | return; /* No free slot; abort */ |
1051 | 1067 | ||
1068 | of_node_get(np); | ||
1052 | /* If the slot is already occupied, then swap slots */ | 1069 | /* If the slot is already occupied, then swap slots */ |
1053 | if (mpc52xx_uart_nodes[idx] && (free_idx != -1)) | 1070 | if (mpc52xx_uart_nodes[idx] && (free_idx != -1)) |
1054 | mpc52xx_uart_nodes[free_idx] = mpc52xx_uart_nodes[idx]; | 1071 | mpc52xx_uart_nodes[free_idx] = mpc52xx_uart_nodes[idx]; |
@@ -1058,7 +1075,7 @@ mpc52xx_uart_of_assign(struct device_node *np, int idx) | |||
1058 | static void | 1075 | static void |
1059 | mpc52xx_uart_of_enumerate(void) | 1076 | mpc52xx_uart_of_enumerate(void) |
1060 | { | 1077 | { |
1061 | static int enum_done = 0; | 1078 | static int enum_done; |
1062 | struct device_node *np; | 1079 | struct device_node *np; |
1063 | const unsigned int *devno; | 1080 | const unsigned int *devno; |
1064 | int i; | 1081 | int i; |
@@ -1072,7 +1089,7 @@ mpc52xx_uart_of_enumerate(void) | |||
1072 | 1089 | ||
1073 | /* Is a particular device number requested? */ | 1090 | /* Is a particular device number requested? */ |
1074 | devno = of_get_property(np, "port-number", NULL); | 1091 | devno = of_get_property(np, "port-number", NULL); |
1075 | mpc52xx_uart_of_assign(of_node_get(np), devno ? *devno : -1); | 1092 | mpc52xx_uart_of_assign(np, devno ? *devno : -1); |
1076 | } | 1093 | } |
1077 | 1094 | ||
1078 | enum_done = 1; | 1095 | enum_done = 1; |
@@ -1080,15 +1097,13 @@ mpc52xx_uart_of_enumerate(void) | |||
1080 | for (i = 0; i < MPC52xx_PSC_MAXNUM; i++) { | 1097 | for (i = 0; i < MPC52xx_PSC_MAXNUM; i++) { |
1081 | if (mpc52xx_uart_nodes[i]) | 1098 | if (mpc52xx_uart_nodes[i]) |
1082 | pr_debug("%s assigned to ttyPSC%x\n", | 1099 | pr_debug("%s assigned to ttyPSC%x\n", |
1083 | mpc52xx_uart_nodes[i]->full_name, i); | 1100 | mpc52xx_uart_nodes[i]->full_name, i); |
1084 | } | 1101 | } |
1085 | } | 1102 | } |
1086 | 1103 | ||
1087 | MODULE_DEVICE_TABLE(of, mpc52xx_uart_of_match); | 1104 | MODULE_DEVICE_TABLE(of, mpc52xx_uart_of_match); |
1088 | 1105 | ||
1089 | static struct of_platform_driver mpc52xx_uart_of_driver = { | 1106 | static struct of_platform_driver mpc52xx_uart_of_driver = { |
1090 | .owner = THIS_MODULE, | ||
1091 | .name = "mpc52xx-psc-uart", | ||
1092 | .match_table = mpc52xx_uart_of_match, | 1107 | .match_table = mpc52xx_uart_of_match, |
1093 | .probe = mpc52xx_uart_of_probe, | 1108 | .probe = mpc52xx_uart_of_probe, |
1094 | .remove = mpc52xx_uart_of_remove, | 1109 | .remove = mpc52xx_uart_of_remove, |
@@ -1114,7 +1129,8 @@ mpc52xx_uart_init(void) | |||
1114 | 1129 | ||
1115 | printk(KERN_INFO "Serial: MPC52xx PSC UART driver\n"); | 1130 | printk(KERN_INFO "Serial: MPC52xx PSC UART driver\n"); |
1116 | 1131 | ||
1117 | if ((ret = uart_register_driver(&mpc52xx_uart_driver)) != 0) { | 1132 | ret = uart_register_driver(&mpc52xx_uart_driver); |
1133 | if (ret) { | ||
1118 | printk(KERN_ERR "%s: uart_register_driver failed (%i)\n", | 1134 | printk(KERN_ERR "%s: uart_register_driver failed (%i)\n", |
1119 | __FILE__, ret); | 1135 | __FILE__, ret); |
1120 | return ret; | 1136 | return ret; |
diff --git a/drivers/serial/suncore.c b/drivers/serial/suncore.c index 707c5b03bce9..a2d4a19550ab 100644 --- a/drivers/serial/suncore.c +++ b/drivers/serial/suncore.c | |||
@@ -52,7 +52,7 @@ void sunserial_unregister_minors(struct uart_driver *drv, int count) | |||
52 | } | 52 | } |
53 | EXPORT_SYMBOL(sunserial_unregister_minors); | 53 | EXPORT_SYMBOL(sunserial_unregister_minors); |
54 | 54 | ||
55 | int __init sunserial_console_match(struct console *con, struct device_node *dp, | 55 | int sunserial_console_match(struct console *con, struct device_node *dp, |
56 | struct uart_driver *drv, int line) | 56 | struct uart_driver *drv, int line) |
57 | { | 57 | { |
58 | int off; | 58 | int off; |