1 
2 /*
3 	(C) Kontron
4  */
5 
6 #ifndef _IPMI_PICMG_H_
7 #define _IPMI_PICMG_H_
8 
9 #include <ipmitool/ipmi.h>
10 
11 /* PICMG version */
12 #define PICMG_CPCI_MAJOR_VERSION                   1
13 #define PICMG_ATCA_MAJOR_VERSION                   2
14 #define PICMG_AMC_MAJOR_VERSION                    4
15 
16 /* PICMG commands */
17 #define PICMG_GET_PICMG_PROPERTIES_CMD             0x00
18 #define PICMG_GET_ADDRESS_INFO_CMD                 0x01
19 #define PICMG_GET_SHELF_ADDRESS_INFO_CMD           0x02
20 #define PICMG_SET_SHELF_ADDRESS_INFO_CMD           0x03
21 #define PICMG_FRU_CONTROL_CMD                      0x04
22 #define PICMG_GET_FRU_LED_PROPERTIES_CMD           0x05
23 #define PICMG_GET_LED_COLOR_CAPABILITIES_CMD       0x06
24 #define PICMG_SET_FRU_LED_STATE_CMD                0x07
25 #define PICMG_GET_FRU_LED_STATE_CMD                0x08
26 #define PICMG_SET_IPMB_CMD                         0x09
27 #define PICMG_SET_FRU_POLICY_CMD                   0x0A
28 #define PICMG_GET_FRU_POLICY_CMD                   0x0B
29 #define PICMG_FRU_ACTIVATION_CMD                   0x0C
30 #define PICMG_GET_DEVICE_LOCATOR_RECORD_CMD        0x0D
31 #define PICMG_SET_PORT_STATE_CMD                   0x0E
32 #define PICMG_GET_PORT_STATE_CMD                   0x0F
33 #define PICMG_COMPUTE_POWER_PROPERTIES_CMD         0x10
34 #define PICMG_SET_POWER_LEVEL_CMD                  0x11
35 #define PICMG_GET_POWER_LEVEL_CMD                  0x12
36 #define PICMG_RENEGOTIATE_POWER_CMD                0x13
37 #define PICMG_GET_FAN_SPEED_PROPERTIES_CMD         0x14
38 #define PICMG_SET_FAN_LEVEL_CMD                    0x15
39 #define PICMG_GET_FAN_LEVEL_CMD                    0x16
40 #define PICMG_BUSED_RESOURCE_CMD                   0x17
41 
42 /* AMC.0 commands */
43 #define PICMG_AMC_SET_PORT_STATE_CMD			0x19
44 #define PICMG_AMC_GET_PORT_STATE_CMD			0x1A
45 /* AMC.0 R2.0 commands */
46 #define PICMG_AMC_SET_CLK_STATE_CMD				0x2C
47 #define PICMG_AMC_GET_CLK_STATE_CMD				0x2D
48 
49 /* Site Types */
50 #define PICMG_ATCA_BOARD                           0x00
51 #define PICMG_POWER_ENTRY                          0x01
52 #define PICMG_SHELF_FRU                            0x02
53 #define PICMG_DEDICATED_SHMC                       0x03
54 #define PICMG_FAN_TRAY                             0x04
55 #define PICMG_FAN_FILTER_TRAY                      0x05
56 #define PICMG_ALARM                                0x06
57 #define PICMG_AMC                                  0x07
58 #define PICMG_PMC                                  0x08
59 #define PICMG_RTM                                  0x09
60 
61 #ifdef HAVE_PRAGMA_PACK
62 #pragma pack(1)
63 #endif
64 struct picmg_set_fru_activation_cmd {
65    unsigned char  picmg_id;      /* always 0*/
66    unsigned char  fru_id;        /* threshold setting mask */
67    unsigned char  fru_state;     /* fru activation/deactivation */
68 } ATTRIBUTE_PACKING;
69 #ifdef HAVE_PRAGMA_PACK
70 #pragma pack(0)
71 #endif
72 
73 typedef enum picmg_busres_board_cmd_types {
74 	PICMG_BUSRES_BOARD_CMD_QUERY =0,
75 	PICMG_BUSRES_BOARD_CMD_RELEASE,
76 	PICMG_BUSRES_BOARD_CMD_FORCE,
77 	PICMG_BUSRES_BOARD_CMD_BUS_FREE
78 } t_picmg_busres_board_cmd_types ;
79 
80 typedef enum picmg_busres_shmc_cmd_types {
81 	PICMG_BUSRES_SHMC_CMD_REQUEST =0,
82 	PICMG_BUSRES_SHMC_CMD_RELINQUISH,
83 	PICMG_BUSRES_SHMC_CMD_NOTIFY
84 } t_picmg_busres_shmc_cmd_types ;
85 
86 typedef enum picmg_busres_resource_id {
87 	PICMG_BUSRES_METAL_TEST_BUS_1=0,
88 	PICMG_BUSRES_METAL_TEST_BUS_2,
89 	PICMG_BUSRES_SYNC_CLOCK_GROUP_1,
90 	PICMG_BUSRES_SYNC_CLOCK_GROUP_2,
91 	PICMG_BUSRES_SYNC_CLOCK_GROUP_3
92 } t_picmg_busres_resource_id;
93 
94 /* the LED color capabilities */
95 static const char* led_color_str[] __attribute__((unused)) = {
96    "reserved",
97    "BLUE",
98    "RED",
99    "GREEN",
100    "AMBER",
101    "ORANGE",
102    "WHITE",
103    "reserved"
104 };
105 
106 
107 static const char* amc_link_type_str[] __attribute__((unused)) = {
108    "RESERVED",
109    "RESERVED1",
110    "PCI EXPRESS",
111    "ADVANCED SWITCHING1",
112    "ADVANCED SWITCHING2",
113    "ETHERNET",
114    "RAPIDIO",
115    "STORAGE",
116 };
117 
118 static const char* amc_link_type_ext_str[][16] __attribute__((unused)) = {
119 	/* FRU_PICMGEXT_AMC_LINK_TYPE_RESERVED */
120 	{
121 		"", "", "", "", "", "", "", "",   "", "", "", "", "", "", "", ""
122 	},
123 	/* FRU_PICMGEXT_AMC_LINK_TYPE_RESERVED1 */
124 	{
125 		"", "", "", "", "", "", "", "",   "", "", "", "", "", "", "", ""
126 	},
127 	/* FRU_PICMGEXT_AMC_LINK_TYPE_PCI_EXPRESS */
128 	{
129 		"Gen 1 - NSSC",
130 		"Gen 1 - SSC",
131 		"Gen 2 - NSSC",
132 		"Gen 2 - SSC",
133 		"", "", "", "",
134 		"", "", "", "",
135 		"", "", "", ""
136 	},
137 	/* FRU_PICMGEXT_AMC_LINK_TYPE_ADVANCED_SWITCHING1 */
138 	{
139 		"Gen 1 - NSSC",
140 		"Gen 1 - SSC",
141 		"Gen 2 - NSSC",
142 		"Gen 2 - SSC",
143 		"", "", "", "",
144 		"", "", "", "",
145 		"", "", "", ""
146 	},
147 	/* FRU_PICMGEXT_AMC_LINK_TYPE_ADVANCED_SWITCHING2 */
148 	{
149 		"Gen 1 - NSSC",
150 		"Gen 1 - SSC",
151 		"Gen 2 - NSSC",
152 		"Gen 2 - SSC",
153 		"", "", "", "",
154 		"", "", "", "",
155 		"", "", "", ""
156 	},
157 	/* FRU_PICMGEXT_AMC_LINK_TYPE_ETHERNET */
158 	{
159    		"1000BASE-BX (SerDES Gigabit)",
160    		"10GBASE-BX410 Gigabit XAUI",
161    		"", "",
162    		"", "", "", "",
163 		"", "", "", "",
164 		"", "", "", ""
165 	},
166 	/* FRU_PICMGEXT_AMC_LINK_TYPE_RAPIDIO */
167 	{
168    		"1.25 Gbaud transmission rate",
169    		"2.5 Gbaud transmission rate",
170    		"3.125 Gbaud transmission rate",
171    		"", "", "", "", "",
172 		"", "", "", "", "", "", "", ""
173 	},
174 	/* FRU_PICMGEXT_AMC_LINK_TYPE_STORAGE */
175 	{
176    		"Fibre Channel",
177    		"Serial ATA",
178    		"Serial Attached SCSI",
179    		"", "", "", "", "",
180 		"", "", "", "", "", "", "", ""
181 	}
182 };
183 
184 struct sAmcPortState {
185 #ifndef WORDS_BIGENDIAN
186    unsigned short lane0       :  1;
187    unsigned short lane1       :  1;
188    unsigned short lane2       :  1;
189    unsigned short lane3       :  1;
190    unsigned short type        :  8;
191    unsigned short type_ext    :  4;
192    unsigned char  group_id    :  8;
193 #else
194    unsigned char  group_id    :  8;
195    unsigned short type_ext    :  4;
196    unsigned short type        :  8;
197    unsigned short lane3       :  1;
198    unsigned short lane2       :  1;
199    unsigned short lane1       :  1;
200    unsigned short lane0       :  1;
201 #endif
202 
203    unsigned char state;
204 };
205 
206 
207 int ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv);
208 uint8_t picmg_discover(struct ipmi_intf *intf);
209 uint8_t ipmi_picmg_ipmb_address(struct ipmi_intf *intf);
210 
211 #endif
212