Ejemplo n.º 1
0
static void pppoev6_mac6_stop_learning(void)
{
    /* do not disable this port if some other registers are already filled in
       to prevent setting conflict */
    int val = S17_P6PAD_MODE_REG_VALUE;

    if ( val != (1<<24))
    {
        aos_printk("%s: MAC 6 already being used!\n", __FUNCTION__);
        return;
    }


    /* clear the MAC6 learning bit */
    athrs17_reg_write(0x6a8, athrs17_reg_read(0x6a8) & ~(1<<20));

    /* force loopback mode */
    athrs17_reg_write(0x94, 0x7e);
    athrs17_reg_write(0xb4, 0x10);
}
Ejemplo n.º 2
0
int do_ethreg (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
    int   rcode = 0;

    /*
     * We use the last specified parameters, unless new ones are
     * entered.
     */

    if ((flag & CMD_FLAG_REPEAT) == 0)
    {
        if (argc == 2) {
            reg = simple_strtoul(argv[1], NULL, 10);
            rcode = READ_MAC;
        }
        if (argc == 3) {
            reg = simple_strtoul(argv[1], NULL, 10);
            val = simple_strtoul(argv[2],NULL,10);
            rcode = WRITE_MAC;
        }
        if (argc == 4) {
            if(*argv[1] == 'p') {
                portnum = simple_strtoul(argv[2], NULL, 10);
                reg = simple_strtoul(argv[3],NULL,10);
                rcode = READ_PHY;
            }
            else
                return 1;
        }
        if (argc == 5) {
            if(*argv[1] == 'p') {
                portnum = simple_strtoul(argv[2], NULL, 10);
                reg = simple_strtoul(argv[3],NULL,10);
                val = simple_strtoul(argv[4],NULL,10);
                rcode = WRITE_PHY;
            }
            else
                return 1;
        }

        if ((argc > 4) && (argc < 2))
            return 1;
    }
#ifdef CONFIG_AR7242_S16_PHY
    if(rcode == READ_PHY) {
        rd_value = ag7240_miiphy_read("eth0",portnum,reg);
        printf("Read Reg: 0x%08x = 0x%08x\n",reg,rd_value);
    }
    else if(rcode == READ_MAC) {
        rd_value = athrs16_reg_read(reg);
        printf("Read Reg: 0x%08x = 0x%08x\n",reg,rd_value);
    }
    else if(rcode  == WRITE_PHY) {
        rd_value = ag7240_miiphy_read("eth0",portnum,reg);
        ag7240_miiphy_write("eth0",portnum,reg,val);
        printf("Write Reg: 0x%08x: Oldval = 0x%08x Newval = 0x%08x\n", reg, rd_value, val);
    }
    else if(rcode == WRITE_MAC) {
        rd_value = athrs16_reg_read(reg);
        athrs16_reg_write(reg,val);
        printf("Write Reg: 0x%08x: Oldval = 0x%08x Newval = 0x%08x\n", reg, rd_value, val);
    }
    else
        return 1;
#endif
#ifdef CFG_ATHRS26_PHY
    if(rcode == READ_PHY) {
        rd_value = s26_rd_phy(portnum,reg);
        printf("Read Reg: 0x%08x = 0x%08x\n",reg,rd_value);
    }
    else if(rcode == READ_MAC) {
        rd_value = athrs26_reg_read(reg);
        printf("Read Reg: 0x%08x = 0x%08x\n",reg,rd_value);
    }
    else if(rcode  == WRITE_PHY) {
        rd_value = s26_rd_phy(portnum,reg);
        s26_wr_phy(portnum,reg,val);
        printf("Write Reg: 0x%08x: Oldval = 0x%08x Newval = 0x%08x\n", reg, rd_value, val);
    }
    else if(rcode == WRITE_MAC) {
        rd_value = athrs26_reg_read(reg);
        athrs26_reg_write(reg,val);
        printf("Write Reg: 0x%08x: Oldval = 0x%08x Newval = 0x%08x\n", reg, rd_value, val);
    }
    else
        return 1;
#endif
#ifdef CFG_ATHRS27_PHY
    if(rcode == READ_PHY) {
        rd_value = s27_rd_phy(portnum,reg);
        printf("Read Reg: 0x%08x = 0x%08x\n",reg,rd_value);
    }
    else if(rcode == READ_MAC) {
        rd_value = athrs27_reg_read(reg);
        printf("Read Reg: 0x%08x = 0x%08x\n",reg,rd_value);
    }
    else if(rcode  == WRITE_PHY) {
        rd_value = s27_rd_phy(portnum,reg);
        s27_wr_phy(portnum,reg,val);
        printf("Write Reg: 0x%08x: Oldval = 0x%08x Newval = 0x%08x\n", reg, rd_value, val);
    }
    else if(rcode == WRITE_MAC) {
        rd_value = athrs27_reg_read(reg);
        athrs27_reg_write(reg,val);
        printf("Write Reg: 0x%08x: Oldval = 0x%08x Newval = 0x%08x\n", reg, rd_value, val);
    }
    else
        return 1;
#endif

#ifdef CONFIG_F1E_PHY
    if(rcode == READ_PHY) {
        rd_value = f1e_rd_phy(portnum, reg);
        printf("Read Reg: 0x%08x = 0x%08x\n",reg,rd_value);
    }
    else if(rcode  == WRITE_PHY) {
        rd_value = f1e_rd_phy(portnum, reg);
        f1e_wr_phy(portnum, reg, val);
        printf("Write Reg: 0x%08x: Oldval = 0x%08x Newval = 0x%08x\n", reg, rd_value, val);
    }
    else
        return 1;
#endif

#ifdef CONFIG_ATHRS17_PHY
    if(rcode == READ_PHY) {
        rd_value = s17_rd_phy(portnum,reg);
        printf("Read Reg: 0x%08x = 0x%08x\n",reg,rd_value);
    }
    else if(rcode == READ_MAC) {
        rd_value = athrs17_reg_read(reg);
        printf("Read Reg: 0x%08x = 0x%08x\n",reg,rd_value);
    }
    else if(rcode  == WRITE_PHY) {
        rd_value = s17_rd_phy(portnum,reg);
        s17_wr_phy(portnum,reg,val);
        printf("Write Reg: 0x%08x: Oldval = 0x%08x Newval = 0x%08x\n", reg, rd_value, val);
    }
    else if(rcode == WRITE_MAC) {
        rd_value = athrs17_reg_read(reg);
        athrs17_reg_write(reg,val);
        printf("Write Reg: 0x%08x: Oldval = 0x%08x Newval = 0x%08x\n", reg, rd_value, val);
    }
    else
        return 1;
#endif

#ifdef CONFIG_ATHRS26E_PHY
    if(rcode == READ_PHY) {
        rd_value = s26e_rd_phy(portnum,reg);
        printf("Read Reg: 0x%08x = 0x%08x\n",reg,rd_value);
    }
    else if(rcode == READ_MAC) {
        rd_value = athrs26e_reg_read(reg);
        printf("Read Reg: 0x%08x = 0x%08x\n",reg,rd_value);
    }
    else if(rcode  == WRITE_PHY) {
        rd_value = s26e_rd_phy(portnum,reg);
        s26e_wr_phy(portnum,reg,val);
        printf("Write Reg: 0x%08x: Oldval = 0x%08x Newval = 0x%08x\n", reg, rd_value, val);
    }
    else if(rcode == WRITE_MAC) {
        rd_value = athrs26e_reg_read(reg);
        athrs26e_reg_write(reg,val);
        printf("Write Reg: 0x%08x: Oldval = 0x%08x Newval = 0x%08x\n", reg, rd_value, val);
    }
    else
        return 1;
#endif
    return 0;
}