| 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 |
| 5 | @@ -1,3 +1,5 @@ |
| 6 | obj-y := prom.o sysctrl.o clk.o reset.o dma.o timer.o dcdc.o |
| 7 | |
| 8 | +obj-y += ath_eep.o rt_eep.o eth_mac.o |
| 9 | + |
| 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 |
| 15 | @@ -0,0 +1,120 @@ |
| 16 | +/* |
| 17 | + * Copyright (C) 2011 John Crispin <blogic@openwrt.org> |
| 18 | + * Copyright (C) 2011 Andrej Vlašić <andrej.vlasic0@gmail.com> |
| 19 | + * |
| 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. |
| 23 | + */ |
| 24 | + |
| 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> |
| 32 | + |
| 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 = { |
| 36 | + .led_pin = -1, |
| 37 | + .endian_check = true, |
| 38 | +};*/ |
| 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]; |
| 42 | + |
| 43 | +/*static int |
| 44 | +ath9k_pci_plat_dev_init(struct pci_dev *dev) |
| 45 | +{ |
| 46 | + dev->dev.platform_data = &ath9k_pdata; |
| 47 | + return 0; |
| 48 | +} |
| 49 | + |
| 50 | +void __init |
| 51 | +ltq_register_ath9k(u16 *eeprom_data, u8 *macaddr) |
| 52 | +{ |
| 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; |
| 56 | +} |
| 57 | +*/ |
| 58 | +static int ath5k_pci_plat_dev_init(struct pci_dev *dev) |
| 59 | +{ |
| 60 | + dev->dev.platform_data = &ath5k_pdata; |
| 61 | + return 0; |
| 62 | +} |
| 63 | + |
| 64 | +int __init of_ath5k_eeprom_probe(struct platform_device *pdev) |
| 65 | +{ |
| 66 | + struct device_node *np = pdev->dev.of_node; |
| 67 | + struct resource *eep_res, *mac_res; |
| 68 | + void __iomem *eep, *mac; |
| 69 | + int mac_offset; |
| 70 | + u32 mac_inc = 0; |
| 71 | + int i; |
| 72 | + |
| 73 | + eep_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 74 | + mac_res = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
| 75 | + |
| 76 | + if (!eep_res) { |
| 77 | + dev_err(&pdev->dev, "failed to load eeprom address\n"); |
| 78 | + return -ENODEV; |
| 79 | + } |
| 80 | + if (resource_size(eep_res) != ATH5K_PLAT_EEP_MAX_WORDS) { |
| 81 | + dev_err(&pdev->dev, "eeprom has an invalid size\n"); |
| 82 | + return -EINVAL; |
| 83 | + } |
| 84 | + |
| 85 | + eep = ioremap(eep_res->start, resource_size(eep_res)); |
| 86 | + memcpy_fromio(ath5k_eeprom_data, eep, ATH5K_PLAT_EEP_MAX_WORDS); |
| 87 | + |
| 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]); |
| 91 | + |
| 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"); |
| 97 | + return -EINVAL; |
| 98 | + } |
| 99 | + mac = ioremap(mac_res->start, resource_size(mac_res)); |
| 100 | + memcpy_fromio(athxk_eeprom_mac, mac, 6); |
| 101 | + } else { |
| 102 | + dev_warn(&pdev->dev, "using random mac\n"); |
| 103 | + random_ether_addr(athxk_eeprom_mac); |
| 104 | + } |
| 105 | + |
| 106 | + if (!of_property_read_u32(np, "ath,mac-increment", &mac_inc)) |
| 107 | + athxk_eeprom_mac[5] += mac_inc; |
| 108 | + |
| 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; |
| 112 | + |
| 113 | + dev_info(&pdev->dev, "loaded ath5k eeprom\n"); |
| 114 | + |
| 115 | + return 0; |
| 116 | +} |
| 117 | + |
| 118 | +static struct of_device_id ath5k_eeprom_ids[] = { |
| 119 | + { .compatible = "ath5k,eeprom" }, |
| 120 | + { } |
| 121 | +}; |
| 122 | + |
| 123 | +static struct platform_driver ath5k_eeprom_driver = { |
| 124 | + .driver = { |
| 125 | + .name = "ath5k,eeprom", |
| 126 | + .owner = THIS_MODULE, |
| 127 | + .of_match_table = of_match_ptr(ath5k_eeprom_ids), |
| 128 | + }, |
| 129 | +}; |
| 130 | + |
| 131 | +static int __init of_ath5k_eeprom_init(void) |
| 132 | +{ |
| 133 | + return platform_driver_probe(&ath5k_eeprom_driver, of_ath5k_eeprom_probe); |
| 134 | +} |
| 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 |
| 140 | @@ -93,5 +93,8 @@ |
| 141 | /* allow tapi driver to read the gptu value */ |
| 142 | long gptu_get_count(struct clk *clk); |
| 143 | |
| 144 | +/* allow the ethernet driver to load a flash mapped mac addr */ |
| 145 | +const u8* ltq_get_eth_mac(void); |
| 146 | + |
| 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 |
| 153 | @@ -0,0 +1,76 @@ |
| 154 | +/* |
| 155 | + * Copyright (C) 2012 John Crispin <blogic@openwrt.org> |
| 156 | + * |
| 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. |
| 160 | + */ |
| 161 | + |
| 162 | +#include <linux/init.h> |
| 163 | +#include <linux/module.h> |
| 164 | +#include <linux/of_platform.h> |
| 165 | +#include <linux/if_ether.h> |
| 166 | + |
| 167 | +static u8 eth_mac[6]; |
| 168 | +static int eth_mac_set; |
| 169 | + |
| 170 | +const u8* ltq_get_eth_mac(void) |
| 171 | +{ |
| 172 | + return eth_mac; |
| 173 | +} |
| 174 | + |
| 175 | +static int __init setup_ethaddr(char *str) |
| 176 | +{ |
| 177 | + eth_mac_set = mac_pton(str, eth_mac); |
| 178 | + return !eth_mac_set; |
| 179 | +} |
| 180 | +__setup("ethaddr=", setup_ethaddr); |
| 181 | + |
| 182 | +int __init of_eth_mac_probe(struct platform_device *pdev) |
| 183 | +{ |
| 184 | + struct device_node *np = pdev->dev.of_node; |
| 185 | + struct resource *mac_res; |
| 186 | + void __iomem *mac; |
| 187 | + u32 mac_inc = 0; |
| 188 | + |
| 189 | + if (eth_mac_set) { |
| 190 | + dev_err(&pdev->dev, "mac was already set by bootloader\n"); |
| 191 | + return -EINVAL; |
| 192 | + } |
| 193 | + mac_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 194 | + |
| 195 | + if (!mac_res) { |
| 196 | + dev_err(&pdev->dev, "failed to load mac\n"); |
| 197 | + return -EINVAL; |
| 198 | + } |
| 199 | + if (resource_size(mac_res) != 6) { |
| 200 | + dev_err(&pdev->dev, "mac has an invalid size\n"); |
| 201 | + return -EINVAL; |
| 202 | + } |
| 203 | + mac = ioremap(mac_res->start, resource_size(mac_res)); |
| 204 | + memcpy_fromio(eth_mac, mac, 6); |
| 205 | + |
| 206 | + if (!of_property_read_u32(np, "mac-increment", &mac_inc)) |
| 207 | + eth_mac[5] += mac_inc; |
| 208 | + |
| 209 | + return 0; |
| 210 | +} |
| 211 | + |
| 212 | +static struct of_device_id eth_mac_ids[] = { |
| 213 | + { .compatible = "lantiq,eth-mac" }, |
| 214 | + { /* sentinel */ } |
| 215 | +}; |
| 216 | + |
| 217 | +static struct platform_driver eth_mac_driver = { |
| 218 | + .driver = { |
| 219 | + .name = "lantiq,eth-mac", |
| 220 | + .owner = THIS_MODULE, |
| 221 | + .of_match_table = of_match_ptr(eth_mac_ids), |
| 222 | + }, |
| 223 | +}; |
| 224 | + |
| 225 | +static int __init of_eth_mac_init(void) |
| 226 | +{ |
| 227 | + return platform_driver_probe(ð_mac_driver, of_eth_mac_probe); |
| 228 | +} |
| 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 |
| 234 | @@ -816,7 +816,8 @@ |
| 235 | |
| 236 | ltq_etop_change_mtu(dev, 1500); |
| 237 | |
| 238 | - memcpy(&mac.sa_data, priv->mac, ETH_ALEN); |
| 239 | + if (priv->mac) |
| 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); |
| 244 | @@ -940,7 +941,9 @@ |
| 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(); |
| 250 | + if (!priv->mac) |
| 251 | + priv->mac = of_get_mac_address(pdev->dev.of_node); |
| 252 | |
| 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 |
| 259 | @@ -0,0 +1,60 @@ |
| 260 | +/* |
| 261 | + * Copyright (C) 2011 John Crispin <blogic@openwrt.org> |
| 262 | + * |
| 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. |
| 266 | + */ |
| 267 | + |
| 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> |
| 273 | + |
| 274 | +extern int (*ltq_pci_plat_dev_init)(struct pci_dev *dev); |
| 275 | +static struct rt2x00_platform_data rt2x00_pdata; |
| 276 | + |
| 277 | +static int rt2x00_pci_plat_dev_init(struct pci_dev *dev) |
| 278 | +{ |
| 279 | + dev->dev.platform_data = &rt2x00_pdata; |
| 280 | + return 0; |
| 281 | +} |
| 282 | + |
| 283 | +int __init of_ralink_eeprom_probe(struct platform_device *pdev) |
| 284 | +{ |
| 285 | + struct device_node *np = pdev->dev.of_node; |
| 286 | + const char *eeprom; |
| 287 | + |
| 288 | + if (of_property_read_string(np, "ralink,eeprom", &eeprom)) { |
| 289 | + dev_err(&pdev->dev, "failed to load eeprom filename\n"); |
| 290 | + return 0; |
| 291 | + } |
| 292 | + |
| 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; |
| 296 | + |
| 297 | + dev_info(&pdev->dev, "using %s as eeprom\n", eeprom); |
| 298 | + |
| 299 | + return 0; |
| 300 | +} |
| 301 | + |
| 302 | +static struct of_device_id ralink_eeprom_ids[] = { |
| 303 | + { .compatible = "ralink,eeprom" }, |
| 304 | + { } |
| 305 | +}; |
| 306 | + |
| 307 | +static struct platform_driver ralink_eeprom_driver = { |
| 308 | + .driver = { |
| 309 | + .name = "ralink,eeprom", |
| 310 | + .owner = THIS_MODULE, |
| 311 | + .of_match_table = of_match_ptr(ralink_eeprom_ids), |
| 312 | + }, |
| 313 | +}; |
| 314 | + |
| 315 | +static int __init of_ralink_eeprom_init(void) |
| 316 | +{ |
| 317 | + return platform_driver_probe(&ralink_eeprom_driver, of_ralink_eeprom_probe); |
| 318 | +} |
| 319 | +device_initcall(of_ralink_eeprom_init); |
| 320 | |