diff options
-rw-r--r-- | drivers/serial/sh-sci.c | 225 | ||||
-rw-r--r-- | drivers/serial/sh-sci.h | 114 |
2 files changed, 223 insertions, 116 deletions
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c index 0111206327ca..80737c131ce7 100644 --- a/drivers/serial/sh-sci.c +++ b/drivers/serial/sh-sci.c | |||
@@ -42,6 +42,7 @@ | |||
42 | #include <linux/delay.h> | 42 | #include <linux/delay.h> |
43 | #include <linux/console.h> | 43 | #include <linux/console.h> |
44 | #include <linux/bitops.h> | 44 | #include <linux/bitops.h> |
45 | #include <linux/generic_serial.h> | ||
45 | 46 | ||
46 | #ifdef CONFIG_CPU_FREQ | 47 | #ifdef CONFIG_CPU_FREQ |
47 | #include <linux/notifier.h> | 48 | #include <linux/notifier.h> |
@@ -53,7 +54,9 @@ | |||
53 | #include <asm/irq.h> | 54 | #include <asm/irq.h> |
54 | #include <asm/uaccess.h> | 55 | #include <asm/uaccess.h> |
55 | 56 | ||
56 | #include <linux/generic_serial.h> | 57 | #if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64) |
58 | #include <asm/clock.h> | ||
59 | #endif | ||
57 | 60 | ||
58 | #ifdef CONFIG_SH_STANDARD_BIOS | 61 | #ifdef CONFIG_SH_STANDARD_BIOS |
59 | #include <asm/sh_bios.h> | 62 | #include <asm/sh_bios.h> |
@@ -86,9 +89,11 @@ static void sci_stop_rx(struct uart_port *port); | |||
86 | static int sci_request_irq(struct sci_port *port); | 89 | static int sci_request_irq(struct sci_port *port); |
87 | static void sci_free_irq(struct sci_port *port); | 90 | static void sci_free_irq(struct sci_port *port); |
88 | 91 | ||
89 | static struct sci_port sci_ports[SCI_NPORTS]; | 92 | static struct sci_port sci_ports[]; |
90 | static struct uart_driver sci_uart_driver; | 93 | static struct uart_driver sci_uart_driver; |
91 | 94 | ||
95 | #define SCI_NPORTS sci_uart_driver.nr | ||
96 | |||
92 | #if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB) | 97 | #if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB) |
93 | 98 | ||
94 | static void handle_error(struct uart_port *port) | 99 | static void handle_error(struct uart_port *port) |
@@ -168,7 +173,7 @@ static void put_string(struct sci_port *sci_port, const char *buffer, int count) | |||
168 | int usegdb=0; | 173 | int usegdb=0; |
169 | 174 | ||
170 | #ifdef CONFIG_SH_STANDARD_BIOS | 175 | #ifdef CONFIG_SH_STANDARD_BIOS |
171 | /* This call only does a trap the first time it is | 176 | /* This call only does a trap the first time it is |
172 | * called, and so is safe to do here unconditionally | 177 | * called, and so is safe to do here unconditionally |
173 | */ | 178 | */ |
174 | usegdb |= sh_bios_in_gdb_mode(); | 179 | usegdb |= sh_bios_in_gdb_mode(); |
@@ -324,47 +329,46 @@ static void sci_init_pins_sci(struct uart_port* port, unsigned int cflag) | |||
324 | /* tx mark output*/ | 329 | /* tx mark output*/ |
325 | H8300_SCI_DR(ch) |= h8300_sci_pins[ch].tx; | 330 | H8300_SCI_DR(ch) |= h8300_sci_pins[ch].tx; |
326 | } | 331 | } |
327 | #else | ||
328 | static void sci_init_pins_sci(struct uart_port *port, unsigned int cflag) | ||
329 | { | ||
330 | } | ||
331 | #endif | 332 | #endif |
332 | #endif | 333 | #endif |
333 | 334 | ||
334 | #if defined(SCIF_ONLY) || defined(SCI_AND_SCIF) | 335 | #if defined(SCIF_ONLY) || defined(SCI_AND_SCIF) |
335 | #if defined(CONFIG_CPU_SH3) | 336 | #if defined(CONFIG_CPU_SUBTYPE_SH7300) |
336 | /* For SH7705, SH7707, SH7709, SH7709A, SH7729, SH7300*/ | 337 | /* SH7300 doesn't use RTS/CTS */ |
338 | static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag) | ||
339 | { | ||
340 | sci_out(port, SCFCR, 0); | ||
341 | } | ||
342 | #elif defined(CONFIG_CPU_SH3) | ||
343 | /* For SH7705, SH7707, SH7709, SH7709A, SH7729 */ | ||
337 | static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag) | 344 | static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag) |
338 | { | 345 | { |
339 | unsigned int fcr_val = 0; | 346 | unsigned int fcr_val = 0; |
340 | #if !defined(CONFIG_CPU_SUBTYPE_SH7300) /* SH7300 doesn't use RTS/CTS */ | 347 | unsigned short data; |
341 | { | 348 | |
342 | unsigned short data; | 349 | /* We need to set SCPCR to enable RTS/CTS */ |
350 | data = ctrl_inw(SCPCR); | ||
351 | /* Clear out SCP7MD1,0, SCP6MD1,0, SCP4MD1,0*/ | ||
352 | ctrl_outw(data & 0x0fcf, SCPCR); | ||
343 | 353 | ||
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); | ||
348 | } | ||
349 | if (cflag & CRTSCTS) | 354 | if (cflag & CRTSCTS) |
350 | fcr_val |= SCFCR_MCE; | 355 | fcr_val |= SCFCR_MCE; |
351 | else { | 356 | else { |
352 | unsigned short data; | ||
353 | |||
354 | /* We need to set SCPCR to enable RTS/CTS */ | 357 | /* We need to set SCPCR to enable RTS/CTS */ |
355 | data = ctrl_inw(SCPCR); | 358 | data = ctrl_inw(SCPCR); |
356 | /* Clear out SCP7MD1,0, SCP4MD1,0, | 359 | /* Clear out SCP7MD1,0, SCP4MD1,0, |
357 | Set SCP6MD1,0 = {01} (output) */ | 360 | Set SCP6MD1,0 = {01} (output) */ |
358 | ctrl_outw((data&0x0fcf)|0x1000, SCPCR); | 361 | ctrl_outw((data & 0x0fcf) | 0x1000, SCPCR); |
359 | 362 | ||
360 | data = ctrl_inb(SCPDR); | 363 | data = ctrl_inb(SCPDR); |
361 | /* Set /RTS2 (bit6) = 0 */ | 364 | /* Set /RTS2 (bit6) = 0 */ |
362 | ctrl_outb(data&0xbf, SCPDR); | 365 | ctrl_outb(data & 0xbf, SCPDR); |
363 | } | 366 | } |
364 | #endif | 367 | |
365 | sci_out(port, SCFCR, fcr_val); | 368 | sci_out(port, SCFCR, fcr_val); |
366 | } | 369 | } |
367 | 370 | ||
371 | #if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) | ||
368 | static void sci_init_pins_irda(struct uart_port *port, unsigned int cflag) | 372 | static void sci_init_pins_irda(struct uart_port *port, unsigned int cflag) |
369 | { | 373 | { |
370 | unsigned int fcr_val = 0; | 374 | unsigned int fcr_val = 0; |
@@ -374,7 +378,7 @@ static void sci_init_pins_irda(struct uart_port *port, unsigned int cflag) | |||
374 | 378 | ||
375 | sci_out(port, SCFCR, fcr_val); | 379 | sci_out(port, SCFCR, fcr_val); |
376 | } | 380 | } |
377 | 381 | #endif | |
378 | #else | 382 | #else |
379 | 383 | ||
380 | /* For SH7750 */ | 384 | /* For SH7750 */ |
@@ -385,7 +389,11 @@ static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag) | |||
385 | if (cflag & CRTSCTS) { | 389 | if (cflag & CRTSCTS) { |
386 | fcr_val |= SCFCR_MCE; | 390 | fcr_val |= SCFCR_MCE; |
387 | } else { | 391 | } else { |
392 | #ifdef CONFIG_CPU_SUBTYPE_SH7780 | ||
393 | ctrl_outw(0x0080, SCSPTR0); /* Set RTS = 1 */ | ||
394 | #else | ||
388 | ctrl_outw(0x0080, SCSPTR2); /* Set RTS = 1 */ | 395 | ctrl_outw(0x0080, SCSPTR2); /* Set RTS = 1 */ |
396 | #endif | ||
389 | } | 397 | } |
390 | sci_out(port, SCFCR, fcr_val); | 398 | sci_out(port, SCFCR, fcr_val); |
391 | } | 399 | } |
@@ -422,7 +430,11 @@ static void sci_transmit_chars(struct uart_port *port) | |||
422 | 430 | ||
423 | #if !defined(SCI_ONLY) | 431 | #if !defined(SCI_ONLY) |
424 | if (port->type == PORT_SCIF) { | 432 | if (port->type == PORT_SCIF) { |
433 | #if defined(CONFIG_CPU_SUBTYPE_SH7760) || defined(CONFIG_CPU_SUBTYPE_SH7780) | ||
434 | txroom = SCIF_TXROOM_MAX - (sci_in(port, SCTFDR) & 0x7f); | ||
435 | #else | ||
425 | txroom = SCIF_TXROOM_MAX - (sci_in(port, SCFDR)>>8); | 436 | txroom = SCIF_TXROOM_MAX - (sci_in(port, SCFDR)>>8); |
437 | #endif | ||
426 | } else { | 438 | } else { |
427 | txroom = (sci_in(port, SCxSR) & SCI_TDRE)?1:0; | 439 | txroom = (sci_in(port, SCxSR) & SCI_TDRE)?1:0; |
428 | } | 440 | } |
@@ -491,7 +503,11 @@ static inline void sci_receive_chars(struct uart_port *port, | |||
491 | while (1) { | 503 | while (1) { |
492 | #if !defined(SCI_ONLY) | 504 | #if !defined(SCI_ONLY) |
493 | if (port->type == PORT_SCIF) { | 505 | if (port->type == PORT_SCIF) { |
506 | #if defined(CONFIG_CPU_SUBTYPE_SH7760) || defined(CONFIG_CPU_SUBTYPE_SH7780) | ||
507 | count = sci_in(port, SCRFDR) & 0x7f; | ||
508 | #else | ||
494 | count = sci_in(port, SCFDR)&SCIF_RFDC_MASK ; | 509 | count = sci_in(port, SCFDR)&SCIF_RFDC_MASK ; |
510 | #endif | ||
495 | } else { | 511 | } else { |
496 | count = (sci_in(port, SCxSR)&SCxSR_RDxF(port))?1:0; | 512 | count = (sci_in(port, SCxSR)&SCxSR_RDxF(port))?1:0; |
497 | } | 513 | } |
@@ -652,7 +668,7 @@ static inline int sci_handle_breaks(struct uart_port *port) | |||
652 | struct tty_struct *tty = port->info->tty; | 668 | struct tty_struct *tty = port->info->tty; |
653 | struct sci_port *s = &sci_ports[port->line]; | 669 | struct sci_port *s = &sci_ports[port->line]; |
654 | 670 | ||
655 | if (!s->break_flag && status & SCxSR_BRK(port)) | 671 | if (!s->break_flag && status & SCxSR_BRK(port)) { |
656 | #if defined(CONFIG_CPU_SH3) | 672 | #if defined(CONFIG_CPU_SH3) |
657 | /* Debounce break */ | 673 | /* Debounce break */ |
658 | s->break_flag = 1; | 674 | s->break_flag = 1; |
@@ -783,6 +799,7 @@ static int sci_notifier(struct notifier_block *self, unsigned long phase, void * | |||
783 | (phase == CPUFREQ_RESUMECHANGE)){ | 799 | (phase == CPUFREQ_RESUMECHANGE)){ |
784 | for (i = 0; i < SCI_NPORTS; i++) { | 800 | for (i = 0; i < SCI_NPORTS; i++) { |
785 | struct uart_port *port = &sci_ports[i].port; | 801 | struct uart_port *port = &sci_ports[i].port; |
802 | struct clk *clk; | ||
786 | 803 | ||
787 | /* | 804 | /* |
788 | * Update the uartclk per-port if frequency has | 805 | * Update the uartclk per-port if frequency has |
@@ -795,7 +812,9 @@ static int sci_notifier(struct notifier_block *self, unsigned long phase, void * | |||
795 | * | 812 | * |
796 | * Clean this up later.. | 813 | * Clean this up later.. |
797 | */ | 814 | */ |
798 | port->uartclk = current_cpu_data.module_clock * 16; | 815 | clk = clk_get("module_clk"); |
816 | port->uartclk = clk_get_rate(clk) * 16; | ||
817 | clk_put(clk); | ||
799 | } | 818 | } |
800 | 819 | ||
801 | printk("%s: got a postchange notification for cpu %d (old %d, new %d)\n", | 820 | printk("%s: got a postchange notification for cpu %d (old %d, new %d)\n", |
@@ -1008,15 +1027,20 @@ static void sci_set_termios(struct uart_port *port, struct termios *termios, | |||
1008 | sci_out(port, SCSMR, smr_val); | 1027 | sci_out(port, SCSMR, smr_val); |
1009 | 1028 | ||
1010 | switch (baud) { | 1029 | switch (baud) { |
1011 | case 0: t = -1; break; | 1030 | case 0: |
1012 | case 2400: t = BPS_2400; break; | 1031 | t = -1; |
1013 | case 4800: t = BPS_4800; break; | 1032 | break; |
1014 | case 9600: t = BPS_9600; break; | 1033 | default: |
1015 | case 19200: t = BPS_19200; break; | 1034 | { |
1016 | case 38400: t = BPS_38400; break; | 1035 | #if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64) |
1017 | case 57600: t = BPS_57600; break; | 1036 | struct clk *clk = clk_get("module_clk"); |
1018 | case 115200: t = BPS_115200; break; | 1037 | t = SCBRR_VALUE(baud, clk_get_rate(clk)); |
1019 | default: t = SCBRR_VALUE(baud); break; | 1038 | clk_put(clk); |
1039 | #else | ||
1040 | t = SCBRR_VALUE(baud); | ||
1041 | #endif | ||
1042 | } | ||
1043 | break; | ||
1020 | } | 1044 | } |
1021 | 1045 | ||
1022 | if (t > 0) { | 1046 | if (t > 0) { |
@@ -1030,7 +1054,9 @@ static void sci_set_termios(struct uart_port *port, struct termios *termios, | |||
1030 | udelay((1000000+(baud-1)) / baud); /* Wait one bit interval */ | 1054 | udelay((1000000+(baud-1)) / baud); /* Wait one bit interval */ |
1031 | } | 1055 | } |
1032 | 1056 | ||
1033 | s->init_pins(port, termios->c_cflag); | 1057 | if (likely(s->init_pins)) |
1058 | s->init_pins(port, termios->c_cflag); | ||
1059 | |||
1034 | sci_out(port, SCSCR, SCSCR_INIT(port)); | 1060 | sci_out(port, SCSCR, SCSCR_INIT(port)); |
1035 | 1061 | ||
1036 | if ((termios->c_cflag & CREAD) != 0) | 1062 | if ((termios->c_cflag & CREAD) != 0) |
@@ -1107,7 +1133,7 @@ static struct uart_ops sci_uart_ops = { | |||
1107 | .verify_port = sci_verify_port, | 1133 | .verify_port = sci_verify_port, |
1108 | }; | 1134 | }; |
1109 | 1135 | ||
1110 | static struct sci_port sci_ports[SCI_NPORTS] = { | 1136 | static struct sci_port sci_ports[] = { |
1111 | #if defined(CONFIG_CPU_SUBTYPE_SH7708) | 1137 | #if defined(CONFIG_CPU_SUBTYPE_SH7708) |
1112 | { | 1138 | { |
1113 | .port = { | 1139 | .port = { |
@@ -1121,7 +1147,6 @@ static struct sci_port sci_ports[SCI_NPORTS] = { | |||
1121 | }, | 1147 | }, |
1122 | .type = PORT_SCI, | 1148 | .type = PORT_SCI, |
1123 | .irqs = SCI_IRQS, | 1149 | .irqs = SCI_IRQS, |
1124 | .init_pins = sci_init_pins_sci, | ||
1125 | }, | 1150 | }, |
1126 | #elif defined(CONFIG_CPU_SUBTYPE_SH7705) | 1151 | #elif defined(CONFIG_CPU_SUBTYPE_SH7705) |
1127 | { | 1152 | { |
@@ -1165,7 +1190,6 @@ static struct sci_port sci_ports[SCI_NPORTS] = { | |||
1165 | }, | 1190 | }, |
1166 | .type = PORT_SCI, | 1191 | .type = PORT_SCI, |
1167 | .irqs = SCI_IRQS, | 1192 | .irqs = SCI_IRQS, |
1168 | .init_pins = sci_init_pins_sci, | ||
1169 | }, | 1193 | }, |
1170 | { | 1194 | { |
1171 | .port = { | 1195 | .port = { |
@@ -1225,7 +1249,7 @@ static struct sci_port sci_ports[SCI_NPORTS] = { | |||
1225 | .irqs = SH73180_SCIF_IRQS, | 1249 | .irqs = SH73180_SCIF_IRQS, |
1226 | .init_pins = sci_init_pins_scif, | 1250 | .init_pins = sci_init_pins_scif, |
1227 | }, | 1251 | }, |
1228 | #elif defined(CONFIG_SH_RTS7751R2D) | 1252 | #elif defined(CONFIG_CPU_SUBTYPE_SH4_202) |
1229 | { | 1253 | { |
1230 | .port = { | 1254 | .port = { |
1231 | .membase = (void *)0xffe80000, | 1255 | .membase = (void *)0xffe80000, |
@@ -1253,7 +1277,6 @@ static struct sci_port sci_ports[SCI_NPORTS] = { | |||
1253 | }, | 1277 | }, |
1254 | .type = PORT_SCI, | 1278 | .type = PORT_SCI, |
1255 | .irqs = SCI_IRQS, | 1279 | .irqs = SCI_IRQS, |
1256 | .init_pins = sci_init_pins_sci, | ||
1257 | }, | 1280 | }, |
1258 | { | 1281 | { |
1259 | .port = { | 1282 | .port = { |
@@ -1312,21 +1335,6 @@ static struct sci_port sci_ports[SCI_NPORTS] = { | |||
1312 | .irqs = SH7760_SCIF2_IRQS, | 1335 | .irqs = SH7760_SCIF2_IRQS, |
1313 | .init_pins = sci_init_pins_scif, | 1336 | .init_pins = sci_init_pins_scif, |
1314 | }, | 1337 | }, |
1315 | #elif defined(CONFIG_CPU_SUBTYPE_SH4_202) | ||
1316 | { | ||
1317 | .port = { | ||
1318 | .membase = (void *)0xffe80000, | ||
1319 | .mapbase = 0xffe80000, | ||
1320 | .iotype = UPIO_MEM, | ||
1321 | .irq = 43, | ||
1322 | .ops = &sci_uart_ops, | ||
1323 | .flags = UPF_BOOT_AUTOCONF, | ||
1324 | .line = 0, | ||
1325 | }, | ||
1326 | .type = PORT_SCIF, | ||
1327 | .irqs = SH4_SCIF_IRQS, | ||
1328 | .init_pins = sci_init_pins_scif, | ||
1329 | }, | ||
1330 | #elif defined(CONFIG_CPU_SUBTYPE_ST40STB1) | 1338 | #elif defined(CONFIG_CPU_SUBTYPE_ST40STB1) |
1331 | { | 1339 | { |
1332 | .port = { | 1340 | .port = { |
@@ -1455,6 +1463,78 @@ static struct sci_port sci_ports[SCI_NPORTS] = { | |||
1455 | .irqs = H8S_SCI_IRQS2, | 1463 | .irqs = H8S_SCI_IRQS2, |
1456 | .init_pins = sci_init_pins_sci, | 1464 | .init_pins = sci_init_pins_sci, |
1457 | }, | 1465 | }, |
1466 | #elif defined(CONFIG_CPU_SUBTYPE_SH7770) | ||
1467 | { | ||
1468 | .port = { | ||
1469 | .membase = (void *)0xff923000, | ||
1470 | .mapbase = 0xff923000, | ||
1471 | .iotype = SERIAL_IO_MEM, | ||
1472 | .irq = 61, | ||
1473 | .ops = &sci_uart_ops, | ||
1474 | .flags = ASYNC_BOOT_AUTOCONF, | ||
1475 | .line = 0, | ||
1476 | }, | ||
1477 | .type = PORT_SCIF, | ||
1478 | .irqs = SH7770_SCIF0_IRQS, | ||
1479 | .init_pins = sci_init_pins_scif, | ||
1480 | }, | ||
1481 | { | ||
1482 | .port = { | ||
1483 | .membase = (void *)0xff924000, | ||
1484 | .mapbase = 0xff924000, | ||
1485 | .iotype = SERIAL_IO_MEM, | ||
1486 | .irq = 62, | ||
1487 | .ops = &sci_uart_ops, | ||
1488 | .flags = ASYNC_BOOT_AUTOCONF, | ||
1489 | .line = 1, | ||
1490 | }, | ||
1491 | .type = PORT_SCIF, | ||
1492 | .irqs = SH7770_SCIF1_IRQS, | ||
1493 | .init_pins = sci_init_pins_scif, | ||
1494 | }, | ||
1495 | { | ||
1496 | .port = { | ||
1497 | .membase = (void *)0xff925000, | ||
1498 | .mapbase = 0xff925000, | ||
1499 | .iotype = SERIAL_IO_MEM, | ||
1500 | .irq = 63, | ||
1501 | .ops = &sci_uart_ops, | ||
1502 | .flags = ASYNC_BOOT_AUTOCONF, | ||
1503 | .line = 2, | ||
1504 | }, | ||
1505 | .type = PORT_SCIF, | ||
1506 | .irqs = SH7770_SCIF2_IRQS, | ||
1507 | .init_pins = sci_init_pins_scif, | ||
1508 | }, | ||
1509 | #elif defined(CONFIG_CPU_SUBTYPE_SH7780) | ||
1510 | { | ||
1511 | .port = { | ||
1512 | .membase = (void *)0xffe00000, | ||
1513 | .mapbase = 0xffe00000, | ||
1514 | .iotype = SERIAL_IO_MEM, | ||
1515 | .irq = 43, | ||
1516 | .ops = &sci_uart_ops, | ||
1517 | .flags = ASYNC_BOOT_AUTOCONF, | ||
1518 | .line = 0, | ||
1519 | }, | ||
1520 | .type = PORT_SCIF, | ||
1521 | .irqs = SH7780_SCIF0_IRQS, | ||
1522 | .init_pins = sci_init_pins_scif, | ||
1523 | }, | ||
1524 | { | ||
1525 | .port = { | ||
1526 | .membase = (void *)0xffe10000, | ||
1527 | .mapbase = 0xffe10000, | ||
1528 | .iotype = SERIAL_IO_MEM, | ||
1529 | .irq = 79, | ||
1530 | .ops = &sci_uart_ops, | ||
1531 | .flags = ASYNC_BOOT_AUTOCONF, | ||
1532 | .line = 1, | ||
1533 | }, | ||
1534 | .type = PORT_SCIF, | ||
1535 | .irqs = SH7780_SCIF1_IRQS, | ||
1536 | .init_pins = sci_init_pins_scif, | ||
1537 | }, | ||
1458 | #else | 1538 | #else |
1459 | #error "CPU subtype not defined" | 1539 | #error "CPU subtype not defined" |
1460 | #endif | 1540 | #endif |
@@ -1480,9 +1560,6 @@ static int __init serial_console_setup(struct console *co, char *options) | |||
1480 | int flow = 'n'; | 1560 | int flow = 'n'; |
1481 | int ret; | 1561 | int ret; |
1482 | 1562 | ||
1483 | if (co->index >= SCI_NPORTS) | ||
1484 | co->index = 0; | ||
1485 | |||
1486 | serial_console_port = &sci_ports[co->index]; | 1563 | serial_console_port = &sci_ports[co->index]; |
1487 | port = &serial_console_port->port; | 1564 | port = &serial_console_port->port; |
1488 | port->type = serial_console_port->type; | 1565 | port->type = serial_console_port->type; |
@@ -1496,14 +1573,21 @@ static int __init serial_console_setup(struct console *co, char *options) | |||
1496 | * We need to set the initial uartclk here, since otherwise it will | 1573 | * We need to set the initial uartclk here, since otherwise it will |
1497 | * only ever be setup at sci_init() time. | 1574 | * only ever be setup at sci_init() time. |
1498 | */ | 1575 | */ |
1499 | #if !defined(__H8300H__) && !defined(__H8300S__) | 1576 | #if defined(__H8300H__) || defined(__H8300S__) |
1500 | port->uartclk = current_cpu_data.module_clock * 16; | ||
1501 | #else | ||
1502 | port->uartclk = CONFIG_CPU_CLOCK; | 1577 | port->uartclk = CONFIG_CPU_CLOCK; |
1503 | #endif | 1578 | |
1504 | #if defined(__H8300S__) | 1579 | #if defined(__H8300S__) |
1505 | h8300_sci_enable(port, sci_enable); | 1580 | h8300_sci_enable(port, sci_enable); |
1506 | #endif | 1581 | #endif |
1582 | #elif defined(CONFIG_SUPERH64) | ||
1583 | port->uartclk = current_cpu_info.module_clock * 16; | ||
1584 | #else | ||
1585 | { | ||
1586 | struct clk *clk = clk_get("module_clk"); | ||
1587 | port->uartclk = clk_get_rate(clk) * 16; | ||
1588 | clk_put(clk); | ||
1589 | } | ||
1590 | #endif | ||
1507 | if (options) | 1591 | if (options) |
1508 | uart_parse_options(options, &baud, &parity, &bits, &flow); | 1592 | uart_parse_options(options, &baud, &parity, &bits, &flow); |
1509 | 1593 | ||
@@ -1566,7 +1650,7 @@ int __init kgdb_console_setup(struct console *co, char *options) | |||
1566 | int parity = 'n'; | 1650 | int parity = 'n'; |
1567 | int flow = 'n'; | 1651 | int flow = 'n'; |
1568 | 1652 | ||
1569 | if (co->index >= SCI_NPORTS || co->index != kgdb_portnum) | 1653 | if (co->index != kgdb_portnum) |
1570 | co->index = kgdb_portnum; | 1654 | co->index = kgdb_portnum; |
1571 | 1655 | ||
1572 | if (options) | 1656 | if (options) |
@@ -1606,7 +1690,7 @@ console_initcall(kgdb_console_init); | |||
1606 | #elif defined(CONFIG_SERIAL_SH_SCI_CONSOLE) | 1690 | #elif defined(CONFIG_SERIAL_SH_SCI_CONSOLE) |
1607 | #define SCI_CONSOLE &serial_console | 1691 | #define SCI_CONSOLE &serial_console |
1608 | #else | 1692 | #else |
1609 | #define SCI_CONSOLE 0 | 1693 | #define SCI_CONSOLE 0 |
1610 | #endif | 1694 | #endif |
1611 | 1695 | ||
1612 | static char banner[] __initdata = | 1696 | static char banner[] __initdata = |
@@ -1621,7 +1705,6 @@ static struct uart_driver sci_uart_driver = { | |||
1621 | .dev_name = "ttySC", | 1705 | .dev_name = "ttySC", |
1622 | .major = SCI_MAJOR, | 1706 | .major = SCI_MAJOR, |
1623 | .minor = SCI_MINOR_START, | 1707 | .minor = SCI_MINOR_START, |
1624 | .nr = SCI_NPORTS, | ||
1625 | .cons = SCI_CONSOLE, | 1708 | .cons = SCI_CONSOLE, |
1626 | }; | 1709 | }; |
1627 | 1710 | ||
@@ -1631,15 +1714,21 @@ static int __init sci_init(void) | |||
1631 | 1714 | ||
1632 | printk("%s", banner); | 1715 | printk("%s", banner); |
1633 | 1716 | ||
1717 | sci_uart_driver.nr = ARRAY_SIZE(sci_ports); | ||
1718 | |||
1634 | ret = uart_register_driver(&sci_uart_driver); | 1719 | ret = uart_register_driver(&sci_uart_driver); |
1635 | if (ret == 0) { | 1720 | if (ret == 0) { |
1636 | for (chan = 0; chan < SCI_NPORTS; chan++) { | 1721 | for (chan = 0; chan < SCI_NPORTS; chan++) { |
1637 | struct sci_port *sciport = &sci_ports[chan]; | 1722 | struct sci_port *sciport = &sci_ports[chan]; |
1638 | 1723 | ||
1639 | #if !defined(__H8300H__) && !defined(__H8300S__) | 1724 | #if defined(__H8300H__) || defined(__H8300S__) |
1640 | sciport->port.uartclk = (current_cpu_data.module_clock * 16); | ||
1641 | #else | ||
1642 | sciport->port.uartclk = CONFIG_CPU_CLOCK; | 1725 | sciport->port.uartclk = CONFIG_CPU_CLOCK; |
1726 | #elif defined(CONFIG_SUPERH64) | ||
1727 | sciport->port.uartclk = current_cpu_info.module_clock * 16; | ||
1728 | #else | ||
1729 | struct clk *clk = clk_get("module_clk"); | ||
1730 | sciport->port.uartclk = clk_get_rate(clk) * 16; | ||
1731 | clk_put(clk); | ||
1643 | #endif | 1732 | #endif |
1644 | uart_add_one_port(&sci_uart_driver, &sciport->port); | 1733 | uart_add_one_port(&sci_uart_driver, &sciport->port); |
1645 | sciport->break_timer.data = (unsigned long)sciport; | 1734 | sciport->break_timer.data = (unsigned long)sciport; |
diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h index 2892169eff05..1f14bb4382f6 100644 --- a/drivers/serial/sh-sci.h +++ b/drivers/serial/sh-sci.h | |||
@@ -46,14 +46,17 @@ | |||
46 | #define H8S_SCI_IRQS1 {92, 93, 94, 0 } | 46 | #define H8S_SCI_IRQS1 {92, 93, 94, 0 } |
47 | #define H8S_SCI_IRQS2 {96, 97, 98, 0 } | 47 | #define H8S_SCI_IRQS2 {96, 97, 98, 0 } |
48 | #define SH5_SCIF_IRQS {39, 40, 42, 0 } | 48 | #define SH5_SCIF_IRQS {39, 40, 42, 0 } |
49 | #define SH7770_SCIF0_IRQS {61, 61, 61, 61 } | ||
50 | #define SH7770_SCIF1_IRQS {62, 62, 62, 62 } | ||
51 | #define SH7770_SCIF2_IRQS {63, 63, 63, 63 } | ||
52 | #define SH7780_SCIF0_IRQS {40, 41, 43, 42 } | ||
53 | #define SH7780_SCIF1_IRQS {76, 77, 79, 78 } | ||
49 | 54 | ||
50 | #if defined(CONFIG_CPU_SUBTYPE_SH7708) | 55 | #if defined(CONFIG_CPU_SUBTYPE_SH7708) |
51 | # define SCI_NPORTS 1 | ||
52 | # define SCSPTR 0xffffff7c /* 8 bit */ | 56 | # define SCSPTR 0xffffff7c /* 8 bit */ |
53 | # define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ | 57 | # define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ |
54 | # define SCI_ONLY | 58 | # define SCI_ONLY |
55 | #elif defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) | 59 | #elif defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) |
56 | # define SCI_NPORTS 3 | ||
57 | # define SCPCR 0xA4000116 /* 16 bit SCI and SCIF */ | 60 | # define SCPCR 0xA4000116 /* 16 bit SCI and SCIF */ |
58 | # define SCPDR 0xA4000136 /* 8 bit SCI and SCIF */ | 61 | # define SCPDR 0xA4000136 /* 8 bit SCI and SCIF */ |
59 | # define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ | 62 | # define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ |
@@ -61,9 +64,8 @@ | |||
61 | #elif defined(CONFIG_CPU_SUBTYPE_SH7705) | 64 | #elif defined(CONFIG_CPU_SUBTYPE_SH7705) |
62 | # define SCIF0 0xA4400000 | 65 | # define SCIF0 0xA4400000 |
63 | # define SCIF2 0xA4410000 | 66 | # define SCIF2 0xA4410000 |
64 | # define SCSMR_Ir 0xA44A0000 | 67 | # define SCSMR_Ir 0xA44A0000 |
65 | # define IRDA_SCIF SCIF0 | 68 | # define IRDA_SCIF SCIF0 |
66 | # define SCI_NPORTS 2 | ||
67 | # define SCPCR 0xA4000116 | 69 | # define SCPCR 0xA4000116 |
68 | # define SCPDR 0xA4000136 | 70 | # define SCPDR 0xA4000136 |
69 | 71 | ||
@@ -74,14 +76,11 @@ | |||
74 | # define SCSCR_INIT(port) (port->mapbase == SCIF2) ? 0xF3 : 0xF0 | 76 | # define SCSCR_INIT(port) (port->mapbase == SCIF2) ? 0xF3 : 0xF0 |
75 | # define SCIF_ONLY | 77 | # define SCIF_ONLY |
76 | #elif defined(CONFIG_SH_RTS7751R2D) | 78 | #elif defined(CONFIG_SH_RTS7751R2D) |
77 | # define SCI_NPORTS 1 | ||
78 | # define SCSPTR1 0xffe0001c /* 8 bit SCI */ | ||
79 | # define SCSPTR2 0xFFE80020 /* 16 bit SCIF */ | 79 | # define SCSPTR2 0xFFE80020 /* 16 bit SCIF */ |
80 | # define SCIF_ORER 0x0001 /* overrun error bit */ | 80 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
81 | # define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ | 81 | # define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
82 | # define SCIF_ONLY | 82 | # define SCIF_ONLY |
83 | #elif defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751) | 83 | #elif defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751) |
84 | # define SCI_NPORTS 2 | ||
85 | # define SCSPTR1 0xffe0001c /* 8 bit SCI */ | 84 | # define SCSPTR1 0xffe0001c /* 8 bit SCI */ |
86 | # define SCSPTR2 0xFFE80020 /* 16 bit SCIF */ | 85 | # define SCSPTR2 0xFFE80020 /* 16 bit SCIF */ |
87 | # define SCIF_ORER 0x0001 /* overrun error bit */ | 86 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
@@ -90,34 +89,29 @@ | |||
90 | 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ ) | 89 | 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ ) |
91 | # define SCI_AND_SCIF | 90 | # define SCI_AND_SCIF |
92 | #elif defined(CONFIG_CPU_SUBTYPE_SH7760) | 91 | #elif defined(CONFIG_CPU_SUBTYPE_SH7760) |
93 | # define SCI_NPORTS 3 | 92 | # define SCSPTR0 0xfe600024 /* 16 bit SCIF */ |
94 | # define SCSPTR0 0xfe600000 /* 16 bit SCIF */ | 93 | # define SCSPTR1 0xfe610024 /* 16 bit SCIF */ |
95 | # define SCSPTR1 0xfe610000 /* 16 bit SCIF */ | 94 | # define SCSPTR2 0xfe620024 /* 16 bit SCIF */ |
96 | # define SCSPTR2 0xfe620000 /* 16 bit SCIF */ | ||
97 | # define SCIF_ORER 0x0001 /* overrun error bit */ | 95 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
98 | # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ | 96 | # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
99 | # define SCIF_ONLY | 97 | # define SCIF_ONLY |
100 | #elif defined(CONFIG_CPU_SUBTYPE_SH7300) | 98 | #elif defined(CONFIG_CPU_SUBTYPE_SH7300) |
101 | # define SCI_NPORTS 1 | ||
102 | # define SCPCR 0xA4050116 /* 16 bit SCIF */ | 99 | # define SCPCR 0xA4050116 /* 16 bit SCIF */ |
103 | # define SCPDR 0xA4050136 /* 16 bit SCIF */ | 100 | # define SCPDR 0xA4050136 /* 16 bit SCIF */ |
104 | # define SCSCR_INIT(port) 0x0030 /* TIE=0,RIE=0,TE=1,RE=1 */ | 101 | # define SCSCR_INIT(port) 0x0030 /* TIE=0,RIE=0,TE=1,RE=1 */ |
105 | # define SCIF_ONLY | 102 | # define SCIF_ONLY |
106 | #elif defined(CONFIG_CPU_SUBTYPE_SH73180) | 103 | #elif defined(CONFIG_CPU_SUBTYPE_SH73180) |
107 | # define SCI_NPORTS 1 | ||
108 | # define SCPDR 0xA4050138 /* 16 bit SCIF */ | 104 | # define SCPDR 0xA4050138 /* 16 bit SCIF */ |
109 | # define SCSPTR2 SCPDR | 105 | # define SCSPTR2 SCPDR |
110 | # define SCIF_ORER 0x0001 /* overrun error bit */ | 106 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
111 | # define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1 */ | 107 | # define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1 */ |
112 | # define SCIF_ONLY | 108 | # define SCIF_ONLY |
113 | #elif defined(CONFIG_CPU_SUBTYPE_SH4_202) | 109 | #elif defined(CONFIG_CPU_SUBTYPE_SH4_202) |
114 | # define SCI_NPORTS 1 | ||
115 | # define SCSPTR2 0xffe80020 /* 16 bit SCIF */ | 110 | # define SCSPTR2 0xffe80020 /* 16 bit SCIF */ |
116 | # define SCIF_ORER 0x0001 /* overrun error bit */ | 111 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
117 | # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ | 112 | # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ |
118 | # define SCIF_ONLY | 113 | # define SCIF_ONLY |
119 | #elif defined(CONFIG_CPU_SUBTYPE_ST40STB1) | 114 | #elif defined(CONFIG_CPU_SUBTYPE_ST40STB1) |
120 | # define SCI_NPORTS 2 | ||
121 | # define SCSPTR1 0xffe00020 /* 16 bit SCIF */ | 115 | # define SCSPTR1 0xffe00020 /* 16 bit SCIF */ |
122 | # define SCSPTR2 0xffe80020 /* 16 bit SCIF */ | 116 | # define SCSPTR2 0xffe80020 /* 16 bit SCIF */ |
123 | # define SCIF_ORER 0x0001 /* overrun error bit */ | 117 | # define SCIF_ORER 0x0001 /* overrun error bit */ |
@@ -129,26 +123,32 @@ | |||
129 | # define SCIF_ADDR_SH5 PHYS_PERIPHERAL_BLOCK+SCIF_BASE_ADDR | 123 | # define SCIF_ADDR_SH5 PHYS_PERIPHERAL_BLOCK+SCIF_BASE_ADDR |
130 | # define SCIF_PTR2_OFFS 0x0000020 | 124 | # define SCIF_PTR2_OFFS 0x0000020 |
131 | # define SCIF_LSR2_OFFS 0x0000024 | 125 | # define SCIF_LSR2_OFFS 0x0000024 |
132 | # define SCI_NPORTS 1 | ||
133 | # define SCI_INIT { \ | ||
134 | { {}, PORT_SCIF, 0, \ | ||
135 | SH5_SCIF_IRQS, sci_init_pins_scif } \ | ||
136 | } | ||
137 | # define SCSPTR2 ((port->mapbase)+SCIF_PTR2_OFFS) /* 16 bit SCIF */ | 126 | # define SCSPTR2 ((port->mapbase)+SCIF_PTR2_OFFS) /* 16 bit SCIF */ |
138 | # define SCLSR2 ((port->mapbase)+SCIF_LSR2_OFFS) /* 16 bit SCIF */ | 127 | # define SCLSR2 ((port->mapbase)+SCIF_LSR2_OFFS) /* 16 bit SCIF */ |
139 | # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0, | 128 | # define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0, |
140 | TE=1,RE=1,REIE=1 */ | 129 | TE=1,RE=1,REIE=1 */ |
141 | # define SCIF_ONLY | 130 | # define SCIF_ONLY |
142 | #elif defined(CONFIG_H83007) || defined(CONFIG_H83068) | 131 | #elif defined(CONFIG_H83007) || defined(CONFIG_H83068) |
143 | # define SCI_NPORTS 3 | ||
144 | # define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ | 132 | # define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ |
145 | # define SCI_ONLY | 133 | # define SCI_ONLY |
146 | # define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port) | 134 | # define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port) |
147 | #elif defined(CONFIG_H8S2678) | 135 | #elif defined(CONFIG_H8S2678) |
148 | # define SCI_NPORTS 3 | ||
149 | # define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ | 136 | # define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ |
150 | # define SCI_ONLY | 137 | # define SCI_ONLY |
151 | # define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port) | 138 | # define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port) |
139 | #elif defined(CONFIG_CPU_SUBTYPE_SH7770) | ||
140 | # define SCSPTR0 0xff923020 /* 16 bit SCIF */ | ||
141 | # define SCSPTR1 0xff924020 /* 16 bit SCIF */ | ||
142 | # define SCSPTR2 0xff925020 /* 16 bit SCIF */ | ||
143 | # define SCIF_ORER 0x0001 /* overrun error bit */ | ||
144 | # define SCSCR_INIT(port) 0x3c /* TIE=0,RIE=0,TE=1,RE=1,REIE=1,cke=2 */ | ||
145 | # define SCIF_ONLY | ||
146 | #elif defined(CONFIG_CPU_SUBTYPE_SH7780) | ||
147 | # define SCSPTR0 0xffe00024 /* 16 bit SCIF */ | ||
148 | # define SCSPTR1 0xffe10024 /* 16 bit SCIF */ | ||
149 | # define SCIF_OPER 0x0001 /* Overrun error bit */ | ||
150 | # define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ | ||
151 | # define SCIF_ONLY | ||
152 | #else | 152 | #else |
153 | # error CPU subtype not defined | 153 | # error CPU subtype not defined |
154 | #endif | 154 | #endif |
@@ -158,7 +158,7 @@ | |||
158 | #define SCI_CTRL_FLAGS_RIE 0x40 /* all */ | 158 | #define SCI_CTRL_FLAGS_RIE 0x40 /* all */ |
159 | #define SCI_CTRL_FLAGS_TE 0x20 /* all */ | 159 | #define SCI_CTRL_FLAGS_TE 0x20 /* all */ |
160 | #define SCI_CTRL_FLAGS_RE 0x10 /* all */ | 160 | #define SCI_CTRL_FLAGS_RE 0x10 /* all */ |
161 | #if defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751) | 161 | #if defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751) || defined(CONFIG_CPU_SUBTYPE_SH7780) |
162 | #define SCI_CTRL_FLAGS_REIE 0x08 /* 7750 SCIF */ | 162 | #define SCI_CTRL_FLAGS_REIE 0x08 /* 7750 SCIF */ |
163 | #else | 163 | #else |
164 | #define SCI_CTRL_FLAGS_REIE 0 | 164 | #define SCI_CTRL_FLAGS_REIE 0 |
@@ -213,7 +213,7 @@ | |||
213 | # define SCxSR_RDxF_CLEAR(port) 0xbc | 213 | # define SCxSR_RDxF_CLEAR(port) 0xbc |
214 | # define SCxSR_ERROR_CLEAR(port) 0xc4 | 214 | # define SCxSR_ERROR_CLEAR(port) 0xc4 |
215 | # define SCxSR_TDxE_CLEAR(port) 0x78 | 215 | # define SCxSR_TDxE_CLEAR(port) 0x78 |
216 | # define SCxSR_BREAK_CLEAR(port) 0xc4 | 216 | # define SCxSR_BREAK_CLEAR(port) 0xc4 |
217 | #elif defined(SCIF_ONLY) | 217 | #elif defined(SCIF_ONLY) |
218 | # define SCxSR_TEND(port) SCIF_TEND | 218 | # define SCxSR_TEND(port) SCIF_TEND |
219 | # define SCxSR_ERRORS(port) SCIF_ERRORS | 219 | # define SCxSR_ERRORS(port) SCIF_ERRORS |
@@ -237,7 +237,7 @@ | |||
237 | # define SCxSR_RDxF_CLEAR(port) 0x00fc | 237 | # define SCxSR_RDxF_CLEAR(port) 0x00fc |
238 | # define SCxSR_ERROR_CLEAR(port) 0x0073 | 238 | # define SCxSR_ERROR_CLEAR(port) 0x0073 |
239 | # define SCxSR_TDxE_CLEAR(port) 0x00df | 239 | # define SCxSR_TDxE_CLEAR(port) 0x00df |
240 | # define SCxSR_BREAK_CLEAR(port) 0x00e3 | 240 | # define SCxSR_BREAK_CLEAR(port) 0x00e3 |
241 | #endif | 241 | #endif |
242 | #else | 242 | #else |
243 | # define SCxSR_TEND(port) (((port)->type == PORT_SCI) ? SCI_TEND : SCIF_TEND) | 243 | # define SCxSR_TEND(port) (((port)->type == PORT_SCI) ? SCI_TEND : SCIF_TEND) |
@@ -285,14 +285,14 @@ struct sci_port { | |||
285 | 285 | ||
286 | #define SCI_IN(size, offset) \ | 286 | #define SCI_IN(size, offset) \ |
287 | unsigned int addr = port->mapbase + (offset); \ | 287 | unsigned int addr = port->mapbase + (offset); \ |
288 | if ((size) == 8) { \ | 288 | if ((size) == 8) { \ |
289 | return ctrl_inb(addr); \ | 289 | return ctrl_inb(addr); \ |
290 | } else { \ | 290 | } else { \ |
291 | return ctrl_inw(addr); \ | 291 | return ctrl_inw(addr); \ |
292 | } | 292 | } |
293 | #define SCI_OUT(size, offset, value) \ | 293 | #define SCI_OUT(size, offset, value) \ |
294 | unsigned int addr = port->mapbase + (offset); \ | 294 | unsigned int addr = port->mapbase + (offset); \ |
295 | if ((size) == 8) { \ | 295 | if ((size) == 8) { \ |
296 | ctrl_outb(value, addr); \ | 296 | ctrl_outb(value, addr); \ |
297 | } else { \ | 297 | } else { \ |
298 | ctrl_outw(value, addr); \ | 298 | ctrl_outw(value, addr); \ |
@@ -301,10 +301,10 @@ struct sci_port { | |||
301 | #define CPU_SCIx_FNS(name, sci_offset, sci_size, scif_offset, scif_size)\ | 301 | #define CPU_SCIx_FNS(name, sci_offset, sci_size, scif_offset, scif_size)\ |
302 | static inline unsigned int sci_##name##_in(struct uart_port *port) \ | 302 | static inline unsigned int sci_##name##_in(struct uart_port *port) \ |
303 | { \ | 303 | { \ |
304 | if (port->type == PORT_SCI) { \ | 304 | if (port->type == PORT_SCI) { \ |
305 | SCI_IN(sci_size, sci_offset) \ | 305 | SCI_IN(sci_size, sci_offset) \ |
306 | } else { \ | 306 | } else { \ |
307 | SCI_IN(scif_size, scif_offset); \ | 307 | SCI_IN(scif_size, scif_offset); \ |
308 | } \ | 308 | } \ |
309 | } \ | 309 | } \ |
310 | static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \ | 310 | static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \ |
@@ -319,7 +319,7 @@ struct sci_port { | |||
319 | #define CPU_SCIF_FNS(name, scif_offset, scif_size) \ | 319 | #define CPU_SCIF_FNS(name, scif_offset, scif_size) \ |
320 | static inline unsigned int sci_##name##_in(struct uart_port *port) \ | 320 | static inline unsigned int sci_##name##_in(struct uart_port *port) \ |
321 | { \ | 321 | { \ |
322 | SCI_IN(scif_size, scif_offset); \ | 322 | SCI_IN(scif_size, scif_offset); \ |
323 | } \ | 323 | } \ |
324 | static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \ | 324 | static inline void sci_##name##_out(struct uart_port *port, unsigned int value) \ |
325 | { \ | 325 | { \ |
@@ -329,7 +329,7 @@ struct sci_port { | |||
329 | #define CPU_SCI_FNS(name, sci_offset, sci_size) \ | 329 | #define CPU_SCI_FNS(name, sci_offset, sci_size) \ |
330 | static inline unsigned int sci_##name##_in(struct uart_port* port) \ | 330 | static inline unsigned int sci_##name##_in(struct uart_port* port) \ |
331 | { \ | 331 | { \ |
332 | SCI_IN(sci_size, sci_offset); \ | 332 | SCI_IN(sci_size, sci_offset); \ |
333 | } \ | 333 | } \ |
334 | static inline void sci_##name##_out(struct uart_port* port, unsigned int value) \ | 334 | static inline void sci_##name##_out(struct uart_port* port, unsigned int value) \ |
335 | { \ | 335 | { \ |
@@ -385,10 +385,17 @@ SCIx_FNS(SCxTDR, 0x06, 8, 0x0c, 8, 0x06, 8, 0x0C, 8, 0x03, 8) | |||
385 | SCIx_FNS(SCxSR, 0x08, 8, 0x10, 8, 0x08, 16, 0x10, 16, 0x04, 8) | 385 | SCIx_FNS(SCxSR, 0x08, 8, 0x10, 8, 0x08, 16, 0x10, 16, 0x04, 8) |
386 | SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8, 0x05, 8) | 386 | SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8, 0x05, 8) |
387 | SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16) | 387 | SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16) |
388 | #if defined(CONFIG_CPU_SUBTYPE_SH7760) || defined(CONFIG_CPU_SUBTYPE_SH7780) | ||
389 | SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16) | ||
390 | SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16) | ||
391 | SCIF_FNS(SCSPTR, 0, 0, 0x24, 16) | ||
392 | SCIF_FNS(SCLSR, 0, 0, 0x28, 16) | ||
393 | #else | ||
388 | SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16) | 394 | SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16) |
389 | SCIF_FNS(SCSPTR, 0, 0, 0x20, 16) | 395 | SCIF_FNS(SCSPTR, 0, 0, 0x20, 16) |
390 | SCIF_FNS(SCLSR, 0, 0, 0x24, 16) | 396 | SCIF_FNS(SCLSR, 0, 0, 0x24, 16) |
391 | #endif | 397 | #endif |
398 | #endif | ||
392 | #define sci_in(port, reg) sci_##reg##_in(port) | 399 | #define sci_in(port, reg) sci_##reg##_in(port) |
393 | #define sci_out(port, reg, value) sci_##reg##_out(port, value) | 400 | #define sci_out(port, reg, value) sci_##reg##_out(port, value) |
394 | 401 | ||
@@ -518,6 +525,24 @@ static inline int sci_rxd_in(struct uart_port *port) | |||
518 | int ch = (port->mapbase - SMR0) >> 3; | 525 | int ch = (port->mapbase - SMR0) >> 3; |
519 | return (H8300_SCI_DR(ch) & h8300_sci_pins[ch].rx) ? 1 : 0; | 526 | return (H8300_SCI_DR(ch) & h8300_sci_pins[ch].rx) ? 1 : 0; |
520 | } | 527 | } |
528 | #elif defined(CONFIG_CPU_SUBTYPE_SH7770) | ||
529 | static inline int sci_rxd_in(struct uart_port *port) | ||
530 | { | ||
531 | if (port->mapbase == 0xff923000) | ||
532 | return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */ | ||
533 | if (port->mapbase == 0xff924000) | ||
534 | return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */ | ||
535 | if (port->mapbase == 0xff925000) | ||
536 | return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */ | ||
537 | } | ||
538 | #elif defined(CONFIG_CPU_SUBTYPE_SH7780) | ||
539 | static inline int sci_rxd_in(struct uart_port *port) | ||
540 | { | ||
541 | if (port->mapbase == 0xffe00000) | ||
542 | return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */ | ||
543 | if (port->mapbase == 0xffe10000) | ||
544 | return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */ | ||
545 | } | ||
521 | #endif | 546 | #endif |
522 | 547 | ||
523 | /* | 548 | /* |
@@ -552,22 +577,15 @@ static inline int sci_rxd_in(struct uart_port *port) | |||
552 | * -- Mitch Davis - 15 Jul 2000 | 577 | * -- Mitch Davis - 15 Jul 2000 |
553 | */ | 578 | */ |
554 | 579 | ||
555 | #define PCLK (current_cpu_data.module_clock) | 580 | #if defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7780) |
556 | 581 | #define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(16*bps)-1) | |
557 | #if defined(CONFIG_CPU_SUBTYPE_SH7300) | ||
558 | #define SCBRR_VALUE(bps) ((PCLK+16*bps)/(16*bps)-1) | ||
559 | #elif defined(CONFIG_CPU_SUBTYPE_SH7705) | 582 | #elif defined(CONFIG_CPU_SUBTYPE_SH7705) |
560 | #define SCBRR_VALUE(bps) (((PCLK*2)+16*bps)/(32*bps)-1) | 583 | #define SCBRR_VALUE(bps, clk) (((clk*2)+16*bps)/(32*bps)-1) |
561 | #elif !defined(__H8300H__) && !defined(__H8300S__) | 584 | #elif defined(__H8300H__) || defined(__H8300S__) |
562 | #define SCBRR_VALUE(bps) ((PCLK+16*bps)/(32*bps)-1) | ||
563 | #else | ||
564 | #define SCBRR_VALUE(bps) (((CONFIG_CPU_CLOCK*1000/32)/bps)-1) | 585 | #define SCBRR_VALUE(bps) (((CONFIG_CPU_CLOCK*1000/32)/bps)-1) |
586 | #elif defined(CONFIG_SUPERH64) | ||
587 | #define SCBRR_VALUE(bps) ((current_cpu_data.module_clock+16*bps)/(32*bps)-1) | ||
588 | #else /* Generic SH */ | ||
589 | #define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(32*bps)-1) | ||
565 | #endif | 590 | #endif |
566 | #define BPS_2400 SCBRR_VALUE(2400) | ||
567 | #define BPS_4800 SCBRR_VALUE(4800) | ||
568 | #define BPS_9600 SCBRR_VALUE(9600) | ||
569 | #define BPS_19200 SCBRR_VALUE(19200) | ||
570 | #define BPS_38400 SCBRR_VALUE(38400) | ||
571 | #define BPS_57600 SCBRR_VALUE(57600) | ||
572 | #define BPS_115200 SCBRR_VALUE(115200) | ||
573 | 591 | ||