All of lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob V2
@ 2016-02-13 22:04 ` John Holland
  0 siblings, 0 replies; 8+ messages in thread
From: John Holland @ 2016-02-13 22:04 UTC (permalink / raw)
  To: intel-wired-lan, netdev

Hello,

The Intel i211 LOM pcie ethernet controllers' iNVM operates as an OTP 
and has no externel EEPROM interface [1]. The following allows the 
driver to pickup the MAC address from a device tree blob when CONFIG_OF 
has been enabled.

[1] 
http://www.intel.com/content/www/us/en/embedded/products/networking/i211-ethernet-controller-datasheet.html

Changes V2
- Restrict searching for compatible devices to current pci device.

Signed-off-by: John Holland <jotihojr@gmail.com>
---

  drivers/net/ethernet/intel/igb/igb_main.c | 30 
++++++++++++++++++++++++++++++
  1 file changed, 30 insertions(+)

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c 
b/drivers/net/ethernet/intel/igb/igb_main.c
index 31e5f39..f7788fa 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -56,6 +56,11 @@
  #include <linux/i2c.h>
  #include "igb.h"

+#ifdef CONFIG_OF
+#include <linux/of_net.h>
+#include <linux/etherdevice.h>
+#endif
+
  #define MAJ 5
  #define MIN 3
  #define BUILD 0
@@ -2216,6 +2221,26 @@ static s32 igb_init_i2c(struct igb_adapter *adapter)
         return status;
  }

+#ifdef CONFIG_OF
+/**
+ *  igb_read_mac_addr_dts - Read mac address from the device tree blob
+ *  @dev: pointer to device structure
+ *  @mac_addr: pointer to found mac address
+ **/
+static void igb_read_mac_addr_dts(const struct device *dev, u8 *mac_addr)
+{
+       const u8 *mac;
+       struct device_node *dn;
+
+       dn = of_find_compatible_node(dev->of_node, NULL, "intel,i210");
+       if (dn) {
+               mac = of_get_mac_address(dn);
+               if (mac)
+                       ether_addr_copy(mac_addr, mac);
+       }
+}
+#endif
+
  /**
   *  igb_probe - Device Initialization Routine
   *  @pdev: PCI device information struct
@@ -2420,6 +2445,11 @@ static int igb_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
         if (hw->mac.ops.read_mac_addr(hw))
                 dev_err(&pdev->dev, "NVM Read Error\n");

+#ifdef CONFIG_OF
+       if (!is_valid_ether_addr(hw->mac.addr))
+               igb_read_mac_addr_dts(&pdev->dev, hw->mac.addr);
+#endif
+
         memcpy(netdev->dev_addr, hw->mac.addr, netdev->addr_len);

         if (!is_valid_ether_addr(netdev->dev_addr)) {

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob V2
@ 2016-02-13 22:04 ` John Holland
  0 siblings, 0 replies; 8+ messages in thread
From: John Holland @ 2016-02-13 22:04 UTC (permalink / raw)
  To: intel-wired-lan

Hello,

The Intel i211 LOM pcie ethernet controllers' iNVM operates as an OTP 
and has no externel EEPROM interface [1]. The following allows the 
driver to pickup the MAC address from a device tree blob when CONFIG_OF 
has been enabled.

[1] 
http://www.intel.com/content/www/us/en/embedded/products/networking/i211-ethernet-controller-datasheet.html

Changes V2
- Restrict searching for compatible devices to current pci device.

Signed-off-by: John Holland <jotihojr@gmail.com>
---

  drivers/net/ethernet/intel/igb/igb_main.c | 30 
++++++++++++++++++++++++++++++
  1 file changed, 30 insertions(+)

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c 
b/drivers/net/ethernet/intel/igb/igb_main.c
index 31e5f39..f7788fa 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -56,6 +56,11 @@
  #include <linux/i2c.h>
  #include "igb.h"

+#ifdef CONFIG_OF
+#include <linux/of_net.h>
+#include <linux/etherdevice.h>
+#endif
+
  #define MAJ 5
  #define MIN 3
  #define BUILD 0
@@ -2216,6 +2221,26 @@ static s32 igb_init_i2c(struct igb_adapter *adapter)
         return status;
  }

+#ifdef CONFIG_OF
+/**
+ *  igb_read_mac_addr_dts - Read mac address from the device tree blob
+ *  @dev: pointer to device structure
+ *  @mac_addr: pointer to found mac address
+ **/
+static void igb_read_mac_addr_dts(const struct device *dev, u8 *mac_addr)
+{
+       const u8 *mac;
+       struct device_node *dn;
+
+       dn = of_find_compatible_node(dev->of_node, NULL, "intel,i210");
+       if (dn) {
+               mac = of_get_mac_address(dn);
+               if (mac)
+                       ether_addr_copy(mac_addr, mac);
+       }
+}
+#endif
+
  /**
   *  igb_probe - Device Initialization Routine
   *  @pdev: PCI device information struct
@@ -2420,6 +2445,11 @@ static int igb_probe(struct pci_dev *pdev, const 
struct pci_device_id *ent)
         if (hw->mac.ops.read_mac_addr(hw))
                 dev_err(&pdev->dev, "NVM Read Error\n");

+#ifdef CONFIG_OF
+       if (!is_valid_ether_addr(hw->mac.addr))
+               igb_read_mac_addr_dts(&pdev->dev, hw->mac.addr);
+#endif
+
         memcpy(netdev->dev_addr, hw->mac.addr, netdev->addr_len);

         if (!is_valid_ether_addr(netdev->dev_addr)) {


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob V2
  2016-02-13 22:04 ` John Holland
@ 2016-02-16 16:58   ` Andrew Lunn
  -1 siblings, 0 replies; 8+ messages in thread
From: Andrew Lunn @ 2016-02-16 16:58 UTC (permalink / raw)
  To: John Holland; +Cc: intel-wired-lan, netdev

On Sat, Feb 13, 2016 at 11:04:45PM +0100, John Holland wrote:
> Hello,
> 
> The Intel i211 LOM pcie ethernet controllers' iNVM operates as an
> OTP and has no externel EEPROM interface [1]. The following allows
> the driver to pickup the MAC address from a device tree blob when
> CONFIG_OF has been enabled.
> 
> [1] http://www.intel.com/content/www/us/en/embedded/products/networking/i211-ethernet-controller-datasheet.html
> 
> Changes V2
> - Restrict searching for compatible devices to current pci device.
> 
> Signed-off-by: John Holland <jotihojr@gmail.com>

Hi John

Thanks for fixing multiple device support.

Please could you add documentation in
Documentation/devicetree/bindings/net. I know these are standard
properties, but it is somewhat unusual to attach them to a PCI node,
so having an example would be good.

   Thanks
	Andrew

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob V2
@ 2016-02-16 16:58   ` Andrew Lunn
  0 siblings, 0 replies; 8+ messages in thread
From: Andrew Lunn @ 2016-02-16 16:58 UTC (permalink / raw)
  To: intel-wired-lan

On Sat, Feb 13, 2016 at 11:04:45PM +0100, John Holland wrote:
> Hello,
> 
> The Intel i211 LOM pcie ethernet controllers' iNVM operates as an
> OTP and has no externel EEPROM interface [1]. The following allows
> the driver to pickup the MAC address from a device tree blob when
> CONFIG_OF has been enabled.
> 
> [1] http://www.intel.com/content/www/us/en/embedded/products/networking/i211-ethernet-controller-datasheet.html
> 
> Changes V2
> - Restrict searching for compatible devices to current pci device.
> 
> Signed-off-by: John Holland <jotihojr@gmail.com>

Hi John

Thanks for fixing multiple device support.

Please could you add documentation in
Documentation/devicetree/bindings/net. I know these are standard
properties, but it is somewhat unusual to attach them to a PCI node,
so having an example would be good.

   Thanks
	Andrew

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob V2
  2016-02-16 16:58   ` Andrew Lunn
@ 2016-02-16 22:34     ` John Holland
  -1 siblings, 0 replies; 8+ messages in thread
From: John Holland @ 2016-02-16 22:34 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: intel-wired-lan, netdev


> On Feb 16, 2016, at 17:58, Andrew Lunn <andrew@lunn.ch> wrote:
> 
>> On Sat, Feb 13, 2016 at 11:04:45PM +0100, John Holland wrote:
>> Hello,
>> 
>> The Intel i211 LOM pcie ethernet controllers' iNVM operates as an
>> OTP and has no externel EEPROM interface [1]. The following allows
>> the driver to pickup the MAC address from a device tree blob when
>> CONFIG_OF has been enabled.
>> 
>> [1] http://www.intel.com/content/www/us/en/embedded/products/networking/i211-ethernet-controller-datasheet.html
>> 
>> Changes V2
>> - Restrict searching for compatible devices to current pci device.
>> 
>> Signed-off-by: John Holland <jotihojr@gmail.com>
> 
> Hi John
> 
> Thanks for fixing multiple device support.
> 
> Please could you add documentation in
> Documentation/devicetree/bindings/net. I know these are standard
> properties, but it is somewhat unusual to attach them to a PCI node,
> so having an example would be good.
> 
>   Thanks
>    Andrew

Odd that the marvel sky2 allows just that, but supplies no documentation.

I can supply some kind of usage description/example, showing how to use this feature to pull in the MAC address from u-boot and route it to the i210. Just uncertain as how to name the respective file. igb.txt or i210.txt come to mind. Do you prefer one over the other?

John

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob V2
@ 2016-02-16 22:34     ` John Holland
  0 siblings, 0 replies; 8+ messages in thread
From: John Holland @ 2016-02-16 22:34 UTC (permalink / raw)
  To: intel-wired-lan


> On Feb 16, 2016, at 17:58, Andrew Lunn <andrew@lunn.ch> wrote:
> 
>> On Sat, Feb 13, 2016 at 11:04:45PM +0100, John Holland wrote:
>> Hello,
>> 
>> The Intel i211 LOM pcie ethernet controllers' iNVM operates as an
>> OTP and has no externel EEPROM interface [1]. The following allows
>> the driver to pickup the MAC address from a device tree blob when
>> CONFIG_OF has been enabled.
>> 
>> [1] http://www.intel.com/content/www/us/en/embedded/products/networking/i211-ethernet-controller-datasheet.html
>> 
>> Changes V2
>> - Restrict searching for compatible devices to current pci device.
>> 
>> Signed-off-by: John Holland <jotihojr@gmail.com>
> 
> Hi John
> 
> Thanks for fixing multiple device support.
> 
> Please could you add documentation in
> Documentation/devicetree/bindings/net. I know these are standard
> properties, but it is somewhat unusual to attach them to a PCI node,
> so having an example would be good.
> 
>   Thanks
>    Andrew

Odd that the marvel sky2 allows just that, but supplies no documentation.

I can supply some kind of usage description/example, showing how to use this feature to pull in the MAC address from u-boot and route it to the i210. Just uncertain as how to name the respective file. igb.txt or i210.txt come to mind. Do you prefer one over the other?

John

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob V2
  2016-02-16 22:34     ` John Holland
@ 2016-02-16 22:47       ` Andrew Lunn
  -1 siblings, 0 replies; 8+ messages in thread
From: Andrew Lunn @ 2016-02-16 22:47 UTC (permalink / raw)
  To: John Holland; +Cc: intel-wired-lan, netdev

> I can supply some kind of usage description/example, showing how to
> use this feature to pull in the MAC address from u-boot and route it
> to the i210. Just uncertain as how to name the respective
> file. igb.txt or i210.txt come to mind. Do you prefer one over the
> other?

Hi John

It is quite common to name it after the compatible string, so
intel,i210.txt

Thanks
	Andrew

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob V2
@ 2016-02-16 22:47       ` Andrew Lunn
  0 siblings, 0 replies; 8+ messages in thread
From: Andrew Lunn @ 2016-02-16 22:47 UTC (permalink / raw)
  To: intel-wired-lan

> I can supply some kind of usage description/example, showing how to
> use this feature to pull in the MAC address from u-boot and route it
> to the i210. Just uncertain as how to name the respective
> file. igb.txt or i210.txt come to mind. Do you prefer one over the
> other?

Hi John

It is quite common to name it after the compatible string, so
intel,i210.txt

Thanks
	Andrew

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-02-16 22:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-13 22:04 [Intel-wired-lan] [next] igb: allow setting MAC address on i211 using a device tree blob V2 John Holland
2016-02-13 22:04 ` John Holland
2016-02-16 16:58 ` Andrew Lunn
2016-02-16 16:58   ` Andrew Lunn
2016-02-16 22:34   ` John Holland
2016-02-16 22:34     ` John Holland
2016-02-16 22:47     ` Andrew Lunn
2016-02-16 22:47       ` Andrew Lunn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.