On 28/05/13 13:12, Daniel Gimpelevich wrote:
This patch enables retrieving the wifi calibration data from a flash
partition.


the existing code reads from a flash offset. your patch chanegs this to use mtd partitions. the description should reflect this.


Signed-off-by: Daniel Gimpelevich<[email protected]>
Index: 
target/linux/lantiq/patches-3.8/0037-owrt-lantiq-wifi-and-ethernet-eeprom-handling.patch
===================================================================
--- 
a/target/linux/lantiq/patches-3.8/0037-owrt-lantiq-wifi-and-ethernet-eeprom-handling.patch
  (revision 36739)
+++ 
b/target/linux/lantiq/patches-3.8/0037-owrt-lantiq-wifi-and-ethernet-eeprom-handling.patch
  (working copy)
@@ -50,7 +50,7 @@
   obj-$(CONFIG_XRX200_PHY_FW) += xrx200_phy_fw.o
  --- /dev/null
  +++ b/arch/mips/lantiq/xway/ath_eep.c
-@@ -0,0 +1,206 @@
+@@ -0,0 +1,246 @@
  +/*
  + *  Copyright (C) 2011 Luca Olivetti<[email protected]>
  + *  Copyright (C) 2011 John Crispin<[email protected]>
@@ -69,7 +69,10 @@
  +#include<linux/ath5k_platform.h>
  +#include<linux/ath9k_platform.h>
  +#include<linux/pci.h>
++#include<linux/err.h>
++#include<linux/mtd/mtd.h>
  +#include<pci-ath-fixup.h>
++#include<lantiq_soc.h>

[....]

  +     }
@@ -176,7 +199,7 @@
  +{
  +     return platform_driver_probe(&ath9k_eeprom_driver, 
of_ath9k_eeprom_probe);
  +}
-+arch_initcall(of_ath9k_eeprom_init);
++late_initcall(of_ath9k_eeprom_init);

ideally this goes in a seperate patch, its not directly related to the subject. changing the init time of pci and eeprom laoding should go into a seperate patch rather than hiding it in a patch

  +
  +
  +static int ath5k_pci_plat_dev_init(struct pci_dev *dev)
@@ -188,30 +211,45 @@
  +int __init of_ath5k_eeprom_probe(struct platform_device *pdev)
  +{
  +     struct device_node *np = pdev->dev.of_node;
-+      struct resource *eep_res, *mac_res;
++      struct resource *eep_res, *mac_res = NULL;
  +     void __iomem *eep, *mac;
  +     int mac_offset;
-+      u32 mac_inc = 0;
++      u32 mac_inc = 0, mtd_addr[2];
  +     int i;
++      struct mtd_info *the_mtd;
++      size_t flash_readlen;
  +
-+      eep_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-+      mac_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
++      if (of_property_read_u32_array(np, "ath,eep-flash", mtd_addr, 2) == 0&&
++                              (the_mtd = get_mtd_device(NULL, mtd_addr[0]))
++                              != ERR_PTR(-ENODEV)) {
++              i = mtd_read(the_mtd, mtd_addr[1],
++                              sizeof(ath5k_eeprom_data),&flash_readlen,
++                              (void *) ath5k_eeprom_data);
++              put_mtd_device(the_mtd);
++              if ((sizeof(ath5k_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);
  +
-+      if (!eep_res) {
-+              dev_err(&pdev->dev, "failed to load eeprom address\n");
-+              return -ENODEV;
++              if (!eep_res) {
++                      dev_err(&pdev->dev, "failed to load eeprom address\n");
++                      return -ENODEV;
++              }
++              if (resource_size(eep_res) != ATH5K_PLAT_EEP_MAX_WORDS) {
++                      dev_err(&pdev->dev, "eeprom has an invalid size\n");
++                      return -EINVAL;
++              }
++
++              eep = ioremap(eep_res->start, resource_size(eep_res));
++              memcpy_fromio(ath5k_eeprom_data, eep, ATH5K_PLAT_EEP_MAX_WORDS);
  +     }
-+      if (resource_size(eep_res) != ATH5K_PLAT_EEP_MAX_WORDS) {
-+              dev_err(&pdev->dev, "eeprom has an invalid size\n");
-+              return -EINVAL;
-+      }
  +
-+      eep = ioremap(eep_res->start, resource_size(eep_res));
-+      memcpy_fromio(ath5k_eeprom_data, eep, ATH5K_PLAT_EEP_MAX_WORDS);
-+
  +     if (of_find_property(np, "ath,eep-swap", NULL))
-+              for (i = 0; i<  (ATH5K_PLAT_EEP_MAX_WORDS>>  1); i++)
-+                              ath5k_eeprom_data[i] = 
swab16(ath5k_eeprom_data[i]);
++              for (i = 0; i<  ATH5K_PLAT_EEP_MAX_WORDS; i++)
++                      ath5k_eeprom_data[i] = swab16(ath5k_eeprom_data[i]);
  +
  +     if (!of_property_read_u32(np, "ath,mac-offset",&mac_offset)) {
  +             memcpy_fromio(athxk_eeprom_mac, (void*) ath5k_eeprom_data, 6);
@@ -222,7 +260,9 @@
  +             }
  +             mac = ioremap(mac_res->start, resource_size(mac_res));
  +             memcpy_fromio(athxk_eeprom_mac, mac, 6);
-+      } else {
++      } 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);
  +     }
@@ -256,7 +296,7 @@
  +{
  +     return platform_driver_probe(&ath5k_eeprom_driver, 
of_ath5k_eeprom_probe);
  +}
-+device_initcall(of_ath5k_eeprom_init);
++late_initcall(of_ath5k_eeprom_init);


same here

  --- /dev/null
  +++ b/arch/mips/lantiq/xway/eth_mac.c
  @@ -0,0 +1,76 @@
@@ -426,7 +466,7 @@
  +     dev->revision = val&  0xff;
  +     dev->class = val>>  8; /* upper 3 bytes */
  +
-+      pr_info("pci %s: fixup info: [%04x:%04x] revision %02x class %#08x\n",
++      pr_info("pci %s: fixup info: [%04x:%04x] revision %02x class %#08x\n",

white space fix is not related to this patch


  +             pci_name(dev), dev->vendor, dev->device, dev->revision, 
dev->class);
  +
  +     pci_read_config_word(dev, PCI_COMMAND,&cmd);
@@ -544,3 +584,11 @@

        priv->clk_ppe = clk_get(&pdev->dev, NULL);
        if (IS_ERR(priv->clk_ppe))
+--- a/arch/mips/pci/pci-lantiq.c
++++ b/arch/mips/pci/pci-lantiq.c
+@@ -260,4 +260,4 @@ int __init pcibios_init(void)
+       return ret;
+ }
+
+-arch_initcall(pcibios_init);
++late_initcall(pcibios_init);

same as the other init time changes



_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to