dev-uart.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
  7. */
  8. #include <linux/init.h>
  9. #include <linux/kernel.h>
  10. #include <linux/platform_device.h>
  11. #include <bcm63xx_cpu.h>
  12. static struct resource uart0_resources[] = {
  13. {
  14. /* start & end filled at runtime */
  15. .flags = IORESOURCE_MEM,
  16. },
  17. {
  18. /* start filled at runtime */
  19. .flags = IORESOURCE_IRQ,
  20. },
  21. };
  22. static struct resource uart1_resources[] = {
  23. {
  24. /* start & end filled at runtime */
  25. .flags = IORESOURCE_MEM,
  26. },
  27. {
  28. /* start filled at runtime */
  29. .flags = IORESOURCE_IRQ,
  30. },
  31. };
  32. static struct platform_device bcm63xx_uart_devices[] = {
  33. {
  34. .name = "bcm63xx_uart",
  35. .id = 0,
  36. .num_resources = ARRAY_SIZE(uart0_resources),
  37. .resource = uart0_resources,
  38. },
  39. {
  40. .name = "bcm63xx_uart",
  41. .id = 1,
  42. .num_resources = ARRAY_SIZE(uart1_resources),
  43. .resource = uart1_resources,
  44. }
  45. };
  46. int __init bcm63xx_uart_register(unsigned int id)
  47. {
  48. if (id >= ARRAY_SIZE(bcm63xx_uart_devices))
  49. return -ENODEV;
  50. if (id == 1 && (!BCMCPU_IS_3368() && !BCMCPU_IS_6358() &&
  51. !BCMCPU_IS_6368()))
  52. return -ENODEV;
  53. if (id == 0) {
  54. uart0_resources[0].start = bcm63xx_regset_address(RSET_UART0);
  55. uart0_resources[0].end = uart0_resources[0].start +
  56. RSET_UART_SIZE - 1;
  57. uart0_resources[1].start = bcm63xx_get_irq_number(IRQ_UART0);
  58. }
  59. if (id == 1) {
  60. uart1_resources[0].start = bcm63xx_regset_address(RSET_UART1);
  61. uart1_resources[0].end = uart1_resources[0].start +
  62. RSET_UART_SIZE - 1;
  63. uart1_resources[1].start = bcm63xx_get_irq_number(IRQ_UART1);
  64. }
  65. return platform_device_register(&bcm63xx_uart_devices[id]);
  66. }