Skip to content
Snippets Groups Projects
Commit 0e8b222a authored by Grzegorz Daniluk's avatar Grzegorz Daniluk
Browse files

adding shell command to disable the SFP transmitting laser

parent 0376b6f1
Branches
Tags
No related merge requests found
......@@ -74,6 +74,7 @@ void ep_init(uint8_t mac_addr[])
{
EP = (volatile struct EP_WB *)BASE_EP;
set_mac_addr(mac_addr);
ep_sfp_enable(1);
*(unsigned int *)(0x62000) = 0x2; // reset network stuff (cleanup required!)
*(unsigned int *)(0x62000) = 0;
......@@ -193,3 +194,16 @@ int ep_timestamper_cal_pulse()
timer_delay_ms(1);
return EP->TSCR & EP_TSCR_RX_CAL_RESULT ? 1 : 0;
}
int ep_sfp_enable(int ena)
{
uint32_t val;
val = pcs_read(MDIO_REG_ECTRL);
if(ena)
val &= (~MDIO_ECTRL_SFP_TX_DISABLE);
else
val |= MDIO_ECTRL_SFP_TX_DISABLE;
pcs_write(MDIO_REG_ECTRL, val);
return 0;
}
......@@ -28,6 +28,7 @@ int ep_get_psval(int32_t * psval);
int ep_cal_pattern_enable(void);
int ep_cal_pattern_disable(void);
int ep_timestamper_cal_pulse(void);
int ep_sfp_enable(int ena);
void pfilter_init_default(void);
......
......@@ -3,7 +3,7 @@
* File : endpoint_mdio.h
* Author : auto-generated by wbgen2 from pcs_regs.wb
* Created : Tue Jan 14 10:24:03 2014
* Created : Thu Aug 6 10:27:26 2015
* Standard : ANSI C
THIS FILE WAS GENERATED BY wbgen2 FROM SOURCE FILE pcs_regs.wb
......@@ -366,6 +366,29 @@
#define MDIO_WR_SPEC_BSLIDE_SHIFT 4
#define MDIO_WR_SPEC_BSLIDE_W(value) WBGEN2_GEN_WRITE(value, 4, 5)
#define MDIO_WR_SPEC_BSLIDE_R(reg) WBGEN2_GEN_READ(reg, 4, 5)
/* definitions for register: MDIO Extended Control Register */
/* definitions for field: Loopback - detailed in reg: MDIO Extended Control Register */
#define MDIO_ECTRL_LPBCK_VEC_MASK WBGEN2_GEN_MASK(0, 3)
#define MDIO_ECTRL_LPBCK_VEC_SHIFT 0
#define MDIO_ECTRL_LPBCK_VEC_W(value) WBGEN2_GEN_WRITE(value, 0, 3)
#define MDIO_ECTRL_LPBCK_VEC_R(reg) WBGEN2_GEN_READ(reg, 0, 3)
/* definitions for field: SFP TX Fault Status in reg: MDIO Extended Control Register */
#define MDIO_ECTRL_SFP_TX_FAULT WBGEN2_GEN_MASK(3, 1)
/* definitions for field: SFP LOS in reg: MDIO Extended Control Register */
#define MDIO_ECTRL_SFP_LOSS WBGEN2_GEN_MASK(4, 1)
/* definitions for field: SFP TX Disable in reg: MDIO Extended Control Register */
#define MDIO_ECTRL_SFP_TX_DISABLE WBGEN2_GEN_MASK(5, 1)
/* definitions for field: tx_prbs_sel in reg: MDIO Extended Control Register */
#define MDIO_ECTRL_TX_PRBS_SEL_MASK WBGEN2_GEN_MASK(8, 3)
#define MDIO_ECTRL_TX_PRBS_SEL_SHIFT 8
#define MDIO_ECTRL_TX_PRBS_SEL_W(value) WBGEN2_GEN_WRITE(value, 8, 3)
#define MDIO_ECTRL_TX_PRBS_SEL_R(reg) WBGEN2_GEN_READ(reg, 8, 3)
/* [0x0]: REG MDIO Control Register */
#define MDIO_REG_MCR 0x00000000
/* [0x4]: REG MDIO Status Register */
......@@ -384,4 +407,6 @@
#define MDIO_REG_ESTATUS 0x0000003c
/* [0x40]: REG WhiteRabbit-specific Configuration Register */
#define MDIO_REG_WR_SPEC 0x00000040
/* [0x44]: REG MDIO Extended Control Register */
#define MDIO_REG_ECTRL 0x00000044
#endif
......@@ -22,11 +22,13 @@
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <wrc.h>
#include "shell.h"
#include "storage.h"
#include "syscon.h"
#include "endpoint.h"
#include "sfp.h"
......@@ -107,6 +109,10 @@ static int cmd_sfp(const char *args[])
} else
mprintf("Could not match to DB\n");
return 0;
} else if (args[0] && !strcasecmp(args[0], "ena")) {
if(!args[1])
return -EINVAL;
ep_sfp_enable(atoi(args[1]));
}
return 0;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment