xref: /titanic_50/usr/src/psm/promif/ieee1275/sun4u/prom_opl.c (revision f6e214c7418f43af38bd8c3a557e3d0a1d311cfa)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 #include <sys/promif.h>
29 #include <sys/promimpl.h>
30 
31 /*
32  * This file implements promif routines for OPL-specific OBP client
33  * interfaces defined in FWARC/2005/268.
34  */
35 
36 /*
37  * prom_opl_get_tod - this function gets time-of-day and stick value from OBP.
38  * Please, see "The OPL OBP functional specification" for details.
39  */
40 
41 void
42 prom_opl_get_tod(time_t *time, int64_t *stickval)
43 {
44 	cell_t	ci[5];
45 
46 	ci[0] = p1275_ptr2cell("FJSV,get-tod");	/* Service name */
47 	ci[1] = (cell_t)0;			/* #argument cells */
48 	ci[2] = (cell_t)2;			/* #result cells */
49 	ci[3] = (cell_t)0;			/* The result: STICK */
50 	ci[4] = (cell_t)0;			/* The result: time */
51 
52 	promif_preprom();
53 	(void) p1275_cif_handler(&ci);
54 	promif_postprom();
55 
56 	*stickval = ci[3];
57 	*time = ci[4];
58 }
59 
60 /*
61  * prom_opl_set_diff - this function updates time difference
62  * w.r.t. SP/OBP reference time.
63  * Please, see "The OPL OBP functional specification" for details.
64  */
65 
66 void
67 prom_opl_set_diff(int64_t diff)
68 {
69 	cell_t	ci[4];
70 
71 	ci[0] = p1275_ptr2cell("FJSV,set-domain-time"); /* Service name */
72 	ci[1] = (cell_t)1;			/* #argument cells */
73 	ci[2] = (cell_t)0;			/* #result cells */
74 	ci[3] = (cell_t)diff;			/* Arg1: time diff */
75 
76 	promif_preprom();
77 	(void) p1275_cif_handler(&ci);
78 	promif_postprom();
79 }
80 
81 int
82 prom_attach_notice(int boardnum)
83 {
84 	int rv;
85 	cell_t	ci[5];
86 
87 	ci[0] = p1275_ptr2cell("FJSV,attach-notice");
88 	ci[1] = (cell_t)1;
89 	ci[2] = (cell_t)1;
90 	ci[3] = (cell_t)boardnum;
91 
92 	promif_preprom();
93 	rv = p1275_cif_handler(&ci);
94 	promif_postprom();
95 
96 	return ((rv) ? -1 : p1275_cell2int(ci[4]));
97 }
98 
99 int
100 prom_detach_notice(int boardnum)
101 {
102 	int rv;
103 	cell_t	ci[5];
104 
105 	ci[0] = p1275_ptr2cell("FJSV,detach-notice");
106 	ci[1] = (cell_t)1;
107 	ci[2] = (cell_t)1;
108 	ci[3] = (cell_t)boardnum;
109 
110 	promif_preprom();
111 	rv = p1275_cif_handler(&ci);
112 	promif_postprom();
113 
114 	return ((rv) ? -1 : p1275_cell2int(ci[4]));
115 }
116 
117 int
118 prom_opl_switch_console(int lsb_id)
119 {
120 	cell_t	ci[5];
121 	int	rv;
122 
123 	ci[0] = p1275_ptr2cell("FJSV,switch-console");	/* name */
124 	ci[1] = (cell_t)1;			/* #argument cells */
125 	ci[2] = (cell_t)1;			/* #result cells */
126 	/* target tty-port# */
127 	ci[3] = p1275_int2cell(lsb_id);
128 
129 	promif_preprom();
130 	rv = p1275_cif_handler(&ci);
131 	promif_postprom();
132 
133 	if (rv != 0) {
134 		return (rv);
135 	}
136 	return (p1275_cell2int(ci[4]));	/* Res1: Catch result */
137 }
138