diff options
author | Renaud Barbier <renaud.barbier@ge.com> | 2014-07-31 14:24:05 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2014-08-01 07:34:46 +0200 |
commit | 70e769a685435c1f5d49616b5a9f8b97addc1515 (patch) | |
tree | a5b1523c589a99f0c6c2d347f0ab22255ab5abde /arch/ppc/boards/geip-da923rc | |
parent | d840f17ec6394d09f13e218c85f1f449e1fb8d2c (diff) | |
download | barebox-70e769a685435c1f5d49616b5a9f8b97addc1515.tar.gz barebox-70e769a685435c1f5d49616b5a9f8b97addc1515.tar.xz |
ppc: DA923RC: 16-bit Product Data EEPROM read access
Change Product Data validity checking to ensure that support can
be provided for 8-bit and 16-bit EEPROM devices.
Signed-off-by: Renaud Barbier <renaud.barbier@ge.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/ppc/boards/geip-da923rc')
-rw-r--r-- | arch/ppc/boards/geip-da923rc/product_data.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/arch/ppc/boards/geip-da923rc/product_data.c b/arch/ppc/boards/geip-da923rc/product_data.c index 09cd84d930..0c4600611a 100644 --- a/arch/ppc/boards/geip-da923rc/product_data.c +++ b/arch/ppc/boards/geip-da923rc/product_data.c @@ -20,12 +20,20 @@ #include <mach/fsl_i2c.h> #include "product_data.h" +static int ge_pd_header_check(unsigned short header) +{ + if (header != 0xa5a5) + return -1; + else + return 0; +} + static int ge_is_data_valid(struct ge_product_data *v) { int crc, ret = 0; const unsigned char *p = (const unsigned char *)v; - if (v->v1.pdh.tag != 0xa5a5) + if (ge_pd_header_check(v->v1.pdh.tag)) return -1; switch (v->v1.pdh.version) { @@ -51,12 +59,20 @@ int ge_get_product_data(struct ge_product_data *productp) { struct i2c_adapter *adapter; struct i2c_client client; + unsigned int width = 0; int ret; adapter = i2c_get_adapter(0); client.addr = 0x51; client.adapter = adapter; ret = i2c_read_reg(&client, 0, (uint8_t *) productp, + sizeof(unsigned short)); + + /* If there is no valid header, it may be a 16-bit eeprom. */ + if (ge_pd_header_check(productp->v1.pdh.tag)) + width = I2C_ADDR_16_BIT; + + ret = i2c_read_reg(&client, width, (uint8_t *) productp, sizeof(struct ge_product_data)); if (ret == sizeof(struct ge_product_data)) |