2 * drivers/serial/mpc52xx_uart.c
4 * Driver for the PSC of the Freescale MPC52xx PSCs configured as UARTs.
6 * FIXME According to the usermanual the status bits in the status register
7 * are only updated when the peripherals access the FIFO and not when the
8 * CPU access them. So since we use this bits to know when we stop writing
9 * and reading, they may not be updated in-time and a race condition may
10 * exists. But I haven't be able to prove this and I don't care. But if
11 * any problem arises, it might worth checking. The TX/RX FIFO Stats
12 * registers should be used in addition.
13 * Update: Actually, they seem updated ... At least the bits we use.
16 * Maintainer : Sylvain Munaut <tnt@246tNt.com>
18 * Some of the code has been inspired/copied from the 2.4 code written
19 * by Dale Farnsworth <dfarnsworth@mvista.com>.
21 * Copyright (C) 2004-2005 Sylvain Munaut <tnt@246tNt.com>
22 * Copyright (C) 2003 MontaVista, Software, Inc.
24 * This file is licensed under the terms of the GNU General Public License
25 * version 2. This program is licensed "as is" without any warranty of any
26 * kind, whether express or implied.
29 /* Platform device Usage :
31 * Since PSCs can have multiple function, the correct driver for each one
32 * is selected by calling mpc52xx_match_psc_function(...). The function
33 * handled by this driver is "uart".
35 * The driver init all necessary registers to place the PSC in uart mode without
36 * DCD. However, the pin multiplexing aren't changed and should be set either
37 * by the bootloader or in the platform init code.
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
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
43 * are parsing the kernel args console=ttyPSC?, we wouldn't know which PSC it
47 #include <linux/platform_device.h>
48 #include <linux/module.h>
49 #include <linux/tty.h>
50 #include <linux/serial.h>
51 #include <linux/sysrq.h>
52 #include <linux/console.h>
54 #include <asm/delay.h>
57 #include <asm/mpc52xx.h>
58 #include <asm/mpc52xx_psc.h>
60 #if defined(CONFIG_SERIAL_MPC52xx_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
64 #include <linux/serial_core.h>
67 /* We've been assigned a range on the "Low-density serial ports" major */
68 #define SERIAL_PSC_MAJOR 204
69 #define SERIAL_PSC_MINOR 148
72 #define ISR_PASS_LIMIT 256 /* Max number of iteration in the interrupt */
75 static struct uart_port mpc52xx_uart_ports
[MPC52xx_PSC_MAXNUM
];
76 /* Rem: - We use the read_status_mask as a shadow of
77 * psc->mpc52xx_psc_imr
78 * - It's important that is array is all zero on start as we
79 * use it to know if it's initialized or not ! If it's not sure
80 * it's cleared, then a memset(...,0,...) should be added to
84 #define PSC(port) ((struct mpc52xx_psc __iomem *)((port)->membase))
87 /* Forward declaration of the interruption handling routine */
88 static irqreturn_t
mpc52xx_uart_int(int irq
,void *dev_id
);
91 /* Simple macro to test if a port is console or not. This one is taken
92 * for serial_core.c and maybe should be moved to serial_core.h ? */
93 #ifdef CONFIG_SERIAL_CORE_CONSOLE
94 #define uart_console(port) ((port)->cons && (port)->cons->index == (port)->line)
96 #define uart_console(port) (0)
100 /* ======================================================================== */
101 /* UART operations */
102 /* ======================================================================== */
105 mpc52xx_uart_tx_empty(struct uart_port
*port
)
107 int status
= in_be16(&PSC(port
)->mpc52xx_psc_status
);
108 return (status
& MPC52xx_PSC_SR_TXEMP
) ? TIOCSER_TEMT
: 0;
112 mpc52xx_uart_set_mctrl(struct uart_port
*port
, unsigned int mctrl
)
114 /* Not implemented */
118 mpc52xx_uart_get_mctrl(struct uart_port
*port
)
120 /* Not implemented */
121 return TIOCM_CTS
| TIOCM_DSR
| TIOCM_CAR
;
125 mpc52xx_uart_stop_tx(struct uart_port
*port
)
127 /* port->lock taken by caller */
128 port
->read_status_mask
&= ~MPC52xx_PSC_IMR_TXRDY
;
129 out_be16(&PSC(port
)->mpc52xx_psc_imr
,port
->read_status_mask
);
133 mpc52xx_uart_start_tx(struct uart_port
*port
)
135 /* port->lock taken by caller */
136 port
->read_status_mask
|= MPC52xx_PSC_IMR_TXRDY
;
137 out_be16(&PSC(port
)->mpc52xx_psc_imr
,port
->read_status_mask
);
141 mpc52xx_uart_send_xchar(struct uart_port
*port
, char ch
)
144 spin_lock_irqsave(&port
->lock
, flags
);
148 /* Make sure tx interrupts are on */
149 /* Truly necessary ??? They should be anyway */
150 port
->read_status_mask
|= MPC52xx_PSC_IMR_TXRDY
;
151 out_be16(&PSC(port
)->mpc52xx_psc_imr
,port
->read_status_mask
);
154 spin_unlock_irqrestore(&port
->lock
, flags
);
158 mpc52xx_uart_stop_rx(struct uart_port
*port
)
160 /* port->lock taken by caller */
161 port
->read_status_mask
&= ~MPC52xx_PSC_IMR_RXRDY
;
162 out_be16(&PSC(port
)->mpc52xx_psc_imr
,port
->read_status_mask
);
166 mpc52xx_uart_enable_ms(struct uart_port
*port
)
168 /* Not implemented */
172 mpc52xx_uart_break_ctl(struct uart_port
*port
, int ctl
)
175 spin_lock_irqsave(&port
->lock
, flags
);
178 out_8(&PSC(port
)->command
,MPC52xx_PSC_START_BRK
);
180 out_8(&PSC(port
)->command
,MPC52xx_PSC_STOP_BRK
);
182 spin_unlock_irqrestore(&port
->lock
, flags
);
186 mpc52xx_uart_startup(struct uart_port
*port
)
188 struct mpc52xx_psc __iomem
*psc
= PSC(port
);
192 ret
= request_irq(port
->irq
, mpc52xx_uart_int
,
193 IRQF_DISABLED
| IRQF_SAMPLE_RANDOM
, "mpc52xx_psc_uart", port
);
197 /* Reset/activate the port, clear and enable interrupts */
198 out_8(&psc
->command
,MPC52xx_PSC_RST_RX
);
199 out_8(&psc
->command
,MPC52xx_PSC_RST_TX
);
201 out_be32(&psc
->sicr
,0); /* UART mode DCD ignored */
203 out_be16(&psc
->mpc52xx_psc_clock_select
, 0xdd00); /* /16 prescaler on */
205 out_8(&psc
->rfcntl
, 0x00);
206 out_be16(&psc
->rfalarm
, 0x1ff);
207 out_8(&psc
->tfcntl
, 0x07);
208 out_be16(&psc
->tfalarm
, 0x80);
210 port
->read_status_mask
|= MPC52xx_PSC_IMR_RXRDY
| MPC52xx_PSC_IMR_TXRDY
;
211 out_be16(&psc
->mpc52xx_psc_imr
,port
->read_status_mask
);
213 out_8(&psc
->command
,MPC52xx_PSC_TX_ENABLE
);
214 out_8(&psc
->command
,MPC52xx_PSC_RX_ENABLE
);
220 mpc52xx_uart_shutdown(struct uart_port
*port
)
222 struct mpc52xx_psc __iomem
*psc
= PSC(port
);
224 /* Shut down the port, interrupt and all */
225 out_8(&psc
->command
,MPC52xx_PSC_RST_RX
);
226 out_8(&psc
->command
,MPC52xx_PSC_RST_TX
);
228 port
->read_status_mask
= 0;
229 out_be16(&psc
->mpc52xx_psc_imr
,port
->read_status_mask
);
231 /* Release interrupt */
232 free_irq(port
->irq
, port
);
236 mpc52xx_uart_set_termios(struct uart_port
*port
, struct termios
*new,
239 struct mpc52xx_psc __iomem
*psc
= PSC(port
);
241 unsigned char mr1
, mr2
;
243 unsigned int j
, baud
, quot
;
245 /* Prepare what we're gonna write */
248 switch (new->c_cflag
& CSIZE
) {
249 case CS5
: mr1
|= MPC52xx_PSC_MODE_5_BITS
;
251 case CS6
: mr1
|= MPC52xx_PSC_MODE_6_BITS
;
253 case CS7
: mr1
|= MPC52xx_PSC_MODE_7_BITS
;
256 default: mr1
|= MPC52xx_PSC_MODE_8_BITS
;
259 if (new->c_cflag
& PARENB
) {
260 mr1
|= (new->c_cflag
& PARODD
) ?
261 MPC52xx_PSC_MODE_PARODD
: MPC52xx_PSC_MODE_PAREVEN
;
263 mr1
|= MPC52xx_PSC_MODE_PARNONE
;
268 if (new->c_cflag
& CSTOPB
)
269 mr2
|= MPC52xx_PSC_MODE_TWO_STOP
;
271 mr2
|= ((new->c_cflag
& CSIZE
) == CS5
) ?
272 MPC52xx_PSC_MODE_ONE_STOP_5_BITS
:
273 MPC52xx_PSC_MODE_ONE_STOP
;
276 baud
= uart_get_baud_rate(port
, new, old
, 0, port
->uartclk
/16);
277 quot
= uart_get_divisor(port
, baud
);
281 spin_lock_irqsave(&port
->lock
, flags
);
283 /* Update the per-port timeout */
284 uart_update_timeout(port
, new->c_cflag
, baud
);
286 /* Do our best to flush TX & RX, so we don't loose anything */
287 /* But we don't wait indefinitly ! */
288 j
= 5000000; /* Maximum wait */
289 /* FIXME Can't receive chars since set_termios might be called at early
290 * boot for the console, all stuff is not yet ready to receive at that
291 * time and that just makes the kernel oops */
292 /* while (j-- && mpc52xx_uart_int_rx_chars(port)); */
293 while (!(in_be16(&psc
->mpc52xx_psc_status
) & MPC52xx_PSC_SR_TXEMP
) &&
298 printk( KERN_ERR
"mpc52xx_uart.c: "
299 "Unable to flush RX & TX fifos in-time in set_termios."
300 "Some chars may have been lost.\n" );
302 /* Reset the TX & RX */
303 out_8(&psc
->command
,MPC52xx_PSC_RST_RX
);
304 out_8(&psc
->command
,MPC52xx_PSC_RST_TX
);
306 /* Send new mode settings */
307 out_8(&psc
->command
,MPC52xx_PSC_SEL_MODE_REG_1
);
308 out_8(&psc
->mode
,mr1
);
309 out_8(&psc
->mode
,mr2
);
310 out_8(&psc
->ctur
,ctr
>> 8);
311 out_8(&psc
->ctlr
,ctr
& 0xff);
313 /* Reenable TX & RX */
314 out_8(&psc
->command
,MPC52xx_PSC_TX_ENABLE
);
315 out_8(&psc
->command
,MPC52xx_PSC_RX_ENABLE
);
317 /* We're all set, release the lock */
318 spin_unlock_irqrestore(&port
->lock
, flags
);
322 mpc52xx_uart_type(struct uart_port
*port
)
324 return port
->type
== PORT_MPC52xx
? "MPC52xx PSC" : NULL
;
328 mpc52xx_uart_release_port(struct uart_port
*port
)
330 if (port
->flags
& UPF_IOREMAP
) { /* remapped by us ? */
331 iounmap(port
->membase
);
332 port
->membase
= NULL
;
335 release_mem_region(port
->mapbase
, MPC52xx_PSC_SIZE
);
339 mpc52xx_uart_request_port(struct uart_port
*port
)
343 if (port
->flags
& UPF_IOREMAP
) /* Need to remap ? */
344 port
->membase
= ioremap(port
->mapbase
, MPC52xx_PSC_SIZE
);
349 err
= request_mem_region(port
->mapbase
, MPC52xx_PSC_SIZE
,
350 "mpc52xx_psc_uart") != NULL
? 0 : -EBUSY
;
352 if (err
&& (port
->flags
& UPF_IOREMAP
)) {
353 iounmap(port
->membase
);
354 port
->membase
= NULL
;
361 mpc52xx_uart_config_port(struct uart_port
*port
, int flags
)
363 if ( (flags
& UART_CONFIG_TYPE
) &&
364 (mpc52xx_uart_request_port(port
) == 0) )
365 port
->type
= PORT_MPC52xx
;
369 mpc52xx_uart_verify_port(struct uart_port
*port
, struct serial_struct
*ser
)
371 if ( ser
->type
!= PORT_UNKNOWN
&& ser
->type
!= PORT_MPC52xx
)
374 if ( (ser
->irq
!= port
->irq
) ||
375 (ser
->io_type
!= SERIAL_IO_MEM
) ||
376 (ser
->baud_base
!= port
->uartclk
) ||
377 (ser
->iomem_base
!= (void*)port
->mapbase
) ||
385 static struct uart_ops mpc52xx_uart_ops
= {
386 .tx_empty
= mpc52xx_uart_tx_empty
,
387 .set_mctrl
= mpc52xx_uart_set_mctrl
,
388 .get_mctrl
= mpc52xx_uart_get_mctrl
,
389 .stop_tx
= mpc52xx_uart_stop_tx
,
390 .start_tx
= mpc52xx_uart_start_tx
,
391 .send_xchar
= mpc52xx_uart_send_xchar
,
392 .stop_rx
= mpc52xx_uart_stop_rx
,
393 .enable_ms
= mpc52xx_uart_enable_ms
,
394 .break_ctl
= mpc52xx_uart_break_ctl
,
395 .startup
= mpc52xx_uart_startup
,
396 .shutdown
= mpc52xx_uart_shutdown
,
397 .set_termios
= mpc52xx_uart_set_termios
,
398 /* .pm = mpc52xx_uart_pm, Not supported yet */
399 /* .set_wake = mpc52xx_uart_set_wake, Not supported yet */
400 .type
= mpc52xx_uart_type
,
401 .release_port
= mpc52xx_uart_release_port
,
402 .request_port
= mpc52xx_uart_request_port
,
403 .config_port
= mpc52xx_uart_config_port
,
404 .verify_port
= mpc52xx_uart_verify_port
408 /* ======================================================================== */
409 /* Interrupt handling */
410 /* ======================================================================== */
413 mpc52xx_uart_int_rx_chars(struct uart_port
*port
)
415 struct tty_struct
*tty
= port
->info
->tty
;
416 unsigned char ch
, flag
;
417 unsigned short status
;
419 /* While we can read, do so ! */
420 while ( (status
= in_be16(&PSC(port
)->mpc52xx_psc_status
)) &
421 MPC52xx_PSC_SR_RXRDY
) {
424 ch
= in_8(&PSC(port
)->mpc52xx_psc_buffer_8
);
426 /* Handle sysreq char */
428 if (uart_handle_sysrq_char(port
, ch
)) {
439 if ( status
& (MPC52xx_PSC_SR_PE
|
441 MPC52xx_PSC_SR_RB
) ) {
443 if (status
& MPC52xx_PSC_SR_RB
) {
445 uart_handle_break(port
);
446 } else if (status
& MPC52xx_PSC_SR_PE
)
448 else if (status
& MPC52xx_PSC_SR_FE
)
451 /* Clear error condition */
452 out_8(&PSC(port
)->command
,MPC52xx_PSC_RST_ERR_STAT
);
455 tty_insert_flip_char(tty
, ch
, flag
);
456 if (status
& MPC52xx_PSC_SR_OE
) {
458 * Overrun is special, since it's
459 * reported immediately, and doesn't
460 * affect the current character
462 tty_insert_flip_char(tty
, 0, TTY_OVERRUN
);
466 tty_flip_buffer_push(tty
);
468 return in_be16(&PSC(port
)->mpc52xx_psc_status
) & MPC52xx_PSC_SR_RXRDY
;
472 mpc52xx_uart_int_tx_chars(struct uart_port
*port
)
474 struct circ_buf
*xmit
= &port
->info
->xmit
;
476 /* Process out of band chars */
478 out_8(&PSC(port
)->mpc52xx_psc_buffer_8
, port
->x_char
);
484 /* Nothing to do ? */
485 if (uart_circ_empty(xmit
) || uart_tx_stopped(port
)) {
486 mpc52xx_uart_stop_tx(port
);
491 while (in_be16(&PSC(port
)->mpc52xx_psc_status
) & MPC52xx_PSC_SR_TXRDY
) {
492 out_8(&PSC(port
)->mpc52xx_psc_buffer_8
, xmit
->buf
[xmit
->tail
]);
493 xmit
->tail
= (xmit
->tail
+ 1) & (UART_XMIT_SIZE
- 1);
495 if (uart_circ_empty(xmit
))
500 if (uart_circ_chars_pending(xmit
) < WAKEUP_CHARS
)
501 uart_write_wakeup(port
);
503 /* Maybe we're done after all */
504 if (uart_circ_empty(xmit
)) {
505 mpc52xx_uart_stop_tx(port
);
513 mpc52xx_uart_int(int irq
, void *dev_id
)
515 struct uart_port
*port
= dev_id
;
516 unsigned long pass
= ISR_PASS_LIMIT
;
517 unsigned int keepgoing
;
518 unsigned short status
;
520 spin_lock(&port
->lock
);
522 /* While we have stuff to do, we continue */
524 /* If we don't find anything to do, we stop */
528 status
= in_be16(&PSC(port
)->mpc52xx_psc_isr
);
529 status
&= port
->read_status_mask
;
531 /* Do we need to receive chars ? */
532 /* For this RX interrupts must be on and some chars waiting */
533 if ( status
& MPC52xx_PSC_IMR_RXRDY
)
534 keepgoing
|= mpc52xx_uart_int_rx_chars(port
);
536 /* Do we need to send chars ? */
537 /* For this, TX must be ready and TX interrupt enabled */
538 if ( status
& MPC52xx_PSC_IMR_TXRDY
)
539 keepgoing
|= mpc52xx_uart_int_tx_chars(port
);
541 /* Limit number of iteration */
547 spin_unlock(&port
->lock
);
553 /* ======================================================================== */
554 /* Console ( if applicable ) */
555 /* ======================================================================== */
557 #ifdef CONFIG_SERIAL_MPC52xx_CONSOLE
560 mpc52xx_console_get_options(struct uart_port
*port
,
561 int *baud
, int *parity
, int *bits
, int *flow
)
563 struct mpc52xx_psc __iomem
*psc
= PSC(port
);
566 /* Read the mode registers */
567 out_8(&psc
->command
,MPC52xx_PSC_SEL_MODE_REG_1
);
568 mr1
= in_8(&psc
->mode
);
570 /* CT{U,L}R are write-only ! */
571 *baud
= __res
.bi_baudrate
?
572 __res
.bi_baudrate
: CONFIG_SERIAL_MPC52xx_CONSOLE_BAUD
;
575 switch (mr1
& MPC52xx_PSC_MODE_BITS_MASK
) {
576 case MPC52xx_PSC_MODE_5_BITS
: *bits
= 5; break;
577 case MPC52xx_PSC_MODE_6_BITS
: *bits
= 6; break;
578 case MPC52xx_PSC_MODE_7_BITS
: *bits
= 7; break;
579 case MPC52xx_PSC_MODE_8_BITS
:
583 if (mr1
& MPC52xx_PSC_MODE_PARNONE
)
586 *parity
= mr1
& MPC52xx_PSC_MODE_PARODD
? 'o' : 'e';
590 mpc52xx_console_write(struct console
*co
, const char *s
, unsigned int count
)
592 struct uart_port
*port
= &mpc52xx_uart_ports
[co
->index
];
593 struct mpc52xx_psc __iomem
*psc
= PSC(port
);
596 /* Disable interrupts */
597 out_be16(&psc
->mpc52xx_psc_imr
, 0);
599 /* Wait the TX buffer to be empty */
600 j
= 5000000; /* Maximum wait */
601 while (!(in_be16(&psc
->mpc52xx_psc_status
) & MPC52xx_PSC_SR_TXEMP
) &&
605 /* Write all the chars */
606 for (i
= 0; i
< count
; i
++, s
++) {
607 /* Line return handling */
609 out_8(&psc
->mpc52xx_psc_buffer_8
, '\r');
612 out_8(&psc
->mpc52xx_psc_buffer_8
, *s
);
614 /* Wait the TX buffer to be empty */
615 j
= 20000; /* Maximum wait */
616 while (!(in_be16(&psc
->mpc52xx_psc_status
) &
617 MPC52xx_PSC_SR_TXEMP
) && --j
)
621 /* Restore interrupt state */
622 out_be16(&psc
->mpc52xx_psc_imr
, port
->read_status_mask
);
626 mpc52xx_console_setup(struct console
*co
, char *options
)
628 struct uart_port
*port
= &mpc52xx_uart_ports
[co
->index
];
630 int baud
= CONFIG_SERIAL_MPC52xx_CONSOLE_BAUD
;
635 if (co
->index
< 0 || co
->index
>= MPC52xx_PSC_MAXNUM
)
638 /* Basic port init. Needed since we use some uart_??? func before
639 * real init for early access */
640 spin_lock_init(&port
->lock
);
641 port
->uartclk
= __res
.bi_ipbfreq
/ 2; /* Look at CTLR doc */
642 port
->ops
= &mpc52xx_uart_ops
;
643 port
->mapbase
= MPC52xx_PA(MPC52xx_PSCx_OFFSET(co
->index
+1));
645 /* We ioremap ourself */
646 port
->membase
= ioremap(port
->mapbase
, MPC52xx_PSC_SIZE
);
647 if (port
->membase
== NULL
)
650 /* Setup the port parameters accoding to options */
652 uart_parse_options(options
, &baud
, &parity
, &bits
, &flow
);
654 mpc52xx_console_get_options(port
, &baud
, &parity
, &bits
, &flow
);
656 return uart_set_options(port
, co
, baud
, parity
, bits
, flow
);
660 static struct uart_driver mpc52xx_uart_driver
;
662 static struct console mpc52xx_console
= {
664 .write
= mpc52xx_console_write
,
665 .device
= uart_console_device
,
666 .setup
= mpc52xx_console_setup
,
667 .flags
= CON_PRINTBUFFER
,
668 .index
= -1, /* Specified on the cmdline (e.g. console=ttyPSC0 ) */
669 .data
= &mpc52xx_uart_driver
,
674 mpc52xx_console_init(void)
676 register_console(&mpc52xx_console
);
680 console_initcall(mpc52xx_console_init
);
682 #define MPC52xx_PSC_CONSOLE &mpc52xx_console
684 #define MPC52xx_PSC_CONSOLE NULL
688 /* ======================================================================== */
690 /* ======================================================================== */
692 static struct uart_driver mpc52xx_uart_driver
= {
693 .owner
= THIS_MODULE
,
694 .driver_name
= "mpc52xx_psc_uart",
695 .dev_name
= "ttyPSC",
696 .major
= SERIAL_PSC_MAJOR
,
697 .minor
= SERIAL_PSC_MINOR
,
698 .nr
= MPC52xx_PSC_MAXNUM
,
699 .cons
= MPC52xx_PSC_CONSOLE
,
703 /* ======================================================================== */
704 /* Platform Driver */
705 /* ======================================================================== */
708 mpc52xx_uart_probe(struct platform_device
*dev
)
710 struct resource
*res
= dev
->resource
;
712 struct uart_port
*port
= NULL
;
715 /* Check validity & presence */
717 if (idx
< 0 || idx
>= MPC52xx_PSC_MAXNUM
)
720 if (!mpc52xx_match_psc_function(idx
,"uart"))
723 /* Init the port structure */
724 port
= &mpc52xx_uart_ports
[idx
];
726 memset(port
, 0x00, sizeof(struct uart_port
));
728 spin_lock_init(&port
->lock
);
729 port
->uartclk
= __res
.bi_ipbfreq
/ 2; /* Look at CTLR doc */
730 port
->fifosize
= 512;
731 port
->iotype
= UPIO_MEM
;
732 port
->flags
= UPF_BOOT_AUTOCONF
|
733 ( uart_console(port
) ? 0 : UPF_IOREMAP
);
735 port
->ops
= &mpc52xx_uart_ops
;
737 /* Search for IRQ and mapbase */
738 for (i
=0 ; i
<dev
->num_resources
; i
++, res
++) {
739 if (res
->flags
& IORESOURCE_MEM
)
740 port
->mapbase
= res
->start
;
741 else if (res
->flags
& IORESOURCE_IRQ
)
742 port
->irq
= res
->start
;
744 if (!port
->irq
|| !port
->mapbase
)
747 /* Add the port to the uart sub-system */
748 ret
= uart_add_one_port(&mpc52xx_uart_driver
, port
);
750 platform_set_drvdata(dev
, (void*)port
);
756 mpc52xx_uart_remove(struct platform_device
*dev
)
758 struct uart_port
*port
= (struct uart_port
*) platform_get_drvdata(dev
);
760 platform_set_drvdata(dev
, NULL
);
763 uart_remove_one_port(&mpc52xx_uart_driver
, port
);
770 mpc52xx_uart_suspend(struct platform_device
*dev
, pm_message_t state
)
772 struct uart_port
*port
= (struct uart_port
*) platform_get_drvdata(dev
);
775 uart_suspend_port(&mpc52xx_uart_driver
, port
);
781 mpc52xx_uart_resume(struct platform_device
*dev
)
783 struct uart_port
*port
= (struct uart_port
*) platform_get_drvdata(dev
);
786 uart_resume_port(&mpc52xx_uart_driver
, port
);
792 static struct platform_driver mpc52xx_uart_platform_driver
= {
793 .probe
= mpc52xx_uart_probe
,
794 .remove
= mpc52xx_uart_remove
,
796 .suspend
= mpc52xx_uart_suspend
,
797 .resume
= mpc52xx_uart_resume
,
800 .name
= "mpc52xx-psc",
805 /* ======================================================================== */
807 /* ======================================================================== */
810 mpc52xx_uart_init(void)
814 printk(KERN_INFO
"Serial: MPC52xx PSC driver\n");
816 ret
= uart_register_driver(&mpc52xx_uart_driver
);
818 ret
= platform_driver_register(&mpc52xx_uart_platform_driver
);
820 uart_unregister_driver(&mpc52xx_uart_driver
);
827 mpc52xx_uart_exit(void)
829 platform_driver_unregister(&mpc52xx_uart_platform_driver
);
830 uart_unregister_driver(&mpc52xx_uart_driver
);
834 module_init(mpc52xx_uart_init
);
835 module_exit(mpc52xx_uart_exit
);
837 MODULE_AUTHOR("Sylvain Munaut <tnt@246tNt.com>");
838 MODULE_DESCRIPTION("Freescale MPC52xx PSC UART");
839 MODULE_LICENSE("GPL");