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] 7/12 Multiadapter/multibus I2C, drivers part 4
Date: Sun, 15 Feb 2009 08:56:30 +0100	[thread overview]
Message-ID: <4997CAAE.60401@denx.de> (raw)
In-Reply-To: <Pine.LNX.4.64ksi.0902142019520.6240@home-gw.koi8.net>

Hello ksi,

ksi at koi8.net wrote:
> On Sat, 14 Feb 2009, Heiko Schocher wrote:
>
>   
>> Hello ksi,
>>
>> ksi at koi8.net wrote:
>>     
>>> On Fri, 13 Feb 2009, Heiko Schocher wrote:
>>>       
>>>> ksi at koi8.net wrote:
>>>>         
>>>>> Signed-off-by: Sergey Kubushyn <ksi@koi8.net>
>>>>> ---
>>>>> diff -purN u-boot-i2c.orig/drivers/i2c/soft_i2c.c u-boot-i2c/drivers/i2c/soft_i2c.c
>>>>> --- u-boot-i2c.orig/drivers/i2c/soft_i2c.c	2009-02-12 10:43:41.000000000 -0800
>>>>> +++ u-boot-i2c/drivers/i2c/soft_i2c.c	2009-02-12 10:46:00.000000000 -0800
>>>>> @@ -1,4 +1,8 @@
>>>>>  /*
>>>>> + * Copyright (c) 2009 Sergey Kubushyn <ksi@koi8.net>
>>>>> + *
>>>>> + * Changes for multibus/multiadapter I2C support.
>>>>> + *
>>>>>   * (C) Copyright 2001, 2002
>>>>>   * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
>>>>>           
>>>> [...]
>>>>
>>>> The following patch is based on your patches without 7/12 and
>>>> adds multibus support for the soft_i2c driver without doing such
>>>> a big change as you did. Maybe it is not yet perfect, because
>>>> it is just a fast try, but I think we should go this way. What
>>>> do you/others think?
>>>>         
>>> The reason behind this patch is making SEVERAL different SOFT_I2C ADAPTERS
>>> available. Not BUSSES but separate PHYSICAL I2C ADAPTERS made of different
>>> pin pairs from different chips.
>>>       
>> This you can also do with "my" suggestion ...
>>
>>     
>>> OK, please explain how are you going to make different functions for
>>> different adapters? Let's say you want to use 2 on-SoC GPIO pins for
>>>       
>> You can do now the following for example in your
>> include/configs/MPC8548CDS.h example:
>>
>> you only have to define
>>
>> #define I2C_SDA(bit)   (printf("hwadap: %d sda1: %d", cur_adap_nr->hwadapnr, bit))
>>
>> if this is a real driver you can make a function in your board code
>> say (just a fast thought):
>>
>> void i2c_soft_sda (int bit)
>> {
>> 	switch(cur_adap_nr->hwadapnr) {
>> 		case 0:
>> 			/* adapter specfic code 0 */
>> 			break;
>> 		case 1:
>> 			/* adapter specfic code 1 */
>> 			break;
>> 		[...]
>> 	}
>> }
>>
>> and define in config file
>>
>> #define I2C_SDA(bit)   i2c_soft_sda (bit)
>>     
>
> That means you have to make changes in two places instead of one -- config
> file AND $(BOARD).c. Also you use functions instead of macros and you can
>   

Yes. But that was just a thought, it should be possible to do this also
in macros.

> NOT make them inline because they come from a separate object file. This
> essentially defeats the very purpose of that common soft_i2c.c driver. If
> you want to make functions for bitbanged I2C into the $(BOARD).c there is no
> reason to have them as a base for that driver. It is much more logical to do
>   

Maybe more logical, but not needed.

> everything in reverse, i.e. instead of having soft_i2c.c as a bona fide
> drivers and those I2C_SDA and friends as its building blocks make those
> i2c_soft_sda() etc. in each and every $(BOARD).c into primary entities and
> build the actual driver in the $(BOARD).c itself. Just convert that
> soft_i2c.c into a header file with macros for real functions (soft_i2c_read
> etc.) and instantiate them in the $(BOARD).c.
>
> The only problem with that is it breaks uniformity and makes another mess.
>   

Just, if we do this, but we don;t need to do it so.

> The whole idea was to bring _ALL_ I2C drivers to a single place and make
> them totally transparent and uniform. Something like e.g. Linux VFS.
>
> And remember, the devil is in details. How are you going to assign
> (initialize) that innocent looking "cur_adap_nr->hwadapnr"? How are you
> going to work on an adapter other that "current" in a situation when you can
> NOT change "current" adapter (e.g. perform all I2C layer initialization
> while still running from flash?) Remember, this is plain C and there is no
>   

Yes, good point. But do we need more then one i2c adapter when running
from flash? I see only one reason to use i2c when running from flash:
accessing SPD EEprom ... and this "bus" could always be the first
hw adapter. All other accesses to i2c should be moved to run when
we are in ram.

> "this" pointer... And that is just a tip of an iceberg...
>
> And the million dollar question -- what is the potential gain?
>   

I want to avoid such a big change in soft_i2c.c. Also if you have
4 bitbang instances with your version you have 3 times more code.

But if others are on your side, I have no problem with your approach.

