Module Name: src Committed By: macallan Date: Thu Sep 1 14:04:55 UTC 2011
Modified Files: src/sys/dev/pci: voyager.c Log Message: some i2c devices we're going to deal with need a little delay after each write. Also make sure the gpios we're using are outputs. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/pci/voyager.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/pci/voyager.c diff -u src/sys/dev/pci/voyager.c:1.2 src/sys/dev/pci/voyager.c:1.3 --- src/sys/dev/pci/voyager.c:1.2 Thu Sep 1 00:06:42 2011 +++ src/sys/dev/pci/voyager.c Thu Sep 1 14:04:55 2011 @@ -1,7 +1,7 @@ -/* $NetBSD: voyager.c,v 1.2 2011/09/01 00:06:42 macallan Exp $ */ +/* $NetBSD: voyager.c,v 1.3 2011/09/01 14:04:55 macallan Exp $ */ /* - * Copyright (c) 2009 Michael Lorenz + * Copyright (c) 2009, 2011 Michael Lorenz * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: voyager.c,v 1.2 2011/09/01 00:06:42 macallan Exp $"); +__KERNEL_RCSID(0, "$NetBSD: voyager.c,v 1.3 2011/09/01 14:04:55 macallan Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -158,6 +158,11 @@ reg = bus_space_read_4(sc->sc_memt, sc->sc_regh, SM502_GPIO0_CONTROL); if ((reg & GPIO_I2C_BITS) == 0) { + /* both bits as outputs */ + reg = bus_space_read_4(sc->sc_memt, sc->sc_regh, SM502_GPIO_DIR0); + reg |= GPIO_I2C_BITS; + bus_space_write_4(sc->sc_memt, sc->sc_regh, SM502_GPIO_DIR0, reg); + /* Fill in the i2c tag */ sc->sc_i2c.ic_cookie = sc; sc->sc_i2c.ic_acquire_bus = voyager_i2c_acquire_bus; @@ -266,11 +271,19 @@ static int voyager_i2c_read_byte(void *cookie, uint8_t *valp, int flags) { - return (i2c_bitbang_read_byte(cookie, valp, flags, &voyager_i2cbb_ops)); + int ret; + + ret = i2c_bitbang_read_byte(cookie, valp, flags, &voyager_i2cbb_ops); + return ret; } static int voyager_i2c_write_byte(void *cookie, uint8_t val, int flags) { - return (i2c_bitbang_write_byte(cookie, val, flags, &voyager_i2cbb_ops)); + int ret; + + ret = i2c_bitbang_write_byte(cookie, val, flags, &voyager_i2cbb_ops); + delay(500); + return ret; } +