Index: linux/drivers/net/wireless/Kconfig
===================================================================
--- linux.orig/drivers/net/wireless/Kconfig	2007-12-05 19:53:08.000000000 +0100
+++ linux/drivers/net/wireless/Kconfig	2007-12-05 19:53:19.000000000 +0100
@@ -400,6 +400,19 @@
 	  The digi_wi_g driver is compiled with debugging support.
           Only the driver maintainer may need to enable it.
 
+choice
+	prompt "UBEC Transceiver Revision"
+	depends on DIGI_WI_G
+	default DIGI_WI_G_UBEC_JD
+
+config DIGI_WI_G_UBEC_JD
+	bool "UBEC Revision JD"
+
+config DIGI_WI_G_UBEC_HC
+	bool "UBEC Revision HC"
+
+endchoice
+
 # If Pcmcia is compiled in, offer Pcmcia cards...
 comment "Wireless 802.11b Pcmcia/Cardbus cards support"
 	depends on NET_RADIO && PCMCIA
Index: linux/drivers/net/wireless/digi_wi_g.c
===================================================================
--- linux.orig/drivers/net/wireless/digi_wi_g.c	2007-12-05 19:53:09.000000000 +0100
+++ linux/drivers/net/wireless/digi_wi_g.c	2007-12-05 19:53:29.000000000 +0100
@@ -9,7 +9,7 @@
  *  the Free Software Foundation.
 */
 /*
- *  !Revision:   $Revision: 1.130 $
+ *  !Revision:   $Revision: 1.135 $
  *  !Author:     Bernd Westermann/Markus Pietrek
  *  !Descr:      
  *  !References: [1] 802.11G_Programming_Guide_1.0
@@ -194,7 +194,7 @@
 # include <asm/arch-ns9xxx/ns9xxx_hperf.h>
 
 /* only in debug case we are interested in revision */
-# define REVISION " $Revision: 1.130 $"
+# define REVISION " $Revision: 1.135 $"
 #else /* CONFIG_DIGI_WI_G_DEBUG */
 # define DBG(      flag, format, ... ) do {} while( 0 )
 # define DBG_FN(   flag )              do {} while( 0 )
@@ -369,6 +369,28 @@
 };
 
 /* RF transceiver frequency divider for each channel */
+#if defined(CONFIG_DIGI_WI_G_UBEC_JD)
+static const struct {
+	u16 integer;
+	u16 fraction;
+} freq_table[] = {
+	{ 0, 0 },
+	{ 0x6847, 0x0999 }, /* 1 (2412 MHz) */
+	{ 0x6847, 0x099b }, /* 2 (2417 MHz) */
+	{ 0x6867, 0x0998 }, /* 3 */
+	{ 0x6867, 0x099a }, /* 4 */
+	{ 0x6867, 0x0999 }, /* 5 */
+	{ 0x6867, 0x099b }, /* 6 */
+	{ 0x6857, 0x0998 }, /* 7 */
+	{ 0x6857, 0x099a }, /* 8 */
+	{ 0x6857, 0x0999 }, /* 9 */
+	{ 0x6857, 0x099b }, /* 10 */
+	{ 0x6877, 0x0998 }, /* 11 */
+	{ 0x6877, 0x099a }, /* 12 */
+	{ 0x6877, 0x0999 }, /* 13 (2472 MHz) */
+	{ 0x684f, 0x0ccc }, /* 14 (2484 MHz) */
+};
+#elif defined(CONFIG_DIGI_WI_G_UBEC_HC)
 static const struct {
 	u16 integer;
 	u16 fraction;
@@ -389,7 +411,7 @@
 	{ 0x04f7, 0x0999 }, /* 13 (2472 MHz) */
 	{ 0x04cf, 0x0ccc }, /* 14 (2484 MHz) */
 };
