ce4100.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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/reboot.h>
  16. #include <linux/serial_reg.h>
  17. #include <linux/serial_8250.h>
  18. #include <linux/reboot.h>
  19. #include <asm/ce4100.h>
  20. #include <asm/prom.h>
  21. #include <asm/setup.h>
  22. #include <asm/i8259.h>
  23. #include <asm/io.h>
  24. #include <asm/io_apic.h>
  25. #include <asm/emergency-restart.h>
  26. static int ce4100_i8042_detect(void)
  27. {
  28. return 0;
  29. }
  30. /*
  31. * The CE4100 platform has an internal 8051 Microcontroller which is
  32. * responsible for signaling to the external Power Management Unit the
  33. * intention to reset, reboot or power off the system. This 8051 device has
  34. * its command register mapped at I/O port 0xcf9 and the value 0x4 is used
  35. * to power off the system.
  36. */
  37. static void ce4100_power_off(void)
  38. {
  39. outb(0x4, 0xcf9);
  40. }
  41. #ifdef CONFIG_SERIAL_8250
  42. static unsigned int mem_serial_in(struct uart_port *p, int offset)
  43. {
  44. offset = offset << p->regshift;
  45. return readl(p->membase + offset);
  46. }
  47. /*
  48. * The UART Tx interrupts are not set under some conditions and therefore serial
  49. * transmission hangs. This is a silicon issue and has not been root caused. The
  50. * workaround for this silicon issue checks UART_LSR_THRE bit and UART_LSR_TEMT
  51. * bit of LSR register in interrupt handler to see whether at least one of these
  52. * two bits is set, if so then process the transmit request. If this workaround
  53. * is not applied, then the serial transmission may hang. This workaround is for
  54. * errata number 9 in Errata - B step.
  55. */
  56. static unsigned int ce4100_mem_serial_in(struct uart_port *p, int offset)
  57. {
  58. unsigned int ret, ier, lsr;
  59. if (offset == UART_IIR) {
  60. offset = offset << p->regshift;
  61. ret = readl(p->membase + offset);
  62. if (ret & UART_IIR_NO_INT) {
  63. /* see if the TX interrupt should have really set */
  64. ier = mem_serial_in(p, UART_IER);
  65. /* see if the UART's XMIT interrupt is enabled */
  66. if (ier & UART_IER_THRI) {
  67. lsr = mem_serial_in(p, UART_LSR);
  68. /* now check to see if the UART should be
  69. generating an interrupt (but isn't) */
  70. if (lsr & (UART_LSR_THRE | UART_LSR_TEMT))
  71. ret &= ~UART_IIR_NO_INT;
  72. }
  73. }
  74. } else
  75. ret = mem_serial_in(p, offset);
  76. return ret;
  77. }
  78. static void ce4100_mem_serial_out(struct uart_port *p, int offset, int value)
  79. {
  80. offset = offset << p->regshift;
  81. writel(value, p->membase + offset);
  82. }
  83. static void ce4100_serial_fixup(int port, struct uart_port *up,
  84. unsigned short *capabilites)
  85. {
  86. #ifdef CONFIG_EARLY_PRINTK
  87. /*
  88. * Over ride the legacy port configuration that comes from
  89. * asm/serial.h. Using the ioport driver then switching to the
  90. * PCI memmaped driver hangs the IOAPIC
  91. */
  92. if (up->iotype != UPIO_MEM32) {
  93. up->uartclk = 14745600;
  94. up->mapbase = 0xdffe0200;
  95. set_fixmap_nocache(FIX_EARLYCON_MEM_BASE,
  96. up->mapbase & PAGE_MASK);
  97. up->membase =
  98. (void __iomem *)__fix_to_virt(FIX_EARLYCON_MEM_BASE);
  99. up->membase += up->mapbase & ~PAGE_MASK;
  100. up->mapbase += port * 0x100;
  101. up->membase += port * 0x100;
  102. up->iotype = UPIO_MEM32;
  103. up->regshift = 2;
  104. up->irq = 4;
  105. }
  106. #endif
  107. up->iobase = 0;
  108. up->serial_in = ce4100_mem_serial_in;
  109. up->serial_out = ce4100_mem_serial_out;
  110. *capabilites |= (1 << 12);
  111. }
  112. static __init void sdv_serial_fixup(void)
  113. {
  114. serial8250_set_isa_configurator(ce4100_serial_fixup);
  115. }
  116. #else
  117. static inline void sdv_serial_fixup(void) {};
  118. #endif
  119. static void __init sdv_arch_setup(void)
  120. {
  121. sdv_serial_fixup();
  122. }
  123. #ifdef CONFIG_X86_IO_APIC
  124. static void sdv_pci_init(void)
  125. {
  126. x86_of_pci_init();
  127. /* We can't set this earlier, because we need to calibrate the timer */
  128. legacy_pic = &null_legacy_pic;
  129. }
  130. #endif
  131. /*
  132. * CE4100 specific x86_init function overrides and early setup
  133. * calls.
  134. */
  135. void __init x86_ce4100_early_setup(void)
  136. {
  137. x86_init.oem.arch_setup = sdv_arch_setup;
  138. x86_platform.i8042_detect = ce4100_i8042_detect;
  139. x86_init.resources.probe_roms = x86_init_noop;
  140. x86_init.mpparse.get_smp_config = x86_init_uint_noop;
  141. x86_init.mpparse.find_smp_config = x86_init_noop;
  142. x86_init.pci.init = ce4100_pci_init;
  143. /*
  144. * By default, the reboot method is ACPI which is supported by the
  145. * CE4100 bootloader CEFDK using FADT.ResetReg Address and ResetValue
  146. * the bootloader will however issue a system power off instead of
  147. * reboot. By using BOOT_KBD we ensure proper system reboot as
  148. * expected.
  149. */
  150. reboot_type = BOOT_KBD;
  151. #ifdef CONFIG_X86_IO_APIC
  152. x86_init.pci.init_irq = sdv_pci_init;
  153. x86_init.mpparse.setup_ioapic_ids = setup_ioapic_ids_from_mpc_nocheck;
  154. #endif
  155. pm_power_off = ce4100_power_off;
  156. }