mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Antony Pavlov <antonynpavlov@gmail.com>
To: barebox@lists.infradead.org
Subject: [PATCH 6/7] MIPS: dts: qemu-malta.dts: use i2c-gpio for accessing CBUS FPGA I2C bus
Date: Tue, 24 Jun 2014 01:21:12 +0400	[thread overview]
Message-ID: <1403558473-26199-7-git-send-email-antonynpavlov@gmail.com> (raw)
In-Reply-To: <1403558473-26199-1-git-send-email-antonynpavlov@gmail.com>

Also we can enable m24c02 eeprom chip in dts-file e.g.

    &i2c0 {
            status = "okay";

            eeprom: m24c02@50 {
                    compatible = "spd";
                    reg = <0x50>;
            };
    };

Alas! qemu mips malta spd m24c02 eeprom chip emulation is not perfect:
the block read operation does not work properly.

Here is an example.

If we read eeprom content byte-by-byte then there is no problem:

    barebox:/ for i in 0x08 0x09 0x0a 0x0b 0x0c 0x0d 0x0e 0x0f ;
    > do i2c_read -b 0 -a 0x50 -r $i -c 1 ; done
    0x01
    0x75
    0x54
    0x00
    0x82
    0x08
    0x00
    0x01

Compare this output with content of qemu.git/hw/mips/mips_malta.c:

    static eeprom24c0x_t spd_eeprom = {
        .contents = {
            ...
            /* 00000008: */ 0x01,0x75,0x54,0x00,0x82,0x08,0x00,0x01,

But if we read several bytes at once the we have data corruption:

    barebox:/ i2c_read -b 0 -a 0x50 -r 0x8 -c 8
    0x01 0xff 0xff 0xff 0xff 0xff 0xff 0xff

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 arch/mips/dts/qemu-malta.dts | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/arch/mips/dts/qemu-malta.dts b/arch/mips/dts/qemu-malta.dts
index 204007d..cc1c960 100644
--- a/arch/mips/dts/qemu-malta.dts
+++ b/arch/mips/dts/qemu-malta.dts
@@ -32,6 +32,18 @@
 		#gpio-cells = <2>;
 	};
 
+	i2c0: i2c0 {
+		compatible = "i2c-gpio";
+		gpios = <&gpio 0 0 /* sda */
+			&gpio 1 0 /* scl */
+			>;
+		i2c-gpio,sda-open-drain;
+		i2c-gpio,scl-open-drain;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		status = "disabled";
+	};
+
 	uart2: serial@bf000900 {
 		compatible = "ns16550a";
 		reg = <0xbf000900 0x40>;
@@ -58,3 +70,7 @@
 		};
 	};
 };
+
+&i2c0 {
+	status = "okay";
+};
-- 
1.9.2


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

  parent reply	other threads:[~2014-06-23 21:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-23 21:21 [PATCH 0/7] MIPS: malta: enable gpio & i2c stuff Antony Pavlov
2014-06-23 21:21 ` [PATCH 1/7] gpio: add Malta CBUS FPGA I2C driver Antony Pavlov
2014-06-23 21:21 ` [PATCH 2/7] MIPS: add <asm/gpio.h> header file Antony Pavlov
2014-06-23 21:21 ` [PATCH 3/7] MIPS: malta: enable gpiolib Antony Pavlov
2014-06-23 21:21 ` [PATCH 4/7] MIPS: dts: qemu-malta.dts: enable CBUS FPGA I2C gpio driver Antony Pavlov
2014-06-23 21:21 ` [PATCH 5/7] i2c: i2c_gpio: add devicetree support Antony Pavlov
2014-06-24  7:03   ` Sascha Hauer
2014-06-23 21:21 ` Antony Pavlov [this message]
2014-06-23 21:21 ` [PATCH 7/7] MIPS: qemu-malta_defconfig: enable gpio & i2c stuff Antony Pavlov
2014-06-24  7:09 ` [PATCH 0/7] MIPS: malta: " Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1403558473-26199-7-git-send-email-antonynpavlov@gmail.com \
    --to=antonynpavlov@gmail.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox