serial.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * 8250 UART probe driver for the BCM47XX platforms
  3. * Author: Aurelien Jarno
  4. *
  5. * This file is subject to the terms and conditions of the GNU General Public
  6. * License. See the file "COPYING" in the main directory of this archive
  7. * for more details.
  8. *
  9. * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net>
  10. */
  11. #include <linux/init.h>
  12. #include <linux/serial.h>
  13. #include <linux/serial_8250.h>
  14. #include <linux/ssb/ssb.h>
  15. #include <bcm47xx.h>
  16. static struct plat_serial8250_port uart8250_data[5];
  17. static struct platform_device uart8250_device = {
  18. .name = "serial8250",
  19. .id = PLAT8250_DEV_PLATFORM,
  20. .dev = {
  21. .platform_data = uart8250_data,
  22. },
  23. };
  24. #ifdef CONFIG_BCM47XX_SSB
  25. static int __init uart8250_init_ssb(void)
  26. {
  27. int i;
  28. struct ssb_mipscore *mcore = &(bcm47xx_bus.ssb.mipscore);
  29. memset(&uart8250_data, 0, sizeof(uart8250_data));
  30. for (i = 0; i < mcore->nr_serial_ports &&
  31. i < ARRAY_SIZE(uart8250_data) - 1; i++) {
  32. struct plat_serial8250_port *p = &(uart8250_data[i]);
  33. struct ssb_serial_port *ssb_port = &(mcore->serial_ports[i]);
  34. p->mapbase = (unsigned int)ssb_port->regs;
  35. p->membase = (void *)ssb_port->regs;
  36. p->irq = ssb_port->irq + 2;
  37. p->uartclk = ssb_port->baud_base;
  38. p->regshift = ssb_port->reg_shift;
  39. p->iotype = UPIO_MEM;
  40. p->flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
  41. }
  42. return platform_device_register(&uart8250_device);
  43. }
  44. #endif
  45. #ifdef CONFIG_BCM47XX_BCMA
  46. static int __init uart8250_init_bcma(void)
  47. {
  48. int i;
  49. struct bcma_drv_cc *cc = &(bcm47xx_bus.bcma.bus.drv_cc);
  50. memset(&uart8250_data, 0, sizeof(uart8250_data));
  51. for (i = 0; i < cc->nr_serial_ports &&
  52. i < ARRAY_SIZE(uart8250_data) - 1; i++) {
  53. struct plat_serial8250_port *p = &(uart8250_data[i]);
  54. struct bcma_serial_port *bcma_port;
  55. bcma_port = &(cc->serial_ports[i]);
  56. p->mapbase = (unsigned int)bcma_port->regs;
  57. p->membase = (void *)bcma_port->regs;
  58. p->irq = bcma_port->irq;
  59. p->uartclk = bcma_port->baud_base;
  60. p->regshift = bcma_port->reg_shift;
  61. p->iotype = UPIO_MEM;
  62. p->flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
  63. }
  64. return platform_device_register(&uart8250_device);
  65. }
  66. #endif
  67. static int __init uart8250_init(void)
  68. {
  69. switch (bcm47xx_bus_type) {
  70. #ifdef CONFIG_BCM47XX_SSB
  71. case BCM47XX_BUS_TYPE_SSB:
  72. return uart8250_init_ssb();
  73. #endif
  74. #ifdef CONFIG_BCM47XX_BCMA
  75. case BCM47XX_BUS_TYPE_BCMA:
  76. return uart8250_init_bcma();
  77. #endif
  78. }
  79. return -EINVAL;
  80. }
  81. device_initcall(uart8250_init);