OpenWrt Forum Archive

Topic: Creating DTS ath5k entry for SX762

The content of this topic has been archived on 22 Apr 2018. Unfortunately there are posts – most likely complete pages – missing.

snk wrote:

Looking at https://dev.openwrt.org/browser/trunk/p … X76X.patch it seems that there is a bug: CONFIG_ENV_OFFSET should be 192k, not 256k. U-Boot thinks its environment resides at 0x40000, and protects it automatically at boot.

Ok. that one worked too. Changed it to (192 * 1024)
Can now upgrade from SSH/command line.

Updated images can be downloaded from temporary download site (see wiki).

(Last edited by wvdakker on 7 Jul 2014, 19:59)

Good. You should submit a patch for that to the mailing list.

snk wrote:

Good. You should submit a patch for that to the mailing list.

Will do.

Only challenge is the leds. Just adding the right gpio address into the dts file
doesnt seem to work.
Have do dig into that....

    gpio-leds {
        compatible = "gpio-leds";

        voip {
            label = "voip";
            gpios = <&gpios 16 0>;
        };
        adsl {
            label = "adsl";
            gpios = <&gpios 17 0>;
        };
        usb {
            label = "usb";
            gpios = <&gpios 18 0>;
        };
        wifi {
            label = "wifi";
            gpios = <&gpios 19 0>;
        };
        phone2 {
            label = "phone2";
            gpios = <&gpios 20 0>;
        };
        phone1 {
            label = "phone1";
            gpios = <&gpios 21 0>;
        };
        line {
            label = "line";
            gpios = <&gpios 22 0>;
        };
        online {
            label = "online";
            gpios = <&gpios 23 0>;
        };
    };

Looking at the PCB picture, there seems to be only one STP converter on the board. Try subtracting 16 from all led numbers, and also adding

lantiq,groups = <0x1>;

to the stp section (like ARV4510PW.dts, which has 0x7).

Thanks for "Installation procedure for Barrier Breaker" on SX76X but I can't test it on my SX763 router due to this message "You don't have permission to access /download/sx762.img on this server."

Could you please send me these files or check permission on "http://www.wilsoft.nl/download" site.

kizo wrote:

Could you please send me these files or check permission on "http://www.wilsoft.nl/download" site.

Done.
Please notice to use the sx763_fw.bin image for the sx763 router.
I havent tested it because I dont have a sx763.

/Willem

Just an update...

My sx762 is operating with the current image without any problems.
Just have to fix the leds.
Therefor I am currently looking for a router to do the develop.
As in the Wiki is mentioned there are 2 types of sx762 with the same
modeltype, one running version 2.x and one 4.x.
After some investigation it looks the one with version 2.x has an indicaton
of   CT/VX at the back and the 4.x CT/Ux.
If an owner of a sx762 has a different scheme then above please let me know.

/Willem

I have 3 of them here. 1 4.x (annex A) CT/W4, and 2 2.x, (both annex B), CT/W9 and CT/V3.

BTW, the 4.x exemplar has a WDS(?) button between the USB port and the switch ports, while the 2.x exemplars haven't.

Mijzelf wrote:

I have 3 of them here. 1 4.x (annex A) CT/W4, and 2 2.x, (both annex B), CT/W9 and CT/V3.

BTW, the 4.x exemplar has a WDS(?) button between the USB port and the switch ports, while the 2.x exemplars haven't.

Thanks!

Yes this is still the same issue.

All patches are not yet merged into the source.
So you still have to use the versions which are available at
the alternative download. That one is updated to the last
BB version.

wvdakker wrote:

Yes this is still the same issue.

All patches are not yet merged into the source.
So you still have to use the versions which are available at
the alternative download. That one is updated to the last
BB version.

I want to add some extra packages and becouse BB doesnt want to opkg packages that are for different kernel i am building it by my self.
I changed the DTS entry as you described in this post and it works for my SX763.

Thank you for that smile

wvdakker wrote:

Yes this is still the same issue.

All patches are not yet merged into the source.
So you still have to use the versions which are available at
the alternative download. That one is updated to the last
BB version.

I'm using the images from the "http://www.wilsoft.nl/download" site and I got the router up & running (including wifi). Then I've compiled the latest 14.09 but could not get the wifi up & running - I guess because it could not read the MAC address from the EEPROM. I've tried the same for trunk but this affected my ethernet ports (plus wifi still broken), so I've reverted back to the images from wilsoft.