-
+#endif
 /* see [2] 10.4.42. */
 static const u8 dw_rates[ RATES_SUPPORTED ] = {
         BASIC_RATE( IEEE80211_CCK_RATE_1MB ),
@@ -441,6 +463,12 @@
 static unsigned int dw_sw_aes  = DW_SW_AES_DEFAULT;
 static unsigned int dw_cfg_vco = 0;  /* use built-in */
 
+/* Tables for the conversion of the signal strenght to dBm */
+/* Map LNA value to gain value */
+static const unsigned char lnatable[] =	{0, 0, 23, 39};
+/* Map high gain values to dBm */
+static const char gaintable[] = {-82, -84, -85, -86, -87, -89, -90, -92, -94, -98};
+
 /* ********** Local Functions ********** */
 
 /* ********** inline stuff ********** */
@@ -517,7 +545,7 @@
 
 static inline void dw_hw_write_rf( u8 addr, u32 data )
 {
-	dw_iowrite32( ( ( (u32) addr ) << 20 ) | data, HW_SPI );
+	dw_iowrite32( ( ( (u32) addr ) << 20 ) | data, HW_SPI_DATA );
 
 	udelay(10);
 }
@@ -749,8 +777,11 @@
         u32 vco = dw_cfg_vco;
         
         if( !vco )
+#if defined(CONFIG_DIGI_WI_G_UBEC_JD)
+		vco = 0x46662;
+#elif defined(CONFIG_DIGI_WI_G_UBEC_HC)
                 vco = 0x3020;
-        
+#endif
         dw_hw_write_rf( 3, vco );
 }
 
