18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * init.c:  Initialize internal variables used by the PROM
48c2ecf20Sopenharmony_ci *          library functions.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
78c2ecf20Sopenharmony_ci * Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include <linux/kernel.h>
118c2ecf20Sopenharmony_ci#include <linux/init.h>
128c2ecf20Sopenharmony_ci#include <linux/string.h>
138c2ecf20Sopenharmony_ci#include <linux/ctype.h>
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#include <asm/openprom.h>
168c2ecf20Sopenharmony_ci#include <asm/oplib.h>
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci/* OBP version string. */
198c2ecf20Sopenharmony_cichar prom_version[80];
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci/* The root node of the prom device tree. */
228c2ecf20Sopenharmony_ciint prom_stdout;
238c2ecf20Sopenharmony_ciphandle prom_chosen_node;
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci/* You must call prom_init() before you attempt to use any of the
268c2ecf20Sopenharmony_ci * routines in the prom library.
278c2ecf20Sopenharmony_ci * It gets passed the pointer to the PROM vector.
288c2ecf20Sopenharmony_ci */
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ciextern void prom_cif_init(void *);
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_civoid __init prom_init(void *cif_handler)
338c2ecf20Sopenharmony_ci{
348c2ecf20Sopenharmony_ci	phandle node;
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci	prom_cif_init(cif_handler);
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci	prom_chosen_node = prom_finddevice(prom_chosen_path);
398c2ecf20Sopenharmony_ci	if (!prom_chosen_node || (s32)prom_chosen_node == -1)
408c2ecf20Sopenharmony_ci		prom_halt();
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci	prom_stdout = prom_getint(prom_chosen_node, "stdout");
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci	node = prom_finddevice("/openprom");
458c2ecf20Sopenharmony_ci	if (!node || (s32)node == -1)
468c2ecf20Sopenharmony_ci		prom_halt();
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci	prom_getstring(node, "version", prom_version, sizeof(prom_version));
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci	prom_printf("\n");
518c2ecf20Sopenharmony_ci}
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_civoid __init prom_init_report(void)
548c2ecf20Sopenharmony_ci{
558c2ecf20Sopenharmony_ci	printk("PROMLIB: Sun IEEE Boot Prom '%s'\n", prom_version);
568c2ecf20Sopenharmony_ci	printk("PROMLIB: Root node compatible: %s\n", prom_root_compatible);
578c2ecf20Sopenharmony_ci}
58