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
6 obj-y := prom.o sysctrl.o clk.o reset.o dma.o timer.o dcdc.o
8 +obj-y += ath_eep.o rt_eep.o eth_mac.o
10 obj-$(CONFIG_XRX200_PHY_FW) += xrx200_phy_fw.o
11 Index: linux-3.7-rc8/arch/mips/lantiq/xway/ath_eep.c
12 ===================================================================
13 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
14 +++ linux-3.7-rc8/arch/mips/lantiq/xway/ath_eep.c 2012-12-13 13:49:12.472569552 +0100
17 + * Copyright (C) 2011 John Crispin <blogic@openwrt.org>
18 + * Copyright (C) 2011 Andrej Vlašić <andrej.vlasic0@gmail.com>
20 + * This program is free software; you can redistribute it and/or modify it
21 + * under the terms of the GNU General Public License version 2 as published
22 + * by the Free Software Foundation.
25 +#include <linux/init.h>
26 +#include <linux/module.h>
27 +#include <linux/platform_device.h>
28 +#include <linux/etherdevice.h>
29 +#include <linux/ath5k_platform.h>
30 +#include <linux/ath9k_platform.h>
31 +#include <linux/pci.h>
33 +extern int (*ltq_pci_plat_dev_init)(struct pci_dev *dev);
34 +struct ath5k_platform_data ath5k_pdata;
35 +/*struct ath9k_platform_data ath9k_pdata = {
37 + .endian_check = true,
39 +static u16 ath5k_eeprom_data[ATH5K_PLAT_EEP_MAX_WORDS];
40 +//static u16 ath9k_eeprom_data[ATH9K_PLAT_EEP_MAX_WORDS];
41 +static u8 athxk_eeprom_mac[6];
44 +ath9k_pci_plat_dev_init(struct pci_dev *dev)
46 + dev->dev.platform_data = &ath9k_pdata;
51 +ltq_register_ath9k(u16 *eeprom_data, u8 *macaddr)
53 + memcpy(ath9k_pdata.eeprom_data, eeprom_data, sizeof(ath9k_pdata.eeprom_data));
54 + ath9k_pdata.macaddr = macaddr;
55 + ltq_pci_plat_dev_init = ath9k_pci_plat_dev_init;
58 +static int ath5k_pci_plat_dev_init(struct pci_dev *dev)
60 + dev->dev.platform_data = &ath5k_pdata;
64 +int __init of_ath5k_eeprom_probe(struct platform_device *pdev)
66 + struct device_node *np = pdev->dev.of_node;
67 + struct resource *eep_res, *mac_res;
68 + void __iomem *eep, *mac;
73 + eep_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
74 + mac_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
77 + dev_err(&pdev->dev, "failed to load eeprom address\n");
80 + if (resource_size(eep_res) != ATH5K_PLAT_EEP_MAX_WORDS) {
81 + dev_err(&pdev->dev, "eeprom has an invalid size\n");
85 + eep = ioremap(eep_res->start, resource_size(eep_res));
86 + memcpy_fromio(ath5k_eeprom_data, eep, ATH5K_PLAT_EEP_MAX_WORDS);
88 + if (of_find_property(np, "ath,eep-swap", NULL))
89 + for (i = 0; i < (ATH5K_PLAT_EEP_MAX_WORDS >> 1); i++)
90 + ath5k_eeprom_data[i] = swab16(ath5k_eeprom_data[i]);
92 + if (!of_property_read_u32(np, "ath,mac-offset", &mac_offset)) {
93 + memcpy_fromio(athxk_eeprom_mac, (void*) ath5k_eeprom_data, 6);
94 + } else if (mac_res) {
95 + if (resource_size(mac_res) != 6) {
96 + dev_err(&pdev->dev, "mac has an invalid size\n");
99 + mac = ioremap(mac_res->start, resource_size(mac_res));
100 + memcpy_fromio(athxk_eeprom_mac, mac, 6);
102 + dev_warn(&pdev->dev, "using random mac\n");
103 + random_ether_addr(athxk_eeprom_mac);
106 + if (!of_property_read_u32(np, "ath,mac-increment", &mac_inc))
107 + athxk_eeprom_mac[5] += mac_inc;
109 + ath5k_pdata.eeprom_data = ath5k_eeprom_data;
110 + ath5k_pdata.macaddr = athxk_eeprom_mac;
111 + ltq_pci_plat_dev_init = ath5k_pci_plat_dev_init;
113 + dev_info(&pdev->dev, "loaded ath5k eeprom\n");
118 +static struct of_device_id ath5k_eeprom_ids[] = {
119 + { .compatible = "ath5k,eeprom" },
123 +static struct platform_driver ath5k_eeprom_driver = {
125 + .name = "ath5k,eeprom",
126 + .owner = THIS_MODULE,
127 + .of_match_table = of_match_ptr(ath5k_eeprom_ids),
131 +static int __init of_ath5k_eeprom_init(void)
133 + return platform_driver_probe(&ath5k_eeprom_driver, of_ath5k_eeprom_probe);
135 +device_initcall(of_ath5k_eeprom_init);
136 Index: linux-3.7-rc8/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h
137 ===================================================================
138 --- linux-3.7-rc8.orig/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h 2012-12-13 10:59:57.300314976 +0100
139 +++ linux-3.7-rc8/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h 2012-12-13 10:59:57.308314977 +0100
141 /* allow tapi driver to read the gptu value */
142 long gptu_get_count(struct clk *clk);
144 +/* allow the ethernet driver to load a flash mapped mac addr */
145 +const u8* ltq_get_eth_mac(void);
147 #endif /* CONFIG_SOC_TYPE_XWAY */
148 #endif /* _LTQ_XWAY_H__ */
149 Index: linux-3.7-rc8/arch/mips/lantiq/xway/eth_mac.c
150 ===================================================================
151 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
152 +++ linux-3.7-rc8/arch/mips/lantiq/xway/eth_mac.c 2012-12-13 10:59:57.308314977 +0100
155 + * Copyright (C) 2012 John Crispin <blogic@openwrt.org>
157 + * This program is free software; you can redistribute it and/or modify it
158 + * under the terms of the GNU General Public License version 2 as published
159 + * by the Free Software Foundation.
162 +#include <linux/init.h>
163 +#include <linux/module.h>
164 +#include <linux/of_platform.h>
165 +#include <linux/if_ether.h>
167 +static u8 eth_mac[6];
168 +static int eth_mac_set;
170 +const u8* ltq_get_eth_mac(void)
175 +static int __init setup_ethaddr(char *str)
177 + eth_mac_set = mac_pton(str, eth_mac);
178 + return !eth_mac_set;
180 +__setup("ethaddr=", setup_ethaddr);
182 +int __init of_eth_mac_probe(struct platform_device *pdev)
184 + struct device_node *np = pdev->dev.of_node;
185 + struct resource *mac_res;
190 + dev_err(&pdev->dev, "mac was already set by bootloader\n");
193 + mac_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
196 + dev_err(&pdev->dev, "failed to load mac\n");
199 + if (resource_size(mac_res) != 6) {
200 + dev_err(&pdev->dev, "mac has an invalid size\n");
203 + mac = ioremap(mac_res->start, resource_size(mac_res));
204 + memcpy_fromio(eth_mac, mac, 6);
206 + if (!of_property_read_u32(np, "mac-increment", &mac_inc))
207 + eth_mac[5] += mac_inc;
212 +static struct of_device_id eth_mac_ids[] = {
213 + { .compatible = "lantiq,eth-mac" },
217 +static struct platform_driver eth_mac_driver = {
219 + .name = "lantiq,eth-mac",
220 + .owner = THIS_MODULE,
221 + .of_match_table = of_match_ptr(eth_mac_ids),
225 +static int __init of_eth_mac_init(void)
227 + return platform_driver_probe(ð_mac_driver, of_eth_mac_probe);
229 +device_initcall(of_eth_mac_init);
230 Index: linux-3.7-rc8/drivers/net/ethernet/lantiq_etop.c
231 ===================================================================
232 --- linux-3.7-rc8.orig/drivers/net/ethernet/lantiq_etop.c 2012-12-13 10:59:54.176314899 +0100
233 +++ linux-3.7-rc8/drivers/net/ethernet/lantiq_etop.c 2012-12-13 10:59:57.308314977 +0100
236 ltq_etop_change_mtu(dev, 1500);
238 - memcpy(&mac.sa_data, priv->mac, ETH_ALEN);
240 + memcpy(&mac.sa_data, priv->mac, ETH_ALEN);
241 if (!is_valid_ether_addr(mac.sa_data)) {
242 pr_warn("etop: invalid MAC, using random\n");
243 random_ether_addr(mac.sa_data);
245 priv->tx_irq = irqres[0].start;
246 priv->rx_irq = irqres[1].start;
247 priv->mii_mode = of_get_phy_mode(pdev->dev.of_node);
248 - priv->mac = of_get_mac_address(pdev->dev.of_node);
249 + priv->mac = ltq_get_eth_mac();
251 + priv->mac = of_get_mac_address(pdev->dev.of_node);
253 priv->clk_ppe = clk_get(&pdev->dev, NULL);
254 if (IS_ERR(priv->clk_ppe))
255 Index: linux-3.7-rc8/arch/mips/lantiq/xway/rt_eep.c
256 ===================================================================
257 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
258 +++ linux-3.7-rc8/arch/mips/lantiq/xway/rt_eep.c 2012-12-13 13:55:43.132579350 +0100
261 + * Copyright (C) 2011 John Crispin <blogic@openwrt.org>
263 + * This program is free software; you can redistribute it and/or modify it
264 + * under the terms of the GNU General Public License version 2 as published
265 + * by the Free Software Foundation.
268 +#include <linux/init.h>
269 +#include <linux/module.h>
270 +#include <linux/pci.h>
271 +#include <linux/platform_device.h>
272 +#include <linux/rt2x00_platform.h>
274 +extern int (*ltq_pci_plat_dev_init)(struct pci_dev *dev);
275 +static struct rt2x00_platform_data rt2x00_pdata;
277 +static int rt2x00_pci_plat_dev_init(struct pci_dev *dev)
279 + dev->dev.platform_data = &rt2x00_pdata;
283 +int __init of_ralink_eeprom_probe(struct platform_device *pdev)
285 + struct device_node *np = pdev->dev.of_node;
286 + const char *eeprom;
288 + if (of_property_read_string(np, "ralink,eeprom", &eeprom)) {
289 + dev_err(&pdev->dev, "failed to load eeprom filename\n");
293 + rt2x00_pdata.eeprom_file_name = kstrdup(eeprom, GFP_KERNEL);
294 +// rt2x00_pdata.mac_address = mac;
295 + ltq_pci_plat_dev_init = rt2x00_pci_plat_dev_init;
297 + dev_info(&pdev->dev, "using %s as eeprom\n", eeprom);
302 +static struct of_device_id ralink_eeprom_ids[] = {
303 + { .compatible = "ralink,eeprom" },
307 +static struct platform_driver ralink_eeprom_driver = {
309 + .name = "ralink,eeprom",
310 + .owner = THIS_MODULE,
311 + .of_match_table = of_match_ptr(ralink_eeprom_ids),
315 +static int __init of_ralink_eeprom_init(void)
317 + return platform_driver_probe(&ralink_eeprom_driver, of_ralink_eeprom_probe);
319 +device_initcall(of_ralink_eeprom_init);