1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * CZ.NIC's Turris Omnia MCU I2C interface commands definitions 4 * 5 * 2024 by Marek BehĂșn <kabel@kernel.org> 6 */ 7 8 #ifndef __TURRIS_OMNIA_MCU_INTERFACE_H 9 #define __TURRIS_OMNIA_MCU_INTERFACE_H 10 11 #include <linux/bitfield.h> 12 #include <linux/bits.h> 13 14 enum omnia_commands_e { 15 OMNIA_CMD_GET_STATUS_WORD = 0x01, /* slave sends status word back */ 16 OMNIA_CMD_GENERAL_CONTROL = 0x02, 17 OMNIA_CMD_LED_MODE = 0x03, /* default/user */ 18 OMNIA_CMD_LED_STATE = 0x04, /* LED on/off */ 19 OMNIA_CMD_LED_COLOR = 0x05, /* LED number + RED + GREEN + BLUE */ 20 OMNIA_CMD_USER_VOLTAGE = 0x06, 21 OMNIA_CMD_SET_BRIGHTNESS = 0x07, 22 OMNIA_CMD_GET_BRIGHTNESS = 0x08, 23 OMNIA_CMD_GET_RESET = 0x09, 24 OMNIA_CMD_GET_FW_VERSION_APP = 0x0A, /* 20B git hash number */ 25 OMNIA_CMD_SET_WATCHDOG_STATE = 0x0B, /* 0 - disable 26 * 1 - enable / ping 27 * after boot watchdog is started 28 * with 2 minutes timeout 29 */ 30 31 /* OMNIA_CMD_WATCHDOG_STATUS = 0x0C, not implemented anymore */ 32 33 OMNIA_CMD_GET_WATCHDOG_STATE = 0x0D, 34 OMNIA_CMD_GET_FW_VERSION_BOOT = 0x0E, /* 20B Git hash number */ 35 OMNIA_CMD_GET_FW_CHECKSUM = 0x0F, /* 4B length, 4B checksum */ 36 37 /* available if FEATURES_SUPPORTED bit set in status word */ 38 OMNIA_CMD_GET_FEATURES = 0x10, 39 40 /* available if EXT_CMD bit set in features */ 41 OMNIA_CMD_GET_EXT_STATUS_DWORD = 0x11, 42 OMNIA_CMD_EXT_CONTROL = 0x12, 43 OMNIA_CMD_GET_EXT_CONTROL_STATUS = 0x13, 44 45 /* available if NEW_INT_API bit set in features */ 46 OMNIA_CMD_GET_INT_AND_CLEAR = 0x14, 47 OMNIA_CMD_GET_INT_MASK = 0x15, 48 OMNIA_CMD_SET_INT_MASK = 0x16, 49 50 /* available if FLASHING bit set in features */ 51 OMNIA_CMD_FLASH = 0x19, 52 53 /* available if WDT_PING bit set in features */ 54 OMNIA_CMD_SET_WDT_TIMEOUT = 0x20, 55 OMNIA_CMD_GET_WDT_TIMELEFT = 0x21, 56 57 /* available if POWEROFF_WAKEUP bit set in features */ 58 OMNIA_CMD_SET_WAKEUP = 0x22, 59 OMNIA_CMD_GET_UPTIME_AND_WAKEUP = 0x23, 60 OMNIA_CMD_POWER_OFF = 0x24, 61 62 /* available if USB_OVC_PROT_SETTING bit set in features */ 63 OMNIA_CMD_SET_USB_OVC_PROT = 0x25, 64 OMNIA_CMD_GET_USB_OVC_PROT = 0x26, 65 66 /* available if TRNG bit set in features */ 67 OMNIA_CMD_TRNG_COLLECT_ENTROPY = 0x28, 68 69 /* available if CRYPTO bit set in features */ 70 OMNIA_CMD_CRYPTO_GET_PUBLIC_KEY = 0x29, 71 OMNIA_CMD_CRYPTO_SIGN_MESSAGE = 0x2A, 72 OMNIA_CMD_CRYPTO_COLLECT_SIGNATURE = 0x2B, 73 74 /* available if BOARD_INFO it set in features */ 75 OMNIA_CMD_BOARD_INFO_GET = 0x2C, 76 OMNIA_CMD_BOARD_INFO_BURN = 0x2D, 77 78 /* available only at address 0x2b (LED-controller) */ 79 /* available only if LED_GAMMA_CORRECTION bit set in features */ 80 OMNIA_CMD_SET_GAMMA_CORRECTION = 0x30, 81 OMNIA_CMD_GET_GAMMA_CORRECTION = 0x31, 82 83 /* available only at address 0x2b (LED-controller) */ 84 /* available only if PER_LED_CORRECTION bit set in features */ 85 /* available only if FROM_BIT_16_INVALID bit NOT set in features */ 86 OMNIA_CMD_SET_LED_CORRECTIONS = 0x32, 87 OMNIA_CMD_GET_LED_CORRECTIONS = 0x33, 88 }; 89 90 enum omnia_flashing_commands_e { 91 OMNIA_FLASH_CMD_UNLOCK = 0x01, 92 OMNIA_FLASH_CMD_SIZE_AND_CSUM = 0x02, 93 OMNIA_FLASH_CMD_PROGRAM = 0x03, 94 OMNIA_FLASH_CMD_RESET = 0x04, 95 }; 96 97 enum omnia_sts_word_e { 98 OMNIA_STS_MCU_TYPE_MASK = GENMASK(1, 0), 99 OMNIA_STS_MCU_TYPE_STM32 = FIELD_PREP_CONST(OMNIA_STS_MCU_TYPE_MASK, 0), 100 OMNIA_STS_MCU_TYPE_GD32 = FIELD_PREP_CONST(OMNIA_STS_MCU_TYPE_MASK, 1), 101 OMNIA_STS_MCU_TYPE_MKL = FIELD_PREP_CONST(OMNIA_STS_MCU_TYPE_MASK, 2), 102 OMNIA_STS_FEATURES_SUPPORTED = BIT(2), 103 OMNIA_STS_USER_REGULATOR_NOT_SUPPORTED = BIT(3), 104 OMNIA_STS_CARD_DET = BIT(4), 105 OMNIA_STS_MSATA_IND = BIT(5), 106 OMNIA_STS_USB30_OVC = BIT(6), 107 OMNIA_STS_USB31_OVC = BIT(7), 108 OMNIA_STS_USB30_PWRON = BIT(8), 109 OMNIA_STS_USB31_PWRON = BIT(9), 110 OMNIA_STS_ENABLE_4V5 = BIT(10), 111 OMNIA_STS_BUTTON_MODE = BIT(11), 112 OMNIA_STS_BUTTON_PRESSED = BIT(12), 113 OMNIA_STS_BUTTON_COUNTER_MASK = GENMASK(15, 13), 114 }; 115 116 enum omnia_ctl_byte_e { 117 OMNIA_CTL_LIGHT_RST = BIT(0), 118 OMNIA_CTL_HARD_RST = BIT(1), 119 /* BIT(2) is currently reserved */ 120 OMNIA_CTL_USB30_PWRON = BIT(3), 121 OMNIA_CTL_USB31_PWRON = BIT(4), 122 OMNIA_CTL_ENABLE_4V5 = BIT(5), 123 OMNIA_CTL_BUTTON_MODE = BIT(6), 124 OMNIA_CTL_BOOTLOADER = BIT(7), 125 }; 126 127 enum omnia_features_e { 128 OMNIA_FEAT_PERIPH_MCU = BIT(0), 129 OMNIA_FEAT_EXT_CMDS = BIT(1), 130 OMNIA_FEAT_WDT_PING = BIT(2), 131 OMNIA_FEAT_LED_STATE_EXT_MASK = GENMASK(4, 3), 132 OMNIA_FEAT_LED_STATE_EXT = FIELD_PREP_CONST(OMNIA_FEAT_LED_STATE_EXT_MASK, 1), 133 OMNIA_FEAT_LED_STATE_EXT_V32 = FIELD_PREP_CONST(OMNIA_FEAT_LED_STATE_EXT_MASK, 2), 134 OMNIA_FEAT_LED_GAMMA_CORRECTION = BIT(5), 135 OMNIA_FEAT_NEW_INT_API = BIT(6), 136 OMNIA_FEAT_BOOTLOADER = BIT(7), 137 OMNIA_FEAT_FLASHING = BIT(8), 138 OMNIA_FEAT_NEW_MESSAGE_API = BIT(9), 139 OMNIA_FEAT_BRIGHTNESS_INT = BIT(10), 140 OMNIA_FEAT_POWEROFF_WAKEUP = BIT(11), 141 OMNIA_FEAT_CAN_OLD_MESSAGE_API = BIT(12), 142 OMNIA_FEAT_TRNG = BIT(13), 143 OMNIA_FEAT_CRYPTO = BIT(14), 144 OMNIA_FEAT_BOARD_INFO = BIT(15), 145 146 /* 147 * Orginally the features command replied only 16 bits. If more were 148 * read, either the I2C transaction failed or 0xff bytes were sent. 149 * Therefore to consider bits 16 - 31 valid, one bit (20) was reserved 150 * to be zero. 151 */ 152 153 /* Bits 16 - 19 correspond to bits 0 - 3 of status word */ 154 OMNIA_FEAT_MCU_TYPE_MASK = GENMASK(17, 16), 155 OMNIA_FEAT_MCU_TYPE_STM32 = FIELD_PREP_CONST(OMNIA_FEAT_MCU_TYPE_MASK, 0), 156 OMNIA_FEAT_MCU_TYPE_GD32 = FIELD_PREP_CONST(OMNIA_FEAT_MCU_TYPE_MASK, 1), 157 OMNIA_FEAT_MCU_TYPE_MKL = FIELD_PREP_CONST(OMNIA_FEAT_MCU_TYPE_MASK, 2), 158 OMNIA_FEAT_FEATURES_SUPPORTED = BIT(18), 159 OMNIA_FEAT_USER_REGULATOR_NOT_SUPPORTED = BIT(19), 160 161 /* must not be set */ 162 OMNIA_FEAT_FROM_BIT_16_INVALID = BIT(20), 163 164 OMNIA_FEAT_PER_LED_CORRECTION = BIT(21), 165 OMNIA_FEAT_USB_OVC_PROT_SETTING = BIT(22), 166 }; 167 168 enum omnia_ext_sts_dword_e { 169 OMNIA_EXT_STS_SFP_nDET = BIT(0), 170 OMNIA_EXT_STS_LED_STATES_MASK = GENMASK(31, 12), 171 OMNIA_EXT_STS_WLAN0_MSATA_LED = BIT(12), 172 OMNIA_EXT_STS_WLAN1_LED = BIT(13), 173 OMNIA_EXT_STS_WLAN2_LED = BIT(14), 174 OMNIA_EXT_STS_WPAN0_LED = BIT(15), 175 OMNIA_EXT_STS_WPAN1_LED = BIT(16), 176 OMNIA_EXT_STS_WPAN2_LED = BIT(17), 177 OMNIA_EXT_STS_WAN_LED0 = BIT(18), 178 OMNIA_EXT_STS_WAN_LED1 = BIT(19), 179 OMNIA_EXT_STS_LAN0_LED0 = BIT(20), 180 OMNIA_EXT_STS_LAN0_LED1 = BIT(21), 181 OMNIA_EXT_STS_LAN1_LED0 = BIT(22), 182 OMNIA_EXT_STS_LAN1_LED1 = BIT(23), 183 OMNIA_EXT_STS_LAN2_LED0 = BIT(24), 184 OMNIA_EXT_STS_LAN2_LED1 = BIT(25), 185 OMNIA_EXT_STS_LAN3_LED0 = BIT(26), 186 OMNIA_EXT_STS_LAN3_LED1 = BIT(27), 187 OMNIA_EXT_STS_LAN4_LED0 = BIT(28), 188 OMNIA_EXT_STS_LAN4_LED1 = BIT(29), 189 OMNIA_EXT_STS_LAN5_LED0 = BIT(30), 190 OMNIA_EXT_STS_LAN5_LED1 = BIT(31), 191 }; 192 193 enum omnia_ext_ctl_e { 194 OMNIA_EXT_CTL_nRES_MMC = BIT(0), 195 OMNIA_EXT_CTL_nRES_LAN = BIT(1), 196 OMNIA_EXT_CTL_nRES_PHY = BIT(2), 197 OMNIA_EXT_CTL_nPERST0 = BIT(3), 198 OMNIA_EXT_CTL_nPERST1 = BIT(4), 199 OMNIA_EXT_CTL_nPERST2 = BIT(5), 200 OMNIA_EXT_CTL_PHY_SFP = BIT(6), 201 OMNIA_EXT_CTL_PHY_SFP_AUTO = BIT(7), 202 OMNIA_EXT_CTL_nVHV_CTRL = BIT(8), 203 }; 204 205 enum omnia_int_e { 206 OMNIA_INT_CARD_DET = BIT(0), 207 OMNIA_INT_MSATA_IND = BIT(1), 208 OMNIA_INT_USB30_OVC = BIT(2), 209 OMNIA_INT_USB31_OVC = BIT(3), 210 OMNIA_INT_BUTTON_PRESSED = BIT(4), 211 OMNIA_INT_SFP_nDET = BIT(5), 212 OMNIA_INT_BRIGHTNESS_CHANGED = BIT(6), 213 OMNIA_INT_TRNG = BIT(7), 214 OMNIA_INT_MESSAGE_SIGNED = BIT(8), 215 216 OMNIA_INT_LED_STATES_MASK = GENMASK(31, 12), 217 OMNIA_INT_WLAN0_MSATA_LED = BIT(12), 218 OMNIA_INT_WLAN1_LED = BIT(13), 219 OMNIA_INT_WLAN2_LED = BIT(14), 220 OMNIA_INT_WPAN0_LED = BIT(15), 221 OMNIA_INT_WPAN1_LED = BIT(16), 222 OMNIA_INT_WPAN2_LED = BIT(17), 223 OMNIA_INT_WAN_LED0 = BIT(18), 224 OMNIA_INT_WAN_LED1 = BIT(19), 225 OMNIA_INT_LAN0_LED0 = BIT(20), 226 OMNIA_INT_LAN0_LED1 = BIT(21), 227 OMNIA_INT_LAN1_LED0 = BIT(22), 228 OMNIA_INT_LAN1_LED1 = BIT(23), 229 OMNIA_INT_LAN2_LED0 = BIT(24), 230 OMNIA_INT_LAN2_LED1 = BIT(25), 231 OMNIA_INT_LAN3_LED0 = BIT(26), 232 OMNIA_INT_LAN3_LED1 = BIT(27), 233 OMNIA_INT_LAN4_LED0 = BIT(28), 234 OMNIA_INT_LAN4_LED1 = BIT(29), 235 OMNIA_INT_LAN5_LED0 = BIT(30), 236 OMNIA_INT_LAN5_LED1 = BIT(31), 237 }; 238 239 enum omnia_cmd_poweroff_e { 240 OMNIA_CMD_POWER_OFF_POWERON_BUTTON = BIT(0), 241 OMNIA_CMD_POWER_OFF_MAGIC = 0xdead, 242 }; 243 244 enum omnia_cmd_usb_ovc_prot_e { 245 OMNIA_CMD_xET_USB_OVC_PROT_PORT_MASK = GENMASK(3, 0), 246 OMNIA_CMD_xET_USB_OVC_PROT_ENABLE = BIT(4), 247 }; 248 249 #endif /* __TURRIS_OMNIA_MCU_INTERFACE_H */ 250
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.