]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mt76: eeprom: add support for big endian eeprom partition
authorLorenzo Bianconi <lorenzo@kernel.org>
Wed, 27 Nov 2019 14:46:33 +0000 (16:46 +0200)
committerFelix Fietkau <nbd@nbd.name>
Fri, 14 Feb 2020 09:06:00 +0000 (10:06 +0100)
mt76x0e users reported some devices (e.g TP-Link Archer VR200v) have
been flashed with big endian radio partition. Add the possibility to
specify eeprom endianness using big-endian dts property and in case
covert eeprom data in little endian

Tested-by: Kevin Schmidt <kevin.patrick.schmidt@googlemail.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/eeprom.c

index 358fb0a1e5235dd138bf0b21b51fabf78ef43053..8f2693748faf3dde11e6d686944ed6e3ea011194 100644 (file)
@@ -64,6 +64,16 @@ mt76_get_of_eeprom(struct mt76_dev *dev, int len)
                goto out_put_node;
        }
 
+       if (of_property_read_bool(dev->dev->of_node, "big-endian")) {
+               u8 *data = (u8 *)dev->eeprom.data;
+               int i;
+
+               /* convert eeprom data in Little Endian */
+               for (i = 0; i < round_down(len, 2); i += 2)
+                       put_unaligned_le16(get_unaligned_be16(&data[i]),
+                                          &data[i]);
+       }
+
 out_put_node:
        of_node_put(np);
        return ret;