For now I'm trying to compile packages for this specific release (r41540). I've taken commit 73c6830261e25cceca8aaa5fbfd13e34d72db02a     (git-svn-id: svn://svn.openwrt.org/openwrt/trunk@41540 3c298f89-4303-0410-b956-a3cf2f4a3e73)

but whenever I try to install the packages I get kernel dependency errors

root@OpenWrt:~# opkg info kernel
Package: kernel
Version: 3.10.44-1-5a6c51038e529384f4f5bbfc800d9269
Depends: libc
Status: install hold installed
Architecture: lantiq
Installed-Time: 1404753697

But my packages require
kernel (= 3.10.44-1-1e7f9460ba0140c008ad4403292361d7)

So it's at least on the correct kernel version, but for some reason the MD5 differs.

Question 1: Is the patches applied for this image available somewhere so I can re-apply it to the latest 14.09? Then I can recompile and flash the router with the latest code, plus install any packages I need.
Question 2: Any idea why the kernel MD5 differs?

For those that want to build usable BB firmware for sx762/3, use this github repo ( branch sx763_testing)
https://tinyurl.com/ps9lfmp
Just change partition layout in GIGASX76X.dts if you are using different bootloaders.

Wlan eeprom is hardcoded into .h file, but when I find some spare time i will make patches to load eeprom from seperate partition and send it to the list.

Also leds are working, and there is a read frendly dsl status script.

(Last edited by Delboy on 4 Sep 2015, 23:04)

I've got an operational 762SX router running Barrier Breaker (14.07) with the following patches in place. Note I'm not using the ADSL port so I haven't bothered to include the ADSL fixes from Delboy, but I did include his LED patch. Also I'm using wvdakker's method to read the MAC address from flash insetad of hardcoding it in the code.

Modified files:
target/linux/lantiq/dts/GIGASX76X.dts

New files:
package/boot/uboot-lantiq/patches/0042-MIPS-lantiq-sx76x.patch
target/linux/lantiq/patches-3.10/0220-lantiq-xway-200-ath5k.patch

==== diff --git a/target/linux/lantiq/dts/GIGASX76X.dts b/target/linux/lantiq/dts/GIGASX76X.dts ====

index b4bb956..8ffd56d 100644
--- a/target/linux/lantiq/dts/GIGASX76X.dts
+++ b/target/linux/lantiq/dts/GIGASX76X.dts
@@ -41,7 +41,12 @@

                                partition@40000 {
                                        label = "firmware";
-                                       reg = <0x40000 0x7c0000>;
+                                       reg = <0x40000 0x7b0000>;
+                               };
+
+                               partition@7f0000 {
+                                       label = "firmware_sx76x";
+                                       reg = <0x7f0000 0x10000>;
                                };
                        };

@@ -54,22 +59,49 @@
                                gpio-controller;
                                lantiq,shadow = <0x3>;
                        };
+
+                       mac_addr {
+                               compatible = "lantiq,eth-mac";
+                               reg = <0 0x7f0016 0x6>;
+                               mac-increment = <2>;
+                       };
+
+                       ath5k_eep {
+                               compatible = "ath5k,eeprom";
+                               reg = <0 0x7f0400 0x1000
+                                       0 0x7f0016 0x6>;
+                               ath,mac-increment = <1>;
+                               ath,arv-ath5k-fix;
+                       };
                };

                gpio: pinmux@E100B10 {
+                       compatible = "lantiq,pinctrl-xway";
                        pinctrl-names = "default";
                        pinctrl-0 = <&state_default>;

+                       gpio-controller;
+                       reg = <0xE100B10 0xA0>;
+
                        state_default: pinmux {
                                stp {
                                        lantiq,groups = "stp";
                                        lantiq,function = "stp";
+                                       lantiq,pull = <2>;
+                                       lantiq,open-drain = <0>;
+                                       lantiq,output = <1>;
                                };
                        };
                };

