diff -urN --exclude=CVS uisp/src/DAPA.C uisp-stargate/src/DAPA.C
--- uisp/src/DAPA.C	2007-04-11 16:48:13.000000000 +0200
+++ uisp-stargate/src/DAPA.C	2007-04-11 16:47:48.000000000 +0200
@@ -168,6 +168,10 @@
 #include "DAPA.h"
 #include "Avr.h"
 
+/* Get handle on the stargate GPIO port access class global object. */
+#include "SGGPIO.h"
+extern SGGPIO_PORT SGport;
+
 /* Parallel Port Base Address
 */
 #define IOBASE parport_base
@@ -318,6 +322,13 @@
 #define DM04_DIN    PARPORT_STATUS_PAPEROUT   /* Data IN */
 #define DM04_DOUT   PARPORT_CONTROL_INIT      /* Data OUT */
 
+/* Intel Stargate GPIO interface to Berkeley motes */
+#define SGGPIO_DIN   26
+#define SGGPIO_DOUT  25
+#define SGGPIO_SCK   23
+#define SGGPIO_RESET 77
+#define SGGPIO_MUX   22
+
 /* Default value for minimum SCK high/low time in microseconds.  */
 #ifndef SCK_DELAY
 #define SCK_DELAY 5
@@ -505,6 +516,10 @@
   case PAT_DM04:
     break;
 
+  case PAT_SGGPIO:
+    SGport.setPin(SGGPIO_RESET, b);
+    break;
+
   case PAT_DASA:
 #ifdef TIOCMGET
     SerialReadCtrl();
@@ -600,6 +615,10 @@
     ParportWriteData();
     break;
 
+  case PAT_SGGPIO:
+    SGport.setPin(SGGPIO_SCK, b);
+    break;
+
   case PAT_DASA:
 #if defined(TIOCMGET)
     SerialReadCtrl();
@@ -724,6 +743,10 @@
     }
     break;
 
+  case PAT_SGGPIO:
+    SGport.setDir(SGGPIO_RESET, 1);
+    break;
+
   case PAT_DASA:
   case PAT_DASA2:
   case PAT_DASA3:
@@ -744,6 +767,10 @@
     ParportWriteData();
     break;
 
+  case PAT_SGGPIO:
+    SGport.setDir(SGGPIO_SCK, 1);
+    break;
+
   case PAT_DAPA:
   case PAT_ABB:
   case PAT_ATDH:
@@ -849,6 +876,10 @@
     ParportWriteCtrl();
     break;
 
+  case PAT_SGGPIO:
+    SGport.setPin(SGGPIO_DOUT, b);
+    break;
+
   case PAT_DASA:
 #if defined(TIOCMGET) && defined(TIOCCBRK)
     ioctl(ppdev_fd, b ? TIOCSBRK : TIOCCBRK, 0);
@@ -906,6 +937,9 @@
     ParportReadStatus();
     b = (par_status & DM04_DIN);
     break;
+  case PAT_SGGPIO:
+    b = SGport.readPin(SGGPIO_DIN);
+    break;
   case PAT_DASA:
   case PAT_DASA2:
   case PAT_DASA3:
@@ -993,6 +1027,24 @@
     }
     break;
 
+  case PAT_SGGPIO:
+    /* Get the proc files open */
+    (void) SGport.readGPIO(PXA_GPLR, 0);
+    (void) SGport.readGPIO(PXA_GPDR, 0);
+    (void) SGport.readGPIO(PXA_GPSR, 0);
+    (void) SGport.readGPIO(PXA_GPCR, 0);
+    (void) SGport.readGPIO(PXA_GPDR, 2);
+    (void) SGport.readGPIO(PXA_GPSR, 2);
+    (void) SGport.readGPIO(PXA_GPCR, 2);
+    /* Set initial output state; others are set below */
+    SGport.setPin(SGGPIO_DOUT, 0);
+    SGport.setPin(SGGPIO_MUX, 0);
+    /* Set pin directions; others are set below */
+    SGport.setDir(SGGPIO_DOUT, 1);
+    SGport.setDir(SGGPIO_DIN, 0);
+    SGport.setDir(SGGPIO_MUX, 1);
+    break;
+
   case PAT_DASA:
   case PAT_DASA2:
   case PAT_DASA3:
