1*b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0 2708d4f09SSam Ravnborg /* 3708d4f09SSam Ravnborg * init.c: Initialize internal variables used by the PROM 4708d4f09SSam Ravnborg * library functions. 5708d4f09SSam Ravnborg * 6708d4f09SSam Ravnborg * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) 7708d4f09SSam Ravnborg * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) 8708d4f09SSam Ravnborg */ 9708d4f09SSam Ravnborg 10708d4f09SSam Ravnborg #include <linux/kernel.h> 11708d4f09SSam Ravnborg #include <linux/init.h> 126943f3daSSam Ravnborg #include <linux/module.h> 13708d4f09SSam Ravnborg 14708d4f09SSam Ravnborg #include <asm/openprom.h> 15708d4f09SSam Ravnborg #include <asm/oplib.h> 16708d4f09SSam Ravnborg 17708d4f09SSam Ravnborg struct linux_romvec *romvec; 186943f3daSSam Ravnborg EXPORT_SYMBOL(romvec); 196943f3daSSam Ravnborg 20708d4f09SSam Ravnborg enum prom_major_version prom_vers; 21708d4f09SSam Ravnborg unsigned int prom_rev, prom_prev; 22708d4f09SSam Ravnborg 23708d4f09SSam Ravnborg /* The root node of the prom device tree. */ 248d125562SAndres Salomon phandle prom_root_node; 256943f3daSSam Ravnborg EXPORT_SYMBOL(prom_root_node); 26708d4f09SSam Ravnborg 27708d4f09SSam Ravnborg /* Pointer to the device tree operations structure. */ 28708d4f09SSam Ravnborg struct linux_nodeops *prom_nodeops; 29708d4f09SSam Ravnborg 30708d4f09SSam Ravnborg /* You must call prom_init() before you attempt to use any of the 31e393d1bdSGeert Uytterhoeven * routines in the prom library. 32e393d1bdSGeert Uytterhoeven * It gets passed the pointer to the PROM vector. 33708d4f09SSam Ravnborg */ 34708d4f09SSam Ravnborg prom_init(struct linux_romvec * rp)35708d4f09SSam Ravnborgvoid __init prom_init(struct linux_romvec *rp) 36708d4f09SSam Ravnborg { 37708d4f09SSam Ravnborg romvec = rp; 38708d4f09SSam Ravnborg 39708d4f09SSam Ravnborg switch(romvec->pv_romvers) { 40708d4f09SSam Ravnborg case 0: 41708d4f09SSam Ravnborg prom_vers = PROM_V0; 42708d4f09SSam Ravnborg break; 43708d4f09SSam Ravnborg case 2: 44708d4f09SSam Ravnborg prom_vers = PROM_V2; 45708d4f09SSam Ravnborg break; 46708d4f09SSam Ravnborg case 3: 47708d4f09SSam Ravnborg prom_vers = PROM_V3; 48708d4f09SSam Ravnborg break; 49708d4f09SSam Ravnborg default: 50708d4f09SSam Ravnborg prom_printf("PROMLIB: Bad PROM version %d\n", 51708d4f09SSam Ravnborg romvec->pv_romvers); 52708d4f09SSam Ravnborg prom_halt(); 53708d4f09SSam Ravnborg break; 546cb79b3fSJoe Perches } 55708d4f09SSam Ravnborg 56708d4f09SSam Ravnborg prom_rev = romvec->pv_plugin_revision; 57708d4f09SSam Ravnborg prom_prev = romvec->pv_printrev; 58708d4f09SSam Ravnborg prom_nodeops = romvec->pv_nodeops; 59708d4f09SSam Ravnborg 60708d4f09SSam Ravnborg prom_root_node = prom_getsibling(0); 614a3a2552SAndres Salomon if ((prom_root_node == 0) || ((s32)prom_root_node == -1)) 62708d4f09SSam Ravnborg prom_halt(); 63708d4f09SSam Ravnborg 64708d4f09SSam Ravnborg if((((unsigned long) prom_nodeops) == 0) || 65708d4f09SSam Ravnborg (((unsigned long) prom_nodeops) == -1)) 66708d4f09SSam Ravnborg prom_halt(); 67708d4f09SSam Ravnborg 68708d4f09SSam Ravnborg prom_meminit(); 69708d4f09SSam Ravnborg 70708d4f09SSam Ravnborg prom_ranges_init(); 71708d4f09SSam Ravnborg 72708d4f09SSam Ravnborg printk("PROMLIB: Sun Boot Prom Version %d Revision %d\n", 73708d4f09SSam Ravnborg romvec->pv_romvers, prom_rev); 74708d4f09SSam Ravnborg 75708d4f09SSam Ravnborg /* Initialization successful. */ 76708d4f09SSam Ravnborg } 77