2 * linux/drivers/serial/s3c2410.c
4 * Driver for onboard UARTs on the Samsung S3C24XX
6 * Based on drivers/char/serial.c and drivers/char/21285.c
8 * Ben Dooks, (c) 2003-2005 Simtec Electronics
9 * http://www.simtec.co.uk/products/SWLINUX/
13 * 22-Jul-2004 BJD Finished off device rewrite
15 * 21-Jul-2004 BJD Thanks to <herbet@13thfloor.at> for pointing out
16 * problems with baud rate and loss of IR settings. Update
17 * to add configuration via platform_device structure
19 * 28-Sep-2004 BJD Re-write for the following items
20 * - S3C2410 and S3C2440 serial support
21 * - Power Management support
22 * - Fix console via IrDA devices
23 * - SysReq (Herbert Pötzl)
24 * - Break character handling (Herbert Pötzl)
25 * - spin-lock initialisation (Dimitry Andric)
26 * - added clock control
27 * - updated init code to use platform_device info
29 * 06-Mar-2005 BJD Add s3c2440 fclk clock source
31 * 09-Mar-2005 BJD Add s3c2400 support
33 * 10-Mar-2005 LCVR Changed S3C2410_VA_UART to S3C24XX_VA_UART
36 /* Note on 2440 fclk clock source handling
38 * Whilst it is possible to use the fclk as clock source, the method
39 * of properly switching too/from this is currently un-implemented, so
40 * whichever way is configured at startup is the one that will be used.
43 /* Hote on 2410 error handling
45 * The s3c2410 manual has a love/hate affair with the contents of the
46 * UERSTAT register in the UART blocks, and keeps marking some of the
47 * error bits as reserved. Having checked with the s3c2410x01,
48 * it copes with BREAKs properly, so I am happy to ignore the RESERVED
49 * feature from the latter versions of the manual.
51 * If it becomes aparrent that latter versions of the 2410 remove these
52 * bits, then action will have to be taken to differentiate the versions
53 * and change the policy on BREAK
58 #include <linux/config.h>
60 #if defined(CONFIG_SERIAL_S3C2410_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
64 #include <linux/module.h>
65 #include <linux/ioport.h>
66 #include <linux/device.h>
67 #include <linux/init.h>
68 #include <linux/sysrq.h>
69 #include <linux/console.h>
70 #include <linux/tty.h>
71 #include <linux/tty_flip.h>
72 #include <linux/serial_core.h>
73 #include <linux/serial.h>
74 #include <linux/delay.h>
79 #include <asm/hardware.h>
80 #include <asm/hardware/clock.h>
82 #include <asm/arch/regs-serial.h>
83 #include <asm/arch/regs-gpio.h>
87 struct s3c24xx_uart_info {
90 unsigned int fifosize;
91 unsigned long rx_fifomask;
92 unsigned long rx_fifoshift;
93 unsigned long rx_fifofull;
94 unsigned long tx_fifomask;
95 unsigned long tx_fifoshift;
96 unsigned long tx_fifofull;
98 /* clock source control */
100 int (*get_clksrc)(struct uart_port *, struct s3c24xx_uart_clksrc *clk);
101 int (*set_clksrc)(struct uart_port *, struct s3c24xx_uart_clksrc *clk);
104 int (*reset_port)(struct uart_port *, struct s3c2410_uartcfg *);
107 struct s3c24xx_uart_port {
108 unsigned char rx_claimed;
109 unsigned char tx_claimed;
111 struct s3c24xx_uart_info *info;
112 struct s3c24xx_uart_clksrc *clksrc;
115 struct uart_port port;
119 /* configuration defines */
123 /* send debug to the low-level output routines */
125 extern void printascii(const char *);
128 s3c24xx_serial_dbg(const char *fmt, ...)
134 vsprintf(buff, fmt, va);
140 #define dbg(x...) s3c24xx_serial_dbg(x)
143 #define dbg(x...) printk(KERN_DEBUG "s3c24xx: ");
146 #define dbg(x...) do {} while(0)
149 /* UART name and device definitions */
151 #define S3C24XX_SERIAL_NAME "ttySAC"
152 #define S3C24XX_SERIAL_DEVFS "tts/"
153 #define S3C24XX_SERIAL_MAJOR 204
154 #define S3C24XX_SERIAL_MINOR 64
157 /* conversion functions */
159 #define s3c24xx_dev_to_port(__dev) (struct uart_port *)dev_get_drvdata(__dev)
160 #define s3c24xx_dev_to_cfg(__dev) (struct s3c2410_uartcfg *)((__dev)->platform_data)
162 /* we can support 3 uarts, but not always use them */
166 /* port irq numbers */
168 #define TX_IRQ(port) ((port)->irq + 1)
169 #define RX_IRQ(port) ((port)->irq)
171 /* register access controls */
173 #define portaddr(port, reg) ((port)->membase + (reg))
175 #define rd_regb(port, reg) (__raw_readb(portaddr(port, reg)))
176 #define rd_regl(port, reg) (__raw_readl(portaddr(port, reg)))
178 #define wr_regb(port, reg, val) \
179 do { __raw_writeb(val, portaddr(port, reg)); } while(0)
181 #define wr_regl(port, reg, val) \
182 do { __raw_writel(val, portaddr(port, reg)); } while(0)
184 /* macros to change one thing to another */
186 #define tx_enabled(port) ((port)->unused[0])
187 #define rx_enabled(port) ((port)->unused[1])
189 /* flag to ignore all characters comming in */
190 #define RXSTAT_DUMMY_READ (0x10000000)
192 static inline struct s3c24xx_uart_port *to_ourport(struct uart_port *port)
194 return container_of(port, struct s3c24xx_uart_port, port);
197 /* translate a port to the device name */
199 static inline const char *s3c24xx_serial_portname(struct uart_port *port)
201 return to_platform_device(port->dev)->name;
204 static int s3c24xx_serial_txempty_nofifo(struct uart_port *port)
206 return (rd_regl(port, S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXE);
209 static void s3c24xx_serial_rx_enable(struct uart_port *port)
212 unsigned int ucon, ufcon;
215 spin_lock_irqsave(&port->lock, flags);
217 while (--count && !s3c24xx_serial_txempty_nofifo(port))
220 ufcon = rd_regl(port, S3C2410_UFCON);
221 ufcon |= S3C2410_UFCON_RESETRX;
222 wr_regl(port, S3C2410_UFCON, ufcon);
224 ucon = rd_regl(port, S3C2410_UCON);
225 ucon |= S3C2410_UCON_RXIRQMODE;
226 wr_regl(port, S3C2410_UCON, ucon);
228 rx_enabled(port) = 1;
229 spin_unlock_irqrestore(&port->lock, flags);
232 static void s3c24xx_serial_rx_disable(struct uart_port *port)
237 spin_lock_irqsave(&port->lock, flags);
239 ucon = rd_regl(port, S3C2410_UCON);
240 ucon &= ~S3C2410_UCON_RXIRQMODE;
241 wr_regl(port, S3C2410_UCON, ucon);
243 rx_enabled(port) = 0;
244 spin_unlock_irqrestore(&port->lock, flags);
247 static void s3c24xx_serial_stop_tx(struct uart_port *port)
249 if (tx_enabled(port)) {
250 disable_irq(TX_IRQ(port));
251 tx_enabled(port) = 0;
252 if (port->flags & UPF_CONS_FLOW)
253 s3c24xx_serial_rx_enable(port);
257 static void s3c24xx_serial_start_tx(struct uart_port *port)
259 if (!tx_enabled(port)) {
260 if (port->flags & UPF_CONS_FLOW)
261 s3c24xx_serial_rx_disable(port);
263 enable_irq(TX_IRQ(port));
264 tx_enabled(port) = 1;
269 static void s3c24xx_serial_stop_rx(struct uart_port *port)
271 if (rx_enabled(port)) {
272 dbg("s3c24xx_serial_stop_rx: port=%p\n", port);
273 disable_irq(RX_IRQ(port));
274 rx_enabled(port) = 0;
278 static void s3c24xx_serial_enable_ms(struct uart_port *port)
282 static inline struct s3c24xx_uart_info *s3c24xx_port_to_info(struct uart_port *port)
284 return to_ourport(port)->info;
287 static inline struct s3c2410_uartcfg *s3c24xx_port_to_cfg(struct uart_port *port)
289 if (port->dev == NULL)
292 return (struct s3c2410_uartcfg *)port->dev->platform_data;
295 static int s3c24xx_serial_rx_fifocnt(struct s3c24xx_uart_port *ourport,
296 unsigned long ufstat)
298 struct s3c24xx_uart_info *info = ourport->info;
300 if (ufstat & info->rx_fifofull)
301 return info->fifosize;
303 return (ufstat & info->rx_fifomask) >> info->rx_fifoshift;
307 /* ? - where has parity gone?? */
308 #define S3C2410_UERSTAT_PARITY (0x1000)
311 s3c24xx_serial_rx_chars(int irq, void *dev_id, struct pt_regs *regs)
313 struct s3c24xx_uart_port *ourport = dev_id;
314 struct uart_port *port = &ourport->port;
315 struct tty_struct *tty = port->info->tty;
316 unsigned int ufcon, ch, flag, ufstat, uerstat;
319 while (max_count-- > 0) {
320 ufcon = rd_regl(port, S3C2410_UFCON);
321 ufstat = rd_regl(port, S3C2410_UFSTAT);
323 if (s3c24xx_serial_rx_fifocnt(ourport, ufstat) == 0)
326 if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
327 if (tty->low_latency)
328 tty_flip_buffer_push(tty);
331 * If this failed then we will throw away the
332 * bytes but must do so to clear interrupts
336 uerstat = rd_regl(port, S3C2410_UERSTAT);
337 ch = rd_regb(port, S3C2410_URXH);
339 if (port->flags & UPF_CONS_FLOW) {
340 int txe = s3c24xx_serial_txempty_nofifo(port);
342 if (rx_enabled(port)) {
344 rx_enabled(port) = 0;
349 ufcon |= S3C2410_UFCON_RESETRX;
350 wr_regl(port, S3C2410_UFCON, ufcon);
351 rx_enabled(port) = 1;
358 /* insert the character into the buffer */
363 if (unlikely(uerstat & S3C2410_UERSTAT_ANY)) {
364 dbg("rxerr: port ch=0x%02x, rxs=0x%08x\n",
367 /* check for break */
368 if (uerstat & S3C2410_UERSTAT_BREAK) {
371 if (uart_handle_break(port))
375 if (uerstat & S3C2410_UERSTAT_FRAME)
376 port->icount.frame++;
377 if (uerstat & S3C2410_UERSTAT_OVERRUN)
378 port->icount.overrun++;
380 uerstat &= port->read_status_mask;
382 if (uerstat & S3C2410_UERSTAT_BREAK)
384 else if (uerstat & S3C2410_UERSTAT_PARITY)
386 else if (uerstat & ( S3C2410_UERSTAT_FRAME | S3C2410_UERSTAT_OVERRUN))
390 if (uart_handle_sysrq_char(port, ch, regs))
393 uart_insert_char(port, uerstat, S3C2410_UERSTAT_OVERRUN, ch, flag);
398 tty_flip_buffer_push(tty);
404 static irqreturn_t s3c24xx_serial_tx_chars(int irq, void *id, struct pt_regs *regs)
406 struct s3c24xx_uart_port *ourport = id;
407 struct uart_port *port = &ourport->port;
408 struct circ_buf *xmit = &port->info->xmit;
412 wr_regb(port, S3C2410_UTXH, port->x_char);
418 /* if there isnt anything more to transmit, or the uart is now
419 * stopped, disable the uart and exit
422 if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
423 s3c24xx_serial_stop_tx(port);
427 /* try and drain the buffer... */
429 while (!uart_circ_empty(xmit) && count-- > 0) {
430 if (rd_regl(port, S3C2410_UFSTAT) & ourport->info->tx_fifofull)
433 wr_regb(port, S3C2410_UTXH, xmit->buf[xmit->tail]);
434 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
438 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
439 uart_write_wakeup(port);
441 if (uart_circ_empty(xmit))
442 s3c24xx_serial_stop_tx(port);
448 static unsigned int s3c24xx_serial_tx_empty(struct uart_port *port)
450 struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
451 unsigned long ufstat = rd_regl(port, S3C2410_UFSTAT);
452 unsigned long ufcon = rd_regl(port, S3C2410_UFCON);
454 if (ufcon & S3C2410_UFCON_FIFOMODE) {
455 if ((ufstat & info->tx_fifomask) != 0 ||
456 (ufstat & info->tx_fifofull))
462 return s3c24xx_serial_txempty_nofifo(port);
465 /* no modem control lines */
466 static unsigned int s3c24xx_serial_get_mctrl(struct uart_port *port)
468 unsigned int umstat = rd_regb(port,S3C2410_UMSTAT);
470 if (umstat & S3C2410_UMSTAT_CTS)
471 return TIOCM_CAR | TIOCM_DSR | TIOCM_CTS;
473 return TIOCM_CAR | TIOCM_DSR;
476 static void s3c24xx_serial_set_mctrl(struct uart_port *port, unsigned int mctrl)
478 /* todo - possibly remove AFC and do manual CTS */
481 static void s3c24xx_serial_break_ctl(struct uart_port *port, int break_state)
486 spin_lock_irqsave(&port->lock, flags);
488 ucon = rd_regl(port, S3C2410_UCON);
491 ucon |= S3C2410_UCON_SBREAK;
493 ucon &= ~S3C2410_UCON_SBREAK;
495 wr_regl(port, S3C2410_UCON, ucon);
497 spin_unlock_irqrestore(&port->lock, flags);
500 static void s3c24xx_serial_shutdown(struct uart_port *port)
502 struct s3c24xx_uart_port *ourport = to_ourport(port);
504 if (ourport->tx_claimed) {
505 free_irq(TX_IRQ(port), ourport);
506 tx_enabled(port) = 0;
507 ourport->tx_claimed = 0;
510 if (ourport->rx_claimed) {
511 free_irq(RX_IRQ(port), ourport);
512 ourport->rx_claimed = 0;
513 rx_enabled(port) = 0;
518 static int s3c24xx_serial_startup(struct uart_port *port)
520 struct s3c24xx_uart_port *ourport = to_ourport(port);
523 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
524 port->mapbase, port->membase);
526 rx_enabled(port) = 1;
528 ret = request_irq(RX_IRQ(port),
529 s3c24xx_serial_rx_chars, 0,
530 s3c24xx_serial_portname(port), ourport);
533 printk(KERN_ERR "cannot get irq %d\n", RX_IRQ(port));
537 ourport->rx_claimed = 1;
539 dbg("requesting tx irq...\n");
541 tx_enabled(port) = 1;
543 ret = request_irq(TX_IRQ(port),
544 s3c24xx_serial_tx_chars, 0,
545 s3c24xx_serial_portname(port), ourport);
548 printk(KERN_ERR "cannot get irq %d\n", TX_IRQ(port));
552 ourport->tx_claimed = 1;
554 dbg("s3c24xx_serial_startup ok\n");
556 /* the port reset code should have done the correct
557 * register setup for the port controls */
562 s3c24xx_serial_shutdown(port);
566 /* power power management control */
568 static void s3c24xx_serial_pm(struct uart_port *port, unsigned int level,
571 struct s3c24xx_uart_port *ourport = to_ourport(port);
575 if (!IS_ERR(ourport->baudclk) && ourport->baudclk != NULL)
576 clk_disable(ourport->baudclk);
578 clk_disable(ourport->clk);
582 clk_enable(ourport->clk);
584 if (!IS_ERR(ourport->baudclk) && ourport->baudclk != NULL)
585 clk_enable(ourport->baudclk);
589 printk(KERN_ERR "s3c24xx_serial: unknown pm %d\n", level);
593 /* baud rate calculation
595 * The UARTs on the S3C2410/S3C2440 can take their clocks from a number
596 * of different sources, including the peripheral clock ("pclk") and an
597 * external clock ("uclk"). The S3C2440 also adds the core clock ("fclk")
598 * with a programmable extra divisor.
600 * The following code goes through the clock sources, and calculates the
601 * baud clocks (and the resultant actual baud rates) and then tries to
602 * pick the closest one and select that.
609 static struct s3c24xx_uart_clksrc tmp_clksrc = {
617 s3c24xx_serial_getsource(struct uart_port *port, struct s3c24xx_uart_clksrc *c)
619 struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
621 return (info->get_clksrc)(port, c);
625 s3c24xx_serial_setsource(struct uart_port *port, struct s3c24xx_uart_clksrc *c)
627 struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
629 return (info->set_clksrc)(port, c);
633 struct s3c24xx_uart_clksrc *clksrc;
639 static int s3c24xx_serial_calcbaud(struct baud_calc *calc,
640 struct uart_port *port,
641 struct s3c24xx_uart_clksrc *clksrc,
646 calc->src = clk_get(port->dev, clksrc->name);
647 if (calc->src == NULL || IS_ERR(calc->src))
650 rate = clk_get_rate(calc->src);
651 rate /= clksrc->divisor;
653 calc->clksrc = clksrc;
654 calc->quot = (rate + (8 * baud)) / (16 * baud);
655 calc->calc = (rate / (calc->quot * 16));
661 static unsigned int s3c24xx_serial_getclk(struct uart_port *port,
662 struct s3c24xx_uart_clksrc **clksrc,
666 struct s3c2410_uartcfg *cfg = s3c24xx_port_to_cfg(port);
667 struct s3c24xx_uart_clksrc *clkp;
668 struct baud_calc res[MAX_CLKS];
669 struct baud_calc *resptr, *best, *sptr;
675 if (cfg->clocks_size < 2) {
676 if (cfg->clocks_size == 0)
679 /* check to see if we're sourcing fclk, and if so we're
680 * going to have to update the clock source
683 if (strcmp(clkp->name, "fclk") == 0) {
684 struct s3c24xx_uart_clksrc src;
686 s3c24xx_serial_getsource(port, &src);
688 /* check that the port already using fclk, and if
689 * not, then re-select fclk
692 if (strcmp(src.name, clkp->name) == 0) {
693 s3c24xx_serial_setsource(port, clkp);
694 s3c24xx_serial_getsource(port, &src);
697 clkp->divisor = src.divisor;
700 s3c24xx_serial_calcbaud(res, port, clkp, baud);
706 for (i = 0; i < cfg->clocks_size; i++, clkp++) {
707 if (s3c24xx_serial_calcbaud(resptr, port, clkp, baud))
712 /* ok, we now need to select the best clock we found */
715 unsigned int deviation = (1<<30)|((1<<30)-1);
718 for (sptr = res; sptr < resptr; sptr++) {
720 "found clk %p (%s) quot %d, calc %d\n",
721 sptr->clksrc, sptr->clksrc->name,
722 sptr->quot, sptr->calc);
724 calc_deviation = baud - sptr->calc;
725 if (calc_deviation < 0)
726 calc_deviation = -calc_deviation;
728 if (calc_deviation < deviation) {
730 deviation = calc_deviation;
734 printk(KERN_DEBUG "best %p (deviation %d)\n", best, deviation);
737 printk(KERN_DEBUG "selected clock %p (%s) quot %d, calc %d\n",
738 best->clksrc, best->clksrc->name, best->quot, best->calc);
740 /* store results to pass back */
742 *clksrc = best->clksrc;
748 static void s3c24xx_serial_set_termios(struct uart_port *port,
749 struct termios *termios,
752 struct s3c2410_uartcfg *cfg = s3c24xx_port_to_cfg(port);
753 struct s3c24xx_uart_port *ourport = to_ourport(port);
754 struct s3c24xx_uart_clksrc *clksrc = NULL;
755 struct clk *clk = NULL;
757 unsigned int baud, quot;
762 * We don't support modem control lines.
764 termios->c_cflag &= ~(HUPCL | CMSPAR);
765 termios->c_cflag |= CLOCAL;
768 * Ask the core to calculate the divisor for us.
771 baud = uart_get_baud_rate(port, termios, old, 0, 115200*8);
773 if (baud == 38400 && (port->flags & UPF_SPD_MASK) == UPF_SPD_CUST)
774 quot = port->custom_divisor;
776 quot = s3c24xx_serial_getclk(port, &clksrc, &clk, baud);
778 /* check to see if we need to change clock source */
780 if (ourport->clksrc != clksrc || ourport->baudclk != clk) {
781 s3c24xx_serial_setsource(port, clksrc);
783 if (ourport->baudclk != NULL && !IS_ERR(ourport->baudclk)) {
784 clk_disable(ourport->baudclk);
785 clk_unuse(ourport->baudclk);
786 ourport->baudclk = NULL;
792 ourport->clksrc = clksrc;
793 ourport->baudclk = clk;
796 switch (termios->c_cflag & CSIZE) {
798 dbg("config: 5bits/char\n");
799 ulcon = S3C2410_LCON_CS5;
802 dbg("config: 6bits/char\n");
803 ulcon = S3C2410_LCON_CS6;
806 dbg("config: 7bits/char\n");
807 ulcon = S3C2410_LCON_CS7;
811 dbg("config: 8bits/char\n");
812 ulcon = S3C2410_LCON_CS8;
816 /* preserve original lcon IR settings */
817 ulcon |= (cfg->ulcon & S3C2410_LCON_IRM);
819 if (termios->c_cflag & CSTOPB)
820 ulcon |= S3C2410_LCON_STOPB;
822 umcon = (termios->c_cflag & CRTSCTS) ? S3C2410_UMCOM_AFC : 0;
824 if (termios->c_cflag & PARENB) {
825 if (termios->c_cflag & PARODD)
826 ulcon |= S3C2410_LCON_PODD;
828 ulcon |= S3C2410_LCON_PEVEN;
830 ulcon |= S3C2410_LCON_PNONE;
833 spin_lock_irqsave(&port->lock, flags);
835 dbg("setting ulcon to %08x, brddiv to %d\n", ulcon, quot);
837 wr_regl(port, S3C2410_ULCON, ulcon);
838 wr_regl(port, S3C2410_UBRDIV, quot);
839 wr_regl(port, S3C2410_UMCON, umcon);
841 dbg("uart: ulcon = 0x%08x, ucon = 0x%08x, ufcon = 0x%08x\n",
842 rd_regl(port, S3C2410_ULCON),
843 rd_regl(port, S3C2410_UCON),
844 rd_regl(port, S3C2410_UFCON));
847 * Update the per-port timeout.
849 uart_update_timeout(port, termios->c_cflag, baud);
852 * Which character status flags are we interested in?
854 port->read_status_mask = S3C2410_UERSTAT_OVERRUN;
855 if (termios->c_iflag & INPCK)
856 port->read_status_mask |= S3C2410_UERSTAT_FRAME | S3C2410_UERSTAT_PARITY;
859 * Which character status flags should we ignore?
861 port->ignore_status_mask = 0;
862 if (termios->c_iflag & IGNPAR)
863 port->ignore_status_mask |= S3C2410_UERSTAT_OVERRUN;
864 if (termios->c_iflag & IGNBRK && termios->c_iflag & IGNPAR)
865 port->ignore_status_mask |= S3C2410_UERSTAT_FRAME;
868 * Ignore all characters if CREAD is not set.
870 if ((termios->c_cflag & CREAD) == 0)
871 port->ignore_status_mask |= RXSTAT_DUMMY_READ;
873 spin_unlock_irqrestore(&port->lock, flags);
876 static const char *s3c24xx_serial_type(struct uart_port *port)
878 switch (port->type) {
888 #define MAP_SIZE (0x100)
890 static void s3c24xx_serial_release_port(struct uart_port *port)
892 release_mem_region(port->mapbase, MAP_SIZE);
895 static int s3c24xx_serial_request_port(struct uart_port *port)
897 const char *name = s3c24xx_serial_portname(port);
898 return request_mem_region(port->mapbase, MAP_SIZE, name) ? 0 : -EBUSY;
901 static void s3c24xx_serial_config_port(struct uart_port *port, int flags)
903 struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
905 if (flags & UART_CONFIG_TYPE &&
906 s3c24xx_serial_request_port(port) == 0)
907 port->type = info->type;
911 * verify the new serial_struct (for TIOCSSERIAL).
914 s3c24xx_serial_verify_port(struct uart_port *port, struct serial_struct *ser)
916 struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
918 if (ser->type != PORT_UNKNOWN && ser->type != info->type)
925 #ifdef CONFIG_SERIAL_S3C2410_CONSOLE
927 static struct console s3c24xx_serial_console;
929 #define S3C24XX_SERIAL_CONSOLE &s3c24xx_serial_console
931 #define S3C24XX_SERIAL_CONSOLE NULL
934 static struct uart_ops s3c24xx_serial_ops = {
935 .pm = s3c24xx_serial_pm,
936 .tx_empty = s3c24xx_serial_tx_empty,
937 .get_mctrl = s3c24xx_serial_get_mctrl,
938 .set_mctrl = s3c24xx_serial_set_mctrl,
939 .stop_tx = s3c24xx_serial_stop_tx,
940 .start_tx = s3c24xx_serial_start_tx,
941 .stop_rx = s3c24xx_serial_stop_rx,
942 .enable_ms = s3c24xx_serial_enable_ms,
943 .break_ctl = s3c24xx_serial_break_ctl,
944 .startup = s3c24xx_serial_startup,
945 .shutdown = s3c24xx_serial_shutdown,
946 .set_termios = s3c24xx_serial_set_termios,
947 .type = s3c24xx_serial_type,
948 .release_port = s3c24xx_serial_release_port,
949 .request_port = s3c24xx_serial_request_port,
950 .config_port = s3c24xx_serial_config_port,
951 .verify_port = s3c24xx_serial_verify_port,
955 static struct uart_driver s3c24xx_uart_drv = {
956 .owner = THIS_MODULE,
957 .dev_name = "s3c2410_serial",
959 .cons = S3C24XX_SERIAL_CONSOLE,
960 .driver_name = S3C24XX_SERIAL_NAME,
961 .devfs_name = S3C24XX_SERIAL_DEVFS,
962 .major = S3C24XX_SERIAL_MAJOR,
963 .minor = S3C24XX_SERIAL_MINOR,
966 static struct s3c24xx_uart_port s3c24xx_serial_ports[NR_PORTS] = {
969 .lock = SPIN_LOCK_UNLOCKED,
971 .irq = IRQ_S3CUART_RX0,
974 .ops = &s3c24xx_serial_ops,
975 .flags = UPF_BOOT_AUTOCONF,
981 .lock = SPIN_LOCK_UNLOCKED,
983 .irq = IRQ_S3CUART_RX1,
986 .ops = &s3c24xx_serial_ops,
987 .flags = UPF_BOOT_AUTOCONF,
995 .lock = SPIN_LOCK_UNLOCKED,
997 .irq = IRQ_S3CUART_RX2,
1000 .ops = &s3c24xx_serial_ops,
1001 .flags = UPF_BOOT_AUTOCONF,
1008 /* s3c24xx_serial_resetport
1010 * wrapper to call the specific reset for this port (reset the fifos
1014 static inline int s3c24xx_serial_resetport(struct uart_port * port,
1015 struct s3c2410_uartcfg *cfg)
1017 struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
1019 return (info->reset_port)(port, cfg);
1022 /* s3c24xx_serial_init_port
1024 * initialise a single serial port from the platform device given
1027 static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
1028 struct s3c24xx_uart_info *info,
1029 struct platform_device *platdev)
1031 struct uart_port *port = &ourport->port;
1032 struct s3c2410_uartcfg *cfg;
1033 struct resource *res;
1035 dbg("s3c24xx_serial_init_port: port=%p, platdev=%p\n", port, platdev);
1037 if (platdev == NULL)
1040 cfg = s3c24xx_dev_to_cfg(&platdev->dev);
1042 if (port->mapbase != 0)
1045 if (cfg->hwport > 3)
1048 /* setup info for port */
1049 port->dev = &platdev->dev;
1050 ourport->info = info;
1052 /* copy the info in from provided structure */
1053 ourport->port.fifosize = info->fifosize;
1055 dbg("s3c24xx_serial_init_port: %p (hw %d)...\n", port, cfg->hwport);
1059 if (cfg->uart_flags & UPF_CONS_FLOW) {
1060 dbg("s3c24xx_serial_init_port: enabling flow control\n");
1061 port->flags |= UPF_CONS_FLOW;
1064 /* sort our the physical and virtual addresses for each UART */
1066 res = platform_get_resource(platdev, IORESOURCE_MEM, 0);
1068 printk(KERN_ERR "failed to find memory resource for uart\n");
1072 dbg("resource %p (%lx..%lx)\n", res, res->start, res->end);
1074 port->mapbase = res->start;
1075 port->membase = S3C24XX_VA_UART + (res->start - S3C2410_PA_UART);
1076 port->irq = platform_get_irq(platdev, 0);
1078 ourport->clk = clk_get(&platdev->dev, "uart");
1080 if (ourport->clk != NULL && !IS_ERR(ourport->clk))
1081 clk_use(ourport->clk);
1083 dbg("port: map=%08x, mem=%08x, irq=%d, clock=%ld\n",
1084 port->mapbase, port->membase, port->irq, port->uartclk);
1086 /* reset the fifos (and setup the uart) */
1087 s3c24xx_serial_resetport(port, cfg);
1091 /* Device driver serial port probe */
1093 static int probe_index = 0;
1095 static int s3c24xx_serial_probe(struct device *_dev,
1096 struct s3c24xx_uart_info *info)
1098 struct s3c24xx_uart_port *ourport;
1099 struct platform_device *dev = to_platform_device(_dev);
1102 dbg("s3c24xx_serial_probe(%p, %p) %d\n", _dev, info, probe_index);
1104 ourport = &s3c24xx_serial_ports[probe_index];
1107 dbg("%s: initialising port %p...\n", __FUNCTION__, ourport);
1109 ret = s3c24xx_serial_init_port(ourport, info, dev);
1113 dbg("%s: adding port\n", __FUNCTION__);
1114 uart_add_one_port(&s3c24xx_uart_drv, &ourport->port);
1115 dev_set_drvdata(_dev, &ourport->port);
1123 static int s3c24xx_serial_remove(struct device *_dev)
1125 struct uart_port *port = s3c24xx_dev_to_port(_dev);
1128 uart_remove_one_port(&s3c24xx_uart_drv, port);
1133 /* UART power management code */
1137 static int s3c24xx_serial_suspend(struct device *dev, pm_message_t state,
1140 struct uart_port *port = s3c24xx_dev_to_port(dev);
1142 if (port && level == SUSPEND_DISABLE)
1143 uart_suspend_port(&s3c24xx_uart_drv, port);
1148 static int s3c24xx_serial_resume(struct device *dev, u32 level)
1150 struct uart_port *port = s3c24xx_dev_to_port(dev);
1151 struct s3c24xx_uart_port *ourport = to_ourport(port);
1153 if (port && level == RESUME_ENABLE) {
1154 clk_enable(ourport->clk);
1155 s3c24xx_serial_resetport(port, s3c24xx_port_to_cfg(port));
1156 clk_disable(ourport->clk);
1158 uart_resume_port(&s3c24xx_uart_drv, port);
1165 #define s3c24xx_serial_suspend NULL
1166 #define s3c24xx_serial_resume NULL
1169 static int s3c24xx_serial_init(struct device_driver *drv,
1170 struct s3c24xx_uart_info *info)
1172 dbg("s3c24xx_serial_init(%p,%p)\n", drv, info);
1173 return driver_register(drv);
1177 /* now comes the code to initialise either the s3c2410 or s3c2440 serial
1181 /* cpu specific variations on the serial port support */
1183 #ifdef CONFIG_CPU_S3C2400
1185 static int s3c2400_serial_getsource(struct uart_port *port,
1186 struct s3c24xx_uart_clksrc *clk)
1194 static int s3c2400_serial_setsource(struct uart_port *port,
1195 struct s3c24xx_uart_clksrc *clk)
1200 static int s3c2400_serial_resetport(struct uart_port *port,
1201 struct s3c2410_uartcfg *cfg)
1203 dbg("s3c2400_serial_resetport: port=%p (%08lx), cfg=%p\n",
1204 port, port->mapbase, cfg);
1206 wr_regl(port, S3C2410_UCON, cfg->ucon);
1207 wr_regl(port, S3C2410_ULCON, cfg->ulcon);
1209 /* reset both fifos */
1211 wr_regl(port, S3C2410_UFCON, cfg->ufcon | S3C2410_UFCON_RESETBOTH);
1212 wr_regl(port, S3C2410_UFCON, cfg->ufcon);
1217 static struct s3c24xx_uart_info s3c2400_uart_inf = {
1218 .name = "Samsung S3C2400 UART",
1219 .type = PORT_S3C2400,
1221 .rx_fifomask = S3C2410_UFSTAT_RXMASK,
1222 .rx_fifoshift = S3C2410_UFSTAT_RXSHIFT,
1223 .rx_fifofull = S3C2410_UFSTAT_RXFULL,
1224 .tx_fifofull = S3C2410_UFSTAT_TXFULL,
1225 .tx_fifomask = S3C2410_UFSTAT_TXMASK,
1226 .tx_fifoshift = S3C2410_UFSTAT_TXSHIFT,
1227 .get_clksrc = s3c2400_serial_getsource,
1228 .set_clksrc = s3c2400_serial_setsource,
1229 .reset_port = s3c2400_serial_resetport,
1232 static int s3c2400_serial_probe(struct device *dev)
1234 return s3c24xx_serial_probe(dev, &s3c2400_uart_inf);
1237 static struct device_driver s3c2400_serial_drv = {
1238 .name = "s3c2400-uart",
1239 .owner = THIS_MODULE,
1240 .bus = &platform_bus_type,
1241 .probe = s3c2400_serial_probe,
1242 .remove = s3c24xx_serial_remove,
1243 .suspend = s3c24xx_serial_suspend,
1244 .resume = s3c24xx_serial_resume,
1247 static inline int s3c2400_serial_init(void)
1249 return s3c24xx_serial_init(&s3c2400_serial_drv, &s3c2400_uart_inf);
1252 static inline void s3c2400_serial_exit(void)
1254 driver_unregister(&s3c2400_serial_drv);
1257 #define s3c2400_uart_inf_at &s3c2400_uart_inf
1260 static inline int s3c2400_serial_init(void)
1265 static inline void s3c2400_serial_exit(void)
1269 #define s3c2400_uart_inf_at NULL
1271 #endif /* CONFIG_CPU_S3C2400 */
1273 /* S3C2410 support */
1275 #ifdef CONFIG_CPU_S3C2410
1277 static int s3c2410_serial_setsource(struct uart_port *port,
1278 struct s3c24xx_uart_clksrc *clk)
1280 unsigned long ucon = rd_regl(port, S3C2410_UCON);
1282 if (strcmp(clk->name, "uclk") == 0)
1283 ucon |= S3C2410_UCON_UCLK;
1285 ucon &= ~S3C2410_UCON_UCLK;
1287 wr_regl(port, S3C2410_UCON, ucon);
1291 static int s3c2410_serial_getsource(struct uart_port *port,
1292 struct s3c24xx_uart_clksrc *clk)
1294 unsigned long ucon = rd_regl(port, S3C2410_UCON);
1297 clk->name = (ucon & S3C2410_UCON_UCLK) ? "uclk" : "pclk";
1302 static int s3c2410_serial_resetport(struct uart_port *port,
1303 struct s3c2410_uartcfg *cfg)
1305 dbg("s3c2410_serial_resetport: port=%p (%08lx), cfg=%p\n",
1306 port, port->mapbase, cfg);
1308 wr_regl(port, S3C2410_UCON, cfg->ucon);
1309 wr_regl(port, S3C2410_ULCON, cfg->ulcon);
1311 /* reset both fifos */
1313 wr_regl(port, S3C2410_UFCON, cfg->ufcon | S3C2410_UFCON_RESETBOTH);
1314 wr_regl(port, S3C2410_UFCON, cfg->ufcon);
1319 static struct s3c24xx_uart_info s3c2410_uart_inf = {
1320 .name = "Samsung S3C2410 UART",
1321 .type = PORT_S3C2410,
1323 .rx_fifomask = S3C2410_UFSTAT_RXMASK,
1324 .rx_fifoshift = S3C2410_UFSTAT_RXSHIFT,
1325 .rx_fifofull = S3C2410_UFSTAT_RXFULL,
1326 .tx_fifofull = S3C2410_UFSTAT_TXFULL,
1327 .tx_fifomask = S3C2410_UFSTAT_TXMASK,
1328 .tx_fifoshift = S3C2410_UFSTAT_TXSHIFT,
1329 .get_clksrc = s3c2410_serial_getsource,
1330 .set_clksrc = s3c2410_serial_setsource,
1331 .reset_port = s3c2410_serial_resetport,
1334 /* device management */
1336 static int s3c2410_serial_probe(struct device *dev)
1338 return s3c24xx_serial_probe(dev, &s3c2410_uart_inf);
1341 static struct device_driver s3c2410_serial_drv = {
1342 .name = "s3c2410-uart",
1343 .owner = THIS_MODULE,
1344 .bus = &platform_bus_type,
1345 .probe = s3c2410_serial_probe,
1346 .remove = s3c24xx_serial_remove,
1347 .suspend = s3c24xx_serial_suspend,
1348 .resume = s3c24xx_serial_resume,
1351 static inline int s3c2410_serial_init(void)
1353 return s3c24xx_serial_init(&s3c2410_serial_drv, &s3c2410_uart_inf);
1356 static inline void s3c2410_serial_exit(void)
1358 driver_unregister(&s3c2410_serial_drv);
1361 #define s3c2410_uart_inf_at &s3c2410_uart_inf
1364 static inline int s3c2410_serial_init(void)
1369 static inline void s3c2410_serial_exit(void)
1373 #define s3c2410_uart_inf_at NULL
1375 #endif /* CONFIG_CPU_S3C2410 */
1377 #ifdef CONFIG_CPU_S3C2440
1379 static int s3c2440_serial_setsource(struct uart_port *port,
1380 struct s3c24xx_uart_clksrc *clk)
1382 unsigned long ucon = rd_regl(port, S3C2410_UCON);
1384 // todo - proper fclk<>nonfclk switch //
1386 ucon &= ~S3C2440_UCON_CLKMASK;
1388 if (strcmp(clk->name, "uclk") == 0)
1389 ucon |= S3C2440_UCON_UCLK;
1390 else if (strcmp(clk->name, "pclk") == 0)
1391 ucon |= S3C2440_UCON_PCLK;
1392 else if (strcmp(clk->name, "fclk") == 0)
1393 ucon |= S3C2440_UCON_FCLK;
1395 printk(KERN_ERR "unknown clock source %s\n", clk->name);
1399 wr_regl(port, S3C2410_UCON, ucon);
1404 static int s3c2440_serial_getsource(struct uart_port *port,
1405 struct s3c24xx_uart_clksrc *clk)
1407 unsigned long ucon = rd_regl(port, S3C2410_UCON);
1408 unsigned long ucon0, ucon1, ucon2;
1410 switch (ucon & S3C2440_UCON_CLKMASK) {
1411 case S3C2440_UCON_UCLK:
1416 case S3C2440_UCON_PCLK:
1417 case S3C2440_UCON_PCLK2:
1422 case S3C2440_UCON_FCLK:
1423 /* the fun of calculating the uart divisors on
1426 ucon0 = __raw_readl(S3C24XX_VA_UART0 + S3C2410_UCON);
1427 ucon1 = __raw_readl(S3C24XX_VA_UART1 + S3C2410_UCON);
1428 ucon2 = __raw_readl(S3C24XX_VA_UART2 + S3C2410_UCON);
1430 printk("ucons: %08lx, %08lx, %08lx\n", ucon0, ucon1, ucon2);
1432 ucon0 &= S3C2440_UCON0_DIVMASK;
1433 ucon1 &= S3C2440_UCON1_DIVMASK;
1434 ucon2 &= S3C2440_UCON2_DIVMASK;
1437 clk->divisor = ucon0 >> S3C2440_UCON_DIVSHIFT;
1439 } else if (ucon1 != 0) {
1440 clk->divisor = ucon1 >> S3C2440_UCON_DIVSHIFT;
1442 } else if (ucon2 != 0) {
1443 clk->divisor = ucon2 >> S3C2440_UCON_DIVSHIFT;
1446 /* manual calims 44, seems to be 9 */
1457 static int s3c2440_serial_resetport(struct uart_port *port,
1458 struct s3c2410_uartcfg *cfg)
1460 unsigned long ucon = rd_regl(port, S3C2410_UCON);
1462 dbg("s3c2440_serial_resetport: port=%p (%08lx), cfg=%p\n",
1463 port, port->mapbase, cfg);
1465 /* ensure we don't change the clock settings... */
1467 ucon &= (S3C2440_UCON0_DIVMASK | (3<<10));
1469 wr_regl(port, S3C2410_UCON, ucon | cfg->ucon);
1470 wr_regl(port, S3C2410_ULCON, cfg->ulcon);
1472 /* reset both fifos */
1474 wr_regl(port, S3C2410_UFCON, cfg->ufcon | S3C2410_UFCON_RESETBOTH);
1475 wr_regl(port, S3C2410_UFCON, cfg->ufcon);
1480 static struct s3c24xx_uart_info s3c2440_uart_inf = {
1481 .name = "Samsung S3C2440 UART",
1482 .type = PORT_S3C2440,
1484 .rx_fifomask = S3C2440_UFSTAT_RXMASK,
1485 .rx_fifoshift = S3C2440_UFSTAT_RXSHIFT,
1486 .rx_fifofull = S3C2440_UFSTAT_RXFULL,
1487 .tx_fifofull = S3C2440_UFSTAT_TXFULL,
1488 .tx_fifomask = S3C2440_UFSTAT_TXMASK,
1489 .tx_fifoshift = S3C2440_UFSTAT_TXSHIFT,
1490 .get_clksrc = s3c2440_serial_getsource,
1491 .set_clksrc = s3c2440_serial_setsource,
1492 .reset_port = s3c2440_serial_resetport,
1495 /* device management */
1497 static int s3c2440_serial_probe(struct device *dev)
1499 dbg("s3c2440_serial_probe: dev=%p\n", dev);
1500 return s3c24xx_serial_probe(dev, &s3c2440_uart_inf);
1503 static struct device_driver s3c2440_serial_drv = {
1504 .name = "s3c2440-uart",
1505 .owner = THIS_MODULE,
1506 .bus = &platform_bus_type,
1507 .probe = s3c2440_serial_probe,
1508 .remove = s3c24xx_serial_remove,
1509 .suspend = s3c24xx_serial_suspend,
1510 .resume = s3c24xx_serial_resume,
1514 static inline int s3c2440_serial_init(void)
1516 return s3c24xx_serial_init(&s3c2440_serial_drv, &s3c2440_uart_inf);
1519 static inline void s3c2440_serial_exit(void)
1521 driver_unregister(&s3c2440_serial_drv);
1524 #define s3c2440_uart_inf_at &s3c2440_uart_inf
1527 static inline int s3c2440_serial_init(void)
1532 static inline void s3c2440_serial_exit(void)
1536 #define s3c2440_uart_inf_at NULL
1537 #endif /* CONFIG_CPU_S3C2440 */
1539 /* module initialisation code */
1541 static int __init s3c24xx_serial_modinit(void)
1545 ret = uart_register_driver(&s3c24xx_uart_drv);
1547 printk(KERN_ERR "failed to register UART driver\n");
1551 s3c2400_serial_init();
1552 s3c2410_serial_init();
1553 s3c2440_serial_init();
1558 static void __exit s3c24xx_serial_modexit(void)
1560 s3c2400_serial_exit();
1561 s3c2410_serial_exit();
1562 s3c2440_serial_exit();
1564 uart_unregister_driver(&s3c24xx_uart_drv);
1568 module_init(s3c24xx_serial_modinit);
1569 module_exit(s3c24xx_serial_modexit);
1573 #ifdef CONFIG_SERIAL_S3C2410_CONSOLE
1575 static struct uart_port *cons_uart;
1578 s3c24xx_serial_console_txrdy(struct uart_port *port, unsigned int ufcon)
1580 struct s3c24xx_uart_info *info = s3c24xx_port_to_info(port);
1581 unsigned long ufstat, utrstat;
1583 if (ufcon & S3C2410_UFCON_FIFOMODE) {
1584 /* fifo mode - check ammount of data in fifo registers... */
1586 ufstat = rd_regl(port, S3C2410_UFSTAT);
1587 return (ufstat & info->tx_fifofull) ? 0 : 1;
1590 /* in non-fifo mode, we go and use the tx buffer empty */
1592 utrstat = rd_regl(port, S3C2410_UTRSTAT);
1593 return (utrstat & S3C2410_UTRSTAT_TXE) ? 1 : 0;
1597 s3c24xx_serial_console_write(struct console *co, const char *s,
1601 unsigned int ufcon = rd_regl(cons_uart, S3C2410_UFCON);
1603 for (i = 0; i < count; i++) {
1604 while (!s3c24xx_serial_console_txrdy(cons_uart, ufcon))
1607 wr_regb(cons_uart, S3C2410_UTXH, s[i]);
1610 while (!s3c24xx_serial_console_txrdy(cons_uart, ufcon))
1613 wr_regb(cons_uart, S3C2410_UTXH, '\r');
1619 s3c24xx_serial_get_options(struct uart_port *port, int *baud,
1620 int *parity, int *bits)
1622 struct s3c24xx_uart_clksrc clksrc;
1626 unsigned int ubrdiv;
1629 ulcon = rd_regl(port, S3C2410_ULCON);
1630 ucon = rd_regl(port, S3C2410_UCON);
1631 ubrdiv = rd_regl(port, S3C2410_UBRDIV);
1633 dbg("s3c24xx_serial_get_options: port=%p\n"
1634 "registers: ulcon=%08x, ucon=%08x, ubdriv=%08x\n",
1635 port, ulcon, ucon, ubrdiv);
1637 if ((ucon & 0xf) != 0) {
1638 /* consider the serial port configured if the tx/rx mode set */
1640 switch (ulcon & S3C2410_LCON_CSMASK) {
1641 case S3C2410_LCON_CS5:
1644 case S3C2410_LCON_CS6:
1647 case S3C2410_LCON_CS7:
1651 case S3C2410_LCON_CS8:
1656 switch (ulcon & S3C2410_LCON_PMASK) {
1657 case S3C2410_LCON_PEVEN:
1661 case S3C2410_LCON_PODD:
1665 case S3C2410_LCON_PNONE:
1670 /* now calculate the baud rate */
1672 s3c24xx_serial_getsource(port, &clksrc);
1674 clk = clk_get(port->dev, clksrc.name);
1675 if (!IS_ERR(clk) && clk != NULL)
1676 rate = clk_get_rate(clk) / clksrc.divisor;
1681 *baud = rate / ( 16 * (ubrdiv + 1));
1682 dbg("calculated baud %d\n", *baud);
1687 /* s3c24xx_serial_init_ports
1689 * initialise the serial ports from the machine provided initialisation
1693 static int s3c24xx_serial_init_ports(struct s3c24xx_uart_info *info)
1695 struct s3c24xx_uart_port *ptr = s3c24xx_serial_ports;
1696 struct platform_device **platdev_ptr;
1699 dbg("s3c24xx_serial_init_ports: initialising ports...\n");
1701 platdev_ptr = s3c24xx_uart_devs;
1703 for (i = 0; i < NR_PORTS; i++, ptr++, platdev_ptr++) {
1704 s3c24xx_serial_init_port(ptr, info, *platdev_ptr);
1711 s3c24xx_serial_console_setup(struct console *co, char *options)
1713 struct uart_port *port;
1719 dbg("s3c24xx_serial_console_setup: co=%p (%d), %s\n",
1720 co, co->index, options);
1722 /* is this a valid port */
1724 if (co->index == -1 || co->index >= NR_PORTS)
1727 port = &s3c24xx_serial_ports[co->index].port;
1729 /* is the port configured? */
1731 if (port->mapbase == 0x0) {
1733 port = &s3c24xx_serial_ports[co->index].port;
1738 dbg("s3c24xx_serial_console_setup: port=%p (%d)\n", port, co->index);
1741 * Check whether an invalid uart number has been specified, and
1742 * if so, search for the first available port that does have
1746 uart_parse_options(options, &baud, &parity, &bits, &flow);
1748 s3c24xx_serial_get_options(port, &baud, &parity, &bits);
1750 dbg("s3c24xx_serial_console_setup: baud %d\n", baud);
1752 return uart_set_options(port, co, baud, parity, bits, flow);
1755 /* s3c24xx_serial_initconsole
1757 * initialise the console from one of the uart drivers
1760 static struct console s3c24xx_serial_console =
1762 .name = S3C24XX_SERIAL_NAME,
1763 .device = uart_console_device,
1764 .flags = CON_PRINTBUFFER,
1766 .write = s3c24xx_serial_console_write,
1767 .setup = s3c24xx_serial_console_setup
1770 static int s3c24xx_serial_initconsole(void)
1772 struct s3c24xx_uart_info *info;
1773 struct platform_device *dev = s3c24xx_uart_devs[0];
1775 dbg("s3c24xx_serial_initconsole\n");
1777 /* select driver based on the cpu */
1780 printk(KERN_ERR "s3c24xx: no devices for console init\n");
1784 if (strcmp(dev->name, "s3c2400-uart") == 0) {
1785 info = s3c2400_uart_inf_at;
1786 } else if (strcmp(dev->name, "s3c2410-uart") == 0) {
1787 info = s3c2410_uart_inf_at;
1788 } else if (strcmp(dev->name, "s3c2440-uart") == 0) {
1789 info = s3c2440_uart_inf_at;
1791 printk(KERN_ERR "s3c24xx: no driver for %s\n", dev->name);
1796 printk(KERN_ERR "s3c24xx: no driver for console\n");
1800 s3c24xx_serial_console.data = &s3c24xx_uart_drv;
1801 s3c24xx_serial_init_ports(info);
1803 register_console(&s3c24xx_serial_console);
1807 console_initcall(s3c24xx_serial_initconsole);
1809 #endif /* CONFIG_SERIAL_S3C2410_CONSOLE */
1811 MODULE_LICENSE("GPL");
1812 MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
1813 MODULE_DESCRIPTION("Samsung S3C2410/S3C2440 Serial port driver");