blob: cd6f184c3b3f181e5431a50e1639e746c917bb76 [file] [log] [blame]
Thomas Gleixnerc751e172010-11-09 12:08:04 -08001/*
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>
Dirk Brandewie5ec69602010-11-22 06:28:48 -080015#include <linux/serial_reg.h>
16#include <linux/serial_8250.h>
Thomas Gleixnerc751e172010-11-09 12:08:04 -080017
Sebastian Andrzej Siewior03150172011-03-14 10:33:40 +010018#include <asm/ce4100.h>
Thomas Gleixnerc751e172010-11-09 12:08:04 -080019#include <asm/setup.h>
Dirk Brandewie5ec69602010-11-22 06:28:48 -080020#include <asm/io.h>
Thomas Gleixnerc751e172010-11-09 12:08:04 -080021
22static int ce4100_i8042_detect(void)
23{
24 return 0;
25}
26
Dirk Brandewie5ec69602010-11-22 06:28:48 -080027static void __init sdv_find_smp_config(void)
Thomas Gleixnerc751e172010-11-09 12:08:04 -080028{
29}
30
Dirk Brandewie5ec69602010-11-22 06:28:48 -080031#ifdef CONFIG_SERIAL_8250
32
33
34static unsigned int mem_serial_in(struct uart_port *p, int offset)
Thomas Gleixnerc751e172010-11-09 12:08:04 -080035{
Dirk Brandewie5ec69602010-11-22 06:28:48 -080036 offset = offset << p->regshift;
37 return readl(p->membase + offset);
38}
39
40/*
41 * The UART Tx interrupts are not set under some conditions and therefore serial
42 * transmission hangs. This is a silicon issue and has not been root caused. The
43 * workaround for this silicon issue checks UART_LSR_THRE bit and UART_LSR_TEMT
44 * bit of LSR register in interrupt handler to see whether at least one of these
45 * two bits is set, if so then process the transmit request. If this workaround
46 * is not applied, then the serial transmission may hang. This workaround is for
47 * errata number 9 in Errata - B step.
48*/
49
50static unsigned int ce4100_mem_serial_in(struct uart_port *p, int offset)
51{
52 unsigned int ret, ier, lsr;
53
54 if (offset == UART_IIR) {
55 offset = offset << p->regshift;
56 ret = readl(p->membase + offset);
57 if (ret & UART_IIR_NO_INT) {
58 /* see if the TX interrupt should have really set */
59 ier = mem_serial_in(p, UART_IER);
60 /* see if the UART's XMIT interrupt is enabled */
61 if (ier & UART_IER_THRI) {
62 lsr = mem_serial_in(p, UART_LSR);
63 /* now check to see if the UART should be
64 generating an interrupt (but isn't) */
65 if (lsr & (UART_LSR_THRE | UART_LSR_TEMT))
66 ret &= ~UART_IIR_NO_INT;
67 }
68 }
69 } else
70 ret = mem_serial_in(p, offset);
71 return ret;
72}
73
74static void ce4100_mem_serial_out(struct uart_port *p, int offset, int value)
75{
76 offset = offset << p->regshift;
77 writel(value, p->membase + offset);
78}
79
80static void ce4100_serial_fixup(int port, struct uart_port *up,
81 unsigned short *capabilites)
82{
83#ifdef CONFIG_EARLY_PRINTK
84 /*
85 * Over ride the legacy port configuration that comes from
86 * asm/serial.h. Using the ioport driver then switching to the
87 * PCI memmaped driver hangs the IOAPIC
88 */
89 if (up->iotype != UPIO_MEM32) {
90 up->uartclk = 14745600;
91 up->mapbase = 0xdffe0200;
92 set_fixmap_nocache(FIX_EARLYCON_MEM_BASE,
93 up->mapbase & PAGE_MASK);
94 up->membase =
95 (void __iomem *)__fix_to_virt(FIX_EARLYCON_MEM_BASE);
96 up->membase += up->mapbase & ~PAGE_MASK;
97 up->iotype = UPIO_MEM32;
98 up->regshift = 2;
99 }
100#endif
101 up->iobase = 0;
102 up->serial_in = ce4100_mem_serial_in;
103 up->serial_out = ce4100_mem_serial_out;
104
105 *capabilites |= (1 << 12);
106}
107
108static __init void sdv_serial_fixup(void)
109{
110 serial8250_set_isa_configurator(ce4100_serial_fixup);
111}
112
113#else
114static inline void sdv_serial_fixup(void);
115#endif
116
117static void __init sdv_arch_setup(void)
118{
119 sdv_serial_fixup();
Thomas Gleixnerc751e172010-11-09 12:08:04 -0800120}
121
122/*
123 * CE4100 specific x86_init function overrides and early setup
124 * calls.
125 */
126void __init x86_ce4100_early_setup(void)
127{
128 x86_init.oem.arch_setup = sdv_arch_setup;
129 x86_platform.i8042_detect = ce4100_i8042_detect;
130 x86_init.resources.probe_roms = x86_init_noop;
131 x86_init.mpparse.get_smp_config = x86_init_uint_noop;
132 x86_init.mpparse.find_smp_config = sdv_find_smp_config;
Sebastian Andrzej Siewior03150172011-03-14 10:33:40 +0100133 x86_init.pci.init = ce4100_pci_init;
Thomas Gleixnerc751e172010-11-09 12:08:04 -0800134}