serial.c 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Registration of Lasat UART platform device.
  3. *
  4. * Copyright (C) 2007 Brian Murphy <brian@murphy.dk>
  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
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <linux/errno.h>
  21. #include <linux/init.h>
  22. #include <linux/ioport.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/serial_8250.h>
  25. #include <asm/lasat/lasat.h>
  26. #include <asm/lasat/serial.h>
  27. static struct resource lasat_serial_res[2] __initdata;
  28. static struct plat_serial8250_port lasat_serial8250_port[] = {
  29. {
  30. .iotype = UPIO_MEM,
  31. .flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF |
  32. UPF_SKIP_TEST,
  33. },
  34. {},
  35. };
  36. static __init int lasat_uart_add(void)
  37. {
  38. struct platform_device *pdev;
  39. int retval;
  40. pdev = platform_device_alloc("serial8250", -1);
  41. if (!pdev)
  42. return -ENOMEM;
  43. if (!IS_LASAT_200()) {
  44. lasat_serial_res[0].start = KSEG1ADDR(LASAT_UART_REGS_BASE_100);
  45. lasat_serial_res[0].end = lasat_serial_res[0].start + LASAT_UART_REGS_SHIFT_100 * 8 - 1;
  46. lasat_serial_res[0].flags = IORESOURCE_MEM;
  47. lasat_serial_res[1].start = LASATINT_UART_100;
  48. lasat_serial_res[1].end = LASATINT_UART_100;
  49. lasat_serial_res[1].flags = IORESOURCE_IRQ;
  50. lasat_serial8250_port[0].mapbase = LASAT_UART_REGS_BASE_100;
  51. lasat_serial8250_port[0].uartclk = LASAT_BASE_BAUD_100 * 16;
  52. lasat_serial8250_port[0].regshift = LASAT_UART_REGS_SHIFT_100;
  53. lasat_serial8250_port[0].irq = LASATINT_UART_100;
  54. } else {
  55. lasat_serial_res[0].start = KSEG1ADDR(LASAT_UART_REGS_BASE_200);
  56. lasat_serial_res[0].end = lasat_serial_res[0].start + LASAT_UART_REGS_SHIFT_200 * 8 - 1;
  57. lasat_serial_res[0].flags = IORESOURCE_MEM;
  58. lasat_serial_res[1].start = LASATINT_UART_200;
  59. lasat_serial_res[1].end = LASATINT_UART_200;
  60. lasat_serial_res[1].flags = IORESOURCE_IRQ;
  61. lasat_serial8250_port[0].mapbase = LASAT_UART_REGS_BASE_200;
  62. lasat_serial8250_port[0].uartclk = LASAT_BASE_BAUD_200 * 16;
  63. lasat_serial8250_port[0].regshift = LASAT_UART_REGS_SHIFT_200;
  64. lasat_serial8250_port[0].irq = LASATINT_UART_200;
  65. }
  66. pdev->id = PLAT8250_DEV_PLATFORM;
  67. pdev->dev.platform_data = lasat_serial8250_port;
  68. retval = platform_device_add_resources(pdev, lasat_serial_res, ARRAY_SIZE(lasat_serial_res));
  69. if (retval)
  70. goto err_free_device;
  71. retval = platform_device_add(pdev);
  72. if (retval)
  73. goto err_free_device;
  74. return 0;
  75. err_free_device:
  76. platform_device_put(pdev);
  77. return retval;
  78. }
  79. device_initcall(lasat_uart_add);