Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/nvidia fix source clock divisor, set MSTR_CONFI...



details:   https://anonhg.NetBSD.org/src/rev/a61a9deb70f2
branches:  trunk
changeset: 338272:a61a9deb70f2
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sat May 16 23:09:08 2015 +0000

description:
fix source clock divisor, set MSTR_CONFIG_LOAD after updating config, reset controller on errors, read from rx fifo before waiting for xfer to complete

diffstat:

 sys/arch/arm/nvidia/tegra_i2c.c |  21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diffs (75 lines):

diff -r 8ccec1db62a1 -r a61a9deb70f2 sys/arch/arm/nvidia/tegra_i2c.c
--- a/sys/arch/arm/nvidia/tegra_i2c.c   Sat May 16 23:07:51 2015 +0000
+++ b/sys/arch/arm/nvidia/tegra_i2c.c   Sat May 16 23:09:08 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_i2c.c,v 1.2 2015/05/16 21:31:39 jmcneill Exp $ */
+/* $NetBSD: tegra_i2c.c,v 1.3 2015/05/16 23:09:08 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
 #include "locators.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tegra_i2c.c,v 1.2 2015/05/16 21:31:39 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_i2c.c,v 1.3 2015/05/16 23:09:08 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -125,7 +125,7 @@
        aprint_normal_dev(self, "interrupting on irq %d\n", loc->loc_intr);
 
        /* Recommended setting for standard mode */
-       tegra_car_periph_i2c_enable(loc->loc_port, 204000000);
+       tegra_car_periph_i2c_enable(loc->loc_port, 20400000);
 
        tegra_i2c_init(sc);
 
@@ -149,6 +149,8 @@
        I2C_WRITE(sc, I2C_CNFG_REG,
            I2C_CNFG_NEW_MASTER_FSM | I2C_CNFG_PACKET_MODE_EN);
        I2C_SET_CLEAR(sc, I2C_SL_CNFG_REG, I2C_SL_CNFG_NEWSL, 0);
+       I2C_WRITE(sc, I2C_BUS_CONFIG_LOAD_REG,
+           I2C_BUS_CONFIG_LOAD_MSTR_CONFIG_LOAD);
 }
 
 static int
@@ -239,6 +241,11 @@
        if ((flags & I2C_F_POLL) == 0) {
                I2C_WRITE(sc, I2C_INTERRUPT_MASK_REG, 0);
        }
+
+       if (error) {
+               tegra_i2c_init(sc);
+       }
+
        return error;
 }
 
@@ -349,7 +356,7 @@
        uint8_t *p = buf;
        size_t n, resid = buflen;
        uint32_t data;
-       int error, retry;
+       int retry;
 
        const uint32_t istatus = I2C_READ(sc, I2C_INTERRUPT_STATUS_REG);
        I2C_WRITE(sc, I2C_INTERRUPT_STATUS_REG, istatus);
@@ -372,10 +379,6 @@
            I2C_IOPACKET_XMITHDR_IE | I2C_IOPACKET_XMITHDR_READ |
            __SHIFTIN((addr << 1) | 1, I2C_IOPACKET_XMITHDR_SLAVE_ADDR));
 
-       if ((error = tegra_i2c_wait(sc, flags)) != 0) {
-               return error;
-       }
-
        while (resid > 0) {
                retry = 10000;
                while (--retry > 0) {
@@ -399,5 +402,5 @@
                p += min(resid, 4);
        }
 
-       return 0;
+       return tegra_i2c_wait(sc, flags);
 }



Home | Main Index | Thread Index | Old Index