X-Git-Url: https://git.archive.openwrt.org/?a=blobdiff_plain;f=target%2Flinux%2Flantiq%2Fpatches-3.8%2F0037-owrt-lantiq-wifi-and-ethernet-eeprom-handling.patch;h=e98a4c08aeed65f24bca37cf91d9fc5b2cd2f40f;hb=a4c4a82647099a5d42afa8adb1e5eae1e0919797;hp=4460961c6bb101c84eec572bac6479e54a322d14;hpb=d5d3a4d87b61b8dfbc59df0670bdb028e8e69dd5;p=15.05%2Fopenwrt.git diff --git a/target/linux/lantiq/patches-3.8/0037-owrt-lantiq-wifi-and-ethernet-eeprom-handling.patch b/target/linux/lantiq/patches-3.8/0037-owrt-lantiq-wifi-and-ethernet-eeprom-handling.patch index 4460961c6b..e98a4c08ae 100644 --- a/target/linux/lantiq/patches-3.8/0037-owrt-lantiq-wifi-and-ethernet-eeprom-handling.patch +++ b/target/linux/lantiq/patches-3.8/0037-owrt-lantiq-wifi-and-ethernet-eeprom-handling.patch @@ -19,9 +19,6 @@ Subject: [PATCH 37/40] owrt: lantiq: wifi and ethernet eeprom handling create mode 100644 arch/mips/lantiq/xway/pci-ath-fixup.c create mode 100644 arch/mips/lantiq/xway/rt_eep.c -diff --git a/arch/mips/include/asm/mach-lantiq/pci-ath-fixup.h b/arch/mips/include/asm/mach-lantiq/pci-ath-fixup.h -new file mode 100644 -index 0000000..095d2619 --- /dev/null +++ b/arch/mips/include/asm/mach-lantiq/pci-ath-fixup.h @@ -0,0 +1,6 @@ @@ -31,11 +28,9 @@ index 0000000..095d2619 +void ltq_pci_ath_fixup(unsigned slot, u16 *cal_data) __init; + +#endif /* _PCI_ATH_FIXUP */ -diff --git a/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h b/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h -index 133336b..779715c 100644 --- a/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h +++ b/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h -@@ -90,5 +90,8 @@ int xrx200_gphy_boot(struct device *dev, unsigned int id, dma_addr_t dev_addr); +@@ -90,5 +90,8 @@ int xrx200_gphy_boot(struct device *dev, extern void ltq_pmu_enable(unsigned int module); extern void ltq_pmu_disable(unsigned int module); @@ -44,8 +39,6 @@ index 133336b..779715c 100644 + #endif /* CONFIG_SOC_TYPE_XWAY */ #endif /* _LTQ_XWAY_H__ */ -diff --git a/arch/mips/lantiq/xway/Makefile b/arch/mips/lantiq/xway/Makefile -index 087497d..51f0eba 100644 --- a/arch/mips/lantiq/xway/Makefile +++ b/arch/mips/lantiq/xway/Makefile @@ -1,3 +1,6 @@ @@ -55,17 +48,15 @@ index 087497d..51f0eba 100644 +obj-$(CONFIG_PCI) += ath_eep.o rt_eep.o pci-ath-fixup.o + obj-$(CONFIG_XRX200_PHY_FW) += xrx200_phy_fw.o -diff --git a/arch/mips/lantiq/xway/ath_eep.c b/arch/mips/lantiq/xway/ath_eep.c -new file mode 100644 -index 0000000..96da7c1 --- /dev/null +++ b/arch/mips/lantiq/xway/ath_eep.c -@@ -0,0 +1,206 @@ +@@ -0,0 +1,248 @@ +/* + * Copyright (C) 2011 Luca Olivetti + * Copyright (C) 2011 John Crispin + * Copyright (C) 2011 Andrej VlaÅ¡ić + * Copyright (C) 2013 Álvaro Fernández Rojas ++ * Copyright (C) 2013 Daniel Gimpelevich + * + * 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,14 +70,16 @@ index 0000000..96da7c1 +#include +#include +#include ++#include ++#include +#include ++#include + +extern int (*ltq_pci_plat_dev_init)(struct pci_dev *dev); +struct ath5k_platform_data ath5k_pdata; +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) @@ -97,49 +90,62 @@ index 0000000..96da7c1 + +int __init of_ath9k_eeprom_probe(struct platform_device *pdev) +{ -+ struct device_node *np = pdev->dev.of_node; -+ struct resource *eep_res, *mac_res; ++ struct device_node *np = pdev->dev.of_node, *mtd_np; ++ struct resource *eep_res, *mac_res = NULL; + 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; ++ ++ 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); ++ 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); + -+ 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 (resource_size(eep_res) != ATH9K_PLAT_EEP_MAX_WORDS << 1) { ++ dev_err(&pdev->dev, "eeprom has an invalid size\n"); ++ return -EINVAL; ++ } + -+ 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) { -+ 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 << 1); + } + -+ eep = ioremap(eep_res->start, resource_size(eep_res)); -+ memcpy_fromio(ath9k_pdata.eeprom_data, eep, ATH9K_PLAT_EEP_MAX_WORDS); ++ 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)) { ++ 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-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; -+ -+ dev_info(&pdev->dev, "checksum fixed.\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"); @@ -147,7 +153,9 @@ index 0000000..96da7c1 + } + 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); + } @@ -186,7 +194,7 @@ index 0000000..96da7c1 +{ + return platform_driver_probe(&ath9k_eeprom_driver, of_ath9k_eeprom_probe); +} -+arch_initcall(of_ath9k_eeprom_init); ++late_initcall(of_ath9k_eeprom_init); + + +static int ath5k_pci_plat_dev_init(struct pci_dev *dev) @@ -197,34 +205,57 @@ index 0000000..96da7c1 + +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 device_node *np = pdev->dev.of_node, *mtd_np; ++ struct resource *eep_res, *mac_res = NULL; + void __iomem *eep, *mac; + int mac_offset; + u32 mac_inc = 0; + int i; ++ 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)) { ++ i = mtd_read(the_mtd, be32_to_cpup(list), ++ 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) { ++ 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); + -+ 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 (resource_size(eep_res) != ATH5K_PLAT_EEP_MAX_WORDS << 1) { ++ dev_err(&pdev->dev, "eeprom has an invalid size\n"); ++ return -EINVAL; ++ } + -+ if (!eep_res) { -+ dev_err(&pdev->dev, "failed to load eeprom address\n"); -+ return -ENODEV; ++ eep = ioremap(eep_res->start, resource_size(eep_res)); ++ memcpy_fromio(ath5k_pdata.eeprom_data, eep, ++ ATH5K_PLAT_EEP_MAX_WORDS << 1); + } -+ 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_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"); @@ -232,7 +263,9 @@ index 0000000..96da7c1 + } + 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); + } @@ -240,7 +273,6 @@ index 0000000..96da7c1 + 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; + @@ -266,10 +298,7 @@ index 0000000..96da7c1 +{ + return platform_driver_probe(&ath5k_eeprom_driver, of_ath5k_eeprom_probe); +} -+device_initcall(of_ath5k_eeprom_init); -diff --git a/arch/mips/lantiq/xway/eth_mac.c b/arch/mips/lantiq/xway/eth_mac.c -new file mode 100644 -index 0000000..d288a0e ++late_initcall(of_ath5k_eeprom_init); --- /dev/null +++ b/arch/mips/lantiq/xway/eth_mac.c @@ -0,0 +1,76 @@ @@ -349,9 +378,6 @@ index 0000000..d288a0e + return platform_driver_probe(ð_mac_driver, of_eth_mac_probe); +} +device_initcall(of_eth_mac_init); -diff --git a/arch/mips/lantiq/xway/pci-ath-fixup.c b/arch/mips/lantiq/xway/pci-ath-fixup.c -new file mode 100644 -index 0000000..c87ffb2 --- /dev/null +++ b/arch/mips/lantiq/xway/pci-ath-fixup.c @@ -0,0 +1,109 @@ @@ -464,9 +490,6 @@ index 0000000..c87ffb2 + ath_fixups[ath_num_fixups].cal_data = cal_data; + ath_num_fixups++; +} -diff --git a/arch/mips/lantiq/xway/rt_eep.c b/arch/mips/lantiq/xway/rt_eep.c -new file mode 100644 -index 0000000..00f2d4c --- /dev/null +++ b/arch/mips/lantiq/xway/rt_eep.c @@ -0,0 +1,60 @@ @@ -530,8 +553,6 @@ index 0000000..00f2d4c + return platform_driver_probe(&ralink_eeprom_driver, of_ralink_eeprom_probe); +} +device_initcall(of_ralink_eeprom_init); -diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c -index 91a37f1..fa23a7e 100644 --- a/drivers/net/ethernet/lantiq_etop.c +++ b/drivers/net/ethernet/lantiq_etop.c @@ -826,7 +826,8 @@ ltq_etop_init(struct net_device *dev) @@ -544,7 +565,7 @@ index 91a37f1..fa23a7e 100644 if (!is_valid_ether_addr(mac.sa_data)) { pr_warn("etop: invalid MAC, using random\n"); random_ether_addr(mac.sa_data); -@@ -885,8 +886,7 @@ static const struct net_device_ops ltq_eth_netdev_ops = { +@@ -885,8 +886,7 @@ static const struct net_device_ops ltq_e .ndo_tx_timeout = ltq_etop_tx_timeout, }; @@ -554,7 +575,7 @@ index 91a37f1..fa23a7e 100644 { struct net_device *dev; struct ltq_etop_priv *priv; -@@ -950,7 +950,9 @@ ltq_etop_probe(struct platform_device *pdev) +@@ -950,7 +950,9 @@ ltq_etop_probe(struct platform_device *p priv->tx_irq = irqres[0].start; priv->rx_irq = irqres[1].start; priv->mii_mode = of_get_phy_mode(pdev->dev.of_node); @@ -565,6 +586,11 @@ index 91a37f1..fa23a7e 100644 priv->clk_ppe = clk_get(&pdev->dev, NULL); if (IS_ERR(priv->clk_ppe)) --- -1.7.10.4 - +--- 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);