lantiq: revert 36778 as it breaks irq assignment to pci devices
[openwrt.git] / target / linux / lantiq / patches-3.8 / 0037-owrt-lantiq-wifi-and-ethernet-eeprom-handling.patch
index 6d19fdb..ca88c74 100644 (file)
@@ -50,12 +50,13 @@ Subject: [PATCH 37/40] owrt: lantiq: wifi and ethernet eeprom handling
  obj-$(CONFIG_XRX200_PHY_FW) += xrx200_phy_fw.o
 --- /dev/null
 +++ b/arch/mips/lantiq/xway/ath_eep.c
-@@ -0,0 +1,258 @@
+@@ -0,0 +1,248 @@
 +/*
 + *  Copyright (C) 2011 Luca Olivetti <luca@ventoso.org>
 + *  Copyright (C) 2011 John Crispin <blogic@openwrt.org>
 + *  Copyright (C) 2011 Andrej Vlašić <andrej.vlasic0@gmail.com>
 + *  Copyright (C) 2013 Álvaro Fernández Rojas <noltari@gmail.com>
++ *  Copyright (C) 2013 Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
 + *
 + *  This program is free software; you can redistribute it and/or modify it
 + *  under the terms of the GNU General Public License version 2 as published
@@ -79,7 +80,6 @@ Subject: [PATCH 37/40] owrt: lantiq: wifi and ethernet eeprom handling
 +struct ath9k_platform_data ath9k_pdata = {
 +      .led_pin = -1,
 +};
-+static u16 ath5k_eeprom_data[ATH5K_PLAT_EEP_MAX_WORDS];
 +static u8 athxk_eeprom_mac[6];
 +
 +static int ath9k_pci_plat_dev_init(struct pci_dev *dev)
@@ -96,7 +96,6 @@ Subject: [PATCH 37/40] owrt: lantiq: wifi and ethernet eeprom handling
 +      int mac_offset;
 +      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;
@@ -110,7 +109,7 @@ Subject: [PATCH 37/40] owrt: lantiq: wifi and ethernet eeprom handling
 +                      mtd_np->name)) && (the_mtd = get_mtd_device_nm(part))
 +                      != ERR_PTR(-ENODEV)) {
 +              i = mtd_read(the_mtd, be32_to_cpup(list),
-+                              sizeof(ath9k_pdata.eeprom_data), &flash_readlen,
++                              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) {
@@ -125,38 +124,28 @@ Subject: [PATCH 37/40] owrt: lantiq: wifi and ethernet eeprom handling
 +                      dev_err(&pdev->dev, "failed to load eeprom address\n");
 +                      return -ENODEV;
 +              }
-+              if (resource_size(eep_res) != ATH9K_PLAT_EEP_MAX_WORDS) {
++              if (resource_size(eep_res) != ATH9K_PLAT_EEP_MAX_WORDS << 1) {
 +                      dev_err(&pdev->dev, "eeprom has an invalid size\n");
 +                      return -EINVAL;
 +              }
 +
 +              eep = ioremap(eep_res->start, resource_size(eep_res));
 +              memcpy_fromio(ath9k_pdata.eeprom_data, eep,
-+                              ATH9K_PLAT_EEP_MAX_WORDS);
++                              ATH9K_PLAT_EEP_MAX_WORDS << 1);
 +      }
 +
-+      if (of_find_property(np, "ath,eep-swap", NULL)) {
-+              ath9k_pdata.endian_check = true;
-+              dev_info(&pdev->dev, "endian check enabled.\n");
++      if (of_find_property(np, "ath,eep-swap", NULL))
 +              for (i = 0; i < ATH9K_PLAT_EEP_MAX_WORDS; i++)
-+                      ath9k_pdata.eeprom_data[i] =
-+                                      swab16(ath9k_pdata.eeprom_data[i]);
-+      }
++                      ath9k_pdata.eeprom_data[i] = swab16(ath9k_pdata.eeprom_data[i]);
 +
-+      if (of_find_property(np, "ath,eep-csum", NULL)) {
-+              sum = ath9k_pdata.eeprom_data[0x200>>1];
-+              el = sum / sizeof(u16) - 2;  /* skip length and (old) checksum */
-+              eepdata = (u16 *) (&ath9k_pdata.eeprom_data[0x204>>1]); /* after checksum */
-+              for (i = 0; i < el; i++)
-+                      sum ^= *eepdata++;
-+              sum ^= 0xffff;
-+              ath9k_pdata.eeprom_data[0x202>>1] = sum;
++      if (of_find_property(np, "ath,eep-endian", NULL)) {
++              ath9k_pdata.endian_check = true;
 +
-+              dev_info(&pdev->dev, "checksum fixed.\n");
++              dev_info(&pdev->dev, "endian check enabled.\n");
 +      }
 +
 +      if (!of_property_read_u32(np, "ath,mac-offset", &mac_offset)) {
-+              memcpy_fromio(athxk_eeprom_mac, (void*) ath9k_pdata.eeprom_data, 6);
++              memcpy_fromio(athxk_eeprom_mac, (void*) ath9k_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");
@@ -205,7 +194,7 @@ Subject: [PATCH 37/40] owrt: lantiq: wifi and ethernet eeprom handling
 +{
 +      return platform_driver_probe(&ath9k_eeprom_driver, of_ath9k_eeprom_probe);
 +}
-+late_initcall(of_ath9k_eeprom_init);
++arch_initcall(of_ath9k_eeprom_init);
 +
 +
 +static int ath5k_pci_plat_dev_init(struct pci_dev *dev)
@@ -235,10 +224,11 @@ Subject: [PATCH 37/40] owrt: lantiq: wifi and ethernet eeprom handling
 +                      mtd_np->name)) && (the_mtd = get_mtd_device_nm(part))
 +                      != ERR_PTR(-ENODEV)) {
 +              i = mtd_read(the_mtd, be32_to_cpup(list),
-+                              sizeof(ath5k_eeprom_data), &flash_readlen,
-+                              (void *) ath5k_eeprom_data);
++                              ATH5K_PLAT_EEP_MAX_WORDS << 1, &flash_readlen,
++                              (void *) ath5k_pdata.eeprom_data);
 +              put_mtd_device(the_mtd);