>   
>>> adapter #0, 2 GPIOs from a PCI-PCI bridge for adapter #1, and 2 pins from
>>> some chip sitting behind that bridge for adapter #2 if all those pin sets
>>> are accessed totally different. I won't even start about using pins from
>>> different chips for SDA and SCL (let's say you only have one GPIO available
>>> on your SoC and another one on PCI Bridge.)
>>>
>>> What your patch creates is just aliases to the SAME physical adapter.
>>>       
>> No, it is not! I only use the same functions, but in the board
>> specific code it is possible to made a switch and access
>> the Pins where ever they are.
>>     
>
> You are adding unnecessary complexity to the code. And you break uniformity.
>   

not really.

> Those defines in config/soft_i2c.c make real inline functions at _COMPILE_
> time. Your approach shifts it to _LINK_ time. It also makes those drivers
> come from 3 places ($(BOARD).c, include/configs/$(BOARD).h, and soft_i2c.c)
>   

Thats not really a problem.

bye
Heiko

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

  reply	other threads:[~2009-02-15  7:56 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-13 10:17 [U-Boot] [PATCH] 7/12 Multiadapter/multibus I2C, drivers part 4 Heiko Schocher
2009-02-13 21:23 ` ksi at koi8.net
2009-02-14  8:24   ` Heiko Schocher
2009-02-15  5:03     ` ksi at koi8.net
2009-02-15  7:56       ` Heiko Schocher [this message]
2009-02-16  6:35         ` ksi at koi8.net
2009-02-16  9:03           ` Heiko Schocher
2009-02-16 22:17             ` Wolfgang Denk
2009-02-17 21:23               ` ksi at koi8.net
2009-02-16 22:16           ` Wolfgang Denk
2009-02-17 21:22             ` ksi at koi8.net
2009-02-18  7:23               ` Heiko Schocher
2009-02-16 22:11       ` Wolfgang Denk
2009-02-17 21:19         ` ksi at koi8.net
2009-02-17 22:49           ` Wolfgang Denk
2009-02-17 23:42             ` ksi at koi8.net
2009-02-18  0:13               ` Wolfgang Denk
2009-02-18  0:35                 ` ksi at koi8.net
2009-02-18  7:47                   ` Heiko Schocher
2009-02-18 18:05                     ` ksi at koi8.net
2009-02-18 18:26                       ` Wolfgang Denk
2009-02-18 19:47                         ` ksi at koi8.net
2009-02-18 22:09                           ` Wolfgang Denk
2009-02-18 23:00                             ` ksi at koi8.net
2009-02-18 23:31                               ` Wolfgang Denk
2009-02-19  0:46                                 ` ksi at koi8.net
2009-02-19  8:00                               ` Heiko Schocher
2009-02-19 19:48                                 ` ksi at koi8.net
2009-02-19 20:50                                   ` Wolfgang Denk
2009-02-19 22:26                                     ` ksi at koi8.net
2009-02-20  8:53                                       ` Heiko Schocher
2009-02-20  7:08                                     ` Heiko Schocher
2009-02-20  7:06                                   ` Heiko Schocher
2009-02-18  7:33             ` Heiko Schocher
2009-02-18  8:06               ` Wolfgang Denk
2009-02-18  8:15                 ` Heiko Schocher
2009-02-18  8:55                   ` Wolfgang Denk
2009-02-18 18:58                     ` ksi at koi8.net
2009-02-18 18:51                 ` ksi at koi8.net
2009-02-18 17:44               ` ksi at koi8.net
2009-02-19  6:10                 ` Heiko Schocher
2009-02-19 14:46                   ` ksi at koi8.net
2009-02-19 15:06                     ` Heiko Schocher
2009-02-19 19:52                       ` ksi at koi8.net
2009-02-19 20:55                         ` Wolfgang Denk
2009-02-19 22:33                           ` ksi at koi8.net
2009-02-20  7:09                           ` Heiko Schocher
2009-02-18  7:20           ` Heiko Schocher
2009-02-18 18:48             ` ksi at koi8.net
2009-02-19  6:31               ` Heiko Schocher
2009-02-19 19:35                 ` ksi at koi8.net
2009-02-19 21:22                   ` Wolfgang Denk
2009-02-20  0:13                     ` ksi at koi8.net
2009-02-20  7:01                   ` Heiko Schocher
2009-02-20 21:29                     ` ksi at koi8.net
2009-02-21  7:25                       ` Heiko Schocher
2009-02-21 18:19                         ` ksi at koi8.net
2009-02-18  8:17           ` Heiko Schocher
2009-02-18  8:58             ` Heiko Schocher
2009-02-18 18:57               ` ksi at koi8.net
2009-02-18 21:56                 ` Wolfgang Denk
2009-02-18 22:32                   ` ksi at koi8.net
2009-02-18 22:48                     ` Wolfgang Denk
2009-02-19  0:35                       ` ksi at koi8.net
2009-02-19  8:04                         ` Heiko Schocher
2009-02-19 21:29                         ` Wolfgang Denk
2009-02-19  7:39                       ` Heiko Schocher
2009-02-19 19:40                         ` ksi at koi8.net
2009-02-19  6:42                 ` Heiko Schocher
2009-02-18 18:53             ` ksi at koi8.net
2009-02-19  6:34               ` Heiko Schocher
2009-02-19 19:36                 ` ksi at koi8.net
  -- strict thread matches above, loose matches on Subject: below --
2009-02-12 22:25 ksi at koi8.net
2009-02-16 21:58 ` Wolfgang Denk
2009-02-17 20:02   ` ksi at koi8.net

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=4997CAAE.60401@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