iwinfo: add hw info support for Rt3xxx SoCs
authorjow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Wed, 15 Aug 2012 16:25:38 +0000 (16:25 +0000)
committerjow <jow@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Wed, 15 Aug 2012 16:25:38 +0000 (16:25 +0000)
This takes the device_id and subsystem_id from the EEPROM, I'll add
the info for other Rt3xxx chips in the next days.

[jow: minor whitespace changes]

Signed-off-by: Daniel Golle <dgolle@allnet.de>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@33199 3c298f89-4303-0410-b956-a3cf2f4a3e73

package/iwinfo/src/iwinfo_lib.c
package/iwinfo/src/iwinfo_utils.c

index b2fc6aa..5ca0a45 100644 (file)
@@ -314,6 +314,7 @@ const struct iwinfo_iso3166_label IWINFO_ISO3166_NAMES[] = {
 
 const char VENDOR_UBNT[] = "Ubiquiti";
 const char VENDOR_ATH[]  = "Atheros";
 
 const char VENDOR_UBNT[] = "Ubiquiti";
 const char VENDOR_ATH[]  = "Atheros";
+const char VENDOR_RALINK[]  = "RaLink";
 
 const struct iwinfo_hardware_entry IWINFO_HARDWARE_ENTRIES[] = {
 /*     { vendor, model, vendorid, deviceid, subsys vendorid, subsys deviceid, poweroff, freqoff } */
 
 const struct iwinfo_hardware_entry IWINFO_HARDWARE_ENTRIES[] = {
 /*     { vendor, model, vendorid, deviceid, subsys vendorid, subsys deviceid, poweroff, freqoff } */
@@ -368,6 +369,7 @@ const struct iwinfo_hardware_entry IWINFO_HARDWARE_ENTRIES[] = {
        { VENDOR_ATH,  "AR9220",                0x168c, 0x0029, 0x168c, 0xa094,  0,     0 },
        { VENDOR_ATH,  "AR9223",                0x168c, 0x0029, 0x168c, 0xa095,  0,     0 },
        { VENDOR_ATH,  "AR9285",                0x168c, 0x002b, 0x168c, 0xa091,  0,     0 },
        { VENDOR_ATH,  "AR9220",                0x168c, 0x0029, 0x168c, 0xa094,  0,     0 },
        { VENDOR_ATH,  "AR9223",                0x168c, 0x0029, 0x168c, 0xa095,  0,     0 },
        { VENDOR_ATH,  "AR9285",                0x168c, 0x002b, 0x168c, 0xa091,  0,     0 },
+       { VENDOR_RALINK,  "Rt3352",             0x1814, 0x3352, 0x1814, 0x000c,  0,     0 },
 #endif
        { NULL }
 };
 #endif
        { NULL }
 };
index 514f34b..164e51f 100644 (file)
@@ -165,7 +165,8 @@ int iwinfo_hardware_id_from_mtd(struct iwinfo_hardware_id *id)
        while (fgets(buf, sizeof(buf), mtd) > 0)
        {
                if (fscanf(mtd, "mtd%d: %*x %x %127s", &off, &len, buf) < 3 ||
        while (fgets(buf, sizeof(buf), mtd) > 0)
        {
                if (fscanf(mtd, "mtd%d: %*x %x %127s", &off, &len, buf) < 3 ||
-                   (strcmp(buf, "\"boardconfig\"") && strcmp(buf, "\"EEPROM\"")))
+                   (strcmp(buf, "\"boardconfig\"") && strcmp(buf, "\"EEPROM\"") &&
+                    strcmp(buf, "\"factory\"")))
                {
                        off = -1;
                        continue;
                {
                        off = -1;
                        continue;
@@ -212,6 +213,26 @@ int iwinfo_hardware_id_from_mtd(struct iwinfo_hardware_id *id)
                                id->subsystem_device_id = bc[off + 0x14];
                                break;
                        }
                                id->subsystem_device_id = bc[off + 0x14];
                                break;
                        }
+
+                       /* Rt3xxx SoC */
+                       else if ((bc[off] == 0x3352) || (bc[off] == 0x5233) ||
+                                (bc[off] == 0x3350) || (bc[off] == 0x5033) ||
+                                (bc[off] == 0x3050) || (bc[off] == 0x5030) ||
+                                (bc[off] == 0x3052) || (bc[off] == 0x5230))
+                       {
+                               /* vendor: RaLink */
+                               id->vendor_id = 0x1814;
+                               id->subsystem_vendor_id = 0x1814;
+
+                               /* device */
+                               if (bc[off] & 0xf0 == 0x30)
+                                       id->device_id = (bc[off] >> 8) | (bc[off] & 0x00ff) << 8;
+                               else
+                                       id->device_id = bc[off];
+
+                               /* subsystem from EEPROM_NIC_CONF0_RF_TYPE */
+                               id->subsystem_device_id = (bc[off + 0x1a] & 0x0f00) >> 8;
+                       }
                }
 
                munmap(bc, len);
                }
 
                munmap(bc, len);