excite_dbg_io.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Copyright (C) 2004 by Basler Vision Technologies AG
  3. * Author: Thomas Koeller <thomas.koeller@baslerweb.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #include <linux/config.h>
  20. #include <linux/linkage.h>
  21. #include <linux/init.h>
  22. #include <linux/kernel.h>
  23. #include <asm/gdb-stub.h>
  24. #include <asm/rm9k-ocd.h>
  25. #include <excite.h>
  26. #if defined(CONFIG_SERIAL_8250) && CONFIG_SERIAL_8250_NR_UARTS > 1
  27. #error Debug port used by serial driver
  28. #endif
  29. #define UART_CLK 25000000
  30. #define BASE_BAUD (UART_CLK / 16)
  31. #define REGISTER_BASE_0 0x0208UL
  32. #define REGISTER_BASE_1 0x0238UL
  33. #define REGISTER_BASE_DBG REGISTER_BASE_1
  34. #define CPRR 0x0004
  35. #define UACFG 0x0200
  36. #define UAINTS 0x0204
  37. #define UARBR (REGISTER_BASE_DBG + 0x0000)
  38. #define UATHR (REGISTER_BASE_DBG + 0x0004)
  39. #define UADLL (REGISTER_BASE_DBG + 0x0008)
  40. #define UAIER (REGISTER_BASE_DBG + 0x000c)
  41. #define UADLH (REGISTER_BASE_DBG + 0x0010)
  42. #define UAIIR (REGISTER_BASE_DBG + 0x0014)
  43. #define UAFCR (REGISTER_BASE_DBG + 0x0018)
  44. #define UALCR (REGISTER_BASE_DBG + 0x001c)
  45. #define UAMCR (REGISTER_BASE_DBG + 0x0020)
  46. #define UALSR (REGISTER_BASE_DBG + 0x0024)
  47. #define UAMSR (REGISTER_BASE_DBG + 0x0028)
  48. #define UASCR (REGISTER_BASE_DBG + 0x002c)
  49. #define PARITY_NONE 0
  50. #define PARITY_ODD 0x08
  51. #define PARITY_EVEN 0x18
  52. #define PARITY_MARK 0x28
  53. #define PARITY_SPACE 0x38
  54. #define DATA_5BIT 0x0
  55. #define DATA_6BIT 0x1
  56. #define DATA_7BIT 0x2
  57. #define DATA_8BIT 0x3
  58. #define STOP_1BIT 0x0
  59. #define STOP_2BIT 0x4
  60. #define BAUD_DBG 57600
  61. #define PARITY_DBG PARITY_NONE
  62. #define DATA_DBG DATA_8BIT
  63. #define STOP_DBG STOP_1BIT
  64. /* Initialize the serial port for KGDB debugging */
  65. void __init excite_kgdb_init(void)
  66. {
  67. const u32 divisor = BASE_BAUD / BAUD_DBG;
  68. /* Take the UART out of reset */
  69. titan_writel(0x00ff1cff, CPRR);
  70. titan_writel(0x00000000, UACFG);
  71. titan_writel(0x00000002, UACFG);
  72. titan_writel(0x0, UALCR);
  73. titan_writel(0x0, UAIER);
  74. /* Disable FIFOs */
  75. titan_writel(0x00, UAFCR);
  76. titan_writel(0x80, UALCR);
  77. titan_writel(divisor & 0xff, UADLL);
  78. titan_writel((divisor & 0xff00) >> 8, UADLH);
  79. titan_writel(0x0, UALCR);
  80. titan_writel(DATA_DBG | PARITY_DBG | STOP_DBG, UALCR);
  81. /* Enable receiver interrupt */
  82. titan_readl(UARBR);
  83. titan_writel(0x1, UAIER);
  84. }
  85. int getDebugChar(void)
  86. {
  87. while (!(titan_readl(UALSR) & 0x1));
  88. return titan_readl(UARBR);
  89. }
  90. int putDebugChar(int data)
  91. {
  92. while (!(titan_readl(UALSR) & 0x20));
  93. titan_writel(data, UATHR);
  94. return 1;
  95. }
  96. /* KGDB interrupt handler */
  97. asmlinkage void excite_kgdb_inthdl(struct pt_regs *regs)
  98. {
  99. if (unlikely(
  100. ((titan_readl(UAIIR) & 0x7) == 4)
  101. && ((titan_readl(UARBR) & 0xff) == 0x3)))
  102. set_async_breakpoint(&regs->cp0_epc);
  103. }