change log for rtems (2011-01-14)
rtems-vc at rtems.org
rtems-vc at rtems.org
Fri Jan 14 11:10:29 UTC 2011
*sh*:
2011-01-14 Sebastian Huber <sebastian.huber at embedded-brains.de>
* mpc83xx/network/tsec.c, mpc83xx/network/tsec.h: Use configuration
structure instead of many function parameters. Moved board specific
initializations. Added support for interfaces without PHY access.
M 1.368 c/src/lib/libcpu/powerpc/ChangeLog
M 1.3 c/src/lib/libcpu/powerpc/mpc83xx/network/tsec.h
M 1.11 c/src/lib/libcpu/powerpc/mpc83xx/network/tsec.c
diff -u rtems/c/src/lib/libcpu/powerpc/ChangeLog:1.367 rtems/c/src/lib/libcpu/powerpc/ChangeLog:1.368
--- rtems/c/src/lib/libcpu/powerpc/ChangeLog:1.367 Mon Jan 10 06:00:27 2011
+++ rtems/c/src/lib/libcpu/powerpc/ChangeLog Fri Jan 14 04:48:56 2011
@@ -1,3 +1,9 @@
+2011-01-14 Sebastian Huber <sebastian.huber at embedded-brains.de>
+
+ * mpc83xx/network/tsec.c, mpc83xx/network/tsec.h: Use configuration
+ structure instead of many function parameters. Moved board specific
+ initializations. Added support for interfaces without PHY access.
+
2011-01-09 Sebastian Huber <sebastian.huber at embedded-brains.de>
* new-exceptions/bspsupport/ppc_exc_categories.c: Fixed e200 machine
diff -u rtems/c/src/lib/libcpu/powerpc/mpc83xx/network/tsec.h:1.2 rtems/c/src/lib/libcpu/powerpc/mpc83xx/network/tsec.h:1.3
--- rtems/c/src/lib/libcpu/powerpc/mpc83xx/network/tsec.h:1.2 Thu Dec 30 07:09:47 2010
+++ rtems/c/src/lib/libcpu/powerpc/mpc83xx/network/tsec.h Fri Jan 14 04:48:57 2011
@@ -21,6 +21,8 @@
#define LIBCPU_POWERPC_TSEC_H
#include <stdint.h>
+
+#include <bsp/irq.h>
#include <bsp/tsec-config.h>
#ifdef __cplusplus
@@ -355,12 +357,19 @@
struct rtems_bsdnet_ifconfig;
+typedef struct {
+ int unit_number;
+ char *unit_name;
+ volatile tsec_registers *reg_ptr;
+ volatile tsec_registers *mdio_ptr;
+ rtems_irq_number irq_num_tx;
+ rtems_irq_number irq_num_rx;
+ rtems_irq_number irq_num_err;
+ int phy_default;
+} tsec_config;
+
int tsec_driver_attach_detach(
struct rtems_bsdnet_ifconfig *config,
- int unitNumber,
- char *unitName,
- volatile tsec_registers *reg_ptr,
- volatile tsec_registers *mdio_ptr,
int attaching
);
diff -u rtems/c/src/lib/libcpu/powerpc/mpc83xx/network/tsec.c:1.10 rtems/c/src/lib/libcpu/powerpc/mpc83xx/network/tsec.c:1.11
--- rtems/c/src/lib/libcpu/powerpc/mpc83xx/network/tsec.c:1.10 Thu Dec 30 07:09:47 2010
+++ rtems/c/src/lib/libcpu/powerpc/mpc83xx/network/tsec.c Fri Jan 14 04:48:56 2011
@@ -16,17 +16,11 @@
+-----------------------------------------------------------------+
| this file contains the MPC83xx TSEC networking driver |
\*===============================================================*/
-/*
- * this driver has the following HW assumptions:
- * - PHY for TSEC1 uses address 0
- * - PHY for TSEC2 uses address 1
- * - PHY uses GMII for 1000Base-T and MII for the rest of the modes
- */
+
#include <stdlib.h>
#include <bsp.h>
#include <bsp/irq.h>
#include <bsp/tsec.h>
-#include <libcpu/spr.h>
#include <rtems/error.h>
#include <rtems/bspIo.h>
#include <rtems/rtems_bsdnet.h>
@@ -43,17 +37,16 @@
#include <netinet/if_ether.h>
#include <stdio.h>
-/* System Version Register */
-#define SVR 286
-SPR_RO( SVR)
-
-/* Processor Version Register */
-SPR_RO( PVR)
-
#define CLREVENT_IN_IRQ
#define TSEC_WATCHDOG_TIMEOUT 5 /* check media every 5 seconds */
+#ifdef DEBUG
+ #define PF(fmt, ...) printk("%s: " fmt, __func__, ##__VA_ARGS__)
+#else
+ #define PF(...)
+#endif
+
/*
* Device data
*/
@@ -64,11 +57,11 @@
/*
* HW links: (filled from rtems_bsdnet_ifconfig
*/
- volatile tsec_registers *reg_ptr; /* pointer to TSEC register block */
- volatile tsec_registers *mdio_ptr; /* pointer to TSEC register block which is responsible for MDIO communication */
- int irq_num_tx; /* tx irq number */
- int irq_num_rx; /* rx irq number */
- int irq_num_err; /* error irq number */
+ volatile tsec_registers *reg_ptr; /* pointer to TSEC register block */
+ volatile tsec_registers *mdio_ptr; /* pointer to TSEC register block which is responsible for MDIO communication */
+ rtems_irq_number irq_num_tx;
+ rtems_irq_number irq_num_rx;
+ rtems_irq_number irq_num_err;
/*
* BD management
@@ -371,14 +364,12 @@
/* pointer to TSEC registers */
volatile tsec_registers *reg_ptr = sc->mdio_ptr;
+ PF("%u\n", reg);
/*
* make sure we work with a valid phy
*/
if (phy == -1) {
- /*
- * set default phy number: 0 for TSEC1, 1 for TSEC2
- */
phy = sc->phy_default;
}
if ( (phy < 0) || (phy > 31)) {
@@ -439,6 +430,7 @@
/* pointer to TSEC registers */
volatile tsec_registers *reg_ptr = sc->mdio_ptr;
+ PF("%u\n", reg);
/*
* make sure we work with a valid phy
@@ -622,6 +614,7 @@
- sizeof(struct ether_header));
eh = mtod(m, struct ether_header *);
m->m_data += sizeof(struct ether_header);
+ PF("RX[%08x] (%i)\n", BD_ptr, m->m_len);
ether_input(&sc->arpcom.ac_if,eh,m);
}
else {
@@ -1001,6 +994,7 @@
CurrBD->buffer = mtod(m, void *);
CurrBD->length = (uint32_t)m->m_len;
l = m; /* remember: we use this mbuf */
+ PF("TX[%08x] (%i)\n", CurrBD, m->m_len);
bd_idx = CurrBD - sc->Tx_Frst_BD;
sc->Tx_mBuf_Ptr[bd_idx] = m;
@@ -1147,6 +1141,7 @@
uint32_t irq_events;
#endif
+ PF("TXIRQ\n");
sc->txInterrupts++;
/*
* disable tx interrupts
@@ -1191,6 +1186,7 @@
#endif
sc->rxInterrupts++;
+ PF("RXIRQ\n");
/*
* disable rx interrupts
*/
@@ -1229,6 +1225,7 @@
{
struct tsec_struct *sc =
(struct tsec_struct *)handle;
+ PF("ERIRQ\n");
/*
* clear error events in IEVENT
*/
@@ -1689,8 +1686,6 @@
return error;
}
-/* #define DEBUG */
-
/*=========================================================================*\
| Function: |
\*-------------------------------------------------------------------------*/
@@ -1713,9 +1708,11 @@
struct tsec_struct *sc = ifp->if_softc;
int media = IFM_MAKEWORD( 0, 0, 0, sc->phy_default);
-#ifdef DEBUG
- printf("c");
-#endif
+ /* In case no PHY is available stop now */
+ if (sc->phy_default < 0) {
+ return 0;
+ }
+
/*
* fetch media status
*/
@@ -1723,9 +1720,7 @@
if (result != 0) {
return result;
}
-#ifdef DEBUG
- printf("C");
-#endif
+
/*
* status is unchanged? then do nothing
*/
@@ -1821,18 +1816,13 @@
ifp->if_timer = TSEC_WATCHDOG_TIMEOUT;
}
-static int tsec_driver_attach(
- struct rtems_bsdnet_ifconfig *config,
- int unitNumber,
- char *unitName,
- volatile tsec_registers *reg_ptr,
- volatile tsec_registers *mdio_ptr
-)
+static int tsec_driver_attach(struct rtems_bsdnet_ifconfig *config)
{
+ tsec_config *tsec_cfg = config->drv_ctrl;
+ int unitNumber = tsec_cfg->unit_number;
+ char *unitName = tsec_cfg->unit_name;
struct tsec_struct *sc;
struct ifnet *ifp;
- uint32_t svr = _read_SVR();
- uint32_t pvr = _read_PVR();
/*
* Is driver free?
@@ -1846,10 +1836,6 @@
sc = &tsec_driver[unitNumber - 1];
ifp = &sc->arpcom.ac_if;
- /*
- * add sc to config
- */
- config->drv_ctrl = sc;
if(ifp->if_softc != NULL) {
printk ("Driver already in use.\n");
@@ -1871,35 +1857,14 @@
sc->acceptBroadcast = !config->ignore_broadcast;
/* get pointer to TSEC register block */
- sc->reg_ptr = reg_ptr;
- sc->mdio_ptr = mdio_ptr;
+ sc->reg_ptr = tsec_cfg->reg_ptr;
+ sc->mdio_ptr = tsec_cfg->mdio_ptr;
- if (svr == 0x80b00010 && pvr == 0x80850010) {
- /*
- * This is a special case for MPC8313ERDB with silicon revision 1. Look in
- * "MPC8313ECE Rev. 3, 3/2008" errata for "IPIC 1".
- */
- if (unitNumber == 1) {
- sc->irq_num_tx = 37;
- sc->irq_num_rx = 36;
- sc->irq_num_err = 35;
- } else if (unitNumber == 2) {
- sc->irq_num_tx = 34;
- sc->irq_num_rx = 33;
- sc->irq_num_err = 32;
- } else {
- return 0;
- }
- } else {
- /* get base interrupt number (for Tx irq, Rx=base+1,Err=base+2) */
- sc->irq_num_tx = config->irno + 0; /* tx irq number from BSP */
- sc->irq_num_rx = config->irno + 1; /* rx irq number from BSP */
- sc->irq_num_err = config->irno + 2; /* err irq number from BSP */
- }
+ /* IRQ numbers */
+ sc->irq_num_tx = tsec_cfg->irq_num_tx;
+ sc->irq_num_rx = tsec_cfg->irq_num_rx;
+ sc->irq_num_err = tsec_cfg->irq_num_err;
- if (config->irno == 0) {
- rtems_panic("TSEC: interupt base number irno not defined");
- }
/*
* setup info about mdio interface
*/
@@ -1907,20 +1872,8 @@
sc->mdio_info.mdio_w = tsec_mdio_write;
sc->mdio_info.has_gmii = 1; /* we support gigabit IF */
- /*
- * XXX: Although most hardware builders will assign the PHY addresses
- * like this, this should be more configurable
- */
-#ifdef MPC8313ERDB
- if (unitNumber == 2) {
- sc->phy_default = 4;
- } else {
- /* TODO */
- return 0;
- }
-#else /* MPC8313ERDB */
- sc->phy_default = unitNumber-1;
-#endif /* MPC8313ERDB */
+ /* PHY address */
+ sc->phy_default = tsec_cfg->phy_default;
/*
* Set up network interface values
@@ -1954,21 +1907,11 @@
int tsec_driver_attach_detach(
struct rtems_bsdnet_ifconfig *config,
- int unitNumber,
- char *unitName,
- volatile tsec_registers *reg_ptr,
- volatile tsec_registers *mdio_ptr,
int attaching
)
{
if (attaching) {
- return tsec_driver_attach(
- config,
- unitNumber,
- unitName,
- reg_ptr,
- mdio_ptr
- );
+ return tsec_driver_attach(config);
} else {
return 0;
}
*sh*:
2011-01-14 Sebastian Huber <sebastian.huber at embedded-brains.de>
* network/network.c: Moved initializations from generic TSEC driver
part.
M 1.98 c/src/lib/libbsp/powerpc/gen83xx/ChangeLog
M 1.16 c/src/lib/libbsp/powerpc/gen83xx/network/network.c
diff -u rtems/c/src/lib/libbsp/powerpc/gen83xx/ChangeLog:1.97 rtems/c/src/lib/libbsp/powerpc/gen83xx/ChangeLog:1.98
--- rtems/c/src/lib/libbsp/powerpc/gen83xx/ChangeLog:1.97 Thu Dec 30 07:16:41 2010
+++ rtems/c/src/lib/libbsp/powerpc/gen83xx/ChangeLog Fri Jan 14 04:54:06 2011
@@ -1,3 +1,8 @@
+2011-01-14 Sebastian Huber <sebastian.huber at embedded-brains.de>
+
+ * network/network.c: Moved initializations from generic TSEC driver
+ part.
+
2010-12-30 Sebastian Huber <sebastian.huber at embedded-brains.de>
* include/u-boot.h: Removed file.
diff -u rtems/c/src/lib/libbsp/powerpc/gen83xx/network/network.c:1.15 rtems/c/src/lib/libbsp/powerpc/gen83xx/network/network.c:1.16
--- rtems/c/src/lib/libbsp/powerpc/gen83xx/network/network.c:1.15 Thu Dec 30 08:05:34 2010
+++ rtems/c/src/lib/libbsp/powerpc/gen83xx/network/network.c Fri Jan 14 04:54:06 2011
@@ -25,7 +25,8 @@
#include <bsp/tsec.h>
#include <bsp/u-boot.h>
#include <mpc83xx/mpc83xx.h>
-#include <stdio.h>
+#include <string.h>
+#include <libcpu/spr.h>
#define TSEC_IFMODE_RGMII 0
#define TSEC_IFMODE_GMII 1
@@ -48,6 +49,13 @@
#endif
+/* System Version Register */
+#define SVR 286
+SPR_RO( SVR)
+
+/* Processor Version Register */
+SPR_RO( PVR)
+
/*=========================================================================*\
| Function: |
\*-------------------------------------------------------------------------*/
@@ -67,8 +75,14 @@
| 1, if success |
\*=========================================================================*/
{
+ tsec_config tsec_cfg;
int unitNumber;
char *unitName;
+ uint32_t svr = _read_SVR();
+ uint32_t pvr = _read_PVR();
+
+ memset(&tsec_cfg, 0, sizeof(tsec_cfg));
+ config->drv_ctrl = &tsec_cfg;
/*
* Parse driver name
@@ -76,6 +90,10 @@
if((unitNumber = rtems_bsdnet_parse_driver_name(config, &unitName)) < 0) {
return 0;
}
+
+ tsec_cfg.reg_ptr = &mpc83xx.tsec [unitNumber - 1];
+ tsec_cfg.mdio_ptr = &mpc83xx.tsec [0];
+
if (attaching) {
#if (TSEC_IFMODE==TSEC_IFMODE_GMII)
#if !defined(HSC_CM01)
@@ -126,11 +144,10 @@
if (config->hardware_address == NULL) {
#if !defined(HAS_UBOOT)
static char hw_addr [TSEC_COUNT][6];
- volatile tsec_registers *reg_ptr;
+ volatile tsec_registers *reg_ptr = tsec_cfg->reg_ptr;
/* read MAC address from hardware register */
/* we expect it htere from the boot loader */
- reg_ptr = &mpc83xx.tsec[unitNumber - 1];
config->hardware_address = hw_addr[unitNumber-1];
hw_addr[unitNumber-1][5] = (reg_ptr->macstnaddr[0] >> 24) & 0xff;
@@ -180,15 +197,53 @@
? BSP_IPIC_IRQ_TSEC1_TX
: BSP_IPIC_IRQ_TSEC2_TX
);
+
+ if (svr == 0x80b00010 && pvr == 0x80850010) {
+ /*
+ * This is a special case for MPC8313ERDB with silicon revision 1. Look in
+ * "MPC8313ECE Rev. 3, 3/2008" errata for "IPIC 1".
+ */
+ if (unitNumber == 1) {
+ tsec_cfg.irq_num_tx = 37;
+ tsec_cfg.irq_num_rx = 36;
+ tsec_cfg.irq_num_err = 35;
+ } else if (unitNumber == 2) {
+ tsec_cfg.irq_num_tx = 34;
+ tsec_cfg.irq_num_rx = 33;
+ tsec_cfg.irq_num_err = 32;
+ } else {
+ return 0;
+ }
+ } else {
+ rtems_irq_number irno = unitNumber == 1 ?
+ BSP_IPIC_IRQ_TSEC1_TX : BSP_IPIC_IRQ_TSEC2_TX;
+
+ /* get base interrupt number (for Tx irq, Rx=base+1,Err=base+2) */
+ tsec_cfg.irq_num_tx = irno + 0;
+ tsec_cfg.irq_num_rx = irno + 1;
+ tsec_cfg.irq_num_err = irno + 2;
+ }
+
+ /*
+ * XXX: Although most hardware builders will assign the PHY addresses
+ * like this, this should be more configurable
+ */
+#ifdef MPC8313ERDB
+ if (unitNumber == 2) {
+ tsec_cfg.phy_default = 4;
+ } else {
+ /* TODO */
+ return 0;
+ }
+#else /* MPC8313ERDB */
+ tsec_cfg.phy_default = unitNumber-1;
+#endif /* MPC8313ERDB */
+
+ tsec_cfg.unit_number = unitNumber;
+ tsec_cfg.unit_name = unitName;
+
/*
* call attach function of board independent driver
*/
- return tsec_driver_attach_detach(
- config,
- unitNumber,
- unitName,
- &mpc83xx.tsec [unitNumber - 1],
- &mpc83xx.tsec [0],
- attaching
- );
+ return tsec_driver_attach_detach(config, attaching);
}
--
Generated by Deluxe Loginfo [http://www.codewiz.org/projects/index.html#loginfo] 2.122 by Bernardo Innocenti <bernie at develer.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/vc/attachments/20110114/744c7668/attachment.html>
More information about the vc
mailing list