drivers: eth_enc28j60: moved to dts

Driver for networking device Microchip ENC28J60 is used as SPI slave,
moved to DTS type definition. Samples echo_client and echo_server use
this device on Arduino 101 board.

Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Andrei Gansari 2018-11-22 11:15:34 +02:00 committed by Anas Nashif
commit 4118b8843f
13 changed files with 111 additions and 102 deletions

View file

@ -45,10 +45,6 @@ config ETH_ENC28J60_0
Include port 0 driver
if ETH_ENC28J60 && ETH_ENC28J60_0
config ETH_ENC28J60_0_NAME
string "Driver's name"
default "ETH_0"
config ETH_EN28J60_0_FULL_DUPLEX
bool "ENC28J60 full duplex"
default y
@ -56,77 +52,10 @@ config ETH_EN28J60_0_FULL_DUPLEX
Enable Full Duplex. Device is configured half duplex
when disabled.
config ETH_ENC28J60_0_GPIO_PORT_NAME
string "GPIO controller port name"
default "GPIO_0"
help
GPIO port name through which ENC28J60C interruption is received.
config ETH_ENC28J60_0_GPIO_PIN
int "ENC28J60C INT GPIO PIN"
default 19
help
GPIO pin number used to connect INT
config ETH_ENC28J60_0_SPI_PORT_NAME
string "SPI master controller port name"
default "SPI_0"
help
Master SPI port name through which ENC28J60C chip is accessed.
config ETH_ENC28J60_0_SLAVE
hex "ETH_ENC28J60 SPI slave select pin"
default 1
help
ENC28J60C chip select pin.
config ETH_ENC28J60_0_GPIO_SPI_CS
bool "Manage SPI CS through a GPIO pin"
help
This option is useful if one needs to manage SPI CS through a GPIO
pin to by-pass the SPI controller's CS logic.
config ETH_ENC28J60_0_SPI_CS_PORT_NAME
string "SPI cs port name"
depends on ETH_ENC28J60_0_GPIO_SPI_CS
help
Master SPI port name through which ENC28J60C chip is accessed.
config ETH_ENC28J60_0_SPI_CS_PIN
int "SPI CS pin"
default 0
depends on ETH_ENC28J60_0_GPIO_SPI_CS
help
CS pin used for the SPI device
config ETH_ENC28J60_0_SPI_BUS_FREQ
int "ENC28J60C SPI bus speed in Hz"
default 128000
help
This is the SPI bus frequency for accessing the device.
config ETH_ENC28J60_0_MAC3
hex "MAC Address Byte 3"
default 0
help
MACADDR<0:23> are Microchip's OUI.
This is the byte 3 of the MAC address.
MACADDR<31:24>
config ETH_ENC28J60_0_MAC4
hex "MAC Address Byte 4"
default 0
help
MACADDR<0:23> are Microchip's OUI.
This is the byte 4 of the MAC address.
MACADDR<40:32>
config ETH_ENC28J60_0_MAC5
hex "MAC Address Byte 5"
default 0
help
MACADDR<0:23> are Microchip's OUI.
This is the byte 5 of the MAC address.
MACADDR<48:41>
endif #ETH_ENC28J60 && ETH_ENC28J60_0

View file

