1
/* Copyright 2013-2014 IBM Corp.
3
* Licensed under the Apache License, Version 2.0 (the "License");
4
* you may not use this file except in compliance with the License.
5
* You may obtain a copy of the License at
7
* http://www.apache.org/licenses/LICENSE-2.0
9
* Unless required by applicable law or agreed to in writing, software
10
* distributed under the License is distributed on an "AS IS" BASIS,
11
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
25
static void qemu_init(void)
27
/* Setup UART console for use by Linux via OPAL API */
28
if (!dummy_console_enabled())
29
uart_setup_opal_console();
31
/* Setup LPC RTC and use it as time source. Call after
37
static void qemu_dt_fixup_uart(struct dt_node *lpc)
40
* The official OF ISA/LPC binding is a bit odd, it prefixes
41
* the unit address for IO with "i". It uses 2 cells, the first
42
* one indicating IO vs. Memory space (along with bits to
43
* represent aliasing).
45
* We pickup that binding and add to it "2" as a indication
48
* TODO: Probe the UART instead if the LPC bus allows for it
52
#define UART_IO_BASE 0x3f8
53
#define UART_IO_COUNT 8
54
#define UART_LPC_IRQ 4
56
snprintf(namebuf, sizeof(namebuf), "serial@i%x", UART_IO_BASE);
57
uart = dt_new(lpc, namebuf);
59
dt_add_property_cells(uart, "reg",
61
UART_IO_BASE, UART_IO_COUNT);
62
dt_add_property_strings(uart, "compatible",
65
dt_add_property_cells(uart, "clock-frequency", 1843200);
66
dt_add_property_cells(uart, "current-speed", 115200);
67
dt_add_property_cells(uart, "interrupts", UART_LPC_IRQ);
68
dt_add_property_cells(uart, "interrupt-parent", lpc->phandle);
71
* This is needed by Linux for some obscure reasons,
72
* we'll eventually need to sanitize it but in the meantime
73
* let's make sure it's there
75
dt_add_property_strings(uart, "device_type", "serial");
79
* This adds the legacy RTC device to the device-tree
82
static void qemu_dt_fixup_rtc(struct dt_node *lpc)
88
* Follows the structure expected by the kernel file
89
* arch/powerpc/sysdev/rtc_cmos_setup.c
91
snprintf(namebuf, sizeof(namebuf), "rtc@i%x", 0x70);
92
rtc = dt_new(lpc, namebuf);
93
dt_add_property_string(rtc, "compatible", "pnpPNP,b00");
94
dt_add_property_cells(rtc, "reg",
99
static void qemu_dt_fixup(void)
101
struct dt_node *n, *primary_lpc = NULL;
103
/* Find the primary LPC bus */
104
dt_for_each_compatible(dt_root, n, "ibm,power8-lpc") {
105
if (!primary_lpc || dt_has_node_property(n, "primary", NULL))
107
if (dt_has_node_property(n, "#address-cells", NULL))
114
qemu_dt_fixup_rtc(primary_lpc);
115
qemu_dt_fixup_uart(primary_lpc);
118
static void qemu_ext_irq_serirq_cpld(unsigned int chip_id)
120
lpc_all_interrupts(chip_id);
123
static bool qemu_probe(void)
125
if (!dt_node_is_compatible(dt_root, "qemu,powernv"))
128
/* Add missing bits of device-tree such as the UART */
131
psi_set_external_irq_policy(EXTERNAL_IRQ_POLICY_SKIBOOT);
133
/* Setup UART and use it as console */
139
DECLARE_PLATFORM(qemu) = {
143
.external_irq = qemu_ext_irq_serirq_cpld,