Cannot get BCM94311MCG working against 2.6.24-rc5

2007-12-22 Thread sarcarsh
[I had sent this email a few minutes back from an unsubscribed id,
apologies if you are getting this twice]


Hello,

I am trying out Linux on my Dell D620 which has BCM94311MCG wlan card.

lspci gives:
0c:00.0 Network controller: Broadcom Corporation BCM94311MCG wlan
mini-PCI (rev 01)

I installed Ubuntu 7.10 and while this would not wor out-of-the-box,
with the help of the restricted-driver-manager my WLAN works fine with
the 2.6.22-14 stock kernel.

I downloaded and compiled the 2.6.24-rc5 kernel. The kernel compiled and
  I can boot into it and perform *most* operations. But my WLAN wont work.
I have been reading on the net and trying to form a picture of the
BCM43xx chipsets, their history of vendor-no-cooperation with Linux and
what people have done to bypass that.

My understanding is that this card has the BCM4311 chipset which is
supported directly by the kernel on the 2.6.24-rc line. I was expecting
this to be the case since I thought I compiled the kernel with the
BCM43xx options "on". Here's a snip:

[EMAIL PROTECTED]:~/fed$ grep BCM /boot/config-2.6.24-rc5
CONFIG_BT_HCIBCM203X=m
CONFIG_BCM43XX=m
CONFIG_BCM43XX_DEBUG=y
CONFIG_BCM43XX_DMA=y
CONFIG_BCM43XX_PIO=y
CONFIG_BCM43XX_DMA_AND_PIO_MODE=y
# CONFIG_BCM43XX_DMA_MODE is not set
# CONFIG_BCM43XX_PIO_MODE is not set
CONFIG_DVB_BCM3510=m

When I do an lsmod, I see..
[EMAIL PROTECTED]:~$ lsmod | grep -i bcm
bcm43xx   433312  0
ieee80211softmac   34944  1 bcm43xx
ieee80211  49900  2 bcm43xx,ieee80211softmac


I tried the ndiswrapper, by following the instructions on the Ubuntu
site (I even re-compiled ndiswrapper-1.51)
https://help.ubuntu.com/community/WifiDocs/Driver/bcm43xx/Feisty_No-Fluff#head-c8cbba1734885284e4f79c2054461c863169f1bf
but, no it won't work :-(


I found some good info on the Gnome Network-Manager list here:
http://www.nabble.com/My-Laptop-td14293457.html

So I tried unloading the bcm43xx module(s), and uninstall the XP driver
wrapped via ndiswrapper and then load b43 directly. But I get an error.

[EMAIL PROTECTED]:/home/shouryas# rmmod bcm43xx
[EMAIL PROTECTED]:/home/shouryas# ndiswrapper -l
bcmwl5 : driver installed
 device (14E4:4311) present (alternate driver: ssb)
[EMAIL PROTECTED]:/home/shouryas# ndiswrapper -e bcmwl5
[EMAIL PROTECTED]:/home/shouryas# ndiswrapper -l
[EMAIL PROTECTED]:/home/shouryas# modprobe b43
FATAL: Error inserting b43
(/lib/modules/2.6.24-rc5/kernel/drivers/net/wireless/b43/b43.ko):
Unknown symbol in module, or unknown parameter (see dmesg)
[EMAIL PROTECTED]:/home/shouryas# dmesg  /* giving the relvant snip here */
[ 6086.380829] b43: Unknown symbol ssb_bus_pcmciabus_register


--[At this point I apologize for this too-long email, I am trying to
make some headway myself and documenting my observations]--
I tried to see who should export the symbol ssb_bus_pcmciabus_register
Expectedly, no one does
[EMAIL PROTECTED]:/proc# cat kallsyms | grep pcmcia | grep ssb
yields nothing.

So, I tried to look into the source:
Around line 656 of /home/shouryas/kernels/my2.6/drivers/ssb/main.c
#ifdef CONFIG_SSB_PCMCIAHOST
int ssb_bus_pcmciabus_register(struct ssb_bus *bus,
struct pcmcia_device *pcmcia_dev,
unsigned long baseaddr)
{
 int err;

 bus->bustype = SSB_BUSTYPE_PCMCIA;
 bus->host_pcmcia = pcmcia_dev;
 bus->ops = &ssb_pcmcia_ops;

 err = ssb_bus_register(bus, ssb_pcmcia_get_invariants, baseaddr);
 if (!err) {
 ssb_printk(KERN_INFO PFX "Sonics Silicon Backplane
found on "
"PCMCIA device %s\n", pcmcia_dev->devname);
 }

 return err;
}
EXPORT_SYMBOL(ssb_bus_pcmciabus_register);
#endif /* CONFIG_SSB_PCMCIAHOST */

I looked into my config file to see if CONFIG_SSB_PCMCIAHOST is defined.
It is !
[EMAIL PROTECTED]:/proc# cat /boot/config | grep SSB
CONFIG_SSB_POSSIBLE=y
CONFIG_SSB=m
CONFIG_SSB_PCIHOST_POSSIBLE=y
CONFIG_SSB_PCIHOST=y
CONFIG_SSB_PCMCIAHOST_POSSIBLE=y
CONFIG_SSB_PCMCIAHOST=y
# CONFIG_SSB_SILENT is not set
# CONFIG_SSB_DEBUG is not set
CONFIG_SSB_DRIVER_PCICORE_POSSIBLE=y
CONFIG_SSB_DRIVER_PCICORE=y
# CONFIG_USB_OHCI_HCD_SSB is not set

Also, I looked into dmesg, and see the line
[   14.635610] ssb: Sonics Silicon Backplane found on PCI device
:0c:00.0

So, it seems that SSB_CONFIG_PCMCIA is defined (and no error in SSB 
detection hoepfully) but then why is the
symbol not exported ?


I would appreciate if you somebody could provide me some hints to where
to go and look for the problem. Maybe you can solve this immediately but
still I'd appreciate only hints so that I can play at least some part in
  resolving the situation.