@ -381,11 +381,11 @@ static void eth_enc28j60_init_mac(struct device *dev)
/* Configure MAC address */
eth_enc28j60_set_bank(dev, ENC28J60_REG_MAADR0);
eth_enc28j60_write_reg(dev, ENC28J60_REG_MAADR0,
CONFIG_ETH_ENC28J60_0_MAC5);
DT_MICROCHIP_ENC28J60_0_LOCAL_MAC_ADDRESS_5);
eth_enc28j60_write_reg(dev, ENC28J60_REG_MAADR1,
CONFIG_ETH_ENC28J60_0_MAC4);
DT_MICROCHIP_ENC28J60_0_LOCAL_MAC_ADDRESS_4);
eth_enc28j60_write_reg(dev, ENC28J60_REG_MAADR2,
CONFIG_ETH_ENC28J60_0_MAC3);
DT_MICROCHIP_ENC28J60_0_LOCAL_MAC_ADDRESS_3);
eth_enc28j60_write_reg(dev, ENC28J60_REG_MAADR3, MICROCHIP_OUI_B2);
eth_enc28j60_write_reg(dev, ENC28J60_REG_MAADR4, MICROCHIP_OUI_B1);
eth_enc28j60_write_reg(dev, ENC28J60_REG_MAADR5, MICROCHIP_OUI_B0);
@ -759,9 +759,9 @@ static struct eth_enc28j60_runtime eth_enc28j60_0_runtime = {
MICROCHIP_OUI_B0,
MICROCHIP_OUI_B1,
MICROCHIP_OUI_B2,
CONFIG_ETH_ENC28J60_0_MAC3,
CONFIG_ETH_ENC28J60_0_MAC4,
CONFIG_ETH_ENC28J60_0_MAC5
DT_MICROCHIP_ENC28J60_0_LOCAL_MAC_ADDRESS_3,
DT_MICROCHIP_ENC28J60_0_LOCAL_MAC_ADDRESS_4,
DT_MICROCHIP_ENC28J60_0_LOCAL_MAC_ADDRESS_5
},
.tx_rx_sem = _K_SEM_INITIALIZER(eth_enc28j60_0_runtime.tx_rx_sem,
1, UINT_MAX),
@ -770,20 +770,20 @@ static struct eth_enc28j60_runtime eth_enc28j60_0_runtime = {
};
static const struct eth_enc28j60_config eth_enc28j60_0_config = {
.gpio_port = CONFIG_ETH_ENC28J60_0_GPIO_PORT_NAME,
.gpio_pin = CONFIG_ETH_ENC28J60_0_GPIO_PIN,
.spi_port = CONFIG_ETH_ENC28J60_0_SPI_PORT_NAME,
.spi_freq = CONFIG_ETH_ENC28J60_0_SPI_BUS_FREQ,
.spi_slave = CONFIG_ETH_ENC28J60_0_SLAVE,
.gpio_port = DT_MICROCHIP_ENC28J60_0_INT_GPIOS_CONTROLLER,
.gpio_pin = DT_MICROCHIP_ENC28J60_0_INT_GPIOS_PIN,
.spi_port = DT_MICROCHIP_ENC28J60_0_BUS_NAME,
.spi_freq = DT_MICROCHIP_ENC28J60_0_SPI_MAX_FREQUENCY,
.spi_slave = DT_MICROCHIP_ENC28J60_0_BASE_ADDRESS,
#ifdef CONFIG_ETH_ENC28J60_0_GPIO_SPI_CS
.spi_cs_port = CONFIG_ETH_ENC28J60_0_SPI_CS_PORT_NAME,
.spi_cs_pin = CONFIG_ETH_ENC28J60_0_SPI_CS_PIN,
.spi_cs_port = DT_MICROCHIP_ENC28J60_0_CS_GPIOS_CONTROLLER,
.spi_cs_pin = DT_MICROCHIP_ENC28J60_0_CS_GPIOS_PIN,
#endif /* CONFIG_ETH_ENC28J60_0_GPIO_SPI_CS */
.full_duplex = CONFIG_ETH_EN28J60_0_FULL_DUPLEX,
.timeout = CONFIG_ETH_EN28J60_TIMEOUT,
};
NET_DEVICE_INIT(enc28j60_0, CONFIG_ETH_ENC28J60_0_NAME,
NET_DEVICE_INIT(enc28j60_0, DT_MICROCHIP_ENC28J60_0_LABEL,
eth_enc28j60_init, &eth_enc28j60_0_runtime,
&eth_enc28j60_0_config, CONFIG_ETH_INIT_PRIORITY, &api_funcs,
ETHERNET_L2, NET_L2_GET_CTX_TYPE(ETHERNET_L2), 1500);

View file

@ -0,0 +1,25 @@
#
# Copyright (c) 2018, Linaro Limited
#
# SPDX-License-Identifier: Apache-2.0
#
---
title: 10Base-T Ethernet Controller with SPI Interface
version: 0.1
description: >
This binding gives a base representation of the standalone ENC28J60 chip
inherits:
!include [ethernet.yaml, spi-device.yaml]
properties:
compatible:
type: string
category: required
description: compatible strings
constraint: "microchip,enc28j60"
int-gpios:
type: compound
category: required
generation: define, use-prop-name
...

View file

@ -0,0 +1,21 @@
/*
* Copyright (c) 2018-2019 Linaro Limited
*
* SPDX-License-Identifier: Apache-2.0
*/
&spi1 {
status = "ok";
cs-gpios = <&gpio0 0 0>;
enc28j60@0 {
compatible = "microchip,enc28j60";
spi-port-name = "SPI_1";
local-mac-address = [00 00 00 00 00 00];
spi-max-frequency = <128000>;
int-gpios = <&gpio0 19 1>;
status = "ok";
label = "ETH_0";
reg = <0>;
};
};

View file

@ -1,2 +0,0 @@
# Arduino 101
CONFIG_SPI=y

View file

@ -1,9 +1,7 @@
# ENC28J60 is L2 chip slave on SPI
CONFIG_SPI=y
CONFIG_NET_L2_ETHERNET=y
# ENC28J60 Ethernet Device
CONFIG_ETH_ENC28J60=y
CONFIG_ETH_ENC28J60_0=y
CONFIG_ETH_ENC28J60_0_SPI_PORT_NAME="SPI_1"
CONFIG_ETH_ENC28J60_0_MAC3=0x2D
CONFIG_ETH_ENC28J60_0_MAC4=0x30
CONFIG_ETH_ENC28J60_0_MAC5=0x32

View file

@ -8,7 +8,7 @@ sample:
tests:
test:
platform_whitelist: qemu_x86 frdm_k64f sam_e70_xplained
qemu_cortex_m3 arduino_101 frdm_kw41z
qemu_cortex_m3 frdm_kw41z
test_802154:
extra_args: OVERLAY_CONFIG="overlay-qemu_802154.conf"
platform_whitelist: qemu_x86
@ -29,3 +29,7 @@ tests:
slow: true
tags: net openthread
platform_whitelist: frdm_kw41z
test_enc28j60:
extra_args: OVERLAY_CONFIG="overlay-enc28j60.conf"
tags: net enc28j60
platform_whitelist: arduino_101

View file

@ -0,0 +1,21 @@
/*
* Copyright (c) 2018-2019 Linaro Limited
*
* SPDX-License-Identifier: Apache-2.0
*/
&spi1 {
status = "ok";
cs-gpios = <&gpio0 0 0>;
enc28j60@0 {
compatible = "microchip,enc28j60";
spi-port-name = "SPI_1";
local-mac-address = [00 00 00 00 00 00];
spi-max-frequency = <128000>;
int-gpios = <&gpio0 19 1>;
status = "ok";
label = "ETH_0";
reg = <0>;
};
};

View file

@ -1,2 +0,0 @@
# Arduino 101
CONFIG_SPI=y

View file

@ -1,9 +1,7 @@
# ENC28J60 is L2 chip slave on SPI
CONFIG_SPI=y
CONFIG_NET_L2_ETHERNET=y
# ENC28J60 Ethernet Device
CONFIG_ETH_ENC28J60=y
CONFIG_ETH_ENC28J60_0=y
CONFIG_ETH_ENC28J60_0_SPI_PORT_NAME="SPI_1"
CONFIG_ETH_ENC28J60_0_MAC3=0x2D
CONFIG_ETH_ENC28J60_0_MAC4=0x30
CONFIG_ETH_ENC28J60_0_MAC5=0x36

View file

@ -8,7 +8,7 @@ sample:
tests:
test:
platform_whitelist: qemu_x86 sam_e70_xplained frdm_k64f
qemu_cortex_m3 arduino_101 frdm_kw41z
qemu_cortex_m3 frdm_kw41z
test_802154:
extra_args: OVERLAY_CONFIG="overlay-qemu_802154.conf"
platform_whitelist: qemu_x86
@ -46,3 +46,7 @@ tests:
slow: true
tags: net openthread
platform_whitelist: frdm_kw41z
test_enc28j60:
extra_args: OVERLAY_CONFIG="overlay-enc28j60.conf"
tags: net enc28j60
platform_whitelist: arduino_101

View file

@ -215,4 +215,20 @@
#define DT_LIS2DH_INT2_GPIO_PIN 1
#endif
#ifndef DT_MICROCHIP_ENC28J60_0_LABEL
#define DT_MICROCHIP_ENC28J60_0_BASE_ADDRESS 0
#define DT_MICROCHIP_ENC28J60_0_BUS_NAME ""
#define DT_MICROCHIP_ENC28J60_0_INT_GPIOS_CONTROLLER ""
#define DT_MICROCHIP_ENC28J60_0_INT_GPIOS_FLAGS 0
#define DT_MICROCHIP_ENC28J60_0_INT_GPIOS_PIN 0
#define DT_MICROCHIP_ENC28J60_0_LABEL ""
#define DT_MICROCHIP_ENC28J60_0_LOCAL_MAC_ADDRESS_0 0
#define DT_MICROCHIP_ENC28J60_0_LOCAL_MAC_ADDRESS_1 0
#define DT_MICROCHIP_ENC28J60_0_LOCAL_MAC_ADDRESS_2 0
#define DT_MICROCHIP_ENC28J60_0_LOCAL_MAC_ADDRESS_3 0
#define DT_MICROCHIP_ENC28J60_0_LOCAL_MAC_ADDRESS_4 0
#define DT_MICROCHIP_ENC28J60_0_LOCAL_MAC_ADDRESS_5 0
#define DT_MICROCHIP_ENC28J60_0_SPI_MAX_FREQUENCY 0
#endif
#endif /* CONFIG_HAS_DTS_SPI */

View file

@ -10,6 +10,3 @@ CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_SPI=y
CONFIG_ETH_ENC28J60=y
CONFIG_ETH_ENC28J60_0=y
CONFIG_ETH_ENC28J60_0_MAC3=0x02
CONFIG_ETH_ENC28J60_0_MAC4=0xde
CONFIG_ETH_ENC28J60_0_MAC5=0xad