Modify to use i2c word mode instead of use block mode for access system eeprom

This commit is contained in:
Jostar Yang
2018-08-29 14:42:23 +08:00
parent d2f687ac82
commit 490aa69c5f
2 changed files with 18 additions and 8 deletions

View File

@@ -26,6 +26,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <onlplib/i2c.h>
#include <onlplib/file.h>
#include <onlp/platformi/sysi.h>
#include <onlp/platformi/ledi.h>
@@ -57,17 +58,26 @@ onlp_sysi_platform_get(void)
int
onlp_sysi_onie_data_get(uint8_t** data, int* size)
{
int ret = ONLP_STATUS_OK;
int i = 0;
uint8_t* rdata = aim_zmalloc(256);
if(onlp_file_read(rdata, 256, size, IDPROM_PATH) == ONLP_STATUS_OK) {
if(*size == 256) {
*data = rdata;
return ONLP_STATUS_OK;
for (i = 0; i < 128; i++) {
ret = onlp_i2c_readw(0, 0x56, i*2, ONLP_I2C_F_FORCE);
if (ret < 0) {
aim_free(rdata);
*size = 0;
return ret;
}
rdata[i*2] = ret & 0xff;
rdata[i*2+1] = (ret >> 8) & 0xff;
}
aim_free(rdata);
*size = 0;
return ONLP_STATUS_E_INTERNAL;
*size = 256;
*data = rdata;
return ONLP_STATUS_OK;
}
int

View File

@@ -124,7 +124,7 @@ class OnlPlatform_x86_64_accton_as7816_64x_r0(OnlPlatformAccton,
('optoe1', 0x50, 87),
('optoe1', 0x50, 88),
('24c02', 0x56, 0),
#('24c02', 0x56, 0),
])
subprocess.call('echo port61 > /sys/bus/i2c/devices/25-0050/port_name', shell=True)