I'd be happy to provide more info from my system.

Thanks and regards,
Shourya







___
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev


Re: Cannot get BCM94311MCG working against 2.6.24-rc5

2007-12-22 Thread Larry Finger
sarcarsh wrote:
> [I had sent this email a few minutes back from an unsubscribed id,
> apologies if you are getting this twice]
> 
> 
> Hello,
> 
> I am trying out Linux on my Dell D620 which has BCM94311MCG wlan card.
> 
> lspci gives:
> 0c:00.0 Network controller: Broadcom Corporation BCM94311MCG wlan
> mini-PCI (rev 01)
> 
> I installed Ubuntu 7.10 and while this would not wor out-of-the-box,
> with the help of the restricted-driver-manager my WLAN works fine with
> the 2.6.22-14 stock kernel.
> 
> I downloaded and compiled the 2.6.24-rc5 kernel. The kernel compiled and
>   I can boot into it and perform *most* operations. But my WLAN wont work.
> I have been reading on the net and trying to form a picture of the
> BCM43xx chipsets, their history of vendor-no-cooperation with Linux and
> what people have done to bypass that.
> 
> My understanding is that this card has the BCM4311 chipset which is
> supported directly by the kernel on the 2.6.24-rc line. I was expecting
> this to be the case since I thought I compiled the kernel with the
> BCM43xx options "on". Here's a snip:
> 
> [EMAIL PROTECTED]:~/fed$ grep BCM /boot/config-2.6.24-rc5
> CONFIG_BT_HCIBCM203X=m
> CONFIG_BCM43XX=m
> CONFIG_BCM43XX_DEBUG=y
> CONFIG_BCM43XX_DMA=y
> CONFIG_BCM43XX_PIO=y
> CONFIG_BCM43XX_DMA_AND_PIO_MODE=y
> # CONFIG_BCM43XX_DMA_MODE is not set
> # CONFIG_BCM43XX_PIO_MODE is not set
> CONFIG_DVB_BCM3510=m
> 
> When I do an lsmod, I see..
> [EMAIL PROTECTED]:~$ lsmod | grep -i bcm
> bcm43xx   433312  0
> ieee80211softmac   34944  1 bcm43xx
> ieee80211  49900  2 bcm43xx,ieee80211softmac
> 
> 
> I tried the ndiswrapper, by following the instructions on the Ubuntu
> site (I even re-compiled ndiswrapper-1.51)
> https://help.ubuntu.com/community/WifiDocs/Driver/bcm43xx/Feisty_No-Fluff#head-c8cbba1734885284e4f79c2054461c863169f1bf
> but, no it won't work :-(
> 
> 
> I found some good info on the Gnome Network-Manager list here:
> http://www.nabble.com/My-Laptop-td14293457.html
> 
> So I tried unloading the bcm43xx module(s), and uninstall the XP driver
> wrapped via ndiswrapper and then load b43 directly. But I get an error.
> 
> [EMAIL PROTECTED]:/home/shouryas# rmmod bcm43xx
> [EMAIL PROTECTED]:/home/shouryas# ndiswrapper -l
> bcmwl5 : driver installed
>  device (14E4:4311) present (alternate driver: ssb)
> [EMAIL PROTECTED]:/home/shouryas# ndiswrapper -e bcmwl5
> [EMAIL PROTECTED]:/home/shouryas# ndiswrapper -l
> [EMAIL PROTECTED]:/home/shouryas# modprobe b43
> FATAL: Error inserting b43
> (/lib/modules/2.6.24-rc5/kernel/drivers/net/wireless/b43/b43.ko):
> Unknown symbol in module, or unknown parameter (see dmesg)
> [EMAIL PROTECTED]:/home/shouryas# dmesg  /* giving the relvant snip here */
> [ 6086.380829] b43: Unknown symbol ssb_bus_pcmciabus_register
> 
> 
> --[At this point I apologize for this too-long email, I am trying to
> make some headway myself and documenting my observations]--
> I tried to see who should export the symbol ssb_bus_pcmciabus_register
> Expectedly, no one does
> [EMAIL PROTECTED]:/proc# cat kallsyms | grep pcmcia | grep ssb
> yields nothing.
> 
> So, I tried to look into the source:
> Around line 656 of /home/shouryas/kernels/my2.6/drivers/ssb/main.c
> #ifdef CONFIG_SSB_PCMCIAHOST
> int ssb_bus_pcmciabus_register(struct ssb_bus *bus,
> struct pcmcia_device *pcmcia_dev,
> unsigned long baseaddr)
> {
>  int err;
> 
>  bus->bustype = SSB_BUSTYPE_PCMCIA;
>  bus->host_pcmcia = pcmcia_dev;
>  bus->ops = &ssb_pcmcia_ops;
> 
>  err = ssb_bus_register(bus, ssb_pcmcia_get_invariants, baseaddr);
>  if (!err) {
>  ssb_printk(KERN_INFO PFX "Sonics Silicon Backplane
> found on "
> "PCMCIA device %s\n", pcmcia_dev->devname);
>  }
> 
>  return err;
> }
> EXPORT_SYMBOL(ssb_bus_pcmciabus_register);
> #endif /* CONFIG_SSB_PCMCIAHOST */
> 
> I looked into my config file to see if CONFIG_SSB_PCMCIAHOST is defined.
> It is !
> [EMAIL PROTECTED]:/proc# cat /boot/config | grep SSB
> CONFIG_SSB_POSSIBLE=y
> CONFIG_SSB=m
> CONFIG_SSB_PCIHOST_POSSIBLE=y
> CONFIG_SSB_PCIHOST=y
> CONFIG_SSB_PCMCIAHOST_POSSIBLE=y
> CONFIG_SSB_PCMCIAHOST=y
> # CONFIG_SSB_SILENT is not set
> # CONFIG_SSB_DEBUG is not set
> CONFIG_SSB_DRIVER_PCICORE_POSSIBLE=y
> CONFIG_SSB_DRIVER_PCICORE=y
> # CONFIG_USB_OHCI_HCD_SSB is not set
> 
> Also, I looked into dmesg, and see the line
> [   14.635610] ssb: Sonics Silicon Backplane found on PCI device
> :0c:00.0
> 
> So, it seems that SSB_CONFIG_PCMCIA is defined (and no error in SSB 
> detection hoepfully) but then why is the
> symbol not exported ?
> 
> 
> I would appreciate if you somebody could provide me some hints to where
> to go and look for the problem. Maybe you can solve this immediately but
> still I'd appreciate only hints so that I can play at least some part in
>   resolving the situation

