Skip to contentSkip to conversation

rtl8187: Modify rfkill for new models

PATCH In review Larry Finger 3 participants 4 messages Dec 5, 2009 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 rtl8187: Modify rfkill for new models

There are different bits used to convey the setting of the rfkill switch to the driver. The current driver only supports one of these possibilities. These changes were derived from the latest version of the vendor driver.

This patch fixes the regression noted in Bug #14xxx.

---

drivers/net/wireless/rtl818x/rtl8187.h +5 -0
Index: wireless-testing/drivers/net/wireless/rtl818x/rtl8187.h
===================================================================
@@ -23,6 +23,7 @@
 #define RTL8187_EEPROM_TXPWR_CHAN_1	0x16	/* 3 channels */
 #define RTL8187_EEPROM_TXPWR_CHAN_6	0x1B	/* 2 channels */
 #define RTL8187_EEPROM_TXPWR_CHAN_4	0x3D	/* 2 channels */
+#define RTL8187_EEPROM_SELECT_GPIO	0x3B	/* Which pin has rfkill? */
 
 #define RTL8187_REQT_READ	0xC0
 #define RTL8187_REQT_WRITE	0x40
@@ -31,6 +32,9 @@
 
 #define RTL8187_MAX_RX		0x9C4
 
+#define RFKILL_MASK_8187_89_97	0x2
+#define RFKILL_MASK_8198	0x4
+
 struct rtl8187_rx_info {
 	struct urb *urb;
 	struct ieee80211_hw *dev;
@@ -122,6 +126,7 @@ struct rtl8187_priv {
 	u8 noise;
 	u8 slot_time;
 	u8 aifsn[4];
+	u8 rfkill_mask;
 	struct {
 		__le64 buf;
 		struct sk_buff_head queue;
drivers/net/wireless/rtl818x/rtl8187_dev.c +10 -0
Index: wireless-testing/drivers/net/wireless/rtl818x/rtl8187_dev.c
===================================================================
@@ -1322,6 +1322,7 @@ static int __devinit rtl8187_probe(struc
 	struct ieee80211_channel *channel;
 	const char *chip_name;
 	u16 txpwr, reg;
+	u16 product_id = le16_to_cpu(udev->descriptor.idProduct);
 	int err, i;
 
 	dev = ieee80211_alloc_hw(sizeof(*priv), &rtl8187_ops);
@@ -1481,6 +1482,15 @@ static int __devinit rtl8187_probe(struc
 		(*channel++).hw_value = txpwr & 0xFF;
 		(*channel++).hw_value = txpwr >> 8;
 	}
+	/* Handle the differing GPIO bit in different models */
+	priv->rfkill_mask = RFKILL_MASK_8187_89_97;
+	if (product_id == 0x8197 || product_id == 0x8198) {
+		eeprom_93cx6_read(&eeprom, RTL8187_EEPROM_SELECT_GPIO, &reg);
+		if (reg & 0xFF00)
+			priv->rfkill_mask = RFKILL_MASK_8198;
+	}
+	printk(KERN_INFO "rtl8187: rfkill mask set to %d for Product ID 0x%x",
+	       priv->rfkill_mask, product_id);
 
 	/*
 	 * XXX: Once this driver supports anything that requires
drivers/net/wireless/rtl818x/rtl8187_rfkill.c +2 -2
Index: wireless-testing/drivers/net/wireless/rtl818x/rtl8187_rfkill.c
===================================================================
@@ -25,10 +25,10 @@ static bool rtl8187_is_radio_enabled(str
 	u8 gpio;
 
 	gpio = rtl818x_ioread8(priv, &priv->map->GPIO0);
-	rtl818x_iowrite8(priv, &priv->map->GPIO0, gpio & ~0x02);
+	rtl818x_iowrite8(priv, &priv->map->GPIO0, gpio & ~priv->rfkill_mask);
 	gpio = rtl818x_ioread8(priv, &priv->map->GPIO1);
 
-	return gpio & 0x02;
+	return gpio & priv->rfkill_mask;
 }
 
 void rtl8187_rfkill_init(struct ieee80211_hw *hw)
#1 lore raw
Quoted 58 lines · Larry Finger

There are different bits used to convey the setting of the rfkill switch to the driver. The current driver only supports one of these possibilities. These changes were derived from the latest version of the vendor driver.

This patch fixes the regression noted in Bug #14xxx.

---

Index: wireless-testing/drivers/net/wireless/rtl818x/rtl8187.h
===================================================================

drivers/net/wireless/rtl818x/rtl8187.h +5 -0
@@ -23,6 +23,7 @@
  #define RTL8187_EEPROM_TXPWR_CHAN_1    0x16    /* 3 channels */
  #define RTL8187_EEPROM_TXPWR_CHAN_6    0x1B    /* 2 channels */
  #define RTL8187_EEPROM_TXPWR_CHAN_4    0x3D    /* 2 channels */
+#define RTL8187_EEPROM_SELECT_GPIO     0x3B    /* Which pin has rfkill? */
 
  #define RTL8187_REQT_READ      0xC0
  #define RTL8187_REQT_WRITE     0x40
@@ -31,6 +32,9 @@
 
  #define RTL8187_MAX_RX         0x9C4
 
+#define RFKILL_MASK_8187_89_97 0x2
+#define RFKILL_MASK_8198       0x4
+
  struct rtl8187_rx_info {
        struct urb *urb;
        struct ieee80211_hw *dev;
@@ -122,6 +126,7 @@ struct rtl8187_priv {
        u8 noise;
        u8 slot_time;
        u8 aifsn[4];
+       u8 rfkill_mask;
        struct {
                __le64 buf;
                struct sk_buff_head queue;

Index: wireless-testing/drivers/net/wireless/rtl818x/rtl8187_dev.c
===================================================================

drivers/net/wireless/rtl818x/rtl8187_dev.c +1 -0
@@ -1322,6 +1322,7 @@ static int __devinit rtl8187_probe(struc
        struct ieee80211_channel *channel;
        const char *chip_name;
        u16 txpwr, reg;
+       u16 product_id = le16_to_cpu(udev->descriptor.idProduct);
        int err, i;
 
        dev = ieee80211_alloc_hw(sizeof(*priv), &rtl8187_ops);
@@ -1481,6 +1482,15 @@ static int __devinit rtl8187_probe(struc
                (*channel++).hw_value = txpwr & 0xFF;
                (*channel++).hw_value = txpwr >> 8;

drivers/net/wireless/rtl818x/rtl8187_dev.c static int __devinit rtl8187_probe(struc · line 1493

Quoted 10 lines
drivers/net/wireless/rtl818x/rtl8187_dev.c +9 -0
        }
+       /* Handle the differing GPIO bit in different models */
+       priv->rfkill_mask = RFKILL_MASK_8187_89_97;
+       if (product_id == 0x8197 || product_id == 0x8198) {
+               eeprom_93cx6_read(&eeprom, RTL8187_EEPROM_SELECT_GPIO, &reg);
+               if (reg & 0xFF00)
+                       priv->rfkill_mask = RFKILL_MASK_8198;
+       }
+       printk(KERN_INFO "rtl8187: rfkill mask set to %d for Product ID 0x%x",
+              priv->rfkill_mask, product_id);

printk(KERN_DEBUG... ?

Quoted 25 lines
drivers/net/wireless/rtl818x/rtl8187_dev.c +0 -0
        /*
         * XXX: Once this driver supports anything that requires

Index: wireless-testing/drivers/net/wireless/rtl818x/rtl8187_rfkill.c
===================================================================

drivers/net/wireless/rtl818x/rtl8187_rfkill.c +2 -3
@@ -25,10 +25,10 @@ static bool rtl8187_is_radio_enabled(str
        u8 gpio;
 
        gpio = rtl818x_ioread8(priv, &priv->map->GPIO0);
-       rtl818x_iowrite8(priv, &priv->map->GPIO0, gpio & ~0x02);
+       rtl818x_iowrite8(priv, &priv->map->GPIO0, gpio & ~priv->rfkill_mask);
        gpio = rtl818x_ioread8(priv, &priv->map->GPIO1);
 
-       return gpio & 0x02;
+       return gpio & priv->rfkill_mask;
  }
 
  void rtl8187_rfkill_init(struct ieee80211_hw *hw)
--

To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Signature · 1 line
Vista: [V]iruses, [I]ntruders, [S]pyware, [T]rojans and [A]dware. :-)
#2 lore raw

2009/12/5 Gábor Stefanik <[email protected]>:

Quoted 6 lines · Larry Finger
Quoted 3 lines

+       printk(KERN_INFO "rtl8187: rfkill mask set to %d for Product ID 0x%x",
+              priv->rfkill_mask, product_id);

printk(KERN_DEBUG... ?

While the info itself is a bit technical and only of use to developers, it is a device sub-type and we currently do try to distinguish them and tell as such... we do

phy0: hwaddr ______________, RTL8187BvE V0 + rtl8225z2
rtl8187: Customer ID is 0x04

It may be appropriate to add to either. e.g.

phy0: hwaddr ______________, RTL8187BvE V0 + rtl8225z2 (rfkill mask %d)
rtl8187: Customer ID is 0x04 (rfkill mask %d)

The product id isn't much use though, since it is readily available via lsusb.

#3 lore raw
In reply to Larry Finger
Quoted 6 lines · Larry Finger

There are different bits used to convey the setting of the rfkill switch to the driver. The current driver only supports one of these possibilities. These changes were derived from the latest version of the vendor driver.

This patch fixes the regression noted in Bug #14xxx.

http://bugzilla.kernel.org/show_bug.cgi?id=14743

Quoted 4 lines

Tested okay here. About that printfk and Gábor's suggestion... I see the 'phy0: hwaddr ______________, RTL8187BvE V0 + rtl8225z2' line is actually only about 20 lines below in the same routine, so it is probably appropriate to combine the two, e.g.

phy0: hwaddr ______________, RTL8187BvE V0 + rtl8225z2, rfkill mask 2