msp_serial.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * The setup file for serial related hardware on PMC-Sierra MSP processors.
  3. *
  4. * Copyright 2005 PMC-Sierra, Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2 of the License, or (at your
  9. * option) any later version.
  10. *
  11. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  12. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  13. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  14. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  15. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  16. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  17. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  18. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  19. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  20. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  21. *
  22. * You should have received a copy of the GNU General Public License along
  23. * with this program; if not, write to the Free Software Foundation, Inc.,
  24. * 675 Mass Ave, Cambridge, MA 02139, USA.
  25. */
  26. #include <linux/serial.h>
  27. #include <linux/serial_core.h>
  28. #include <linux/serial_reg.h>
  29. #include <asm/bootinfo.h>
  30. #include <asm/io.h>
  31. #include <asm/processor.h>
  32. #include <asm/serial.h>
  33. #include <linux/serial_8250.h>
  34. #include <msp_prom.h>
  35. #include <msp_int.h>
  36. #include <msp_regs.h>
  37. void __init msp_serial_setup(void)
  38. {
  39. char *s;
  40. char *endp;
  41. struct uart_port up;
  42. unsigned int uartclk;
  43. memset(&up, 0, sizeof(up));
  44. /* Check if clock was specified in environment */
  45. s = prom_getenv("uartfreqhz");
  46. if(!(s && *s && (uartclk = simple_strtoul(s, &endp, 10)) && *endp == 0))
  47. uartclk = MSP_BASE_BAUD;
  48. ppfinit("UART clock set to %d\n", uartclk);
  49. /* Initialize first serial port */
  50. up.mapbase = MSP_UART0_BASE;
  51. up.membase = ioremap_nocache(up.mapbase, MSP_UART_REG_LEN);
  52. up.irq = MSP_INT_UART0;
  53. up.uartclk = uartclk;
  54. up.regshift = 2;
  55. up.iotype = UPIO_DWAPB; /* UPIO_MEM like */
  56. up.flags = ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST;
  57. up.type = PORT_16550A;
  58. up.line = 0;
  59. up.private_data = (void*)UART0_STATUS_REG;
  60. if (early_serial_setup(&up))
  61. printk(KERN_ERR "Early serial init of port 0 failed\n");
  62. /* Initialize the second serial port, if one exists */
  63. switch (mips_machtype) {
  64. case MACH_MSP4200_EVAL:
  65. case MACH_MSP4200_GW:
  66. case MACH_MSP4200_FPGA:
  67. case MACH_MSP7120_EVAL:
  68. case MACH_MSP7120_GW:
  69. case MACH_MSP7120_FPGA:
  70. /* Enable UART1 on MSP4200 and MSP7120 */
  71. *GPIO_CFG2_REG = 0x00002299;
  72. break;
  73. default:
  74. return; /* No second serial port, good-bye. */
  75. }
  76. up.mapbase = MSP_UART1_BASE;
  77. up.membase = ioremap_nocache(up.mapbase, MSP_UART_REG_LEN);
  78. up.irq = MSP_INT_UART1;
  79. up.line = 1;
  80. up.private_data = (void*)UART1_STATUS_REG;
  81. if (early_serial_setup(&up))
  82. printk(KERN_ERR "Early serial init of port 1 failed\n");
  83. }