RT5392 support?

I'm porting OpenWrt to ZTE ZXHN H367N. It has Ralink RT5392L chip connected via PCI bus. If I understood correctly, it should work with the kmod-rt2800-pci driver, but I'm getting this:

[   15.966452] ifx_pcie_bios_map_irq port 0 dev 0000:01:00.0 slot 0 pin 1 
[   15.971764] ifx_pcie_bios_map_irq dev 0000:01:00.0 irq 144 assigned
[   15.977999] rt2800pci 0000:01:00.0: enabling device (0000 -> 0002)
[   15.984373] ieee80211 phy0: rt2x00_set_rt: Info - RT chipset 5392, rev 0223 detected
[   15.995418] ieee80211 phy0: rt2800_init_eeprom: Error - Invalid RF chipset 0xffff detected
[   16.002316] ieee80211 phy0: rt2x00lib_probe_dev: Error - Failed to allocate device

The original firmware contains module rt5390.ko which appears to try to load the file RT5392_PCIe_2T2R_ALC_V1_4.bin, but it's a 512-byte file which doesn't look like a typical Ralink firmware/EEPROM image. (It also appears that it could work without any files since there's the string saying " WIFI 2.4G(RT5392) Not Calibrated Use default" in the driver.)
The device also has a partition called WIFI but it's mostly empty, except for a few bytes at the beginning. Another file is RT2860AP.dat, but it's 2KiB textual configuration, not the firmware.

All in all, the ZTE's original firmware doesn't appear to be uploading some kind of firmware to the chip, and I'm stuck here trying to make it work, so I'd appreciate any help.

take a look at this, maybe it applies to your device as well https://patchwork.kernel.org/patch/10743707/

But it's eeprom data (calibration data for specific pcie card). Don't confuse with firmware. If i'm not mistaken firmware for your card exist in package rt2800-pci-firmware.
Vendor's rt5390.ko have compiled in both firmware and eeprom.
Open source driver search eeprom data in flash partition and fallback to request file if failed.
In file rt2x00eeprom.c:

static int rt2x00lib_request_eeprom_file(struct rt2x00_dev *rt2x00dev)
{
        const struct firmware *ee;
        const char *ee_name;
        int retval;

        if (!rt2800lib_read_eeprom_mtd(rt2x00dev))
                return 0;

        ee_name = rt2x00lib_get_eeprom_file_name(rt2x00dev);
        if (!ee_name && test_bit(REQUIRE_EEPROM_FILE, &rt2x00dev->cap_flags)) {
                rt2x00_err(rt2x00dev, "Required EEPROM name is missing.");
                return -EINVAL;
        }

        if (!ee_name)
                return 0;

        rt2x00_info(rt2x00dev, "Loading EEPROM data from '%s'.\n", ee_name);

        retval = request_firmware(&ee, ee_name, rt2x00dev->dev);
        if (retval) {
                rt2x00_err(rt2x00dev, "Failed to request EEPROM.\n");
                return retval;
        }

        if (!ee || !ee->size || !ee->data) {
                rt2x00_err(rt2x00dev, "Failed to read EEPROM file.\n");
                retval = -ENOENT;
                goto err_exit;
        }

        if (ee->size != rt2x00dev->ops->eeprom_size) {
                rt2x00_err(rt2x00dev,
                           "EEPROM file size is invalid, it should be %d bytes\n",
                           rt2x00dev->ops->eeprom_size);
                retval = -EINVAL;
                goto err_release_ee;
        }

        rt2x00dev->eeprom_file = ee;
        return 0;

err_release_ee:
        release_firmware(ee);
err_exit:
        return retval;
}

you can see this logic. In your log no messages for reading eeprom from external file. So I think that for your board reading eeprom from mtd partition is configure wrong. In rt2x00eeprom.c you can see that driver search property "ralink,mtd-eeprom". As example see files in target/linux/ramips/dts,

1 Like

OK, I've compared the partitions and files and I've located the EEPROM data in the flash, however, the driver doesn't attempt to load the firmware.

I've defined the partition in the device tree:

wifi: partition@7f32000 {
	label = "wifi";
	reg = <0x7f32000 0x10000>;
};

And added ralink,mtd-eeprom:

&pci0 {
	status = "okay";
	gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;

	wifi@1814,5392 {
		compatible = "pci1814,5392";
		reg = <0x7000 0 0 0 0>;
		ralink,mtd-eeprom = <&wifi 0x0>;
	};
};

But still, the only output is this:

[   15.799688] ifx_pcie_bios_map_irq port 0 dev 0000:01:00.0 slot 0 pin 1 
[   15.804998] ifx_pcie_bios_map_irq dev 0000:01:00.0 irq 144 assigned
[   15.811215] rt2800pci 0000:01:00.0: enabling device (0000 -> 0002)
[   15.817629] ieee80211 phy0: rt2x00_set_rt: Info - RT chipset 5392, rev 0223 detected
[   15.828652] ieee80211 phy0: rt2800_init_eeprom: Error - Invalid RF chipset 0xffff detected
[   15.835545] ieee80211 phy0: rt2x00lib_probe_dev: Error - Failed to allocate device

Stupid me, it was on pcie bus, not pci. It works now.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.