[OpenWrt-Devel] [PATCH] [lantiq] [1/2] EEPROM fix for Astoria/Arcadyan boards.

2014-05-16 Thread José Vázquez Fernández
EEPROM fix for Astoria/Arcadyan boards.

This patch fixes a problem in some Astoria/Arcadyan routers with Atheros
based wireless. In these boards the flash partition that contains the
MAC and calibration data is not read properly, causing the driver to not
initialize the wireless.

[   13.772000] PCI: Enabling device :00:0e.0 ( - 0002)
[   13.776000] ath5k :00:0e.0: registered as 'phy0'
[   15.024000] ath5k: phy0: unable to init EEPROM
[   15.024000] ath5k: probe of :00:0e.0 failed with error -5

This patch covers both ath5k and ath9k drivers.

Signed off by: David Fernández papijunkm...@yahoo.com
Signed off by: Bruno Rodríguez bruno.rodriguez.1...@gmail.com
Signed off by: Álvaro Fernández nolt...@gmail.com
Tested by: José Vázquez Fernández ppvazquez...@gmail.com


--- a/arch/mips/lantiq/xway/ath_eep.c
+++ b/arch/mips/lantiq/xway/ath_eep.c
@@ -41,94 +41,182 @@ int __init of_ath9k_eeprom_probe(struct
 {
struct device_node *np = pdev-dev.of_node, *mtd_np;
int mac_offset, led_pin;
+   struct resource *eep_res, *mac_res;
+   void __iomem *eep, *mac;
+   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;
const char *part;
phandle phandle;
 
-   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 (!of_find_property(np,ath,arv-ath9k-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;
-   }
+   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;
-   }
+   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;
-   }
+   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),
+   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;
-   }
+   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))
-   for (i = 0; i  ATH9K_PLAT_EEP_MAX_WORDS; i++)
-   ath9k_pdata.eeprom_data[i] = 
swab16(ath9k_pdata.eeprom_data[i]);
+   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]);
+
+   if (of_find_property(np, ath,eep-endian, NULL)) {
+   ath9k_pdata.endian_check = true;
+   dev_info(pdev-dev, endian check enabled.\n);
+   }
 
-   if (of_find_property(np, ath,eep-endian, NULL)) {
-   ath9k_pdata.endian_check = true;
+   if (!of_property_read_u32(np, ath,mac-offset, mac_offset)) {
+   memcpy_fromio(athxk_eeprom_mac, (void*) 
ath9k_pdata.eeprom_data +
mac_offset, 6);
+   

[OpenWrt-Devel] [PATCH] [lantiq] [1/2] EEPROM fix for Astoria/Arcadyan boards.

2014-05-16 Thread José Vázquez Fernández
- Mensaje reenviado 
De: José Vázquez Fernández ppvazquez...@gmail.com
Para: openwrt-devel openwrt-devel@lists.openwrt.org
Asunto: [OpenWrt-Devel] [PATCH] [lantiq] [1/2] EEPROM fix for
Astoria/Arcadyan boards.
Fecha: Fri, 16 May 2014 19:47:03 +0200

EEPROM fix for Astoria/Arcadyan boards.

This patch fixes a problem in some Astoria/Arcadyan routers with Atheros
based wireless. In these boards the flash partition that contains the
MAC and calibration data is not read properly, causing the driver to not
initialize the wireless.

[   13.772000] PCI: Enabling device :00:0e.0 ( - 0002)
[   13.776000] ath5k :00:0e.0: registered as 'phy0'
[   15.024000] ath5k: phy0: unable to init EEPROM
[   15.024000] ath5k: probe of :00:0e.0 failed with error -5

This patch covers both ath5k and ath9k drivers.

Signed off by: David Fernández papijunkm...@yahoo.com
Signed off by: Bruno Rodríguez bruno.rodriguez.1...@gmail.com
Signed off by: Álvaro Fernández nolt...@gmail.com
Tested by: José Vázquez Fernández ppvazquez...@gmail.com


Index: target/linux/lantiq/patches-3.10/0203-arv-athx-workaround.patch
===
--- target/linux/lantiq/patches-3.10/0203-arv-athx-workaround.patch
(revisión: 0)
+++ target/linux/lantiq/patches-3.10/0203-arv-athx-workaround.patch
(revisión: 0)
@@ -0,0 +1,447 @@
+--- a/arch/mips/lantiq/xway/ath_eep.c
 b/arch/mips/lantiq/xway/ath_eep.c
+@@ -41,94 +41,182 @@ int __init of_ath9k_eeprom_probe(struct
+ {
+   struct device_node *np = pdev-dev.of_node, *mtd_np;
+   int mac_offset, led_pin;
++  struct resource *eep_res, *mac_res;
++  void __iomem *eep, *mac;
++  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;
+   const char *part;
+   phandle phandle;
+ 
+-  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 (!of_find_property(np,ath,arv-ath9k-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;
+-  }
++  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;
+-  }
++  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;
+-  }
++  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),
++  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;
+-  }
++  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))
+-  for (i = 0; i  ATH9K_PLAT_EEP_MAX_WORDS; i++)
+-  ath9k_pdata.eeprom_data[i] = 
swab16(ath9k_pdata.eeprom_data[i]);
++  if (of_find_property(np, ath,eep-swap, NULL))
++  for (i = 0; i  ATH9K_PLAT_EEP_MAX_WORDS; i