2018-09-19 11:51:47 +02:00
|
|
|
/* Stellaris Ethernet Controller
|
|
|
|
*
|
|
|
|
* Copyright (c) 2018 Zilogic Systems
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2020-03-24 22:18:30 +01:00
|
|
|
#define DT_DRV_COMPAT ti_stellaris_ethernet
|
|
|
|
|
2018-09-19 11:51:47 +02:00
|
|
|
#define LOG_MODULE_NAME eth_stellaris
|
|
|
|
#define LOG_LEVEL CONFIG_ETHERNET_LOG_LEVEL
|
2022-05-06 10:25:46 +02:00
|
|
|
#include <zephyr/logging/log.h>
|
2018-09-19 11:51:47 +02:00
|
|
|
LOG_MODULE_REGISTER(LOG_MODULE_NAME);
|
|
|
|
|
2022-05-06 10:25:46 +02:00
|
|
|
#include <zephyr/net/ethernet.h>
|
|
|
|
#include <zephyr/net/net_pkt.h>
|
|
|
|
#include <zephyr/net/net_if.h>
|
|
|
|
#include <zephyr/device.h>
|
2018-09-19 11:51:47 +02:00
|
|
|
#include <soc.h>
|
|
|
|
#include <ethernet/eth_stats.h>
|
2022-10-17 10:24:11 +02:00
|
|
|
#include <zephyr/irq.h>
|
2018-09-19 11:51:47 +02:00
|
|
|
#include "eth_stellaris_priv.h"
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static void eth_stellaris_assign_mac(const struct device *dev)
|
2018-09-19 11:51:47 +02:00
|
|
|
{
|
2020-05-27 18:26:57 +02:00
|
|
|
uint8_t mac_addr[6] = DT_INST_PROP(0, local_mac_address);
|
|
|
|
uint32_t value = 0x0;
|
2018-09-19 11:51:47 +02:00
|
|
|
|
2019-07-10 18:52:32 +02:00
|
|
|
value |= mac_addr[0];
|
|
|
|
value |= mac_addr[1] << 8;
|
|
|
|
value |= mac_addr[2] << 16;
|
|
|
|
value |= mac_addr[3] << 24;
|
2018-09-19 11:51:47 +02:00
|
|
|
sys_write32(value, REG_MACIA0);
|
|
|
|
|
|
|
|
value = 0x0;
|
2019-07-10 18:52:32 +02:00
|
|
|
value |= mac_addr[4];
|
|
|
|
value |= mac_addr[5] << 8;
|
2018-09-19 11:51:47 +02:00
|
|
|
sys_write32(value, REG_MACIA1);
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static void eth_stellaris_flush(const struct device *dev)
|
2018-09-19 11:51:47 +02:00
|
|
|
{
|
2022-01-18 15:48:18 +01:00
|
|
|
struct eth_stellaris_runtime *dev_data = dev->data;
|
2018-09-19 11:51:47 +02:00
|
|
|
|
|
|
|
if (dev_data->tx_pos != 0) {
|
|
|
|
sys_write32(dev_data->tx_word, REG_MACDATA);
|
|
|
|
dev_data->tx_pos = 0;
|
2019-03-27 02:57:45 +01:00
|
|
|
dev_data->tx_word = 0U;
|
2018-09-19 11:51:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static void eth_stellaris_send_byte(const struct device *dev, uint8_t byte)
|
2018-09-19 11:51:47 +02:00
|
|
|
{
|
2022-01-18 15:48:18 +01:00
|
|
|
struct eth_stellaris_runtime *dev_data = dev->data;
|
2018-09-19 11:51:47 +02:00
|
|
|
|
|
|
|
dev_data->tx_word |= byte << (dev_data->tx_pos * 8);
|
|
|
|
dev_data->tx_pos++;
|
|
|
|
if (dev_data->tx_pos == 4) {
|
|
|
|
sys_write32(dev_data->tx_word, REG_MACDATA);
|
|
|
|
dev_data->tx_pos = 0;
|
2019-03-27 02:57:45 +01:00
|
|
|
dev_data->tx_word = 0U;
|
2018-09-19 11:51:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int eth_stellaris_send(const struct device *dev, struct net_pkt *pkt)
|
2018-09-19 11:51:47 +02:00
|
|
|
{
|
2022-01-18 15:48:18 +01:00
|
|
|
struct eth_stellaris_runtime *dev_data = dev->data;
|
2018-09-19 11:51:47 +02:00
|
|
|
struct net_buf *frag;
|
2020-05-27 18:26:57 +02:00
|
|
|
uint16_t i, data_len;
|
2018-09-19 11:51:47 +02:00
|
|
|
|
|
|
|
/* Frame transmission
|
2019-04-06 06:59:30 +02:00
|
|
|
*
|
|
|
|
* First two bytes is the length of the frame, exclusive of
|
|
|
|
* the header length.
|
2018-09-19 11:51:47 +02:00
|
|
|
*/
|
2019-04-06 06:59:30 +02:00
|
|
|
data_len = net_pkt_get_len(pkt) - sizeof(struct net_eth_hdr);
|
2018-09-19 11:51:47 +02:00
|
|
|
eth_stellaris_send_byte(dev, data_len & 0xff);
|
|
|
|
eth_stellaris_send_byte(dev, (data_len & 0xff00) >> 8);
|
|
|
|
|
|
|
|
/* Send the payload */
|
|
|
|
for (frag = pkt->frags; frag; frag = frag->frags) {
|
2019-03-27 02:57:45 +01:00
|
|
|
for (i = 0U; i < frag->len; ++i) {
|
2018-09-19 11:51:47 +02:00
|
|
|
eth_stellaris_send_byte(dev, frag->data[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Will transmit the partial word. */
|
|
|
|
eth_stellaris_flush(dev);
|
|
|
|
|
|
|
|
/* Enable transmit. */
|
|
|
|
sys_write32(BIT_MACTR_NEWTX, REG_MACTR);
|
|
|
|
|
|
|
|
/* Wait and check if transmit successful or not. */
|
|
|
|
k_sem_take(&dev_data->tx_sem, K_FOREVER);
|
|
|
|
|
|
|
|
if (dev_data->tx_err) {
|
|
|
|
dev_data->tx_err = false;
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
2018-12-05 14:54:41 +01:00
|
|
|
LOG_DBG("pkt sent %p len %d", pkt, data_len);
|
2018-09-19 11:51:47 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void eth_stellaris_rx_error(struct net_if *iface)
|
|
|
|
{
|
2020-04-30 20:33:38 +02:00
|
|
|
const struct device *dev = net_if_get_device(iface);
|
2020-05-27 18:26:57 +02:00
|
|
|
uint32_t val;
|
2018-09-19 11:51:47 +02:00
|
|
|
|
|
|
|
eth_stats_update_errors_rx(iface);
|
|
|
|
|
|
|
|
/* Clear the rx_frame buffer,
|
|
|
|
* otherwise it could lead to underflow errors
|
|
|
|
*/
|
|
|
|
sys_write32(0x0, REG_MACRCTL);
|
|
|
|
sys_write32(BIT_MACRCTL_RSTFIFO, REG_MACRCTL);
|
|
|
|
val = BIT_MACRCTL_BADCRC | BIT_MACRCTL_RXEN;
|
|
|
|
sys_write32(val, REG_MACRCTL);
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static struct net_pkt *eth_stellaris_rx_pkt(const struct device *dev,
|
2019-02-20 11:26:34 +01:00
|
|
|
struct net_if *iface)
|
2018-09-19 11:51:47 +02:00
|
|
|
{
|
|
|
|
int frame_len, bytes_left;
|
2019-02-20 11:26:34 +01:00
|
|
|
struct net_pkt *pkt;
|
2020-05-27 18:26:57 +02:00
|
|
|
uint32_t reg_val;
|
|
|
|
uint16_t count;
|
|
|
|
uint8_t *data;
|
2018-09-19 11:51:47 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The Ethernet frame received from the hardware has the
|
|
|
|
* following format. The first two bytes contains the ethernet
|
|
|
|
* frame length, followed by the actual ethernet frame.
|
|
|
|
*
|
|
|
|
* +---------+---- ... -------+
|
|
|
|
* | Length | Ethernet Frame |
|
|
|
|
* +---------+---- ... -------+
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The first word contains the frame length and a portion of
|
|
|
|
* the ethernet frame. Extract the frame length.
|
|
|
|
*/
|
|
|
|
reg_val = sys_read32(REG_MACDATA);
|
|
|
|
frame_len = reg_val & 0x0000ffff;
|
|
|
|
|
2019-02-20 11:26:34 +01:00
|
|
|
pkt = net_pkt_rx_alloc_with_buffer(iface, frame_len,
|
|
|
|
AF_UNSPEC, 0, K_NO_WAIT);
|
|
|
|
if (!pkt) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-09-19 11:51:47 +02:00
|
|
|
/*
|
|
|
|
* The remaining 2 bytes, in the first word is appended to the
|
|
|
|
* ethernet frame.
|
|
|
|
*/
|
2019-03-27 02:57:45 +01:00
|
|
|
count = 2U;
|
2020-05-27 18:26:57 +02:00
|
|
|
data = (uint8_t *)®_val + 2;
|
2019-02-20 10:01:57 +01:00
|
|
|
if (net_pkt_write(pkt, data, count)) {
|
2019-02-20 11:26:34 +01:00
|
|
|
goto error;
|
2018-09-19 11:51:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* A word has been read already, thus minus 4 bytes to be read. */
|
|
|
|
bytes_left = frame_len - 4;
|
|
|
|
|
|
|
|
/* Read the rest of words, minus the partial word and FCS byte. */
|
|
|
|
for (; bytes_left > 7; bytes_left -= 4) {
|
|
|
|
reg_val = sys_read32(REG_MACDATA);
|
2019-03-27 02:57:45 +01:00
|
|
|
count = 4U;
|
2020-05-27 18:26:57 +02:00
|
|
|
data = (uint8_t *)®_val;
|
2019-02-20 10:01:57 +01:00
|
|
|
if (net_pkt_write(pkt, data, count)) {
|
2019-02-20 11:26:34 +01:00
|
|
|
goto error;
|
2018-09-19 11:51:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle the last partial word and discard the 4 Byte FCS. */
|
|
|
|
while (bytes_left > 0) {
|
|
|
|
/* Read the partial word. */
|
|
|
|
reg_val = sys_read32(REG_MACDATA);
|
|
|
|
|
|
|
|
/* Discard the last FCS word. */
|
|
|
|
if (bytes_left <= 4) {
|
|
|
|
bytes_left = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
count = bytes_left - 4;
|
2020-05-27 18:26:57 +02:00
|
|
|
data = (uint8_t *)®_val;
|
2019-02-20 10:01:57 +01:00
|
|
|
if (net_pkt_write(pkt, data, count)) {
|
2019-02-20 11:26:34 +01:00
|
|
|
goto error;
|
2018-09-19 11:51:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bytes_left -= 4;
|
|
|
|
}
|
|
|
|
|
2019-02-20 11:26:34 +01:00
|
|
|
return pkt;
|
|
|
|
|
|
|
|
error:
|
|
|
|
net_pkt_unref(pkt);
|
|
|
|
|
|
|
|
return NULL;
|
2018-09-19 11:51:47 +02:00
|
|
|
}
|
|
|
|
|
2024-03-20 15:40:31 +01:00
|
|
|
static int eth_stellaris_rx(const struct device *dev)
|
2018-09-19 11:51:47 +02:00
|
|
|
{
|
2022-01-18 15:48:18 +01:00
|
|
|
struct eth_stellaris_runtime *dev_data = dev->data;
|
2018-09-19 11:51:47 +02:00
|
|
|
struct net_if *iface = dev_data->iface;
|
2019-02-20 11:26:34 +01:00
|
|
|
struct net_pkt *pkt;
|
2018-09-19 11:51:47 +02:00
|
|
|
|
2019-02-20 11:26:34 +01:00
|
|
|
pkt = eth_stellaris_rx_pkt(dev, iface);
|
2018-09-19 11:51:47 +02:00
|
|
|
if (!pkt) {
|
2019-02-20 11:26:34 +01:00
|
|
|
LOG_ERR("Failed to read data");
|
2018-09-19 11:51:47 +02:00
|
|
|
goto err_mem;
|
|
|
|
}
|
|
|
|
|
2019-02-20 11:26:34 +01:00
|
|
|
if (net_recv_data(iface, pkt) < 0) {
|
2018-09-19 11:51:47 +02:00
|
|
|
LOG_ERR("Failed to place frame in RX Queue");
|
|
|
|
goto pkt_unref;
|
|
|
|
}
|
|
|
|
|
2024-03-20 15:40:31 +01:00
|
|
|
return 0;
|
2018-09-19 11:51:47 +02:00
|
|
|
|
|
|
|
pkt_unref:
|
|
|
|
net_pkt_unref(pkt);
|
|
|
|
|
|
|
|
err_mem:
|
|
|
|
eth_stellaris_rx_error(iface);
|
2024-03-20 15:40:31 +01:00
|
|
|
return -EIO;
|
2018-09-19 11:51:47 +02:00
|
|
|
}
|
|
|
|
|
isr: Normalize usage of device instance through ISR
The goal of this patch is to replace the 'void *' parameter by 'struct
device *' if they use such variable or just 'const void *' on all
relevant ISRs
This will avoid not-so-nice const qualifier tweaks when device instances
will be constant.
Note that only the ISR passed to IRQ_CONNECT are of interest here.
In order to do so, the script fix_isr.py below is necessary:
from pathlib import Path
import subprocess
import pickle
import mmap
import sys
import re
import os
cocci_template = """
@r_fix_isr_0
@
type ret_type;
identifier P;
identifier D;
@@
-ret_type <!fn!>(void *P)
+ret_type <!fn!>(const struct device *P)
{
...
(
const struct device *D = (const struct device *)P;
|
const struct device *D = P;
)
...
}
@r_fix_isr_1
@
type ret_type;
identifier P;
identifier D;
@@
-ret_type <!fn!>(void *P)
+ret_type <!fn!>(const struct device *P)
{
...
const struct device *D;
...
(
D = (const struct device *)P;
|
D = P;
)
...
}
@r_fix_isr_2
@
type ret_type;
identifier A;
@@
-ret_type <!fn!>(void *A)
+ret_type <!fn!>(const void *A)
{
...
}
@r_fix_isr_3
@
const struct device *D;
@@
-<!fn!>((void *)D);
+<!fn!>(D);
@r_fix_isr_4
@
type ret_type;
identifier D;
identifier P;
@@
-ret_type <!fn!>(const struct device *P)
+ret_type <!fn!>(const struct device *D)
{
...
(
-const struct device *D = (const struct device *)P;
|
-const struct device *D = P;
)
...
}
@r_fix_isr_5
@
type ret_type;
identifier D;
identifier P;
@@
-ret_type <!fn!>(const struct device *P)
+ret_type <!fn!>(const struct device *D)
{
...
-const struct device *D;
...
(
-D = (const struct device *)P;
|
-D = P;
)
...
}
"""
def find_isr(fn):
db = []
data = None
start = 0
try:
with open(fn, 'r+') as f:
data = str(mmap.mmap(f.fileno(), 0).read())
except Exception as e:
return db
while True:
isr = ""
irq = data.find('IRQ_CONNECT', start)
while irq > -1:
p = 1
arg = 1
p_o = data.find('(', irq)
if p_o < 0:
irq = -1
break;
pos = p_o + 1
while p > 0:
if data[pos] == ')':
p -= 1
elif data[pos] == '(':
p += 1
elif data[pos] == ',' and p == 1:
arg += 1
if arg == 3:
isr += data[pos]
pos += 1
isr = isr.strip(',\\n\\t ')
if isr not in db and len(isr) > 0:
db.append(isr)
start = pos
break
if irq < 0:
break
return db
def patch_isr(fn, isr_list):
if len(isr_list) <= 0:
return
for isr in isr_list:
tmplt = cocci_template.replace('<!fn!>', isr)
with open('/tmp/isr_fix.cocci', 'w') as f:
f.write(tmplt)
cmd = ['spatch', '--sp-file', '/tmp/isr_fix.cocci', '--in-place', fn]
subprocess.run(cmd)
def process_files(path):
if path.is_file() and path.suffix in ['.h', '.c']:
p = str(path.parent) + '/' + path.name
isr_list = find_isr(p)
patch_isr(p, isr_list)
elif path.is_dir():
for p in path.iterdir():
process_files(p)
if len(sys.argv) < 2:
print("You need to provide a dir/file path")
sys.exit(1)
process_files(Path(sys.argv[1]))
And is run: ./fix_isr.py <zephyr root directory>
Finally, some files needed manual fixes such.
Fixes #27399
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-06-17 14:58:56 +02:00
|
|
|
static void eth_stellaris_isr(const struct device *dev)
|
2018-09-19 11:51:47 +02:00
|
|
|
{
|
2022-01-18 15:48:18 +01:00
|
|
|
struct eth_stellaris_runtime *dev_data = dev->data;
|
2018-09-19 11:51:47 +02:00
|
|
|
int isr_val = sys_read32(REG_MACRIS);
|
2024-03-20 15:40:31 +01:00
|
|
|
int num_packets;
|
2020-05-27 18:26:57 +02:00
|
|
|
uint32_t lock;
|
2018-09-19 11:51:47 +02:00
|
|
|
|
|
|
|
lock = irq_lock();
|
|
|
|
|
|
|
|
/* Acknowledge the interrupt. */
|
|
|
|
sys_write32(isr_val, REG_MACRIS);
|
|
|
|
|
|
|
|
if (isr_val & BIT_MACRIS_RXINT) {
|
2024-03-20 15:40:31 +01:00
|
|
|
/*
|
|
|
|
* When multiple packets are received by the Ethernet,
|
|
|
|
* only one interrupt may be dispatched to the driver
|
|
|
|
* Therefore, it is necessary to obtain the register NP value
|
|
|
|
* to get how many packets are in the Ethernet.
|
|
|
|
*/
|
|
|
|
num_packets = sys_read32(REG_MACNP);
|
2024-04-10 09:08:19 +02:00
|
|
|
for (int i = 0; i < num_packets; i++) {
|
2024-03-20 15:40:31 +01:00
|
|
|
if (eth_stellaris_rx(dev) != 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-09-19 11:51:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isr_val & BIT_MACRIS_TXEMP) {
|
|
|
|
dev_data->tx_err = false;
|
|
|
|
k_sem_give(&dev_data->tx_sem);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isr_val & BIT_MACRIS_TXER) {
|
|
|
|
LOG_ERR("Transmit Frame Error");
|
|
|
|
eth_stats_update_errors_tx(dev_data->iface);
|
|
|
|
dev_data->tx_err = true;
|
|
|
|
k_sem_give(&dev_data->tx_sem);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isr_val & BIT_MACRIS_RXER) {
|
|
|
|
LOG_ERR("Error Receiving Frame");
|
|
|
|
eth_stellaris_rx_error(dev_data->iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isr_val & BIT_MACRIS_FOV) {
|
|
|
|
LOG_ERR("Error Rx Overrun");
|
|
|
|
eth_stellaris_rx_error(dev_data->iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
irq_unlock(lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void eth_stellaris_init(struct net_if *iface)
|
|
|
|
{
|
2020-04-30 20:33:38 +02:00
|
|
|
const struct device *dev = net_if_get_device(iface);
|
2022-01-18 15:48:18 +01:00
|
|
|
const struct eth_stellaris_config *dev_conf = dev->config;
|
|
|
|
struct eth_stellaris_runtime *dev_data = dev->data;
|
2018-09-19 11:51:47 +02:00
|
|
|
|
|
|
|
dev_data->iface = iface;
|
|
|
|
|
|
|
|
/* Assign link local address. */
|
|
|
|
net_if_set_link_addr(iface,
|
|
|
|
dev_data->mac_addr, 6, NET_LINK_ETHERNET);
|
|
|
|
|
|
|
|
ethernet_init(iface);
|
|
|
|
|
|
|
|
/* Initialize semaphore. */
|
|
|
|
k_sem_init(&dev_data->tx_sem, 0, 1);
|
|
|
|
|
|
|
|
/* Initialize Interrupts. */
|
|
|
|
dev_conf->config_func(dev);
|
|
|
|
}
|
|
|
|
|
2019-02-28 14:08:30 +01:00
|
|
|
#if defined(CONFIG_NET_STATISTICS_ETHERNET)
|
2020-04-30 20:33:38 +02:00
|
|
|
static struct net_stats_eth *eth_stellaris_stats(const struct device *dev)
|
2018-09-19 11:51:47 +02:00
|
|
|
{
|
2022-01-18 15:48:18 +01:00
|
|
|
struct eth_stellaris_runtime *dev_data = dev->data;
|
|
|
|
|
2022-03-10 19:47:38 +01:00
|
|
|
return &dev_data->stats;
|
2018-09-19 11:51:47 +02:00
|
|
|
}
|
2019-02-28 14:08:30 +01:00
|
|
|
#endif
|
2018-09-19 11:51:47 +02:00
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int eth_stellaris_dev_init(const struct device *dev)
|
2018-09-19 11:51:47 +02:00
|
|
|
{
|
2020-05-27 18:26:57 +02:00
|
|
|
uint32_t value;
|
2018-09-19 11:51:47 +02:00
|
|
|
|
|
|
|
/* Assign MAC address to Hardware */
|
|
|
|
eth_stellaris_assign_mac(dev);
|
|
|
|
|
|
|
|
/* Program MCRCTL to clear RXFIFO */
|
|
|
|
value = BIT_MACRCTL_RSTFIFO;
|
|
|
|
sys_write32(value, REG_MACRCTL);
|
|
|
|
|
|
|
|
/* Enable transmitter */
|
|
|
|
value = BIT_MACTCTL_DUPLEX | BIT_MACTCTL_CRC |
|
|
|
|
BIT_MACTCTL_PADEN | BIT_MACTCTL_TXEN;
|
|
|
|
sys_write32(value, REG_MACTCTL);
|
|
|
|
|
|
|
|
/* Enable Receiver */
|
|
|
|
value = BIT_MACRCTL_BADCRC | BIT_MACRCTL_RXEN;
|
|
|
|
sys_write32(value, REG_MACRCTL);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static void eth_stellaris_irq_config(const struct device *dev)
|
2018-09-19 11:51:47 +02:00
|
|
|
{
|
|
|
|
/* Enable Interrupt. */
|
2020-03-24 22:18:30 +01:00
|
|
|
IRQ_CONNECT(DT_INST_IRQN(0),
|
|
|
|
DT_INST_IRQ(0, priority),
|
2020-12-16 18:17:24 +01:00
|
|
|
eth_stellaris_isr, DEVICE_DT_INST_GET(0), 0);
|
2020-03-24 22:18:30 +01:00
|
|
|
irq_enable(DT_INST_IRQN(0));
|
2018-09-19 11:51:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
struct eth_stellaris_config eth_cfg = {
|
2020-03-24 22:18:30 +01:00
|
|
|
.mac_base = DT_INST_REG_ADDR(0),
|
2018-09-19 11:51:47 +02:00
|
|
|
.config_func = eth_stellaris_irq_config,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct eth_stellaris_runtime eth_data = {
|
2020-03-24 22:18:30 +01:00
|
|
|
.mac_addr = DT_INST_PROP(0, local_mac_address),
|
2018-09-19 11:51:47 +02:00
|
|
|
.tx_err = false,
|
|
|
|
.tx_word = 0,
|
|
|
|
.tx_pos = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct ethernet_api eth_stellaris_apis = {
|
|
|
|
.iface_api.init = eth_stellaris_init,
|
2018-12-05 09:50:21 +01:00
|
|
|
.send = eth_stellaris_send,
|
2019-02-28 14:08:30 +01:00
|
|
|
#if defined(CONFIG_NET_STATISTICS_ETHERNET)
|
|
|
|
.get_stats = eth_stellaris_stats,
|
|
|
|
#endif
|
2018-09-19 11:51:47 +02:00
|
|
|
};
|
|
|
|
|
2020-12-16 18:17:24 +01:00
|
|
|
NET_DEVICE_DT_INST_DEFINE(0,
|
2021-04-28 10:43:35 +02:00
|
|
|
eth_stellaris_dev_init, NULL,
|
2020-02-25 10:45:25 +01:00
|
|
|
ð_data, ð_cfg, CONFIG_ETH_INIT_PRIORITY,
|
2018-09-19 11:51:47 +02:00
|
|
|
ð_stellaris_apis, ETHERNET_L2,
|
2019-03-14 13:06:54 +01:00
|
|
|
NET_L2_GET_CTX_TYPE(ETHERNET_L2), NET_ETH_MTU);
|