summaryrefslogtreecommitdiffstats
path: root/bsps/sparc/leon3/net/leon_open_eth.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-04-20 13:36:14 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-04-20 14:10:08 +0200
commitb15cb636e18f7810f529ecb66f99eaf1ac1c18c9 (patch)
treea23e152f9139093aab4c480dfd6392383ad489b6 /bsps/sparc/leon3/net/leon_open_eth.c
parentbsps/sparc: Move shared files to bsps (diff)
downloadrtems-b15cb636e18f7810f529ecb66f99eaf1ac1c18c9.tar.bz2
bsps/sparc: Move network drivers to bsps
This patch is a part of the BSP source reorganization. Update #3285.
Diffstat (limited to 'bsps/sparc/leon3/net/leon_open_eth.c')
-rw-r--r--bsps/sparc/leon3/net/leon_open_eth.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/bsps/sparc/leon3/net/leon_open_eth.c b/bsps/sparc/leon3/net/leon_open_eth.c
new file mode 100644
index 0000000000..c59d613d75
--- /dev/null
+++ b/bsps/sparc/leon3/net/leon_open_eth.c
@@ -0,0 +1,75 @@
+/**
+ * @file
+ * @ingroup sparc_leon3
+ * @brief LEON3 Opencores Ethernet MAC Configuration Information
+ */
+
+/*
+ * Copyright (c) 2004.
+ * Aeroflex Gaisler AB.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#define __INSIDE_RTEMS_BSD_TCPIP_STACK__
+
+#include <bsp.h>
+#include <libchip/open_eth.h>
+#if (OPEN_ETH_DEBUG & OPEN_ETH_DEBUG_PRINT_REGISTERS)
+#include <stdio.h>
+#endif
+
+/*
+ * Default sizes of transmit and receive descriptor areas
+ */
+#define RDA_COUNT 16
+#define TDA_COUNT 16
+
+open_eth_configuration_t leon_open_eth_configuration;
+
+int rtems_leon_open_eth_driver_attach(
+ struct rtems_bsdnet_ifconfig *config,
+ int attach
+)
+{
+ unsigned int base_addr = 0; /* avoid warnings */
+ unsigned int eth_irq = 0; /* avoid warnings */
+ struct ambapp_dev *adev;
+ struct ambapp_ahb_info *ahb;
+
+ /* Scan for MAC AHB slave interface */
+ adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_AHB_SLVS),
+ VENDOR_OPENCORES, OPENCORES_ETHMAC,
+ ambapp_find_by_idx, NULL);
+ if (!adev) {
+ adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_AHB_SLVS),
+ VENDOR_GAISLER, GAISLER_ETHAHB,
+ ambapp_find_by_idx, NULL);
+ }
+
+ if (adev)
+ {
+ ahb = DEV_TO_AHB(adev);
+ base_addr = ahb->start[0];
+ eth_irq = ahb->irq;
+
+ /* clear control register and reset NIC */
+ *(volatile int *) base_addr = 0;
+ *(volatile int *) base_addr = 0x800;
+ *(volatile int *) base_addr = 0;
+ leon_open_eth_configuration.base_address = (void *) base_addr;
+ leon_open_eth_configuration.vector = eth_irq + 0x10;
+ leon_open_eth_configuration.txd_count = TDA_COUNT;
+ leon_open_eth_configuration.rxd_count = RDA_COUNT;
+ /* enable 100 MHz operation only if cpu frequency >= 50 MHz */
+ if (LEON3_Timer_Regs->scaler_reload >= 49)
+ leon_open_eth_configuration.en100MHz = 1;
+ if (rtems_open_eth_driver_attach( config, &leon_open_eth_configuration )) {
+ LEON_Clear_interrupt(eth_irq);
+ LEON_Unmask_interrupt(eth_irq);
+ }
+ }
+ return 0;
+}