Skip to content

Commit dbd4558

Browse files
authored
Merge pull request #84 from kelvin-cao/update_flash_info
Update flash info
2 parents 87a73aa + 9534e88 commit dbd4558

File tree

3 files changed

+50
-21
lines changed

3 files changed

+50
-21
lines changed

linux/switchtec.h

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,21 @@ enum {
138138
};
139139

140140
enum {
141-
SWITCHTEC_GEN4_BL2_0_RUNNING = 0x01,
142-
SWITCHTEC_GEN4_BL2_1_RUNNING = 0x02,
143-
SWITCHTEC_GEN4_MAP0_RUNNING = 0x03,
144-
SWITCHTEC_GEN4_MAP1_RUNNING = 0x04,
145-
SWITCHTEC_GEN4_CFG0_RUNNING = 0x05,
146-
SWITCHTEC_GEN4_CFG1_RUNNING = 0x06,
147-
SWITCHTEC_GEN4_IMG0_RUNNING = 0x07,
148-
SWITCHTEC_GEN4_IMG1_RUNNING = 0x08,
141+
SWITCHTEC_GEN4_MAP0_RUNNING = 0x00,
142+
SWITCHTEC_GEN4_MAP1_RUNNING = 0x01,
143+
SWITCHTEC_GEN4_KEY0_RUNNING = 0x02,
144+
SWITCHTEC_GEN4_KEY1_RUNNING = 0x03,
145+
SWITCHTEC_GEN4_BL2_0_RUNNING = 0x04,
146+
SWITCHTEC_GEN4_BL2_1_RUNNING = 0x05,
147+
SWITCHTEC_GEN4_CFG0_RUNNING = 0x06,
148+
SWITCHTEC_GEN4_CFG1_RUNNING = 0x07,
149+
SWITCHTEC_GEN4_IMG0_RUNNING = 0x08,
150+
SWITCHTEC_GEN4_IMG1_RUNNING = 0x09,
149151
};
150152

151153
enum {
154+
SWITCHTEC_GEN4_KEY0_ACTIVE = 0,
155+
SWITCHTEC_GEN4_KEY1_ACTIVE = 1,
152156
SWITCHTEC_GEN4_BL2_0_ACTIVE = 0,
153157
SWITCHTEC_GEN4_BL2_1_ACTIVE = 1,
154158
SWITCHTEC_GEN4_CFG0_ACTIVE = 0,
@@ -187,32 +191,32 @@ struct sys_info_regs_gen4 {
187191
u8 mrpc_inband_ver;
188192
u32 reserved3[7];
189193
u32 fw_update_tmo;
190-
u32 table_version_cfg;
191-
u32 table_version_img;
194+
u32 xml_version_cfg;
195+
u32 xml_version_img;
192196
u32 partition_id;
193197
u16 bl2_running;
194198
u16 cfg_running;
195199
u16 img_running;
196-
u16 reserved4;
197-
u32 reserved5[43];
200+
u16 key_running;
201+
u32 reserved4[43];
198202
u32 vendor_seeprom_twi;
199203
u32 vendor_table_revision;
200204
u32 vendor_specific_info[2];
201205
u16 p2p_vendor_id;
202206
u16 p2p_device_id;
203207
u8 p2p_revision_id;
204-
u8 reserved6[3];
208+
u8 reserved5[3];
205209
u32 p2p_class_id;
206210
u16 subsystem_vendor_id;
207211
u16 subsystem_id;
208212
u32 p2p_serial_number[2];
209213
u8 mac_addr[6];
210-
u8 reserved7[2];
211-
u32 reserved8[3];
214+
u8 reserved6[2];
215+
u32 reserved7[3];
212216
char vendor_id[8];
213217
char product_id[24];
214218
char product_revision[2];
215-
u16 reserved9;
219+
u16 reserved8;
216220
} __packed;
217221

218222
struct sys_info_regs {
@@ -261,16 +265,17 @@ struct flash_info_regs_gen4 {
261265
unsigned char bl2;
262266
unsigned char cfg;
263267
unsigned char img;
264-
unsigned char reserved;
268+
unsigned char key;
265269
} active_flag;
266270

267271
u32 reserved[3];
268272

269-
struct partition_info bl1;
270-
struct partition_info bl2_0;
271-
struct partition_info bl2_1;
272273
struct partition_info map0;
273274
struct partition_info map1;
275+
struct partition_info key0;
276+
struct partition_info key1;
277+
struct partition_info bl2_0;
278+
struct partition_info bl2_1;
274279
struct partition_info cfg0;
275280
struct partition_info cfg1;
276281
struct partition_info img0;

linux/switchtec_ioctl.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,13 @@
3434
#define SWITCHTEC_IOCTL_PART_VENDOR7 12
3535
#define SWITCHTEC_IOCTL_PART_BL2_0 13
3636
#define SWITCHTEC_IOCTL_PART_BL2_1 14
37+
#define SWITCHTEC_IOCTL_PART_MAP_0 15
38+
#define SWITCHTEC_IOCTL_PART_MAP_1 16
39+
#define SWITCHTEC_IOCTL_PART_KEY_0 17
40+
#define SWITCHTEC_IOCTL_PART_KEY_1 18
3741

3842
#define SWITCHTEC_NUM_PARTITIONS_GEN3 13
39-
#define SWITCHTEC_NUM_PARTITIONS_GEN4 15
43+
#define SWITCHTEC_NUM_PARTITIONS_GEN4 19
4044

4145
struct switchtec_ioctl_flash_info {
4246
__u64 flash_length;

switchtec.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,26 @@ static int flash_part_info_gen4(struct switchtec_dev *stdev,
705705
struct active_partition_info_gen4 __iomem *af = &fi->active_flag;
706706

707707
switch (info->flash_partition) {
708+
case SWITCHTEC_IOCTL_PART_MAP_0:
709+
set_fw_info_part(info, &fi->map0);
710+
break;
711+
case SWITCHTEC_IOCTL_PART_MAP_1:
712+
set_fw_info_part(info, &fi->map1);
713+
break;
714+
case SWITCHTEC_IOCTL_PART_KEY_0:
715+
set_fw_info_part(info, &fi->key0);
716+
if (ioread8(&af->key) == SWITCHTEC_GEN4_KEY0_ACTIVE)
717+
info->active |= SWITCHTEC_IOCTL_PART_ACTIVE;
718+
if (ioread16(&si->key_running) == SWITCHTEC_GEN4_KEY0_RUNNING)
719+
info->active |= SWITCHTEC_IOCTL_PART_RUNNING;
720+
break;
721+
case SWITCHTEC_IOCTL_PART_KEY_1:
722+
set_fw_info_part(info, &fi->key1);
723+
if (ioread8(&af->key) == SWITCHTEC_GEN4_KEY1_ACTIVE)
724+
info->active |= SWITCHTEC_IOCTL_PART_ACTIVE;
725+
if (ioread16(&si->key_running) == SWITCHTEC_GEN4_KEY1_RUNNING)
726+
info->active |= SWITCHTEC_IOCTL_PART_RUNNING;
727+
break;
708728
case SWITCHTEC_IOCTL_PART_BL2_0:
709729
set_fw_info_part(info, &fi->bl2_0);
710730
if (ioread8(&af->bl2) == SWITCHTEC_GEN4_BL2_0_ACTIVE)

0 commit comments

Comments
 (0)