diff options
author | John Rigby <jrigby@freescale.com> | 2008-01-16 16:37:25 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2008-01-21 13:01:33 -0500 |
commit | 406b7d4f7b6b4a19dadaaad0744466013afe59b8 (patch) | |
tree | 21fd1b5bde0d4a8697b0418412fb30994488bf10 /drivers/serial | |
parent | 94f389485e27641348c1951ab8d65157122a8939 (diff) |
[POWERPC] mpc5200: Cleanup checkpatch.pl problems in mpc52xx_uart.c
In preparation of adding MPC5121 support
cleanup some things that checkpatch.pl complains
about also some minor fixes suggested by
Stephen Rothwell.
Signed-off-by: John Rigby <jrigby@freescale.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/serial')
-rw-r--r-- | drivers/serial/mpc52xx_uart.c | 200 |
1 files changed, 107 insertions, 93 deletions
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c index 141b8da7e0e7..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> |
@@ -116,13 +116,14 @@ static void mpc52xx_uart_of_enumerate(void); | |||
116 | 116 | ||
117 | 117 | ||
118 | /* Forward declaration of the interruption handling routine */ | 118 | /* Forward declaration of the interruption handling routine */ |
119 | static irqreturn_t mpc52xx_uart_int(int irq,void *dev_id); | 119 | static irqreturn_t mpc52xx_uart_int(int irq, void *dev_id); |
120 | 120 | ||
121 | 121 | ||
122 | /* 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 |
123 | * 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 ? */ |
124 | #ifdef CONFIG_SERIAL_CORE_CONSOLE | 124 | #ifdef CONFIG_SERIAL_CORE_CONSOLE |
125 | #define uart_console(port) ((port)->cons && (port)->cons->index == (port)->line) | 125 | #define uart_console(port) \ |
126 | ((port)->cons && (port)->cons->index == (port)->line) | ||
126 | #else | 127 | #else |
127 | #define uart_console(port) (0) | 128 | #define uart_console(port) (0) |
128 | #endif | 129 | #endif |
@@ -164,7 +165,7 @@ mpc52xx_uart_stop_tx(struct uart_port *port) | |||
164 | { | 165 | { |
165 | /* port->lock taken by caller */ | 166 | /* port->lock taken by caller */ |
166 | port->read_status_mask &= ~MPC52xx_PSC_IMR_TXRDY; | 167 | port->read_status_mask &= ~MPC52xx_PSC_IMR_TXRDY; |
167 | out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask); | 168 | out_be16(&PSC(port)->mpc52xx_psc_imr, port->read_status_mask); |
168 | } | 169 | } |
169 | 170 | ||
170 | static void | 171 | static void |
@@ -172,7 +173,7 @@ mpc52xx_uart_start_tx(struct uart_port *port) | |||
172 | { | 173 | { |
173 | /* port->lock taken by caller */ | 174 | /* port->lock taken by caller */ |
174 | port->read_status_mask |= MPC52xx_PSC_IMR_TXRDY; | 175 | port->read_status_mask |= MPC52xx_PSC_IMR_TXRDY; |
175 | out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask); | 176 | out_be16(&PSC(port)->mpc52xx_psc_imr, port->read_status_mask); |
176 | } | 177 | } |
177 | 178 | ||
178 | static void | 179 | static void |
@@ -186,7 +187,7 @@ mpc52xx_uart_send_xchar(struct uart_port *port, char ch) | |||
186 | /* Make sure tx interrupts are on */ | 187 | /* Make sure tx interrupts are on */ |
187 | /* Truly necessary ??? They should be anyway */ | 188 | /* Truly necessary ??? They should be anyway */ |
188 | port->read_status_mask |= MPC52xx_PSC_IMR_TXRDY; | 189 | port->read_status_mask |= MPC52xx_PSC_IMR_TXRDY; |
189 | out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask); | 190 | out_be16(&PSC(port)->mpc52xx_psc_imr, port->read_status_mask); |
190 | } | 191 | } |
191 | 192 | ||
192 | spin_unlock_irqrestore(&port->lock, flags); | 193 | spin_unlock_irqrestore(&port->lock, flags); |
@@ -197,7 +198,7 @@ mpc52xx_uart_stop_rx(struct uart_port *port) | |||
197 | { | 198 | { |
198 | /* port->lock taken by caller */ | 199 | /* port->lock taken by caller */ |
199 | port->read_status_mask &= ~MPC52xx_PSC_IMR_RXRDY; | 200 | port->read_status_mask &= ~MPC52xx_PSC_IMR_RXRDY; |
200 | out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask); | 201 | out_be16(&PSC(port)->mpc52xx_psc_imr, port->read_status_mask); |
201 | } | 202 | } |
202 | 203 | ||
203 | static void | 204 | static void |
@@ -212,10 +213,10 @@ mpc52xx_uart_break_ctl(struct uart_port *port, int ctl) | |||
212 | unsigned long flags; | 213 | unsigned long flags; |
213 | spin_lock_irqsave(&port->lock, flags); | 214 | spin_lock_irqsave(&port->lock, flags); |
214 | 215 | ||
215 | if ( ctl == -1 ) | 216 | if (ctl == -1) |
216 | out_8(&PSC(port)->command,MPC52xx_PSC_START_BRK); | 217 | out_8(&PSC(port)->command, MPC52xx_PSC_START_BRK); |
217 | else | 218 | else |
218 | out_8(&PSC(port)->command,MPC52xx_PSC_STOP_BRK); | 219 | out_8(&PSC(port)->command, MPC52xx_PSC_STOP_BRK); |
219 | 220 | ||
220 | spin_unlock_irqrestore(&port->lock, flags); | 221 | spin_unlock_irqrestore(&port->lock, flags); |
221 | } | 222 | } |
@@ -234,10 +235,10 @@ mpc52xx_uart_startup(struct uart_port *port) | |||
234 | return ret; | 235 | return ret; |
235 | 236 | ||
236 | /* Reset/activate the port, clear and enable interrupts */ | 237 | /* Reset/activate the port, clear and enable interrupts */ |
237 | out_8(&psc->command,MPC52xx_PSC_RST_RX); | 238 | out_8(&psc->command, MPC52xx_PSC_RST_RX); |
238 | out_8(&psc->command,MPC52xx_PSC_RST_TX); | 239 | out_8(&psc->command, MPC52xx_PSC_RST_TX); |
239 | 240 | ||
240 | out_be32(&psc->sicr,0); /* UART mode DCD ignored */ | 241 | out_be32(&psc->sicr, 0); /* UART mode DCD ignored */ |
241 | 242 | ||
242 | out_be16(&psc->mpc52xx_psc_clock_select, 0xdd00); /* /16 prescaler on */ | 243 | out_be16(&psc->mpc52xx_psc_clock_select, 0xdd00); /* /16 prescaler on */ |
243 | 244 | ||
@@ -247,10 +248,10 @@ mpc52xx_uart_startup(struct uart_port *port) | |||
247 | out_be16(&fifo->tfalarm, 0x80); | 248 | out_be16(&fifo->tfalarm, 0x80); |
248 | 249 | ||
249 | 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; |
250 | out_be16(&psc->mpc52xx_psc_imr,port->read_status_mask); | 251 | out_be16(&psc->mpc52xx_psc_imr, port->read_status_mask); |
251 | 252 | ||
252 | out_8(&psc->command,MPC52xx_PSC_TX_ENABLE); | 253 | out_8(&psc->command, MPC52xx_PSC_TX_ENABLE); |
253 | out_8(&psc->command,MPC52xx_PSC_RX_ENABLE); | 254 | out_8(&psc->command, MPC52xx_PSC_RX_ENABLE); |
254 | 255 | ||
255 | return 0; | 256 | return 0; |
256 | } | 257 | } |
@@ -261,12 +262,12 @@ mpc52xx_uart_shutdown(struct uart_port *port) | |||
261 | struct mpc52xx_psc __iomem *psc = PSC(port); | 262 | struct mpc52xx_psc __iomem *psc = PSC(port); |
262 | 263 | ||
263 | /* 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 */ |
264 | out_8(&psc->command,MPC52xx_PSC_RST_RX); | 265 | out_8(&psc->command, MPC52xx_PSC_RST_RX); |
265 | if (!uart_console(port)) | 266 | if (!uart_console(port)) |
266 | out_8(&psc->command,MPC52xx_PSC_RST_TX); | 267 | out_8(&psc->command, MPC52xx_PSC_RST_TX); |
267 | 268 | ||
268 | port->read_status_mask = 0; | 269 | port->read_status_mask = 0; |
269 | out_be16(&psc->mpc52xx_psc_imr,port->read_status_mask); | 270 | out_be16(&psc->mpc52xx_psc_imr, port->read_status_mask); |
270 | 271 | ||
271 | /* Release interrupt */ | 272 | /* Release interrupt */ |
272 | free_irq(port->irq, port); | 273 | free_irq(port->irq, port); |
@@ -274,7 +275,7 @@ mpc52xx_uart_shutdown(struct uart_port *port) | |||
274 | 275 | ||
275 | static void | 276 | static void |
276 | mpc52xx_uart_set_termios(struct uart_port *port, struct ktermios *new, | 277 | mpc52xx_uart_set_termios(struct uart_port *port, struct ktermios *new, |
277 | struct ktermios *old) | 278 | struct ktermios *old) |
278 | { | 279 | { |
279 | struct mpc52xx_psc __iomem *psc = PSC(port); | 280 | struct mpc52xx_psc __iomem *psc = PSC(port); |
280 | unsigned long flags; | 281 | unsigned long flags; |
@@ -286,14 +287,14 @@ mpc52xx_uart_set_termios(struct uart_port *port, struct ktermios *new, | |||
286 | mr1 = 0; | 287 | mr1 = 0; |
287 | 288 | ||
288 | switch (new->c_cflag & CSIZE) { | 289 | switch (new->c_cflag & CSIZE) { |
289 | case CS5: mr1 |= MPC52xx_PSC_MODE_5_BITS; | 290 | case CS5: mr1 |= MPC52xx_PSC_MODE_5_BITS; |
290 | break; | 291 | break; |
291 | case CS6: mr1 |= MPC52xx_PSC_MODE_6_BITS; | 292 | case CS6: mr1 |= MPC52xx_PSC_MODE_6_BITS; |
292 | break; | 293 | break; |
293 | case CS7: mr1 |= MPC52xx_PSC_MODE_7_BITS; | 294 | case CS7: mr1 |= MPC52xx_PSC_MODE_7_BITS; |
294 | break; | 295 | break; |
295 | case CS8: | 296 | case CS8: |
296 | default: mr1 |= MPC52xx_PSC_MODE_8_BITS; | 297 | default: mr1 |= MPC52xx_PSC_MODE_8_BITS; |
297 | } | 298 | } |
298 | 299 | ||
299 | if (new->c_cflag & PARENB) { | 300 | if (new->c_cflag & PARENB) { |
@@ -335,24 +336,24 @@ mpc52xx_uart_set_termios(struct uart_port *port, struct ktermios *new, | |||
335 | udelay(1); | 336 | udelay(1); |
336 | 337 | ||
337 | if (!j) | 338 | if (!j) |
338 | printk( KERN_ERR "mpc52xx_uart.c: " | 339 | printk(KERN_ERR "mpc52xx_uart.c: " |
339 | "Unable to flush RX & TX fifos in-time in set_termios." | 340 | "Unable to flush RX & TX fifos in-time in set_termios." |
340 | "Some chars may have been lost.\n" ); | 341 | "Some chars may have been lost.\n"); |
341 | 342 | ||
342 | /* Reset the TX & RX */ | 343 | /* Reset the TX & RX */ |
343 | out_8(&psc->command,MPC52xx_PSC_RST_RX); | 344 | out_8(&psc->command, MPC52xx_PSC_RST_RX); |
344 | out_8(&psc->command,MPC52xx_PSC_RST_TX); | 345 | out_8(&psc->command, MPC52xx_PSC_RST_TX); |
345 | 346 | ||
346 | /* Send new mode settings */ | 347 | /* Send new mode settings */ |
347 | out_8(&psc->command,MPC52xx_PSC_SEL_MODE_REG_1); | 348 | out_8(&psc->command, MPC52xx_PSC_SEL_MODE_REG_1); |
348 | out_8(&psc->mode,mr1); | 349 | out_8(&psc->mode, mr1); |
349 | out_8(&psc->mode,mr2); | 350 | out_8(&psc->mode, mr2); |
350 | out_8(&psc->ctur,ctr >> 8); | 351 | out_8(&psc->ctur, ctr >> 8); |
351 | out_8(&psc->ctlr,ctr & 0xff); | 352 | out_8(&psc->ctlr, ctr & 0xff); |
352 | 353 | ||
353 | /* Reenable TX & RX */ | 354 | /* Reenable TX & RX */ |
354 | out_8(&psc->command,MPC52xx_PSC_TX_ENABLE); | 355 | out_8(&psc->command, MPC52xx_PSC_TX_ENABLE); |
355 | out_8(&psc->command,MPC52xx_PSC_RX_ENABLE); | 356 | out_8(&psc->command, MPC52xx_PSC_RX_ENABLE); |
356 | 357 | ||
357 | /* We're all set, release the lock */ | 358 | /* We're all set, release the lock */ |
358 | spin_unlock_irqrestore(&port->lock, flags); | 359 | spin_unlock_irqrestore(&port->lock, flags); |
@@ -367,7 +368,8 @@ mpc52xx_uart_type(struct uart_port *port) | |||
367 | static void | 368 | static void |
368 | mpc52xx_uart_release_port(struct uart_port *port) | 369 | mpc52xx_uart_release_port(struct uart_port *port) |
369 | { | 370 | { |
370 | if (port->flags & UPF_IOREMAP) { /* remapped by us ? */ | 371 | /* remapped by us ? */ |
372 | if (port->flags & UPF_IOREMAP) { | ||
371 | iounmap(port->membase); | 373 | iounmap(port->membase); |
372 | port->membase = NULL; | 374 | port->membase = NULL; |
373 | } | 375 | } |
@@ -382,7 +384,7 @@ mpc52xx_uart_request_port(struct uart_port *port) | |||
382 | 384 | ||
383 | if (port->flags & UPF_IOREMAP) /* Need to remap ? */ | 385 | if (port->flags & UPF_IOREMAP) /* Need to remap ? */ |
384 | port->membase = ioremap(port->mapbase, | 386 | port->membase = ioremap(port->mapbase, |
385 | sizeof(struct mpc52xx_psc)); | 387 | sizeof(struct mpc52xx_psc)); |
386 | 388 | ||
387 | if (!port->membase) | 389 | if (!port->membase) |
388 | return -EINVAL; | 390 | return -EINVAL; |
@@ -401,22 +403,22 @@ mpc52xx_uart_request_port(struct uart_port *port) | |||
401 | static void | 403 | static void |
402 | mpc52xx_uart_config_port(struct uart_port *port, int flags) | 404 | mpc52xx_uart_config_port(struct uart_port *port, int flags) |
403 | { | 405 | { |
404 | if ( (flags & UART_CONFIG_TYPE) && | 406 | if ((flags & UART_CONFIG_TYPE) |
405 | (mpc52xx_uart_request_port(port) == 0) ) | 407 | && (mpc52xx_uart_request_port(port) == 0)) |
406 | port->type = PORT_MPC52xx; | 408 | port->type = PORT_MPC52xx; |
407 | } | 409 | } |
408 | 410 | ||
409 | static int | 411 | static int |
410 | 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) |
411 | { | 413 | { |
412 | if ( ser->type != PORT_UNKNOWN && ser->type != PORT_MPC52xx ) | 414 | if (ser->type != PORT_UNKNOWN && ser->type != PORT_MPC52xx) |
413 | return -EINVAL; | 415 | return -EINVAL; |
414 | 416 | ||
415 | if ( (ser->irq != port->irq) || | 417 | if ((ser->irq != port->irq) || |
416 | (ser->io_type != SERIAL_IO_MEM) || | 418 | (ser->io_type != SERIAL_IO_MEM) || |
417 | (ser->baud_base != port->uartclk) || | 419 | (ser->baud_base != port->uartclk) || |
418 | (ser->iomem_base != (void*)port->mapbase) || | 420 | (ser->iomem_base != (void *)port->mapbase) || |
419 | (ser->hub6 != 0 ) ) | 421 | (ser->hub6 != 0)) |
420 | return -EINVAL; | 422 | return -EINVAL; |
421 | 423 | ||
422 | return 0; | 424 | return 0; |
@@ -458,8 +460,8 @@ mpc52xx_uart_int_rx_chars(struct uart_port *port) | |||
458 | unsigned short status; | 460 | unsigned short status; |
459 | 461 | ||
460 | /* While we can read, do so ! */ | 462 | /* While we can read, do so ! */ |
461 | while ( (status = in_be16(&PSC(port)->mpc52xx_psc_status)) & | 463 | while ((status = in_be16(&PSC(port)->mpc52xx_psc_status)) & |
462 | MPC52xx_PSC_SR_RXRDY) { | 464 | MPC52xx_PSC_SR_RXRDY) { |
463 | 465 | ||
464 | /* Get the char */ | 466 | /* Get the char */ |
465 | ch = in_8(&PSC(port)->mpc52xx_psc_buffer_8); | 467 | ch = in_8(&PSC(port)->mpc52xx_psc_buffer_8); |
@@ -477,9 +479,9 @@ mpc52xx_uart_int_rx_chars(struct uart_port *port) | |||
477 | flag = TTY_NORMAL; | 479 | flag = TTY_NORMAL; |
478 | port->icount.rx++; | 480 | port->icount.rx++; |
479 | 481 | ||
480 | if ( status & (MPC52xx_PSC_SR_PE | | 482 | if (status & (MPC52xx_PSC_SR_PE | |
481 | MPC52xx_PSC_SR_FE | | 483 | MPC52xx_PSC_SR_FE | |
482 | MPC52xx_PSC_SR_RB) ) { | 484 | MPC52xx_PSC_SR_RB)) { |
483 | 485 | ||
484 | if (status & MPC52xx_PSC_SR_RB) { | 486 | if (status & MPC52xx_PSC_SR_RB) { |
485 | flag = TTY_BREAK; | 487 | flag = TTY_BREAK; |
@@ -490,7 +492,7 @@ mpc52xx_uart_int_rx_chars(struct uart_port *port) | |||
490 | flag = TTY_FRAME; | 492 | flag = TTY_FRAME; |
491 | 493 | ||
492 | /* Clear error condition */ | 494 | /* Clear error condition */ |
493 | out_8(&PSC(port)->command,MPC52xx_PSC_RST_ERR_STAT); | 495 | out_8(&PSC(port)->command, MPC52xx_PSC_RST_ERR_STAT); |
494 | 496 | ||
495 | } | 497 | } |
496 | tty_insert_flip_char(tty, ch, flag); | 498 | tty_insert_flip_char(tty, ch, flag); |
@@ -571,16 +573,16 @@ mpc52xx_uart_int(int irq, void *dev_id) | |||
571 | 573 | ||
572 | /* Do we need to receive chars ? */ | 574 | /* Do we need to receive chars ? */ |
573 | /* For this RX interrupts must be on and some chars waiting */ | 575 | /* For this RX interrupts must be on and some chars waiting */ |
574 | if ( status & MPC52xx_PSC_IMR_RXRDY ) | 576 | if (status & MPC52xx_PSC_IMR_RXRDY) |
575 | keepgoing |= mpc52xx_uart_int_rx_chars(port); | 577 | keepgoing |= mpc52xx_uart_int_rx_chars(port); |
576 | 578 | ||
577 | /* Do we need to send chars ? */ | 579 | /* Do we need to send chars ? */ |
578 | /* For this, TX must be ready and TX interrupt enabled */ | 580 | /* For this, TX must be ready and TX interrupt enabled */ |
579 | if ( status & MPC52xx_PSC_IMR_TXRDY ) | 581 | if (status & MPC52xx_PSC_IMR_TXRDY) |
580 | keepgoing |= mpc52xx_uart_int_tx_chars(port); | 582 | keepgoing |= mpc52xx_uart_int_tx_chars(port); |
581 | 583 | ||
582 | /* Limit number of iteration */ | 584 | /* Limit number of iteration */ |
583 | if ( !(--pass) ) | 585 | if (!(--pass)) |
584 | keepgoing = 0; | 586 | keepgoing = 0; |
585 | 587 | ||
586 | } while (keepgoing); | 588 | } while (keepgoing); |
@@ -599,7 +601,7 @@ mpc52xx_uart_int(int irq, void *dev_id) | |||
599 | 601 | ||
600 | static void __init | 602 | static void __init |
601 | mpc52xx_console_get_options(struct uart_port *port, | 603 | mpc52xx_console_get_options(struct uart_port *port, |
602 | int *baud, int *parity, int *bits, int *flow) | 604 | int *baud, int *parity, int *bits, int *flow) |
603 | { | 605 | { |
604 | struct mpc52xx_psc __iomem *psc = PSC(port); | 606 | struct mpc52xx_psc __iomem *psc = PSC(port); |
605 | unsigned char mr1; | 607 | unsigned char mr1; |
@@ -607,7 +609,7 @@ mpc52xx_console_get_options(struct uart_port *port, | |||
607 | pr_debug("mpc52xx_console_get_options(port=%p)\n", port); | 609 | pr_debug("mpc52xx_console_get_options(port=%p)\n", port); |
608 | 610 | ||
609 | /* Read the mode registers */ | 611 | /* Read the mode registers */ |
610 | out_8(&psc->command,MPC52xx_PSC_SEL_MODE_REG_1); | 612 | out_8(&psc->command, MPC52xx_PSC_SEL_MODE_REG_1); |
611 | mr1 = in_8(&psc->mode); | 613 | mr1 = in_8(&psc->mode); |
612 | 614 | ||
613 | /* CT{U,L}R are write-only ! */ | 615 | /* CT{U,L}R are write-only ! */ |
@@ -619,11 +621,18 @@ mpc52xx_console_get_options(struct uart_port *port, | |||
619 | 621 | ||
620 | /* Parse them */ | 622 | /* Parse them */ |
621 | switch (mr1 & MPC52xx_PSC_MODE_BITS_MASK) { | 623 | switch (mr1 & MPC52xx_PSC_MODE_BITS_MASK) { |
622 | case MPC52xx_PSC_MODE_5_BITS: *bits = 5; break; | 624 | case MPC52xx_PSC_MODE_5_BITS: |
623 | case MPC52xx_PSC_MODE_6_BITS: *bits = 6; break; | 625 | *bits = 5; |
624 | case MPC52xx_PSC_MODE_7_BITS: *bits = 7; break; | 626 | break; |
625 | case MPC52xx_PSC_MODE_8_BITS: | 627 | case MPC52xx_PSC_MODE_6_BITS: |
626 | 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; | ||
627 | } | 636 | } |
628 | 637 | ||
629 | if (mr1 & MPC52xx_PSC_MODE_PARNONE) | 638 | if (mr1 & MPC52xx_PSC_MODE_PARNONE) |
@@ -660,7 +669,7 @@ mpc52xx_console_write(struct console *co, const char *s, unsigned int count) | |||
660 | /* Wait the TX buffer to be empty */ | 669 | /* Wait the TX buffer to be empty */ |
661 | j = 20000; /* Maximum wait */ | 670 | j = 20000; /* Maximum wait */ |
662 | while (!(in_be16(&psc->mpc52xx_psc_status) & | 671 | while (!(in_be16(&psc->mpc52xx_psc_status) & |
663 | MPC52xx_PSC_SR_TXEMP) && --j) | 672 | MPC52xx_PSC_SR_TXEMP) && --j) |
664 | udelay(1); | 673 | udelay(1); |
665 | } | 674 | } |
666 | 675 | ||
@@ -733,16 +742,18 @@ mpc52xx_console_setup(struct console *co, char *options) | |||
733 | } | 742 | } |
734 | 743 | ||
735 | pr_debug("Console on ttyPSC%x is %s\n", | 744 | pr_debug("Console on ttyPSC%x is %s\n", |
736 | co->index, mpc52xx_uart_nodes[co->index]->full_name); | 745 | co->index, mpc52xx_uart_nodes[co->index]->full_name); |
737 | 746 | ||
738 | /* Fetch register locations */ | 747 | /* Fetch register locations */ |
739 | if ((ret = of_address_to_resource(np, 0, &res)) != 0) { | 748 | ret = of_address_to_resource(np, 0, &res); |
749 | if (ret) { | ||
740 | 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); |
741 | return ret; | 751 | return ret; |
742 | } | 752 | } |
743 | 753 | ||
744 | /* Search for bus-frequency property in this node or a parent */ | 754 | /* Search for bus-frequency property in this node or a parent */ |
745 | if ((ipb_freq = mpc52xx_find_ipb_freq(np)) == 0) { | 755 | ipb_freq = mpc52xx_find_ipb_freq(np); |
756 | if (ipb_freq == 0) { | ||
746 | pr_debug("Could not find IPB bus frequency!\n"); | 757 | pr_debug("Could not find IPB bus frequency!\n"); |
747 | return -EINVAL; | 758 | return -EINVAL; |
748 | } | 759 | } |
@@ -760,7 +771,8 @@ mpc52xx_console_setup(struct console *co, char *options) | |||
760 | return -EINVAL; | 771 | return -EINVAL; |
761 | 772 | ||
762 | 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", |
763 | (void*)port->mapbase, port->membase, port->irq, port->uartclk); | 774 | (void *)port->mapbase, port->membase, |
775 | port->irq, port->uartclk); | ||
764 | 776 | ||
765 | /* Setup the port parameters accoding to options */ | 777 | /* Setup the port parameters accoding to options */ |
766 | if (options) | 778 | if (options) |
@@ -769,7 +781,7 @@ mpc52xx_console_setup(struct console *co, char *options) | |||
769 | mpc52xx_console_get_options(port, &baud, &parity, &bits, &flow); | 781 | mpc52xx_console_get_options(port, &baud, &parity, &bits, &flow); |
770 | 782 | ||
771 | pr_debug("Setting console parameters: %i %i%c1 flow=%c\n", | 783 | pr_debug("Setting console parameters: %i %i%c1 flow=%c\n", |
772 | baud, bits, parity, flow); | 784 | baud, bits, parity, flow); |
773 | 785 | ||
774 | return uart_set_options(port, co, baud, parity, bits, flow); | 786 | return uart_set_options(port, co, baud, parity, bits, flow); |
775 | } | 787 | } |
@@ -784,7 +796,7 @@ static struct console mpc52xx_console = { | |||
784 | .device = uart_console_device, | 796 | .device = uart_console_device, |
785 | .setup = mpc52xx_console_setup, | 797 | .setup = mpc52xx_console_setup, |
786 | .flags = CON_PRINTBUFFER, | 798 | .flags = CON_PRINTBUFFER, |
787 | .index = -1, /* Specified on the cmdline (e.g. console=ttyPSC0 ) */ | 799 | .index = -1, /* Specified on the cmdline (e.g. console=ttyPSC0) */ |
788 | .data = &mpc52xx_uart_driver, | 800 | .data = &mpc52xx_uart_driver, |
789 | }; | 801 | }; |
790 | 802 | ||
@@ -812,7 +824,6 @@ console_initcall(mpc52xx_console_init); | |||
812 | /* ======================================================================== */ | 824 | /* ======================================================================== */ |
813 | 825 | ||
814 | static struct uart_driver mpc52xx_uart_driver = { | 826 | static struct uart_driver mpc52xx_uart_driver = { |
815 | .owner = THIS_MODULE, | ||
816 | .driver_name = "mpc52xx_psc_uart", | 827 | .driver_name = "mpc52xx_psc_uart", |
817 | .dev_name = "ttyPSC", | 828 | .dev_name = "ttyPSC", |
818 | .major = SERIAL_PSC_MAJOR, | 829 | .major = SERIAL_PSC_MAJOR, |
@@ -840,7 +851,7 @@ mpc52xx_uart_probe(struct platform_device *dev) | |||
840 | if (idx < 0 || idx >= MPC52xx_PSC_MAXNUM) | 851 | if (idx < 0 || idx >= MPC52xx_PSC_MAXNUM) |
841 | return -EINVAL; | 852 | return -EINVAL; |
842 | 853 | ||
843 | if (!mpc52xx_match_psc_function(idx,"uart")) | 854 | if (!mpc52xx_match_psc_function(idx, "uart")) |
844 | return -ENODEV; | 855 | return -ENODEV; |
845 | 856 | ||
846 | /* Init the port structure */ | 857 | /* Init the port structure */ |
@@ -851,13 +862,13 @@ mpc52xx_uart_probe(struct platform_device *dev) | |||
851 | port->fifosize = 512; | 862 | port->fifosize = 512; |
852 | port->iotype = UPIO_MEM; | 863 | port->iotype = UPIO_MEM; |
853 | port->flags = UPF_BOOT_AUTOCONF | | 864 | port->flags = UPF_BOOT_AUTOCONF | |
854 | ( uart_console(port) ? 0 : UPF_IOREMAP ); | 865 | (uart_console(port) ? 0 : UPF_IOREMAP); |
855 | port->line = idx; | 866 | port->line = idx; |
856 | port->ops = &mpc52xx_uart_ops; | 867 | port->ops = &mpc52xx_uart_ops; |
857 | port->dev = &dev->dev; | 868 | port->dev = &dev->dev; |
858 | 869 | ||
859 | /* Search for IRQ and mapbase */ | 870 | /* Search for IRQ and mapbase */ |
860 | for (i=0 ; i<dev->num_resources ; i++, res++) { | 871 | for (i = 0 ; i < dev->num_resources ; i++, res++) { |
861 | if (res->flags & IORESOURCE_MEM) | 872 | if (res->flags & IORESOURCE_MEM) |
862 | port->mapbase = res->start; | 873 | port->mapbase = res->start; |
863 | else if (res->flags & IORESOURCE_IRQ) | 874 | else if (res->flags & IORESOURCE_IRQ) |
@@ -869,7 +880,7 @@ mpc52xx_uart_probe(struct platform_device *dev) | |||
869 | /* Add the port to the uart sub-system */ | 880 | /* Add the port to the uart sub-system */ |
870 | ret = uart_add_one_port(&mpc52xx_uart_driver, port); | 881 | ret = uart_add_one_port(&mpc52xx_uart_driver, port); |
871 | if (!ret) | 882 | if (!ret) |
872 | platform_set_drvdata(dev, (void*)port); | 883 | platform_set_drvdata(dev, (void *)port); |
873 | 884 | ||
874 | return ret; | 885 | return ret; |
875 | } | 886 | } |
@@ -920,6 +931,7 @@ static struct platform_driver mpc52xx_uart_platform_driver = { | |||
920 | .resume = mpc52xx_uart_resume, | 931 | .resume = mpc52xx_uart_resume, |
921 | #endif | 932 | #endif |
922 | .driver = { | 933 | .driver = { |
934 | .owner = THIS_MODULE, | ||
923 | .name = "mpc52xx-psc", | 935 | .name = "mpc52xx-psc", |
924 | }, | 936 | }, |
925 | }; | 937 | }; |
@@ -949,10 +961,11 @@ mpc52xx_uart_of_probe(struct of_device *op, const struct of_device_id *match) | |||
949 | if (idx >= MPC52xx_PSC_MAXNUM) | 961 | if (idx >= MPC52xx_PSC_MAXNUM) |
950 | return -EINVAL; | 962 | return -EINVAL; |
951 | pr_debug("Found %s assigned to ttyPSC%x\n", | 963 | pr_debug("Found %s assigned to ttyPSC%x\n", |
952 | mpc52xx_uart_nodes[idx]->full_name, idx); | 964 | mpc52xx_uart_nodes[idx]->full_name, idx); |
953 | 965 | ||
954 | /* Search for bus-frequency property in this node or a parent */ | 966 | /* Search for bus-frequency property in this node or a parent */ |
955 | if ((ipb_freq = mpc52xx_find_ipb_freq(op->node)) == 0) { | 967 | ipb_freq = mpc52xx_find_ipb_freq(op->node); |
968 | if (ipb_freq == 0) { | ||
956 | dev_dbg(&op->dev, "Could not find IPB bus frequency!\n"); | 969 | dev_dbg(&op->dev, "Could not find IPB bus frequency!\n"); |
957 | return -EINVAL; | 970 | return -EINVAL; |
958 | } | 971 | } |
@@ -965,22 +978,23 @@ mpc52xx_uart_of_probe(struct of_device *op, const struct of_device_id *match) | |||
965 | port->fifosize = 512; | 978 | port->fifosize = 512; |
966 | port->iotype = UPIO_MEM; | 979 | port->iotype = UPIO_MEM; |
967 | port->flags = UPF_BOOT_AUTOCONF | | 980 | port->flags = UPF_BOOT_AUTOCONF | |
968 | ( uart_console(port) ? 0 : UPF_IOREMAP ); | 981 | (uart_console(port) ? 0 : UPF_IOREMAP); |
969 | port->line = idx; | 982 | port->line = idx; |
970 | port->ops = &mpc52xx_uart_ops; | 983 | port->ops = &mpc52xx_uart_ops; |
971 | port->dev = &op->dev; | 984 | port->dev = &op->dev; |
972 | 985 | ||
973 | /* Search for IRQ and mapbase */ | 986 | /* Search for IRQ and mapbase */ |
974 | if ((ret = of_address_to_resource(op->node, 0, &res)) != 0) | 987 | ret = of_address_to_resource(op->node, 0, &res); |
988 | if (ret) | ||
975 | return ret; | 989 | return ret; |
976 | 990 | ||
977 | port->mapbase = res.start; | 991 | port->mapbase = res.start; |
978 | port->irq = irq_of_parse_and_map(op->node, 0); | 992 | port->irq = irq_of_parse_and_map(op->node, 0); |
979 | 993 | ||
980 | 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", |
981 | (void*)port->mapbase, port->irq, port->uartclk); | 995 | (void *)port->mapbase, port->irq, port->uartclk); |
982 | 996 | ||
983 | if ((port->irq==NO_IRQ) || !port->mapbase) { | 997 | if ((port->irq == NO_IRQ) || !port->mapbase) { |
984 | printk(KERN_ERR "Could not allocate resources for PSC\n"); | 998 | printk(KERN_ERR "Could not allocate resources for PSC\n"); |
985 | return -EINVAL; | 999 | return -EINVAL; |
986 | } | 1000 | } |
@@ -988,7 +1002,7 @@ mpc52xx_uart_of_probe(struct of_device *op, const struct of_device_id *match) | |||
988 | /* Add the port to the uart sub-system */ | 1002 | /* Add the port to the uart sub-system */ |
989 | ret = uart_add_one_port(&mpc52xx_uart_driver, port); | 1003 | ret = uart_add_one_port(&mpc52xx_uart_driver, port); |
990 | if (!ret) | 1004 | if (!ret) |
991 | dev_set_drvdata(&op->dev, (void*)port); | 1005 | dev_set_drvdata(&op->dev, (void *)port); |
992 | 1006 | ||
993 | return ret; | 1007 | return ret; |
994 | } | 1008 | } |
@@ -1051,6 +1065,7 @@ mpc52xx_uart_of_assign(struct device_node *np, int idx) | |||
1051 | if (idx < 0) | 1065 | if (idx < 0) |
1052 | return; /* No free slot; abort */ | 1066 | return; /* No free slot; abort */ |
1053 | 1067 | ||
1068 | of_node_get(np); | ||
1054 | /* If the slot is already occupied, then swap slots */ | 1069 | /* If the slot is already occupied, then swap slots */ |
1055 | if (mpc52xx_uart_nodes[idx] && (free_idx != -1)) | 1070 | if (mpc52xx_uart_nodes[idx] && (free_idx != -1)) |
1056 | mpc52xx_uart_nodes[free_idx] = mpc52xx_uart_nodes[idx]; | 1071 | mpc52xx_uart_nodes[free_idx] = mpc52xx_uart_nodes[idx]; |
@@ -1060,7 +1075,7 @@ mpc52xx_uart_of_assign(struct device_node *np, int idx) | |||
1060 | static void | 1075 | static void |
1061 | mpc52xx_uart_of_enumerate(void) | 1076 | mpc52xx_uart_of_enumerate(void) |
1062 | { | 1077 | { |
1063 | static int enum_done = 0; | 1078 | static int enum_done; |
1064 | struct device_node *np; | 1079 | struct device_node *np; |
1065 | const unsigned int *devno; | 1080 | const unsigned int *devno; |
1066 | int i; | 1081 | int i; |
@@ -1074,7 +1089,7 @@ mpc52xx_uart_of_enumerate(void) | |||
1074 | 1089 | ||
1075 | /* Is a particular device number requested? */ | 1090 | /* Is a particular device number requested? */ |
1076 | devno = of_get_property(np, "port-number", NULL); | 1091 | devno = of_get_property(np, "port-number", NULL); |
1077 | mpc52xx_uart_of_assign(of_node_get(np), devno ? *devno : -1); | 1092 | mpc52xx_uart_of_assign(np, devno ? *devno : -1); |
1078 | } | 1093 | } |
1079 | 1094 | ||
1080 | enum_done = 1; | 1095 | enum_done = 1; |
@@ -1082,15 +1097,13 @@ mpc52xx_uart_of_enumerate(void) | |||
1082 | for (i = 0; i < MPC52xx_PSC_MAXNUM; i++) { | 1097 | for (i = 0; i < MPC52xx_PSC_MAXNUM; i++) { |
1083 | if (mpc52xx_uart_nodes[i]) | 1098 | if (mpc52xx_uart_nodes[i]) |
1084 | pr_debug("%s assigned to ttyPSC%x\n", | 1099 | pr_debug("%s assigned to ttyPSC%x\n", |
1085 | mpc52xx_uart_nodes[i]->full_name, i); | 1100 | mpc52xx_uart_nodes[i]->full_name, i); |
1086 | } | 1101 | } |
1087 | } | 1102 | } |
1088 | 1103 | ||
1089 | MODULE_DEVICE_TABLE(of, mpc52xx_uart_of_match); | 1104 | MODULE_DEVICE_TABLE(of, mpc52xx_uart_of_match); |
1090 | 1105 | ||
1091 | static struct of_platform_driver mpc52xx_uart_of_driver = { | 1106 | static struct of_platform_driver mpc52xx_uart_of_driver = { |
1092 | .owner = THIS_MODULE, | ||
1093 | .name = "mpc52xx-psc-uart", | ||
1094 | .match_table = mpc52xx_uart_of_match, | 1107 | .match_table = mpc52xx_uart_of_match, |
1095 | .probe = mpc52xx_uart_of_probe, | 1108 | .probe = mpc52xx_uart_of_probe, |
1096 | .remove = mpc52xx_uart_of_remove, | 1109 | .remove = mpc52xx_uart_of_remove, |
@@ -1116,7 +1129,8 @@ mpc52xx_uart_init(void) | |||
1116 | 1129 | ||
1117 | printk(KERN_INFO "Serial: MPC52xx PSC UART driver\n"); | 1130 | printk(KERN_INFO "Serial: MPC52xx PSC UART driver\n"); |
1118 | 1131 | ||
1119 | if ((ret = uart_register_driver(&mpc52xx_uart_driver)) != 0) { | 1132 | ret = uart_register_driver(&mpc52xx_uart_driver); |
1133 | if (ret) { | ||
1120 | printk(KERN_ERR "%s: uart_register_driver failed (%i)\n", | 1134 | printk(KERN_ERR "%s: uart_register_driver failed (%i)\n", |
1121 | __FILE__, ret); | 1135 | __FILE__, ret); |
1122 | return ret; | 1136 | return ret; |