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 v2 4/7] tegra: Add I2C driver
Date: Fri, 13 Jan 2012 16:15:09 +0100	[thread overview]
Message-ID: <4F104A7D.2050008@denx.de> (raw)
In-Reply-To: <CAPnjgZ3jGG2DsafPsf3LS+9GvURTagjRjB9AiUzZiWeS1G+ASQ@mail.gmail.com>

Hello Simon,

Simon Glass wrote:
> Hi Heiko,
> 
> On Thu, Jan 12, 2012 at 11:25 PM, Heiko Schocher <hs@denx.de> wrote:
>> Hello Simon,
>>
>> Simon Glass wrote:
>>> From: Yen Lin <yelin@nvidia.com>
>>>
>>> Add basic i2c driver for Tegra2 with 8- and 16-bit address support.
>>> The driver requires CONFIG_OF_CONTROL to obtain its configuration
>>> from the device tree.
>>>
>>> (Simon Glass: sjg at chromium.org modified for upstream)
>>>
>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>> ---
>>> Changes in v2:
>>> - Use DIV_ROUND_UP() instead of a home-grown macro
>>> - Tidy comment style
>>> - Change i2c array to static
>>> - Adjust definitions to fit new peripheral clock bindings
>>> - Remove i2c configuring using CONFIG (use fdt instead)
>> Why? Ah found it ... Hmm.. why we don't need the non OF
>> case?
> 
> The intent is that Tegra boards will run with fdt turned on. It means
> that we should be able to build U-Boot for a Tegra platform using the
> Linux fdt file and not lots of manual config. Of course this works
> better for some peripherals than others, but I2C works well enough.

Ah, Ok, nice!

>>> - Make i2c/dvc decision come from fdt
>>> - Use new fdtdec alias decode function
>>> - Simplify code in i2c_addr_ok()
>>> - Return an error if an unavailable i2c bus is selected
>>>
>>>  arch/arm/include/asm/arch-tegra2/tegra2_i2c.h |  160 +++++++
>>>  drivers/i2c/Makefile                          |    1 +
>>>  drivers/i2c/tegra2_i2c.c                      |  551 +++++++++++++++++++++++++
>>>  include/fdtdec.h                              |    2 +
>>>  lib/fdtdec.c                                  |    2 +
>>>  5 files changed, 716 insertions(+), 0 deletions(-)
>>>  create mode 100644 arch/arm/include/asm/arch-tegra2/tegra2_i2c.h
>>>  create mode 100644 drivers/i2c/tegra2_i2c.c
>> [...]
>>> diff --git a/drivers/i2c/tegra2_i2c.c b/drivers/i2c/tegra2_i2c.c
>>> new file mode 100644
>>> index 0000000..a7db714
>>> --- /dev/null
>>> +++ b/drivers/i2c/tegra2_i2c.c
>>> @@ -0,0 +1,551 @@
>> [...]
>>> +static void i2c_init_controller(struct i2c_bus *i2c_bus)
>>> +{
>>> +     /* TODO: Fix bug which makes us need to do this */
>>> +     clock_start_periph_pll(i2c_bus->periph_id, CLOCK_ID_OSC,
>>> +                            i2c_bus->speed * (8 * 2 - 1));
>>                                                 Can you use here some defines?
>> What is (8 * 2 - 1) ?
> 
> I will look up the bug and find out.

Not a bug, just I did not know what this values are for ...

>>> +#ifndef CONFIG_OF_CONTROL
>>> +#error "Please enable device tree support to use this driver"
>>> +#endif
>> Hmm.. see above question. Ok, if somebody need want to use this
>> driver without CONFIG_OF_CONTROL it must be added ...
> 
> Yes and they need a way of getting the configuration in there. The fdt
> is nicer...

;-)

[...]
>>> +void i2c_init(int speed, int slaveaddr)
>>> +{
>>> +     debug("i2c_init(speed=%u, slaveaddr=0x%x)\n", speed, slaveaddr);
>>> +}
>> Hmm... i2c_init is called to init the i2c subsystem ... you do nothing
>> here ... and use i2c_init_board for init the i2c bus, right?
>>
>> But i2c_init_board is not called from the driver ... ah, you do this
>> in board code ... Ok ...
>>
>> I think, you do this, because i2c_init is called very early, and
>> so processing fdt is slow?
> 
> That's not the main reason but it is true. We have no need of early
> I2C on the platform. Also we don't want to set the speed as this is
> defined individually per port in the fdt.

Ok.

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

  reply	other threads:[~2012-01-13 15:15 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-12 19:00 [U-Boot] [PATCH v2 0/7] tegra: Add I2C driver and associated parts Simon Glass
2012-01-12 19:00 ` [U-Boot] [PATCH v2 1/7] tegra: Rename NV_PA_PMC_BASE to TEGRA2_PMC_BASE Simon Glass
2012-01-12 19:00 ` [U-Boot] [PATCH v2 2/7] fdt: Add function to allow aliases to refer to multiple nodes Simon Glass
2012-01-19 20:49   ` Stephen Warren
2012-01-19 23:45     ` Simon Glass
2012-01-20  0:17       ` Stephen Warren
2012-01-20  0:31         ` Simon Glass
2012-01-12 19:00 ` [U-Boot] [PATCH v2 3/7] tegra: fdt: Add extra I2C bindings for U-Boot Simon Glass
2012-01-13  6:31   ` Heiko Schocher
2012-01-13 15:02     ` Simon Glass
2012-01-19 20:51   ` Stephen Warren
2012-01-22 17:41     ` Simon Glass
2012-01-23 18:25       ` Stephen Warren
2012-02-03 23:27         ` Simon Glass
2012-01-12 19:00 ` [U-Boot] [PATCH v2 4/7] tegra: Add I2C driver Simon Glass
2012-01-13  7:25   ` Heiko Schocher
2012-01-13 15:09     ` Simon Glass
2012-01-13 15:15       ` Heiko Schocher [this message]
2012-01-19 21:08   ` Stephen Warren
2012-02-03 23:26     ` Simon Glass
2012-02-06 21:41       ` Yen Lin
2012-02-09 17:46         ` Simon Glass
2012-01-12 19:00 ` [U-Boot] [PATCH v2 5/7] tegra: Initialise I2C on Nvidia boards Simon Glass
2012-01-12 19:00 ` [U-Boot] [PATCH v2 6/7] tegra: Select I2C ordering for Seaboard Simon Glass
2012-01-19 20:56   ` Stephen Warren
2012-02-03 23:24     ` Simon Glass
2012-02-04  0:14       ` Stephen Warren
2012-02-04  0:19         ` Simon Glass
2012-02-04  0:25           ` Stephen Warren
2012-02-04  0:36             ` Simon Glass
2012-02-04  0:41               ` Stephen Warren
2012-02-04  0:58                 ` Simon Glass
2012-01-12 19:00 ` [U-Boot] [PATCH v2 7/7] tegra: Enable I2C on Seaboard Simon Glass
2012-01-13  6:28 ` [U-Boot] [PATCH v2 0/7] tegra: Add I2C driver and associated parts Heiko Schocher
2012-01-13 15:01   ` Simon Glass

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=4F104A7D.2050008@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