Skip to contentSkip to conversation

rt2x00: Add dynamic detection of eFuse EEPROM in rt2800pci.

RFC/RFT Gertjan van Wingerde 3 participants 3 messages Nov 8, 2009 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

Instead of assuming that all rt3090 devices will have an eFuse EEPROM, do as the legacy Ralink driver, and detect at run-time whether an eFuse EEPROM is present.

---
I only had the possibilitye to test this on a rt2890 device without eFuse EEPROM. It would be good if someone can test this on a rt3090 device with eFuse EEPROM.

---
 drivers/net/wireless/rt2x00/rt2800pci.c |   22 ++++++++++++++++++----
 drivers/net/wireless/rt2x00/rt2800pci.h |    1 +
 2 files changed, 19 insertions(+), 4 deletions(-)
drivers/net/wireless/rt2x00/rt2800pci.c +18 -4
index bff8707..2f284a6 100644
@@ -145,6 +145,15 @@ static void rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev)
 			       EEPROM_SIZE / sizeof(u16));
 }
 
+static int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev)
+{
+	u32 reg;
+
+	rt2800_register_read(rt2x00dev, EFUSE_CTRL, &reg);
+
+	return rt2x00_get_field32(reg, EFUSE_CTRL_PRESENT);
+}
+
 static void rt2800pci_efuse_read(struct rt2x00_dev *rt2x00dev,
 				 unsigned int i)
 {
@@ -182,6 +191,11 @@ static inline void rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev)
 {
 }
 
+static inline int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev)
+{
+	return 0;
+}
+
 static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
 {
 }
@@ -1091,11 +1105,11 @@ static int rt2800pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 	case RT3052:
 		rt2800pci_read_eeprom_soc(rt2x00dev);
 		break;
-	case RT3090:
-		rt2800pci_read_eeprom_efuse(rt2x00dev);
-		break;
 	default:
-		rt2800pci_read_eeprom_pci(rt2x00dev);
+		if (rt2800pci_efuse_detect(rt2x00dev))
+			rt2800pci_read_eeprom_efuse(rt2x00dev);
+		else
+			rt2800pci_read_eeprom_pci(rt2x00dev);
 		break;
 	}
 
drivers/net/wireless/rt2x00/rt2800pci.h +1 -0
index 1dbf132..8f944ee 100644
@@ -62,6 +62,7 @@
 #define EFUSE_CTRL_ADDRESS_IN		FIELD32(0x03fe0000)
 #define EFUSE_CTRL_MODE			FIELD32(0x000000c0)
 #define EFUSE_CTRL_KICK			FIELD32(0x40000000)
+#define EFUSE_CTRL_PRESENT		FIELD32(0x80000000)
 
 /*
  * EFUSE_DATA0
Signature · 1 line
1.6.5.2
Acked-by
#1 lore raw
Quoted 4 lines · Gertjan van Wingerde

Instead of assuming that all rt3090 devices will have an eFuse EEPROM, do as the legacy Ralink driver, and detect at run-time whether an eFuse EEPROM is present.

Quoted 68 lines

---
I only had the possibilitye to test this on a rt2890 device without eFuse EEPROM. It would be good if someone can test this on a rt3090 device with eFuse EEPROM.

---
 drivers/net/wireless/rt2x00/rt2800pci.c |   22 ++++++++++++++++++----
 drivers/net/wireless/rt2x00/rt2800pci.h |    1 +
 2 files changed, 19 insertions(+), 4 deletions(-)
drivers/net/wireless/rt2x00/rt2800pci.c +18 -4
index bff8707..2f284a6 100644
@@ -145,6 +145,15 @@ static void rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev)
 			       EEPROM_SIZE / sizeof(u16));
 }
 
+static int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev)
+{
+	u32 reg;
+
+	rt2800_register_read(rt2x00dev, EFUSE_CTRL, &reg);
+
+	return rt2x00_get_field32(reg, EFUSE_CTRL_PRESENT);
+}
+
 static void rt2800pci_efuse_read(struct rt2x00_dev *rt2x00dev,
 				 unsigned int i)
 {
@@ -182,6 +191,11 @@ static inline void rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev)
 {
 }
 
+static inline int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev)
+{
+	return 0;
+}
+
 static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
 {
 }
@@ -1091,11 +1105,11 @@ static int rt2800pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 	case RT3052:
 		rt2800pci_read_eeprom_soc(rt2x00dev);
 		break;
-	case RT3090:
-		rt2800pci_read_eeprom_efuse(rt2x00dev);
-		break;
 	default:
-		rt2800pci_read_eeprom_pci(rt2x00dev);
+		if (rt2800pci_efuse_detect(rt2x00dev))
+			rt2800pci_read_eeprom_efuse(rt2x00dev);
+		else
+			rt2800pci_read_eeprom_pci(rt2x00dev);
 		break;
 	}
 
drivers/net/wireless/rt2x00/rt2800pci.h +1 -0
index 1dbf132..8f944ee 100644
@@ -62,6 +62,7 @@
 #define EFUSE_CTRL_ADDRESS_IN		FIELD32(0x03fe0000)
 #define EFUSE_CTRL_MODE			FIELD32(0x000000c0)
 #define EFUSE_CTRL_KICK			FIELD32(0x40000000)
+#define EFUSE_CTRL_PRESENT		FIELD32(0x80000000)
 
 /*
  * EFUSE_DATA0
#2 lore raw
In reply to Gertjan van Wingerde
Quoted 4 lines · On Sunday 08 November 2009 12:30:35 Gertjan van Wingerde wrote:

Instead of assuming that all rt3090 devices will have an eFuse EEPROM, do as the legacy Ralink driver, and detect at run-time whether an eFuse EEPROM is present.

Incidentally I made a very similar patch on Friday as a preparation for other changes but this version is a bit more readable (cause it adds rt2800pci_efuse_detect() helper) so I'll replace my version by your patch.