xref: /openbmc/linux/arch/m68k/sun3/prom/init.c (revision f30828a6)
1f30828a6SAdrian Bunk /*
21da177e4SLinus Torvalds  * init.c:  Initialize internal variables used by the PROM
31da177e4SLinus Torvalds  *          library functions.
41da177e4SLinus Torvalds  *
51da177e4SLinus Torvalds  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
61da177e4SLinus Torvalds  */
71da177e4SLinus Torvalds 
81da177e4SLinus Torvalds #include <linux/kernel.h>
91da177e4SLinus Torvalds #include <linux/init.h>
101da177e4SLinus Torvalds 
111da177e4SLinus Torvalds #include <asm/openprom.h>
121da177e4SLinus Torvalds #include <asm/oplib.h>
131da177e4SLinus Torvalds 
141da177e4SLinus Torvalds struct linux_romvec *romvec;
151da177e4SLinus Torvalds enum prom_major_version prom_vers;
161da177e4SLinus Torvalds unsigned int prom_rev, prom_prev;
171da177e4SLinus Torvalds 
181da177e4SLinus Torvalds /* The root node of the prom device tree. */
191da177e4SLinus Torvalds int prom_root_node;
201da177e4SLinus Torvalds 
211da177e4SLinus Torvalds /* Pointer to the device tree operations structure. */
221da177e4SLinus Torvalds struct linux_nodeops *prom_nodeops;
231da177e4SLinus Torvalds 
241da177e4SLinus Torvalds /* You must call prom_init() before you attempt to use any of the
251da177e4SLinus Torvalds  * routines in the prom library.  It returns 0 on success, 1 on
261da177e4SLinus Torvalds  * failure.  It gets passed the pointer to the PROM vector.
271da177e4SLinus Torvalds  */
281da177e4SLinus Torvalds 
291da177e4SLinus Torvalds extern void prom_meminit(void);
301da177e4SLinus Torvalds extern void prom_ranges_init(void);
311da177e4SLinus Torvalds 
321da177e4SLinus Torvalds void __init prom_init(struct linux_romvec *rp)
331da177e4SLinus Torvalds {
341da177e4SLinus Torvalds #ifdef CONFIG_AP1000
351da177e4SLinus Torvalds 	extern struct linux_romvec *ap_prom_init(void);
361da177e4SLinus Torvalds 	rp = ap_prom_init();
371da177e4SLinus Torvalds #endif
381da177e4SLinus Torvalds 
391da177e4SLinus Torvalds 	romvec = rp;
401da177e4SLinus Torvalds #ifndef CONFIG_SUN3
411da177e4SLinus Torvalds 	switch(romvec->pv_romvers) {
421da177e4SLinus Torvalds 	case 0:
431da177e4SLinus Torvalds 		prom_vers = PROM_V0;
441da177e4SLinus Torvalds 		break;
451da177e4SLinus Torvalds 	case 2:
461da177e4SLinus Torvalds 		prom_vers = PROM_V2;
471da177e4SLinus Torvalds 		break;
481da177e4SLinus Torvalds 	case 3:
491da177e4SLinus Torvalds 		prom_vers = PROM_V3;
501da177e4SLinus Torvalds 		break;
511da177e4SLinus Torvalds 	case 4:
521da177e4SLinus Torvalds 		prom_vers = PROM_P1275;
531da177e4SLinus Torvalds 		prom_printf("PROMLIB: Sun IEEE Prom not supported yet\n");
541da177e4SLinus Torvalds 		prom_halt();
551da177e4SLinus Torvalds 		break;
561da177e4SLinus Torvalds 	case 42: /* why not :-) */
571da177e4SLinus Torvalds 		prom_vers = PROM_AP1000;
581da177e4SLinus Torvalds 		break;
591da177e4SLinus Torvalds 
601da177e4SLinus Torvalds 	default:
611da177e4SLinus Torvalds 		prom_printf("PROMLIB: Bad PROM version %d\n",
621da177e4SLinus Torvalds 			    romvec->pv_romvers);
631da177e4SLinus Torvalds 		prom_halt();
641da177e4SLinus Torvalds 		break;
651da177e4SLinus Torvalds 	};
661da177e4SLinus Torvalds 
671da177e4SLinus Torvalds 	prom_rev = romvec->pv_plugin_revision;
681da177e4SLinus Torvalds 	prom_prev = romvec->pv_printrev;
691da177e4SLinus Torvalds 	prom_nodeops = romvec->pv_nodeops;
701da177e4SLinus Torvalds 
711da177e4SLinus Torvalds 	prom_root_node = prom_getsibling(0);
721da177e4SLinus Torvalds 	if((prom_root_node == 0) || (prom_root_node == -1))
731da177e4SLinus Torvalds 		prom_halt();
741da177e4SLinus Torvalds 
751da177e4SLinus Torvalds 	if((((unsigned long) prom_nodeops) == 0) ||
761da177e4SLinus Torvalds 	   (((unsigned long) prom_nodeops) == -1))
771da177e4SLinus Torvalds 		prom_halt();
781da177e4SLinus Torvalds 
791da177e4SLinus Torvalds 	prom_meminit();
801da177e4SLinus Torvalds 
811da177e4SLinus Torvalds 	prom_ranges_init();
821da177e4SLinus Torvalds #endif
831da177e4SLinus Torvalds //	printk("PROMLIB: Sun Boot Prom Version %d Revision %d\n",
841da177e4SLinus Torvalds //	       romvec->pv_romvers, prom_rev);
851da177e4SLinus Torvalds 
861da177e4SLinus Torvalds 	/* Initialization successful. */
871da177e4SLinus Torvalds 	return;
881da177e4SLinus Torvalds }
89