39 #include <linux/types.h>
42 #include <linux/slab.h>
44 #include <linux/module.h>
54 static const char hvc_driver_name[] =
"hvc_console";
57 {
"serial",
"hvterm1"},
59 {
"serial",
"hvterm-protocol"},
75 char buf[SIZE_VIO_GET_CHARS];
103 for (i = 1; i < pv->
left; ++
i) {
104 if (pv->
buf[i] == 0 && pv->
buf[i-1] ==
'\r') {
119 spin_unlock_irqrestore(&pv->
buf_lock, flags);
124 static int hvterm_raw_put_chars(
uint32_t vtermno,
const char *buf,
int count)
134 static const struct hv_ops hvterm_raw_ops = {
135 .get_chars = hvterm_raw_get_chars,
136 .put_chars = hvterm_raw_put_chars,
142 static int hvterm_hvsi_get_chars(
uint32_t vtermno,
char *buf,
int count)
152 static int hvterm_hvsi_put_chars(
uint32_t vtermno,
const char *buf,
int count)
176 static void hvterm_hvsi_close(
struct hvc_struct *hp,
int data)
198 static int hvterm_hvsi_tiocmget(
struct hvc_struct *hp)
204 return pv->
hvsi.mctrl;
207 static int hvterm_hvsi_tiocmset(
struct hvc_struct *hp,
unsigned int set,
212 pr_devel(
"HVSI@%x: Set modem control, set=%x,clr=%x\n",
223 static const struct hv_ops hvterm_hvsi_ops = {
224 .get_chars = hvterm_hvsi_get_chars,
225 .put_chars = hvterm_hvsi_put_chars,
226 .notifier_add = hvterm_hvsi_open,
227 .notifier_del = hvterm_hvsi_close,
229 .tiocmget = hvterm_hvsi_tiocmget,
230 .tiocmset = hvterm_hvsi_tiocmset,
233 static void udbg_hvc_putc(
char c)
237 if (!hvterm_privs[0])
244 switch(hvterm_privs[0]->
proto) {
246 count = hvterm_raw_put_chars(0, &c, 1);
249 count = hvterm_hvsi_put_chars(0, &c, 1);
255 static int udbg_hvc_getc_poll(
void)
260 if (!hvterm_privs[0])
263 switch(hvterm_privs[0]->
proto) {
265 rc = hvterm_raw_get_chars(0, &c, 1);
268 rc = hvterm_hvsi_get_chars(0, &c, 1);
276 static int udbg_hvc_getc(
void)
280 if (!hvterm_privs[0])
284 ch = udbg_hvc_getc_poll();
287 volatile unsigned long delay;
288 for (delay=0; delay < 2000000; delay++)
311 ops = &hvterm_raw_ops;
314 ops = &hvterm_hvsi_ops;
316 pr_err(
"hvc_vio: Unkown protocol for %s\n", vdev->
dev.of_node->full_name);
320 pr_devel(
"hvc_vio_probe() device %s, using %s protocol\n",
321 vdev->
dev.of_node->full_name,
325 if (hvterm_privs[0] == &hvterm_priv0 &&
326 vdev->unit_address == hvterm_priv0.termno) {
327 pv = hvterm_privs[0];
329 pr_devel(
"->boot console, using termno 0\n");
334 if (!hvterm_privs[i])
336 pr_devel(
"->non-boot console, using termno %d\n", termno);
342 pv->
termno = vdev->unit_address;
350 hp =
hvc_alloc(termno, vdev->irq, ops, MAX_VIO_PUT_CHARS);
373 if (hvterm_privs[termno] != &hvterm_priv0)
374 kfree(hvterm_privs[termno]);
375 hvterm_privs[termno] =
NULL;
381 .id_table = hvc_driver_table,
382 .probe = hvc_vio_probe,
383 .remove = hvc_vio_remove,
384 .name = hvc_driver_name,
387 static int __init hvc_vio_init(
void)
398 static void __exit hvc_vio_exit(
void)
427 if (
strncmp(name,
"vty", 3) != 0)
432 hvterm_priv0.termno = *termno;
434 hvterm_privs[0] = &hvterm_priv0;
439 ops = &hvterm_raw_ops;
443 ops = &hvterm_hvsi_ops;
445 hvterm_priv0.termno, 1);
463 of_node_put(stdout_node);
469 #ifdef CONFIG_PPC_EARLY_DEBUG_LPAR
470 void __init udbg_init_debug_lpar(
void)
472 hvterm_privs[0] = &hvterm_priv0;
473 hvterm_priv0.termno = 0;
482 #ifdef CONFIG_PPC_EARLY_DEBUG_LPAR_HVSI
483 void __init udbg_init_debug_lpar_hvsi(
void)
485 hvterm_privs[0] = &hvterm_priv0;
486 hvterm_priv0.termno = CONFIG_PPC_EARLY_DEBUG_HVSI_VTERMNO;
493 hvterm_priv0.termno, 1);