@@ -1246,6 +1277,7 @@
 static void dw_rx_frame_give_to_stack( dw_priv_t* priv, dw_frame_rx_t* frame )
 {
         static struct ieee80211_rx_stats stats;
+	int gain; /* For received signal strength to dBm conversion */
         
         DBG_FN( DBG_RX | DBG_MAJOR );
         DBG_MARK( RX_FRAME_TO_STACK );
@@ -1272,16 +1304,31 @@
         stats.len  = frame->skb->len;
 
 
-        /* taken from Net+OS:mac_hw_wi9c:HandleIR
-           Max RSSI is 92 when LNA=1 and VGA=0 */
-        stats.rssi   = MAC_RSSI_MAX -
-                15 * ( frame->hdr.mod.rssi_lna - 1 ) -
-                2 * ( frame->hdr.mod.rssi_vga );
-
-        /* we don't have noise or signal in dB. RSSI is used only internally to
-         * determine best network and not reported back. Therefore, we provide
-         * signal == rssi and provide it as strength */
-        stats.signal = stats.rssi;
+	/* Convert received signal strength to dBm */
+	gain = lnatable[frame->hdr.mod.rssi_lna] + 2 * frame->hdr.mod.rssi_vga;
+	if (gain > 96)
+		stats.signal = -98;
+	else if (gain > 86)
+		stats.signal = gaintable[gain-87];
+	else
+		stats.signal = 5 - gain;
+
+	/* RSSI is used only internally to determine best network and not reported back */
+
+        /* RSSI (Received Signal Strength Indication) is a measurement of the
+         * power present in a received radio signal. In an IEEE 802.11 system
+         * RSSI is the received signal strength in a wireless environment, in
+         * arbitrary units. RSSI measurements will vary from 0 to 255 depending
+         * on the vendor. It consists of a one byte integer value. A value of 1
+         * will indicate the minimum signal strength detectable by the wireless
+         * card, while 0 indicates no signal. The value has a maximum of
+         * RSSI_Max. - http://en.wikipedia.org/wiki/RSSI
+         *
+         * See also: http://www.ces.clemson.edu/linux/dbm-rssi.shtml
+         */
+	stats.rssi   = MAC_RSSI_MAX
+		       - 15 * ( frame->hdr.mod.rssi_lna - 1 )
+		       - 2 * ( frame->hdr.mod.rssi_vga );
 
         /* we don't know it here, but ieee80211 stack will look into it with
            our patch in ieee80211_rx.c before
@@ -1464,11 +1511,11 @@
                     case IEEE80211_FTYPE_MGMT:  /* no break */
                     case IEEE80211_FTYPE_DATA:
                         break;
-                    case IEEE80211_FTYPE_CTL:   /* no break */
 
+                    case IEEE80211_FTYPE_CTL:   /* no break */
                     default:
                         ignore = 1;
-                        return;
+                        break;
                 }
 
 		if( !ignore &&
@@ -1903,11 +1950,11 @@
         }
         /* sent frame, either bye AES or unencrypted engine */
         if( !frame->s.use_hw_encryption ) { 
-                dw_iowrite32( hw_gen_ctrl, HW_GEN_CONTROL );
-                /* we are not interrupted. Tx starts immediately when writing
-                 * to FIFO. */
+		/* Prevent transmitting until all data have been written into the tx fifo */
+                dw_iowrite32( hw_gen_ctrl | GEN_TXHOLD, HW_GEN_CONTROL );
                 dw_hw_write_fifo( &frag->hdr, sizeof( frag->hdr ) );
                 dw_hw_write_fifo( skb->data,  skb->len );
+		dw_iowrite32( hw_gen_ctrl, HW_GEN_CONTROL );
         } else {
                 ccmp_data_t cdata;
                 u8          extiv[ EXTIV_SIZE ];
@@ -2370,6 +2417,7 @@
 	unsigned long flags;
         u32 firmware_id;
         u32 ctrl;
+	u32 mac_status;
         
         DBG_FN( DBG_INIT );
         
@@ -2414,6 +2462,17 @@
 	dw_hw_memcpy_from( dev->dev_addr, HW_STAID0, ETH_ALEN );
 
 	/* Initialize RF tranceiver */
+#if defined(CONFIG_DIGI_WI_G_UBEC_JD)
+	dw_hw_write_rf( 7, 0x27ffe ); /* TEST register */
+	dw_hw_write_rf( 6, 0xf81ac ); /* Filter Register */
+	dw_hw_write_rf( 5, 0x19e4f ); /* Transmitter Gain */
+	dw_hw_write_rf( 4, 0x0002b ); /* Receiver Gain */
+	
+	dw_hw_set_vco( 0 );     /* no channel selected yet */
+	
+	dw_hw_write_rf( 0, 0x25f9c ); /* Mode Control - Calibrate Filter */
+	udelay( 10 );
+#elif defined(CONFIG_DIGI_WI_G_UBEC_HC)
         dw_hw_set_vco( 0 );     /* no channel selected yet */
         dw_hw_write_rf( 4, 0x0007b ); /* Receiver Gain */
         dw_hw_write_rf( 5, 0x09ee0 ); /* Transmitter Gain */
@@ -2423,11 +2482,15 @@
 	dw_hw_write_rf( 0, 0x27fdc ); /* Mode Control - Calibrate Filter */
 	udelay( 10 );
 	dw_hw_write_rf( 0, 0x27fd4 ); /* Mode Control - RX/TX mode */
+#endif
 
 	/* Firmware version */
 	firmware_id = dw_ioread32( HW_VERSION );
-	printk( KERN_DEBUG DRIVER_NAME ": FPGA version: %i.%02i\n",
-                ( firmware_id >> 8 ) & 0xff, firmware_id & 0xff );
+	mac_status = dw_ioread32( HW_MAC_STATUS );
+	printk( KERN_DEBUG DRIVER_NAME ": FPGA  HW version: %i.%02i  FW Version: %i.%02i\n",
+		( firmware_id >> 8 ) & 0xff, firmware_id & 0xff,
+		( mac_status >> 24 ) & 0xff, (mac_status >> 16) & 0xff );
+
 	dw_unlock(priv, flags);
 
 	return 1;
@@ -3311,10 +3374,26 @@
         
 	dw_rmw32( HW_GEN_CONTROL, & ~GEN_RXEN );
 
+
 	/* Set frequency divider for channel */
 	dw_hw_write_rf (1, freq_table[channel].integer);
 	dw_hw_write_rf (2, freq_table[channel].fraction);
 
+#if defined(CONFIG_DIGI_WI_G_UBEC_JD)
+	/* Filter  calibration */
+	dw_hw_write_rf (0, 0x25f9c);
+	udelay (10);
+	
+	/* VCO calibration */
+	dw_hw_write_rf (0, 0x25f9a);
+	udelay (80);
+	
+	/* Mode Control - RX/TX mode */
+	dw_hw_write_rf (0, 0x25f94); 
+	
+	/* Allow the trannsceiver to settle in the new mode of operation */
+	udelay (10); 
+#elif defined(CONFIG_DIGI_WI_G_UBEC_HC)
 	/* VCO Calibration */
 	dw_hw_write_rf (0, 0x27fda); 
 	udelay(40);
@@ -3327,12 +3406,11 @@
 	dw_hw_write_rf (0, 0x27fd4); 
 
         dw_hw_set_vco( channel );
-
+#endif
 	priv->channel = channel;
 	dw_rmw32( HW_GEN_CONTROL, | GEN_RXEN );
 }
 
