plat-serial8250.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * arch/arm/mach-ns9xxx/plat-serial8250.c
  3. *
  4. * Copyright (C) 2008 by Digi International Inc.
  5. * All rights reserved.
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published by
  9. * the Free Software Foundation.
  10. */
  11. #include <linux/platform_device.h>
  12. #include <linux/serial_8250.h>
  13. #include <mach/regs-board-a9m9750dev.h>
  14. #include <mach/board.h>
  15. #define DRIVER_NAME "serial8250"
  16. static int __init ns9xxx_plat_serial8250_init(void)
  17. {
  18. struct plat_serial8250_port *pdata;
  19. struct platform_device *pdev;
  20. int ret = -ENOMEM;
  21. int i;
  22. if (!board_is_a9m9750dev())
  23. return -ENODEV;
  24. pdev = platform_device_alloc(DRIVER_NAME, 0);
  25. if (!pdev)
  26. goto err;
  27. pdata = kzalloc(5 * sizeof(*pdata), GFP_KERNEL);
  28. if (!pdata)
  29. goto err;
  30. pdev->dev.platform_data = pdata;
  31. pdata[0].iobase = FPGA_UARTA_BASE;
  32. pdata[1].iobase = FPGA_UARTB_BASE;
  33. pdata[2].iobase = FPGA_UARTC_BASE;
  34. pdata[3].iobase = FPGA_UARTD_BASE;
  35. for (i = 0; i < 4; ++i) {
  36. pdata[i].membase = (void __iomem *)pdata[i].iobase;
  37. pdata[i].mapbase = pdata[i].iobase;
  38. pdata[i].iotype = UPIO_MEM;
  39. pdata[i].uartclk = 18432000;
  40. pdata[i].flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
  41. }
  42. pdata[0].irq = IRQ_FPGA_UARTA;
  43. pdata[1].irq = IRQ_FPGA_UARTB;
  44. pdata[2].irq = IRQ_FPGA_UARTC;
  45. pdata[3].irq = IRQ_FPGA_UARTD;
  46. ret = platform_device_add(pdev);
  47. if (ret) {
  48. err:
  49. platform_device_put(pdev);
  50. printk(KERN_WARNING "Could not add %s (errno=%d)\n",
  51. DRIVER_NAME, ret);
  52. }
  53. return 0;
  54. }
  55. arch_initcall(ns9xxx_plat_serial8250_init);