-               gpios: stp@E100BB0 {
+               stp0: stp@E100BB0 {
                        status = "okay";
+                       compatible = "lantiq,gpio-stp-xway";
+                       reg = <0xE100BB0 0x40>;
+                       gpio-controller;
+
+                       lantiq,shadow = <0xfff>;
+                       lantiq,groups = <0x3>;
                };

                etop@E180000 {
@@ -100,6 +132,48 @@
                        gpios = <&gpio 14 0>;
                        linux,code = <0x198>;
                };
+               wps {
+                       label = "wps";
+                       gpios = <&gpio 22 1>;
+                       linux,code = <0x211>;
+               };
+       };
+
+       gpio-leds {
+               compatible = "gpio-leds";
+
+               adsl {
+                       label = "adsl";
+                       gpios = <&stp0 9 0>;
+               };
+               line {
+                       label = "line";
+                       gpios = <&stp0 14 0>;
+               };
+               online {
+                       label = "online";
+                       gpios = <&stp0 15 0>;
+               };
+               usb {
+                       label = "usb";
+                       gpios = <&stp0 10 0>;
+               };
+               wlan {
+                       label = "wlan";
+                       gpios = <&stp0 11 0>;
+               };
+               voip {
+                       label = "voip";
+                       gpios = <&stp0 8 0>;
+               };
+               phone1 {
+                       label = "phone1";
+                       gpios = <&stp0 13 0>;
+               };
+               phone2 {
+                       label = "phone2";
+                       gpios = <&stp0 12 0>;
+               };
        };

        gpio_export {
@@ -111,5 +185,11 @@
                        gpio-export,output = <1>;
                        gpios = <&gpio 19 0>;
                };
+
+               relay {
+                       gpio-export,name = "relay";
+                       gpio-export,output = <1>;
+                       gpios = <&gpio 30 0>;
+               };
        };
 };

==== package/boot/uboot-lantiq/patches/0042-MIPS-lantiq-sx76x.patch ====

--- a/include/configs/sx76x.h
+++ b/include/configs/sx76x.h
@@ -26,7 +26,7 @@
 #if defined(CONFIG_SYS_BOOT_NOR)
 #define CONFIG_ENV_IS_IN_FLASH
 #define CONFIG_ENV_OVERWRITE
-#define CONFIG_ENV_OFFSET              (256 * 1024)
+#define CONFIG_ENV_OFFSET              (192 * 1024)
 #define CONFIG_ENV_SECT_SIZE           (64 * 1024)
 #else
 #define CONFIG_ENV_IS_NOWHERE

==== target/linux/lantiq/patches-3.10/0220-lantiq-xway-200-ath5k.patch ====

--- a/arch/mips/lantiq/Makefile
+++ b/arch/mips/lantiq/Makefile
@@ -4,8 +4,9 @@
 # under the terms of the GNU General Public License version 2 as published
 # by the Free Software Foundation.

-obj-y := irq.o clk.o prom.o softdog_vpe.o
+obj-y := irq.o clk.o prom.o

+obj=$(CONFIG_MIPS_VPE_LOADER) += softdog_vpe.o
 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o

 obj-$(CONFIG_SOC_TYPE_XWAY) += xway/
--- a/arch/mips/lantiq/xway/ath_eep.c
+++ b/arch/mips/lantiq/xway/ath_eep.c
@@ -21,6 +21,7 @@
 #include <linux/mtd/mtd.h>
 #include <pci-ath-fixup.h>
 #include <lantiq_soc.h>
+#include <linux/of_net.h>

 extern int (*ltq_pci_plat_dev_init)(struct pci_dev *dev);
 struct ath5k_platform_data ath5k_pdata;
@@ -36,11 +37,10 @@ static int ath9k_pci_plat_dev_init(struc
 }

 static int ath9k_eep_load;
