ip27-dbgio.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * This program is free software; you can redistribute it and/or modify it
  3. * under the terms of the GNU General Public License as published by the
  4. * Free Software Foundation; either version 2 of the License, or (at your
  5. * option) any later version.
  6. *
  7. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  8. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  9. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  10. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  11. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  12. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  13. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  14. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  15. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  16. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program; if not, write to the Free Software Foundation, Inc.,
  20. * 675 Mass Ave, Cambridge, MA 02139, USA.
  21. *
  22. * Copyright 2004 Ralf Baechle <ralf@linux-mips.org>
  23. */
  24. #include <asm/sn/addrs.h>
  25. #include <asm/sn/sn0/hub.h>
  26. #include <asm/sn/klconfig.h>
  27. #include <asm/sn/ioc3.h>
  28. #include <asm/sn/sn_private.h>
  29. #include <linux/serial.h>
  30. #include <linux/serial_core.h>
  31. #include <linux/serial_reg.h>
  32. #define IOC3_CLK (22000000 / 3)
  33. #define IOC3_FLAGS (0)
  34. static inline struct ioc3_uartregs *console_uart(void)
  35. {
  36. struct ioc3 *ioc3;
  37. ioc3 = (struct ioc3 *)KL_CONFIG_CH_CONS_INFO(get_nasid())->memory_base;
  38. return &ioc3->sregs.uarta;
  39. }
  40. unsigned char getDebugChar(void)
  41. {
  42. struct ioc3_uartregs *uart = console_uart();
  43. while ((uart->iu_lsr & UART_LSR_DR) == 0);
  44. return uart->iu_rbr;
  45. }
  46. void putDebugChar(unsigned char c)
  47. {
  48. struct ioc3_uartregs *uart = console_uart();
  49. while ((uart->iu_lsr & UART_LSR_THRE) == 0);
  50. uart->iu_thr = c;
  51. }