dev-uart.c 1.8 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. #include <bcm63xx_dev_uart.h>
  13. static struct resource uart0_resources[] = {
  14. {
  15. /* start & end filled at runtime */
  16. .flags = IORESOURCE_MEM,
  17. },
  18. {
  19. /* start filled at runtime */
  20. .flags = IORESOURCE_IRQ,
  21. },
  22. };
  23. static struct resource uart1_resources[] = {
  24. {
  25. /* start & end filled at runtime */
  26. .flags = IORESOURCE_MEM,
  27. },
  28. {
  29. /* start filled at runtime */
  30. .flags = IORESOURCE_IRQ,
  31. },
  32. };
  33. static struct platform_device bcm63xx_uart_devices[] = {
  34. {
  35. .name = "bcm63xx_uart",
  36. .id = 0,
  37. .num_resources = ARRAY_SIZE(uart0_resources),
  38. .resource = uart0_resources,
  39. },
  40. {
  41. .name = "bcm63xx_uart",
  42. .id = 1,
  43. .num_resources = ARRAY_SIZE(uart1_resources),
  44. .resource = uart1_resources,
  45. }
  46. };
  47. int __init bcm63xx_uart_register(unsigned int id)
  48. {
  49. if (id >= ARRAY_SIZE(bcm63xx_uart_devices))
  50. return -ENODEV;
  51. if (id == 1 && (!BCMCPU_IS_3368() && !BCMCPU_IS_6358() &&
  52. !BCMCPU_IS_6368()))
  53. return -ENODEV;
  54. if (id == 0) {
  55. uart0_resources[0].start = bcm63xx_regset_address(RSET_UART0);
  56. uart0_resources[0].end = uart0_resources[0].start +
  57. RSET_UART_SIZE - 1;
  58. uart0_resources[1].start = bcm63xx_get_irq_number(IRQ_UART0);
  59. }
  60. if (id == 1) {
  61. uart1_resources[0].start = bcm63xx_regset_address(RSET_UART1);
  62. uart1_resources[0].end = uart1_resources[0].start +
  63. RSET_UART_SIZE - 1;
  64. uart1_resources[1].start = bcm63xx_get_irq_number(IRQ_UART1);
  65. }
  66. return platform_device_register(&bcm63xx_uart_devices[id]);
  67. }