Changeset 35353


Ignore:
Timestamp:
2013-01-28T18:43:25+01:00 (5 years ago)
Author:
blogic
Message:

[lantiq] Add ath9k eeprom and pci fixup support

Add ath9k eeprom and pci fixup support (again) for linux 3.7.

On linux 3.3, the fixup forced the regdomain to 0x67, causing low TX power.
This patch only corrects checksum, the rest of the EEPROM isn't changed.

Signed-off-by: Álvaro Fernández Rojas <noltari@…>

Location:
trunk/target/linux/lantiq
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/target/linux/lantiq/image/ARV7518PW.dts

    r35077 r35353  
    7373                                        0 0x7f0016 0x6>; 
    7474                                ath,mac-increment = <1>; 
     75                                ath,pci-slot = <14>; 
    7576                                ath,eep-swap; 
     77                                ath,eep-csum; 
    7678                        }; 
    7779                }; 
  • trunk/target/linux/lantiq/patches-3.7/0302-wifi-eep.patch

    r35062 r35353  
    1 Index: linux-3.7-rc8/arch/mips/lantiq/xway/Makefile 
    2 =================================================================== 
    3 --- linux-3.7-rc8.orig/arch/mips/lantiq/xway/Makefile   2012-12-13 10:59:54.176314899 +0100 
    4 +++ linux-3.7-rc8/arch/mips/lantiq/xway/Makefile        2012-12-13 13:58:51.696584083 +0100 
     1Index: linux-3.7.4/arch/mips/lantiq/xway/Makefile 
     2=================================================================== 
     3--- linux-3.7.4.orig/arch/mips/lantiq/xway/Makefile     2013-01-28 18:08:39.000000000 +0100 
     4+++ linux-3.7.4/arch/mips/lantiq/xway/Makefile  2013-01-28 18:10:31.416141818 +0100 
    55@@ -1,3 +1,6 @@ 
    66 obj-y := prom.o sysctrl.o clk.o reset.o dma.o timer.o dcdc.o 
    77  
    88+obj-y += eth_mac.o 
    9 +obj-$(CONFIG_PCI) += ath_eep.o rt_eep.o 
     9+obj-$(CONFIG_PCI) += ath_eep.o rt_eep.o pci-ath-fixup.o 
    1010+ 
    1111 obj-$(CONFIG_XRX200_PHY_FW) += xrx200_phy_fw.o 
    12 Index: linux-3.7-rc8/arch/mips/lantiq/xway/ath_eep.c 
     12Index: linux-3.7.4/arch/mips/lantiq/xway/ath_eep.c 
    1313=================================================================== 
    1414--- /dev/null   1970-01-01 00:00:00.000000000 +0000 
    15 +++ linux-3.7-rc8/arch/mips/lantiq/xway/ath_eep.c       2012-12-13 13:49:12.472569552 +0100 
    16 @@ -0,0 +1,120 @@ 
     15+++ linux-3.7.4/arch/mips/lantiq/xway/ath_eep.c 2013-01-28 18:13:43.256146389 +0100 
     16@@ -0,0 +1,206 @@ 
    1717+/* 
     18+ *  Copyright (C) 2011 Luca Olivetti <luca@ventoso.org> 
    1819+ *  Copyright (C) 2011 John Crispin <blogic@openwrt.org> 
    1920+ *  Copyright (C) 2011 Andrej VlaÅ¡ić <andrej.vlasic0@gmail.com> 
     21+ *  Copyright (C) 2013 Álvaro Fernández Rojas <noltari@gmail.com> 
    2022+ * 
    2123+ *  This program is free software; you can redistribute it and/or modify it 
     
    3133+#include <linux/ath9k_platform.h> 
    3234+#include <linux/pci.h> 
     35+#include <pci-ath-fixup.h> 
    3336+ 
    3437+extern int (*ltq_pci_plat_dev_init)(struct pci_dev *dev); 
    3538+struct ath5k_platform_data ath5k_pdata; 
    36 +/*struct ath9k_platform_data ath9k_pdata = { 
     39+struct ath9k_platform_data ath9k_pdata = { 
    3740+       .led_pin = -1, 
    38 +       .endian_check = true, 
    39 +};*/ 
     41+}; 
    4042+static u16 ath5k_eeprom_data[ATH5K_PLAT_EEP_MAX_WORDS]; 
    41 +//static u16 ath9k_eeprom_data[ATH9K_PLAT_EEP_MAX_WORDS]; 
    4243+static u8 athxk_eeprom_mac[6]; 
    4344+ 
    44 +/*static int 
    45 +ath9k_pci_plat_dev_init(struct pci_dev *dev) 
     45+static int ath9k_pci_plat_dev_init(struct pci_dev *dev) 
    4646+{ 
    4747+       dev->dev.platform_data = &ath9k_pdata; 
     
    4949+} 
    5050+ 
    51 +void __init 
    52 +ltq_register_ath9k(u16 *eeprom_data, u8 *macaddr) 
    53 +{ 
    54 +       memcpy(ath9k_pdata.eeprom_data, eeprom_data, sizeof(ath9k_pdata.eeprom_data)); 
    55 +       ath9k_pdata.macaddr = macaddr; 
     51+int __init of_ath9k_eeprom_probe(struct platform_device *pdev) 
     52+{ 
     53+       struct device_node *np = pdev->dev.of_node; 
     54+       struct resource *eep_res, *mac_res; 
     55+       void __iomem *eep, *mac; 
     56+       int mac_offset; 
     57+       u32 mac_inc = 0, pci_slot = 0; 
     58+       int i; 
     59+       u16 *eepdata, sum, el; 
     60+ 
     61+       eep_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 
     62+       mac_res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 
     63+ 
     64+       if (!eep_res) { 
     65+               dev_err(&pdev->dev, "failed to load eeprom address\n"); 
     66+               return -ENODEV; 
     67+       } 
     68+       if (resource_size(eep_res) != ATH9K_PLAT_EEP_MAX_WORDS) { 
     69+               dev_err(&pdev->dev, "eeprom has an invalid size\n"); 
     70+               return -EINVAL; 
     71+       } 
     72+ 
     73+       eep = ioremap(eep_res->start, resource_size(eep_res)); 
     74+       memcpy_fromio(ath9k_pdata.eeprom_data, eep, ATH9K_PLAT_EEP_MAX_WORDS); 
     75+ 
     76+       if (of_find_property(np, "ath,eep-swap", NULL)) { 
     77+               ath9k_pdata.endian_check = true; 
     78+ 
     79+               dev_info(&pdev->dev, "endian check enabled.\n"); 
     80+       } 
     81+ 
     82+       if (of_find_property(np, "ath,eep-csum", NULL)) { 
     83+               sum = ath9k_pdata.eeprom_data[0x200>>1]; 
     84+               el = sum / sizeof(u16) - 2;  /* skip length and (old) checksum */ 
     85+               eepdata = (u16 *) (&ath9k_pdata.eeprom_data[0x204>>1]); /* after checksum */ 
     86+               for (i = 0; i < el; i++) 
     87+                       sum ^= *eepdata++; 
     88+               sum ^= 0xffff; 
     89+               ath9k_pdata.eeprom_data[0x202>>1] = sum; 
     90+ 
     91+               dev_info(&pdev->dev, "checksum fixed.\n"); 
     92+       } 
     93+ 
     94+       if (!of_property_read_u32(np, "ath,mac-offset", &mac_offset)) { 
     95+               memcpy_fromio(athxk_eeprom_mac, (void*) ath9k_pdata.eeprom_data, 6); 
     96+       } else if (mac_res) { 
     97+               if (resource_size(mac_res) != 6) { 
     98+                       dev_err(&pdev->dev, "mac has an invalid size\n"); 
     99+                       return -EINVAL; 
     100+               } 
     101+               mac = ioremap(mac_res->start, resource_size(mac_res)); 
     102+               memcpy_fromio(athxk_eeprom_mac, mac, 6); 
     103+       } else { 
     104+               dev_warn(&pdev->dev, "using random mac\n"); 
     105+               random_ether_addr(athxk_eeprom_mac); 
     106+       } 
     107+ 
     108+       if (!of_property_read_u32(np, "ath,mac-increment", &mac_inc)) 
     109+               athxk_eeprom_mac[5] += mac_inc; 
     110+ 
     111+       ath9k_pdata.macaddr = athxk_eeprom_mac; 
    56112+       ltq_pci_plat_dev_init = ath9k_pci_plat_dev_init; 
    57 +} 
    58 +*/ 
     113+ 
     114+       if (!of_property_read_u32(np, "ath,pci-slot", &pci_slot)) { 
     115+               ltq_pci_ath_fixup(pci_slot, ath9k_pdata.eeprom_data); 
     116+ 
     117+               dev_info(&pdev->dev, "pci slot: %u\n", pci_slot); 
     118+       } 
     119+ 
     120+       dev_info(&pdev->dev, "loaded ath9k eeprom\n"); 
     121+ 
     122+       return 0; 
     123+} 
     124+ 
     125+static struct of_device_id ath9k_eeprom_ids[] = { 
     126+       { .compatible = "ath9k,eeprom" }, 
     127+       { } 
     128+}; 
     129+ 
     130+static struct platform_driver ath9k_eeprom_driver = { 
     131+       .driver         = { 
     132+               .name           = "ath9k,eeprom", 
     133+               .owner  = THIS_MODULE, 
     134+               .of_match_table = of_match_ptr(ath9k_eeprom_ids), 
     135+       }, 
     136+}; 
     137+ 
     138+static int __init of_ath9k_eeprom_init(void) 
     139+{ 
     140+       return platform_driver_probe(&ath9k_eeprom_driver, of_ath9k_eeprom_probe); 
     141+} 
     142+arch_initcall(of_ath9k_eeprom_init); 
     143+ 
     144+ 
    59145+static int ath5k_pci_plat_dev_init(struct pci_dev *dev) 
    60146+{ 
     
    135221+} 
    136222+device_initcall(of_ath5k_eeprom_init); 
    137 Index: linux-3.7-rc8/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h 
    138 =================================================================== 
    139 --- linux-3.7-rc8.orig/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h      2012-12-13 10:59:57.300314976 +0100 
    140 +++ linux-3.7-rc8/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h   2012-12-13 10:59:57.308314977 +0100 
    141 @@ -93,5 +93,8 @@ 
    142  /* allow tapi driver to read the gptu value */ 
    143  long gptu_get_count(struct clk *clk); 
     223Index: linux-3.7.4/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h 
     224=================================================================== 
     225--- linux-3.7.4.orig/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h        2013-01-28 18:08:38.000000000 +0100 
     226+++ linux-3.7.4/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h     2013-01-28 18:10:03.616141155 +0100 
     227@@ -90,5 +90,8 @@ 
     228 extern void ltq_pmu_enable(unsigned int module); 
     229 extern void ltq_pmu_disable(unsigned int module); 
    144230  
    145231+/* allow the ethernet driver to load a flash mapped mac addr */ 
     
    148234 #endif /* CONFIG_SOC_TYPE_XWAY */ 
    149235 #endif /* _LTQ_XWAY_H__ */ 
    150 Index: linux-3.7-rc8/arch/mips/lantiq/xway/eth_mac.c 
     236Index: linux-3.7.4/arch/mips/lantiq/xway/eth_mac.c 
    151237=================================================================== 
    152238--- /dev/null   1970-01-01 00:00:00.000000000 +0000 
    153 +++ linux-3.7-rc8/arch/mips/lantiq/xway/eth_mac.c       2012-12-13 10:59:57.308314977 +0100 
     239+++ linux-3.7.4/arch/mips/lantiq/xway/eth_mac.c 2013-01-28 18:10:03.620141154 +0100 
    154240@@ -0,0 +1,76 @@ 
    155241+/* 
     
    229315+} 
    230316+device_initcall(of_eth_mac_init); 
    231 Index: linux-3.7-rc8/drivers/net/ethernet/lantiq_etop.c 
    232 =================================================================== 
    233 --- linux-3.7-rc8.orig/drivers/net/ethernet/lantiq_etop.c       2012-12-13 10:59:54.176314899 +0100 
    234 +++ linux-3.7-rc8/drivers/net/ethernet/lantiq_etop.c    2012-12-13 10:59:57.308314977 +0100 
    235 @@ -816,7 +816,8 @@ 
     317Index: linux-3.7.4/drivers/net/ethernet/lantiq_etop.c 
     318=================================================================== 
     319--- linux-3.7.4.orig/drivers/net/ethernet/lantiq_etop.c 2013-01-28 18:08:39.000000000 +0100 
     320+++ linux-3.7.4/drivers/net/ethernet/lantiq_etop.c      2013-01-28 18:10:03.620141154 +0100 
     321@@ -825,7 +825,8 @@ 
    236322  
    237323        ltq_etop_change_mtu(dev, 1500); 
     
    243329                pr_warn("etop: invalid MAC, using random\n"); 
    244330                random_ether_addr(mac.sa_data); 
    245 @@ -940,7 +941,9 @@ 
     331@@ -949,7 +950,9 @@ 
    246332        priv->tx_irq = irqres[0].start; 
    247333        priv->rx_irq = irqres[1].start; 
     
    254340        priv->clk_ppe = clk_get(&pdev->dev, NULL); 
    255341        if (IS_ERR(priv->clk_ppe)) 
    256 Index: linux-3.7-rc8/arch/mips/lantiq/xway/rt_eep.c 
     342Index: linux-3.7.4/arch/mips/lantiq/xway/rt_eep.c 
    257343=================================================================== 
    258344--- /dev/null   1970-01-01 00:00:00.000000000 +0000 
    259 +++ linux-3.7-rc8/arch/mips/lantiq/xway/rt_eep.c        2012-12-13 13:55:43.132579350 +0100 
     345+++ linux-3.7.4/arch/mips/lantiq/xway/rt_eep.c  2013-01-28 18:10:03.620141154 +0100 
    260346@@ -0,0 +1,60 @@ 
    261347+/* 
     
    319405+} 
    320406+device_initcall(of_ralink_eeprom_init); 
     407Index: linux-3.7.4/arch/mips/include/asm/mach-lantiq/pci-ath-fixup.h 
     408=================================================================== 
     409--- /dev/null   1970-01-01 00:00:00.000000000 +0000 
     410+++ linux-3.7.4/arch/mips/include/asm/mach-lantiq/pci-ath-fixup.h       2013-01-28 18:10:03.620141154 +0100 
     411@@ -0,0 +1,6 @@ 
     412+#ifndef _PCI_ATH_FIXUP 
     413+#define _PCI_ATH_FIXUP 
     414+ 
     415+void ltq_pci_ath_fixup(unsigned slot, u16 *cal_data) __init; 
     416+ 
     417+#endif /* _PCI_ATH_FIXUP */ 
     418Index: linux-3.7.4/arch/mips/lantiq/xway/pci-ath-fixup.c 
     419=================================================================== 
     420--- /dev/null   1970-01-01 00:00:00.000000000 +0000 
     421+++ linux-3.7.4/arch/mips/lantiq/xway/pci-ath-fixup.c   2013-01-28 18:10:03.624141153 +0100 
     422@@ -0,0 +1,109 @@ 
     423+/* 
     424+ *  Atheros AP94 reference board PCI initialization 
     425+ * 
     426+ *  Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org> 
     427+ * 
     428+ *  This program is free software; you can redistribute it and/or modify it 
     429+ *  under the terms of the GNU General Public License version 2 as published 
     430+ *  by the Free Software Foundation. 
     431+ */ 
     432+ 
     433+#include <linux/pci.h> 
     434+#include <linux/init.h> 
     435+#include <linux/delay.h> 
     436+#include <lantiq_soc.h> 
     437+ 
     438+#define LTQ_PCI_MEM_BASE               0x18000000 
     439+ 
     440+struct ath_fixup { 
     441+       u16             *cal_data; 
     442+       unsigned        slot; 
     443+}; 
     444+ 
     445+static int ath_num_fixups; 
     446+static struct ath_fixup ath_fixups[2]; 
     447+ 
     448+static void ath_pci_fixup(struct pci_dev *dev) 
     449+{ 
     450+       void __iomem *mem; 
     451+       u16 *cal_data = NULL; 
     452+       u16 cmd; 
     453+       u32 bar0; 
     454+       u32 val; 
     455+       unsigned i; 
     456+ 
     457+       for (i = 0; i < ath_num_fixups; i++) { 
     458+               if (ath_fixups[i].cal_data == NULL) 
     459+                       continue; 
     460+ 
     461+               if (ath_fixups[i].slot != PCI_SLOT(dev->devfn)) 
     462+                       continue; 
     463+ 
     464+               cal_data = ath_fixups[i].cal_data; 
     465+               break; 
     466+       } 
     467+ 
     468+       if (cal_data == NULL) 
     469+               return; 
     470+ 
     471+       if (*cal_data != 0xa55a) { 
     472+               pr_err("pci %s: invalid calibration data\n", pci_name(dev)); 
     473+               return; 
     474+       } 
     475+ 
     476+       pr_info("pci %s: fixup device configuration\n", pci_name(dev)); 
     477+ 
     478+       mem = ioremap(LTQ_PCI_MEM_BASE, 0x10000); 
     479+       if (!mem) { 
     480+               pr_err("pci %s: ioremap error\n", pci_name(dev)); 
     481+               return; 
     482+       } 
     483+ 
     484+       pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &bar0); 
     485+       pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, LTQ_PCI_MEM_BASE); 
     486+       pci_read_config_word(dev, PCI_COMMAND, &cmd); 
     487+       cmd |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY; 
     488+       pci_write_config_word(dev, PCI_COMMAND, cmd); 
     489+ 
     490+       /* set pointer to first reg address */ 
     491+       cal_data += 3; 
     492+       while (*cal_data != 0xffff) { 
     493+               u32 reg; 
     494+               reg = *cal_data++; 
     495+               val = *cal_data++; 
     496+               val |= (*cal_data++) << 16; 
     497+ 
     498+               ltq_w32(swab32(val), mem + reg); 
     499+               udelay(100); 
     500+       } 
     501+ 
     502+       pci_read_config_dword(dev, PCI_VENDOR_ID, &val); 
     503+       dev->vendor = val & 0xffff; 
     504+       dev->device = (val >> 16) & 0xffff; 
     505+ 
     506+       pci_read_config_dword(dev, PCI_CLASS_REVISION, &val); 
     507+       dev->revision = val & 0xff; 
     508+       dev->class = val >> 8; /* upper 3 bytes */ 
     509+ 
     510+       pr_info("pci %s: fixup info: [%04x:%04x] revision %02x class %#08x\n",  
     511+               pci_name(dev), dev->vendor, dev->device, dev->revision, dev->class); 
     512+ 
     513+       pci_read_config_word(dev, PCI_COMMAND, &cmd); 
     514+       cmd &= ~(PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY); 
     515+       pci_write_config_word(dev, PCI_COMMAND, cmd); 
     516+ 
     517+       pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, bar0); 
     518+ 
     519+       iounmap(mem); 
     520+} 
     521+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_ATHEROS, PCI_ANY_ID, ath_pci_fixup); 
     522+ 
     523+void __init ltq_pci_ath_fixup(unsigned slot, u16 *cal_data) 
     524+{ 
     525+       if (ath_num_fixups >= ARRAY_SIZE(ath_fixups)) 
     526+               return; 
     527+ 
     528+       ath_fixups[ath_num_fixups].slot = slot; 
     529+       ath_fixups[ath_num_fixups].cal_data = cal_data; 
     530+       ath_num_fixups++; 
     531+} 
  • trunk/target/linux/lantiq/patches-3.7/0303-vmmc.patch

    r35062 r35353  
    1 Index: linux-3.7.1/arch/mips/lantiq/xway/Makefile 
     1Index: linux-3.7.4/arch/mips/lantiq/xway/Makefile 
    22=================================================================== 
    3 --- linux-3.7.1.orig/arch/mips/lantiq/xway/Makefile     2013-01-09 09:30:35.000000000 +0100 
    4 +++ linux-3.7.1/arch/mips/lantiq/xway/Makefile  2013-01-09 09:33:03.932167465 +0100 
     3--- linux-3.7.4.orig/arch/mips/lantiq/xway/Makefile     2013-01-28 18:10:31.000000000 +0100 
     4+++ linux-3.7.4/arch/mips/lantiq/xway/Makefile  2013-01-28 18:14:12.224147075 +0100 
    55@@ -1,6 +1,6 @@ 
    66 obj-y := prom.o sysctrl.o clk.o reset.o dma.o timer.o dcdc.o 
     
    88-obj-y += eth_mac.o 
    99+obj-y += eth_mac.o vmmc.o 
    10  obj-$(CONFIG_PCI) += ath_eep.o rt_eep.o 
     10 obj-$(CONFIG_PCI) += ath_eep.o rt_eep.o pci-ath-fixup.o 
    1111  
    1212 obj-$(CONFIG_XRX200_PHY_FW) += xrx200_phy_fw.o 
    13 Index: linux-3.7.1/arch/mips/lantiq/xway/vmmc.c 
     13Index: linux-3.7.4/arch/mips/lantiq/xway/vmmc.c 
    1414=================================================================== 
    1515--- /dev/null   1970-01-01 00:00:00.000000000 +0000 
    16 +++ linux-3.7.1/arch/mips/lantiq/xway/vmmc.c    2013-01-09 09:31:49.264164272 +0100 
     16+++ linux-3.7.4/arch/mips/lantiq/xway/vmmc.c    2013-01-28 18:13:53.128146621 +0100 
    1717@@ -0,0 +1,63 @@ 
    1818+/* 
Note: See TracChangeset for help on using the changeset viewer.