ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / ia64 / sn / io / sn2 / l1_command.c
1 /*
2  * This file is subject to the terms and conditions of the GNU General Public
3  * License.  See the file "COPYING" in the main directory of this archive
4  * for more details.
5  *
6  * Copyright (c) 1992-1997,2000-2003 Silicon Graphics, Inc. All rights reserved.
7  */ 
8
9 #include <linux/types.h>
10 #include <linux/slab.h>
11 #include <asm/sn/sgi.h>
12 #include <asm/sn/io.h>
13 #include <asm/sn/iograph.h>
14 #include <asm/sn/hcl.h>
15 #include <asm/sn/hcl_util.h>
16 #include <asm/sn/labelcl.h>
17 #include <asm/sn/router.h>
18 #include <asm/sn/module.h>
19 #include <asm/sn/ksys/l1.h>
20 #include <asm/sn/nodepda.h>
21 #include <asm/sn/clksupport.h>
22 #include <asm/sn/sn_cpuid.h>
23 #include <asm/sn/sn_sal.h>
24 #include <linux/ctype.h>
25
26 /* elsc_display_line writes up to 12 characters to either the top or bottom
27  * line of the L1 display.  line points to a buffer containing the message
28  * to be displayed.  The zero-based line number is specified by lnum (so
29  * lnum == 0 specifies the top line and lnum == 1 specifies the bottom).
30  * Lines longer than 12 characters, or line numbers not less than
31  * L1_DISPLAY_LINES, cause elsc_display_line to return an error.
32  */
33 int elsc_display_line(nasid_t nasid, char *line, int lnum)
34 {
35     return 0;
36 }
37
38
39 /*
40  * iobrick routines
41  */
42
43 /* iobrick_rack_bay_type_get fills in the three int * arguments with the
44  * rack number, bay number and brick type of the L1 being addressed.  Note
45  * that if the L1 operation fails and this function returns an error value, 
46  * garbage may be written to brick_type.
47  */
48
49
50 int iobrick_rack_bay_type_get( nasid_t nasid, uint *rack, 
51                                uint *bay, uint *brick_type )
52 {
53         int result = 0;
54
55         if ( ia64_sn_sysctl_iobrick_module_get(nasid, &result) )
56                 return( ELSC_ERROR_CMD_SEND );
57
58         *rack = (result & MODULE_RACK_MASK) >> MODULE_RACK_SHFT;
59         *bay = (result & MODULE_BPOS_MASK) >> MODULE_BPOS_SHFT;
60         *brick_type = (result & MODULE_BTYPE_MASK) >> MODULE_BTYPE_SHFT;
61         return 0;
62 }
63
64
65 int iomoduleid_get(nasid_t nasid)
66 {
67         int result = 0;
68
69         if ( ia64_sn_sysctl_iobrick_module_get(nasid, &result) )
70                 return( ELSC_ERROR_CMD_SEND );
71
72         return result;
73 }
74
75 int
76 iobrick_type_get_nasid(nasid_t nasid)
77 {
78     uint rack, bay, type;
79     int t, ret;
80     extern char brick_types[];
81
82     if ((ret = iobrick_rack_bay_type_get(nasid, &rack, &bay, &type)) < 0) {
83         return ret;
84     }
85
86     /* convert brick_type to lower case */
87     if ((type >= 'A') && (type <= 'Z'))
88         type = type - 'A' + 'a';
89
90     /* convert to a module.h brick type */
91     for( t = 0; t < MAX_BRICK_TYPES; t++ ) {
92         if( brick_types[t] == type ) {
93             return t;
94         }
95     }
96
97     return -1;    /* unknown brick */
98 }
99
100 /*
101  * given a L1 bricktype, return a bricktype string.  This string is the
102  * string that will be used in the hwpath for I/O bricks
103  */
104 char *
105 iobrick_L1bricktype_to_name(int type)
106 {
107     switch (type)
108     {
109     default:
110         return("Unknown");
111
112     case L1_BRICKTYPE_PX:
113         return(EDGE_LBL_PXBRICK);
114
115     case L1_BRICKTYPE_OPUS:
116         return(EDGE_LBL_OPUSBRICK);
117
118     case L1_BRICKTYPE_IX:
119         return(EDGE_LBL_IXBRICK);
120
121     case L1_BRICKTYPE_C:
122         return("Cbrick");
123
124     case L1_BRICKTYPE_R:
125         return("Rbrick");
126
127     case L1_BRICKTYPE_CHI_CG:
128         return(EDGE_LBL_CGBRICK);
129     }
130 }
131