serial.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Registration of WRPPMC UART platform device.
  3. *
  4. * Copyright (C) 2007 Yoichi Yuasa <yuasa@linux-mips.org>
  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 Street, 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/gt64120.h>
  26. static struct resource wrppmc_uart_resource[] __initdata = {
  27. {
  28. .start = WRPPMC_UART16550_BASE,
  29. .end = WRPPMC_UART16550_BASE + 7,
  30. .flags = IORESOURCE_MEM,
  31. },
  32. {
  33. .start = WRPPMC_UART16550_IRQ,
  34. .end = WRPPMC_UART16550_IRQ,
  35. .flags = IORESOURCE_IRQ,
  36. },
  37. };
  38. static struct plat_serial8250_port wrppmc_serial8250_port[] = {
  39. {
  40. .irq = WRPPMC_UART16550_IRQ,
  41. .uartclk = WRPPMC_UART16550_CLOCK,
  42. .iotype = UPIO_MEM,
  43. .flags = UPF_IOREMAP | UPF_SKIP_TEST,
  44. .mapbase = WRPPMC_UART16550_BASE,
  45. },
  46. {},
  47. };
  48. static __init int wrppmc_uart_add(void)
  49. {
  50. struct platform_device *pdev;
  51. int retval;
  52. pdev = platform_device_alloc("serial8250", -1);
  53. if (!pdev)
  54. return -ENOMEM;
  55. pdev->id = PLAT8250_DEV_PLATFORM;
  56. pdev->dev.platform_data = wrppmc_serial8250_port;
  57. retval = platform_device_add_resources(pdev, wrppmc_uart_resource,
  58. ARRAY_SIZE(wrppmc_uart_resource));
  59. if (retval)
  60. goto err_free_device;
  61. retval = platform_device_add(pdev);
  62. if (retval)
  63. goto err_free_device;
  64. return 0;
  65. err_free_device:
  66. platform_device_put(pdev);
  67. return retval;
  68. }
  69. device_initcall(wrppmc_uart_add);