celleb_scc_sio.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * setup serial port in SCC
  3. *
  4. * (C) Copyright 2006-2007 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 __initdata;
  29. static struct {
  30. uint32_t offset;
  31. uint32_t index;
  32. } txx9_scc_tab[3] __initdata = {
  33. { 0x300, 0 }, /* 0xFFF300 */
  34. { 0x400, 0 }, /* 0xFFF400 */
  35. { 0x800, 1 } /* 0xFF2800 */
  36. };
  37. static int __init txx9_serial_init(void)
  38. {
  39. extern int early_serial_txx9_setup(struct uart_port *port);
  40. struct device_node *node = NULL;
  41. int i;
  42. struct uart_port req;
  43. struct of_irq irq;
  44. struct resource res;
  45. while ((node = of_find_compatible_node(node,
  46. "serial", "toshiba,sio-scc")) != NULL) {
  47. for (i = 0; i < ARRAY_SIZE(txx9_scc_tab); i++) {
  48. if (!(txx9_serial_bitmap & (1<<i)))
  49. continue;
  50. if (of_irq_map_one(node, i, &irq))
  51. continue;
  52. if (of_address_to_resource(node,
  53. 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
  65. /*HAVE_CTS_LINE*/;
  66. req.uartclk = 83300000;
  67. early_serial_txx9_setup(&req);
  68. }
  69. }
  70. return 0;
  71. }
  72. static int __init txx9_serial_config(char *ptr)
  73. {
  74. int i;
  75. for (;;) {
  76. switch (get_option(&ptr, &i)) {
  77. default:
  78. return 0;
  79. case 2:
  80. txx9_serial_bitmap |= 1 << i;
  81. break;
  82. case 1:
  83. txx9_serial_bitmap |= 1 << i;
  84. return 0;
  85. }
  86. }
  87. }
  88. __setup("txx9_serial=", txx9_serial_config);
  89. console_initcall(txx9_serial_init);