Re: [PATCH v2 1/1] i2c: rcar: modify I2C driver

2013-07-22 Thread Nguyen Viet Dung

Hi Wolfram,

I'm sorry ,I had mistake for your'address.

Please consider this patch.
It have tested on Lager board (R8A7790 soc) and it seen like goood.

Thanks you,
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] i2c-designware: make *CNT values configurable

2013-07-22 Thread Christian Ruppert
On Wed, Jul 17, 2013 at 11:39:58PM +0900, Shinya Kuribayashi wrote:
> On 7/16/13 8:16 PM, Christian Ruppert wrote:> On Sat, Jul 13, 2013 at 
> 02:36:43PM +0900, Shinya Kuribayashi wrote:
> >>Basically, DW I2C core provides a good enough (and quite direct) way
> >>to control tHIGH and tLOW timing specs, *HCNT and *LCNT registers.
> >>
> >>But from my experience (with a slightly old version of DW I2C core
> >>around 2005, version 1.06a or so), DW I2C core was apparently lacking
> >>in an appropriate hardware mechanism to meet tHD;STA timing spec.  We
> >>then found that we could meet tHD;STA by increasing *HCNT values, so
> >>that's what currently we have in i2c-designware.c  I know with that
> >>workaround applied, tHIGH is to be configured with a larger value
> >>than necessary, but we have no choice.  For I2C bus systems, we must
> >>meet every timing constraint strictly as required.  If DW I2C core
> >>cannot meet tHD;STA without the sacrifice of tHIGH, and I would call
> >>it a hardware bug.
> >
> >I agree. However, tHD;STA [min] is defined to the same value as tHIGH
> >[min] for all modes in the I2C specification. Do I understand you
> >correctly that the SCL_HCNT parameters control at the same time tHIGH
> >and tHD;STA?
> 
> *HCNT value does affect both tHIGH and tHD;STA at the same time.
> But we have to make sure that composition of tHIGH is different
> from the one of tHD;STA.
> 
> For tHIGH
> --
> 
> DW I2C core is aware of the SCL rising transition (tr) and can
> ignore it.  It starts counting the HIGH period of the SCL signal
> (tHIGH) after the SCL input voltage increases at VIH.
> 
> This is described in the data book as an ideal configuration,
> and the resulting formula would be:
> 
>   HCNT + (1+4+3) >= IC_CLK * tHIGH ... (a)
> 
> please refer to the data book for details about (1+4+3) part.
> 
> For tLOW
> 
> 
> DW I2C core starts counting the SCL CNTs for the LOW period of
> the SCL signal (tLOW) as soon as it pulls the SCL line _without_
> _confirming_ the SCL input voltage decreases at VIL.
> 
> In order to meet the tLOW timing spec, we need to take into
> account the fall time of SCL signal (tf), so the resulting
> formula should be:
> 
>   LCNT + 1 >= IC_CLK * (tLOW + tf)
> 
> please refer to the data book for details about '+1' part.
> 
> For tHD;STA
> ---
> 
> There is no explanation about tHD;STA in the data book.  We
> only have (my) experimental result; tHD;STA turned out to be
> proportional to 'HCNT + 3'.  The formula is:
> 
>   HCNT + 3 >= IC_CLK * (tHD;STA + tf) ... (b)
> 
> DW I2C core seems to start counting the SCL CNTs for the HIGH
> period of the SCL signel (tHD;STA) as soon as it pulls the _SDA_
> line without confirming the SDA input voltage decreases at VIL,
> so we have to take into account the SDA falling transition (tf)
> here.
> 
> As can be expected from (a) and (b), if tHD;STA [min] is defined
> to the same value as tHIGH [min], we need to have larger HCNT
> value than necessary for tHIGH, to meet tHD;STA constraint.
> 
> [...]

Hrmmm... This makes my head spin. Do you think the following code
snippet represents an accurate method to calculate the register values?
If you agree I'll prepare a patch based on that for the DW I2C. The
question will be, however, how to obtain the transition times.

Would it make sense to add generic I2C device tree properties for those
parameters? These parameters are independent of the actual bus driver,
rather a PCB property... And as such the correct place would be device
tree or ACPI or similar.

Greetings,
  Christian

--- SNIP ---
/*
 *t_f;SDA
 *  |-|
 * _  _ . . .
 *  \/
 * SDA   \  /
 *\/   t_r;SCLt_f;SCL
 *   |-||-|
 * __   
 *   \ /\
 * SCL\   /  \
 * \_/\___ . . .
 *|--| |-| ||
 *t_HD;STAt_LOW  t_HIGH
 *
 *  ||---| ||
 * (   HCNT   LCNTHCNT   ) * 1/f_SYS
 *
 *
 * HCNT = f_SYS * max(t_HD;STA + t_f;SDA , t_HIGH)
 *  = f_SYS * (t_HIGH + t_f;SDA)  because T_HD;STA == T_HIGH
 * LCNT = f_SYS * (t_f;SCL + t_LOW)
 * HCNT + LCNT + t_r;SCL = 1/f_SCL = t_SCL
 */

#define I2C_STD_MODE   (0)
#define I2C_FAST_MODE  (1)
#define I2C_FAST_MODE_PLUS (2)

static const struct i2c_timing_params {
unsigned int t_SCL;   /* t_SCL in (ms * 65536) */
unsigned int t_LOW;   /* t_LOW in (ms * 65536) */
unsigned int t_HIGH;  /* t_HIGH = t_HD;STA in (ms * 65536) */
} i2c_timing_params[] = {
{ /* I2C_STD_MODE */
.t_SCL   = 10.0e-3 * 65536 + 0.5,
.t_LOW   =  4.7e-3 * 65536 + 0.5,
.t_HIGH  =  4.0e-3 * 65536 + 0.5,
},
{ /* I2C_FAST

Re: [PATCH v2 1/1] i2c: rcar: modify I2C driver

2013-07-22 Thread Nguyen Viet Dung

Hi Wolfram, Morimoto-san

On 07/11/2013 06:03 PM, Kuninori Morimoto wrote:

Hi Wolfram, Dung-san

# I added Wolfram's email address


From: Nguyen Viet Dung 

This patch modify calculate for clock in I2C driver.

Signed-off-by: Nguyen Viet Dung 
---

You forgot to add Wolfram's email address on this patch

Acked-by: Kuninori Morimoto 

I am sorry, I have forgot  to add Wolfram's email address on the patch.

Wolfram,please consider this patch.
It have tested on Lager board (R8A7790 soc) and it seen like goood.

Thanks you,
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html