serial.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Registration of Cobalt UART platform device.
  4. *
  5. * Copyright (C) 2007 Yoichi Yuasa <[email protected]>
  6. */
  7. #include <linux/errno.h>
  8. #include <linux/init.h>
  9. #include <linux/ioport.h>
  10. #include <linux/platform_device.h>
  11. #include <linux/serial_8250.h>
  12. #include <cobalt.h>
  13. #include <irq.h>
  14. static struct resource cobalt_uart_resource[] __initdata = {
  15. {
  16. .start = 0x1c800000,
  17. .end = 0x1c800007,
  18. .flags = IORESOURCE_MEM,
  19. },
  20. {
  21. .start = SERIAL_IRQ,
  22. .end = SERIAL_IRQ,
  23. .flags = IORESOURCE_IRQ,
  24. },
  25. };
  26. static struct plat_serial8250_port cobalt_serial8250_port[] = {
  27. {
  28. .irq = SERIAL_IRQ,
  29. .uartclk = 18432000,
  30. .iotype = UPIO_MEM,
  31. .flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
  32. .mapbase = 0x1c800000,
  33. },
  34. {},
  35. };
  36. static __init int cobalt_uart_add(void)
  37. {
  38. struct platform_device *pdev;
  39. int retval;
  40. /*
  41. * Cobalt Qube1 has no UART.
  42. */
  43. if (cobalt_board_id == COBALT_BRD_ID_QUBE1)
  44. return 0;
  45. pdev = platform_device_alloc("serial8250", -1);
  46. if (!pdev)
  47. return -ENOMEM;
  48. pdev->id = PLAT8250_DEV_PLATFORM;
  49. pdev->dev.platform_data = cobalt_serial8250_port;
  50. retval = platform_device_add_resources(pdev, cobalt_uart_resource, ARRAY_SIZE(cobalt_uart_resource));
  51. if (retval)
  52. goto err_free_device;
  53. retval = platform_device_add(pdev);
  54. if (retval)
  55. goto err_free_device;
  56. return 0;
  57. err_free_device:
  58. platform_device_put(pdev);
  59. return retval;
  60. }
  61. device_initcall(cobalt_uart_add);