Hello Christophe,

Am 17.01.2016 um 12:09 schrieb Christophe Ricard:
Work based on i2c-omap.c from linux kernel.

fsscll/fssclh and hsscll/hssclh was always negative in high speed.

i2c high speed frequency start after 400Khz.

Signed-off-by: Christophe Ricard <christophe-h.ric...@st.com>
---

  drivers/i2c/omap24xx_i2c.c | 17 +++++++++--------
  1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/i2c/omap24xx_i2c.c b/drivers/i2c/omap24xx_i2c.c
index 48ca446..774edaf 100644
--- a/drivers/i2c/omap24xx_i2c.c
+++ b/drivers/i2c/omap24xx_i2c.c
@@ -129,7 +129,9 @@ static int omap24_i2c_setspeed(struct udevice *adap, 
unsigned int speed)
        i2c_base = i2c_bus->i2c_base;
  #endif

-       if (speed >= OMAP_I2C_HIGH_SPEED) {
+       if (speed > 400000) {

Why you remove the define?

+               unsigned long scl;
+
                /* High speed */
                psc = I2C_IP_CLK / I2C_INTERNAL_SAMPLING_CLK;
                psc -= 1;
@@ -139,12 +141,11 @@ static int omap24_i2c_setspeed(struct udevice *adap, 
unsigned int speed)
                }

                /* For first phase of HS mode */
-               fsscll = I2C_INTERNAL_SAMPLING_CLK / (2 * speed);
+               scl = I2C_INTERNAL_SAMPLING_CLK / 400000;

-               fssclh = fsscll;
+               fsscll = scl - (scl / 3) - 7;
+               fssclh = (scl / 3)  - 5;

-               fsscll -= I2C_HIGHSPEED_PHASE_ONE_SCLL_TRIM;
-               fssclh -= I2C_HIGHSPEED_PHASE_ONE_SCLH_TRIM;
                if (((fsscll < 0) || (fssclh < 0)) ||
                    ((fsscll > 255) || (fssclh > 255))) {
                        puts("Error : I2C initializing first phase clock\n");
@@ -152,10 +153,10 @@ static int omap24_i2c_setspeed(struct udevice *adap, 
unsigned int speed)
                }

                /* For second phase of HS mode */
-               hsscll = hssclh = I2C_INTERNAL_SAMPLING_CLK / (2 * speed);
+               scl = I2C_IP_CLK / speed;
+               hsscll = scl - (scl / 3) - 7;
+               hssclh = (scl / 3) - 5;

-               hsscll -= I2C_HIGHSPEED_PHASE_TWO_SCLL_TRIM;
-               hssclh -= I2C_HIGHSPEED_PHASE_TWO_SCLH_TRIM;
                if (((fsscll < 0) || (fssclh < 0)) ||
                    ((fsscll > 255) || (fssclh > 255))) {
                        puts("Error : I2C initializing second phase clock\n");


Reviewed-by: Heiko Schocher <h...@denx.de>

bye,
Heiko
--
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
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