1 /* 2 * Copyright (c) 2024 ENE Technology Inc. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef ENE_KB1200_FSMBM_H 8 #define ENE_KB1200_FSMBM_H 9 10 /** 11 * Structure type to access Flexible SMBus Master (FSMBM). 12 */ 13 struct fsmbm_regs { 14 volatile uint32_t FSMBMCFG; /* Configuration Register */ 15 volatile uint8_t FSMBMIE; /* Interrupt Enable Register */ 16 volatile uint8_t Reserved0[3]; 17 volatile uint8_t FSMBMPF; /* Event Pending Flag Register */ 18 volatile uint8_t Reserved1[3]; 19 volatile uint8_t FSMBMFRT; /* Protocol Control Register */ 20 volatile uint8_t Reserved2[3]; 21 volatile uint16_t FSMBMPEC; /* PEC Value Register */ 22 volatile uint16_t Reserved3; 23 volatile uint8_t FSMBMSTS; /* Status Register */ 24 volatile uint8_t Reserved4[3]; 25 volatile uint8_t FSMBMADR; /* Slave Address Register */ 26 volatile uint8_t Reserved5[3]; 27 volatile uint8_t FSMBMCMD; /* Command Register */ 28 volatile uint8_t Reserved6[3]; 29 volatile uint8_t FSMBMDAT[32]; /* Data Register */ 30 volatile uint8_t FSMBMPRTC_P; /* Protocol Register */ 31 volatile uint8_t FSMBMPRTC_C; /* Protocol Register */ 32 volatile uint16_t Reserved7; 33 volatile uint8_t FSMBMNADR; /* HostNotify Slave Address Register */ 34 volatile uint8_t Reserved8[3]; 35 volatile uint16_t FSMBMNDAT; /* HostNotify Data Register */ 36 volatile uint16_t Reserved9; 37 }; 38 39 #define FSMBM_NUM 10 40 41 /* data->state */ 42 #define STATE_IDLE 0 43 #define STATE_SENDING 1 44 #define STATE_RECEIVING 2 45 #define STATE_COMPLETE 3 46 47 /* PROTOCOL */ 48 #define FLEXIBLE_PROTOCOL 0x7F 49 50 /* Error code */ 51 #define FSMBM_NO_ERROR 0x00 52 #define FSMBM_DEVICE_ADDR_NO_ACK 0x10 53 #define FSMBM_CMD_NO_ACK 0x12 54 #define FSMBM_DEVICE_DATA_NO_ACK 0x13 55 #define FSMBM_LOST_ARBITRATION 0x17 56 #define FSMBM_SMBUS_TIMEOUT 0x18 57 #define FSMBM_UNSUPPORTED_PRTC 0x19 58 #define FSMBM_SMBUS_BUSY 0x1A 59 #define FSMBM_STOP_FAIL 0x1E 60 #define FSMBM_PEC_ERROR 0x1F 61 /* Packet Form */ 62 #define ___NONE 0x00 63 #define ___STOP 0x01 64 #define __PEC_ 0x02 65 #define __PEC_STOP 0x03 66 #define _CNT__ 0x04 67 #define _CNT__STOP 0x05 68 #define _CNT_PEC_ 0x06 69 #define _CNT_PEC_STOP 0x07 70 #define CMD___ 0x08 71 #define CMD___STOP 0x09 72 #define CMD__PEC_ 0x0A 73 #define CMD__PEC_STOP 0x0B 74 #define CMD_CNT__ 0x0C 75 #define CMD_CNT__STOP 0x0D 76 #define CMD_CNT_PEC_ 0x0E 77 #define CMD_CNT_PEC_STOP 0x0F 78 79 #define FLEXIBLE_CMD 0x08 80 #define FLEXIBLE_CNT 0x04 81 #define FLEXIBLE_PEC 0x02 82 #define FLEXIBLE_STOP 0x01 83 /* HW */ 84 #define FSMBM_BUFFER_SIZE 0x20 85 #define FSMBM_MAXCNT 0xFF 86 87 #define FSMBM_WRITE 0x00 88 #define FSMBM_READ 0x01 89 90 /* Clock Setting = 1 / (1u + (1u * N)) ,50% Duty Cycle */ 91 #define FSMBM_CLK_1M 0x0000 92 #define FSMBM_CLK_500K 0x0101 93 #define FSMBM_CLK_333K 0x0202 94 #define FSMBM_CLK_250K 0x0303 95 #define FSMBM_CLK_200K 0x0404 96 #define FSMBM_CLK_167K 0x0505 97 #define FSMBM_CLK_143K 0x0606 98 #define FSMBM_CLK_125K 0x0707 99 #define FSMBM_CLK_111K 0x0808 100 #define FSMBM_CLK_100K 0x0909 101 #define FSMBM_CLK_91K 0x0A0A 102 #define FSMBM_CLK_83K 0x0B0B 103 #define FSMBM_CLK_71K 0x0D0D 104 #define FSMBM_CLK_63K 0x0F0F 105 #define FSMBM_CLK_50K 0x1313 106 #define FSMBM_CLK_40K 0x1818 107 #define FSMBM_CLK_30K 0x2020 108 #define FSMBM_CLK_20K 0x3131 109 #define FSMBM_CLK_10K 0x6363 110 /* Other(non 50% Duty Cycle) */ 111 #define FSMBM_CLK_400K 0x0102 112 113 #define FSMBM_COMPLETE_EVENT 0x01 114 #define FSMBM_HOST_NOTIFY_EVENT 0x02 115 #define FSMBM_BLOCK_FINISH_EVENT 0x04 116 117 #define FSMBM_FUNCTION_ENABLE 0x01 118 #define FSMBM_TIMEOUT_ENABLE 0x02 119 #define FSMBM_HW_RESET 0x10 120 121 #define FSMBM_CLK_POS 16 122 #define FSMBM_CLK_MASK 0xFFFF 123 #define FSMBM_STS_MASK 0x1F 124 125 #endif /* ENE_KB1200_FSMBM_H */ 126