diff options
author | Marcel Ziswiler <marcel.ziswiler@toradex.com> | 2017-11-13 14:41:42 +0100 |
---|---|---|
committer | Marcel Ziswiler <marcel.ziswiler@toradex.com> | 2018-04-03 10:12:51 +0200 |
commit | 9b8c081249f6b9754bcde2602fa1c3094ae3b2a6 (patch) | |
tree | afc7b6f4e5cc2f95a630cf42ed18b5e3c6ec92b0 /recipes-kernel/linux/linux-toradex-mainline-4.14/0004-apalis_t30-tk1-igb-no-nvm-and-Ethernet-MAC-address-h.patch | |
parent | 8deaad62384fbe4f4079f62bb7fdfa70ef199236 (diff) |
linux-toradex-mainline: apalis tk1 mainline, update to 4.14
Update to latest Linux LTS 4.14.
Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Acked-by: Dominik Sliwa <dominik.sliwa@toradex.com>
(cherry picked from commit 7bcd5eac4e92b1f372835e9f44066f6dd337bd61)
Diffstat (limited to 'recipes-kernel/linux/linux-toradex-mainline-4.14/0004-apalis_t30-tk1-igb-no-nvm-and-Ethernet-MAC-address-h.patch')
-rw-r--r-- | recipes-kernel/linux/linux-toradex-mainline-4.14/0004-apalis_t30-tk1-igb-no-nvm-and-Ethernet-MAC-address-h.patch | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/recipes-kernel/linux/linux-toradex-mainline-4.14/0004-apalis_t30-tk1-igb-no-nvm-and-Ethernet-MAC-address-h.patch b/recipes-kernel/linux/linux-toradex-mainline-4.14/0004-apalis_t30-tk1-igb-no-nvm-and-Ethernet-MAC-address-h.patch new file mode 100644 index 0000000..0613617 --- /dev/null +++ b/recipes-kernel/linux/linux-toradex-mainline-4.14/0004-apalis_t30-tk1-igb-no-nvm-and-Ethernet-MAC-address-h.patch @@ -0,0 +1,137 @@ +From d912735d53757d9b525ee7f016020400be458867 Mon Sep 17 00:00:00 2001 +Message-Id: <d912735d53757d9b525ee7f016020400be458867.1510580437.git.marcel.ziswiler@toradex.com> +In-Reply-To: <8d39626d07718220b426e9be045df8ed9d1fd707.1510580437.git.marcel.ziswiler@toradex.com> +References: <8d39626d07718220b426e9be045df8ed9d1fd707.1510580437.git.marcel.ziswiler@toradex.com> +From: Marcel Ziswiler <marcel.ziswiler@toradex.com> +Date: Thu, 15 Dec 2016 10:55:54 +0100 +Subject: [PATCH 4/8] apalis_t30/tk1: igb: no nvm and Ethernet MAC address + handling + +Only warn rather than fail on NVM validation failures on Apalis T30 and +Apalis TK1. + +Revise Ethernet MAC address assignment: should now handle up to two +instances of custom user MACs (2nd one with a 0x100000 offset). This +way customer does not have to worry about NVM on a secondary Ethernet +on the carrier board and still gets a valid official MAC address from +us (e.g. analogous to how we did it on our Protea carrier board). + +Use the Toradex OUI as default MAC address if no valid one is +encountered. + +Tested on samples of Apalis T30 2GB V1.0B, V1.0C, V1.1A, Apalis T30 1GB +V1.0A, V1.1A and Apalis T30 1GB IT V1.1A both with blank NVMs as well +as iNVMs programmed with Intel's defaults. + +Tested on samples of Apalis TK1 2GB V1.0A, V1.0B and V1.1A both with +blank NVMs as well as iNVMs programmed with Intel's defaults. + +Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com> +Acked-by: Dominik Sliwa <dominik.sliwa@toradex.com> + +(cherry picked from toradex_tk1_l4t_r21.5 commit +70efa60d96c9f05d91d8875eee97446df7f9e877) +(cherry picked from tegra commit +c4c3c7449bdb15c53bfebb0a29c73b24ea810d23) +--- + drivers/net/ethernet/intel/igb/igb_main.c | 60 +++++++++++++++++++++++++++++-- + 1 file changed, 57 insertions(+), 3 deletions(-) + +diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c +index a060fc2..c872c15 100644 +--- a/drivers/net/ethernet/intel/igb/igb_main.c ++++ b/drivers/net/ethernet/intel/igb/igb_main.c +@@ -55,6 +55,7 @@ + #include <linux/dca.h> + #endif + #include <linux/i2c.h> ++#include <linux/ctype.h> + #include "igb.h" + + #define MAJ 5 +@@ -69,6 +70,9 @@ static const char igb_driver_string[] = + static const char igb_copyright[] = + "Copyright (c) 2007-2014 Intel Corporation."; + ++static char g_mac_addr[ETH_ALEN]; ++static int g_usr_mac = 0; ++ + static const struct e1000_info *igb_info_tbl[] = { + [board_82575] = &e1000_82575_info, + }; +@@ -259,6 +263,37 @@ static int debug = -1; + module_param(debug, int, 0); + MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)"); + ++/* Retrieve user set MAC address */ ++static int __init setup_igb_mac(char *macstr) ++{ ++ int i, j; ++ unsigned char result, value; ++ ++ for (i = 0; i < ETH_ALEN; i++) { ++ result = 0; ++ ++ if (i != 5 && *(macstr + 2) != ':') ++ return -1; ++ ++ for (j = 0; j < 2; j++) { ++ if (isxdigit(*macstr) && (value = isdigit(*macstr) ? ++ *macstr - '0' : toupper(*macstr) - 'A' + 10) < 16) { ++ result = result * 16 + value; ++ macstr++; ++ } else ++ return -1; ++ } ++ ++ macstr++; ++ g_mac_addr[i] = result; ++ } ++ ++ g_usr_mac = 1; ++ ++ return 0; ++} ++__setup("igb_mac=", setup_igb_mac); ++ + struct igb_reg_info { + u32 ofs; + char *name; +@@ -2521,12 +2556,31 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) + dev_err(&pdev->dev, "NVM Read Error\n"); + } + ++ if (g_usr_mac && (g_usr_mac < 3)) { ++ /* Get user set MAC address */ ++ if (g_usr_mac == 2) { ++ /* 0x100000 offset for 2nd Ethernet MAC */ ++ g_mac_addr[3] += 0x10; ++ if (g_mac_addr[3] < 0x10) ++ dev_warn(&pdev->dev, ++ "MAC addr byte 3 (0x%02x) wrap around" ++ "\n", ++ g_mac_addr[3]); ++ } ++ memcpy(hw->mac.addr, g_mac_addr, ETH_ALEN); ++ g_usr_mac++; ++ } ++ + memcpy(netdev->dev_addr, hw->mac.addr, netdev->addr_len); + + if (!is_valid_ether_addr(netdev->dev_addr)) { +- dev_err(&pdev->dev, "Invalid MAC Address\n"); +- err = -EIO; +- goto err_eeprom; ++ /* Use Toradex OUI as default */ ++ char default_mac_addr[ETH_ALEN] = { ++ 0x0, 0x14, 0x2d, 0x0, 0x0, 0x0 ++ }; ++ dev_warn(&pdev->dev, "using Toradex OUI as default igb MAC\n"); ++ memcpy(hw->mac.addr, default_mac_addr, ETH_ALEN); ++ memcpy(netdev->dev_addr, hw->mac.addr, netdev->addr_len); + } + + igb_set_default_mac_filter(adapter); +-- +2.9.5 + |