You've already forked gitified_old_clb_svn
95 lines
2.1 KiB
C
Executable File
95 lines
2.1 KiB
C
Executable File
/*
|
|
Command to write into the wishbone registers and to disable the auto-negotiation.
|
|
*/
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
#include <wrc.h>
|
|
|
|
#include "softpll_ng.h"
|
|
#include "shell.h"
|
|
#include "onewire.h"
|
|
#include "endpoint.h"
|
|
|
|
#include <hw/endpoint_regs.h>
|
|
#include <hw/endpoint_mdio.h>
|
|
|
|
const char *shw_2binary(uint8_t x)
|
|
{
|
|
static char b[9];
|
|
int z;
|
|
char *p=b;
|
|
|
|
for (z=0x80; z > 0; z >>= 1)
|
|
{
|
|
*p++=(((x & z) == z) ? '1' : '0');
|
|
}
|
|
*p='\0';
|
|
|
|
return b;
|
|
}
|
|
|
|
|
|
static int cmd_autoneg(const char *args[])
|
|
{
|
|
char *b;
|
|
|
|
//mprintf("Command to disable/enable the auto-negotiation \n");
|
|
|
|
//read from the Status Register (MSR)
|
|
uint16_t reg_msr = pcs_read(MDIO_REG_MSR);
|
|
mprintf("\n");
|
|
mprintf("MDIO Status Resgister is: %08x \n", reg_msr);
|
|
mprintf("En bin :\n");
|
|
b=shw_2binary((uint8_t)(reg_msr>8));
|
|
mprintf("%s\n",b);
|
|
b=shw_2binary((uint8_t)(reg_msr>>0));
|
|
mprintf("%s\n",b);
|
|
|
|
if(!strcasecmp(args[0], "disable"))
|
|
{
|
|
//Unidirectional enable and AN disable, in MCR.
|
|
uint16_t valor=0x0160; //0x1140 by default
|
|
pcs_write(MDIO_REG_MCR, valor);
|
|
}
|
|
else if(!strcasecmp(args[0], "enable"))
|
|
{
|
|
//Unidirectional disable and AN enable, in MCR.
|
|
uint16_t valor=0x1140; //0x1140 by default
|
|
pcs_write(MDIO_REG_MCR, valor);
|
|
} else {
|
|
if(((uint16_t)pcs_read(MDIO_REG_MCR) & (0x1000))) {
|
|
mprintf("Autonegotiation enabled\n");
|
|
}
|
|
else {
|
|
mprintf("Autonegotiation disabled\n");
|
|
}
|
|
mprintf("autoneg <option>\n");
|
|
mprintf(" disable\n");
|
|
mprintf(" enable\n");
|
|
}
|
|
|
|
//Reading from the Control Register (MCR)
|
|
uint16_t reg_mcr = pcs_read(MDIO_REG_MCR);
|
|
mprintf("\n");
|
|
mprintf("MDIO Control Resgister es: %08x \n", reg_mcr);
|
|
mprintf("En bin :\n");
|
|
|
|
b=shw_2binary((uint8_t)(reg_mcr>>8));
|
|
mprintf("%s\n",b);
|
|
b=shw_2binary((uint8_t)(reg_mcr>>0));
|
|
mprintf("%s\n",b);
|
|
|
|
if(((uint16_t)pcs_read(MDIO_REG_MCR) & (0x1000))) {
|
|
mprintf("Autonegotiation enabled\n");
|
|
}
|
|
else {
|
|
mprintf("Autonegotiation disabled\n");
|
|
}
|
|
}
|
|
|
|
DEFINE_WRC_COMMAND(autoneg) = {
|
|
.name = "autoneg",
|
|
.exec = cmd_autoneg,
|
|
};
|