From 02e217df506bfb2d096168eb4dbaec8126f64197 Mon Sep 17 00:00:00 2001 From: Andrei Gansari Date: Thu, 27 Sep 2018 15:23:06 +0300 Subject: [PATCH] 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 --- boards/arm/frdm_k64f/frdm_k64f.dts | 8 ++++ drivers/ethernet/Kconfig.mcux | 38 +------------------ drivers/ethernet/eth_mcux.c | 16 ++++---- dts/arm/nxp/nxp_k6x.dtsi | 16 ++++++++ dts/bindings/ethernet/ethernet.yaml | 23 +++++++++++ .../ethernet/nxp,kinetis-ethernet.yaml | 31 +++++++++++++++ dts/bindings/ethernet/nxp.kinetis-ptp.yaml | 21 ++++++++++ soc/arm/nxp_kinetis/k6x/dts_fixup.h | 13 +++++++ soc/arm/nxp_kinetis/k6x/soc.h | 7 ---- 9 files changed, 121 insertions(+), 52 deletions(-) create mode 100644 dts/bindings/ethernet/ethernet.yaml create mode 100644 dts/bindings/ethernet/nxp,kinetis-ethernet.yaml create mode 100644 dts/bindings/ethernet/nxp.kinetis-ptp.yaml diff --git a/boards/arm/frdm_k64f/frdm_k64f.dts b/boards/arm/frdm_k64f/frdm_k64f.dts index fec0eaf272c..13865d9848e 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 = ð }; chosen { @@ -194,3 +195,10 @@ }; }; }; + +ð { + status = "ok"; + ptp { + status = "ok"; + }; +}; diff --git a/drivers/ethernet/Kconfig.mcux b/drivers/ethernet/Kconfig.mcux index ab2db7b101a..46e25a03d88 100644 --- a/drivers/ethernet/Kconfig.mcux +++ b/drivers/ethernet/Kconfig.mcux @@ -53,18 +53,6 @@ config ETH_MCUX_0 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 @@ config ETH_MCUX_0_MANUAL_MAC 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 @@ config ETH_MCUX_PTP_CLOCK_SRC_HZ endif # PTP_CLOCK_MCUX -endif +endif # ETH_MCUX diff --git a/drivers/ethernet/eth_mcux.c b/drivers/ethernet/eth_mcux.c index f0924673920..ca25aee39bf 100644 --- a/drivers/ethernet/eth_mcux.c +++ b/drivers/ethernet/eth_mcux.c @@ -982,22 +982,22 @@ ETH_NET_DEVICE_INIT(eth_mcux_0, CONFIG_ETH_MCUX_0_NAME, eth_0_init, 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 ad5efd65e51..f9df2fc78b9 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 00000000000..288e89f70be --- /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 00000000000..525c1e1ed93 --- /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 00000000000..aebb4feb79e --- /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 10f35bafa92..b077e577dbf 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 f6a0e9a9d91..25bba6abd86 100644 --- a/soc/arm/nxp_kinetis/k6x/soc.h +++ b/soc/arm/nxp_kinetis/k6x/soc.h @@ -31,13 +31,6 @@ extern "C" { #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