1 /* Copyright 2013-2014 IBM Corp. 2 * 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12 * implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 /* 17 */ 18 19 20 /* 21 * SPCN based LED location code and other information 22 */ 23 24 #ifndef __FSP_LEDS_H 25 #define __FSP_LEDS_H 26 27 /* Supported FSP response codes */ 28 #define FSP_IND_NOT_IMPLMNTD 0x00 /* Indicator not implemented */ 29 #define FSP_IND_IMPLMNTD 0x04 /* Indicator implemented */ 30 #define FSP_IND_IMPL_UNKNOWN 0x08 /* Implementation unknown */ 31 #define FSP_IND_INACTIVE 0x00 /* Indicator not active */ 32 #define FSP_IND_IDENTIFY_ACTV 0x01 /* Identify state active */ 33 #define FSP_IND_FAULT_ACTV 0x02 /* Fault state active */ 34 #define FSP_IND_STATE_UNKNOWN 0xff /* Indicator state unknown */ 35 #define FSP_RSRC_NOT_PRESENT 0x00 /* Resource not present */ 36 #define FSP_RSRC_PRESENT 0x40 /* Resource present */ 37 #define FSP_RSRC_PRSNC_UNKNOWN 0x80 /* Resource presence unknown */ 38 39 /* LED exclusive bits */ 40 #define FSP_LED_EXCL_FAULT (1UL << 0) 41 #define FSP_LED_EXCL_IDENTIFY (1UL << 1) 42 43 /* LED update message source */ 44 enum spcn_cmd_src { 45 SPCN_SRC_FSP = 0, 46 SPCN_SRC_OPAL = 1, 47 SPCN_SRC_MAX = 2 48 }; 49 50 /* SPCN set LED */ 51 struct spcn_led_data { 52 u8 lc_len; 53 u16 state; 54 char lc_code[LOC_CODE_SIZE]; 55 }; 56 57 /* LED data */ 58 struct fsp_led_data { 59 u16 rid; /* Resource ID */ 60 u8 lc_len; /* Location code len */ 61 char loc_code[LOC_CODE_SIZE]; 62 u16 parms; /* Parameters */ 63 u16 status; /* Status */ 64 u16 excl_bit; /* Exclusive LED bit */ 65 struct list_node link; 66 }; 67 68 /* FSP location code request */ 69 struct fsp_loc_code_req { 70 u16 len; 71 u16 req_type; 72 u8 raw_len; 73 u8 lc_sz; 74 char loc_code[LOC_CODE_SIZE]; 75 }; 76 77 /* FSP location code data */ 78 struct fsp_loc_code_data { 79 u16 size; 80 u32 ccin; 81 u8 status; 82 u8 ind_state; 83 u8 raw_len; 84 u8 fld_sz; 85 86 /* The size below must include the padding to 87 * make the whole structure aligned to a 88 * multiple of 4 bytes 89 */ 90 char loc_code[LOC_CODE_SIZE + 2]; /* 82 */ 91 92 /* We need to pack the structure otherwise the 93 * compiler adds additional alignment to make 94 * it 8 bytes aligned 95 */ 96 } __packed; 97 98 /* Get indicator state request */ 99 struct fsp_get_ind_state_req { 100 u16 size; 101 u8 lc_len; 102 u8 fld_sz; 103 char loc_code[LOC_CODE_SIZE]; 104 }; 105 106 /* Set indicator state request */ 107 struct fsp_set_ind_state_req { 108 u16 size; 109 u16 req_type; 110 u8 reserved[3]; 111 u8 ind_state; 112 u8 lc_len; 113 u8 fld_sz; 114 char loc_code[LOC_CODE_SIZE]; 115 }; 116 117 /* LED set SPCN command */ 118 struct led_set_cmd { 119 char loc_code[LOC_CODE_SIZE]; 120 u8 command; 121 u8 state; 122 u16 ckpt_status; /* Checkpointed status */ 123 u16 ckpt_excl_bit; /* Checkpointed exclusive status */ 124 u64 async_token; /* OPAL async token */ 125 enum spcn_cmd_src cmd_src; /* OPAL or FSP based */ 126 struct list_node link; 127 }; 128 129 /* System Attention Indicator */ 130 struct sai_data { 131 uint8_t state; 132 char loc_code[LOC_CODE_SIZE]; 133 }; 134 135 /* LED commands and state */ 136 #define LED_COMMAND_FAULT 1 137 #define LED_COMMAND_IDENTIFY 0 138 #define LED_STATE_ON 1 139 #define LED_STATE_OFF 0 140 141 /* FSP get loc-code list command request type */ 142 #define GET_LC_CMPLT_SYS 0x8000 143 #define GET_LC_ENCLOSURES 0x4000 144 #define GET_LC_ENCL_DESCENDANTS 0x2000 145 #define GET_LC_SINGLE_LOC_CODE 0x0100 146 147 /* FSP set indicator command request type */ 148 #define SET_IND_ENCLOSURE 0x4000 149 #define SET_IND_SINGLE_LOC_CODE 0x0001 150 151 /* Response buffer */ 152 #define OUTBUF_HEADER_SIZE 8 153 154 /* LED miscellaneous */ 155 #define LOC_CODE_LEN 1 156 #define LED_CONTROL_LEN 2 157 #define FSP_LC_STRUCT_FIXED_SZ 0x0a 158 159 /* LED Device tree property names */ 160 #define DT_PROPERTY_LED_COMPATIBLE "ibm,opal-v3-led" 161 #define DT_PROPERTY_LED_NODE "leds" 162 #define DT_PROPERTY_LED_MODE "led-mode" 163 #define DT_PROPERTY_LED_TYPES "led-types" 164 165 /* LED Mode */ 166 #define LED_MODE_LIGHT_PATH "lightpath" 167 #define LED_MODE_GUIDING_LIGHT "guidinglight" 168 169 /* LED type */ 170 #define LED_TYPE_IDENTIFY "identify" 171 #define LED_TYPE_FAULT "fault" 172 #define LED_TYPE_ATTENTION "attention" 173 174 #endif 175