excite_dbg_io.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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/linkage.h>
  20. #include <linux/init.h>
  21. #include <linux/kernel.h>
  22. #include <asm/gdb-stub.h>
  23. #include <asm/rm9k-ocd.h>
  24. #include <excite.h>
  25. #if defined(CONFIG_SERIAL_8250) && CONFIG_SERIAL_8250_NR_UARTS > 1
  26. #error Debug port used by serial driver
  27. #endif
  28. #define UART_CLK 25000000
  29. #define BASE_BAUD (UART_CLK / 16)
  30. #define REGISTER_BASE_0 0x0208UL
  31. #define REGISTER_BASE_1 0x0238UL
  32. #define REGISTER_BASE_DBG REGISTER_BASE_1
  33. #define CPRR 0x0004
  34. #define UACFG 0x0200
  35. #define UAINTS 0x0204
  36. #define UARBR (REGISTER_BASE_DBG + 0x0000)
  37. #define UATHR (REGISTER_BASE_DBG + 0x0004)
  38. #define UADLL (REGISTER_BASE_DBG + 0x0008)
  39. #define UAIER (REGISTER_BASE_DBG + 0x000c)
  40. #define UADLH (REGISTER_BASE_DBG + 0x0010)
  41. #define UAIIR (REGISTER_BASE_DBG + 0x0014)
  42. #define UAFCR (REGISTER_BASE_DBG + 0x0018)
  43. #define UALCR (REGISTER_BASE_DBG + 0x001c)
  44. #define UAMCR (REGISTER_BASE_DBG + 0x0020)
  45. #define UALSR (REGISTER_BASE_DBG + 0x0024)
  46. #define UAMSR (REGISTER_BASE_DBG + 0x0028)
  47. #define UASCR (REGISTER_BASE_DBG + 0x002c)
  48. #define PARITY_NONE 0
  49. #define PARITY_ODD 0x08
  50. #define PARITY_EVEN 0x18
  51. #define PARITY_MARK 0x28
  52. #define PARITY_SPACE 0x38
  53. #define DATA_5BIT 0x0
  54. #define DATA_6BIT 0x1
  55. #define DATA_7BIT 0x2
  56. #define DATA_8BIT 0x3
  57. #define STOP_1BIT 0x0
  58. #define STOP_2BIT 0x4
  59. #define BAUD_DBG 57600
  60. #define PARITY_DBG PARITY_NONE
  61. #define DATA_DBG DATA_8BIT
  62. #define STOP_DBG STOP_1BIT
  63. /* Initialize the serial port for KGDB debugging */
  64. void __init excite_kgdb_init(void)
  65. {
  66. const u32 divisor = BASE_BAUD / BAUD_DBG;
  67. /* Take the UART out of reset */
  68. titan_writel(0x00ff1cff, CPRR);
  69. titan_writel(0x00000000, UACFG);
  70. titan_writel(0x00000002, UACFG);
  71. titan_writel(0x0, UALCR);
  72. titan_writel(0x0, UAIER);
  73. /* Disable FIFOs */
  74. titan_writel(0x00, UAFCR);
  75. titan_writel(0x80, UALCR);
  76. titan_writel(divisor & 0xff, UADLL);
  77. titan_writel((divisor & 0xff00) >> 8, UADLH);
  78. titan_writel(0x0, UALCR);
  79. titan_writel(DATA_DBG | PARITY_DBG | STOP_DBG, UALCR);
  80. /* Enable receiver interrupt */
  81. titan_readl(UARBR);
  82. titan_writel(0x1, UAIER);
  83. }
  84. int getDebugChar(void)
  85. {
  86. while (!(titan_readl(UALSR) & 0x1));
  87. return titan_readl(UARBR);
  88. }
  89. int putDebugChar(int data)
  90. {
  91. while (!(titan_readl(UALSR) & 0x20));
  92. titan_writel(data, UATHR);
  93. return 1;
  94. }
  95. /* KGDB interrupt handler */
  96. asmlinkage void excite_kgdb_inthdl(struct pt_regs *regs)
  97. {
  98. if (unlikely(
  99. ((titan_readl(UAIIR) & 0x7) == 4)
  100. && ((titan_readl(UARBR) & 0xff) == 0x3)))
  101. set_async_breakpoint(&regs->cp0_epc);
  102. }