Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci add a function to mess with gpios which locks ag...



details:   https://anonhg.NetBSD.org/src/rev/4c14842a95ab
branches:  trunk
changeset: 769298:4c14842a95ab
user:      macallan <macallan%NetBSD.org@localhost>
date:      Tue Sep 06 06:26:13 2011 +0000

description:
add a function to mess with gpios which locks against the i2c stuff

diffstat:

 sys/dev/pci/voyager.c    |  21 ++++++++++++++++++---
 sys/dev/pci/voyagervar.h |   8 +++++---
 2 files changed, 23 insertions(+), 6 deletions(-)

diffs (76 lines):

diff -r fbc167f8fc79 -r 4c14842a95ab sys/dev/pci/voyager.c
--- a/sys/dev/pci/voyager.c     Tue Sep 06 03:31:37 2011 +0000
+++ b/sys/dev/pci/voyager.c     Tue Sep 06 06:26:13 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: voyager.c,v 1.3 2011/09/01 14:04:55 macallan Exp $     */
+/*     $NetBSD: voyager.c,v 1.4 2011/09/06 06:26:13 macallan Exp $     */
 
 /*
  * Copyright (c) 2009, 2011 Michael Lorenz
@@ -26,7 +26,7 @@
  */
  
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: voyager.c,v 1.3 2011/09/01 14:04:55 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: voyager.c,v 1.4 2011/09/06 06:26:13 macallan Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -162,7 +162,7 @@
                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;
@@ -287,3 +287,18 @@
        return ret;
 }
 
+/* gpio stuff */
+void
+voyager_write_gpio(void *cookie, uint32_t mask, uint32_t bits)
+{
+       struct voyager_softc *sc = cookie;
+       uint32_t reg;
+
+       /* don't interfere with i2c ops */
+       mutex_enter(&sc->sc_i2c_lock);
+       reg = bus_space_read_4(sc->sc_memt, sc->sc_regh, SM502_GPIO_DATA0);
+       reg &= mask;
+       reg |= bits;
+       bus_space_write_4(sc->sc_memt, sc->sc_regh, SM502_GPIO_DATA0, reg);
+       mutex_exit(&sc->sc_i2c_lock);
+}
diff -r fbc167f8fc79 -r 4c14842a95ab sys/dev/pci/voyagervar.h
--- a/sys/dev/pci/voyagervar.h  Tue Sep 06 03:31:37 2011 +0000
+++ b/sys/dev/pci/voyagervar.h  Tue Sep 06 06:26:13 2011 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: voyagervar.h,v 1.1 2011/08/31 16:47:31 macallan Exp $  */
+/*     $NetBSD: voyagervar.h,v 1.2 2011/09/06 06:26:13 macallan Exp $  */
 
 /*
- * Copyright (c) 2009 Michael Lorenz
+ * Copyright (c) 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: voyagervar.h,v 1.1 2011/08/31 16:47:31 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: voyagervar.h,v 1.2 2011/09/06 06:26:13 macallan Exp $");
 
 #ifndef VOYAGERVAR_H
 #define VOYAGERVAR_H
@@ -42,4 +42,6 @@
        char                    vaa_name[32];
 };
 
+void voyager_write_gpio(void *, uint32_t, uint32_t);
+
 #endif
\ No newline at end of file



Home | Main Index | Thread Index | Old Index