From b32b15cd98b16819359705ed1c624b19be52df35 Mon Sep 17 00:00:00 2001 From: Martin Michlmayr Date: Sat, 5 Apr 2008 15:45:15 +0000 Subject: [PATCH] Add patch to set the MAC address on QNAP TS-109/TS-209. svn path=/dists/trunk/linux-2.6/; revision=11049 --- debian/changelog | 1 + debian/patches/bugfix/arm/ts209-set-mac.patch | 102 ++++++++++++++++++ debian/patches/series/1~experimental.1 | 1 + 3 files changed, 104 insertions(+) create mode 100644 debian/patches/bugfix/arm/ts209-set-mac.patch diff --git a/debian/changelog b/debian/changelog index 16e7b7c1a..3f698e190 100644 --- a/debian/changelog +++ b/debian/changelog @@ -51,6 +51,7 @@ linux-2.6 (2.6.25~rc8-1~experimental.1) UNRELEASED; urgency=low enable NFSv4. (closes: #471007) * [mips/r5k-ip32] Enable R8169, requested by Giuseppe Sacco. * [arm/iop32x] Enable MACH_EM7210. (closes: #473136) + [ [arm/armel] Add patch to set the MAC address on QNAP TS-109/TS-209. [ Daniel Baumann ] * Added patch from unionfs upstream to export release_open_intent symbol. diff --git a/debian/patches/bugfix/arm/ts209-set-mac.patch b/debian/patches/bugfix/arm/ts209-set-mac.patch new file mode 100644 index 000000000..4528b28e0 --- /dev/null +++ b/debian/patches/bugfix/arm/ts209-set-mac.patch @@ -0,0 +1,102 @@ +Will be in 2.6.26 + +diff --git a/arch/arm/mach-orion/ts209-setup.c b/arch/arm/mach-orion/ts209-setup.c +index 45764da..6d3d900 100644 +--- a/arch/arm/mach-orion/ts209-setup.c ++++ b/arch/arm/mach-orion/ts209-setup.c +@@ -189,6 +189,87 @@ static struct mv643xx_eth_platform_data qnap_ts209_eth_data = { + .force_phy_addr = 1, + }; + ++static int __init parse_hex_nibble(char n) ++{ ++ if (n >= '0' && n <= '9') ++ return n - '0'; ++ ++ if (n >= 'A' && n <= 'F') ++ return n - 'A' + 10; ++ ++ if (n >= 'a' && n <= 'f') ++ return n - 'a' + 10; ++ ++ return -1; ++} ++ ++static int __init parse_hex_byte(const char *b) ++{ ++ int hi; ++ int lo; ++ ++ hi = parse_hex_nibble(b[0]); ++ lo = parse_hex_nibble(b[1]); ++ ++ if (hi < 0 || lo < 0) ++ return -1; ++ ++ return (hi << 4) | lo; ++} ++ ++static int __init check_mac_addr(const char *addr_str) ++{ ++ u_int8_t addr[6]; ++ int i; ++ ++ for (i = 0; i < 6; i++) { ++ int byte; ++ ++ /* ++ * Enforce "xx:xx:xx:xx:xx:xx\n" format. ++ */ ++ if (addr_str[(i * 3) + 2] != ((i < 5) ? ':' : '\n')) ++ return -1; ++ ++ byte = parse_hex_byte(addr_str + (i * 3)); ++ if (byte < 0) ++ return -1; ++ addr[i] = byte; ++ } ++ ++ printk(KERN_INFO "ts209: found ethernet mac address "); ++ for (i = 0; i < 6; i++) ++ printk("%.2x%s", addr[i], (i < 5) ? ":" : ".\n"); ++ ++ memcpy(qnap_ts209_eth_data.mac_addr, addr, 6); ++ ++ return 0; ++} ++ ++/* ++ * The 'NAS Config' flash partition has an ext2 filesystem which ++ * contains a file that has the ethernet MAC address in plain text ++ * (format "xx:xx:xx:xx:xx:xx\n".) ++ */ ++static void __init ts209_find_mac_addr(void) ++{ ++ unsigned long addr; ++ ++ for (addr = 0x00700000; addr < 0x00760000; addr += 1024) { ++ char *nor_page; ++ int ret = 0; ++ ++ nor_page = ioremap(QNAP_TS209_NOR_BOOT_BASE + addr, 1024); ++ if (nor_page != NULL) { ++ ret = check_mac_addr(nor_page); ++ iounmap(nor_page); ++ } ++ ++ if (ret == 0) ++ break; ++ } ++} ++ + /***************************************************************************** + * RTC S35390A on I2C bus + ****************************************************************************/ +@@ -344,6 +425,7 @@ static void __init qnap_ts209_init(void) + pr_warning("qnap_ts209_init: failed to get RTC IRQ\n"); + i2c_register_board_info(0, &qnap_ts209_i2c_rtc, 1); + ++ ts209_find_mac_addr(); + orion_eth_init(&qnap_ts209_eth_data); + orion_sata_init(&qnap_ts209_sata_data); + } diff --git a/debian/patches/series/1~experimental.1 b/debian/patches/series/1~experimental.1 index 8a2085168..f0e7b3b99 100644 --- a/debian/patches/series/1~experimental.1 +++ b/debian/patches/series/1~experimental.1 @@ -19,6 +19,7 @@ + bugfix/powerpc/serial.patch + bugfix/mips/tulip_mwi_fix.patch + features/arm/ixp4xx-net-drivers.patch ++ bugfix/arm/ts209-set-mac.patch + bugfix/sparc/drivers_net-broken.patch + bugfix/ia64/hardcode-arch-script-output.patch + bugfix/mips/disable-advansys.patch