mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] ppc: DA923RC: 16-bit Product Data EEPROM read access
@ 2014-07-31 13:24 Renaud Barbier
  2014-08-01  5:35 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Renaud Barbier @ 2014-07-31 13:24 UTC (permalink / raw)
  To: barebox

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>
---
 arch/ppc/boards/geip-da923rc/product_data.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/arch/ppc/boards/geip-da923rc/product_data.c b/arch/ppc/boards/geip-da923rc/product_data.c
index 09cd84d..0c46006 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))
--
1.8.3.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ppc: DA923RC: 16-bit Product Data EEPROM read access
  2014-07-31 13:24 [PATCH] ppc: DA923RC: 16-bit Product Data EEPROM read access Renaud Barbier
@ 2014-08-01  5:35 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2014-08-01  5:35 UTC (permalink / raw)
  To: Renaud Barbier; +Cc: barebox

On Thu, Jul 31, 2014 at 02:24:05PM +0100, Renaud Barbier wrote:
> 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>

Applied, thanks

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-08-01  5:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-31 13:24 [PATCH] ppc: DA923RC: 16-bit Product Data EEPROM read access Renaud Barbier
2014-08-01  5:35 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox