serial.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  2. * (C) Copyright 2001
  3. * Josh Huber <huber@mclx.com>, Mission Critical Linux, Inc.
  4. *
  5. * modified for marvell db64360 eval board by
  6. * Ingo Assmus <ingo.assmus@keymile.com>
  7. *
  8. * modified for cpci750 board by
  9. * Reinhard Arlt <reinhard.arlt@esd-electronics.com>
  10. *
  11. * See file CREDITS for list of people who contributed to this
  12. * project.
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License as
  16. * published by the Free Software Foundation; either version 2 of
  17. * the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  27. * MA 02111-1307 USA
  28. */
  29. /*
  30. * serial.c - serial support for esd cpci750 board
  31. */
  32. /* supports the MPSC */
  33. #include <common.h>
  34. #include <command.h>
  35. #include <serial.h>
  36. #include <linux/compiler.h>
  37. #include "../../Marvell/include/memory.h"
  38. #include "serial.h"
  39. #include "mpsc.h"
  40. DECLARE_GLOBAL_DATA_PTR;
  41. static int cpci750_serial_init(void)
  42. {
  43. mpsc_init (gd->baudrate);
  44. return (0);
  45. }
  46. static void cpci750_serial_putc(const char c)
  47. {
  48. if (c == '\n')
  49. mpsc_putchar ('\r');
  50. mpsc_putchar (c);
  51. }
  52. static int cpci750_serial_getc(void)
  53. {
  54. return mpsc_getchar ();
  55. }
  56. static int cpci750_serial_tstc(void)
  57. {
  58. return mpsc_test_char ();
  59. }
  60. static void cpci750_serial_setbrg(void)
  61. {
  62. galbrg_set_baudrate (CONFIG_MPSC_PORT, gd->baudrate);
  63. }
  64. static void cpci750_serial_puts(const char *s)
  65. {
  66. while (*s) {
  67. serial_putc (*s++);
  68. }
  69. }
  70. #ifdef CONFIG_SERIAL_MULTI
  71. static struct serial_device cpci750_serial_drv = {
  72. .name = "cpci750_serial",
  73. .start = cpci750_serial_init,
  74. .stop = NULL,
  75. .setbrg = cpci750_serial_setbrg,
  76. .putc = cpci750_serial_putc,
  77. .puts = cpci750_serial_puts,
  78. .getc = cpci750_serial_getc,
  79. .tstc = cpci750_serial_tstc,
  80. };
  81. void cpci750_serial_initialize(void)
  82. {
  83. serial_register(&cpci750_serial_drv);
  84. }
  85. __weak struct serial_device *default_serial_console(void)
  86. {
  87. return &cpci750_serial_drv;
  88. }
  89. #else
  90. int serial_init(void)
  91. {
  92. return cpci750_serial_init();
  93. }
  94. void serial_setbrg(void)
  95. {
  96. cpci750_serial_setbrg();
  97. }
  98. void serial_putc(const char c)
  99. {
  100. cpci750_serial_putc(c);
  101. }
  102. void serial_puts(const char *s)
  103. {
  104. cpci750_serial_puts(s);
  105. }
  106. int serial_getc(void)
  107. {
  108. return cpci750_serial_getc();
  109. }
  110. int serial_tstc(void)
  111. {
  112. return cpci750_serial_tstc();
  113. }
  114. #endif
  115. #if defined(CONFIG_CMD_KGDB)
  116. void kgdb_serial_init (void)
  117. {
  118. }
  119. void putDebugChar (int c)
  120. {
  121. serial_putc (c);
  122. }
  123. void putDebugStr (const char *str)
  124. {
  125. serial_puts (str);
  126. }
  127. int getDebugChar (void)
  128. {
  129. return serial_getc ();
  130. }
  131. void kgdb_interruptible (int yes)
  132. {
  133. return;
  134. }
  135. #endif