scc_sio.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * setup serial port in SCC
  3. *
  4. * (C) Copyright 2006 TOSHIBA CORPORATION
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. */
  20. #include <linux/tty.h>
  21. #include <linux/serial.h>
  22. #include <linux/serial_core.h>
  23. #include <linux/console.h>
  24. #include <asm/io.h>
  25. #include <asm/prom.h>
  26. /* sio irq0=0xb00010022 irq0=0xb00010023 irq2=0xb00010024
  27. mmio=0xfff000-0x1000,0xff2000-0x1000 */
  28. static int txx9_serial_bitmap = 0;
  29. static struct {
  30. uint32_t offset;
  31. uint32_t index;
  32. } txx9_scc_tab[3] = {
  33. { 0x300, 0 }, /* 0xFFF300 */
  34. { 0x400, 0 }, /* 0xFFF400 */
  35. { 0x800, 1 } /* 0xFF2800 */
  36. };
  37. static int txx9_serial_init(void)
  38. {
  39. extern int early_serial_txx9_setup(struct uart_port *port);
  40. struct device_node *node;
  41. int i;
  42. struct uart_port req;
  43. struct of_irq irq;
  44. struct resource res;
  45. node = of_find_node_by_path("/ioif1/sio");
  46. if (!node)
  47. return 0;
  48. for(i = 0; i < sizeof(txx9_scc_tab)/sizeof(txx9_scc_tab[0]); i++) {
  49. if (!(txx9_serial_bitmap & (1<<i)))
  50. continue;
  51. if (of_irq_map_one(node, i, &irq))
  52. continue;
  53. if (of_address_to_resource(node, txx9_scc_tab[i].index, &res))
  54. continue;
  55. memset(&req, 0, sizeof(req));
  56. req.line = i;
  57. req.iotype = UPIO_MEM;
  58. req.mapbase = res.start + txx9_scc_tab[i].offset;
  59. #ifdef CONFIG_SERIAL_TXX9_CONSOLE
  60. req.membase = ioremap(req.mapbase, 0x24);
  61. #endif
  62. req.irq = irq_create_of_mapping(irq.controller,
  63. irq.specifier, irq.size);
  64. req.flags |= UPF_IOREMAP | UPF_BUGGY_UART /*HAVE_CTS_LINE*/;
  65. req.uartclk = 83300000;
  66. early_serial_txx9_setup(&req);
  67. }
  68. of_node_put(node);
  69. return 0;
  70. }
  71. static int txx9_serial_config(char *ptr)
  72. {
  73. int i;
  74. for (;;) {
  75. switch(get_option(&ptr, &i)) {
  76. default:
  77. return 0;
  78. case 2:
  79. txx9_serial_bitmap |= 1 << i;
  80. break;
  81. case 1:
  82. txx9_serial_bitmap |= 1 << i;
  83. return 0;
  84. }
  85. }
  86. }
  87. __setup("txx9_serial=", txx9_serial_config);
  88. console_initcall(txx9_serial_init);