serial.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * TI DaVinci serial driver
  3. *
  4. * Copyright (C) 2006 Texas Instruments.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. *
  20. */
  21. #include <linux/kernel.h>
  22. #include <linux/init.h>
  23. #include <linux/serial_8250.h>
  24. #include <linux/serial_reg.h>
  25. #include <linux/platform_device.h>
  26. #include <linux/delay.h>
  27. #include <linux/clk.h>
  28. #include <asm/io.h>
  29. #include <asm/irq.h>
  30. #include <asm/hardware.h>
  31. #include <asm/arch/serial.h>
  32. #include <asm/arch/irqs.h>
  33. #define UART_DAVINCI_PWREMU 0x0c
  34. static inline unsigned int davinci_serial_in(struct plat_serial8250_port *up,
  35. int offset)
  36. {
  37. offset <<= up->regshift;
  38. return (unsigned int)__raw_readb(up->membase + offset);
  39. }
  40. static inline void davinci_serial_outp(struct plat_serial8250_port *p,
  41. int offset, int value)
  42. {
  43. offset <<= p->regshift;
  44. __raw_writeb(value, p->membase + offset);
  45. }
  46. static struct plat_serial8250_port serial_platform_data[] = {
  47. {
  48. .membase = (char *)IO_ADDRESS(DAVINCI_UART0_BASE),
  49. .mapbase = (unsigned long)DAVINCI_UART0_BASE,
  50. .irq = IRQ_UARTINT0,
  51. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
  52. .iotype = UPIO_MEM,
  53. .regshift = 2,
  54. .uartclk = 27000000,
  55. },
  56. {
  57. .flags = 0
  58. },
  59. };
  60. static struct platform_device serial_device = {
  61. .name = "serial8250",
  62. .id = PLAT8250_DEV_PLATFORM,
  63. .dev = {
  64. .platform_data = serial_platform_data,
  65. },
  66. };
  67. static void __init davinci_serial_reset(struct plat_serial8250_port *p)
  68. {
  69. /* reset both transmitter and receiver: bits 14,13 = UTRST, URRST */
  70. unsigned int pwremu = 0;
  71. davinci_serial_outp(p, UART_IER, 0); /* disable all interrupts */
  72. davinci_serial_outp(p, UART_DAVINCI_PWREMU, pwremu);
  73. mdelay(10);
  74. pwremu |= (0x3 << 13);
  75. pwremu |= 0x1;
  76. davinci_serial_outp(p, UART_DAVINCI_PWREMU, pwremu);
  77. }
  78. static int __init davinci_init(void)
  79. {
  80. davinci_serial_reset(&serial_platform_data[0]);
  81. return platform_device_register(&serial_device);
  82. }
  83. arch_initcall(davinci_init);