[PATCH] ssb: Fix extraction of values from SPROM

2007-12-22 Thread Michael Buesch
This fixes extraction of some values from the SPROM.
It mainly fixes extraction of antenna related values, which
is needed for another b43 fix sent later.

Signed-off-by: Michael Buesch <[EMAIL PROTECTED]>

Index: wireless-2.6/drivers/ssb/pci.c
===
--- wireless-2.6.orig/drivers/ssb/pci.c 2007-12-14 13:15:42.0 +0100
+++ wireless-2.6/drivers/ssb/pci.c  2007-12-20 18:58:49.0 +0100
@@ -247,7 +247,7 @@ static void sprom_do_read(struct ssb_bus
int i;
 
for (i = 0; i < bus->sprom_size; i++)
-   sprom[i] = readw(bus->mmio + SSB_SPROM_BASE + (i * 2));
+   sprom[i] = ioread16(bus->mmio + SSB_SPROM_BASE + (i * 2));
 }
 
 static int sprom_do_write(struct ssb_bus *bus, const u16 *sprom)
@@ -297,10 +297,32 @@ err_ctlreg:
return err;
 }
 
+static s8 r123_extract_antgain(u8 sprom_revision, const u16 *in,
+  u16 mask, u16 shift)
+{
+   u16 v;
+   u8 gain;
+
+   v = in[SPOFF(SSB_SPROM1_AGAIN)];
+   gain = (v & mask) >> shift;
+   if (gain == 0xFF)
+   gain = 2; /* If unset use 2dBm */
+   if (sprom_revision == 1) {
+   /* Convert to Q5.2 */
+   gain <<= 2;
+   } else {
+   /* Q5.2 Fractional part is stored in 0xC0 */
+   gain = ((gain & 0xC0) >> 6) | ((gain & 0x3F) << 2);
+   }
+
+   return (s8)gain;
+}
+
 static void sprom_extract_r123(struct ssb_sprom *out, const u16 *in)
 {
int i;
u16 v;
+   s8 gain;
u16 loc[3];
 
if (out->revision == 3) {   /* rev 3 moved MAC */
@@ -327,8 +349,15 @@ static void sprom_extract_r123(struct ss
SPEX(et0phyaddr, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET0A, 0);
SPEX(et1phyaddr, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET1A,
 SSB_SPROM1_ETHPHY_ET1A_SHIFT);
+   SPEX(et0mdcport, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET0M, 14);
+   SPEX(et1mdcport, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET1M, 15);
+   SPEX(board_rev, SSB_SPROM1_BINF, SSB_SPROM1_BINF_BREV, 0);
SPEX(country_code, SSB_SPROM1_BINF, SSB_SPROM1_BINF_CCODE,
 SSB_SPROM1_BINF_CCODE_SHIFT);
+   SPEX(ant_available_a, SSB_SPROM1_BINF, SSB_SPROM1_BINF_ANTA,
+SSB_SPROM1_BINF_ANTA_SHIFT);
+   SPEX(ant_available_bg, SSB_SPROM1_BINF, SSB_SPROM1_BINF_ANTBG,
+SSB_SPROM1_BINF_ANTBG_SHIFT);
SPEX(pa0b0, SSB_SPROM1_PA0B0, 0x, 0);
SPEX(pa0b1, SSB_SPROM1_PA0B1, 0x, 0);
SPEX(pa0b2, SSB_SPROM1_PA0B2, 0x, 0);
@@ -348,9 +377,22 @@ static void sprom_extract_r123(struct ss
 SSB_SPROM1_ITSSI_A_SHIFT);
SPEX(itssi_bg, SSB_SPROM1_ITSSI, SSB_SPROM1_ITSSI_BG, 0);
SPEX(boardflags_lo, SSB_SPROM1_BFLLO, 0x, 0);
-   SPEX(antenna_gain_a, SSB_SPROM1_AGAIN, SSB_SPROM1_AGAIN_A, 0);
-   SPEX(antenna_gain_bg, SSB_SPROM1_AGAIN, SSB_SPROM1_AGAIN_BG,
-SSB_SPROM1_AGAIN_BG_SHIFT);
+
+   /* Extract the antenna gain values. */
+   gain = r123_extract_antgain(out->revision, in,
+   SSB_SPROM1_AGAIN_BG,
+   SSB_SPROM1_AGAIN_BG_SHIFT);
+   out->antenna_gain.ghz24.a0 = gain;
+   out->antenna_gain.ghz24.a1 = gain;
+   out->antenna_gain.ghz24.a2 = gain;
+   out->antenna_gain.ghz24.a3 = gain;
+   gain = r123_extract_antgain(out->revision, in,
+   SSB_SPROM1_AGAIN_A,
+   SSB_SPROM1_AGAIN_A_SHIFT);
+   out->antenna_gain.ghz5.a0 = gain;
+   out->antenna_gain.ghz5.a1 = gain;
+   out->antenna_gain.ghz5.a2 = gain;
+   out->antenna_gain.ghz5.a3 = gain;
 }
 
 static void sprom_extract_r4(struct ssb_sprom *out, const u16 *in)
@@ -376,9 +418,10 @@ static void sprom_extract_r4(struct ssb_
 SSB_SPROM4_ETHPHY_ET1A_SHIFT);
SPEX(country_code, SSB_SPROM4_CCODE, 0x, 0);
SPEX(boardflags_lo, SSB_SPROM4_BFLLO, 0x, 0);
-   SPEX(antenna_gain_a, SSB_SPROM4_AGAIN, SSB_SPROM4_AGAIN_0, 0);
-   SPEX(antenna_gain_bg, SSB_SPROM4_AGAIN, SSB_SPROM4_AGAIN_1,
-SSB_SPROM4_AGAIN_1_SHIFT);
+   SPEX(ant_available_a, SSB_SPROM4_ANTAVAIL, SSB_SPROM4_ANTAVAIL_A,
+SSB_SPROM4_ANTAVAIL_A_SHIFT);
+   SPEX(ant_available_bg, SSB_SPROM4_ANTAVAIL, SSB_SPROM4_ANTAVAIL_BG,
+SSB_SPROM4_ANTAVAIL_BG_SHIFT);
SPEX(maxpwr_bg, SSB_SPROM4_MAXP_BG, SSB_SPROM4_MAXP_BG_MASK, 0);
SPEX(itssi_bg, SSB_SPROM4_MAXP_BG, SSB_SPROM4_ITSSI_BG,
 SSB_SPROM4_ITSSI_BG_SHIFT);
@@ -391,6 +434,19 @@ static void sprom_extract_r4(struct ssb_
SPEX(gpio2, SSB_SPROM4_GPIOB, SSB_SPROM4_GPIOB_P2, 0);
SPEX(gpio3, SSB_SPROM4_GPIOB, SSB_SPROM4_GPIOB_P3,
 SSB_SPROM4_GPIOB_P3_SHIFT);
+
+   /* Extract the antenna gain values. */
+   SPEX(antenna_gain.ghz24.a0, SSB_SPROM4_AGAIN01,
+   

[PATCH] b43: Only select allowed TX and RX antennas

2007-12-22 Thread Michael Buesch
This fixes antenna selection in b43. It adds a sanity check
for the antenna numbers we get from mac80211.

This patch depends on
[PATCH] ssb: Fix extraction of values from SPROM

Signed-off-by: Michael Buesch <[EMAIL PROTECTED]>


Index: wireless-2.6/drivers/net/wireless/b43/main.c
===
--- wireless-2.6.orig/drivers/net/wireless/b43/main.c   2007-12-12 
19:55:48.0 +0100
+++ wireless-2.6/drivers/net/wireless/b43/main.c2007-12-12 
19:55:53.0 +0100
@@ -2692,8 +2692,36 @@ static int b43_switch_phymode(struct b43
return err;
 }
 
-static int b43_antenna_from_ieee80211(u8 antenna)
+/* Check if the use of the antenna that ieee80211 told us to
+ * use is possible. This will fall back to DEFAULT.
+ * "antenna_nr" is the antenna identifier we got from ieee80211. */
+u8 b43_ieee80211_antenna_sanitize(struct b43_wldev *dev,
+ u8 antenna_nr)
+{
+   u8 antenna_mask;
+
+   if (antenna_nr == 0) {
+   /* Zero means "use default antenna". That's always OK. */
+   return 0;
+   }
+
+   /* Get the mask of available antennas. */
+   if (dev->phy.gmode)
+   antenna_mask = dev->dev->bus->sprom.ant_available_bg;
+   else
+   antenna_mask = dev->dev->bus->sprom.ant_available_a;
+
+   if (!(antenna_mask & (1 << (antenna_nr - 1 {
+   /* This antenna is not available. Fall back to default. */
+   return 0;
+   }
+
+   return antenna_nr;
+}
+
+static int b43_antenna_from_ieee80211(struct b43_wldev *dev, u8 antenna)
 {
+   antenna = b43_ieee80211_antenna_sanitize(dev, antenna);
switch (antenna) {
case 0: /* default/diversity */
return B43_ANTENNA_DEFAULT;
@@ -2713,14 +2741,10 @@ static int b43_op_config(struct ieee8021
struct b43_phy *phy;
unsigned long flags;
unsigned int new_phymode = 0x;
-   int antenna_tx;
-   int antenna_rx;
+   int antenna;
int err = 0;
u32 savedirqs;
 
-   antenna_tx = b43_antenna_from_ieee80211(conf->antenna_sel_tx);
-   antenna_rx = b43_antenna_from_ieee80211(conf->antenna_sel_rx);
-
mutex_lock(&wl->mutex);
 
/* Switch the PHY mode (if necessary). */
@@ -2781,8 +2805,10 @@ static int b43_op_config(struct ieee8021
}
 
/* Antennas for RX and management frame TX. */
-   b43_mgmtframe_txantenna(dev, antenna_tx);
-   b43_set_rx_antenna(dev, antenna_rx);
+   antenna = b43_antenna_from_ieee80211(dev, conf->antenna_sel_tx);
+   b43_mgmtframe_txantenna(dev, antenna);
+   antenna = b43_antenna_from_ieee80211(dev, conf->antenna_sel_rx);
+   b43_set_rx_antenna(dev, antenna);
 
/* Update templates for AP mode. */
if (b43_is_mode(wl, IEEE80211_IF_TYPE_AP))
Index: wireless-2.6/drivers/net/wireless/b43/main.h
===
--- wireless-2.6.orig/drivers/net/wireless/b43/main.h   2007-12-12 
18:29:32.0 +0100
+++ wireless-2.6/drivers/net/wireless/b43/main.h2007-12-12 
19:55:53.0 +0100
@@ -96,6 +96,9 @@ static inline int b43_is_ofdm_rate(int r
return !b43_is_cck_rate(rate);
 }
 
+u8 b43_ieee80211_antenna_sanitize(struct b43_wldev *dev,
+ u8 antenna_nr);
+
 void b43_tsf_read(struct b43_wldev *dev, u64 * tsf);
 void b43_tsf_write(struct b43_wldev *dev, u64 tsf);
 
Index: wireless-2.6/drivers/net/wireless/b43/xmit.c
===
--- wireless-2.6.orig/drivers/net/wireless/b43/xmit.c   2007-12-12 
18:29:32.0 +0100
+++ wireless-2.6/drivers/net/wireless/b43/xmit.c2007-12-12 
19:55:53.0 +0100
@@ -270,14 +270,15 @@ static void generate_txhdr_fw4(struct b4
phy_ctl |= B43_TX4_PHY_OFDM;
if (dev->short_preamble)
phy_ctl |= B43_TX4_PHY_SHORTPRMBL;
-   switch (txctl->antenna_sel_tx) {
-   case 0:
+
+   switch (b43_ieee80211_antenna_sanitize(dev, txctl->antenna_sel_tx)) {
+   case 0: /* Default */
phy_ctl |= B43_TX4_PHY_ANTLAST;
break;
-   case 1:
+   case 1: /* Antenna 0 */
phy_ctl |= B43_TX4_PHY_ANT0;
break;
-   case 2:
+   case 2: /* Antenna 1 */
phy_ctl |= B43_TX4_PHY_ANT1;
break;
default:
___
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev


[PATCH] b43: Fix chip access validation for new devices

2007-12-22 Thread Michael Buesch
This fixes chip access validation for newer devices
(4318 and up, I think)

This patch fixes probing of a PCMCIA based 4318 device.

Signed-off-by: Michael Buesch <[EMAIL PROTECTED]>

Index: wireless-2.6/drivers/net/wireless/b43/b43.h
===
--- wireless-2.6.orig/drivers/net/wireless/b43/b43.h2007-12-12 
19:54:27.0 +0100
+++ wireless-2.6/drivers/net/wireless/b43/b43.h 2007-12-12 19:55:57.0 
+0100
@@ -50,6 +50,9 @@
 #define B43_MMIO_XMITSTAT_10x174
 #define B43_MMIO_REV3PLUS_TSF_LOW  0x180   /* core rev >= 3 only */
 #define B43_MMIO_REV3PLUS_TSF_HIGH 0x184   /* core rev >= 3 only */
+#define B43_MMIO_TSF_CFP_REP   0x188
+#define B43_MMIO_TSF_CFP_START 0x18C
+#define B43_MMIO_TSF_CFP_MAXDUR0x190
 
 /* 32-bit DMA */
 #define B43_MMIO_DMA32_BASE0   0x200
@@ -88,6 +91,8 @@
 #define B43_MMIO_RADIO_HWENABLED_LO0x49A
 #define B43_MMIO_GPIO_CONTROL  0x49C
 #define B43_MMIO_GPIO_MASK 0x49E
+#define B43_MMIO_TSF_CFP_START_LOW 0x604
+#define B43_MMIO_TSF_CFP_START_HIGH0x606
 #define B43_MMIO_TSF_0 0x632   /* core rev < 3 only */
 #define B43_MMIO_TSF_1 0x634   /* core rev < 3 only */
 #define B43_MMIO_TSF_2 0x636   /* core rev < 3 only */
Index: wireless-2.6/drivers/net/wireless/b43/main.c
===
--- wireless-2.6.orig/drivers/net/wireless/b43/main.c   2007-12-12 
19:55:53.0 +0100
+++ wireless-2.6/drivers/net/wireless/b43/main.c2007-12-12 
19:55:57.0 +0100
@@ -2408,32 +2408,42 @@ static void b43_periodic_tasks_setup(str
queue_delayed_work(dev->wl->hw->workqueue, work, 0);
 }
 
-/* Validate access to the chip (SHM) */
+/* Check if communication with the device works correctly. */
 static int b43_validate_chipaccess(struct b43_wldev *dev)
 {
-   u32 value;
-   u32 shm_backup;
+   u32 v, backup;
 
-   shm_backup = b43_shm_read32(dev, B43_SHM_SHARED, 0);
-   b43_shm_write32(dev, B43_SHM_SHARED, 0, 0xAAAA);
-   if (b43_shm_read32(dev, B43_SHM_SHARED, 0) != 0xAAAA)
-   goto error;
+   backup = b43_shm_read32(dev, B43_SHM_SHARED, 0);
+
+   /* Check for read/write and endianness problems. */
b43_shm_write32(dev, B43_SHM_SHARED, 0, 0x5555);
if (b43_shm_read32(dev, B43_SHM_SHARED, 0) != 0x5555)
goto error;
-   b43_shm_write32(dev, B43_SHM_SHARED, 0, shm_backup);
-
-   value = b43_read32(dev, B43_MMIO_MACCTL);
-   if ((value | B43_MACCTL_GMODE) !=
-   (B43_MACCTL_GMODE | B43_MACCTL_IHR_ENABLED))
+   b43_shm_write32(dev, B43_SHM_SHARED, 0, 0xAAAA);
+   if (b43_shm_read32(dev, B43_SHM_SHARED, 0) != 0xAAAA)
goto error;
 
-   value = b43_read32(dev, B43_MMIO_GEN_IRQ_REASON);
-   if (value)
+   b43_shm_write32(dev, B43_SHM_SHARED, 0, backup);
+
+   if ((dev->dev->id.revision >= 3) && (dev->dev->id.revision <= 10)) {
+   /* The 32bit register shadows the two 16bit registers
+* with update sideeffects. Validate this. */
+   b43_write16(dev, B43_MMIO_TSF_CFP_START, 0x);
+   b43_write32(dev, B43_MMIO_TSF_CFP_START, 0x);
+   if (b43_read16(dev, B43_MMIO_TSF_CFP_START_LOW) != 0x)
+   goto error;
+   if (b43_read16(dev, B43_MMIO_TSF_CFP_START_HIGH) != 0x)
+   goto error;
+   }
+   b43_write32(dev, B43_MMIO_TSF_CFP_START, 0);
+
+   v = b43_read32(dev, B43_MMIO_MACCTL);
+   v |= B43_MACCTL_GMODE;
+   if (v != (B43_MACCTL_GMODE | B43_MACCTL_IHR_ENABLED))
goto error;
 
return 0;
-  error:
+error:
b43err(dev->wl, "Failed to validate the chipaccess\n");
return -ENODEV;
 }
___
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev


[PATCH] ssb: Fix PCMCIA lowlevel register access

2007-12-22 Thread Michael Buesch
This fixes lowlevel register access for PCMCIA based devices.

The patch also adds a temporary workaround for the device mac address.
It simply adds generation of a random address. The real SPROM extraction
will follow in another patch.
The temporary workaround will be removed then, but for now it's OK.

Signed-off-by: Michael Buesch <[EMAIL PROTECTED]>

Index: wireless-2.6/drivers/ssb/pcmcia.c
===
--- wireless-2.6.orig/drivers/ssb/pcmcia.c  2007-12-09 21:33:20.0 
+0100
+++ wireless-2.6/drivers/ssb/pcmcia.c   2007-12-09 22:16:59.0 +0100
@@ -94,7 +94,6 @@ int ssb_pcmcia_switch_core(struct ssb_bu
   struct ssb_device *dev)
 {
int err;
-   unsigned long flags;
 
 #if SSB_VERBOSE_PCMCIACORESWITCH_DEBUG
ssb_printk(KERN_INFO PFX
@@ -103,11 +102,9 @@ int ssb_pcmcia_switch_core(struct ssb_bu
   dev->core_index);
 #endif
 
-   spin_lock_irqsave(&bus->bar_lock, flags);
err = ssb_pcmcia_switch_coreidx(bus, dev->core_index);
if (!err)
bus->mapped_device = dev;
-   spin_unlock_irqrestore(&bus->bar_lock, flags);
 
return err;
 }
@@ -115,14 +112,12 @@ int ssb_pcmcia_switch_core(struct ssb_bu
 int ssb_pcmcia_switch_segment(struct ssb_bus *bus, u8 seg)
 {
int attempts = 0;
-   unsigned long flags;
conf_reg_t reg;
-   int res, err = 0;
+   int res;
 
SSB_WARN_ON((seg != 0) && (seg != 1));
reg.Offset = 0x34;
reg.Function = 0;
-   spin_lock_irqsave(&bus->bar_lock, flags);
while (1) {
reg.Action = CS_WRITE;
reg.Value = seg;
@@ -143,13 +138,11 @@ int ssb_pcmcia_switch_segment(struct ssb
udelay(10);
}
bus->mapped_pcmcia_seg = seg;
-out_unlock:
-   spin_unlock_irqrestore(&bus->bar_lock, flags);
-   return err;
+
+   return 0;
 error:
ssb_printk(KERN_ERR PFX "Failed to switch pcmcia segment\n");
-   err = -ENODEV;
-   goto out_unlock;
+   return -ENODEV;
 }
 
 static int select_core_and_segment(struct ssb_device *dev,
@@ -182,22 +175,33 @@ static int select_core_and_segment(struc
 static u16 ssb_pcmcia_read16(struct ssb_device *dev, u16 offset)
 {
struct ssb_bus *bus = dev->bus;
+   unsigned long flags;
+   int err;
+   u16 value = 0x;
 
-   if (unlikely(select_core_and_segment(dev, &offset)))
-   return 0x;
+   spin_lock_irqsave(&bus->bar_lock, flags);
+   err = select_core_and_segment(dev, &offset);
+   if (likely(!err))
+   value = readw(bus->mmio + offset);
+   spin_unlock_irqrestore(&bus->bar_lock, flags);
 
-   return readw(bus->mmio + offset);
+   return value;
 }
 
 static u32 ssb_pcmcia_read32(struct ssb_device *dev, u16 offset)
 {
struct ssb_bus *bus = dev->bus;
-   u32 lo, hi;
+   unsigned long flags;
+   int err;
+   u32 lo = 0x, hi = 0x;
 
-   if (unlikely(select_core_and_segment(dev, &offset)))
-   return 0x;
-   lo = readw(bus->mmio + offset);
-   hi = readw(bus->mmio + offset + 2);
+   spin_lock_irqsave(&bus->bar_lock, flags);
+   err = select_core_and_segment(dev, &offset);
+   if (likely(!err)) {
+   lo = readw(bus->mmio + offset);
+   hi = readw(bus->mmio + offset + 2);
+   }
+   spin_unlock_irqrestore(&bus->bar_lock, flags);
 
return (lo | (hi << 16));
 }
@@ -205,22 +209,31 @@ static u32 ssb_pcmcia_read32(struct ssb_
 static void ssb_pcmcia_write16(struct ssb_device *dev, u16 offset, u16 value)
 {
struct ssb_bus *bus = dev->bus;
+   unsigned long flags;
+   int err;
 
-   if (unlikely(select_core_and_segment(dev, &offset)))
-   return;
-   writew(value, bus->mmio + offset);
+   spin_lock_irqsave(&bus->bar_lock, flags);
+   err = select_core_and_segment(dev, &offset);
+   if (likely(!err))
+   writew(value, bus->mmio + offset);
+   mmiowb();
+   spin_unlock_irqrestore(&bus->bar_lock, flags);
 }
 
 static void ssb_pcmcia_write32(struct ssb_device *dev, u16 offset, u32 value)
 {
struct ssb_bus *bus = dev->bus;
+   unsigned long flags;
+   int err;
 
-   if (unlikely(select_core_and_segment(dev, &offset)))
-   return;
-   writeb((value & 0xFF00) >> 24, bus->mmio + offset + 3);
-   writeb((value & 0x00FF) >> 16, bus->mmio + offset + 2);
-   writeb((value & 0xFF00) >> 8, bus->mmio + offset + 1);
-   writeb((value & 0x00FF) >> 0, bus->mmio + offset + 0);
+   spin_lock_irqsave(&bus->bar_lock, flags);
+   err = select_core_and_segment(dev, &offset);
+   if (likely(!err)) {
+   writew((value & 0x), bus->mmio + offset);
+   writew(((value & 0x) >> 16), bus->mmio + offset + 2);
+   }
+   m

Re: [PATCH] b43: Only select allowed TX and RX antennas

2007-12-22 Thread Michael Buesch
On Saturday 22 December 2007 22:55:38 Larry Finger wrote:
> Michael Buesch wrote:
> > This fixes antenna selection in b43. It adds a sanity check
> > for the antenna numbers we get from mac80211.
> > 
> > This patch depends on
> > [PATCH] ssb: Fix extraction of values from SPROM
> > 
> > Signed-off-by: Michael Buesch <[EMAIL PROTECTED]>
> 
> After applying the 4 patches you sent earlier, the compilation fails with
> 
>   CC [M]  drivers/ssb/main.o
> drivers/net/wireless/b43/main.c: In function ‘b43_ieee80211_antenna_sanitize’:
> drivers/net/wireless/b43/main.c:2720: error: ‘struct ssb_sprom’ has no member 
> named ‘ant_available_bg’
> drivers/net/wireless/b43/main.c:2722: error: ‘struct ssb_sprom’ has no member 
> named ‘ant_available_a’
> 
> These members of ssb_sprom are defined in the patch you sent to Felix Fietkau 
> on Dec. 10, but not in
> this patch set.

This patch was included in the series I just sent.
[PATCH] ssb: Fix extraction of values from SPROM

> Index: wireless-2.6/include/linux/ssb/ssb.h
> ===
> --- wireless-2.6.orig/include/linux/ssb/ssb.h   2007-12-14
> 13:15:42.0 +0100 +++ wireless-2.6/include/linux/ssb/ssb.h   
> 2007-12-20 18:58:49.0 +0100 @@ -22,7 +22,12 @@ struct ssb_sprom {
> u8 et1mac[6];   /* MAC address for 802.11a */
> u8 et0phyaddr;  /* MII address for enet0 */
> u8 et1phyaddr;  /* MII address for enet1 */
> +   u8 et0mdcport;  /* MDIO for enet0 */
> +   u8 et1mdcport;  /* MDIO for enet1 */
> +   u8 board_rev;   /* Board revision number from SPROM. */
> u8 country_code;/* Country Code */
> +   u8 ant_available_a; /* A-PHY antenna available bits (up to 4)
> +   u8 ant_available_bg;/* B/G-PHY antenna available bits (up to

-- 
Greetings Michael.
___
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev


Re: [PATCH] b43: Only select allowed TX and RX antennas

2007-12-22 Thread Larry Finger
Michael Buesch wrote:
> This fixes antenna selection in b43. It adds a sanity check
> for the antenna numbers we get from mac80211.
> 
> This patch depends on
> [PATCH] ssb: Fix extraction of values from SPROM
> 
> Signed-off-by: Michael Buesch <[EMAIL PROTECTED]>

After applying the 4 patches you sent earlier, the compilation fails with

  CC [M]  drivers/ssb/main.o
drivers/net/wireless/b43/main.c: In function ‘b43_ieee80211_antenna_sanitize’:
drivers/net/wireless/b43/main.c:2720: error: ‘struct ssb_sprom’ has no member 
named ‘ant_available_bg’
drivers/net/wireless/b43/main.c:2722: error: ‘struct ssb_sprom’ has no member 
named ‘ant_available_a’

These members of ssb_sprom are defined in the patch you sent to Felix Fietkau 
on Dec. 10, but not in
this patch set.

Larry

___
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev


Re: [PATCH] b43: Only select allowed TX and RX antennas

2007-12-22 Thread Larry Finger
Larry Finger wrote:
> Michael Buesch wrote:
>> This fixes antenna selection in b43. It adds a sanity check
>> for the antenna numbers we get from mac80211.
>>
>> This patch depends on
>> [PATCH] ssb: Fix extraction of values from SPROM
>>
>> Signed-off-by: Michael Buesch <[EMAIL PROTECTED]>
> 
> After applying the 4 patches you sent earlier, the compilation fails with
> 
>   CC [M]  drivers/ssb/main.o
> drivers/net/wireless/b43/main.c: In function ‘b43_ieee80211_antenna_sanitize’:
> drivers/net/wireless/b43/main.c:2720: error: ‘struct ssb_sprom’ has no member 
> named ‘ant_available_bg’
> drivers/net/wireless/b43/main.c:2722: error: ‘struct ssb_sprom’ has no member 
> named ‘ant_available_a’
> 
> These members of ssb_sprom are defined in the patch you sent to Felix Fietkau 
> on Dec. 10, but not in
> this patch set.
> 
> Larry

Please ignore the noise in this message. I had mangled the first patch in the 
series of four. It now
compiles and I am about to start testing.

Larry
___
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev


Last 4 patches from Michael

2007-12-22 Thread Jory A. Pratt
I have just tested the last four patches from Michael. Compilation is
fine and no regressions that I have seen as of yet. My 4306 and 4318 are
working just fine with the changes.

-Jory
___
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev


Re: [PATCH] b43: Only select allowed TX and RX antennas

2007-12-22 Thread Stefano Brivio
On Sat, 22 Dec 2007 21:54:20 +0100
Michael Buesch <[EMAIL PROTECTED]> wrote:

> This fixes antenna selection in b43. It adds a sanity check
> for the antenna numbers we get from mac80211.

Just FYI. I'm going to port this patch to b43legacy, as soon as I figure
out exactly the differences between v3 and v4 firmware devices here.


-- 
Ciao
Stefano
___
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev


Re: Cannot get BCM94311MCG working against 2.6.24-rc5

2007-12-22 Thread Shourya Sarcar
Larry Finger wrote:
> 
> You are making a number of mistakes. The biggest one is to try to use bcm43xx 
> or b43 with
> ndiswrapper. THEY ARE MUTUALLY EXCLUSIVE. If you want to use ndiswrapper, 
> then we cannot help you.

Thanks, got it ! I am focussing on getting b43 support now. ndiswrapper 
is not wrapping anything now.

> 
> A second minor mistake is to try to use bcm43xx when b43 is available. The 
> actual hardware handling
> is not that different; however, the MAC implementation in b43 (mac80211) is 
> vastly superior to that
> in bcm43xx (SoftMAC).

Thanks for pointing out. Only b43 from now !

> 
> Please rebuild your 2.6.24-rc5 with bcm43xx disabled, but with ssb, mac80211 
> and b43 enabled. Please
> enable ssb and b43 debugging. 

Did this and compiled 2.6.24-rc5 kernel cleanly. Rebooted.

After the new kernel is built, installed and booted, check the output
> of the following commands:
> 
> iwconfig
> ifconfig

[EMAIL PROTECTED]:~$ iwconfig
lono wireless extensions.

eth0  no wireless extensions.


> 
> If ifconfig does not show eth1 or wlan1 (whatever your device is named) to be 
> UP, then issue an
> 'ifup eth1' command, then

[EMAIL PROTECTED]:/home/shouryas# ifup eth1
Ignoring unknown interface eth1=eth1.
(Same for wlan0, wlan1)


> 
> dmesg | grep ssb
> dmesg | grep b43
> 
> Fix whatever problems that you can, then post the output of the last two.

[EMAIL PROTECTED]:/home/shouryas# dmesg | grep "ssb\|b43"
[   43.324090] ssb: Sonics Silicon Backplane found on PCI device 
:0c:00.0
[   53.899968] b43: disagrees about version of symbol ssb_device_is_enabled
[   53.899974] b43: Unknown symbol ssb_device_is_enabled
[   53.900126] b43: disagrees about version of symbol 
ssb_pcicore_dev_irqvecs_enable
[   53.900129] b43: Unknown symbol ssb_pcicore_dev_irqvecs_enable
[   53.900214] b43: disagrees about version of symbol ssb_bus_may_powerdown
[   53.900216] b43: Unknown symbol ssb_bus_may_powerdown
[   53.900500] b43: disagrees about version of symbol ssb_bus_unregister
[   53.900502] b43: Unknown symbol ssb_bus_unregister
[   53.900661] b43: disagrees about version of symbol ssb_set_devtypedata
[   53.900663] b43: Unknown symbol ssb_set_devtypedata
[   53.900850] b43: disagrees about version of symbol ssb_device_disable
[   53.900852] b43: Unknown symbol ssb_device_disable
[   53.901030] b43: disagrees about version of symbol ssb_dma_set_mask
[   53.901032] b43: Unknown symbol ssb_dma_set_mask
[   53.901320] b43: disagrees about version of symbol ssb_device_enable
[   53.901322] b43: Unknown symbol ssb_device_enable
[   53.901437] b43: disagrees about version of symbol ssb_driver_unregister
[   53.901439] b43: Unknown symbol ssb_driver_unregister
[   53.901577] b43: disagrees about version of symbol __ssb_driver_register
[   53.901579] b43: Unknown symbol __ssb_driver_register
[   53.901809] b43: Unknown symbol ssb_bus_pcmciabus_register
[   53.901891] b43: disagrees about version of symbol ssb_bus_powerup
[   53.901893] b43: Unknown symbol ssb_bus_powerup
[   53.902404] b43: disagrees about version of symbol ssb_dma_translation
[   53.902406] b43: Unknown symbol ssb_dma_translation


To confirm, I am building the 2.6.24-rc5 kernel and booting into the same.

> 
> Larry
> 

Some pointers appreciated.

Thanks in advance,
Shourya
___
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev


Re: Cannot get BCM94311MCG working against 2.6.24-rc5

2007-12-22 Thread Larry Finger
Shourya Sarcar wrote:
> 
> [EMAIL PROTECTED]:/home/shouryas# dmesg | grep "ssb\|b43"
> [   43.324090] ssb: Sonics Silicon Backplane found on PCI device
> :0c:00.0
> [   53.899968] b43: disagrees about version of symbol ssb_device_is_enabled
> [   53.899974] b43: Unknown symbol ssb_device_is_enabled
> [   53.900126] b43: disagrees about version of symbol
> ssb_pcicore_dev_irqvecs_enable
> [   53.900129] b43: Unknown symbol ssb_pcicore_dev_irqvecs_enable
> [   53.900214] b43: disagrees about version of symbol ssb_bus_may_powerdown
> [   53.900216] b43: Unknown symbol ssb_bus_may_powerdown
> [   53.900500] b43: disagrees about version of symbol ssb_bus_unregister
> [   53.900502] b43: Unknown symbol ssb_bus_unregister
> [   53.900661] b43: disagrees about version of symbol ssb_set_devtypedata
> [   53.900663] b43: Unknown symbol ssb_set_devtypedata
> [   53.900850] b43: disagrees about version of symbol ssb_device_disable
> [   53.900852] b43: Unknown symbol ssb_device_disable
> [   53.901030] b43: disagrees about version of symbol ssb_dma_set_mask
> [   53.901032] b43: Unknown symbol ssb_dma_set_mask
> [   53.901320] b43: disagrees about version of symbol ssb_device_enable
> [   53.901322] b43: Unknown symbol ssb_device_enable
> [   53.901437] b43: disagrees about version of symbol ssb_driver_unregister
> [   53.901439] b43: Unknown symbol ssb_driver_unregister
> [   53.901577] b43: disagrees about version of symbol __ssb_driver_register
> [   53.901579] b43: Unknown symbol __ssb_driver_register
> [   53.901809] b43: Unknown symbol ssb_bus_pcmciabus_register
> [   53.901891] b43: disagrees about version of symbol ssb_bus_powerup
> [   53.901893] b43: Unknown symbol ssb_bus_powerup
> [   53.902404] b43: disagrees about version of symbol ssb_dma_translation
> [   53.902406] b43: Unknown symbol ssb_dma_translation
> 
> 
> To confirm, I am building the 2.6.24-rc5 kernel and booting into the same.

I'm not sure about the problem, but something has gone wrong with your kernel 
build and/or the
install. After the 'make' step finished, did you issue a 'sudo make 
modules_install install'? If
not, that could make the symbol versions disagree.

Larry
___
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev