drivers: eth_mcux: kinetis networking device Tree

Partially replaces Kinetis MCUX driver configuration from Kconfig to
Device Tree. Interrputs moved from defines configuration to DT.

Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
diff --git a/boards/arm/frdm_k64f/frdm_k64f.dts b/boards/arm/frdm_k64f/frdm_k64f.dts
index fec0eaf..13865d9 100644
--- a/boards/arm/frdm_k64f/frdm_k64f.dts
+++ b/boards/arm/frdm_k64f/frdm_k64f.dts
@@ -33,6 +33,7 @@
 		led2 = &red_led;
 		sw0 = &user_button_3;
 		sw1 = &user_button_2;
+		eth = &eth;
 	};
 
 	chosen {
@@ -194,3 +195,10 @@
 		};
 	};
 };
+
+&eth {
+	status = "ok";
+	ptp {
+		status = "ok";
+	};
+};
diff --git a/drivers/ethernet/Kconfig.mcux b/drivers/ethernet/Kconfig.mcux
index ab2db7b..46e25a0 100644
--- a/drivers/ethernet/Kconfig.mcux
+++ b/drivers/ethernet/Kconfig.mcux
@@ -53,18 +53,6 @@
 	help
 	 Include port 0 driver
 
-config ETH_MCUX_0_NAME
-	string "Driver name"
-	depends on ETH_MCUX_0
-	default "ETH_0"
-
-config ETH_MCUX_0_IRQ_PRI
-	int "Controller interrupt priority"
-	depends on ETH_MCUX_0
-	default 0
-	help
-	  IRQ priority
-
 choice ETH_MCUX_0_MAC_SELECT
 	prompt "MAC address"
 	help
@@ -89,30 +77,6 @@
 
 endchoice
 
-if ETH_MCUX_0_MANUAL_MAC
-
-config ETH_MCUX_0_MAC3
-	hex "MAC Address Byte 3"
-	default 0
-	range 0 0xff
-	help
-	  This is the byte 3 of the MAC address.
-
-config ETH_MCUX_0_MAC4
-	hex "MAC Address Byte 4"
-	default 0
-	range 0 0xff
-	help
-	  This is the byte 4 of the MAC address.
-
-config ETH_MCUX_0_MAC5
-	hex "MAC Address Byte 5"
-	default 0
-	range 0 0xff
-	help
-	  This is the byte 5 of the MAC address.
-endif
-
 config PTP_CLOCK_MCUX
 	bool "MCUX PTP clock driver support"
 	default y
@@ -145,4 +109,4 @@
 
 endif # PTP_CLOCK_MCUX
 
-endif
+endif # ETH_MCUX
diff --git a/drivers/ethernet/eth_mcux.c b/drivers/ethernet/eth_mcux.c
index f092467..ca25aee 100644
--- a/drivers/ethernet/eth_mcux.c
+++ b/drivers/ethernet/eth_mcux.c
@@ -982,22 +982,22 @@
 
 static void eth_0_config_func(void)
 {
-	IRQ_CONNECT(IRQ_ETH_RX, CONFIG_ETH_MCUX_0_IRQ_PRI,
+	IRQ_CONNECT(CONFIG_IRQ_ETH_RX, CONFIG_ETH_MCUX_0_IRQ_PRI,
 		    eth_mcux_rx_isr, DEVICE_GET(eth_mcux_0), 0);
-	irq_enable(IRQ_ETH_RX);
+	irq_enable(CONFIG_IRQ_ETH_RX);
 
-	IRQ_CONNECT(IRQ_ETH_TX, CONFIG_ETH_MCUX_0_IRQ_PRI,
+	IRQ_CONNECT(CONFIG_IRQ_ETH_TX, CONFIG_ETH_MCUX_0_IRQ_PRI,
 		    eth_mcux_tx_isr, DEVICE_GET(eth_mcux_0), 0);
-	irq_enable(IRQ_ETH_TX);
+	irq_enable(CONFIG_IRQ_ETH_TX);
 
-	IRQ_CONNECT(IRQ_ETH_ERR_MISC, CONFIG_ETH_MCUX_0_IRQ_PRI,
+	IRQ_CONNECT(CONFIG_IRQ_ETH_ERR_MISC, CONFIG_ETH_MCUX_0_IRQ_PRI,
 		    eth_mcux_error_isr, DEVICE_GET(eth_mcux_0), 0);
-	irq_enable(IRQ_ETH_ERR_MISC);
+	irq_enable(CONFIG_IRQ_ETH_ERR_MISC);
 
 #if defined(CONFIG_PTP_CLOCK_MCUX)
-	IRQ_CONNECT(IRQ_ETH_IEEE1588_TMR, CONFIG_ETH_MCUX_0_IRQ_PRI,
+	IRQ_CONNECT(CONFIG_IRQ_ETH_IEEE1588_TMR, CONFIG_ETH_MCUX_0_IRQ_PRI,
 		    eth_mcux_ptp_isr, DEVICE_GET(eth_mcux_0), 0);
-	irq_enable(IRQ_ETH_IEEE1588_TMR);
+	irq_enable(CONFIG_IRQ_ETH_IEEE1588_TMR);
 #endif
 }
 
diff --git a/dts/arm/nxp/nxp_k6x.dtsi b/dts/arm/nxp/nxp_k6x.dtsi
index ad5efd6..f9df2fc 100644
--- a/dts/arm/nxp/nxp_k6x.dtsi
+++ b/dts/arm/nxp/nxp_k6x.dtsi
@@ -393,6 +393,22 @@
 			status = "disabled";
 			label = "USBD";
 		};
+
+		eth: ethernet@400C0004 {
+			compatible = "nxp,kinetis-ethernet";
+			reg = <0x400C0004 0x620>;
+			interrupts = <83 0>, <84 0>, <85 0>;
+			interrupts-names = "TX", "RX", "ERR_MISC";
+			status = "disabled";
+			local-mac-address = [00 00 00 00 00 00];
+			label = "ETH_0";
+			ptp {
+				compatible = "nxp,kinetis-ptp";
+				status = "disabled";
+				interrupts = <82 0>;
+				interrupts-names = "IEEE1588_TMR";
+			};
+		};
 	};
 };
 
diff --git a/dts/bindings/ethernet/ethernet.yaml b/dts/bindings/ethernet/ethernet.yaml
new file mode 100644
index 0000000..288e89f
--- /dev/null
+++ b/dts/bindings/ethernet/ethernet.yaml
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2018, Linaro Limited
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+---
+title: Ethernet Base Structure
+version: 0.1
+
+description: >
+    This binding gives a base structures for all Ethernet devices
+properties:
+    local-mac-address:
+      type: array
+      category: optional
+      description: mac address
+      generation: define
+    label:
+      type: string
+      category: required
+      description: Human readable string describing the device (used by Zephyr for API name)
+      generation: define
+...
diff --git a/dts/bindings/ethernet/nxp,kinetis-ethernet.yaml b/dts/bindings/ethernet/nxp,kinetis-ethernet.yaml
new file mode 100644
index 0000000..525c1e1
--- /dev/null
+++ b/dts/bindings/ethernet/nxp,kinetis-ethernet.yaml
@@ -0,0 +1,31 @@
+#
+# Copyright (c) 2018, Linaro Limited
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+---
+title: NXP Kinetis Ethernet
+version: 0.1
+
+description: >
+    This binding gives a base representation of the NXP Kinetis Ethernet
+inherits:
+  !include ethernet.yaml
+
+properties:
+    compatible:
+      type: string
+      category: required
+      description: compatible strings
+      constraint: "nxp,kinetis-ethernet"
+    reg:
+      type: array
+      description: mmio register space
+      generation: define
+      category: required
+    interrupts:
+      type: array
+      category: required
+      description: required interrupts
+      generation: define
+...
diff --git a/dts/bindings/ethernet/nxp.kinetis-ptp.yaml b/dts/bindings/ethernet/nxp.kinetis-ptp.yaml
new file mode 100644
index 0000000..aebb4fe
--- /dev/null
+++ b/dts/bindings/ethernet/nxp.kinetis-ptp.yaml
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2018, Linaro Limited
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+---
+title: NXP Kinetis Ethernet PTP
+version: 0.1
+
+description: >
+    This binding gives a base representation of the NXP Kinetis Ethernet PTP
+inherits:
+  !include ethernet.yaml
+
+properties:
+    compatible:
+      type: string
+      category: required
+      description: compatible strings
+      constraint: "nxp,kinetis-ptp"
+...
diff --git a/soc/arm/nxp_kinetis/k6x/dts_fixup.h b/soc/arm/nxp_kinetis/k6x/dts_fixup.h
index 10f35ba..b077e57 100644
--- a/soc/arm/nxp_kinetis/k6x/dts_fixup.h
+++ b/soc/arm/nxp_kinetis/k6x/dts_fixup.h
@@ -122,4 +122,17 @@
 #define CONFIG_USBD_KINETIS_BASE_ADDRESS	NXP_KINETIS_USBD_40072000_BASE_ADDRESS
 #define CONFIG_USBD_KINETIS_NUM_BIDIR_EP	NXP_KINETIS_USBD_40072000_NUM_BIDIR_ENDPOINTS
 
+#define CONFIG_ETH_MCUX_0_NAME		ETH_LABEL
+
+#define CONFIG_ETH_MCUX_0_MAC3		NXP_KINETIS_ETHERNET_400C0004_LOCAL_MAC_ADDRESS_3
+#define CONFIG_ETH_MCUX_0_MAC4		NXP_KINETIS_ETHERNET_400C0004_LOCAL_MAC_ADDRESS_4
+#define CONFIG_ETH_MCUX_0_MAC5		NXP_KINETIS_ETHERNET_400C0004_LOCAL_MAC_ADDRESS_5
+
+/* IRQs */
+#define CONFIG_IRQ_ETH_IEEE1588_TMR		NXP_KINETIS_ETHERNET_400C0004_IRQ_ERR_MISC
+#define CONFIG_IRQ_ETH_RX		NXP_KINETIS_ETHERNET_400C0004_IRQ_RX
+#define CONFIG_IRQ_ETH_TX		NXP_KINETIS_ETHERNET_400C0004_IRQ_TX
+#define CONFIG_IRQ_ETH_ERR_MISC		NXP_KINETIS_ETHERNET_400C0004_IRQ_ERR_MISC
+#define CONFIG_ETH_MCUX_0_IRQ_PRI		NXP_KINETIS_ETHERNET_400C0004_IRQ_RX_PRIORITY
+
 /* End of SoC Level DTS fixup file */
diff --git a/soc/arm/nxp_kinetis/k6x/soc.h b/soc/arm/nxp_kinetis/k6x/soc.h
index f6a0e9a..25bba6a 100644
--- a/soc/arm/nxp_kinetis/k6x/soc.h
+++ b/soc/arm/nxp_kinetis/k6x/soc.h
@@ -31,13 +31,6 @@
 
 #define PERIPH_ADDR_BASE_WDOG 0x40052000 /* Watchdog Timer module */
 
-/* IRQs */
-
-#define IRQ_ETH_IEEE1588_TMR 82
-#define IRQ_ETH_TX 83
-#define IRQ_ETH_RX 84
-#define IRQ_ETH_ERR_MISC 85
-
 #ifndef _ASMLANGUAGE
 
 #include <fsl_common.h>