-+              if ((sizeof(ath5k_eeprom_data) != flash_readlen) || i) {
++              if ((sizeof(ATH5K_PLAT_EEP_MAX_WORDS << 1) != flash_readlen)
++                              || i) {
 +                      dev_err(&pdev->dev, "failed to load eeprom from mtd\n");
 +                      return -ENODEV;
 +              }
@@ -250,21 +240,22 @@ Subject: [PATCH 37/40] owrt: lantiq: wifi and ethernet eeprom handling
 +                      dev_err(&pdev->dev, "failed to load eeprom address\n");
 +                      return -ENODEV;
 +              }
-+              if (resource_size(eep_res) != ATH5K_PLAT_EEP_MAX_WORDS) {
++              if (resource_size(eep_res) != ATH5K_PLAT_EEP_MAX_WORDS << 1) {
 +                      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);
++              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_eeprom_data[i] = swab16(ath5k_eeprom_data[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_eeprom_data, 6);
++              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");
@@ -282,7 +273,6 @@ Subject: [PATCH 37/40] owrt: lantiq: wifi and ethernet eeprom handling
 +      if (!of_property_read_u32(np, "ath,mac-increment", &mac_inc))
 +              athxk_eeprom_mac[5] += mac_inc;
 +
-+      ath5k_pdata.eeprom_data = ath5k_eeprom_data;
 +      ath5k_pdata.macaddr = athxk_eeprom_mac;
 +      ltq_pci_plat_dev_init = ath5k_pci_plat_dev_init;
 +
@@ -308,7 +298,7 @@ Subject: [PATCH 37/40] owrt: lantiq: wifi and ethernet eeprom handling
 +{
 +      return platform_driver_probe(&ath5k_eeprom_driver, of_ath5k_eeprom_probe);
 +}
-+late_initcall(of_ath5k_eeprom_init);
++device_initcall(of_ath5k_eeprom_init);
 --- /dev/null
 +++ b/arch/mips/lantiq/xway/eth_mac.c
 @@ -0,0 +1,76 @@
@@ -596,11 +586,3 @@ Subject: [PATCH 37/40] owrt: lantiq: wifi and ethernet eeprom handling
  
        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);