ce4100.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * Intel CE4100 platform specific setup code
  3. *
  4. * (C) Copyright 2010 Intel Corporation
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; version 2
  9. * of the License.
  10. */
  11. #include <linux/init.h>
  12. #include <linux/kernel.h>
  13. #include <linux/irq.h>
  14. #include <linux/module.h>
  15. #include <linux/serial_reg.h>
  16. #include <linux/serial_8250.h>
  17. #include <asm/ce4100.h>
  18. #include <asm/prom.h>
  19. #include <asm/setup.h>
  20. #include <asm/i8259.h>
  21. #include <asm/io.h>
  22. #include <asm/io_apic.h>
  23. static int ce4100_i8042_detect(void)
  24. {
  25. return 0;
  26. }
  27. #ifdef CONFIG_SERIAL_8250
  28. static unsigned int mem_serial_in(struct uart_port *p, int offset)
  29. {
  30. offset = offset << p->regshift;
  31. return readl(p->membase + offset);
  32. }
  33. /*
  34. * The UART Tx interrupts are not set under some conditions and therefore serial
  35. * transmission hangs. This is a silicon issue and has not been root caused. The
  36. * workaround for this silicon issue checks UART_LSR_THRE bit and UART_LSR_TEMT
  37. * bit of LSR register in interrupt handler to see whether at least one of these
  38. * two bits is set, if so then process the transmit request. If this workaround
  39. * is not applied, then the serial transmission may hang. This workaround is for
  40. * errata number 9 in Errata - B step.
  41. */
  42. static unsigned int ce4100_mem_serial_in(struct uart_port *p, int offset)
  43. {
  44. unsigned int ret, ier, lsr;
  45. if (offset == UART_IIR) {
  46. offset = offset << p->regshift;
  47. ret = readl(p->membase + offset);
  48. if (ret & UART_IIR_NO_INT) {
  49. /* see if the TX interrupt should have really set */
  50. ier = mem_serial_in(p, UART_IER);
  51. /* see if the UART's XMIT interrupt is enabled */
  52. if (ier & UART_IER_THRI) {
  53. lsr = mem_serial_in(p, UART_LSR);
  54. /* now check to see if the UART should be
  55. generating an interrupt (but isn't) */
  56. if (lsr & (UART_LSR_THRE | UART_LSR_TEMT))
  57. ret &= ~UART_IIR_NO_INT;
  58. }
  59. }
  60. } else
  61. ret = mem_serial_in(p, offset);
  62. return ret;
  63. }
  64. static void ce4100_mem_serial_out(struct uart_port *p, int offset, int value)
  65. {
  66. offset = offset << p->regshift;
  67. writel(value, p->membase + offset);
  68. }
  69. static void ce4100_serial_fixup(int port, struct uart_port *up,
  70. unsigned short *capabilites)
  71. {
  72. #ifdef CONFIG_EARLY_PRINTK
  73. /*
  74. * Over ride the legacy port configuration that comes from
  75. * asm/serial.h. Using the ioport driver then switching to the
  76. * PCI memmaped driver hangs the IOAPIC
  77. */
  78. if (up->iotype != UPIO_MEM32) {
  79. up->uartclk = 14745600;
  80. up->mapbase = 0xdffe0200;
  81. set_fixmap_nocache(FIX_EARLYCON_MEM_BASE,
  82. up->mapbase & PAGE_MASK);
  83. up->membase =
  84. (void __iomem *)__fix_to_virt(FIX_EARLYCON_MEM_BASE);
  85. up->membase += up->mapbase & ~PAGE_MASK;
  86. up->iotype = UPIO_MEM32;
  87. up->regshift = 2;
  88. }
  89. #endif
  90. up->iobase = 0;
  91. up->serial_in = ce4100_mem_serial_in;
  92. up->serial_out = ce4100_mem_serial_out;
  93. *capabilites |= (1 << 12);
  94. }
  95. static __init void sdv_serial_fixup(void)
  96. {
  97. serial8250_set_isa_configurator(ce4100_serial_fixup);
  98. }
  99. #else
  100. static inline void sdv_serial_fixup(void) {};
  101. #endif
  102. static void __init sdv_arch_setup(void)
  103. {
  104. sdv_serial_fixup();
  105. }
  106. #ifdef CONFIG_X86_IO_APIC
  107. static void __cpuinit sdv_pci_init(void)
  108. {
  109. x86_of_pci_init();
  110. /* We can't set this earlier, because we need to calibrate the timer */
  111. legacy_pic = &null_legacy_pic;
  112. }
  113. #endif
  114. /*
  115. * CE4100 specific x86_init function overrides and early setup
  116. * calls.
  117. */
  118. void __init x86_ce4100_early_setup(void)
  119. {
  120. x86_init.oem.arch_setup = sdv_arch_setup;
  121. x86_platform.i8042_detect = ce4100_i8042_detect;
  122. x86_init.resources.probe_roms = x86_init_noop;
  123. x86_init.mpparse.get_smp_config = x86_init_uint_noop;
  124. x86_init.mpparse.find_smp_config = x86_init_noop;
  125. x86_init.pci.init = ce4100_pci_init;
  126. #ifdef CONFIG_X86_IO_APIC
  127. x86_init.pci.init_irq = sdv_pci_init;
  128. x86_init.mpparse.setup_ioapic_ids = setup_ioapic_ids_from_mpc_nocheck;
  129. #endif
  130. }