2 * drivers/serial/sh-sci.c
4 * SuperH on-chip serial module support. (SCI with no FIFO / with FIFO)
6 * Copyright (C) 2002, 2003, 2004 Paul Mundt
8 * based off of the old drivers/char/sh-sci.c by:
10 * Copyright (C) 1999, 2000 Niibe Yutaka
11 * Copyright (C) 2000 Sugioka Toshinobu
12 * Modified to support multiple serial ports. Stuart Menefy (May 2000).
13 * Modified to support SecureEdge. David McCullough (2002)
14 * Modified to support SH7300 SCIF. Takashi Kusuda (Jun 2003).
16 * This file is subject to the terms and conditions of the GNU General Public
17 * License. See the file "COPYING" in the main directory of this archive
23 #include <linux/config.h>
24 #include <linux/module.h>
25 #include <linux/errno.h>
26 #include <linux/signal.h>
27 #include <linux/sched.h>
28 #include <linux/timer.h>
29 #include <linux/interrupt.h>
30 #include <linux/tty.h>
31 #include <linux/tty_flip.h>
32 #include <linux/serial.h>
33 #include <linux/major.h>
34 #include <linux/string.h>
35 #include <linux/sysrq.h>
36 #include <linux/fcntl.h>
37 #include <linux/ptrace.h>
38 #include <linux/ioport.h>
40 #include <linux/slab.h>
41 #include <linux/init.h>
42 #include <linux/delay.h>
43 #include <linux/console.h>
44 #include <linux/bitops.h>
46 #ifdef CONFIG_CPU_FREQ
47 #include <linux/notifier.h>
48 #include <linux/cpufreq.h>
51 #include <asm/system.h>
54 #include <asm/uaccess.h>
56 #include <linux/generic_serial.h>
58 #ifdef CONFIG_SH_STANDARD_BIOS
59 #include <asm/sh_bios.h>
62 #if defined(CONFIG_SERIAL_SH_SCI_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
71 static int kgdb_get_char(struct sci_port
*port
);
72 static void kgdb_put_char(struct sci_port
*port
, char c
);
73 static void kgdb_handle_error(struct sci_port
*port
);
74 static struct sci_port
*kgdb_sci_port
;
75 #endif /* CONFIG_SH_KGDB */
77 #ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
78 static struct sci_port
*serial_console_port
= 0;
79 #endif /* CONFIG_SERIAL_SH_SCI_CONSOLE */
81 /* Function prototypes */
82 static void sci_stop_tx(struct uart_port
*port
);
83 static void sci_start_tx(struct uart_port
*port
);
84 static void sci_start_rx(struct uart_port
*port
, unsigned int tty_start
);
85 static void sci_stop_rx(struct uart_port
*port
);
86 static int sci_request_irq(struct sci_port
*port
);
87 static void sci_free_irq(struct sci_port
*port
);
89 static struct sci_port sci_ports
[SCI_NPORTS
];
90 static struct uart_driver sci_uart_driver
;
92 #if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
94 static void handle_error(struct uart_port
*port
)
95 { /* Clear error flags */
96 sci_out(port
, SCxSR
, SCxSR_ERROR_CLEAR(port
));
99 static int get_char(struct uart_port
*port
)
102 unsigned short status
;
105 local_irq_save(flags
);
107 status
= sci_in(port
, SCxSR
);
108 if (status
& SCxSR_ERRORS(port
)) {
112 } while (!(status
& SCxSR_RDxF(port
)));
113 c
= sci_in(port
, SCxRDR
);
114 sci_in(port
, SCxSR
); /* Dummy read */
115 sci_out(port
, SCxSR
, SCxSR_RDxF_CLEAR(port
));
116 local_irq_restore(flags
);
121 /* Taken from sh-stub.c of GDB 4.18 */
122 static const char hexchars
[] = "0123456789abcdef";
124 static __inline__
char highhex(int x
)
126 return hexchars
[(x
>> 4) & 0xf];
129 static __inline__
char lowhex(int x
)
131 return hexchars
[x
& 0xf];
134 #endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_SH_KGDB */
137 * Send the packet in buffer. The host gets one chance to read it.
138 * This routine does not wait for a positive acknowledge.
141 #ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
142 static void put_char(struct uart_port
*port
, char c
)
145 unsigned short status
;
147 local_irq_save(flags
);
150 status
= sci_in(port
, SCxSR
);
151 } while (!(status
& SCxSR_TDxE(port
)));
153 sci_out(port
, SCxTDR
, c
);
154 sci_in(port
, SCxSR
); /* Dummy read */
155 sci_out(port
, SCxSR
, SCxSR_TDxE_CLEAR(port
));
157 local_irq_restore(flags
);
160 static void put_string(struct sci_port
*sci_port
, const char *buffer
, int count
)
162 struct uart_port
*port
= &sci_port
->port
;
163 const unsigned char *p
= buffer
;
166 #if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
170 #ifdef CONFIG_SH_STANDARD_BIOS
171 /* This call only does a trap the first time it is
172 * called, and so is safe to do here unconditionally
174 usegdb
|= sh_bios_in_gdb_mode();
176 #ifdef CONFIG_SH_KGDB
177 usegdb
|= (kgdb_in_gdb_mode
&& (port
== kgdb_sci_port
));
181 /* $<packet info>#<checksum>. */
185 put_char(port
, 'O'); /* 'O'utput to console */
188 for (i
=0; i
<count
; i
++) { /* Don't use run length encoding */
199 put_char(port
, highhex(checksum
));
200 put_char(port
, lowhex(checksum
));
201 } while (get_char(port
) != '+');
203 #endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_SH_KGDB */
204 for (i
=0; i
<count
; i
++) {
206 put_char(port
, '\r');
207 put_char(port
, *p
++);
210 #endif /* CONFIG_SERIAL_SH_SCI_CONSOLE */
213 #ifdef CONFIG_SH_KGDB
215 /* Is the SCI ready, ie is there a char waiting? */
216 static int kgdb_is_char_ready(struct sci_port
*port
)
218 unsigned short status
= sci_in(port
, SCxSR
);
220 if (status
& (SCxSR_ERRORS(port
) | SCxSR_BRK(port
)))
221 kgdb_handle_error(port
);
223 return (status
& SCxSR_RDxF(port
));
227 static void kgdb_put_char(struct sci_port
*port
, char c
)
229 unsigned short status
;
232 status
= sci_in(port
, SCxSR
);
233 while (!(status
& SCxSR_TDxE(port
)));
235 sci_out(port
, SCxTDR
, c
);
236 sci_in(port
, SCxSR
); /* Dummy read */
237 sci_out(port
, SCxSR
, SCxSR_TDxE_CLEAR(port
));
240 /* Get a char if there is one, else ret -1 */
241 static int kgdb_get_char(struct sci_port
*port
)
245 if (kgdb_is_char_ready(port
) == 0)
248 c
= sci_in(port
, SCxRDR
);
249 sci_in(port
, SCxSR
); /* Dummy read */
250 sci_out(port
, SCxSR
, SCxSR_RDxF_CLEAR(port
));
256 /* Called from kgdbstub.c to get a character, i.e. is blocking */
257 static int kgdb_sci_getchar(void)
261 /* Keep trying to read a character, this could be neater */
262 while ((c
= kgdb_get_char(kgdb_sci_port
)) < 0);
267 /* Called from kgdbstub.c to put a character, just a wrapper */
268 static void kgdb_sci_putchar(int c
)
271 kgdb_put_char(kgdb_sci_port
, c
);
274 /* Clear any errors on the SCI */
275 static void kgdb_handle_error(struct sci_port
*port
)
277 sci_out(port
, SCxSR
, SCxSR_ERROR_CLEAR(port
)); /* Clear error flags */
280 /* Breakpoint if there's a break sent on the serial port */
281 static void kgdb_break_interrupt(int irq
, void *ptr
, struct pt_regs
*regs
)
283 struct sci_port
*port
= ptr
;
284 unsigned short status
= sci_in(port
, SCxSR
);
286 if (status
& SCxSR_BRK(port
)) {
288 /* Break into the debugger if a break is detected */
292 sci_out(port
, SCxSR
, SCxSR_BREAK_CLEAR(port
));
296 #endif /* CONFIG_SH_KGDB */
298 #if defined(__H8300S__)
299 enum { sci_disable
, sci_enable
};
301 static void h8300_sci_enable(struct uart_port
* port
, unsigned int ctrl
)
303 volatile unsigned char *mstpcrl
=(volatile unsigned char *)MSTPCRL
;
304 int ch
= (port
->mapbase
- SMR0
) >> 3;
305 unsigned char mask
= 1 << (ch
+1);
307 if (ctrl
== sci_disable
) {
315 #if defined(SCI_ONLY) || defined(SCI_AND_SCIF)
316 #if defined(__H8300H__) || defined(__H8300S__)
317 static void sci_init_pins_sci(struct uart_port
* port
, unsigned int cflag
)
319 int ch
= (port
->mapbase
- SMR0
) >> 3;
322 H8300_GPIO_DDR(h8300_sci_pins
[ch
].port
,h8300_sci_pins
[ch
].rx
,H8300_GPIO_INPUT
);
323 H8300_GPIO_DDR(h8300_sci_pins
[ch
].port
,h8300_sci_pins
[ch
].tx
,H8300_GPIO_OUTPUT
);
325 H8300_SCI_DR(ch
) |= h8300_sci_pins
[ch
].tx
;
328 static void sci_init_pins_sci(struct uart_port
*port
, unsigned int cflag
)
334 #if defined(SCIF_ONLY) || defined(SCI_AND_SCIF)
335 #if defined(CONFIG_CPU_SH3)
336 /* For SH7705, SH7707, SH7709, SH7709A, SH7729, SH7300*/
337 static void sci_init_pins_scif(struct uart_port
*port
, unsigned int cflag
)
339 unsigned int fcr_val
= 0;
340 #if !defined(CONFIG_CPU_SUBTYPE_SH7300) /* SH7300 doesn't use RTS/CTS */
344 /* We need to set SCPCR to enable RTS/CTS */
345 data
= ctrl_inw(SCPCR
);
346 /* Clear out SCP7MD1,0, SCP6MD1,0, SCP4MD1,0*/
347 ctrl_outw(data
&0x0fcf, SCPCR
);
350 fcr_val
|= SCFCR_MCE
;
354 /* We need to set SCPCR to enable RTS/CTS */
355 data
= ctrl_inw(SCPCR
);
356 /* Clear out SCP7MD1,0, SCP4MD1,0,
357 Set SCP6MD1,0 = {01} (output) */
358 ctrl_outw((data
&0x0fcf)|0x1000, SCPCR
);
360 data
= ctrl_inb(SCPDR
);
361 /* Set /RTS2 (bit6) = 0 */
362 ctrl_outb(data
&0xbf, SCPDR
);
365 sci_out(port
, SCFCR
, fcr_val
);
368 static void sci_init_pins_irda(struct uart_port
*port
, unsigned int cflag
)
370 unsigned int fcr_val
= 0;
373 fcr_val
|= SCFCR_MCE
;
375 sci_out(port
, SCFCR
, fcr_val
);
381 static void sci_init_pins_scif(struct uart_port
*port
, unsigned int cflag
)
383 unsigned int fcr_val
= 0;
385 if (cflag
& CRTSCTS
) {
386 fcr_val
|= SCFCR_MCE
;
388 ctrl_outw(0x0080, SCSPTR2
); /* Set RTS = 1 */
390 sci_out(port
, SCFCR
, fcr_val
);
394 #endif /* SCIF_ONLY || SCI_AND_SCIF */
396 /* ********************************************************************** *
397 * the interrupt related routines *
398 * ********************************************************************** */
400 static void sci_transmit_chars(struct uart_port
*port
)
402 struct circ_buf
*xmit
= &port
->info
->xmit
;
403 unsigned int stopped
= uart_tx_stopped(port
);
405 unsigned short status
;
409 status
= sci_in(port
, SCxSR
);
410 if (!(status
& SCxSR_TDxE(port
))) {
411 local_irq_save(flags
);
412 ctrl
= sci_in(port
, SCSCR
);
413 if (uart_circ_empty(xmit
)) {
414 ctrl
&= ~SCI_CTRL_FLAGS_TIE
;
416 ctrl
|= SCI_CTRL_FLAGS_TIE
;
418 sci_out(port
, SCSCR
, ctrl
);
419 local_irq_restore(flags
);
423 #if !defined(SCI_ONLY)
424 if (port
->type
== PORT_SCIF
) {
425 txroom
= SCIF_TXROOM_MAX
- (sci_in(port
, SCFDR
)>>8);
427 txroom
= (sci_in(port
, SCxSR
) & SCI_TDRE
)?1:0;
430 txroom
= (sci_in(port
, SCxSR
) & SCI_TDRE
)?1:0;
441 } else if (!uart_circ_empty(xmit
) && !stopped
) {
442 c
= xmit
->buf
[xmit
->tail
];
443 xmit
->tail
= (xmit
->tail
+ 1) & (UART_XMIT_SIZE
- 1);
448 sci_out(port
, SCxTDR
, c
);
451 } while (--count
> 0);
453 sci_out(port
, SCxSR
, SCxSR_TDxE_CLEAR(port
));
455 if (uart_circ_chars_pending(xmit
) < WAKEUP_CHARS
)
456 uart_write_wakeup(port
);
457 if (uart_circ_empty(xmit
)) {
460 local_irq_save(flags
);
461 ctrl
= sci_in(port
, SCSCR
);
463 #if !defined(SCI_ONLY)
464 if (port
->type
== PORT_SCIF
) {
465 sci_in(port
, SCxSR
); /* Dummy read */
466 sci_out(port
, SCxSR
, SCxSR_TDxE_CLEAR(port
));
470 ctrl
|= SCI_CTRL_FLAGS_TIE
;
471 sci_out(port
, SCSCR
, ctrl
);
472 local_irq_restore(flags
);
476 /* On SH3, SCIF may read end-of-break as a space->mark char */
477 #define STEPFN(c) ({int __c=(c); (((__c-1)|(__c)) == -1); })
479 static inline void sci_receive_chars(struct uart_port
*port
,
480 struct pt_regs
*regs
)
482 struct tty_struct
*tty
= port
->info
->tty
;
483 int i
, count
, copied
= 0;
484 unsigned short status
;
486 status
= sci_in(port
, SCxSR
);
487 if (!(status
& SCxSR_RDxF(port
)))
491 #if !defined(SCI_ONLY)
492 if (port
->type
== PORT_SCIF
) {
493 count
= sci_in(port
, SCFDR
)&SCIF_RFDC_MASK
;
495 count
= (sci_in(port
, SCxSR
)&SCxSR_RDxF(port
))?1:0;
498 count
= (sci_in(port
, SCxSR
)&SCxSR_RDxF(port
))?1:0;
501 /* Don't copy more bytes than there is room for in the buffer */
502 if (tty
->flip
.count
+ count
> TTY_FLIPBUF_SIZE
)
503 count
= TTY_FLIPBUF_SIZE
- tty
->flip
.count
;
505 /* If for any reason we can't copy more data, we're done! */
509 if (port
->type
== PORT_SCI
) {
510 char c
= sci_in(port
, SCxRDR
);
511 if(((struct sci_port
*)port
)->break_flag
512 || uart_handle_sysrq_char(port
, c
, regs
)) {
515 tty
->flip
.char_buf_ptr
[0] = c
;
516 tty
->flip
.flag_buf_ptr
[0] = TTY_NORMAL
;
519 for (i
=0; i
<count
; i
++) {
520 char c
= sci_in(port
, SCxRDR
);
521 status
= sci_in(port
, SCxSR
);
522 #if defined(CONFIG_CPU_SH3)
523 /* Skip "chars" during break */
524 if (((struct sci_port
*)port
)->break_flag
) {
526 (status
& SCxSR_FER(port
))) {
530 /* Nonzero => end-of-break */
531 pr_debug("scif: debounce<%02x>\n", c
);
532 ((struct sci_port
*)port
)->break_flag
= 0;
538 #endif /* CONFIG_CPU_SH3 */
539 if (uart_handle_sysrq_char(port
, c
, regs
)) {
544 /* Store data and status */
545 tty
->flip
.char_buf_ptr
[i
] = c
;
546 if (status
&SCxSR_FER(port
)) {
547 tty
->flip
.flag_buf_ptr
[i
] = TTY_FRAME
;
548 pr_debug("sci: frame error\n");
549 } else if (status
&SCxSR_PER(port
)) {
550 tty
->flip
.flag_buf_ptr
[i
] = TTY_PARITY
;
551 pr_debug("sci: parity error\n");
553 tty
->flip
.flag_buf_ptr
[i
] = TTY_NORMAL
;
558 sci_in(port
, SCxSR
); /* dummy read */
559 sci_out(port
, SCxSR
, SCxSR_RDxF_CLEAR(port
));
561 /* Update the kernel buffer end */
562 tty
->flip
.count
+= count
;
563 tty
->flip
.char_buf_ptr
+= count
;
564 tty
->flip
.flag_buf_ptr
+= count
;
566 port
->icount
.rx
+= count
;
570 /* Tell the rest of the system the news. New characters! */
571 tty_flip_buffer_push(tty
);
573 sci_in(port
, SCxSR
); /* dummy read */
574 sci_out(port
, SCxSR
, SCxSR_RDxF_CLEAR(port
));
578 #define SCI_BREAK_JIFFIES (HZ/20)
579 /* The sci generates interrupts during the break,
580 * 1 per millisecond or so during the break period, for 9600 baud.
581 * So dont bother disabling interrupts.
582 * But dont want more than 1 break event.
583 * Use a kernel timer to periodically poll the rx line until
584 * the break is finished.
586 static void sci_schedule_break_timer(struct sci_port
*port
)
588 port
->break_timer
.expires
= jiffies
+ SCI_BREAK_JIFFIES
;
589 add_timer(&port
->break_timer
);
591 /* Ensure that two consecutive samples find the break over. */
592 static void sci_break_timer(unsigned long data
)
594 struct sci_port
* port
= (struct sci_port
*)data
;
595 if(sci_rxd_in(&port
->port
) == 0) {
596 port
->break_flag
= 1;
597 sci_schedule_break_timer(port
);
598 } else if(port
->break_flag
== 1){
600 port
->break_flag
= 2;
601 sci_schedule_break_timer(port
);
602 } else port
->break_flag
= 0;
605 static inline int sci_handle_errors(struct uart_port
*port
)
608 unsigned short status
= sci_in(port
, SCxSR
);
609 struct tty_struct
*tty
= port
->info
->tty
;
611 if (status
&SCxSR_ORER(port
) && tty
->flip
.count
<TTY_FLIPBUF_SIZE
) {
614 *tty
->flip
.flag_buf_ptr
++ = TTY_OVERRUN
;
615 pr_debug("sci: overrun error\n");
618 if (status
&SCxSR_FER(port
) && tty
->flip
.count
<TTY_FLIPBUF_SIZE
) {
619 if (sci_rxd_in(port
) == 0) {
620 /* Notify of BREAK */
621 struct sci_port
* sci_port
= (struct sci_port
*)port
;
622 if(!sci_port
->break_flag
) {
623 sci_port
->break_flag
= 1;
624 sci_schedule_break_timer((struct sci_port
*)port
);
625 /* Do sysrq handling. */
626 if(uart_handle_break(port
)) {
629 pr_debug("sci: BREAK detected\n");
631 *tty
->flip
.flag_buf_ptr
++ = TTY_BREAK
;
637 *tty
->flip
.flag_buf_ptr
++ = TTY_FRAME
;
638 pr_debug("sci: frame error\n");
642 if (status
&SCxSR_PER(port
) && tty
->flip
.count
<TTY_FLIPBUF_SIZE
) {
645 *tty
->flip
.flag_buf_ptr
++ = TTY_PARITY
;
646 pr_debug("sci: parity error\n");
650 tty
->flip
.count
+= copied
;
651 tty_flip_buffer_push(tty
);
657 static inline int sci_handle_breaks(struct uart_port
*port
)
660 unsigned short status
= sci_in(port
, SCxSR
);
661 struct tty_struct
*tty
= port
->info
->tty
;
662 struct sci_port
*s
= &sci_ports
[port
->line
];
664 if (!s
->break_flag
&& status
& SCxSR_BRK(port
) &&
665 tty
->flip
.count
< TTY_FLIPBUF_SIZE
) {
666 #if defined(CONFIG_CPU_SH3)
670 /* Notify of BREAK */
672 *tty
->flip
.flag_buf_ptr
++ = TTY_BREAK
;
673 pr_debug("sci: BREAK detected\n");
676 #if defined(SCIF_ORER)
677 /* XXX: Handle SCIF overrun error */
678 if (port
->type
== PORT_SCIF
&& (sci_in(port
, SCLSR
) & SCIF_ORER
) != 0) {
679 sci_out(port
, SCLSR
, 0);
680 if(tty
->flip
.count
<TTY_FLIPBUF_SIZE
) {
682 *tty
->flip
.flag_buf_ptr
++ = TTY_OVERRUN
;
683 pr_debug("sci: overrun error\n");
689 tty
->flip
.count
+= copied
;
690 tty_flip_buffer_push(tty
);
696 static irqreturn_t
sci_rx_interrupt(int irq
, void *ptr
, struct pt_regs
*regs
)
698 struct uart_port
*port
= ptr
;
700 /* I think sci_receive_chars has to be called irrespective
701 * of whether the I_IXOFF is set, otherwise, how is the interrupt
704 sci_receive_chars(port
, regs
);
709 static irqreturn_t
sci_tx_interrupt(int irq
, void *ptr
, struct pt_regs
*regs
)
711 struct uart_port
*port
= ptr
;
713 sci_transmit_chars(port
);
718 static irqreturn_t
sci_er_interrupt(int irq
, void *ptr
, struct pt_regs
*regs
)
720 struct uart_port
*port
= ptr
;
723 if (port
->type
== PORT_SCI
) {
724 if (sci_handle_errors(port
)) {
725 /* discard character in rx buffer */
727 sci_out(port
, SCxSR
, SCxSR_RDxF_CLEAR(port
));
730 #if defined(SCIF_ORER)
731 if((sci_in(port
, SCLSR
) & SCIF_ORER
) != 0) {
732 struct tty_struct
*tty
= port
->info
->tty
;
734 sci_out(port
, SCLSR
, 0);
735 if(tty
->flip
.count
<TTY_FLIPBUF_SIZE
) {
736 *tty
->flip
.flag_buf_ptr
++ = TTY_OVERRUN
;
738 tty_flip_buffer_push(tty
);
739 pr_debug("scif: overrun error\n");
743 sci_rx_interrupt(irq
, ptr
, regs
);
746 sci_out(port
, SCxSR
, SCxSR_ERROR_CLEAR(port
));
748 /* Kick the transmission */
749 sci_tx_interrupt(irq
, ptr
, regs
);
754 static irqreturn_t
sci_br_interrupt(int irq
, void *ptr
, struct pt_regs
*regs
)
756 struct uart_port
*port
= ptr
;
759 sci_handle_breaks(port
);
760 sci_out(port
, SCxSR
, SCxSR_BREAK_CLEAR(port
));
765 static irqreturn_t
sci_mpxed_interrupt(int irq
, void *ptr
, struct pt_regs
*regs
)
767 unsigned short ssr_status
, scr_status
;
768 struct uart_port
*port
= ptr
;
770 ssr_status
= sci_in(port
,SCxSR
);
771 scr_status
= sci_in(port
,SCSCR
);
774 if ((ssr_status
&0x0020) && (scr_status
&0x0080))
775 sci_tx_interrupt(irq
, ptr
, regs
);
777 if ((ssr_status
&0x0002) && (scr_status
&0x0040))
778 sci_rx_interrupt(irq
, ptr
, regs
);
779 /* Error Interrupt */
780 if ((ssr_status
&0x0080) && (scr_status
&0x0400))
781 sci_er_interrupt(irq
, ptr
, regs
);
782 /* Break Interrupt */
783 if ((ssr_status
&0x0010) && (scr_status
&0x0200))
784 sci_br_interrupt(irq
, ptr
, regs
);
789 #ifdef CONFIG_CPU_FREQ
791 * Here we define a transistion notifier so that we can update all of our
792 * ports' baud rate when the peripheral clock changes.
794 static int sci_notifier(struct notifier_block
*self
, unsigned long phase
, void *p
)
796 struct cpufreq_freqs
*freqs
= p
;
799 if ((phase
== CPUFREQ_POSTCHANGE
) ||
800 (phase
== CPUFREQ_RESUMECHANGE
)){
801 for (i
= 0; i
< SCI_NPORTS
; i
++) {
802 struct uart_port
*port
= &sci_ports
[i
].port
;
805 * Update the uartclk per-port if frequency has
806 * changed, since it will no longer necessarily be
807 * consistent with the old frequency.
809 * Really we want to be able to do something like
810 * uart_change_speed() or something along those lines
811 * here to implicitly reset the per-port baud rate..
813 * Clean this up later..
815 port
->uartclk
= current_cpu_data
.module_clock
* 16;
818 printk("%s: got a postchange notification for cpu %d (old %d, new %d)\n",
819 __FUNCTION__
, freqs
->cpu
, freqs
->old
, freqs
->new);
825 static struct notifier_block sci_nb
= { &sci_notifier
, NULL
, 0 };
826 #endif /* CONFIG_CPU_FREQ */
828 static int sci_request_irq(struct sci_port
*port
)
831 irqreturn_t (*handlers
[4])(int irq
, void *ptr
, struct pt_regs
*regs
) = {
832 sci_er_interrupt
, sci_rx_interrupt
, sci_tx_interrupt
,
835 const char *desc
[] = { "SCI Receive Error", "SCI Receive Data Full",
836 "SCI Transmit Data Empty", "SCI Break" };
838 if (port
->irqs
[0] == port
->irqs
[1]) {
839 if (!port
->irqs
[0]) {
840 printk(KERN_ERR
"sci: Cannot allocate irq.(IRQ=0)\n");
843 if (request_irq(port
->irqs
[0], sci_mpxed_interrupt
, SA_INTERRUPT
,
845 printk(KERN_ERR
"sci: Cannot allocate irq.\n");
849 for (i
= 0; i
< ARRAY_SIZE(handlers
); i
++) {
852 if (request_irq(port
->irqs
[i
], handlers
[i
], SA_INTERRUPT
,
854 printk(KERN_ERR
"sci: Cannot allocate irq.\n");
863 static void sci_free_irq(struct sci_port
*port
)
867 if (port
->irqs
[0] == port
->irqs
[1]) {
869 printk("sci: sci_free_irq error\n");
871 free_irq(port
->irqs
[0], port
);
873 for (i
= 0; i
< ARRAY_SIZE(port
->irqs
); i
++) {
877 free_irq(port
->irqs
[i
], port
);
882 static unsigned int sci_tx_empty(struct uart_port
*port
)
888 static void sci_set_mctrl(struct uart_port
*port
, unsigned int mctrl
)
890 /* This routine is used for seting signals of: DTR, DCD, CTS/RTS */
891 /* We use SCIF's hardware for CTS/RTS, so don't need any for that. */
892 /* If you have signals for DTR and DCD, please implement here. */
895 static unsigned int sci_get_mctrl(struct uart_port
*port
)
897 /* This routine is used for geting signals of: DTR, DCD, DSR, RI,
900 return TIOCM_DTR
| TIOCM_RTS
| TIOCM_DSR
;
903 static void sci_start_tx(struct uart_port
*port
)
905 struct sci_port
*s
= &sci_ports
[port
->line
];
907 disable_irq(s
->irqs
[SCIx_TXI_IRQ
]);
908 sci_transmit_chars(port
);
909 enable_irq(s
->irqs
[SCIx_TXI_IRQ
]);
912 static void sci_stop_tx(struct uart_port
*port
)
917 /* Clear TIE (Transmit Interrupt Enable) bit in SCSCR */
918 local_irq_save(flags
);
919 ctrl
= sci_in(port
, SCSCR
);
920 ctrl
&= ~SCI_CTRL_FLAGS_TIE
;
921 sci_out(port
, SCSCR
, ctrl
);
922 local_irq_restore(flags
);
925 static void sci_start_rx(struct uart_port
*port
, unsigned int tty_start
)
930 /* Set RIE (Receive Interrupt Enable) bit in SCSCR */
931 local_irq_save(flags
);
932 ctrl
= sci_in(port
, SCSCR
);
933 ctrl
|= SCI_CTRL_FLAGS_RIE
| SCI_CTRL_FLAGS_REIE
;
934 sci_out(port
, SCSCR
, ctrl
);
935 local_irq_restore(flags
);
938 static void sci_stop_rx(struct uart_port
*port
)
943 /* Clear RIE (Receive Interrupt Enable) bit in SCSCR */
944 local_irq_save(flags
);
945 ctrl
= sci_in(port
, SCSCR
);
946 ctrl
&= ~(SCI_CTRL_FLAGS_RIE
| SCI_CTRL_FLAGS_REIE
);
947 sci_out(port
, SCSCR
, ctrl
);
948 local_irq_restore(flags
);
951 static void sci_enable_ms(struct uart_port
*port
)
953 /* Nothing here yet .. */
956 static void sci_break_ctl(struct uart_port
*port
, int break_state
)
958 /* Nothing here yet .. */
961 static int sci_startup(struct uart_port
*port
)
963 struct sci_port
*s
= &sci_ports
[port
->line
];
965 #if defined(__H8300S__)
966 h8300_sci_enable(port
, sci_enable
);
970 sci_start_tx(port
, 1);
971 sci_start_rx(port
, 1);
976 static void sci_shutdown(struct uart_port
*port
)
978 struct sci_port
*s
= &sci_ports
[port
->line
];
984 #if defined(__H8300S__)
985 h8300_sci_enable(port
, sci_disable
);
989 static void sci_set_termios(struct uart_port
*port
, struct termios
*termios
,
992 struct sci_port
*s
= &sci_ports
[port
->line
];
993 unsigned int status
, baud
, smr_val
;
997 baud
= uart_get_baud_rate(port
, termios
, old
, 0, port
->uartclk
/16);
999 spin_lock_irqsave(&port
->lock
, flags
);
1002 status
= sci_in(port
, SCxSR
);
1003 } while (!(status
& SCxSR_TEND(port
)));
1005 sci_out(port
, SCSCR
, 0x00); /* TE=0, RE=0, CKE1=0 */
1007 #if !defined(SCI_ONLY)
1008 if (port
->type
== PORT_SCIF
) {
1009 sci_out(port
, SCFCR
, SCFCR_RFRST
| SCFCR_TFRST
);
1013 smr_val
= sci_in(port
, SCSMR
) & 3;
1014 if ((termios
->c_cflag
& CSIZE
) == CS7
)
1016 if (termios
->c_cflag
& PARENB
)
1018 if (termios
->c_cflag
& PARODD
)
1020 if (termios
->c_cflag
& CSTOPB
)
1023 uart_update_timeout(port
, termios
->c_cflag
, baud
);
1025 sci_out(port
, SCSMR
, smr_val
);
1028 case 0: t
= -1; break;
1029 case 2400: t
= BPS_2400
; break;
1030 case 4800: t
= BPS_4800
; break;
1031 case 9600: t
= BPS_9600
; break;
1032 case 19200: t
= BPS_19200
; break;
1033 case 38400: t
= BPS_38400
; break;
1034 case 57600: t
= BPS_57600
; break;
1035 case 115200: t
= BPS_115200
; break;
1036 default: t
= SCBRR_VALUE(baud
); break;
1041 sci_out(port
, SCSMR
, (sci_in(port
, SCSMR
) & ~3) | 1);
1044 sci_out(port
, SCSMR
, sci_in(port
, SCSMR
) & ~3);
1046 sci_out(port
, SCBRR
, t
);
1047 udelay((1000000+(baud
-1)) / baud
); /* Wait one bit interval */
1050 s
->init_pins(port
, termios
->c_cflag
);
1051 sci_out(port
, SCSCR
, SCSCR_INIT(port
));
1053 if ((termios
->c_cflag
& CREAD
) != 0)
1054 sci_start_rx(port
,0);
1056 spin_unlock_irqrestore(&port
->lock
, flags
);
1059 static const char *sci_type(struct uart_port
*port
)
1061 switch (port
->type
) {
1062 case PORT_SCI
: return "sci";
1063 case PORT_SCIF
: return "scif";
1064 case PORT_IRDA
: return "irda";
1070 static void sci_release_port(struct uart_port
*port
)
1072 /* Nothing here yet .. */
1075 static int sci_request_port(struct uart_port
*port
)
1077 /* Nothing here yet .. */
1081 static void sci_config_port(struct uart_port
*port
, int flags
)
1083 struct sci_port
*s
= &sci_ports
[port
->line
];
1085 port
->type
= s
->type
;
1087 #if defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103)
1088 if (port
->mapbase
== 0)
1089 port
->mapbase
= onchip_remap(SCIF_ADDR_SH5
, 1024, "SCIF");
1091 port
->membase
= (void *)port
->mapbase
;
1095 static int sci_verify_port(struct uart_port
*port
, struct serial_struct
*ser
)
1097 struct sci_port
*s
= &sci_ports
[port
->line
];
1099 if (ser
->irq
!= s
->irqs
[SCIx_TXI_IRQ
] || ser
->irq
> NR_IRQS
)
1101 if (ser
->baud_base
< 2400)
1102 /* No paper tape reader for Mitch.. */
1108 static struct uart_ops sci_uart_ops
= {
1109 .tx_empty
= sci_tx_empty
,
1110 .set_mctrl
= sci_set_mctrl
,
1111 .get_mctrl
= sci_get_mctrl
,
1112 .start_tx
= sci_start_tx
,
1113 .stop_tx
= sci_stop_tx
,
1114 .stop_rx
= sci_stop_rx
,
1115 .enable_ms
= sci_enable_ms
,
1116 .break_ctl
= sci_break_ctl
,
1117 .startup
= sci_startup
,
1118 .shutdown
= sci_shutdown
,
1119 .set_termios
= sci_set_termios
,
1121 .release_port
= sci_release_port
,
1122 .request_port
= sci_request_port
,
1123 .config_port
= sci_config_port
,
1124 .verify_port
= sci_verify_port
,
1127 static struct sci_port sci_ports
[SCI_NPORTS
] = {
1128 #if defined(CONFIG_CPU_SUBTYPE_SH7708)
1131 .membase
= (void *)0xfffffe80,
1132 .mapbase
= 0xfffffe80,
1133 .iotype
= SERIAL_IO_MEM
,
1135 .ops
= &sci_uart_ops
,
1136 .flags
= ASYNC_BOOT_AUTOCONF
,
1141 .init_pins
= sci_init_pins_sci
,
1143 #elif defined(CONFIG_CPU_SUBTYPE_SH7705)
1146 .membase
= (void *)SCIF0
,
1148 .iotype
= SERIAL_IO_MEM
,
1150 .ops
= &sci_uart_ops
,
1151 .flags
= ASYNC_BOOT_AUTOCONF
,
1155 .irqs
= SH3_IRDA_IRQS
,
1156 .init_pins
= sci_init_pins_scif
,
1160 .membase
= (void *)SCIF2
,
1162 .iotype
= SERIAL_IO_MEM
,
1164 .ops
= &sci_uart_ops
,
1165 .flags
= ASYNC_BOOT_AUTOCONF
,
1169 .irqs
= SH3_SCIF_IRQS
,
1170 .init_pins
= sci_init_pins_scif
,
1172 #elif defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709)
1175 .membase
= (void *)0xfffffe80,
1176 .mapbase
= 0xfffffe80,
1177 .iotype
= SERIAL_IO_MEM
,
1179 .ops
= &sci_uart_ops
,
1180 .flags
= ASYNC_BOOT_AUTOCONF
,
1185 .init_pins
= sci_init_pins_sci
,
1189 .membase
= (void *)0xa4000150,
1190 .mapbase
= 0xa4000150,
1191 .iotype
= SERIAL_IO_MEM
,
1193 .ops
= &sci_uart_ops
,
1194 .flags
= ASYNC_BOOT_AUTOCONF
,
1198 .irqs
= SH3_SCIF_IRQS
,
1199 .init_pins
= sci_init_pins_scif
,
1203 .membase
= (void *)0xa4000140,
1204 .mapbase
= 0xa4000140,
1205 .iotype
= SERIAL_IO_MEM
,
1207 .ops
= &sci_uart_ops
,
1208 .flags
= ASYNC_BOOT_AUTOCONF
,
1212 .irqs
= SH3_IRDA_IRQS
,
1213 .init_pins
= sci_init_pins_irda
,
1215 #elif defined(CONFIG_CPU_SUBTYPE_SH7300)
1218 .membase
= (void *)0xA4430000,
1219 .mapbase
= 0xA4430000,
1220 .iotype
= SERIAL_IO_MEM
,
1222 .ops
= &sci_uart_ops
,
1223 .flags
= ASYNC_BOOT_AUTOCONF
,
1227 .irqs
= SH7300_SCIF0_IRQS
,
1228 .init_pins
= sci_init_pins_scif
,
1230 #elif defined(CONFIG_CPU_SUBTYPE_SH73180)
1233 .membase
= (void *)0xffe00000,
1234 .mapbase
= 0xffe00000,
1235 .iotype
= SERIAL_IO_MEM
,
1237 .ops
= &sci_uart_ops
,
1238 .flags
= ASYNC_BOOT_AUTOCONF
,
1242 .irqs
= SH73180_SCIF_IRQS
,
1243 .init_pins
= sci_init_pins_scif
,
1245 #elif defined(CONFIG_SH_RTS7751R2D)
1248 .membase
= (void *)0xffe80000,
1249 .mapbase
= 0xffe80000,
1250 .iotype
= SERIAL_IO_MEM
,
1252 .ops
= &sci_uart_ops
,
1253 .flags
= ASYNC_BOOT_AUTOCONF
,
1257 .irqs
= SH4_SCIF_IRQS
,
1258 .init_pins
= sci_init_pins_scif
,
1260 #elif defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751)
1263 .membase
= (void *)0xffe00000,
1264 .mapbase
= 0xffe00000,
1265 .iotype
= SERIAL_IO_MEM
,
1267 .ops
= &sci_uart_ops
,
1268 .flags
= ASYNC_BOOT_AUTOCONF
,
1273 .init_pins
= sci_init_pins_sci
,
1277 .membase
= (void *)0xffe80000,
1278 .mapbase
= 0xffe80000,
1279 .iotype
= SERIAL_IO_MEM
,
1281 .ops
= &sci_uart_ops
,
1282 .flags
= ASYNC_BOOT_AUTOCONF
,
1286 .irqs
= SH4_SCIF_IRQS
,
1287 .init_pins
= sci_init_pins_scif
,
1289 #elif defined(CONFIG_CPU_SUBTYPE_SH7760)
1292 .membase
= (void *)0xfe600000,
1293 .mapbase
= 0xfe600000,
1294 .iotype
= SERIAL_IO_MEM
,
1296 .ops
= &sci_uart_ops
,
1297 .flags
= ASYNC_BOOT_AUTOCONF
,
1301 .irqs
= SH7760_SCIF0_IRQS
,
1302 .init_pins
= sci_init_pins_scif
,
1306 .membase
= (void *)0xfe610000,
1307 .mapbase
= 0xfe610000,
1308 .iotype
= SERIAL_IO_MEM
,
1310 .ops
= &sci_uart_ops
,
1311 .flags
= ASYNC_BOOT_AUTOCONF
,
1315 .irqs
= SH7760_SCIF1_IRQS
,
1316 .init_pins
= sci_init_pins_scif
,
1320 .membase
= (void *)0xfe620000,
1321 .mapbase
= 0xfe620000,
1322 .iotype
= SERIAL_IO_MEM
,
1324 .ops
= &sci_uart_ops
,
1325 .flags
= ASYNC_BOOT_AUTOCONF
,
1329 .irqs
= SH7760_SCIF2_IRQS
,
1330 .init_pins
= sci_init_pins_scif
,
1332 #elif defined(CONFIG_CPU_SUBTYPE_SH4_202)
1335 .membase
= (void *)0xffe80000,
1336 .mapbase
= 0xffe80000,
1337 .iotype
= SERIAL_IO_MEM
,
1339 .ops
= &sci_uart_ops
,
1340 .flags
= ASYNC_BOOT_AUTOCONF
,
1344 .irqs
= SH4_SCIF_IRQS
,
1345 .init_pins
= sci_init_pins_scif
,
1347 #elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)
1350 .membase
= (void *)0xffe00000,
1351 .mapbase
= 0xffe00000,
1352 .iotype
= SERIAL_IO_MEM
,
1354 .ops
= &sci_uart_ops
,
1355 .flags
= ASYNC_BOOT_AUTOCONF
,
1359 .irqs
= STB1_SCIF1_IRQS
,
1360 .init_pins
= sci_init_pins_scif
,
1364 .membase
= (void *)0xffe80000,
1365 .mapbase
= 0xffe80000,
1366 .iotype
= SERIAL_IO_MEM
,
1368 .ops
= &sci_uart_ops
,
1369 .flags
= ASYNC_BOOT_AUTOCONF
,
1373 .irqs
= SH4_SCIF_IRQS
,
1374 .init_pins
= sci_init_pins_scif
,
1376 #elif defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103)
1379 .iotype
= SERIAL_IO_MEM
,
1381 .ops
= &sci_uart_ops
,
1382 .flags
= ASYNC_BOOT_AUTOCONF
,
1386 .irqs
= SH5_SCIF_IRQS
,
1387 .init_pins
= sci_init_pins_scif
,
1389 #elif defined(CONFIG_H83007) || defined(CONFIG_H83068)
1392 .membase
= (void *)0x00ffffb0,
1393 .mapbase
= 0x00ffffb0,
1394 .iotype
= SERIAL_IO_MEM
,
1396 .ops
= &sci_uart_ops
,
1397 .flags
= ASYNC_BOOT_AUTOCONF
,
1401 .irqs
= H8300H_SCI_IRQS0
,
1402 .init_pins
= sci_init_pins_sci
,
1406 .membase
= (void *)0x00ffffb8,
1407 .mapbase
= 0x00ffffb8,
1408 .iotype
= SERIAL_IO_MEM
,
1410 .ops
= &sci_uart_ops
,
1411 .flags
= ASYNC_BOOT_AUTOCONF
,
1415 .irqs
= H8300H_SCI_IRQS1
,
1416 .init_pins
= sci_init_pins_sci
,
1420 .membase
= (void *)0x00ffffc0,
1421 .mapbase
= 0x00ffffc0,
1422 .iotype
= SERIAL_IO_MEM
,
1424 .ops
= &sci_uart_ops
,
1425 .flags
= ASYNC_BOOT_AUTOCONF
,
1429 .irqs
= H8300H_SCI_IRQS2
,
1430 .init_pins
= sci_init_pins_sci
,
1432 #elif defined(CONFIG_H8S2678)
1435 .membase
= (void *)0x00ffff78,
1436 .mapbase
= 0x00ffff78,
1437 .iotype
= SERIAL_IO_MEM
,
1439 .ops
= &sci_uart_ops
,
1440 .flags
= ASYNC_BOOT_AUTOCONF
,
1444 .irqs
= H8S_SCI_IRQS0
,
1445 .init_pins
= sci_init_pins_sci
,
1449 .membase
= (void *)0x00ffff80,
1450 .mapbase
= 0x00ffff80,
1451 .iotype
= SERIAL_IO_MEM
,
1453 .ops
= &sci_uart_ops
,
1454 .flags
= ASYNC_BOOT_AUTOCONF
,
1458 .irqs
= H8S_SCI_IRQS1
,
1459 .init_pins
= sci_init_pins_sci
,
1463 .membase
= (void *)0x00ffff88,
1464 .mapbase
= 0x00ffff88,
1465 .iotype
= SERIAL_IO_MEM
,
1467 .ops
= &sci_uart_ops
,
1468 .flags
= ASYNC_BOOT_AUTOCONF
,
1472 .irqs
= H8S_SCI_IRQS2
,
1473 .init_pins
= sci_init_pins_sci
,
1476 #error "CPU subtype not defined"
1480 #ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
1482 * Print a string to the serial port trying not to disturb
1483 * any possible real use of the port...
1485 static void serial_console_write(struct console
*co
, const char *s
,
1488 put_string(serial_console_port
, s
, count
);
1491 static int __init
serial_console_setup(struct console
*co
, char *options
)
1493 struct uart_port
*port
;
1500 if (co
->index
>= SCI_NPORTS
)
1503 serial_console_port
= &sci_ports
[co
->index
];
1504 port
= &serial_console_port
->port
;
1505 port
->type
= serial_console_port
->type
;
1507 #ifdef CONFIG_SUPERH64
1508 /* This is especially needed on sh64 to remap the SCIF */
1509 sci_config_port(port
, 0);
1513 * We need to set the initial uartclk here, since otherwise it will
1514 * only ever be setup at sci_init() time.
1516 #if !defined(__H8300H__) && !defined(__H8300S__)
1517 port
->uartclk
= current_cpu_data
.module_clock
* 16;
1519 port
->uartclk
= CONFIG_CPU_CLOCK
;
1521 #if defined(__H8300S__)
1522 h8300_sci_enable(port
, sci_enable
);
1525 uart_parse_options(options
, &baud
, &parity
, &bits
, &flow
);
1527 ret
= uart_set_options(port
, co
, baud
, parity
, bits
, flow
);
1528 #if defined(__H8300H__) || defined(__H8300S__)
1529 /* disable rx interrupt */
1536 static struct console serial_console
= {
1538 .device
= uart_console_device
,
1539 .write
= serial_console_write
,
1540 .setup
= serial_console_setup
,
1541 .flags
= CON_PRINTBUFFER
,
1543 .data
= &sci_uart_driver
,
1546 static int __init
sci_console_init(void)
1548 register_console(&serial_console
);
1552 console_initcall(sci_console_init
);
1553 #endif /* CONFIG_SERIAL_SH_SCI_CONSOLE */
1555 #ifdef CONFIG_SH_KGDB
1557 * FIXME: Most of this can go away.. at the moment, we rely on
1558 * arch/sh/kernel/setup.c to do the command line parsing for kgdb, though
1559 * most of that can easily be done here instead.
1561 * For the time being, just accept the values that were parsed earlier..
1563 static void __init
kgdb_console_get_options(struct uart_port
*port
, int *baud
,
1564 int *parity
, int *bits
)
1567 *parity
= tolower(kgdb_parity
);
1568 *bits
= kgdb_bits
- '0';
1572 * The naming here is somewhat misleading, since kgdb_console_setup() takes
1573 * care of the early-on initialization for kgdb, regardless of whether we
1574 * actually use kgdb as a console or not.
1576 * On the plus side, this lets us kill off the old kgdb_sci_setup() nonsense.
1578 int __init
kgdb_console_setup(struct console
*co
, char *options
)
1580 struct uart_port
*port
= &sci_ports
[kgdb_portnum
].port
;
1586 if (co
->index
>= SCI_NPORTS
|| co
->index
!= kgdb_portnum
)
1587 co
->index
= kgdb_portnum
;
1590 uart_parse_options(options
, &baud
, &parity
, &bits
, &flow
);
1592 kgdb_console_get_options(port
, &baud
, &parity
, &bits
);
1594 kgdb_getchar
= kgdb_sci_getchar
;
1595 kgdb_putchar
= kgdb_sci_putchar
;
1597 return uart_set_options(port
, co
, baud
, parity
, bits
, flow
);
1599 #endif /* CONFIG_SH_KGDB */
1601 #ifdef CONFIG_SH_KGDB_CONSOLE
1602 static struct console kgdb_console
= {
1604 .write
= kgdb_console_write
,
1605 .setup
= kgdb_console_setup
,
1606 .flags
= CON_PRINTBUFFER
| CON_ENABLED
,
1608 .data
= &sci_uart_driver
,
1611 /* Register the KGDB console so we get messages (d'oh!) */
1612 static int __init
kgdb_console_init(void)
1614 register_console(&kgdb_console
);
1618 console_initcall(kgdb_console_init
);
1619 #endif /* CONFIG_SH_KGDB_CONSOLE */
1621 #if defined(CONFIG_SH_KGDB_CONSOLE)
1622 #define SCI_CONSOLE &kgdb_console
1623 #elif defined(CONFIG_SERIAL_SH_SCI_CONSOLE)
1624 #define SCI_CONSOLE &serial_console
1626 #define SCI_CONSOLE 0
1629 static char banner
[] __initdata
=
1630 KERN_INFO
"SuperH SCI(F) driver initialized\n";
1632 static struct uart_driver sci_uart_driver
= {
1633 .owner
= THIS_MODULE
,
1634 .driver_name
= "sci",
1635 #ifdef CONFIG_DEVFS_FS
1636 .devfs_name
= "ttsc/",
1638 .dev_name
= "ttySC",
1640 .minor
= SCI_MINOR_START
,
1642 .cons
= SCI_CONSOLE
,
1645 static int __init
sci_init(void)
1649 printk("%s", banner
);
1651 ret
= uart_register_driver(&sci_uart_driver
);
1653 for (chan
= 0; chan
< SCI_NPORTS
; chan
++) {
1654 struct sci_port
*sciport
= &sci_ports
[chan
];
1656 #if !defined(__H8300H__) && !defined(__H8300S__)
1657 sciport
->port
.uartclk
= (current_cpu_data
.module_clock
* 16);
1659 sciport
->port
.uartclk
= CONFIG_CPU_CLOCK
;
1661 uart_add_one_port(&sci_uart_driver
, &sciport
->port
);
1662 sciport
->break_timer
.data
= (unsigned long)sciport
;
1663 sciport
->break_timer
.function
= sci_break_timer
;
1664 init_timer(&sciport
->break_timer
);
1668 #ifdef CONFIG_CPU_FREQ
1669 cpufreq_register_notifier(&sci_nb
, CPUFREQ_TRANSITION_NOTIFIER
);
1670 printk("sci: CPU frequency notifier registered\n");
1673 #ifdef CONFIG_SH_STANDARD_BIOS
1674 sh_bios_gdb_detach();
1680 static void __exit
sci_exit(void)
1684 for (chan
= 0; chan
< SCI_NPORTS
; chan
++)
1685 uart_remove_one_port(&sci_uart_driver
, &sci_ports
[chan
].port
);
1687 uart_unregister_driver(&sci_uart_driver
);
1690 module_init(sci_init
);
1691 module_exit(sci_exit
);