Hello Tom,

On 26.10.2012 20:44, Tom Rini wrote:
On Thu, Oct 25, 2012 at 02:37:08PM -0700, Simon Glass wrote:

[snip]
Later, I wonder whether the concept of a 'current' i2c bus should be
maintained by the command line interpreter, rather than the i2c
system. Because to be honest, most of the drivers I see have to save
the current bus number, set the current bus, do the operation, then
set the bus back how they found it (to preserve whatever the user
things is the current bus).

I agree.  Lets move the notion of "current" to cmd_i2c and make
everything internally pass around the bus to operate on.  Or try going
down this path and find a fatal problem :)

As I wrote to simon, stephen, this is an independent problem from the
new framework patches!

- There are two steps to do:
  - save the curent cmdline bus in a variable, and call i2c_set_bus_num()
    before you call i2c_* from the commandline, get rid of the store/restore
    calls ...

  - change the i2c API to pass the i2c bus in the i2c_* functions
    -> in the new i2c framework, i2c_set_bus() gets static and the
       gd->current_i2c_bus is used only in i2c_core.c

This two steps can be done in one step, but the second step is complicated
enough, so it is better to do it in two steps (I think)!

Waiting for patches ;-)

The i2c framework change is independent from this! The current_i2c_bus is
used i2c_core internally for storing the current active i2c bus, based
on the idea of having only one i2c bus active in U-Boot, see therefore
the U-Boot principle:

http://www.denx.de/wiki/view/U-Boot/DesignPrinciples#2_Keep_it_Fast
"Initialize devices only when they are needed within U-Boot, i.e. don't
initialize the Ethernet interface(s) unless U-Boot performs" [...]", etc.
(and don't forget to shut down these devices after using them -
otherwise nasty things may happen when you try to boot your OS). "

therefore the "current i2c bus" is needed! If we want to drop this
"U-Boot principle", we can get rid of current_i2c_bus ... (Ok, currently
U-Boot do not deactivate not used i2c adapters ...)

bye,
Heiko
--
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to