@ -9,7 +9,7 @@
obj-$(CONFIG_XRX200_PHY_FW) += xrx200_phy_fw.o
obj-$(CONFIG_XRX200_PHY_FW) += xrx200_phy_fw.o
--- /dev/null
--- /dev/null
+++ b/arch/mips/lantiq/xway/ath_eep.c
+++ b/arch/mips/lantiq/xway/ath_eep.c
@@ -0,0 +1,206 @@
@@ -0,0 +1,195 @@
+/*
+/*
+ * Copyright (C) 2011 Luca Olivetti <luca@ventoso.org>
+ * Copyright (C) 2011 Luca Olivetti <luca@ventoso.org>
+ * Copyright (C) 2011 John Crispin <blogic@openwrt.org>
+ * Copyright (C) 2011 John Crispin <blogic@openwrt.org>
@ -35,7 +35,6 @@
+struct ath9k_platform_data ath9k_pdata = {
+struct ath9k_platform_data ath9k_pdata = {
+ .led_pin = -1,
+ .led_pin = -1,
+};
+};
+static u16 ath5k_eeprom_data[ATH5K_PLAT_EEP_MAX_WORDS];
+static u8 athxk_eeprom_mac[6];
+static u8 athxk_eeprom_mac[6];
+
+
+static int ath9k_pci_plat_dev_init(struct pci_dev *dev)
+static int ath9k_pci_plat_dev_init(struct pci_dev *dev)
@ -52,7 +51,6 @@
+ int mac_offset;
+ int mac_offset;
+ u32 mac_inc = 0, pci_slot = 0;
+ u32 mac_inc = 0, pci_slot = 0;
+ int i;
+ int i;
+ u16 *eepdata, sum, el;
+
+
+ eep_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ eep_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ mac_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+ mac_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
@ -61,34 +59,26 @@
+ dev_err(&pdev->dev, "failed to load eeprom address\n");
+ dev_err(&pdev->dev, "failed to load eeprom address\n");
+ return -ENODEV;
+ 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");
+ dev_err(&pdev->dev, "eeprom has an invalid size\n");
+ return -EINVAL;
+ return -EINVAL;
+ }
+ }
+
+
+ eep = ioremap(eep_res->start, resource_size(eep_res));
+ eep = ioremap(eep_res->start, resource_size(eep_res));
+ memcpy_fromio(ath9k_pdata.eeprom_data, eep, ATH9K_PLAT_EEP_MAX_WORDS);
+ memcpy_fromio(ath9k_pdata.eeprom_data, eep, ATH9K_PLAT_EEP_MAX_WORDS << 1 );
+
+
+ if (of_find_property(np, "ath,eep-swap", NULL)) {
+ 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;
+ ath9k_pdata.endian_check = true;
+
+
+ dev_info(&pdev->dev, "endian check enabled.\n");
+ 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)) {
+ 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) {
+ } else if (mac_res) {
+ if (resource_size(mac_res) != 6) {
+ if (resource_size(mac_res) != 6) {
+ dev_err(&pdev->dev, "mac has an invalid size\n");
+ dev_err(&pdev->dev, "mac has an invalid size\n");
@ -135,7 +125,7 @@
+{
+{
+ return platform_driver_probe(&ath9k_eeprom_driver, of_ath9k_eeprom_probe);
+ 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)
+static int ath5k_pci_plat_dev_init(struct pci_dev *dev)
@ -160,20 +150,20 @@
+ dev_err(&pdev->dev, "failed to load eeprom address\n");
+ dev_err(&pdev->dev, "failed to load eeprom address\n");
+ return -ENODEV;
+ 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");
+ dev_err(&pdev->dev, "eeprom has an invalid size\n");
+ return -EINVAL;
+ return -EINVAL;
+ }
+ }
+
+
+ eep = ioremap(eep_res->start, resource_size(eep_res));
+ 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))
+ if (of_find_property(np, "ath,eep-swap", NULL))
+ for (i = 0; i < ( ATH5K_PLAT_EEP_MAX_WORDS >> 1) ; i++)
+ 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)) {
+ 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) {
+ } else if (mac_res) {
+ if (resource_size(mac_res) != 6) {
+ if (resource_size(mac_res) != 6) {
+ dev_err(&pdev->dev, "mac has an invalid size\n");
+ dev_err(&pdev->dev, "mac has an invalid size\n");
@ -189,7 +179,6 @@
+ if (!of_property_read_u32(np, "ath,mac-increment", &mac_inc))
+ if (!of_property_read_u32(np, "ath,mac-increment", &mac_inc))
+ athxk_eeprom_mac[5] += mac_inc;
+ athxk_eeprom_mac[5] += mac_inc;
+
+
+ ath5k_pdata.eeprom_data = ath5k_eeprom_data;
+ ath5k_pdata.macaddr = athxk_eeprom_mac;
+ ath5k_pdata.macaddr = athxk_eeprom_mac;
+ ltq_pci_plat_dev_init = ath5k_pci_plat_dev_init;
+ ltq_pci_plat_dev_init = ath5k_pci_plat_dev_init;
+
+
@ -215,7 +204,7 @@
+{
+{
+ return platform_driver_probe(&ath5k_eeprom_driver, of_ath5k_eeprom_probe);
+ return platform_driver_probe(&ath5k_eeprom_driver, of_ath5k_eeprom_probe);
+}
+}
+devic e_initcall(of_ath5k_eeprom_init);
+lat e_initcall(of_ath5k_eeprom_init);
--- a/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h
--- a/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h
+++ b/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,
@@ -90,5 +90,8 @@ int xrx200_gphy_boot(struct device *dev,