public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 04/11] powerpc/ppc4xx: Add bitbang i2c interface for gdsys boards
Date: Tue, 23 Apr 2013 08:16:32 +0200	[thread overview]
Message-ID: <51762740.1060407@denx.de> (raw)
In-Reply-To: <51762DEF.8050608@denx.de>

Hello Stefan,

Am 23.04.2013 08:45, schrieb Stefan Roese:
> Hi Dirk!
> 
> (Added Heiko as I2C custodian to Cc)
> 
> On 22.04.2013 13:16, Dirk Eibach wrote:
>> This adds an i2c bitbang interface that can coexist with processor i2c.

Huh... missed this EMail...

>>
>> Signed-off-by: Dirk Eibach <eibach@gdsys.de>
>> ---
>>  board/gdsys/common/Makefile |    2 +-
>>  board/gdsys/common/bb_i2c.c |  304 +++++++++++++++++++++++++++++++++++++++++++
>>  board/gdsys/common/bb_i2c.h |   76 +++++++++++
>>  3 files changed, 381 insertions(+), 1 deletion(-)
>>  create mode 100644 board/gdsys/common/bb_i2c.c
>>  create mode 100644 board/gdsys/common/bb_i2c.h
> 
> Just checking: Is it really not possible to use multiple different I2C
> interfaces (e.g. PPC4xx I2C and GPIO bitbang I2C)? Heiko, whats the
> current status here?

If this is needed, we should merge the multibus/multiadapter
approach finally to mainline, found here:

http://git.denx.de/?p=u-boot/u-boot-i2c.git;a=shortlog;h=refs/heads/20130416_multibus_v2

Yeah, waiting for such a chance for some years ;-)

I am not happy to have boardspecific approaches here! Dirk, could
you give the above sources a try? I must admit that the sources
are just rebased without doing big tests on several plattforms ...
but the branch compiles clean for arm and powerpc. If it works
for you, we can try to bring it in the next merge window in mainline...

- steps to do (for you):
  - port the ppc4xx i2c driver to the new framework
    There is an older branch, where I did this for an older
    version of the multibus/multiadapter approach, see here:
    http://git.denx.de/?p=u-boot/u-boot-i2c.git;a=shortlog;h=refs/heads/multibus_v2_20111112

    It gives you maybe an idea how to do this.

  - for adding a soft i2c driver you should do something like:

+#define CONFIG_SYS_I2C_SOFT            /* I2C bit-banged */
+#define CONFIG_SYS_I2C_SOFT_SPEED      Your speed
+#define CONFIG_SYS_I2C_SOFT_SLAVE      Your slave addr

+#define I2C_TRISTATE   i2c_soft_tristate()
+#define I2C_READ       i2c_soft_read()
+#define I2C_ACTIVE     i2c_soft_delay()
+#define I2C_SCL(bit)   i2c_soft_scl(bit)
+#define I2C_SDA(bit)   i2c_soft_sda(bit)
+#define I2C_DELAY      i2c_soft_delay()
+#define I2C_INIT       i2c_soft_init()

and in your board code define the above functions:

+#if defined(CONFIG_SYS_I2C_SOFT)
+#include <i2c.h>
+
+void i2c_soft_init(void)
+{
+       printf("init: %d\n", I2C_ADAP_HWNR);
+}
+
+void i2c_soft_active(void)
+{
+       printf("active: %d\n", I2C_ADAP_HWNR);
+}
+
+void i2c_soft_tristate(void)
+{
+       printf("tristate: %d\n", I2C_ADAP_HWNR);
+}
+
+int i2c_soft_read(void)
+{
+       return 1;
+}
+
+void i2c_soft_sda(int bit)
+{
+       printf("sda: %d\n", I2C_ADAP_HWNR);
+}
+
+void i2c_soft_scl(int bit)
+{
+       printf("scl: %d\n", I2C_ADAP_HWNR);
+}
+
+void i2c_soft_delay(void)
+{
+       printf("delay: %d\n", I2C_ADAP_HWNR);
+}
+
+#endif

You can have more than one soft i2c adapter by defining
the defines I2C_SOFT_DECLARATIONS2, I2C_SOFT_DECLARATIONS3 ...
and switch between them by interpreting the I2C_ADAP_HWNR
in the above functions ...

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

  reply	other threads:[~2013-04-23  6:16 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-22 11:16 [U-Boot] [PATCH 0/11] Update gdsys ppc4xx-based boards Dirk Eibach
2013-04-22 11:16 ` [U-Boot] [PATCH 01/11] powerpc/ppc4xx: Add generic accessor functions for gdsys FPGA Dirk Eibach
2013-04-22 11:16 ` [U-Boot] [PATCH 02/11] powerpc/ppc4xx: Add gdsys mclink interface Dirk Eibach
2013-04-22 11:16 ` [U-Boot] [PATCH 03/11] powerpc/ppc4xx: Add fpgad command for dumping gdsys fpga registers Dirk Eibach
2013-04-22 17:14   ` Tom Rini
2013-04-23  9:53     ` [U-Boot] (WARNING!!! PGP with incorrect signature) " Eibach, Dirk
2013-04-23 11:40       ` Tom Rini
2013-04-22 11:16 ` [U-Boot] [PATCH 04/11] powerpc/ppc4xx: Add bitbang i2c interface for gdsys boards Dirk Eibach
2013-04-23  6:45   ` Stefan Roese
2013-04-23  6:16     ` Heiko Schocher [this message]
2013-04-23  7:35       ` [U-Boot] burst transaction test TigerLiu at viatech.com.cn
2013-04-23 12:16         ` Wolfgang Denk
2013-04-24 11:43       ` [U-Boot] [RFC] i2c, ppc4xx_i2c: switch to new multibus/multiadapter support Dirk Eibach
2013-04-24 12:48         ` Heiko Schocher
2013-04-24 13:00           ` Dirk Eibach
2013-04-24 13:04             ` Heiko Schocher
2013-04-24 13:11               ` Stefan Roese
2013-04-25 13:21               ` Dirk Eibach
2013-04-25 13:49                 ` Heiko Schocher
2013-04-22 11:16 ` [U-Boot] [PATCH 05/11] powerpc/ppc4xx: Use generic FPGA accessors in gdsys common code Dirk Eibach
2013-04-22 11:16 ` [U-Boot] [PATCH 06/11] powerpc/ppc4xx: Support gdsys multichannel iocon hardware Dirk Eibach
2013-04-22 11:16 ` [U-Boot] [PATCH 07/11] powerpc/ppc4xx: Use generic FPGA accessors on all gdsys 405ep/ex boards Dirk Eibach
2013-04-22 11:16 ` [U-Boot] [PATCH 08/11] powerpc/ppc4xx: Fixup phy erratum on gdsys iocon hardware Dirk Eibach
2013-04-22 11:16 ` [U-Boot] [PATCH 09/11] powerpc/ppc4xx: Increase timeout for gdsys mclink bus startup Dirk Eibach
2013-04-22 11:16 ` [U-Boot] [PATCH 10/11] powerpc/ppc4xx: Consider gdsys FPGA OSD size Dirk Eibach
2013-04-22 11:16 ` [U-Boot] [PATCH 11/11] powerpc/ppc4xx: Remove CONFIG_SYS_FLASH_PROTECTION from gdsys boards Dirk Eibach

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=51762740.1060407@denx.de \
    --to=hs@denx.de \
    --cc=u-boot@lists.denx.de \
    /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