-
 /***********************************************************************
  * @Function: dw_softmac_set_chan
  * @Return:
@@ -4362,7 +4440,7 @@
         
         DBG_FN( DBG_INIT );
 
-	printk( KERN_NOTICE "%s\n", dw_version );
+	printk( KERN_INFO "%s\n", dw_version );
 
         if( dw_sw_aes )
                 printk( KERN_NOTICE "AES encoding/decoding is done in software\n" );
Index: linux/drivers/net/wireless/digi_wi_g.h
===================================================================
--- linux.orig/drivers/net/wireless/digi_wi_g.h	2007-12-05 19:53:09.000000000 +0100
+++ linux/drivers/net/wireless/digi_wi_g.h	2007-12-05 19:53:33.000000000 +0100
@@ -3,7 +3,7 @@
  *
  * Support for DIGI Wireless Module.
  *
- * $Id: digi_wi_g.h,v 1.55 2007-06-04 08:17:31 mpietrek Exp $
+ * $Id: digi_wi_g.h,v 1.56 2007/11/22 18:22:09 jviguera Exp $
  * @Author: Bernd Westermann
  * @References: [1] NET+OS code mac_hw_wi9c.c
  *
@@ -54,7 +54,7 @@
 #define	MANAGEMENT_JIFFIES	 ( ( MANAGEMENT_TIME_MS * HZ ) / 1000 )
 /* update rate only every 500ms */
 #define MANAGEMENT_TICKS_FOR_UPDATE ( 500 / MANAGEMENT_TIME_MS )
-#define TX_TIMEOUT		(5 * HZ)
+#define TX_TIMEOUT		(HZ/2)
 /* Min/max successful intervals to increase rate */
 #define	THRESH_MIN		1
 #define	THRESH_MAX		10
@@ -108,8 +108,8 @@
 #define	HW_RSSI_AES		(0x0c)	/* RSSI and AES status */
 #define	HW_INTR_MASK		(0x10)	/* Interrupt mask */
 #define	HW_INTR_STATUS		(0x14)	/* Interrupt status */
-#define	HW_SPI			(0x18)	/* RF SPI interface */
-#define HW_BOOTMUX      	(0x1c)	/* Bootmux? */
+#define	HW_SPI_DATA		(0x18)	/* RF SPI data register */
+#define	HW_SPI_CONTROL		(0x1c)	/* RF SPI control register */
 #define	HW_DATA_FIFO		(0x20)	/* Data FIFO */
 #define	HW_AES_FIFO		(0x30)	/* AES FIFO */
 #define	HW_AES_MODE		(0x38)	/* AES mode */
@@ -147,7 +147,13 @@
 #define	GEN_TXFIFOEMPTY	0x00004000	/* Transmit FIFO empty */
 #define	GEN_TXFIFOFULL	0x00008000	/* Transmit FIFO full */
 
+#if defined(CONFIG_DIGI_WI_G_UBEC_JD)
+# define GEN_INIT	0x377a0000	/* Initial state */
+#elif defined(CONFIG_DIGI_WI_G_UBEC_HC)
 #define	GEN_INIT	0x37700000	/* Initial state */
+#else
+# error "You need to choose an UBEC Transceiver Revision"
+#endif
 
 /* General status register bits */
 #define	STAT_RXFE	0x00000010	/* Receive FIFO empty */