+
 int __init of_ath9k_eeprom_probe(struct platform_device *pdev)
 {
        struct device_node *np = pdev->dev.of_node, *mtd_np;
-       struct resource *eep_res, *mac_res = NULL;
-       void __iomem *eep, *mac;
        int mac_offset, led_pin;
        u32 mac_inc = 0, pci_slot = 0;
        int i;
@@ -50,41 +50,41 @@ int __init of_ath9k_eeprom_probe(struct
        const char *part;
        phandle phandle;

-       if ((list = of_get_property(np, "ath,eep-flash", &i)) && i == 2 *
-                       sizeof(*list) && (phandle = be32_to_cpup(list++)) &&
-                       (mtd_np = of_find_node_by_phandle(phandle)) && ((part =
-                       of_get_property(mtd_np, "label", NULL)) || (part =
-                       mtd_np->name)) && (the_mtd = get_mtd_device_nm(part))
-                       != ERR_PTR(-ENODEV)) {
-               i = mtd_read(the_mtd, be32_to_cpup(list),
-                               ATH9K_PLAT_EEP_MAX_WORDS << 1, &flash_readlen,
-                               (void *) ath9k_pdata.eeprom_data);
-               if (!of_property_read_u32(np, "ath,mac-offset", &mac_offset)) {
-                       size_t mac_readlen;
-                       mtd_read(the_mtd, mac_offset, 6, &mac_readlen,
-                               (void *) athxk_eeprom_mac);
-               }
-               put_mtd_device(the_mtd);
-               if ((sizeof(ath9k_pdata.eeprom_data) != flash_readlen) || i) {
-                       dev_err(&pdev->dev, "failed to load eeprom from mtd\n");
-                       return -ENODEV;
-               }
-       } else {
-               eep_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-               mac_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+       list = of_get_property(np, "ath,eep-flash", &i);
+       if (!list || (i !=  (2 * sizeof(*list)))) {
+               dev_err(&pdev->dev, "failed to find ath,eep-flash\n");
+               return -ENODEV;
+       }

-               if (!eep_res) {
-                       dev_err(&pdev->dev, "failed to load eeprom address\n");
-                       return -ENODEV;
-               }
-               if (resource_size(eep_res) != ATH9K_PLAT_EEP_MAX_WORDS << 1) {
-                       dev_err(&pdev->dev, "eeprom has an invalid size\n");
-                       return -EINVAL;
-               }
+       phandle = be32_to_cpup(list++);
+       if (!phandle) {
+               dev_err(&pdev->dev, "failed to find phandle\n");
+               return -ENODEV;
+       }

-               eep = ioremap(eep_res->start, resource_size(eep_res));
-               memcpy_fromio(ath9k_pdata.eeprom_data, eep,
-                               ATH9K_PLAT_EEP_MAX_WORDS << 1);
+       mtd_np = of_find_node_by_phandle(phandle);
+       if (!mtd_np) {
+               dev_err(&pdev->dev, "failed to find mtd node\n");
+               return -ENODEV;
+       }
+
+       part = of_get_property(mtd_np, "label", NULL);
+       if (!part)
+               part = mtd_np->name;
+
+       the_mtd = get_mtd_device_nm(part);
+       if (the_mtd == ERR_PTR(-ENODEV)) {
+               dev_err(&pdev->dev, "failed to find mtd device\n");
+               return -ENODEV;
+       }
+
+       i = mtd_read(the_mtd, be32_to_cpup(list),
+                       ATH9K_PLAT_EEP_MAX_WORDS << 1, &flash_readlen,
+                       (void *) ath9k_pdata.eeprom_data);
+       put_mtd_device(the_mtd);
+       if ((sizeof(ath9k_pdata.eeprom_data) != flash_readlen) || i) {
+               dev_err(&pdev->dev, "failed to load eeprom from mtd\n");
+               return -ENODEV;
        }

        if (of_find_property(np, "ath,eep-swap", NULL))
@@ -97,21 +97,12 @@ int __init of_ath9k_eeprom_probe(struct
                dev_info(&pdev->dev, "endian check enabled.\n");
        }

-       if (!is_valid_ether_addr(athxk_eeprom_mac)) {
-               if (mac_res) {
-                       if (resource_size(mac_res) != 6) {
-                               dev_err(&pdev->dev, "mac has an invalid size\n");
-                               return -EINVAL;
-                       }
-                       mac = ioremap(mac_res->start, resource_size(mac_res));
-                       memcpy_fromio(athxk_eeprom_mac, mac, 6);
-               } else if (ltq_get_eth_mac()) {
-                       memcpy(athxk_eeprom_mac, ltq_get_eth_mac(), 6);
-               }
-       }
-       if (!is_valid_ether_addr(athxk_eeprom_mac)) {
-               dev_warn(&pdev->dev, "using random mac\n");
+       if (!of_property_read_u32(np, "ath,mac-offset", &mac_offset)) {
+               memcpy_fromio(athxk_eeprom_mac, (void*) ath9k_pdata.eeprom_data + mac_offset, 6);
+       } else {
                random_ether_addr(athxk_eeprom_mac);
+               if (of_get_mac_address_mtd(np, athxk_eeprom_mac))
+                       dev_warn(&pdev->dev, "using random mac\n");
        }

        if (!of_property_read_u32(np, "ath,mac-increment", &mac_inc))
@@ -122,19 +113,18 @@ int __init of_ath9k_eeprom_probe(struct

        if (!of_property_read_u32(np, "ath,pci-slot", &pci_slot)) {
                ltq_pci_ath_fixup(pci_slot, ath9k_pdata.eeprom_data);
-
                dev_info(&pdev->dev, "pci slot: %u\n", pci_slot);
-                if (ath9k_eep_load) {
-                        struct pci_dev *d = NULL;
-                        while ((d = pci_get_device(PCI_VENDOR_ID_ATHEROS,
-                                        PCI_ANY_ID, d)) != NULL)
-                                pci_fixup_device(pci_fixup_early, d);
-                }
-
+               if (ath9k_eep_load) {
+                       struct pci_dev *d = NULL;
+                       while ((d = pci_get_device(PCI_VENDOR_ID_ATHEROS,
+                                       PCI_ANY_ID, d)) != NULL)
+                               pci_fixup_device(pci_fixup_early, d);
+               }
        }

        if (!of_property_read_u32(np, "ath,led-pin", &led_pin)) {
                ath9k_pdata.led_pin = led_pin;
+
                dev_info(&pdev->dev, "using led pin %d.\n", led_pin);
        }

@@ -158,24 +148,25 @@ static struct platform_driver ath9k_eepr

 static int __init of_ath9k_eeprom_init(void)
 {
-        int ret = platform_driver_probe(&ath9k_eeprom_driver, of_ath9k_eeprom_probe);
+       int ret = 0;
+
+       ret = platform_driver_probe(&ath9k_eeprom_driver, of_ath9k_eeprom_probe);

-        if (ret)
-                ath9k_eep_load = 1;
+       if (ret)
+               ath9k_eep_load = 1;

-        return ret;
+       return ret;
 }

 static int __init of_ath9k_eeprom_init_late(void)
 {
-        if (!ath9k_eep_load)
-                return 0;
-        return platform_driver_probe(&ath9k_eeprom_driver, of_ath9k_eeprom_probe);
+       if (!ath9k_eep_load)
+               return 0;
+       return platform_driver_probe(&ath9k_eeprom_driver, of_ath9k_eeprom_probe);
 }
 late_initcall(of_ath9k_eeprom_init_late);
 subsys_initcall(of_ath9k_eeprom_init);

-
 static int ath5k_pci_plat_dev_init(struct pci_dev *dev)
 {
        dev->dev.platform_data = &ath5k_pdata;
@@ -185,77 +176,146 @@ static int ath5k_pci_plat_dev_init(struc
 int __init of_ath5k_eeprom_probe(struct platform_device *pdev)
 {
        struct device_node *np = pdev->dev.of_node, *mtd_np;
-       struct resource *eep_res, *mac_res = NULL;
+       struct resource *eep_res, *mac_res;
        void __iomem *eep, *mac;
        int mac_offset;
-       u32 mac_inc = 0;
+       u32 mac_inc = 0, pci_slot = 0;
        int i;
+       u16 *eepdata, sum, el;
        struct mtd_info *the_mtd;
        size_t flash_readlen;
        const __be32 *list;
        const char *part;
        phandle phandle;

-       if ((list = of_get_property(np, "ath,eep-flash", &i)) && i == 2 *
-                       sizeof(*list) && (phandle = be32_to_cpup(list++)) &&
-                       (mtd_np = of_find_node_by_phandle(phandle)) && ((part =
-                       of_get_property(mtd_np, "label", NULL)) || (part =
-                       mtd_np->name)) && (the_mtd = get_mtd_device_nm(part))
-                       != ERR_PTR(-ENODEV)) {
+       if (!of_find_property(np,"ath,arv-ath5k-fix",NULL)) {
+
+               list = of_get_property(np, "ath,eep-flash", &i);
+               if (!list || (i !=  (2 * sizeof(*list)))) {
+                       dev_err(&pdev->dev, "failed to find ath,eep-flash\n");
+                       return -ENODEV;
+               }
+
+               phandle = be32_to_cpup(list++);
+               if (!phandle) {
+                       dev_err(&pdev->dev, "failed to find phandle\n");
+                       return -ENODEV;
+               }
+
+               mtd_np = of_find_node_by_phandle(phandle);
+               if (!mtd_np) {
+                       dev_err(&pdev->dev, "failed to find mtd node\n");
+                       return -ENODEV;
+               }
+
+               part = of_get_property(mtd_np, "label", NULL);
+               if (!part)
+                       part = mtd_np->name;
+
+               the_mtd = get_mtd_device_nm(part);
+               if (the_mtd == ERR_PTR(-ENODEV)) {
+                       dev_err(&pdev->dev, "failed to find mtd device\n");
+                       return -ENODEV;
+               }
+
                i = mtd_read(the_mtd, be32_to_cpup(list),
-                               ATH5K_PLAT_EEP_MAX_WORDS << 1, &flash_readlen,
-                               (void *) ath5k_pdata.eeprom_data);
+                       ATH5K_PLAT_EEP_MAX_WORDS << 1, &flash_readlen,
+                       (void *) ath5k_pdata.eeprom_data);
                put_mtd_device(the_mtd);
-               if ((sizeof(ATH5K_PLAT_EEP_MAX_WORDS << 1) != flash_readlen)
-                               || i) {
+               if ((sizeof(ath5k_pdata.eeprom_data) != flash_readlen) || i) {
                        dev_err(&pdev->dev, "failed to load eeprom from mtd\n");
                        return -ENODEV;
                }
+
+               if (of_find_property(np, "ath,eep-swap", NULL))
+                       for (i = 0; i < ATH5K_PLAT_EEP_MAX_WORDS; i++)
+                               ath5k_pdata.eeprom_data[i] = swab16(ath5k_pdata.eeprom_data[i]);
+
+               if (!of_property_read_u32(np, "ath,mac-offset", &mac_offset)) {
+                       memcpy_fromio(athxk_eeprom_mac, (void*) ath5k_pdata.eeprom_data + mac_offset, 6);
+               } else {
+                       random_ether_addr(athxk_eeprom_mac);
+                       if (of_get_mac_address_mtd(np, athxk_eeprom_mac))
+                               dev_warn(&pdev->dev, "using random mac\n");
+               }
+
+               if (!of_property_read_u32(np, "ath,mac-increment", &mac_inc))
+                       athxk_eeprom_mac[5] += mac_inc;
+
+               ath5k_pdata.macaddr = athxk_eeprom_mac;
+               ltq_pci_plat_dev_init = ath5k_pci_plat_dev_init;
        } else {
+               // Noltari patch for ath5k arv4518pw. Applicable for other ath5k lantiqs.
+
                eep_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
                mac_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);

+               dev_info(&pdev->dev,"eeprom expected size : %u\n",ATH5K_PLAT_EEP_MAX_WORDS<<1);
+               dev_info(&pdev->dev,"mac expected size : %u\n",6);
+               dev_info(&pdev->dev,"eeprom read size : %u\n",resource_size(eep_res));
+               dev_info(&pdev->dev,"mac address size : %u\n",resource_size(mac_res));
+
                if (!eep_res) {
-                       dev_err(&pdev->dev, "failed to load eeprom address\n");
+                       dev_err(&pdev->dev, "failed to load eeprom addres\n");
                        return -ENODEV;
                }
-               if (resource_size(eep_res) != ATH5K_PLAT_EEP_MAX_WORDS << 1) {
-                       dev_err(&pdev->dev, "eeprom has an invalid size\n");
+
+               if (resource_size(eep_res) != ATH5K_PLAT_EEP_MAX_WORDS<<1) {
+                       dev_err(&pdev->dev, "eeprom size mismatch\n");
                        return -EINVAL;
                }

                eep = ioremap(eep_res->start, resource_size(eep_res));
-               ath5k_pdata.eeprom_data = kmalloc(ATH5K_PLAT_EEP_MAX_WORDS<<1,
-                               GFP_KERNEL);
-               memcpy_fromio(ath5k_pdata.eeprom_data, eep,
-                               ATH5K_PLAT_EEP_MAX_WORDS << 1);
-       }

-       if (of_find_property(np, "ath,eep-swap", NULL))
-               for (i = 0; i < ATH5K_PLAT_EEP_MAX_WORDS; i++)
-                       ath5k_pdata.eeprom_data[i] = swab16(ath5k_pdata.eeprom_data[i]);
+               ath5k_pdata.eeprom_data=kmalloc(ATH5K_PLAT_EEP_MAX_WORDS<<1,GFP_KERNEL);
+               memcpy_fromio(ath5k_pdata.eeprom_data, eep,ATH5K_PLAT_EEP_MAX_WORDS<<1);

-       if (!of_property_read_u32(np, "ath,mac-offset", &mac_offset)) {
-               memcpy_fromio(athxk_eeprom_mac, (void*) ath5k_pdata.eeprom_data + mac_offset, 6);
-       } else if (mac_res) {
-               if (resource_size(mac_res) != 6) {
-                       dev_err(&pdev->dev, "mac has an invalid size\n");
-                       return -EINVAL;
+               if (of_find_property(np, "ath,eep-swap",NULL)) {
+                       for (i=0; i<ATH5K_PLAT_EEP_MAX_WORDS; i++)
+                               ath5k_pdata.eeprom_data[i]=swab16(ath5k_pdata.eeprom_data[i]);
                }
-               mac = ioremap(mac_res->start, resource_size(mac_res));
-               memcpy_fromio(athxk_eeprom_mac, mac, 6);
-       } else if (ltq_get_eth_mac())
-               memcpy(athxk_eeprom_mac, ltq_get_eth_mac(), 6);
-       else {
-               dev_warn(&pdev->dev, "using random mac\n");
-               random_ether_addr(athxk_eeprom_mac);
-       }

-       if (!of_property_read_u32(np, "ath,mac-increment", &mac_inc))
-               athxk_eeprom_mac[5] += mac_inc;
+               if (of_find_property(np, "ath,eep-csum", NULL)) {
+                       sum=ath5k_pdata.eeprom_data[0x200>>1];
+                       el=sum/sizeof(u16)-2;           // skip length and old cheksum
+                       eepdata=(u16 *)(&ath5k_pdata.eeprom_data[0x204>>1]);            // after cheksum
+                       for (i=0; i<el; i++)
+                               sum^=*eepdata++;
+                       sum^=0xffff;
+                       ath5k_pdata.eeprom_data[0x202>>1]=sum;
+                       dev_info(&pdev->dev,"checksum fixed.\n");
+               }

-       ath5k_pdata.macaddr = athxk_eeprom_mac;
-       ltq_pci_plat_dev_init = ath5k_pci_plat_dev_init;
+               if (!of_property_read_u32(np,"ath,mac-offset",&mac_offset)) {
+                       memcpy_fromio(athxk_eeprom_mac, (void*) ath5k_pdata.eeprom_data +mac_offset, 6);
+               } else {
+                       if (mac_res) {
+                               if (resource_size(mac_res)!=6) {
+                                       dev_err(&pdev->dev, "mac has an invalid size.\n");
+                                       return -EINVAL;
+                               }
+                               dev_info(&pdev->dev,"loading MAC.\n");
+                               mac=ioremap(mac_res->start, resource_size(mac_res));
+                               memcpy_fromio(athxk_eeprom_mac, mac, 6);
+                               dev_info(&pdev->dev,"loaded MAC.\n");
+                       } else {
+                               dev_warn(&pdev->dev,"using random mac.\n");
+                               random_ether_addr(athxk_eeprom_mac);
+                       }
+               }
+
+               if (!of_property_read_u32(np, "ath,mac-increment", &mac_inc))
+                       athxk_eeprom_mac[5]+=mac_inc;
+
+               ath5k_pdata.macaddr=athxk_eeprom_mac;
+               ltq_pci_plat_dev_init=ath5k_pci_plat_dev_init;
+
+               if (!of_property_read_u32(np,"ath,pci-slot", &pci_slot)) {
+                       ltq_pci_ath_fixup(pci_slot, ath5k_pdata.eeprom_data);
+                       dev_info(&pdev->dev,"pci slot: %u.\n",pci_slot);
+               }
+               dev_info(&pdev->dev,"eeprom init finished.\n");
+       }

        dev_info(&pdev->dev, "loaded ath5k eeprom\n");

@@ -279,4 +339,6 @@ static int __init of_ath5k_eeprom_init(v
 {
        return platform_driver_probe(&ath5k_eeprom_driver, of_ath5k_eeprom_probe);
 }
-device_initcall(of_ath5k_eeprom_init);
+
+subsys_initcall(of_ath5k_eeprom_init);
+

The discussion might have continued from here.