debug-macro.S 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * linux/arch/unicore32/kernel/debug-macro.S
  3. *
  4. * Code specific to PKUnity SoC and UniCore ISA
  5. *
  6. * Copyright (C) 2001-2010 GUAN Xue-tao
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. * Debugging macro include header
  13. */
  14. #include <generated/asm-offsets.h>
  15. #include <mach/hardware.h>
  16. .macro put_word_ocd, rd, rx=r16
  17. 1001: movc \rx, p1.c0, #0
  18. cand.a \rx, #2
  19. bne 1001b
  20. movc p1.c1, \rd, #1
  21. .endm
  22. #ifdef CONFIG_DEBUG_OCD
  23. /* debug using UniCore On-Chip-Debugger */
  24. .macro addruart, rx
  25. .endm
  26. .macro senduart, rd, rx
  27. put_word_ocd \rd, \rx
  28. .endm
  29. .macro busyuart, rd, rx
  30. .endm
  31. .macro waituart, rd, rx
  32. .endm
  33. #else
  34. #define UART_CLK_DEFAULT 3686400 * 20
  35. /* Uartclk = MCLK/ 2, The MCLK on my board is 3686400 * 40 */
  36. #define BAUD_RATE_DEFAULT 115200
  37. /* The baud rate of the serial port */
  38. #define UART_DIVISOR_DEFAULT (UART_CLK_DEFAULT \
  39. / (16 * BAUD_RATE_DEFAULT) - 1)
  40. .macro addruart,rx
  41. mrc p0, #0, \rx, c1, c0
  42. tst \rx, #1 @ MMU enabled?
  43. moveq \rx, #0xee000000 @ physical base address
  44. movne \rx, #0x6e000000 @ virtual address
  45. @ We probe for the active serial port here
  46. @ However, now we assume UART0 is active: epip4d
  47. @ We assume r1 and r2 can be clobbered.
  48. movl r2, #UART_DIVISOR_DEFAULT
  49. mov r1, #0x80
  50. str r1, [\rx, #UART_LCR_OFFSET]
  51. and r1, r2, #0xff00
  52. mov r1, r1, lsr #8
  53. str r1, [\rx, #UART_DLH_OFFSET]
  54. and r1, r2, #0xff
  55. str r1, [\rx, #UART_DLL_OFFSET]
  56. mov r1, #0x7
  57. str r1, [\rx, #UART_FCR_OFFSET]
  58. mov r1, #0x3
  59. str r1, [\rx, #UART_LCR_OFFSET]
  60. mov r1, #0x0
  61. str r1, [\rx, #UART_IER_OFFSET]
  62. .endm
  63. .macro senduart,rd,rx
  64. str \rd, [\rx, #UART_THR_OFFSET]
  65. .endm
  66. .macro waituart,rd,rx
  67. 1001: ldr \rd, [\rx, #UART_LSR_OFFSET]
  68. tst \rd, #UART_LSR_THRE
  69. beq 1001b
  70. .endm
  71. .macro busyuart,rd,rx
  72. 1001: ldr \rd, [\rx, #UART_LSR_OFFSET]
  73. tst \rd, #UART_LSR_TEMT
  74. bne 1001b
  75. .endm
  76. #endif