@@ -1117,6 +1169,8 @@
     pa_type = PAT_MAXI;
   else if (val && strcmp(val, "xil") == 0)
     pa_type = PAT_XIL;
+  else if (val && strcmp(val, "sggpio") == 0)
+    pa_type = PAT_SGGPIO;
   else if (val && strcmp(val, "dasa") == 0)
     pa_type = PAT_DASA;
   else if (val && strcmp(val, "dasa2") == 0)
@@ -1156,7 +1210,7 @@
   else if ((val = GetCmdParam("-dserial")) != NULL) {
       ppdev_name = val;
   }
-  if (!ppdev_name && !pa_type_is_serial) {
+  if (!ppdev_name && !pa_type_is_serial && !(pa_type = PAT_SGGPIO)) {
     if (parport_base!=0x278 && parport_base!=0x378 && parport_base!=0x3bc) {
       /* TODO: option to override this if you really know
 	 what you're doing (only if running as root).  */
@@ -1182,7 +1236,7 @@
   }
 #endif
 
-  if (ppdev_name) {
+  if (ppdev_name && (pa_type != PAT_SGGPIO)) {
     if (pa_type_is_serial) {
       ppdev_fd = open(ppdev_name, O_RDWR | O_NOCTTY | O_NONBLOCK);
       if (ppdev_fd != -1) {
@@ -1270,6 +1324,10 @@
   OutReset(1);
   OutEnaReset(0);
 
+  if (pa_type == PAT_SGGPIO) {
+    SGport.setPin(SGGPIO_MUX, 1);
+  }
+
   if (ppdev_fd != -1) {
     if (pa_type_is_serial)
       tcsetattr(ppdev_fd, TCSADRAIN, &saved_modes);
diff -urN --exclude=CVS uisp/src/DAPA.h uisp-stargate/src/DAPA.h
--- uisp/src/DAPA.h	2007-04-11 16:48:13.000000000 +0200
+++ uisp-stargate/src/DAPA.h	2007-04-11 16:47:48.000000000 +0200
@@ -45,7 +45,7 @@
 public:
   enum TPaType{	PAT_DAPA, PAT_STK200, PAT_ABB, PAT_ATDH, PAT_PARAVRISP, 
 		PAT_BSD, PAT_FBPRG, PAT_DT006, PAT_ETT, PAT_MAXI, PAT_XIL,
-		PAT_DASA, PAT_DASA2, PAT_DASA3, PAT_DM04 };
+		 PAT_SGGPIO, PAT_DASA, PAT_DASA2, PAT_DASA3, PAT_DM04 };
 
 private:
   int mosi_invert;
diff -urN --exclude=CVS uisp/src/Main.C uisp-stargate/src/Main.C
--- uisp/src/Main.C	2007-04-11 16:48:13.000000000 +0200
+++ uisp-stargate/src/Main.C	2007-04-11 16:47:48.000000000 +0200
@@ -40,6 +40,7 @@
 #include "MotIntl.h"
 #include "AvrAtmel.h"
 #include "Stk500.h"
+#include "SGGPIO.h"
 #ifndef NO_DAPA
 # include "AvrDummy.h"
 #endif
@@ -55,6 +56,7 @@
 PDevice device;
 TMotIntl motintl;
 TTerminal terminal;
+SGGPIO_PORT SGport;
 
 const char* version = "uisp version %s\n"
 "(C) 1997-1999 Uros Platise, 2000-2003 Marek Michalkiewicz\n"
@@ -101,6 +103,7 @@
 "         xil       Xilinx HW-JTAG-PC Cable (parallel)\n"
 "         ett       ETT AVR Programmer V2.0 [from Futurlec] (parallel)\n"
 "         dm04      Datamekatronik 2004 (parallel)\n"
+"         sggpio    Stargate direct GPIO access (for Berkeley Motes)\n"
 "         dasa      serial (RESET=RTS SCK=DTR MOSI=TXD MISO=CTS)\n"
 "         dasa2     serial (RESET=!TXD SCK=RTS MOSI=DTR MISO=CTS)\n"
 "         dasa3     serial (RESET=!DTR SCK=RTS MOSI=TXD MISO=CTS)\n"
diff -urN --exclude=CVS uisp/src/Makefile.am uisp-stargate/src/Makefile.am
--- uisp/src/Makefile.am	2007-04-11 16:48:13.000000000 +0200
+++ uisp-stargate/src/Makefile.am	2007-04-11 16:47:48.000000000 +0200
@@ -50,6 +50,8 @@
 	MotIntl.h          \
 	Serial.C           \
 	Serial.h           \
+	SGGPIO.C           \
+	SGGPIO.h           \
 	Stk500.C           \
 	Stk500.h           \
 	Terminal.C         \
diff -urN --exclude=CVS uisp/src/SGGPIO.C uisp-stargate/src/SGGPIO.C
--- uisp/src/SGGPIO.C	1970-01-01 01:00:00.000000000 +0100
+++ uisp-stargate/src/SGGPIO.C	2007-04-11 16:47:48.000000000 +0200
@@ -0,0 +1,153 @@
+/*
+ * $Id:$
+ *
+ ****************************************************************************
+ *
+ * uisp - The Micro In-System Programmer for Atmel AVR microcontrollers.
+ * Copyright (C) 2003 University of Utah and The Flux Group
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ ****************************************************************************
+ */
+
+/*
+  SGGPIO.C
+  
+  Direct Stargate/PXA GPIO Access
+  
+*/
+
+
+#include "SGGPIO.h"
+
+char *pxa_reg_names[] = {"GPLR", "GPDR", "GPSR", "GPCR"};
+
+int 
+SGGPIO_PORT::setDir(int pin, unsigned int indir) {
+  
+  unsigned int val = readGPIO(PXA_GPDR, GPIO_nr(pin));
+  
+  if (indir) {
+    val = val | GPIO_bit(pin);
+  } else {
+    val = val & ~(GPIO_bit(pin));
+  }
+  
+  writeGPIO(PXA_GPDR, GPIO_nr(pin), val);
+  
+  return 0;
+}
+
+int 
+SGGPIO_PORT::setPin(int pin, unsigned int inval) {
+  if (inval) {
+    writeGPIO(PXA_GPSR, GPIO_nr(pin), GPIO_bit(pin));
+  } else {
+    writeGPIO(PXA_GPCR, GPIO_nr(pin), GPIO_bit(pin));
+  }
+  return 0;
+}
+
+int 
+SGGPIO_PORT::readPin(int pin) {
+  return ((readGPIO(PXA_GPLR, GPIO_nr(pin)) & GPIO_bit(pin)) >> (0x1f & pin));
+}
+
+unsigned int 
+SGGPIO_PORT::readGPIO(PXA_REG reg,  int regnum) {
+  int fdesc = getGPIO(reg, regnum);
+  char buf[16];
+  int cnt = 0;
+  unsigned int retval = 0;
+  
+  if (! fdesc) {
+    printf("Couldn't get GPIO handle\n");
+    return 0;
+  }
+
+  if ((cnt = pread(fdesc, buf, sizeof(buf)-1, 0)) <= 0) {
+    printf("Error reading GPIO register\n");
+    return 0;
+  }
+  
+  buf[cnt] = '\0';
+  retval = strtoul(buf, NULL, 0);
+  return retval;
+}
+
+int 
+SGGPIO_PORT::writeGPIO(PXA_REG reg, int regnum, unsigned int value) {
+  int fdesc = getGPIO(reg, regnum);
+  char buf[16];
+  int len;
+  
+  if (! fdesc) {
+    printf("Couldn't get GPIO handle\n");
+    return -1;
+  }
+  
+  len = sprintf(buf, "0x%08X\n", value);
+  
+  if (pwrite(fdesc, buf, len, 0) < 0) {
+    perror("Problem setting GPIO register");
+    printf("Register: %s%d\n", PXA_REG_NAME(reg), regnum);
+    printf("fdesc: %d\n", fdesc);
+    printf("Data: %s\n", buf);
+    return -1;
+  }
+
+  return 0;
+}
+
+SGGPIO_PORT::SGGPIO_PORT() {
+  int i, j;
+  
+  for (i = 0; i < NUM_REGS; ++i) {
+    for (j = 0; j < NUM_REGNUMS; ++j) {
+      GPIO_fds[i][j] = 0;
+    }
+  }
+}
+
+SGGPIO_PORT::~SGGPIO_PORT() {
+  int i, j;
+
+  for (i = 0; i < NUM_REGS; ++i) {
+    for (j = 0; j < NUM_REGNUMS; ++j) {
+      if (GPIO_fds[i][j]) {
+        close(GPIO_fds[i][j]);
+        GPIO_fds[i][j] = 0;
+      }
+    }
+  }
+}
+
+
+int 
+SGGPIO_PORT::getGPIO(PXA_REG reg, int regnum) {
+  char gpioPath[256];
+  
+  if (! GPIO_fds[reg][regnum]) {
+    sprintf(gpioPath, "%s/%s%d", PROC_REG_PREFIX, PXA_REG_NAME(reg), regnum);
+    if ((GPIO_fds[reg][regnum] = open(gpioPath, O_RDWR | O_FSYNC, 0)) < 0) {
+      printf("Error opening %s proc file: %s\n", PXA_REG_NAME(reg), 
+             strerror(errno));
+      return -1;
+    }
+  }
+  
+  return GPIO_fds[reg][regnum];
+}
diff -urN --exclude=CVS uisp/src/SGGPIO.h uisp-stargate/src/SGGPIO.h
--- uisp/src/SGGPIO.h	1970-01-01 01:00:00.000000000 +0100
+++ uisp-stargate/src/SGGPIO.h	2007-04-11 16:47:48.000000000 +0200
@@ -0,0 +1,83 @@
+/*
+ * $Id:$
+ *
+ ****************************************************************************
+ *
+ * uisp - The Micro In-System Programmer for Atmel AVR microcontrollers.
+ * Copyright (C) 2003 University of Utah and The Flux Group
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ ****************************************************************************
+ */
+
+/*
+  SGGPIO.h
+  
+  Direct Stargate/PXA GPIO Access
+  
+*/
+
+#ifndef __SGGPIO_H
+#define __SGGPIO_H
+
+#include <stdlib.h>
+#include <sys/types.h>
+#include <termios.h>
+#include <time.h>
+#include <unistd.h>
+#include <string.h>
+#include <fcntl.h>
+#include <errno.h>
+#include "Error.h"
+
+#define GPIO_bit(x)	(1 << ((x) & 0x1f))
+#define GPIO_nr(x)      ((x) >> 5)
+
+enum PXA_REG {
+  PXA_GPLR = 0,
+  PXA_GPDR = 1,
+  PXA_GPSR = 2,
+  PXA_GPCR = 3
+};
+#define NUM_REGS 4
+#define NUM_REGNUMS 3
+
+extern char *pxa_reg_names[];
+
+#define PXA_REG_NAME(reg) pxa_reg_names[(reg)]
+
+//#define PROC_REG_PREFIX "/proc/cpu/registers"
+#define PROC_REG_PREFIX "/proc/platx/registers"
+
+class SGGPIO_PORT {
+
+public:
+
+  int setDir(int pin, unsigned int indir);
+  int setPin(int pin, unsigned int inval);
+  int readPin(int pin);
+  unsigned int readGPIO(PXA_REG reg,  int regnum);
+  int writeGPIO(PXA_REG reg, int regnum, unsigned int value);
+  SGGPIO_PORT();
+  ~SGGPIO_PORT();
+
+private:
+
+  int getGPIO(PXA_REG reg, int regnum);
+  int GPIO_fds[NUM_REGS][NUM_REGNUMS];
+};
+
+#endif /* __SGGPIO_H */
