/*
 *  internal_open - initialize Ethernet device
 */
int internal_open( bcm6352enet_softc *softc )
{
    int status;
    int i;
    unsigned char macAddr[ETH_ALEN];
    int dualMacMode = 0;

    /* figure out which chip we're running on */
    softc->chipId  = (INTC->RevID & 0xFFFF0000) >> 16;
    softc->chipRev = (INTC->RevID & 0xFF);

    /* print the ChipID and module version info */
    printf("Broadcom BCM%X%X Ethernet Network Device ", 
        softc->chipId, softc->chipRev);
    printf(VER_STR "\n");

    clear_bit(0, &softc->dualMacMode);

    /* read NVRam setting on route mode or switch mode */
    dualMacMode = nvramData.ulEnetModeFlag;

    if (dualMacMode == 1)
        set_bit(0, &softc->dualMacMode);

    printf("bcm6352Enet configure as %s mode\n",
        softc->dualMacMode ? "MAC Isolation" : "Switching");

    if( (status = bcm6352_init_dev(softc)) == 0 )
    {
        /* Read first MAC address.  Only use first MAC even if dual MAC is
         * configured.
         */
        macAddr[0] = 0xff;
        memcpy(macAddr, nvramData.ucaBaseMacAddr, sizeof(macAddr));

        if( macAddr[0] == 0xff )
            memcpy( macAddr, "\x00\x10\x18\x00\x00\x01", 6 );

        /* fill in the MAC address */
        for (i = 0; i < 6; i++)
            softc->macAddr[i] = macAddr[i];

        printf( "MAC Address: %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n",
            macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4],
            macAddr[5], macAddr[6], macAddr[7] );

        write_mac_address(softc);
    }

    return( status );
}
Example #2
0
int main(int argc, char *argv[])
{
	int ret;
	const char *system_mnt_point = SYSTEM_MNT_POINT;

	ret = mount_to(EMMC_DEVICE "p2", system_mnt_point, "ext4", NULL);
	if (ret < 0) {
		pr_err_info("mount system device");
		return ret;
	}

	ret = write_mac_address(EMMC_DEVICE, system_mnt_point);
	if (ret < 0) {
		pr_err_info("write mac address failed");
	}

	umount_directory2(system_mnt_point, MNT_DETACH);

	return ret;
}
/* --------------------------------------------------------------------------
    Name: bcm6352_enet_ioctl
 Purpose: I/O Control function.
-------------------------------------------------------------------------- */
static int bcm6352_enet_ioctl(cfe_devctx_t *ctx,iocb_buffer_t *buffer)
{
    bcm6352enet_softc *softc = (bcm6352enet_softc *) ctx->dev_softc;
    int retval = 0;

    switch( (int)buffer->buf_ioctlcmd ) {
        case IOCTL_ETHER_GETHWADDR:
            memcpy( buffer->buf_ptr, softc->macAddr, sizeof(softc->macAddr) );
            break;
        case IOCTL_ETHER_SETHWADDR:
            memcpy( softc->macAddr, buffer->buf_ptr, sizeof(softc->macAddr) );
            write_mac_address( softc );
            break;
        case IOCTL_ETHER_GETSPEED:
            xprintf( "BCM6352 : GETSPEED not implemented.\n" );
            retval = -1;
            break;
        case IOCTL_ETHER_SETSPEED:
            xprintf( "BCM6352 : SETSPEED not implemented.\n" );
            retval = -1;
            break;
        case IOCTL_ETHER_GETLINK:
            xprintf( "BCM6352 : GETLINK not implemented.\n" );
            retval = -1;
            break;
        case IOCTL_ETHER_GETLOOPBACK:
            xprintf( "BCM6352 : GETLOOPBACK not implemented.\n" );
            retval = -1;
            break;
        case IOCTL_ETHER_SETLOOPBACK:
            xprintf( "BCM6352 : SETLOOPBACK not implemented.\n" );
            retval = -1;
            break;
        default:
            xprintf( "Invalid IOCTL to bcm6352_enet_ioctl.\n" );
            retval = -1;
    }

    return retval;
}