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 2/6] power: Explicitly select pmic device's bus
Date: Fri, 04 Oct 2013 11:35:32 +0200	[thread overview]
Message-ID: <524E8BE4.3000400@denx.de> (raw)
In-Reply-To: <20131004105835.758b54f5@amdc308.digital.local>

Hello Lukasz,

Am 04.10.2013 10:58, schrieb Lukasz Majewski:
> Hi Heiko,
>
>> Hello Lukasz,
>>
>> Am 03.10.2013 18:15, schrieb Lukasz Majewski:
>>> Hi Heiko,
>>>
>>> Sorry for a late reply.
>>>
>>>> Hello Lukasz,
>>>>
>>>> Am 02.10.2013 17:11, schrieb Lukasz Majewski:
>>>>> Hi Leela,
[...]
>>>> but exactly I want to get rid of this code as it is in
>>>> pmic_select() someday, when all i2c drivers converted to the new
>>>> i2c framework.
>>>
>>> My 2 cents. I understand that pmic_select() preserves old i2c bus
>>> number, when PMIC performs transmission. This is probably done to
>>> not break the legacy code (where one driver assumed, that it is
>>> alone).
>>>
>>> If this is necessary, then I'm OK with this. However I personally
>>> think, that drivers shall call API functions from i2c core (like
>>> i2c_bus_num()) only with bus number to switch and do not store and
>>> preserve the i2c value. This is my personal comment.
>>
>> Full Ack. I am just thinking, that we can get rid of such constructs,
>> independent of the new i2c framework switch. We just need to introduce
>> a "current_i2c_cmd_bus" in common/cmd_i2c.c. This var stores the
>> current i2c bus where i2c commands are executed ...
>
> I think that "last used bus" variable shall be stored/managed at
> i2c_core.c. I can use i2c without cmd_i2c.c compiled (as it is with

Thats the case for the new framework! It stores the current bus, and
so i2c_set_bus_num() can decide, if it is necessary to switch to
a new bus ...

Additionally to get rid of such "store oldbus, switch to new, restore
old bus" constructs, the i2c commands needs to store somewhere, which
i2c bus the i2c commands currently use, because you can do a "i2c md ..."
then a "date" (maybe on antoher i2c bus) and then again a "i2c md ..."
I think, thats the real historical reason for doing all over the code
such "save oldbus" code ...

That var (saying i2c_cur_cmd_bus) can easily stored in common/cmd_i2c.c,
as commands are only useable after relocation. So, we must just add a
i2c_set_bus_num(i2c_cur_cmd_bus) call before a command is executed ...
That can be done in common/cmd_i2c.c also ...

So, in the end, before every i2c access we call i2c_set_bus_num()
and have no longer to store an "old bus" ... and if we have reached
this point, we can make i2c_set_bus_num() static, and add to the
i2c api a new first "int bus" parameter .... and can delete all
i2c_set_bus_num() calls ... so every i2c device must know, on which
i2c bus it works ... and as a bonus, we can get rid of all i2c_init()
calls all over around the code, as i2c_set_bus_num() checks, if the
drivers is initialized or not, if not initialize it, look if i2c
muxes are involved on this bus, and so on ...

> pmic and fuel gauge, which use different buses).

Yep, and its enough to call i2c_set_bus_num() before you want to access
a device ... i2c_set_bus_num() do all necessary steps for you.

>> and all other
>> subsystems, which use the i2c_api can call i2c_set_bus_num() without
>> a previous "save old bus" and after the i2c bus usage a "restore i2c
>> bus" ...
>
>
>> I try to look into this, maybe we can do this before all
>> i2c drivers are ported to the new framework ...
>
> Ok, lets wait for a patch.

I have such a patch in my queue, but it works only for drivers, which use
the new framework I think ... so I must think about it, if this works
for old style drivers too ...

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-10-04  9:35 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-01 14:32 [U-Boot] [PATCH 0/6] SMDK5420: Add S2MPS11 pmic support to SMDK5420 Leela Krishna Amudala
2013-10-01 14:32 ` [U-Boot] [PATCH 1/6] exynos: Use common pmic_reg_update() definition Leela Krishna Amudala
2013-10-02 14:49   ` Lukasz Majewski
2013-10-01 14:32 ` [U-Boot] [PATCH 2/6] power: Explicitly select pmic device's bus Leela Krishna Amudala
2013-10-02 15:11   ` Lukasz Majewski
2013-10-03  5:52     ` Heiko Schocher
2013-10-03 16:15       ` Lukasz Majewski
2013-10-04  5:23         ` Heiko Schocher
2013-10-04  8:58           ` Lukasz Majewski
2013-10-04  9:35             ` Heiko Schocher [this message]
2013-10-03  8:41     ` Leela Krishna Amudala
2013-10-03  9:44       ` Lukasz Majewski
2013-10-01 14:32 ` [U-Boot] [PATCH 3/6] FDT: Exynos5420: Add compatible srings for PMIC Leela Krishna Amudala
2013-10-01 14:32 ` [U-Boot] [PATCH 4/6] SMDK5420: S2MPS11: Adds the register settings for S2MPS11 Leela Krishna Amudala
2013-10-02 15:13   ` Lukasz Majewski
2013-10-01 14:32 ` [U-Boot] [PATCH 5/6] exynos: Add a common DT based PMIC driver initialization Leela Krishna Amudala
2013-10-01 14:32 ` [U-Boot] [PATCH 6/6] config: SMDK5420: Enable S2MPS1111111111111111111111 pmic Leela Krishna Amudala
2013-10-01 15:27   ` Leela Krishna Amudala

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=524E8BE4.3000400@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