2 * Copyright (c) 2016 IBM Corporation.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
14 #include "../include/asm/opal-api.h"
18 /* Global OPAL struct used by opal-call.S */
24 static u32 opal_con_id;
26 int64_t opal_console_write(int64_t term_number, u64 *length, const u8 *buffer);
27 int64_t opal_console_read(int64_t term_number, uint64_t *length, u8 *buffer);
28 int64_t opal_console_write_buffer_space(uint64_t term_number, uint64_t *length);
29 int64_t opal_console_flush(uint64_t term_number);
30 int64_t opal_poll_events(uint64_t *outstanding_event_mask);
32 static int opal_con_open(void)
37 static void opal_con_putc(unsigned char c)
43 rc = opal_console_write_buffer_space(opal_con_id, &olen);
44 len = be64_to_cpu(olen);
47 opal_poll_events(NULL);
51 olen = cpu_to_be64(1);
52 opal_console_write(opal_con_id, &olen, &c);
55 static void opal_con_close(void)
57 opal_console_flush(opal_con_id);
60 static void opal_init(void)
64 opal_node = finddevice("/ibm,opal");
67 if (getprop(opal_node, "opal-base-address", &opal.base, sizeof(u64)) < 0)
69 opal.base = be64_to_cpu(opal.base);
70 if (getprop(opal_node, "opal-entry-address", &opal.entry, sizeof(u64)) < 0)
72 opal.entry = be64_to_cpu(opal.entry);
75 int opal_console_init(void *devp, struct serial_console_data *scdp)
80 int n = getprop(devp, "reg", &opal_con_id, sizeof(u32));
83 opal_con_id = be32_to_cpu(opal_con_id);
87 scdp->open = opal_con_open;
88 scdp->putc = opal_con_putc;
89 scdp->close = opal_con_close;
94 int opal_console_init(void *devp, struct serial_console_data *scdp)
98 #endif /* __powerpc64__ */